A question about creating colliders. I would expect that a single collider can be used for multiple bodies. For example, when
initializing my app I create a collider made of 2 convex point clouds:
- Code: Select all
// build collider
colliderCount := 2;
colliderArray[0]:= NewtonCreateConvexHull( nWorld, mesh[0].vertexCount, @mesh[0].vertex[0][0], 12, mesh[0].localMatrix[0][0] );
colliderArray[1]:= NewtonCreateConvexHull( nWorld, mesh[1].vertexCount, @mesh[1].vertex[0][0], 12, mesh[1].localMatrix[0][0] );
staticData.nCollider := NewtonCreateCompoundCollision( nWorld, colliderCount, colliderArray );
Later on, I make use of this collider:
- Code: Select all
// build body
nCol := staticData.nCollider;
nBody := NewtonCreateBody( nWorld, nCol );
Everything goes ok for the first body. But when I use the same collider again for a second body it behaves strange. The body falls through the ground, it doesn't collide properly with other objects, it doesn't fall straight downwards, etcetera. As if its collision hull was messed up. However, if I draw the hulls with Newton's debug tools, the shapes are correct though.
The problem is solved when I rebuild the collider for every body again. But... do I really need to rebuild the collider each time again, or can I share a collider between multiple bodies and is there something I'm doing wrong now? By the way, the collider doesn't get released until the program ends.
Greetings,
Rick