I'm trying to scale btGImpactMeshShape instances.
A brief description of the application seems necessary. An user configures a display case by adding and moving several objects. The user moves just one selected object not a group of objects. The objects are scanned manually by the user (not a 3d engineer) and slightly simplified (around 100k triangles). The application uses collision detection for providing feedback to the user (red objects are inside other objects, blue objects are "flying"...).
An overview of the Bullet setup. For creating the static part I wire a btCollisionWorld, then wrap each unselected object mesh with a btGImpactMeshShape and add each btCollisionObject to the btCollisionWorld. The selected object is wrap with a btGImpactMeshShape but it isn't add to the btCollisionWorld and collisions are detected using the btCollisionWorld::contactTest method.
Code: Select all
class CollisionCallback : public btCollisionWorld::ContactResultCallback
{
int count;
public:
_rtguBulletCollisionCallback()
: count( 0 )
{
}
int getCount()
{
return count;
}
btScalar addSingleResult( btManifoldPoint&,
const btCollisionObject*, int, int,
const btCollisionObject*, int, int
)
{
count++;
return 0;
}
};
bool testCollitionObject( btCollisionWorld* collisionWorld, btCollisionObject* collisionObject )
{
CollisionCallback collisionCallback;
collisionWorld->contactTest( collisionObject, collisionCallback );
return collisionCallback.getCount() > 0;
}
Code: Select all
void moveCollisionObject( btCollisionObject* collisionObject, const btTransform& worldTransform, btScalar scaling )
{
btGImpactMeshShape* collisionShape = (btGImpactMeshShape*)collisionObject->getCollisionShape();
collisionShape->setLocalScaling( btVector3( scaling, scaling, scaling ) );
collisionShape->updateBound();
collisionObject->setWorldTransform( worldTransform );
}
* render display case and static objects;
* test collision (using testCollitionObject);
* render selected object;
* manipulate selected object using a gizmo;
* move object (using moveCollisionObject);
* loop again.
Translations and rotations and fine but scaling isn't. After debugging the whole thing from the application to bullet internals, I'm almost sure the selected object AABB is updated and also its TrimeshPrimitiveManager.
Any question and any help is welcome