btCompoundShape not working with dynamic aabb tree enabled
I noticed something weird with compound shapes, on PC, PlayStation Portable, PlayStation Vita I don't have any problem with compound shapes, but on PlayStation 3 it's not working well. (Using GCC 7.2 C++17 with the open source sdk, none of the PS3 specific code of bullet is used, PS3 defines used by bullet are no defined in my case, I'm not using the SPU).
Everything works fine when I'm doing this
compoundShape = new btCompoundShape(false);
but collisions are buggy with this instead
compoundShape = new btCompoundShape();
When I add children to the compound shape, looks like only the first (or last idk) added shape is affected by collisions, but other shapes do not collide with other objects of the scene.
Here is a sample, on PC the final Y position of the cube is 2, but on PS3 the final Y position is 1.
btDefaultCollisionConfiguration collisionConfig;
btCollisionDispatcher dispatcher(&collisionConfig);
btDbvtBroadphase broadphase;
btSequentialImpulseConstraintSolver solver;
btDiscreteDynamicsWorld world(&dispatcher, &broadphase, &solver, &collisionConfig);
world.setGravity(btVector3(0, -9.81, 0));
// Static ground
btCollisionShape* groundShape = new btBoxShape(btVector3(1, 1, 1));
btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 0, 0)));
btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(0, groundMotionState, groundShape, btVector3(0, 0, 0));
btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI);
world.addRigidBody(groundRigidBody);
btCompoundShape* compoundShape = new btCompoundShape();
// Add shapes to the compound shape
for (int i = 0; i < 2; ++i) {
btBoxShape* box = new btBoxShape(btVector3(1, 1, 1));
btTransform transform;
transform.setIdentity();
transform.setOrigin(btVector3(0, 1-i, 0));
compoundShape->addChildShape(transform, box);
}
btDefaultMotionState* compoundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 10, 0)));
btScalar mass = 5.0;
btVector3 inertia(0, 0, 0);
compoundShape->calculateLocalInertia(mass, inertia);
btRigidBody::btRigidBodyConstructionInfo compoundRigidBodyCI(mass, compoundMotionState, compoundShape, inertia);
btRigidBody* compoundRigidBody = new btRigidBody(compoundRigidBodyCI);
world.addRigidBody(compoundRigidBody);
// Simulation
for (int i = 0; i < 300; i++)
{
world.stepSimulation(1.f / 60.f, 10);
btTransform transform;
compoundRigidBody->getMotionState()->getWorldTransform(transform);
std::cout << "Step " << i << ": Position = "
<< transform.getOrigin().getX() << ", "
<< transform.getOrigin().getY() << ", "
<< transform.getOrigin().getZ() << std::endl;
}