Recalculate local origin of btCompoundShape?
Posted: Thu Feb 03, 2022 10:45 pm
Curious if there is a way to recalculate the local origin of a btCompoundShape? I currently have a shape consisting of two spheres and a cylinder, however the origin of the btCompoundShape seems to be the origin of one of it's child shapes and not the origin of the aabb for the compound shape.
Below is an image of the btPairCachingGhostObject which uses the btCompoundShape with it's origin set as follows (where y is up -z forward):
Below is how the btCompoundShape and btPairCachingGhostObject are being generated:
Below is an image of the btPairCachingGhostObject which uses the btCompoundShape with it's origin set as follows (where y is up -z forward):
Code: Select all
this->ghostObject->getWorldTransform().setOrigin(btVector3(2, 0, 0));Below is how the btCompoundShape and btPairCachingGhostObject are being generated:
Code: Select all
btCylinderShape* cyl = new btCylinderShape(btVector3(this->radius, (1.25f / 2.0f), this->radius));
btTransform cylTran;
cylTran.setIdentity();
cylTran.setOrigin(btVector3(0,0,0));
btSphereShape* sphereSmall = new btSphereShape(0.36f);
btTransform sphereSmallTran;
sphereSmallTran.setIdentity();
sphereSmallTran.setOrigin(btVector3(0, -0.77456, 0));
btSphereShape* blendSphere = new btSphereShape(0.4f);
btTransform blendSphereTran;
blendSphereTran.setIdentity();
blendSphereTran.setOrigin(btVector3(0, -0.62507, 0));
btCompoundShape* compoundShape = new btCompoundShape();
compoundShape->addChildShape(cylTran, cyl);
compoundShape->addChildShape(sphereSmallTran, sphereSmall);
compoundShape->addChildShape(blendSphereTran, blendSphere);
this->shape = compoundShape;
this->ghostObject = new btPairCachingGhostObject();
this->ghostObject->setCollisionShape(this->shape);
this->ghostObject->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
this->collisionWorld->getDynamicsWorld()->addCollisionObject(this->ghostObject, btBroadphaseProxy::KinematicFilter, btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter);
this->collisionWorld->getDynamicsWorld()->getPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
this->ghostObject->getWorldTransform().setOrigin(btVector3(2, 0, 0));