btQuantizedBvh serialization

Romain Daize
Posts: 15
Joined: Tue Jan 06, 2009 10:04 am

btQuantizedBvh serialization

Post by Romain Daize »

Hi all,

I'm currently testing the btQuantizedBvh serialization process and I have notice a small difference between the original btQuantizedBvh and the serialized one. In my case my original bvh has theses values :

m_curNodeIndex 231
m_quantizedContiguousNodes {m_allocator={...} m_size=232 m_capacity=232

If I serialize and deserialize it in another btQuantizedBvh, I get these values for the new bvh :

m_curNodeIndex 231
m_quantizedContiguousNodes {m_allocator={...} m_size=231 m_capacity=231

Finally, I had a look in serialization implementation and it seems that m_curNodeIndex is used as the count of quantizedContiguousNodes in serialization process :

int nodeCount = m_curNodeIndex;

if (m_useQuantization)
{
targetBvh->m_quantizedContiguousNodes.initializeFromBuffer(nodeData, nodeCount, nodeCount);
...

I would like to make sure that everything is ok here. Why the serialized bvh is not exactly the same as the original one ? Is this done on purpose ? Small optimization ?
Notice that calculateSerializeBufferSize is well synchronized with this implementation. I would like to make sure that runtime methods won't patch any invalid memory location or else and that everything is safe with the new generated bvh.

PS : I'm using Bullet 2.74.

Thanks a lot.

Romain
slithEToves
Posts: 24
Joined: Mon Mar 12, 2007 9:55 pm

Re: btQuantizedBvh serialization

Post by slithEToves »

The original allocator was resized 1 larger than it needed to be, and the iteration/recursion on the tree was limited by m_curNodeIndex rather than by the array size, so the extra slot was not necessary in the serialized data.
Romain Daize
Posts: 15
Joined: Tue Jan 06, 2009 10:04 am

Re: btQuantizedBvh serialization

Post by Romain Daize »

Nice, thanks a lot for the answer.