btTriangleMeshShape construction calculates aabb

Post Reply
reltham
Posts: 66
Joined: Fri Oct 12, 2007 6:28 pm
Location: San Diego

btTriangleMeshShape construction calculates aabb

Post by reltham »

Currently constructing a btTriangleMeshShape (or in my case a btBvhTriangleMeshShape that is dirived from one), it does a caclulation of the aabb that is pretty expensive. It would be really nice if we could provide an aabb thru the btStridingMeshInterface that would could calculate offline.

Do you see a problem with this?

I am going to work on implementing the change, and submitting a patch to you. Please let me know if there is something I should be aware of regarding this change. Thanks

Roy
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: btTriangleMeshShape construction calculates aabb

Post by Erwin Coumans »

Good point.

The btBvhTriangleMeshShape already has one constructor that takes a local bvhAabbMin and bvhAabbMax. We can add an additional constructor to btTriangleMeshShape that takes those bvhAabbMin/bvhAabbMax, instead of recalculating it.

Code: Select all

btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,bool buildBvh)
If you have a patch, please create an issue at googlecode issue tracker.
Thanks for the feedback,
Erwin
reltham
Posts: 66
Joined: Fri Oct 12, 2007 6:28 pm
Location: San Diego

Re: btTriangleMeshShape construction calculates aabb

Post by reltham »

In my case I have an already calculated aabb in my data. I want to feed that in, and use it instead of letting bullet do any calculation of it.

I am in the process of changing btStridingMeshInterface, btTriangleIndexVertexArray, btTriangMeshShape, btBvhTriangleMeshShape.

My solution was to make it so that you could set an premade aabb onto the btTriangleIndexVertexArray, and if you did then it would be used by the btTriangleMeshShape and/or btBvhTriangleMeshShape. If you don't then it does the calculation as before.

The added API to btStridingMeshInterface/btTriangleIndexVertexArray is:

bool hasPremadeAabb()
void setPremadeAabb(const btVector3& aabbMin, const btVector& aabbMax)
void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax)

Also, there is now added storage of the aabb in btTrianleIndexVertexArray.

Once I have test it out properly, I will submit a patch on the google issue tracker thing.

Roy
reltham
Posts: 66
Joined: Fri Oct 12, 2007 6:28 pm
Location: San Diego

Re: btTriangleMeshShape construction calculates aabb

Post by reltham »

Added issue #70 with an attach zip contained the changed files.

Roy
Post Reply