I'm using Ammo.js with the Goo webGL engine, and I'm working on trying to get triggers implemented, but I'm having some struggle finding a 'good' way to handle collision separation.
Here is a jsFiddle which shows how to handle collision starting:
I'm also planning to implement a 'callback' type thing like this:
So when one object collides with another, it will pass in some collision info.
The problem I am having, is figuring out a good way to handle the separation, when the two previously colliding objects are no longer colliding.
Supposedly, there are gContactProcessed and gContactDestroyed callbacks which I could tap into, but I don't think these are currently possible.
http://www.bulletphysics.org/mediawiki-1.5.8/index.php?title=Collision_Callbacks_and_Triggers
So I'm reaching out, before I start from scratch creating my own functionality, to see how other people have handled this.
Here is my main idea:
1. Have a map of collisions.
2. At the start of each pass, set a boolean value for all current collisions to false.
3. The fist time a collision is added to the map, trigger the onCollisionBegin callback, with the data from the collision.
4. During the collision check, if two objects are still colliding, set their boolean value to true.
5. For each collision in the map, if their boolean value is still false, trigger the onCollisionEnd callback and remove it from the map.
Does something like this seem good? Are there any current implementations of Ammo.js with collision separation mechanics that I can look at?
Thank you in advance!