diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2010-02-04 00:20:06 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2010-02-04 00:20:06 +0300 |
commit | ec5788925c305b062ae28bc55c72699e30257b9a (patch) | |
tree | 40aed37418636f69c900b4a35bf675dc627d2691 /extern/bullet2/src/BulletCollision/CollisionShapes | |
parent | b6c643c19f83248eb8100e2e5bc7eeb9bd262a09 (diff) |
Add btBvhTriangleMeshShape::buildOptimizedBvh() in preparation of next commit. This patch has been approved already and will be in Bullet 2.76.
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes')
-rw-r--r-- | extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp | 42 | ||||
-rw-r--r-- | extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h | 2 |
2 files changed, 19 insertions, 25 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp index 68ff5e2d7bb..4d350196943 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp @@ -30,22 +30,9 @@ m_ownsBvh(false) //construct bvh from meshInterface #ifndef DISABLE_BVH - btVector3 bvhAabbMin,bvhAabbMax; - if(meshInterface->hasPremadeAabb()) - { - meshInterface->getPremadeAabb(&bvhAabbMin, &bvhAabbMax); - } - else - { - meshInterface->calculateAabbBruteForce(bvhAabbMin,bvhAabbMax); - } - if (buildBvh) { - void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16); - m_bvh = new (mem) btOptimizedBvh(); - m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax); - m_ownsBvh = true; + buildOptimizedBvh(); } #endif //DISABLE_BVH @@ -343,20 +330,25 @@ void btBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling) if ((getLocalScaling() -scaling).length2() > SIMD_EPSILON) { btTriangleMeshShape::setLocalScaling(scaling); - if (m_ownsBvh) - { - m_bvh->~btOptimizedBvh(); - btAlignedFree(m_bvh); - } - ///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work - void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16); - m_bvh = new(mem) btOptimizedBvh(); - //rebuild the bvh... - m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax); - m_ownsBvh = true; + buildOptimizedBvh(); } } +void btBvhTriangleMeshShape::buildOptimizedBvh() +{ + if (m_ownsBvh) + { + m_bvh->~btOptimizedBvh(); + btAlignedFree(m_bvh); + } + ///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work + void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16); + m_bvh = new(mem) btOptimizedBvh(); + //rebuild the bvh... + m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax); + m_ownsBvh = true; +} + void btBvhTriangleMeshShape::setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& scaling) { btAssert(!m_bvh); diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h index cb2c326574e..ab54bd1a1ed 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h @@ -76,6 +76,8 @@ public: void setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1)); + void buildOptimizedBvh(); + bool usesQuantizedAabbCompression() const { return m_useQuantizedAabbCompression; |