Fracture Demo child Transform question

Post Reply
itchyfingerz
Posts: 2
Joined: Wed May 03, 2017 2:00 pm

Fracture Demo child Transform question

Post by itchyfingerz »

I am trying to build the fracture Demo with my own rendering system, the problem I am having is that I cannot find the child transforms of each fractureBody within m_fractureBodies in btFractureDynamicsWorld.cpp. There are a total of 10 boxes but the
m_dynamicsWorld->getCollisionObjectArray().at(i)->getWorldTransform() call will only give me one transform of what seems to be the center of the compound shape for the object that will be fractured. For instance before the 1st fracture there are 10 boxes and 2 boxes on the ground, however I am only given a total of 3 transforms which doesn't represent the correct structure. The 10 boxes are all rendered at the same location.
then at the end of simulation there are 5 transforms. 3 of which seem specify the center of the new fractured compound shape with 2 representing the boxes on the ground.

How can I draw all 10 boxes of the fracture shape correctly at the start and during the simulation? am I missing a call or are there offsets located somewhere or should I manually recalculate the new object's compound shapes with using the size, center of mass and rotation of the compound shapes? I was hoping that information was somewhere and I overlooked it in the simulation and objects..
ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: Fracture Demo child Transform question

Post by ktfh »

you probably want to grab the compound collision shape for the object and iterate over its children.

Code: Select all

if(fractureObject->getCollisionShape()->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) {
    btCompoundShape* compoundShape = (btCompoundShape*)fractureObject->getCollisionShape();
    for(int i = compoundShape->getNumChildShapes() -1; i >= 0; i--) {
        btTransform location = fractureObject->getWorldTransform() * compoundShape->getChildTransform(i);
        // draw shapes visual here
    }
}
itchyfingerz
Posts: 2
Joined: Wed May 03, 2017 2:00 pm

Re: Fracture Demo child Transform question

Post by itchyfingerz »

Thank you, I love you man.
Post Reply