Questions about serialization and contact query

Post Reply
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Questions about serialization and contact query

Post by Flix »

Some quick questions about recent Bullet features:

Serialization:
1) I've seen that it's possible to serialize/deserialize objects to/from memory. Based on this, is there some robust code snippet around to clone physic bodies?
2) Is it complete ? (i.e. can I serialize/deserialize all kind of constraints, raycast vehicles and so on?)
3) Is it easy to extend? (i.e. if I derive from btRigidBody, or I use a has-it approach, and I want to serialize/deserialize my class, what must I do?)

Queries:
4) What is the difference between using a ghostObject/pairCachingGhostObject and using aabbTest/contactTest queries?
(I suppose that ghost objects have their manifold points refreshed automatically every physic frame by Bullet, even if the user don't need to use them that often, and contact queries must be used "on the fly". Is it correct?)

Thank everybody in advance for your answers.
Flix.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Questions about serialization and contact query

Post by Erwin Coumans »

Flix wrote:Some quick questions about recent Bullet features:

Serialization:
1) I've seen that it's possible to serialize/deserialize objects to/from memory. Based on this, is there some robust code snippet around to clone physic bodies?
No replication is supported, there are no 'deSerialize' methods for all classes yet.
2) Is it complete ? (i.e. can I serialize/deserialize all kind of constraints, raycast vehicles and so on?)
Although most important structures are covered, it is not 100% complete. Most collision shape types and constraints are supported, but btRayCastVehicle not yet.
3) Is it easy to extend? (i.e. if I derive from btRigidBody, or I use a has-it approach, and I want to serialize/deserialize my class, what must I do?)
You can extend the binary file format in several ways. I added some documentation in the wiki here: http://bulletphysics.org/mediawiki-1.5. ... ialization

Please try it and ask here if you get stuck.
Queries:
4) What is the difference between using a ghostObject/pairCachingGhostObject and using aabbTest/contactTest queries?
(I suppose that ghost objects have their manifold points refreshed automatically every physic frame by Bullet, even if the user don't need to use them that often, and contact queries must be used "on the fly". Is it correct?)
The most important difference is that aabbTest/contactTest has to calculate the overlapping AABB's and contact information from scratch, while the btGhostObject approach is incremental (it only computes changes). So if there are a lot of objects in the world, and you can keep a btGhostObject in a given location for a longer period of time, it could be more efficient. In other words, it doesn't make sense to insert a btGhostObject only a single frame, or moving it around a lot, in that case a aabbTest/contactTest is more suitable.

The difference might be not so big anymore, because Bullet uses the btDbvtBroadphase for a fast O(log n) search. Also the btAxisSweep3 uses this optional dynamic btDbvt acceleration stucture by default (as long as you don't disable the 'disableRaycastAccelerator')

Thanks,
Erwin
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Questions about serialization and contact query

Post by Flix »

Thanks for all your clarifications.
Flix.
Post Reply