I was wondering if there was a way to detect collisions between more than 2 bodies at once? I can get the collisions between a body and a material just fine, or a body with 1 other body, fine. But I was wondering if there was another way. I thought the collision detection worked like this:
1.) Set up bodies + materials, apply materials to bodies.
2.) Call NDB_NewtonMaterialSetCollisionCallback(mat1,mat2) (!!!)
3.) On every frame (or whenever) of the simulation, check either NDB_GetCollisionBodyToBody or NDB_GetCollisionBodyToMaterial.
Now, I thought you used ~BodyToBody and ~BodyToMaterial to retrieve an
index to the collision # that is the collision of the body in question (the one passed as a parameter in ~BodyToBody and ~BodyToMaterial). With that index, you can then use NDB_GetCollisionBody() or GetCollisionData to get the more detailed information pertaining to that particular collision.
So this implies that for each frame (after NetwonUpdate, I presume), whatever collisions are present are stored. This makes sense because on any particular frame, there could be many or more than 1 collision happening concurrently. And this seems to work when calling GetCollisionBody() or GetCollisionData using the index; the index references a certain collision (the one you're checking for, or 0).
So, the only way I've seen to check for collisions between objects is with NDB_GetCollisionBodyToBody, which can only check for collision between 2 bodies. Doing this, you'd have to make 1 check for every other object. With 50 objects, that's 49 checks for every 1 object, = 2950 checks, once per loop! I tried it and it obviously can't be the way to do it, my program can't even run with that kind of bog in the loop.
I thought I could trick it by using the same material as the objects were made of, but no go, it didn't work to detect its own material. I was hoping there was a way to detect the collisions between all objects much like it works when using the material method; all the collisions that are present on the current frame are indexed, and all you have to do is retrieve the index to the collision in question, if present. Is there a correct way to go about this?
http://www.geocities.com/crmnlelmnt/