Page 1 of 1

btBvhTriangleMeshShape and btTriangleInfoMap serialization

Posted: Thu Jul 26, 2012 10:13 am
by DavidM
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

Re: btBvhTriangleMeshShape and btTriangleInfoMap serializati

Posted: Wed Oct 17, 2012 4:36 pm
by VicariousEnt
I re-enabled that code as well and have had no problems with it thus far. Not sure why it was removed either. I still need to add the InternalEdgeInfo, good to know about that problem.

Re: btBvhTriangleMeshShape and btTriangleInfoMap serializati

Posted: Wed Oct 17, 2012 6:40 pm
by Erwin Coumans
The latest trunk, and Bullet 2.81 release enables the import/deserialization of the BVH, see
http://code.google.com/p/bullet/source/ ... porter.cpp

We still need to fix the btTriangleInfoMap /btHashMap serialization indeed.
If you have a fix, can you contribute it to this issue?
https://code.google.com/p/bullet/issues/detail?id=353

Thanks,
Erwin