oguzeroglu/Nearby

How is collision response determined in the demos?

notchris opened this issue · 1 comments

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!

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:

  1. Get the objects nearby (from the start and the end point of the ray)
  2. Draw an imaginary line segment representing the ray
  3. For each nearby object: Check if this line intersects the face of the object.