Godlike / Pegasus

Game physics engine (can fly)
MIT License
6 stars 2 forks source link

Add interface for contact processing #121

Open MrDmitry opened 6 years ago

MrDmitry commented 6 years ago

Current state

All contacts are detected and resolved locally within Pegasus. There is pegasus::Debug::s_collisionDetectionCall callback hook allowing user code to process detected contacts for debug purposes only

Use case

Trigger some events upon any contact selected Primitive is a part of. Examples:

  1. play some sound whenever Primitive collides with anything
  2. create particle effect whenever Primitive collides with anything

Points to consider

Meta information regarding collision can also be interesting. Not only Primitive handles that are in contact, but also calculations about their collision. Example: relative velocities can be used to determine the volume of the sound or amount of particle effects.


I will test existing pegasus::Debug::s_collisionDetectionCall callback to see how handy this model would be if this information was exposed via some public interface as opposed to debug hook. Ultimately triggers/logic based on these contacts is inside user code so as long as traversing contact collection does not result in some huge overhead, it would be a viable solution.

Sidenotes: