btBvhTriangleMeshShape and btTriangleInfoMap serialization
Posted: Thu Jul 26, 2012 10:13 am
We've just started using Bullet recently and as part of our build process we create a single btBvhTriangleMeshShape to represent the static part of our 'world'. At this point we also create a btTriangleInfoMap and use btGenerateInternalEdgeInfo() to generate the data for the internal edge utility to prevent collision with internal triangle edges at runtime.
These are then serialized out and loaded at runtime using the btBulletWorldImporter.
I've found a couple of problems with this, firstly btTriangleInfoMap doesn't serialize properly. It's derived from btHashMap and the hash map implementation uses the capacity of one of it's members. This capacity gets changed when you serialize it out (it gets trimmed to the size of the array) and so none of the hashes match up anymore. I've fixed this locally by adding a trim function to the hashmap and calling that before serializing it in the btTriangleInfoMap, but it's a problem with any btHashMap serialization.
The second issue is that in btBulletWorldImporter the code that deserializes btOptimizedBVH is #if 0'ed out, so instead of using the bvh that's been stored a new one is generated at runtime. I've put it back in and not had any obvious issues, but I guess there was a reason for removing it - does anyone know why?
We're using Bullet 2.80-rev2531
These are then serialized out and loaded at runtime using the btBulletWorldImporter.
I've found a couple of problems with this, firstly btTriangleInfoMap doesn't serialize properly. It's derived from btHashMap and the hash map implementation uses the capacity of one of it's members. This capacity gets changed when you serialize it out (it gets trimmed to the size of the array) and so none of the hashes match up anymore. I've fixed this locally by adding a trim function to the hashmap and calling that before serializing it in the btTriangleInfoMap, but it's a problem with any btHashMap serialization.
The second issue is that in btBulletWorldImporter the code that deserializes btOptimizedBVH is #if 0'ed out, so instead of using the bvh that's been stored a new one is generated at runtime. I've put it back in and not had any obvious issues, but I guess there was a reason for removing it - does anyone know why?
We're using Bullet 2.80-rev2531