No hit/collision on convexSweepTest using btBulletWorldImporter
Posted: Wed Sep 08, 2021 10:28 pm
Still new to Bullet Physics here. I was able to successfully do a discrete collision detection using a static triangle mesh against a collision object with shapes loaded from a .bcs file using btBulletWorldImporter. But that is not good enough for our application so now I'm giving CCD a try using sweep test. I was able to use btCollisionWorld::convexSweepTest on a simple sphere against my triangle mesh and got collision detected at the correct coordinate. But when loading collision shape from .bcs file, no collision got detected even though the object travels on the same vector as the simple sphere through my trianglemesh. I checked it also visually using debugDrawWorld.
I compared the difference between the simple sphere vs the loaded shape and found that when loading the shape, the collision shape type is int 31 vs. int 8 for simple sphere.
and so this line of code in btGjkPairDetector.cpp returns a very low negative number (don't make sense)
Is it bad to cast btCollisionShape to btConvexShape? What's the correct way to use convexSweepTest with .bcs file?
Code: Select all
btCollisionShape* collisionCheck::loadBCS(const char* filename, bool verbose) {
btBulletWorldImporter loader(0);//don't store info into the world
loader.setVerboseMode(verbose);
if (!loader.loadFile(filename)) return NULL;
btCollisionShape* shape = NULL;
if (loader.getNumCollisionShapes()>0) shape = loader.getCollisionShapeByIndex(0);
return shape;
}
Code: Select all
MyContactResultCallback crCallback;
btCollisionShape* shapeA= loadBCS("Models/Excalibur2_ABAxis.bcs");
btConvexShape* myCS= static_cast<btConvexShape*>(shapeA);
prevPtA.setOrigin(btVector3(-100, -200, -500));
btPtA.setOrigin(btVector3(-500, -200, -500));
if (prevPtA.getOrigin() != btPtA.getOrigin())
dynamicsWorld->convexSweepTest(myCS, prevPtA, btPtA, crCallback);
if (crCallback.hasHit()) {
cout << "Got a hit!";
}
I compared the difference between the simple sphere vs the loaded shape and found that when loading the shape, the collision shape type is int 31 vs. int 8 for simple sphere.
and so this line of code in btGjkPairDetector.cpp returns a very low negative number (don't make sense)
Code: Select all
btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA);
Is it bad to cast btCollisionShape to btConvexShape? What's the correct way to use convexSweepTest with .bcs file?