This is a ray cast algorithm that uses ray marching. It repeatedly calculates the distance to the nearest obstacle then takes a step of that length. When the distance to the nearest obstacle is 0 it has hit its target! The code includes signed distance functions for circles, axis-aligned rectangles, and capsules.
leifekstromclark / ray-marching-and-signed-distance Goto Github PK
View Code? Open in Web Editor NEWRay marching algorithm for ray casts. Implemented in Pygame.