Problems when adding collisionshapes to compound shape

Hello.



I’m adding multiple instances of one collision-shape to a compound collision shape. Each instance has its own location, rotation and scale. To do that i create transformation objects first:



Matrix3f rotation

Vector3f location

Vector3f scale



When they are prepared, I do this:





CollisionShape cShape = “The collision shape being duplicated”

for( number of iterations ){

// set scale, rotation, location for this instance





cShape.setScale(scale);

compoundShape.addChildShape( location, rotation, cShape);

}





This works well for position and rotation. If i use constant scale, the models will fit the collision shapes perfectly. Scale does not work tho.



Does anyone know if it’s possible to do something about this? I guess the problem has to be all child collision shapes has different rotation and location, but references the same scale vector?



In CompoundCollisionShape I find two methods, addChildShape(location,cShape) and the one with rotation used above, but none for scale.

The scale is specific to one collision shape object so you have to create a new one.

Hmm I guess if that’s the case, maybe it’s better to generate a collision shape from the batched geometry directly, rather then doing what I do now.

Yeah, just make sure they are not spanning the whole map, else the broadphase is pretty much useless for the trees.

1 Like