btBvhTriangleMeshShape::partialRefitTree with smaller aabb?

pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

btBvhTriangleMeshShape::partialRefitTree with smaller aabb?

Post by pico »

Hi,

i use "btBvhTriangleMeshShape::refitTree" to refit a changed triangle mesh. This works fine.
However, when using "btBvhTriangleMeshShape::partialRefitTree" i get an assertion for the new aaBBs.

The ASSERT code looks like its not allowed to refit a region that is smaller then the before region?!
Is this the case?

--------------------
void btOptimizedBvh::refitPartial(btStridingMeshInterface* meshInterface,const btVector3& aabbMin,const btVector3& aabbMax)
{
//incrementally initialize quantization values
btAssert(m_useQuantization);

btAssert(aabbMin.getX() > m_bvhAabbMin.getX());
btAssert(aabbMin.getY() > m_bvhAabbMin.getY());
btAssert(aabbMin.getZ() > m_bvhAabbMin.getZ());

btAssert(aabbMax.getX() < m_bvhAabbMax.getX());
btAssert(aabbMax.getY() < m_bvhAabbMax.getY());
btAssert(aabbMax.getZ() < m_bvhAabbMax.getZ());
--------------------

Thanks for your help
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btBvhTriangleMeshShape::partialRefitTree with smaller aabb?

Post by Erwin Coumans »

The partial update requires an aabb that totally fits within the original full AABB of the triangle mesh. This means you have to provide a bigger AABB when creating the btBvhTriangleMeshShape, that encapsulated the total future deformation.

For example, say the mesh will deform 100 units maximum in the Y direction, then just add 10 units to the bvhAabbMin/bvhAabbMax during construction. It is safe to add some additional deformation extents, but keep it reasonable. Don't just add 100000 units, the trianglemesh/BVH performance will degrade dramatically due to lossy quantization. You can calculate the local aabb from the mesh using:
btVector3 bvhAabbMin,bvhAabbMax;
btVector3 additionalDeformationExtents(0,100,0);
meshInterface->calculateAabbBruteForce(bvhAabbMin,bvhAabbMax);
bvhAabbMin -= additionalDeformationExtents;
bvhAabbMax += additionalDeformationExtents
And make sure to use the right constructor, that passes in the bvhAabbMin/max:
btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true);
Hope this helps,
Erwin