How is collision response determined in the demos?
notchris opened this issue · 1 comments
notchris commented
Hello! Awesome library, excited to try it out. Wondering how you deal with player -> wall / objects collisions in the demos. Does nearby determine which bin to do a raycast check on, then the physics engine is constrained to a loop on only those objects? Thanks!
oguzeroglu commented
Hey, thank you!
Raycasting is out of the scope of this project. This is the Raycaster class of the engine that takes care of it.
How you use Nearby to improve raycasting is that, you first do a Nearby query to get the nearby objects, then you perform a ray test only on them, rather than every other object of the scene. Needles to say this dramatically improves the performance.
ROYGBIV engine handles collisions with these steps:
- Get the objects nearby (from the start and the end point of the ray)
- Draw an imaginary line segment representing the ray
- For each nearby object: Check if this line intersects the face of the object.