Collision causes "pure virtual method called" crash

sizeak
Posts: 8
Joined: Thu Jan 07, 2010 6:39 pm

Collision causes "pure virtual method called" crash

Post by sizeak »

I just added a falling sphere from the hello world demo to my world and when it collides with the ground ( a btBvhTriangleMeshShape with info: btRigidBody::btRigidBodyConstructionInfo TempRigidBodyCI(0,TempMotionState,model->getCollisionShape(),btVector3(0.0f, 0.0f, 0.0f));), the program crashes with this error:

"pure virtual method called

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information."

I'm working with positive gravity because for reasons I haven't yet looked into, my world is upside down :S

Heres my init code:

Code: Select all

void Scene::physicsInit()
{
	maxRigidBodies = 1024; //maybe this should be in the scene file instead
	btVector3 worldAabbMin(-10000, -10000, -10000); //world size for broadphase.
	btVector3 worldAabbMax(10000, 10000, 10000);	//should probs be loaded from scene file to
	broadphase = new btAxisSweep3(worldAabbMin, worldAabbMax, (unsigned short)maxRigidBodies);
	//m_overlappingPairCache = broadphase;
	collisionConfig = new btDefaultCollisionConfiguration();
	dispatcher = new btCollisionDispatcher(collisionConfig);
	solver = new btSequentialImpulseConstraintSolver;
	dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfig);
	dynamicsWorld->setGravity(btVector3(0.0f, 1.0f, 0.0f));
}
sphere init:

Code: Select all

void Scene::addTestCol()
{
	btCollisionShape* fallShape = new btSphereShape(1);
	btDefaultMotionState* fallMotionState =
                new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,-100,0)));
	btScalar mass = 0.11;
	btVector3 fallInertia(0,0,0);
	fallShape->calculateLocalInertia(mass,fallInertia);
	btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass,fallMotionState,fallShape,fallInertia);
	fallRigidBody = new btRigidBody(fallRigidBodyCI);
	dynamicsWorld->addRigidBody(fallRigidBody);
}
getting its position:

Code: Select all

cnVertex Scene::getTestPos()
{	std::cout << "Activation state: " << fallRigidBody->isInWorld() << std::endl;
	btTransform trans;
	fallRigidBody->getMotionState()->getWorldTransform(trans);
	std::cout << "sphere height: " << trans.getOrigin().getY() << std::endl;
	
	cnVertex temp;
	temp.x = trans.getOrigin().getX();
	temp.y = trans.getOrigin().getY();
	temp.z = trans.getOrigin().getZ();
	
	return temp;
}
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision causes "pure virtual method called" crash

Post by Erwin Coumans »

It sounds like you are having build system issues. Are you using Visual Studio?

Try the following:
  • Do a full rebuild (clean all)
  • Don't link against the precompiled Bullet .lib files, but include the Bullet project files or directly all files from the Bullet/src folder directly in your project solution.
  • Make sure all the projects use the same settings, in particular MSVC/Project Settings/C++/Code Generation/Run-time library needs to be the same for all projects
  • Compare the projects with the Bullet demos (either from Bullet/msvc folder or autogenerated using cmake)
Thanks,
Erwin
vahidb
Posts: 1
Joined: Mon Apr 18, 2011 5:37 pm

Re: Collision causes "pure virtual method called" crash

Post by vahidb »

Hi, I have a same problem with Bullet 2.78 , i used ODE 0.11.1 for dynamics.

unfortunately, Solution in last post not worked.

Error appear when execute mCollisionWorld->performDiscreteCollisionDetection(); that mCollisionWorld is Object of CollitionWorld class.

When i get break point error rreach me to this line of class: dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache->getOverlappingPairCache(),dispatchInfo,m_dispatcher1);

it say a pure virtual call happend!!

EDit1: Problem Solved. Thanks

//...................b2CollisionWorld....................................
void btCollisionWorld::performDiscreteCollisionDetection()
{
BT_PROFILE("performDiscreteCollisionDetection");

btDispatcherInfo& dispatchInfo = getDispatchInfo();

updateAabbs();

{
BT_PROFILE("calculateOverlappingPairs");
m_broadphasePairCache->calculateOverlappingPairs(m_dispatcher1);
}


btDispatcher* dispatcher = getDispatcher();
{
BT_PROFILE("dispatchAllCollisionPairs");
if (dispatcher)
dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache->getOverlappingPairCache(),dispatchInfo,m_dispatcher1);
}

}