Page 1 of 1

Re: Serializing Multiple Bullet Objects

Posted: Mon Sep 13, 2010 2:03 am
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

Re: Serializing Multiple Bullet Objects

Posted: Mon Sep 13, 2010 12:51 pm
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