Serializing Multiple Bullet Objects

Post Reply
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Serializing Multiple Bullet Objects

Post by Erwin Coumans »

The serialization support multiple objects and multiple constaints. It is not clear what is going wrong. Serializing using unique names for bodies/shapes should work fine.
It is recommended that you don't use the serializeSingleObject but use the btDynamicsWorld::serialize instead:

Code: Select all

	//create a large enough buffer. There is no method to pre-calculate the buffer size yet.
	int maxSerializeBufferSize = 1024*1024*5;
 
	btDefaultSerializer*	serializer = new btDefaultSerializer(maxSerializeBufferSize);
	dynamicsWorld->serialize(serializer);
 
	FILE* file = fopen("testFile.bullet","wb");
	fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
	fclose(file);
See also http://bulletphysics.org/mediawiki-1.5. ... ialization

Note that while running most of the (unmodified) Bullet demos, you can press '=' key to serialize to a .bullet file, named "test.bullet". It will serialize all objects and constraints in the dynamics world. Some collision shapes are not supported yet (btHeightfieldTerrainShape for example).

Thanks,
Erwin
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Serializing Multiple Bullet Objects

Post by Erwin Coumans »

Code: Select all

	char* serialName = new char[8];
The serialName is shared and overwritten for all bodies/shapes. This is not OK because there is no copy made, so during btDynamicsWorld::serialize, all bodies will have the same name.

Try allocating a name for each body/shape dynamically and don't share the memory.

Thanks,
Erwin
Post Reply