Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Coumans <blender@erwincoumans.com>2007-06-23 09:28:07 +0400
committerErwin Coumans <blender@erwincoumans.com>2007-06-23 09:28:07 +0400
commitca26aeb7b23e37e65f49d907ea53fcaeee77ad4e (patch)
treeb6530195a8ef5d874b9fc2bbb9574f1484781be5 /extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
parent14ad8c9941ac1e6f5252a843c6ad17653cbbd689 (diff)
upgrade to latest Bullet 2.53. cross the fingers it doesn't break one of the exotic or less exotic platforms
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp')
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp58
1 files changed, 47 insertions, 11 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
index 3bd0a317545..8da554ef14d 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
@@ -18,21 +18,53 @@ subject to the following restrictions:
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btOptimizedBvh.h"
+
///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization.
///Uses an interface to access the triangles to allow for sharing graphics/physics triangles.
-btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface)
-:btTriangleMeshShape(meshInterface)
+btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression)
+:btTriangleMeshShape(meshInterface),m_useQuantizedAabbCompression(useQuantizedAabbCompression)
{
//construct bvh from meshInterface
#ifndef DISABLE_BVH
m_bvh = new btOptimizedBvh();
- m_bvh->build(meshInterface);
+ btVector3 bvhAabbMin,bvhAabbMax;
+ meshInterface->calculateAabbBruteForce(bvhAabbMin,bvhAabbMax);
+ m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax);
#endif //DISABLE_BVH
}
+btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax)
+:btTriangleMeshShape(meshInterface),m_useQuantizedAabbCompression(useQuantizedAabbCompression)
+{
+ //construct bvh from meshInterface
+#ifndef DISABLE_BVH
+
+ m_bvh = new btOptimizedBvh();
+ m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax);
+
+#endif //DISABLE_BVH
+
+}
+
+void btBvhTriangleMeshShape::partialRefitTree(const btVector3& aabbMin,const btVector3& aabbMax)
+{
+ m_bvh->refitPartial( m_meshInterface,aabbMin,aabbMax );
+
+ m_localAabbMin.setMin(aabbMin);
+ m_localAabbMax.setMax(aabbMax);
+}
+
+
+void btBvhTriangleMeshShape::refitTree()
+{
+ m_bvh->refit( m_meshInterface );
+
+ recalcLocalAabb();
+}
+
btBvhTriangleMeshShape::~btBvhTriangleMeshShape()
{
delete m_bvh;
@@ -63,7 +95,7 @@ void btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,co
{
}
- virtual void processNode(const btOptimizedBvhNode* node)
+ virtual void processNode(int nodeSubPart, int nodeTriangleIndex)
{
const unsigned char *vertexbase;
int numverts;
@@ -84,19 +116,21 @@ void btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,co
indexstride,
numfaces,
indicestype,
- node->m_subPart);
+ nodeSubPart);
- int* gfxbase = (int*)(indexbase+node->m_triangleIndex*indexstride);
-
+ int* gfxbase = (int*)(indexbase+nodeTriangleIndex*indexstride);
+
const btVector3& meshScaling = m_meshInterface->getScaling();
for (int j=2;j>=0;j--)
{
int graphicsindex = gfxbase[j];
+
+
#ifdef DEBUG_TRIANGLE_MESH
printf("%d ,",graphicsindex);
#endif //DEBUG_TRIANGLE_MESH
- float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
+ btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
m_triangle[j] = btVector3(
graphicsbase[0]*meshScaling.getX(),
@@ -107,8 +141,8 @@ void btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,co
#endif //DEBUG_TRIANGLE_MESH
}
- m_callback->processTriangle(m_triangle,node->m_subPart,node->m_triangleIndex);
- m_meshInterface->unLockReadOnlyVertexBase(node->m_subPart);
+ m_callback->processTriangle(m_triangle,nodeSubPart,nodeTriangleIndex);
+ m_meshInterface->unLockReadOnlyVertexBase(nodeSubPart);
}
};
@@ -130,8 +164,10 @@ void btBvhTriangleMeshShape::setLocalScaling(const btVector3& scaling)
{
btTriangleMeshShape::setLocalScaling(scaling);
delete m_bvh;
+ ///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work
m_bvh = new btOptimizedBvh();
- m_bvh->build(m_meshInterface);
//rebuild the bvh...
+ m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax);
+
}
}