"Assertion failed" when calling addRigidBody(..)

Ipredlol
Posts: 8
Joined: Fri Mar 11, 2011 6:23 pm

"Assertion failed" when calling addRigidBody(..)

Post by Ipredlol »

Hi,

I am at the moment trying to write a very basic program to learn how btBulletWorldImporter works, in the program I try to use it to load a .bullet model and then create/add the body to the dynamicsWorld:

Code: Select all

btBroadphaseInterface* broadphase = new btDbvtBroadphase();
	btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
    btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
    btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
    dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
	dynamicsWorld->setGravity(btVector3(0,-10,0));

	
	btBulletWorldImporter* fileLoader = new btBulletWorldImporter(dynamicsWorld);
	fileLoader->loadFile("myShape.bullet");
	btScalar mass = 1;
	btCollisionShape* shape = new btBoxShape(btVector3(0,1,0));
	char name = 'A';

	btRigidBody* body = fileLoader->createRigidBody(false,mass,btTransform(btQuaternion(0,0,0,1),btVector3(0,50,0)),shape,&name);
	int body_count = fileLoader->getNumRigidBodies();
	dynamicsWorld->addRigidBody(body);
//If I comment the last line, I'd get body_count=1. 
but now I have spent the whole day staring at

Code: Select all

Assertion failed: m_collisionObjects.findLinearSearch<collisionObject> == m_collisionObjects.size<>, file ..\..\..\..\src\BulletCollision\CollisionDispatch\btCollisionWorld.cpp, line 114
and repeatly googling "Bullet Physics load .bullet model" or similiar.
I 'd appreciate it if somebody could help me understand what I am doing wrong here!

Thanks a lot in advance and happy weekend! :)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: "Assertion failed" when calling addRigidBody(..)

Post by Erwin Coumans »

How did you save/create the .bullet file?

The btBulletWOrldImporter can only load files that are created using the btDiscreteDynamicsWorld::serialize method
(either manually or using the Maya Dynamica plugin, Cinema 4D, Blender etc)

Thanks,
Erwin
Ipredlol
Posts: 8
Joined: Fri Mar 11, 2011 6:23 pm

Re: "Assertion failed" when calling addRigidBody(..)

Post by Ipredlol »

Thank you for your quick reply!

I took the .bullet file which was imported and used in a demo called "ConcaveDemo" and the file is located in the root directory of Bullet where you can find a whole bunch of runnable applications of the Bullet demos.

But even if btBulletWorldImporter can only load certain files, why would the body_count be 1 after calling "fileLoader->createRigidBody(...)" ? Or maybe it just created an "empty" rigid body with nothing in it(since btBulletWorldImporter can't read the file), thus the assertion failed?

Thank you!