CollisionDetection with CompoundShape and GImpactMeshShape

koenigderfischer
Posts: 2
Joined: Tue Mar 23, 2010 3:26 pm

CollisionDetection with CompoundShape and GImpactMeshShape

Post by koenigderfischer »

Hi,
in my java application i have several objects which consist of several meshes.
So I wanted to test if there is a collision between the objects.
I use the java port of the bulletengine.
Now I have a problem with the collision detection, because the
collision algorithm compares some AABB which cant be correct.

For every object I use a compound shape where I add the meshes as children.
The meshes are from the type GImpactMeshShape (dont know if this
is the correct way)
Every mesh gets as child shape of the compound shape a transformation.
This is in my case the relative translation to the whole object.

Then I create a rigid body with this compound shape and the world translation added.

When it comes to getCollisionWorld().performDiscreteCollisionDetection();
I debugged down to a method called gimpact_vs_concave in GImpactCollisionAlgorithm.class
In this method the world transform of one body (which is the correct transformation)
is put into a Transform object called gimpactInConcaveSpace. Then the inverse is
taken and then it is multiplied with the worldTransform of the other rigidbody.
(dont know why this is done)

then the AABB from one shape is taken and transformed by the above mentioned transform object
and all Triangles of the other shape are processed in a processAllTriangles method.

When I look in this method the AABB of the current mesh part is in for example a range from
minAABB(-2,-2,-2) and maxAABB(2,2,2)) which seems to be correct values which has been set in the beginning
for the transformation of a single mesh. But then this AABB is compared with the other AABB which has been inverted and
multiplied which has a range for example minAABB(-1000,1000,-11500) and maxAABB(-800,1000,-1200).
As you can see though the objects are at the same place they dont collide. The values of the AABB are in very different ranges. And I dont know why. Maybe I made a mistake when adding it to the compound shape.
But it looks strange too me that an inverse and multiplied world transformation is compared with the aabb which is not inverted and not multiplied and no transformation is applied.

Maybe someone understood what I said and sees a point where I got wrong.

Greetings
Flo
koenigderfischer
Posts: 2
Joined: Tue Mar 23, 2010 3:26 pm

Re: CollisionDetection with CompoundShape and GImpactMeshShape

Post by koenigderfischer »

Hi,

the problem was due to I had scale values in my world transformation of the rigid body.
After I put it into the setLocalScaling of the collisionshape it worked.

Greetings

Flo