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:
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes')
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h36
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp58
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h7
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp3
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.h6
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.cpp10
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.h15
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp65
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.h26
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h10
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp6
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h3
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp45
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.h42
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp5
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.h11
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp156
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.h96
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp361
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h26
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp18
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h10
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.cpp2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.h6
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.cpp3
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h6
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp251
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h108
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp10
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp3
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h1
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h11
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp26
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp5
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h25
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp11
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h7
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.cpp6
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.h9
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp3
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h5
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h23
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.cpp35
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.h21
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp4
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h8
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp1
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp52
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h8
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp5
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h17
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.cpp3
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.h1
56 files changed, 1285 insertions, 412 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h
index 4d4fbefea37..14502d485dc 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h
@@ -19,7 +19,7 @@ subject to the following restrictions:
#include "btPolyhedralConvexShape.h"
#include "btCollisionMargin.h"
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
-#include "LinearMath/btPoint3.h"
+#include "LinearMath/btVector3.h"
#include "LinearMath/btMinMax.h"
///The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by half extents, in local shape coordinates. When used as part of a btCollisionObject or btRigidBody it will be an oriented box in world space.
@@ -45,8 +45,6 @@ public:
}
- virtual int getShapeType() const { return BOX_SHAPE_PROXYTYPE;}
-
virtual btVector3 localGetSupportingVertex(const btVector3& vec) const
{
btVector3 halfExtents = getHalfExtentsWithoutMargin();
@@ -82,8 +80,10 @@ public:
}
- btBoxShape( const btVector3& boxHalfExtents)
+ btBoxShape( const btVector3& boxHalfExtents)
+ : btPolyhedralConvexShape()
{
+ m_shapeType = BOX_SHAPE_PROXYTYPE;
btVector3 margin(getMargin(),getMargin(),getMargin());
m_implicitShapeDimensions = (boxHalfExtents * m_localScaling) - margin;
};
@@ -117,7 +117,7 @@ public:
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
- virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const
+ virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const
{
//this plane might not be aligned...
btVector4 plane ;
@@ -161,36 +161,30 @@ public:
switch (i)
{
case 0:
- plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
- plane[3] = -halfExtents.x();
+ plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.),-halfExtents.x());
break;
case 1:
- plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
- plane[3] = -halfExtents.x();
+ plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.),-halfExtents.x());
break;
case 2:
- plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
- plane[3] = -halfExtents.y();
+ plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.),-halfExtents.y());
break;
case 3:
- plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
- plane[3] = -halfExtents.y();
+ plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.),-halfExtents.y());
break;
case 4:
- plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
- plane[3] = -halfExtents.z();
+ plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.),-halfExtents.z());
break;
case 5:
- plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
- plane[3] = -halfExtents.z();
+ plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z());
break;
default:
- assert(0);
+ btAssert(0);
}
}
- virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const
+ virtual void getEdge(int i,btVector3& pa,btVector3& pb) const
//virtual void getEdge(int i,Edge& edge) const
{
int edgeVert0 = 0;
@@ -261,7 +255,7 @@ public:
- virtual bool isInside(const btPoint3& pt,btScalar tolerance) const
+ virtual bool isInside(const btVector3& pt,btScalar tolerance) const
{
btVector3 halfExtents = getHalfExtentsWithoutMargin();
@@ -312,7 +306,7 @@ public:
penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
break;
default:
- assert(0);
+ btAssert(0);
}
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
index 819f6f7f97d..68ff5e2d7bb 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
@@ -26,6 +26,7 @@ m_bvh(0),
m_useQuantizedAabbCompression(useQuantizedAabbCompression),
m_ownsBvh(false)
{
+ m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;
//construct bvh from meshInterface
#ifndef DISABLE_BVH
@@ -57,6 +58,7 @@ m_bvh(0),
m_useQuantizedAabbCompression(useQuantizedAabbCompression),
m_ownsBvh(false)
{
+ m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;
//construct bvh from meshInterface
#ifndef DISABLE_BVH
@@ -141,10 +143,19 @@ void btBvhTriangleMeshShape::performRaycast (btTriangleCallback* callback, const
for (int j=2;j>=0;j--)
{
int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
-
- btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
-
- m_triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
+
+ if (type == PHY_FLOAT)
+ {
+ float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
+
+ m_triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
+ }
+ else
+ {
+ double* graphicsbase = (double*)(vertexbase+graphicsindex*stride);
+
+ m_triangle[j] = btVector3(btScalar(graphicsbase[0])*meshScaling.getX(),btScalar(graphicsbase[1])*meshScaling.getY(),btScalar(graphicsbase[2])*meshScaling.getZ());
+ }
}
/* Perform ray vs. triangle collision here */
@@ -202,9 +213,18 @@ void btBvhTriangleMeshShape::performConvexcast (btTriangleCallback* callback, co
{
int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
- btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
-
- m_triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
+ if (type == PHY_FLOAT)
+ {
+ float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
+
+ m_triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
+ }
+ else
+ {
+ double* graphicsbase = (double*)(vertexbase+graphicsindex*stride);
+
+ m_triangle[j] = btVector3(btScalar(graphicsbase[0])*meshScaling.getX(),btScalar(graphicsbase[1])*meshScaling.getY(),btScalar(graphicsbase[2])*meshScaling.getZ());
+ }
}
/* Perform ray vs. triangle collision here */
@@ -279,12 +299,24 @@ void btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,co
#ifdef DEBUG_TRIANGLE_MESH
printf("%d ,",graphicsindex);
#endif //DEBUG_TRIANGLE_MESH
- btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
-
- m_triangle[j] = btVector3(
- graphicsbase[0]*meshScaling.getX(),
- graphicsbase[1]*meshScaling.getY(),
- graphicsbase[2]*meshScaling.getZ());
+ if (type == PHY_FLOAT)
+ {
+ float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
+
+ m_triangle[j] = btVector3(
+ graphicsbase[0]*meshScaling.getX(),
+ graphicsbase[1]*meshScaling.getY(),
+ graphicsbase[2]*meshScaling.getZ());
+ }
+ else
+ {
+ double* graphicsbase = (double*)(vertexbase+graphicsindex*stride);
+
+ m_triangle[j] = btVector3(
+ btScalar(graphicsbase[0])*meshScaling.getX(),
+ btScalar(graphicsbase[1])*meshScaling.getY(),
+ btScalar(graphicsbase[2])*meshScaling.getZ());
+ }
#ifdef DEBUG_TRIANGLE_MESH
printf("triangle vertices:%f,%f,%f\n",triangle[j].x(),triangle[j].y(),triangle[j].z());
#endif //DEBUG_TRIANGLE_MESH
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h
index 6e587340dc1..cb2c326574e 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h
@@ -37,7 +37,7 @@ public:
BT_DECLARE_ALIGNED_ALLOCATOR();
- btBvhTriangleMeshShape() :btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {};
+ btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};
btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb
@@ -50,10 +50,7 @@ public:
return m_ownsBvh;
}
- virtual int getShapeType() const
- {
- return TRIANGLE_MESH_SHAPE_PROXYTYPE;
- }
+
void performRaycast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget);
void performConvexcast (btTriangleCallback* callback, const btVector3& boxSource, const btVector3& boxTarget, const btVector3& boxMin, const btVector3& boxMax);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp
index 26ba276b900..60a96a542f9 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp
@@ -19,8 +19,9 @@ subject to the following restrictions:
#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
#include "LinearMath/btQuaternion.h"
-btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height)
+btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInternalShape ()
{
+ m_shapeType = CAPSULE_SHAPE_PROXYTYPE;
m_upAxis = 1;
m_implicitShapeDimensions.setValue(radius,0.5f*height,radius);
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.h
index d4b046d40c9..828c1b3a565 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.h
@@ -30,7 +30,7 @@ protected:
protected:
///only used for btCapsuleShapeZ and btCapsuleShapeX subclasses.
- btCapsuleShape() {};
+ btCapsuleShape() : btConvexInternalShape() {m_shapeType = CAPSULE_SHAPE_PROXYTYPE;};
public:
btCapsuleShape(btScalar radius,btScalar height);
@@ -43,15 +43,13 @@ public:
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
- virtual int getShapeType() const { return CAPSULE_SHAPE_PROXYTYPE; }
-
virtual void getAabb (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
{
btVector3 halfExtents(getRadius(),getRadius(),getRadius());
halfExtents[m_upAxis] = getRadius() + getHalfHeight();
halfExtents += btVector3(getMargin(),getMargin(),getMargin());
btMatrix3x3 abs_b = t.getBasis().absolute();
- btPoint3 center = t.getOrigin();
+ btVector3 center = t.getOrigin();
btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));
aabbMin = center - extent;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.cpp
index 39e621aa946..d242cba1b72 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.cpp
@@ -16,6 +16,9 @@ subject to the following restrictions:
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
+btScalar gContactThresholdFactor=btScalar(0.02);
+
+
/*
Make sure this dummy function never changes so that it
can be used by probes that are checking whether the
@@ -42,8 +45,13 @@ void btCollisionShape::getBoundingSphere(btVector3& center,btScalar& radius) con
center = (aabbMin+aabbMax)*btScalar(0.5);
}
+btScalar btCollisionShape::getContactBreakingThreshold() const
+{
+ return getAngularMotionDisc() * gContactThresholdFactor;
+}
btScalar btCollisionShape::getAngularMotionDisc() const
{
+ ///@todo cache this value, to improve performance
btVector3 center;
btScalar disc;
getBoundingSphere(center,disc);
@@ -65,7 +73,7 @@ void btCollisionShape::calculateTemporalAabb(const btTransform& curTrans,const b
// add linear motion
btVector3 linMotion = linvel*timeStep;
- //todo: simd would have a vector max/min operation, instead of per-element access
+ ///@todo: simd would have a vector max/min operation, instead of per-element access
if (linMotion.x() > btScalar(0.))
temporalAabbMaxx += linMotion.x();
else
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.h
index 3a352b90777..1f4b9bec647 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCollisionShape.h
@@ -19,20 +19,21 @@ subject to the following restrictions:
#include "LinearMath/btTransform.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btMatrix3x3.h"
-#include "LinearMath/btPoint3.h"
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types
///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects.
class btCollisionShape
{
-
+protected:
+ int m_shapeType;
void* m_userPointer;
public:
- btCollisionShape() : m_userPointer(0)
+ btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0)
{
}
+
virtual ~btCollisionShape()
{
}
@@ -45,6 +46,8 @@ public:
///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations.
virtual btScalar getAngularMotionDisc() const;
+ virtual btScalar getContactBreakingThreshold() const;
+
///calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep)
///result is conservative
@@ -76,7 +79,7 @@ public:
return btBroadphaseProxy::isInfinite(getShapeType());
}
- virtual int getShapeType() const=0;
+
virtual void setLocalScaling(const btVector3& scaling) =0;
virtual const btVector3& getLocalScaling() const =0;
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const = 0;
@@ -87,13 +90,13 @@ public:
#endif //__SPU__
-
+ int getShapeType() const { return m_shapeType; }
virtual void setMargin(btScalar margin) = 0;
virtual btScalar getMargin() const = 0;
///optional user data pointer
- void setUserPointer(void* userPtr)
+ void setUserPointer(void* userPtr)
{
m_userPointer = userPtr;
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
index 997361a5069..9c2b04d18fa 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
@@ -17,16 +17,22 @@ subject to the following restrictions:
#include "btCollisionShape.h"
#include "BulletCollision/BroadphaseCollision/btDbvt.h"
-btCompoundShape::btCompoundShape()
-:m_localAabbMin(btScalar(1e30),btScalar(1e30),btScalar(1e30)),
+btCompoundShape::btCompoundShape(bool enableDynamicAabbTree)
+: m_localAabbMin(btScalar(1e30),btScalar(1e30),btScalar(1e30)),
m_localAabbMax(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)),
m_collisionMargin(btScalar(0.)),
m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
-m_dynamicAabbTree(0)
+m_dynamicAabbTree(0),
+m_updateRevision(1)
{
- void* mem = btAlignedAlloc(sizeof(btDbvt),16);
- m_dynamicAabbTree = new(mem) btDbvt();
- btAssert(mem==m_dynamicAabbTree);
+ m_shapeType = COMPOUND_SHAPE_PROXYTYPE;
+
+ if (enableDynamicAabbTree)
+ {
+ void* mem = btAlignedAlloc(sizeof(btDbvt),16);
+ m_dynamicAabbTree = new(mem) btDbvt();
+ btAssert(mem==m_dynamicAabbTree);
+ }
}
@@ -41,6 +47,7 @@ btCompoundShape::~btCompoundShape()
void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape)
{
+ m_updateRevision++;
//m_childTransforms.push_back(localTransform);
//m_childShapes.push_back(shape);
btCompoundShapeChild child;
@@ -49,6 +56,7 @@ void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisio
child.m_childShapeType = shape->getShapeType();
child.m_childMargin = shape->getMargin();
+
//extend the local aabbMin/aabbMax
btVector3 localAabbMin,localAabbMax;
shape->getAabb(localTransform,localAabbMin,localAabbMax);
@@ -72,10 +80,29 @@ void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisio
}
m_children.push_back(child);
+
+}
+
+void btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform)
+{
+ m_children[childIndex].m_transform = newChildTransform;
+
+ if (m_dynamicAabbTree)
+ {
+ ///update the dynamic aabb tree
+ btVector3 localAabbMin,localAabbMax;
+ m_children[childIndex].m_childShape->getAabb(newChildTransform,localAabbMin,localAabbMax);
+ ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
+ int index = m_children.size()-1;
+ m_dynamicAabbTree->update(m_children[childIndex].m_node,bounds);
+ }
+
+ recalculateLocalAabb();
}
void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
{
+ m_updateRevision++;
btAssert(childShapeIndex >=0 && childShapeIndex < m_children.size());
if (m_dynamicAabbTree)
{
@@ -86,8 +113,11 @@ void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
}
+
+
void btCompoundShape::removeChildShape(btCollisionShape* shape)
{
+ m_updateRevision++;
// Find the children containing the shape specified, and remove those children.
//note: there might be multiple children using the same shape!
for(int i = m_children.size()-1; i >= 0 ; i--)
@@ -97,6 +127,8 @@ void btCompoundShape::removeChildShape(btCollisionShape* shape)
m_children.swap(i,m_children.size()-1);
m_children.pop_back();
//remove it from the m_dynamicAabbTree too
+ //@todo: this leads to problems due to caching in the btCompoundCollisionAlgorithm
+ //so effectively, removeChildShape is broken at the moment
//m_dynamicAabbTree->remove(m_aabbProxies[i]);
//m_aabbProxies.swap(i,m_children.size()-1);
//m_aabbProxies.pop_back();
@@ -112,6 +144,7 @@ void btCompoundShape::recalculateLocalAabb()
{
// Recalculate the local aabb
// Brute force, it iterates over all the shapes left.
+
m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
@@ -134,19 +167,27 @@ void btCompoundShape::recalculateLocalAabb()
void btCompoundShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
{
btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
- localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
+
+ //avoid an illegal AABB when there are no children
+ if (!m_children.size())
+ {
+ localHalfExtents.setValue(0,0,0);
+ localCenter.setValue(0,0,0);
+ }
+ localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
+
btMatrix3x3 abs_b = trans.getBasis().absolute();
- btPoint3 center = trans(localCenter);
+ btVector3 center = trans(localCenter);
btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
abs_b[1].dot(localHalfExtents),
abs_b[2].dot(localHalfExtents));
aabbMin = center-extent;
aabbMax = center+extent;
-
+
}
void btCompoundShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
@@ -178,7 +219,9 @@ void btCompoundShape::calculatePrincipalAxisTransform(btScalar* masses, btTransf
btScalar totalMass = 0;
btVector3 center(0, 0, 0);
- for (int k = 0; k < n; k++)
+ int k;
+
+ for (k = 0; k < n; k++)
{
center += m_children[k].m_transform.getOrigin() * masses[k];
totalMass += masses[k];
@@ -187,7 +230,7 @@ void btCompoundShape::calculatePrincipalAxisTransform(btScalar* masses, btTransf
principal.setOrigin(center);
btMatrix3x3 tensor(0, 0, 0, 0, 0, 0, 0, 0, 0);
- for (int k = 0; k < n; k++)
+ for ( k = 0; k < n; k++)
{
btVector3 i;
m_children[k].m_childShape->calculateLocalInertia(masses[k], i);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.h
index 3624749f768..434860c8633 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.h
@@ -46,23 +46,26 @@ SIMD_FORCE_INLINE bool operator==(const btCompoundShapeChild& c1, const btCompou
c1.m_childMargin == c2.m_childMargin );
}
-/// btCompoundShape allows to store multiple other btCollisionShapes
+/// The btCompoundShape allows to store multiple other btCollisionShapes
/// This allows for moving concave collision objects. This is more general then the static concave btBvhTriangleMeshShape.
+/// It has an (optional) dynamic aabb tree to accelerate early rejection tests.
+/// @todo: This aabb tree can also be use to speed up ray tests on btCompoundShape, see http://code.google.com/p/bullet/issues/detail?id=25
+/// Currently, removal of child shapes is only supported when disabling the aabb tree (pass 'false' in the constructor of btCompoundShape)
ATTRIBUTE_ALIGNED16(class) btCompoundShape : public btCollisionShape
{
- //btAlignedObjectArray<btTransform> m_childTransforms;
- //btAlignedObjectArray<btCollisionShape*> m_childShapes;
btAlignedObjectArray<btCompoundShapeChild> m_children;
btVector3 m_localAabbMin;
btVector3 m_localAabbMax;
- //btOptimizedBvh* m_aabbTree;
btDbvt* m_dynamicAabbTree;
+ ///increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated
+ int m_updateRevision;
+
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
- btCompoundShape();
+ btCompoundShape(bool enableDynamicAabbTree = true);
virtual ~btCompoundShape();
@@ -88,15 +91,18 @@ public:
return m_children[index].m_childShape;
}
- btTransform getChildTransform(int index)
+ btTransform& getChildTransform(int index)
{
return m_children[index].m_transform;
}
- const btTransform getChildTransform(int index) const
+ const btTransform& getChildTransform(int index) const
{
return m_children[index].m_transform;
}
+ ///set a new transform for a child, and update internal data structures (local aabb and dynamic tree)
+ void updateChildTransform(int childIndex, const btTransform& newChildTransform);
+
btCompoundShapeChild* getChildList()
{
@@ -121,8 +127,6 @@ public:
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
- virtual int getShapeType() const { return COMPOUND_SHAPE_PROXYTYPE;}
-
virtual void setMargin(btScalar margin)
{
m_collisionMargin = margin;
@@ -151,6 +155,10 @@ public:
///of the collision object by the principal transform.
void calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const;
+ int getUpdateRevision() const
+ {
+ return m_updateRevision;
+ }
private:
btScalar m_collisionMargin;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h
index f3f57206ab7..30065d55a12 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h
@@ -20,6 +20,16 @@ subject to the following restrictions:
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
#include "btTriangleCallback.h"
+/// PHY_ScalarType enumerates possible scalar types.
+/// See the btStridingMeshInterface or btHeightfieldTerrainShape for its use
+typedef enum PHY_ScalarType {
+ PHY_FLOAT,
+ PHY_DOUBLE,
+ PHY_INTEGER,
+ PHY_SHORT,
+ PHY_FIXEDPOINT88,
+ PHY_UCHAR
+} PHY_ScalarType;
///The btConcaveShape class provides an interface for non-moving (static) concave shapes.
///It has been implemented by the btStaticPlaneShape, btBvhTriangleMeshShape and btHeightfieldTerrainShape.
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
index 207b3024bc3..d887be61ada 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
@@ -14,14 +14,14 @@ subject to the following restrictions:
*/
#include "btConeShape.h"
-#include "LinearMath/btPoint3.h"
-btConeShape::btConeShape (btScalar radius,btScalar height):
+btConeShape::btConeShape (btScalar radius,btScalar height): btConvexInternalShape (),
m_radius (radius),
m_height(height)
{
+ m_shapeType = CONE_SHAPE_PROXYTYPE;
setConeUpIndex(1);
btVector3 halfExtents;
m_sinAngle = (m_radius / btSqrt(m_radius * m_radius + m_height * m_height));
@@ -60,7 +60,7 @@ void btConeShape::setConeUpIndex(int upIndex)
m_coneIndices[2] = 1;
break;
default:
- assert(0);
+ btAssert(0);
};
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h
index 685369742e4..1869893f37a 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h
@@ -69,9 +69,6 @@ public:
}
-
- virtual int getShapeType() const { return CONE_SHAPE_PROXYTYPE; }
-
virtual const char* getName()const
{
return "Cone";
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp
index 2596858bc3a..2b067367767 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp
@@ -19,16 +19,17 @@ subject to the following restrictions:
-btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride)
+btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexShape ()
{
- m_points.resize(numPoints);
+ m_shapeType = CONVEX_HULL_SHAPE_PROXYTYPE;
+ m_unscaledPoints.resize(numPoints);
unsigned char* pointsBaseAddress = (unsigned char*)points;
for (int i=0;i<numPoints;i++)
{
- btPoint3* point = (btPoint3*)(pointsBaseAddress + i*stride);
- m_points[i] = point[0];
+ btVector3* point = (btVector3*)(pointsBaseAddress + i*stride);
+ m_unscaledPoints[i] = point[0];
}
recalcLocalAabb();
@@ -43,9 +44,9 @@ void btConvexHullShape::setLocalScaling(const btVector3& scaling)
recalcLocalAabb();
}
-void btConvexHullShape::addPoint(const btPoint3& point)
+void btConvexHullShape::addPoint(const btVector3& point)
{
- m_points.push_back(point);
+ m_unscaledPoints.push_back(point);
recalcLocalAabb();
}
@@ -67,9 +68,9 @@ btVector3 btConvexHullShape::localGetSupportingVertexWithoutMargin(const btVecto
}
- for (int i=0;i<m_points.size();i++)
+ for (int i=0;i<m_unscaledPoints.size();i++)
{
- btPoint3 vtx = m_points[i] * m_localScaling;
+ btVector3 vtx = m_unscaledPoints[i] * m_localScaling;
newDot = vec.dot(vtx);
if (newDot > maxDot)
@@ -91,9 +92,9 @@ void btConvexHullShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const
supportVerticesOut[i][3] = btScalar(-1e30);
}
}
- for (int i=0;i<m_points.size();i++)
+ for (int i=0;i<m_unscaledPoints.size();i++)
{
- btPoint3 vtx = m_points[i] * m_localScaling;
+ btVector3 vtx = getScaledPoint(i);
for (int j=0;j<numVectors;j++)
{
@@ -144,26 +145,26 @@ btVector3 btConvexHullShape::localGetSupportingVertex(const btVector3& vec)const
//Please note that you can debug-draw btConvexHullShape with the Raytracer Demo
int btConvexHullShape::getNumVertices() const
{
- return m_points.size();
+ return m_unscaledPoints.size();
}
int btConvexHullShape::getNumEdges() const
{
- return m_points.size();
+ return m_unscaledPoints.size();
}
-void btConvexHullShape::getEdge(int i,btPoint3& pa,btPoint3& pb) const
+void btConvexHullShape::getEdge(int i,btVector3& pa,btVector3& pb) const
{
- int index0 = i%m_points.size();
- int index1 = (i+1)%m_points.size();
- pa = m_points[index0]*m_localScaling;
- pb = m_points[index1]*m_localScaling;
+ int index0 = i%m_unscaledPoints.size();
+ int index1 = (i+1)%m_unscaledPoints.size();
+ pa = getScaledPoint(index0);
+ pb = getScaledPoint(index1);
}
-void btConvexHullShape::getVertex(int i,btPoint3& vtx) const
+void btConvexHullShape::getVertex(int i,btVector3& vtx) const
{
- vtx = m_points[i]*m_localScaling;
+ vtx = getScaledPoint(i);
}
int btConvexHullShape::getNumPlanes() const
@@ -171,16 +172,16 @@ int btConvexHullShape::getNumPlanes() const
return 0;
}
-void btConvexHullShape::getPlane(btVector3& ,btPoint3& ,int ) const
+void btConvexHullShape::getPlane(btVector3& ,btVector3& ,int ) const
{
btAssert(0);
}
//not yet
-bool btConvexHullShape::isInside(const btPoint3& ,btScalar ) const
+bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const
{
- assert(0);
+ btAssert(0);
return false;
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.h
index 4773de2dc51..baf074be6c3 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.h
@@ -24,7 +24,7 @@ subject to the following restrictions:
///Bullet provides a general and fast collision detector for convex shapes based on GJK and EPA using localGetSupportingVertex.
ATTRIBUTE_ALIGNED16(class) btConvexHullShape : public btPolyhedralConvexShape
{
- btAlignedObjectArray<btPoint3> m_points;
+ btAlignedObjectArray<btVector3> m_unscaledPoints;
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
@@ -33,23 +33,38 @@ public:
///this constructor optionally takes in a pointer to points. Each point is assumed to be 3 consecutive btScalar (x,y,z), the striding defines the number of bytes between each point, in memory.
///It is easier to not pass any points in the constructor, and just add one point at a time, using addPoint.
///btConvexHullShape make an internal copy of the points.
- btConvexHullShape(const btScalar* points=0,int numPoints=0, int stride=sizeof(btPoint3));
+ btConvexHullShape(const btScalar* points=0,int numPoints=0, int stride=sizeof(btVector3));
- void addPoint(const btPoint3& point);
+ void addPoint(const btVector3& point);
- btPoint3* getPoints()
+
+ btVector3* getUnscaledPoints()
+ {
+ return &m_unscaledPoints[0];
+ }
+
+ const btVector3* getUnscaledPoints() const
+ {
+ return &m_unscaledPoints[0];
+ }
+
+ ///getPoints is obsolete, please use getUnscaledPoints
+ const btVector3* getPoints() const
{
- return &m_points[0];
+ return getUnscaledPoints();
}
- const btPoint3* getPoints() const
+
+
+
+ SIMD_FORCE_INLINE btVector3 getScaledPoint(int i) const
{
- return &m_points[0];
+ return m_unscaledPoints[i] * m_localScaling;
}
- int getNumPoints() const
+ SIMD_FORCE_INLINE int getNumPoints() const
{
- return m_points.size();
+ return m_unscaledPoints.size();
}
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
@@ -57,7 +72,6 @@ public:
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
- virtual int getShapeType()const { return CONVEX_HULL_SHAPE_PROXYTYPE; }
//debugging
virtual const char* getName()const {return "Convex";}
@@ -65,11 +79,11 @@ public:
virtual int getNumVertices() const;
virtual int getNumEdges() const;
- virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
- virtual void getVertex(int i,btPoint3& vtx) const;
+ virtual void getEdge(int i,btVector3& pa,btVector3& pb) const;
+ virtual void getVertex(int i,btVector3& vtx) const;
virtual int getNumPlanes() const;
- virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const;
- virtual bool isInside(const btPoint3& pt,btScalar tolerance) const;
+ virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const;
+ virtual bool isInside(const btVector3& pt,btScalar tolerance) const;
///in case we receive negative scaling
virtual void setLocalScaling(const btVector3& scaling);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp
index fb81c8a5bde..bfb741310e1 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp
@@ -17,6 +17,7 @@ subject to the following restrictions:
#include "btConvexInternalShape.h"
+
btConvexInternalShape::btConvexInternalShape()
: m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
m_collisionMargin(CONVEX_DISTANCE_MARGIN)
@@ -48,7 +49,8 @@ void btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAa
tmp = trans(localGetSupportingVertex(vec*trans.getBasis()));
minAabb[i] = tmp[i]-margin;
}
-};
+}
+
btVector3 btConvexInternalShape::localGetSupportingVertex(const btVector3& vec)const
@@ -70,6 +72,7 @@ btVector3 btConvexInternalShape::localGetSupportingVertex(const btVector3& vec)c
return supVertex;
#else
+ btAssert(0);
return btVector3(0,0,0);
#endif //__SPU__
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.h
index 9388ccf31f2..bab720d7b6d 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexInternalShape.h
@@ -19,23 +19,18 @@ class btConvexInternalShape : public btConvexShape
btScalar m_padding;
+ btConvexInternalShape();
+
public:
- btConvexInternalShape();
+
virtual ~btConvexInternalShape()
{
}
-
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
-#ifndef __SPU__
- virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec) const= 0;
-
- //notice that the vectors should be unit length
- virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const= 0;
-#endif //#ifndef __SPU__
const btVector3& getImplicitShapeDimensions() const
{
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp
new file mode 100644
index 00000000000..4ab5d692945
--- /dev/null
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp
@@ -0,0 +1,156 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+#include "btConvexPointCloudShape.h"
+#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
+
+#include "LinearMath/btQuaternion.h"
+
+void btConvexPointCloudShape::setLocalScaling(const btVector3& scaling)
+{
+ m_localScaling = scaling;
+ recalcLocalAabb();
+}
+
+#ifndef __SPU__
+btVector3 btConvexPointCloudShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
+{
+ btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
+ btScalar newDot,maxDot = btScalar(-1e30);
+
+ btVector3 vec = vec0;
+ btScalar lenSqr = vec.length2();
+ if (lenSqr < btScalar(0.0001))
+ {
+ vec.setValue(1,0,0);
+ } else
+ {
+ btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+ vec *= rlen;
+ }
+
+
+ for (int i=0;i<m_numPoints;i++)
+ {
+ btVector3 vtx = getScaledPoint(i);
+
+ newDot = vec.dot(vtx);
+ if (newDot > maxDot)
+ {
+ maxDot = newDot;
+ supVec = vtx;
+ }
+ }
+ return supVec;
+}
+
+void btConvexPointCloudShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+{
+ btScalar newDot;
+ //use 'w' component of supportVerticesOut?
+ {
+ for (int i=0;i<numVectors;i++)
+ {
+ supportVerticesOut[i][3] = btScalar(-1e30);
+ }
+ }
+ for (int i=0;i<m_numPoints;i++)
+ {
+ btVector3 vtx = getScaledPoint(i);
+
+ for (int j=0;j<numVectors;j++)
+ {
+ const btVector3& vec = vectors[j];
+
+ newDot = vec.dot(vtx);
+ if (newDot > supportVerticesOut[j][3])
+ {
+ //WARNING: don't swap next lines, the w component would get overwritten!
+ supportVerticesOut[j] = vtx;
+ supportVerticesOut[j][3] = newDot;
+ }
+ }
+ }
+
+
+
+}
+
+
+
+btVector3 btConvexPointCloudShape::localGetSupportingVertex(const btVector3& vec)const
+{
+ btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
+
+ if ( getMargin()!=btScalar(0.) )
+ {
+ btVector3 vecnorm = vec;
+ if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+ {
+ vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+ }
+ vecnorm.normalize();
+ supVertex+= getMargin() * vecnorm;
+ }
+ return supVertex;
+}
+
+
+#endif
+
+
+
+
+
+
+//currently just for debugging (drawing), perhaps future support for algebraic continuous collision detection
+//Please note that you can debug-draw btConvexHullShape with the Raytracer Demo
+int btConvexPointCloudShape::getNumVertices() const
+{
+ return m_numPoints;
+}
+
+int btConvexPointCloudShape::getNumEdges() const
+{
+ return 0;
+}
+
+void btConvexPointCloudShape::getEdge(int i,btVector3& pa,btVector3& pb) const
+{
+ btAssert (0);
+}
+
+void btConvexPointCloudShape::getVertex(int i,btVector3& vtx) const
+{
+ vtx = m_unscaledPoints[i]*m_localScaling;
+}
+
+int btConvexPointCloudShape::getNumPlanes() const
+{
+ return 0;
+}
+
+void btConvexPointCloudShape::getPlane(btVector3& ,btVector3& ,int ) const
+{
+
+ btAssert(0);
+}
+
+//not yet
+bool btConvexPointCloudShape::isInside(const btVector3& ,btScalar ) const
+{
+ btAssert(0);
+ return false;
+}
+
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.h
new file mode 100644
index 00000000000..7e1c13b29c1
--- /dev/null
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexPointCloudShape.h
@@ -0,0 +1,96 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it freely,
+subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef BT_CONVEX_POINT_CLOUD_SHAPE_H
+#define BT_CONVEX_POINT_CLOUD_SHAPE_H
+
+#include "btPolyhedralConvexShape.h"
+#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
+#include "LinearMath/btAlignedObjectArray.h"
+
+///The btConvexPointCloudShape implements an implicit convex hull of an array of vertices.
+ATTRIBUTE_ALIGNED16(class) btConvexPointCloudShape : public btPolyhedralConvexShape
+{
+ btVector3* m_unscaledPoints;
+ int m_numPoints;
+
+public:
+ BT_DECLARE_ALIGNED_ALLOCATOR();
+
+ btConvexPointCloudShape(btVector3* points,int numPoints, const btVector3& localScaling,bool computeAabb = true)
+ {
+ m_localScaling = localScaling;
+ m_shapeType = CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE;
+ m_unscaledPoints = points;
+ m_numPoints = numPoints;
+
+ if (computeAabb)
+ recalcLocalAabb();
+ }
+
+ void setPoints (btVector3* points, int numPoints, bool computeAabb = true)
+ {
+ m_unscaledPoints = points;
+ m_numPoints = numPoints;
+
+ if (computeAabb)
+ recalcLocalAabb();
+ }
+
+ SIMD_FORCE_INLINE btVector3* getUnscaledPoints()
+ {
+ return m_unscaledPoints;
+ }
+
+ SIMD_FORCE_INLINE const btVector3* getUnscaledPoints() const
+ {
+ return m_unscaledPoints;
+ }
+
+ SIMD_FORCE_INLINE int getNumPoints() const
+ {
+ return m_numPoints;
+ }
+
+ SIMD_FORCE_INLINE btVector3 getScaledPoint( int index) const
+ {
+ return m_unscaledPoints[index] * m_localScaling;
+ }
+
+#ifndef __SPU__
+ virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
+ virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
+ virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+#endif
+
+
+ //debugging
+ virtual const char* getName()const {return "ConvexPointCloud";}
+
+ virtual int getNumVertices() const;
+ virtual int getNumEdges() const;
+ virtual void getEdge(int i,btVector3& pa,btVector3& pb) const;
+ virtual void getVertex(int i,btVector3& vtx) const;
+ virtual int getNumPlanes() const;
+ virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const;
+ virtual bool isInside(const btVector3& pt,btScalar tolerance) const;
+
+ ///in case we receive negative scaling
+ virtual void setLocalScaling(const btVector3& scaling);
+};
+
+
+#endif //BT_CONVEX_POINT_CLOUD_SHAPE_H
+
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
index 7afcccf8b03..7e67696f4c7 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
@@ -14,5 +14,366 @@ subject to the following restrictions:
*/
#include "btConvexShape.h"
+#include "btTriangleShape.h"
+#include "btSphereShape.h"
+#include "btCylinderShape.h"
+#include "btCapsuleShape.h"
+#include "btConvexHullShape.h"
+#include "btConvexPointCloudShape.h"
+btConvexShape::btConvexShape ()
+{
+}
+btConvexShape::~btConvexShape()
+{
+
+}
+
+
+
+static btVector3 convexHullSupport (const btVector3& localDir, const btVector3* points, int numPoints, const btVector3& localScaling)
+{
+ btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
+ btScalar newDot,maxDot = btScalar(-1e30);
+
+ btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ());
+ btVector3 vec = vec0;
+ btScalar lenSqr = vec.length2();
+ if (lenSqr < btScalar(0.0001))
+ {
+ vec.setValue(1,0,0);
+ } else {
+ btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+ vec *= rlen;
+ }
+
+
+ for (int i=0;i<numPoints;i++)
+ {
+ btVector3 vtx = points[i] * localScaling;
+
+ newDot = vec.dot(vtx);
+ if (newDot > maxDot)
+ {
+ maxDot = newDot;
+ supVec = vtx;
+ }
+ }
+ return btVector3(supVec.getX(),supVec.getY(),supVec.getZ());
+}
+
+btVector3 btConvexShape::localGetSupportVertexWithoutMarginNonVirtual (const btVector3& localDir) const
+{
+ switch (m_shapeType)
+ {
+ case SPHERE_SHAPE_PROXYTYPE:
+ {
+ return btVector3(0,0,0);
+ }
+ case BOX_SHAPE_PROXYTYPE:
+ {
+ btBoxShape* convexShape = (btBoxShape*)this;
+ const btVector3& halfExtents = convexShape->getImplicitShapeDimensions();
+
+ return btVector3(btFsels(localDir.x(), halfExtents.x(), -halfExtents.x()),
+ btFsels(localDir.y(), halfExtents.y(), -halfExtents.y()),
+ btFsels(localDir.z(), halfExtents.z(), -halfExtents.z()));
+ }
+ case TRIANGLE_SHAPE_PROXYTYPE:
+ {
+ btTriangleShape* triangleShape = (btTriangleShape*)this;
+ btVector3 dir(localDir.getX(),localDir.getY(),localDir.getZ());
+ btVector3* vertices = &triangleShape->m_vertices1[0];
+ btVector3 dots(dir.dot(vertices[0]), dir.dot(vertices[1]), dir.dot(vertices[2]));
+ btVector3 sup = vertices[dots.maxAxis()];
+ return btVector3(sup.getX(),sup.getY(),sup.getZ());
+ }
+ case CYLINDER_SHAPE_PROXYTYPE:
+ {
+ btCylinderShape* cylShape = (btCylinderShape*)this;
+ //mapping of halfextents/dimension onto radius/height depends on how cylinder local orientation is (upAxis)
+
+ btVector3 halfExtents = cylShape->getImplicitShapeDimensions();
+ btVector3 v(localDir.getX(),localDir.getY(),localDir.getZ());
+ int cylinderUpAxis = cylShape->getUpAxis();
+ int XX(1),YY(0),ZZ(2);
+
+ switch (cylinderUpAxis)
+ {
+ case 0:
+ {
+ XX = 1;
+ YY = 0;
+ ZZ = 2;
+ }
+ break;
+ case 1:
+ {
+ XX = 0;
+ YY = 1;
+ ZZ = 2;
+ }
+ break;
+ case 2:
+ {
+ XX = 0;
+ YY = 2;
+ ZZ = 1;
+
+ }
+ break;
+ default:
+ btAssert(0);
+ break;
+ };
+
+ btScalar radius = halfExtents[XX];
+ btScalar halfHeight = halfExtents[cylinderUpAxis];
+
+ btVector3 tmp;
+ btScalar d ;
+
+ btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
+ if (s != btScalar(0.0))
+ {
+ d = radius / s;
+ tmp[XX] = v[XX] * d;
+ tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+ tmp[ZZ] = v[ZZ] * d;
+ return btVector3(tmp.getX(),tmp.getY(),tmp.getZ());
+ } else {
+ tmp[XX] = radius;
+ tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
+ tmp[ZZ] = btScalar(0.0);
+ return btVector3(tmp.getX(),tmp.getY(),tmp.getZ());
+ }
+ }
+ case CAPSULE_SHAPE_PROXYTYPE:
+ {
+ btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ());
+
+ btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
+ btScalar halfHeight = capsuleShape->getHalfHeight();
+ int capsuleUpAxis = capsuleShape->getUpAxis();
+
+ btScalar radius = capsuleShape->getRadius();
+ btVector3 supVec(0,0,0);
+
+ btScalar maxDot(btScalar(-1e30));
+
+ btVector3 vec = vec0;
+ btScalar lenSqr = vec.length2();
+ if (lenSqr < btScalar(0.0001))
+ {
+ vec.setValue(1,0,0);
+ } else
+ {
+ btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+ vec *= rlen;
+ }
+ btVector3 vtx;
+ btScalar newDot;
+ {
+ btVector3 pos(0,0,0);
+ pos[capsuleUpAxis] = halfHeight;
+
+ //vtx = pos +vec*(radius);
+ vtx = pos +vec*capsuleShape->getLocalScalingNV()*(radius) - vec * capsuleShape->getMarginNV();
+ newDot = vec.dot(vtx);
+
+
+ if (newDot > maxDot)
+ {
+ maxDot = newDot;
+ supVec = vtx;
+ }
+ }
+ {
+ btVector3 pos(0,0,0);
+ pos[capsuleUpAxis] = -halfHeight;
+
+ //vtx = pos +vec*(radius);
+ vtx = pos +vec*capsuleShape->getLocalScalingNV()*(radius) - vec * capsuleShape->getMarginNV();
+ newDot = vec.dot(vtx);
+ if (newDot > maxDot)
+ {
+ maxDot = newDot;
+ supVec = vtx;
+ }
+ }
+ return btVector3(supVec.getX(),supVec.getY(),supVec.getZ());
+ }
+ case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
+ {
+ btConvexPointCloudShape* convexPointCloudShape = (btConvexPointCloudShape*)this;
+ btVector3* points = convexPointCloudShape->getUnscaledPoints ();
+ int numPoints = convexPointCloudShape->getNumPoints ();
+ return convexHullSupport (localDir, points, numPoints,convexPointCloudShape->getLocalScalingNV());
+ }
+ case CONVEX_HULL_SHAPE_PROXYTYPE:
+ {
+ btConvexHullShape* convexHullShape = (btConvexHullShape*)this;
+ btVector3* points = convexHullShape->getUnscaledPoints();
+ int numPoints = convexHullShape->getNumPoints ();
+ return convexHullSupport (localDir, points, numPoints,convexHullShape->getLocalScalingNV());
+ }
+ default:
+#ifndef __SPU__
+ return this->localGetSupportingVertexWithoutMargin (localDir);
+#else
+ btAssert (0);
+#endif
+ }
+
+ // should never reach here
+ btAssert (0);
+ return btVector3 (btScalar(0.0f), btScalar(0.0f), btScalar(0.0f));
+}
+
+btVector3 btConvexShape::localGetSupportVertexNonVirtual (const btVector3& localDir) const
+{
+ btVector3 localDirNorm = localDir;
+ if (localDirNorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
+ {
+ localDirNorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
+ }
+ localDirNorm.normalize ();
+
+ return localGetSupportVertexWithoutMarginNonVirtual(localDirNorm)+ getMarginNonVirtual() * localDirNorm;
+}
+
+/* TODO: This should be bumped up to btCollisionShape () */
+btScalar btConvexShape::getMarginNonVirtual () const
+{
+ switch (m_shapeType)
+ {
+ case SPHERE_SHAPE_PROXYTYPE:
+ {
+ btSphereShape* sphereShape = (btSphereShape*)this;
+ return sphereShape->getRadius ();
+ }
+ case BOX_SHAPE_PROXYTYPE:
+ {
+ btBoxShape* convexShape = (btBoxShape*)this;
+ return convexShape->getMarginNV ();
+ }
+ case TRIANGLE_SHAPE_PROXYTYPE:
+ {
+ btTriangleShape* triangleShape = (btTriangleShape*)this;
+ return triangleShape->getMarginNV ();
+ }
+ case CYLINDER_SHAPE_PROXYTYPE:
+ {
+ btCylinderShape* cylShape = (btCylinderShape*)this;
+ return cylShape->getMarginNV();
+ }
+ case CAPSULE_SHAPE_PROXYTYPE:
+ {
+ btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
+ return capsuleShape->getMarginNV();
+ }
+ case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
+ /* fall through */
+ case CONVEX_HULL_SHAPE_PROXYTYPE:
+ {
+ btPolyhedralConvexShape* convexHullShape = (btPolyhedralConvexShape*)this;
+ return convexHullShape->getMarginNV();
+ }
+ default:
+#ifndef __SPU__
+ return this->getMargin ();
+#else
+ btAssert (0);
+#endif
+ }
+
+ // should never reach here
+ btAssert (0);
+ return btScalar(0.0f);
+}
+
+void btConvexShape::getAabbNonVirtual (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
+{
+ switch (m_shapeType)
+ {
+ case SPHERE_SHAPE_PROXYTYPE:
+ {
+ btSphereShape* sphereShape = (btSphereShape*)this;
+ btScalar radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
+ btScalar margin = radius + sphereShape->getMarginNonVirtual();
+ const btVector3& center = t.getOrigin();
+ btVector3 extent(margin,margin,margin);
+ aabbMin = center - extent;
+ aabbMax = center + extent;
+ }
+ break;
+ case CYLINDER_SHAPE_PROXYTYPE:
+ /* fall through */
+ case BOX_SHAPE_PROXYTYPE:
+ {
+ btBoxShape* convexShape = (btBoxShape*)this;
+ btScalar margin=convexShape->getMarginNonVirtual();
+ btVector3 halfExtents = convexShape->getImplicitShapeDimensions();
+ halfExtents += btVector3(margin,margin,margin);
+ btMatrix3x3 abs_b = t.getBasis().absolute();
+ btVector3 center = t.getOrigin();
+ btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));
+
+ aabbMin = center - extent;
+ aabbMax = center + extent;
+ break;
+ }
+ case TRIANGLE_SHAPE_PROXYTYPE:
+ {
+ btTriangleShape* triangleShape = (btTriangleShape*)this;
+ btScalar margin = triangleShape->getMarginNonVirtual();
+ for (int i=0;i<3;i++)
+ {
+ btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
+ vec[i] = btScalar(1.);
+
+ btVector3 sv = localGetSupportVertexWithoutMarginNonVirtual(vec*t.getBasis());
+
+ btVector3 tmp = t(sv);
+ aabbMax[i] = tmp[i]+margin;
+ vec[i] = btScalar(-1.);
+ tmp = t(localGetSupportVertexWithoutMarginNonVirtual(vec*t.getBasis()));
+ aabbMin[i] = tmp[i]-margin;
+ }
+ }
+ break;
+ case CAPSULE_SHAPE_PROXYTYPE:
+ {
+ btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
+ btVector3 halfExtents(capsuleShape->getRadius(),capsuleShape->getRadius(),capsuleShape->getRadius());
+ int m_upAxis = capsuleShape->getUpAxis();
+ halfExtents[m_upAxis] = capsuleShape->getRadius() + capsuleShape->getHalfHeight();
+ halfExtents += btVector3(capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual());
+ btMatrix3x3 abs_b = t.getBasis().absolute();
+ btVector3 center = t.getOrigin();
+ btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));
+ aabbMin = center - extent;
+ aabbMax = center + extent;
+ }
+ break;
+ case CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE:
+ case CONVEX_HULL_SHAPE_PROXYTYPE:
+ {
+ btPolyhedralConvexShape* convexHullShape = (btPolyhedralConvexShape*)this;
+ btScalar margin = convexHullShape->getMarginNonVirtual();
+ convexHullShape->getNonvirtualAabb (t, aabbMin, aabbMax, margin);
+ }
+ break;
+ default:
+#ifndef __SPU__
+ this->getAabb (t, aabbMin, aabbMax);
+#else
+ btAssert (0);
+#endif
+ break;
+ }
+
+ // should never reach here
+ btAssert (0);
+}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h
index e4eb7f6dbf6..0cc7b349521 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h
@@ -24,8 +24,6 @@ subject to the following restrictions:
#include "btCollisionMargin.h"
#include "LinearMath/btAlignedAllocator.h"
-//todo: get rid of this btConvexCastResult thing!
-struct btConvexCastResult;
#define MAX_PREFERRED_PENETRATION_DIRECTIONS 10
/// The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape, btConvexHullShape etc.
@@ -38,20 +36,25 @@ public:
BT_DECLARE_ALIGNED_ALLOCATOR();
- virtual ~btConvexShape()
- {
+ btConvexShape ();
- }
+ virtual ~btConvexShape();
+ virtual btVector3 localGetSupportingVertex(const btVector3& vec)const = 0;
+
+ ////////
+ #ifndef __SPU__
+ virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec) const=0;
+ #endif //#ifndef __SPU__
+
+ btVector3 localGetSupportVertexWithoutMarginNonVirtual (const btVector3& vec) const;
+ btVector3 localGetSupportVertexNonVirtual (const btVector3& vec) const;
+ btScalar getMarginNonVirtual () const;
+ void getAabbNonVirtual (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const;
- virtual btVector3 localGetSupportingVertex(const btVector3& vec)const =0;
-#ifndef __SPU__
- virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec) const= 0;
//notice that the vectors should be unit length
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const= 0;
-#endif //#ifndef __SPU__
-
///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0;
@@ -69,6 +72,9 @@ public:
virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const=0;
+
+
+
};
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp
index 02a293e82ba..4bd986bb7f7 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp
@@ -20,8 +20,9 @@ subject to the following restrictions:
btConvexTriangleMeshShape ::btConvexTriangleMeshShape (btStridingMeshInterface* meshInterface, bool calcAabb)
-:m_stridingMesh(meshInterface)
+: btPolyhedralConvexShape(), m_stridingMesh(meshInterface)
{
+ m_shapeType = CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE;
if ( calcAabb )
recalcLocalAabb();
}
@@ -107,7 +108,7 @@ void btConvexTriangleMeshShape::batchedUnitVectorGetSupportingVertexWithoutMargi
}
}
- //todo: could do the batch inside the callback!
+ ///@todo: could do the batch inside the callback!
for (int j=0;j<numVectors;j++)
@@ -162,12 +163,12 @@ int btConvexTriangleMeshShape::getNumEdges() const
return 0;
}
-void btConvexTriangleMeshShape::getEdge(int ,btPoint3& ,btPoint3& ) const
+void btConvexTriangleMeshShape::getEdge(int ,btVector3& ,btVector3& ) const
{
btAssert(0);
}
-void btConvexTriangleMeshShape::getVertex(int ,btPoint3& ) const
+void btConvexTriangleMeshShape::getVertex(int ,btVector3& ) const
{
btAssert(0);
}
@@ -177,13 +178,13 @@ int btConvexTriangleMeshShape::getNumPlanes() const
return 0;
}
-void btConvexTriangleMeshShape::getPlane(btVector3& ,btPoint3& ,int ) const
+void btConvexTriangleMeshShape::getPlane(btVector3& ,btVector3& ,int ) const
{
btAssert(0);
}
//not yet
-bool btConvexTriangleMeshShape::isInside(const btPoint3& ,btScalar ) const
+bool btConvexTriangleMeshShape::isInside(const btVector3& ,btScalar ) const
{
btAssert(0);
return false;
@@ -268,15 +269,12 @@ void btConvexTriangleMeshShape::calculatePrincipalAxisTransform(btTransform& pri
btVector3 a = triangle[0] - center;
btVector3 b = triangle[1] - center;
btVector3 c = triangle[2] - center;
- btVector3 abc = a + b + c;
btScalar volNeg = -btFabs(a.triple(b, c)) * btScalar(1. / 6);
for (int j = 0; j < 3; j++)
{
for (int k = 0; k <= j; k++)
{
- i[j][k] = i[k][j] = volNeg * (center[j] * center[k]
- + btScalar(0.25) * (center[j] * abc[k] + center[k] * abc[j])
- + btScalar(0.1) * (a[j] * a[k] + b[j] * b[k] + c[j] * c[k])
+ i[j][k] = i[k][j] = volNeg * (btScalar(0.1) * (a[j] * a[k] + b[j] * b[k] + c[j] * c[k])
+ btScalar(0.05) * (a[j] * b[k] + a[k] * b[j] + a[j] * c[k] + a[k] * c[j] + b[j] * c[k] + b[k] * c[j]));
}
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h
index 6ff0bf5d43b..9d7e39fce69 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h
@@ -29,18 +29,16 @@ public:
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
- virtual int getShapeType()const { return CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE; }
-
//debugging
virtual const char* getName()const {return "ConvexTrimesh";}
virtual int getNumVertices() const;
virtual int getNumEdges() const;
- virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
- virtual void getVertex(int i,btPoint3& vtx) const;
+ virtual void getEdge(int i,btVector3& pa,btVector3& pb) const;
+ virtual void getVertex(int i,btVector3& vtx) const;
virtual int getNumPlanes() const;
- virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const;
- virtual bool isInside(const btPoint3& pt,btScalar tolerance) const;
+ virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const;
+ virtual bool isInside(const btVector3& pt,btScalar tolerance) const;
virtual void setLocalScaling(const btVector3& scaling);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.cpp
index 3afef1c7550..c9fa907edf3 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.cpp
@@ -13,12 +13,12 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#include "btCylinderShape.h"
-#include "LinearMath/btPoint3.h"
btCylinderShape::btCylinderShape (const btVector3& halfExtents)
:btBoxShape(halfExtents),
m_upAxis(1)
{
+ m_shapeType = CYLINDER_SHAPE_PROXYTYPE;
recalcLocalAabb();
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.h
index 30938acf7c7..bda74a8612d 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCylinderShape.h
@@ -62,11 +62,7 @@ public:
//use box inertia
// virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
- virtual int getShapeType() const
- {
- return CYLINDER_SHAPE_PROXYTYPE;
- }
-
+
int getUpAxis() const
{
return m_upAxis;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.cpp
index 6954aad7917..8387b9584bb 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.cpp
@@ -19,8 +19,9 @@ subject to the following restrictions:
#include "btCollisionShape.h"
-btEmptyShape::btEmptyShape()
+btEmptyShape::btEmptyShape() : btConcaveShape ()
{
+ m_shapeType = EMPTY_SHAPE_PROXYTYPE;
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h
index d7d78407b61..8720d53ae63 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h
@@ -51,14 +51,14 @@ public:
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
- virtual int getShapeType() const { return EMPTY_SHAPE_PROXYTYPE;}
-
-
virtual const char* getName()const
{
return "Empty";
}
+ virtual void processAllTriangles(btTriangleCallback* ,const btVector3& ,const btVector3& ) const
+ {
+ }
protected:
btVector3 m_localScaling;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
index a291d6b7ce7..7d4875d8037 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
@@ -18,71 +18,107 @@ subject to the following restrictions:
#include "LinearMath/btTransformUtil.h"
-btHeightfieldTerrainShape::btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength,void* heightfieldData,btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges)
-: m_heightStickWidth(heightStickWidth),
-m_heightStickLength(heightStickLength),
-m_maxHeight(maxHeight),
-m_width((btScalar)heightStickWidth-1),
-m_length((btScalar)heightStickLength-1),
-m_heightfieldDataUnknown(heightfieldData),
-m_useFloatData(useFloatData),
-m_flipQuadEdges(flipQuadEdges),
-m_useDiamondSubdivision(false),
-m_upAxis(upAxis),
-m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.))
+
+btHeightfieldTerrainShape::btHeightfieldTerrainShape
+(
+int heightStickWidth, int heightStickLength, void* heightfieldData,
+btScalar heightScale, btScalar minHeight, btScalar maxHeight,int upAxis,
+PHY_ScalarType hdt, bool flipQuadEdges
+)
{
+ initialize(heightStickWidth, heightStickLength, heightfieldData,
+ heightScale, minHeight, maxHeight, upAxis, hdt,
+ flipQuadEdges);
+}
+
- btScalar quantizationMargin = 1.f;
+btHeightfieldTerrainShape::btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength,void* heightfieldData,btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges)
+{
+ // legacy constructor: support only float or unsigned char,
+ // and min height is zero
+ PHY_ScalarType hdt = (useFloatData) ? PHY_FLOAT : PHY_UCHAR;
+ btScalar minHeight = 0.0;
+
+ // previously, height = uchar * maxHeight / 65535.
+ // So to preserve legacy behavior, heightScale = maxHeight / 65535
+ btScalar heightScale = maxHeight / 65535;
+
+ initialize(heightStickWidth, heightStickLength, heightfieldData,
+ heightScale, minHeight, maxHeight, upAxis, hdt,
+ flipQuadEdges);
+}
- //enlarge the AABB to avoid division by zero when initializing the quantization values
- btVector3 clampValue(quantizationMargin,quantizationMargin,quantizationMargin);
- btVector3 halfExtents(0,0,0);
+void btHeightfieldTerrainShape::initialize
+(
+int heightStickWidth, int heightStickLength, void* heightfieldData,
+btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis,
+PHY_ScalarType hdt, bool flipQuadEdges
+)
+{
+ // validation
+ btAssert(heightStickWidth > 1 && "bad width");
+ btAssert(heightStickLength > 1 && "bad length");
+ btAssert(heightfieldData && "null heightfield data");
+ // btAssert(heightScale) -- do we care? Trust caller here
+ btAssert(minHeight <= maxHeight && "bad min/max height");
+ btAssert(upAxis >= 0 && upAxis < 3 &&
+ "bad upAxis--should be in range [0,2]");
+ btAssert(hdt != PHY_UCHAR || hdt != PHY_FLOAT || hdt != PHY_SHORT &&
+ "Bad height data type enum");
+
+ // initialize member variables
+ m_shapeType = TERRAIN_SHAPE_PROXYTYPE;
+ m_heightStickWidth = heightStickWidth;
+ m_heightStickLength = heightStickLength;
+ m_minHeight = minHeight;
+ m_maxHeight = maxHeight;
+ m_width = (btScalar) (heightStickWidth - 1);
+ m_length = (btScalar) (heightStickLength - 1);
+ m_heightScale = heightScale;
+ m_heightfieldDataUnknown = heightfieldData;
+ m_heightDataType = hdt;
+ m_flipQuadEdges = flipQuadEdges;
+ m_useDiamondSubdivision = false;
+ m_upAxis = upAxis;
+ m_localScaling.setValue(btScalar(1.), btScalar(1.), btScalar(1.));
+
+ // determine min/max axis-aligned bounding box (aabb) values
switch (m_upAxis)
{
case 0:
{
- halfExtents.setValue(
- btScalar(m_maxHeight),
- btScalar(m_width), //?? don't know if this should change
- btScalar(m_length));
+ m_localAabbMin.setValue(m_minHeight, 0, 0);
+ m_localAabbMax.setValue(m_maxHeight, m_width, m_length);
break;
}
case 1:
{
- halfExtents.setValue(
- btScalar(m_width),
- btScalar(m_maxHeight),
- btScalar(m_length));
+ m_localAabbMin.setValue(0, m_minHeight, 0);
+ m_localAabbMax.setValue(m_width, m_maxHeight, m_length);
break;
};
case 2:
{
- halfExtents.setValue(
- btScalar(m_width),
- btScalar(m_length),
- btScalar(m_maxHeight)
- );
+ m_localAabbMin.setValue(0, 0, m_minHeight);
+ m_localAabbMax.setValue(m_width, m_length, m_maxHeight);
break;
}
default:
{
//need to get valid m_upAxis
- btAssert(0);
+ btAssert(0 && "Bad m_upAxis");
}
}
- halfExtents*= btScalar(0.5);
-
- m_localAabbMin = -halfExtents - clampValue;
- m_localAabbMax = halfExtents + clampValue;
- btVector3 aabbSize = m_localAabbMax - m_localAabbMin;
-
+ // remember origin (defined as exact middle of aabb)
+ m_localOrigin = btScalar(0.5) * (m_localAabbMin + m_localAabbMax);
}
+
btHeightfieldTerrainShape::~btHeightfieldTerrainShape()
{
}
@@ -92,57 +128,80 @@ btHeightfieldTerrainShape::~btHeightfieldTerrainShape()
void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
{
btVector3 halfExtents = (m_localAabbMax-m_localAabbMin)* m_localScaling * btScalar(0.5);
- halfExtents += btVector3(getMargin(),getMargin(),getMargin());
+
+ btVector3 localOrigin(0, 0, 0);
+ localOrigin[m_upAxis] = (m_minHeight + m_maxHeight) * btScalar(0.5);
+ localOrigin *= m_localScaling;
btMatrix3x3 abs_b = t.getBasis().absolute();
- btPoint3 center = t.getOrigin();
+ btVector3 center = t.getOrigin();
btVector3 extent = btVector3(abs_b[0].dot(halfExtents),
abs_b[1].dot(halfExtents),
abs_b[2].dot(halfExtents));
-
+ extent += btVector3(getMargin(),getMargin(),getMargin());
aabbMin = center - extent;
aabbMax = center + extent;
-
-
}
-btScalar btHeightfieldTerrainShape::getHeightFieldValue(int x,int y) const
+
+/// This returns the "raw" (user's initial) height, not the actual height.
+/// The actual height needs to be adjusted to be relative to the center
+/// of the heightfield's AABB.
+btScalar
+btHeightfieldTerrainShape::getRawHeightFieldValue(int x,int y) const
{
btScalar val = 0.f;
- if (m_useFloatData)
+ switch (m_heightDataType)
{
- val = m_heightfieldDataFloat[(y*m_heightStickWidth)+x];
- } else
- {
- //assume unsigned short int
- unsigned char heightFieldValue = m_heightfieldDataUnsignedChar[(y*m_heightStickWidth)+x];
- val = heightFieldValue* (m_maxHeight/btScalar(65535));
+ case PHY_FLOAT:
+ {
+ val = m_heightfieldDataFloat[(y*m_heightStickWidth)+x];
+ break;
+ }
+
+ case PHY_UCHAR:
+ {
+ unsigned char heightFieldValue = m_heightfieldDataUnsignedChar[(y*m_heightStickWidth)+x];
+ val = heightFieldValue * m_heightScale;
+ break;
+ }
+
+ case PHY_SHORT:
+ {
+ short hfValue = m_heightfieldDataShort[(y * m_heightStickWidth) + x];
+ val = hfValue * m_heightScale;
+ break;
+ }
+
+ default:
+ {
+ btAssert(!"Bad m_heightDataType");
+ }
}
+
return val;
}
-
+/// this returns the vertex in bullet-local coordinates
void btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
{
-
btAssert(x>=0);
btAssert(y>=0);
btAssert(x<m_heightStickWidth);
btAssert(y<m_heightStickLength);
-
- btScalar height = getHeightFieldValue(x,y);
+ btScalar height = getRawHeightFieldValue(x,y);
switch (m_upAxis)
{
case 0:
{
vertex.setValue(
- height,
+ height - m_localOrigin.getX(),
(-m_width/btScalar(2.0)) + x,
(-m_length/btScalar(2.0) ) + y
);
@@ -152,7 +211,7 @@ void btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
{
vertex.setValue(
(-m_width/btScalar(2.0)) + x,
- height,
+ height - m_localOrigin.getY(),
(-m_length/btScalar(2.0)) + y
);
break;
@@ -162,7 +221,7 @@ void btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
vertex.setValue(
(-m_width/btScalar(2.0)) + x,
(-m_length/btScalar(2.0)) + y,
- height
+ height - m_localOrigin.getZ()
);
break;
}
@@ -174,45 +233,76 @@ void btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
}
vertex*=m_localScaling;
-
}
+
+static inline int
+getQuantized
+(
+btScalar x
+)
+{
+ if (x < 0.0) {
+ return (int) (x - 0.5);
+ }
+ return (int) (x + 0.5);
+}
+
+
+
+/// given input vector, return quantized version
+/**
+ This routine is basically determining the gridpoint indices for a given
+ input vector, answering the question: "which gridpoint is closest to the
+ provided point?".
+
+ "with clamp" means that we restrict the point to be in the heightfield's
+ axis-aligned bounding box.
+ */
void btHeightfieldTerrainShape::quantizeWithClamp(int* out, const btVector3& point,int /*isMax*/) const
{
btVector3 clampedPoint(point);
clampedPoint.setMax(m_localAabbMin);
clampedPoint.setMin(m_localAabbMax);
- btVector3 v = (clampedPoint);// - m_bvhAabbMin) * m_bvhQuantization;
-
- //TODO: optimization: check out how to removed this btFabs
+ out[0] = getQuantized(clampedPoint.getX());
+ out[1] = getQuantized(clampedPoint.getY());
+ out[2] = getQuantized(clampedPoint.getZ());
- out[0] = (int)(v.getX() + v.getX() / btFabs(v.getX())* btScalar(0.5) );
- out[1] = (int)(v.getY() + v.getY() / btFabs(v.getY())* btScalar(0.5) );
- out[2] = (int)(v.getZ() + v.getZ() / btFabs(v.getZ())* btScalar(0.5) );
-
}
+
+/// process all triangles within the provided axis-aligned bounding box
+/**
+ basic algorithm:
+ - convert input aabb to local coordinates (scale down and shift for local origin)
+ - convert input aabb to a range of heightfield grid points (quantize)
+ - iterate over all triangles in that subset of the grid
+ */
void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
{
- (void)callback;
- (void)aabbMax;
- (void)aabbMin;
+ // scale down the input aabb's so they are in local (non-scaled) coordinates
+ btVector3 localAabbMin = aabbMin*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
+ btVector3 localAabbMax = aabbMax*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
- //quantize the aabbMin and aabbMax, and adjust the start/end ranges
+ // account for local origin
+ localAabbMin += m_localOrigin;
+ localAabbMax += m_localOrigin;
+ //quantize the aabbMin and aabbMax, and adjust the start/end ranges
int quantizedAabbMin[3];
int quantizedAabbMax[3];
-
- btVector3 localAabbMin = aabbMin*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
- btVector3 localAabbMax = aabbMax*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
-
quantizeWithClamp(quantizedAabbMin, localAabbMin,0);
quantizeWithClamp(quantizedAabbMax, localAabbMax,1);
-
+ // expand the min/max quantized values
+ // this is to catch the case where the input aabb falls between grid points!
+ for (int i = 0; i < 3; ++i) {
+ quantizedAabbMin[i]--;
+ quantizedAabbMax[i]++;
+ }
int startX=0;
int endX=m_heightStickWidth-1;
@@ -223,11 +313,6 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback
{
case 0:
{
- quantizedAabbMin[1]+=m_heightStickWidth/2-1;
- quantizedAabbMax[1]+=m_heightStickWidth/2+1;
- quantizedAabbMin[2]+=m_heightStickLength/2-1;
- quantizedAabbMax[2]+=m_heightStickLength/2+1;
-
if (quantizedAabbMin[1]>startX)
startX = quantizedAabbMin[1];
if (quantizedAabbMax[1]<endX)
@@ -240,11 +325,6 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback
}
case 1:
{
- quantizedAabbMin[0]+=m_heightStickWidth/2-1;
- quantizedAabbMax[0]+=m_heightStickWidth/2+1;
- quantizedAabbMin[2]+=m_heightStickLength/2-1;
- quantizedAabbMax[2]+=m_heightStickLength/2+1;
-
if (quantizedAabbMin[0]>startX)
startX = quantizedAabbMin[0];
if (quantizedAabbMax[0]<endX)
@@ -257,11 +337,6 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback
};
case 2:
{
- quantizedAabbMin[0]+=m_heightStickWidth/2-1;
- quantizedAabbMax[0]+=m_heightStickWidth/2+1;
- quantizedAabbMin[1]+=m_heightStickLength/2-1;
- quantizedAabbMax[1]+=m_heightStickLength/2+1;
-
if (quantizedAabbMin[0]>startX)
startX = quantizedAabbMin[0];
if (quantizedAabbMax[0]<endX)
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
index d6890fe6b97..36489a0ebc3 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
@@ -18,28 +18,80 @@ subject to the following restrictions:
#include "btConcaveShape.h"
-///The btHeightfieldTerrainShape simulates a 2D heightfield terrain collision shape. You can also use the more general btBvhTriangleMeshShape instead.
-///An example implementation of btHeightfieldTerrainShape is provided in Demos/VehicleDemo/VehicleDemo.cpp
+///btHeightfieldTerrainShape simulates a 2D heightfield terrain
+/**
+ The caller is responsible for maintaining the heightfield array; this
+ class does not make a copy.
+
+ The heightfield can be dynamic so long as the min/max height values
+ capture the extremes (heights must always be in that range).
+
+ The local origin of the heightfield is assumed to be the exact
+ center (as determined by width and length and height, with each
+ axis multiplied by the localScaling).
+
+ \b NOTE: be careful with coordinates. If you have a heightfield with a local
+ min height of -100m, and a max height of +500m, you may be tempted to place it
+ at the origin (0,0) and expect the heights in world coordinates to be
+ -100 to +500 meters.
+ Actually, the heights will be -300 to +300m, because bullet will re-center
+ the heightfield based on its AABB (which is determined by the min/max
+ heights). So keep in mind that once you create a btHeightfieldTerrainShape
+ object, the heights will be adjusted relative to the center of the AABB. This
+ is different to the behavior of many rendering engines, but is useful for
+ physics engines.
+
+ Most (but not all) rendering and heightfield libraries assume upAxis = 1
+ (that is, the y-axis is "up"). This class allows any of the 3 coordinates
+ to be "up". Make sure your choice of axis is consistent with your rendering
+ system.
+
+ The heightfield heights are determined from the data type used for the
+ heightfieldData array.
+
+ - PHY_UCHAR: height at a point is the uchar value at the
+ grid point, multipled by heightScale. uchar isn't recommended
+ because of its inability to deal with negative values, and
+ low resolution (8-bit).
+
+ - PHY_SHORT: height at a point is the short int value at that grid
+ point, multipled by heightScale.
+
+ - PHY_FLOAT: height at a point is the float value at that grid
+ point. heightScale is ignored when using the float heightfield
+ data type.
+
+ Whatever the caller specifies as minHeight and maxHeight will be honored.
+ The class will not inspect the heightfield to discover the actual minimum
+ or maximum heights. These values are used to determine the heightfield's
+ axis-aligned bounding box, multiplied by localScaling.
+
+ For usage and testing see the TerrainDemo.
+ */
class btHeightfieldTerrainShape : public btConcaveShape
{
protected:
btVector3 m_localAabbMin;
btVector3 m_localAabbMax;
-
+ btVector3 m_localOrigin;
+
///terrain data
int m_heightStickWidth;
int m_heightStickLength;
+ btScalar m_minHeight;
btScalar m_maxHeight;
btScalar m_width;
btScalar m_length;
+ btScalar m_heightScale;
union
{
unsigned char* m_heightfieldDataUnsignedChar;
+ short* m_heightfieldDataShort;
btScalar* m_heightfieldDataFloat;
void* m_heightfieldDataUnknown;
};
-
- bool m_useFloatData;
+
+ PHY_ScalarType m_heightDataType;
bool m_flipQuadEdges;
bool m_useDiamondSubdivision;
@@ -47,31 +99,49 @@ protected:
btVector3 m_localScaling;
- virtual btScalar getHeightFieldValue(int x,int y) const;
+ virtual btScalar getRawHeightFieldValue(int x,int y) const;
void quantizeWithClamp(int* out, const btVector3& point,int isMax) const;
void getVertex(int x,int y,btVector3& vertex) const;
- inline bool testQuantizedAabbAgainstQuantizedAabb(int* aabbMin1, int* aabbMax1,const int* aabbMin2,const int* aabbMax2) const
- {
- bool overlap = true;
- overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap;
- overlap = (aabbMin1[2] > aabbMax2[2] || aabbMax1[2] < aabbMin2[2]) ? false : overlap;
- overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap;
- return overlap;
- }
+
+
+ /// protected initialization
+ /**
+ Handles the work of constructors so that public constructors can be
+ backwards-compatible without a lot of copy/paste.
+ */
+ void initialize(int heightStickWidth, int heightStickLength,
+ void* heightfieldData, btScalar heightScale,
+ btScalar minHeight, btScalar maxHeight, int upAxis,
+ PHY_ScalarType heightDataType, bool flipQuadEdges);
public:
- btHeightfieldTerrainShape(int heightStickWidth,int heightStickHeight,void* heightfieldData, btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges);
+ /// preferred constructor
+ /**
+ This constructor supports a range of heightfield
+ data types, and allows for a non-zero minimum height value.
+ heightScale is needed for any integer-based heightfield data types.
+ */
+ btHeightfieldTerrainShape(int heightStickWidth,int heightStickLength,
+ void* heightfieldData, btScalar heightScale,
+ btScalar minHeight, btScalar maxHeight,
+ int upAxis, PHY_ScalarType heightDataType,
+ bool flipQuadEdges);
+
+ /// legacy constructor
+ /**
+ The legacy constructor assumes the heightfield has a minimum height
+ of zero. Only unsigned char or floats are supported. For legacy
+ compatibility reasons, heightScale is calculated as maxHeight / 65535
+ (and is only used when useFloatData = false).
+ */
+ btHeightfieldTerrainShape(int heightStickWidth,int heightStickLength,void* heightfieldData, btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges);
virtual ~btHeightfieldTerrainShape();
void setUseDiamondSubdivision(bool useDiamondSubdivision=true) { m_useDiamondSubdivision = useDiamondSubdivision;}
- virtual int getShapeType() const
- {
- return TERRAIN_SHAPE_PROXYTYPE;
- }
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp
index 8f893ac98aa..b107b0bea6e 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp
@@ -17,23 +17,25 @@ subject to the following restrictions:
btMinkowskiSumShape::btMinkowskiSumShape(const btConvexShape* shapeA,const btConvexShape* shapeB)
-:m_shapeA(shapeA),
+: btConvexInternalShape (),
+m_shapeA(shapeA),
m_shapeB(shapeB)
{
+ m_shapeType = MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE;
m_transA.setIdentity();
m_transB.setIdentity();
}
btVector3 btMinkowskiSumShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
{
- btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(-vec*m_transA.getBasis()));
- btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(vec*m_transB.getBasis()));
+ btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(vec*m_transA.getBasis()));
+ btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(-vec*m_transB.getBasis()));
return supVertexA - supVertexB;
}
void btMinkowskiSumShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
{
- //todo: could make recursive use of batching. probably this shape is not used frequently.
+ ///@todo: could make recursive use of batching. probably this shape is not used frequently.
for (int i=0;i<numVectors;i++)
{
supportVerticesOut[i] = localGetSupportingVertexWithoutMargin(vectors[i]);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h
index f9c8427c2f3..6f637fbf40b 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h
@@ -46,8 +46,6 @@ public:
const btTransform& GetTransformB()const { return m_transB;}
- virtual int getShapeType() const { return MINKOWSKI_SUM_SHAPE_PROXYTYPE; }
-
virtual btScalar getMargin() const;
const btConvexShape* getShapeA() const { return m_shapeA;}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
index c709205efc2..9423505290d 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
@@ -18,8 +18,9 @@ subject to the following restrictions:
#include "LinearMath/btQuaternion.h"
btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres)
-:m_inertiaHalfExtents(inertiaHalfExtents)
+:btConvexInternalShape (), m_inertiaHalfExtents(inertiaHalfExtents)
{
+ m_shapeType = MULTI_SPHERE_SHAPE_PROXYTYPE;
btScalar startMargin = btScalar(1e30);
m_numSpheres = numSpheres;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h
index 45968f3947f..97309fbbed9 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h
@@ -62,7 +62,6 @@ public:
return m_radi[index];
}
- virtual int getShapeType() const { return MULTI_SPHERE_SHAPE_PROXYTYPE; }
virtual const char* getName()const
{
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
index 2f108020cdf..d025a5c4450 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
@@ -31,10 +31,12 @@ public:
BT_DECLARE_ALIGNED_ALLOCATOR();
- btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {}
+ btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
{
+ m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
+
btVector3 m_triangle[3];
const unsigned char *vertexbase;
int numverts;
@@ -67,6 +69,8 @@ public:
btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true):
btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
{
+ m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
+
btVector3 m_triangle[3];
const unsigned char *vertexbase;
int numverts;
@@ -107,11 +111,6 @@ public:
m_materialLookup = NULL;
*/
}
- virtual int getShapeType() const
- {
- return MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
- }
-
//debugging
virtual const char* getName()const {return "MULTIMATERIALTRIANGLEMESH";}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp
index a248c55b571..3e73059394c 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp
@@ -319,19 +319,19 @@ void btOptimizedBvh::updateBvhNodes(btStridingMeshInterface* meshInterface,int f
{
int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
- btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
-#ifdef DEBUG_PATCH_COLORS
- btVector3 mycolor = color[index&3];
- graphicsbase[8] = mycolor.getX();
- graphicsbase[9] = mycolor.getY();
- graphicsbase[10] = mycolor.getZ();
-#endif //DEBUG_PATCH_COLORS
-
-
- triangleVerts[j] = btVector3(
- graphicsbase[0]*meshScaling.getX(),
- graphicsbase[1]*meshScaling.getY(),
- graphicsbase[2]*meshScaling.getZ());
+ if (type == PHY_FLOAT)
+ {
+ float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
+ triangleVerts[j] = btVector3(
+ graphicsbase[0]*meshScaling.getX(),
+ graphicsbase[1]*meshScaling.getY(),
+ graphicsbase[2]*meshScaling.getZ());
+ }
+ else
+ {
+ double* graphicsbase = (double*)(vertexbase+graphicsindex*stride);
+ triangleVerts[j] = btVector3( btScalar(graphicsbase[0]*meshScaling.getX()), btScalar(graphicsbase[1]*meshScaling.getY()), btScalar(graphicsbase[2]*meshScaling.getZ()));
+ }
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
index 71c3af38a02..7a79ac25791 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
@@ -15,8 +15,8 @@ subject to the following restrictions:
#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
-btPolyhedralConvexShape::btPolyhedralConvexShape()
-:m_localAabbMin(1,1,1),
+btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape(),
+m_localAabbMin(1,1,1),
m_localAabbMax(-1,-1,-1),
m_isLocalAabbValid(false),
m_optionalHull(0)
@@ -25,7 +25,6 @@ m_optionalHull(0)
}
-
btVector3 btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
{
int i;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h
index 4c4ce7feaa7..7567a42d3ba 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h
@@ -16,7 +16,6 @@ subject to the following restrictions:
#ifndef BU_SHAPE
#define BU_SHAPE
-#include "LinearMath/btPoint3.h"
#include "LinearMath/btMatrix3x3.h"
#include "LinearMath/btAabbUtil2.h"
#include "btConvexInternalShape.h"
@@ -36,12 +35,28 @@ public:
btPolyhedralConvexShape();
//brute force implementations
+
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
+
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
+ void setCachedLocalAabb (const btVector3& aabbMin, const btVector3& aabbMax)
+ {
+ m_isLocalAabbValid = true;
+ m_localAabbMin = aabbMin;
+ m_localAabbMax = aabbMax;
+ }
+
+ inline void getCachedLocalAabb (btVector3& aabbMin, btVector3& aabbMax) const
+ {
+ btAssert(m_isLocalAabbValid);
+ aabbMin = m_localAabbMin;
+ aabbMax = m_localAabbMax;
+ }
+
inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const
{
@@ -59,13 +74,13 @@ public:
virtual int getNumVertices() const = 0 ;
virtual int getNumEdges() const = 0;
- virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const = 0;
- virtual void getVertex(int i,btPoint3& vtx) const = 0;
+ virtual void getEdge(int i,btVector3& pa,btVector3& pb) const = 0;
+ virtual void getVertex(int i,btVector3& vtx) const = 0;
virtual int getNumPlanes() const = 0;
- virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const = 0;
+ virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const = 0;
// virtual int getIndex(int i) const = 0 ;
- virtual bool isInside(const btPoint3& pt,btScalar tolerance) const = 0;
+ virtual bool isInside(const btVector3& pt,btScalar tolerance) const = 0;
/// optional Hull is for optional Separating Axis Test Hull collision detection, see Hull.cpp
class Hull* m_optionalHull;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp
index 2b81a02b557..1fac1538769 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp
@@ -15,11 +15,10 @@ subject to the following restrictions:
#include "btScaledBvhTriangleMeshShape.h"
-btScaledBvhTriangleMeshShape::btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape* childShape,btVector3 localScaling)
-:m_bvhTriMeshShape(childShape),
-m_localScaling(localScaling)
+btScaledBvhTriangleMeshShape::btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape* childShape,const btVector3& localScaling)
+:m_localScaling(localScaling),m_bvhTriMeshShape(childShape)
{
-
+ m_shapeType = SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE;
}
btScaledBvhTriangleMeshShape::~btScaledBvhTriangleMeshShape()
@@ -35,7 +34,7 @@ class btScaledTriangleCallback : public btTriangleCallback
public:
- btScaledTriangleCallback(btTriangleCallback* originalCallback,btVector3 localScaling)
+ btScaledTriangleCallback(btTriangleCallback* originalCallback,const btVector3& localScaling)
:m_originalCallback(originalCallback),
m_localScaling(localScaling)
{
@@ -94,7 +93,7 @@ void btScaledBvhTriangleMeshShape::getAabb(const btTransform& trans,btVector3& a
btMatrix3x3 abs_b = trans.getBasis().absolute();
- btPoint3 center = trans(localCenter);
+ btVector3 center = trans(localCenter);
btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
abs_b[1].dot(localHalfExtents),
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h
index 0a1ef8ce5cb..5da6fe8bc95 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h
@@ -32,15 +32,10 @@ ATTRIBUTE_ALIGNED16(class) btScaledBvhTriangleMeshShape : public btConcaveShape
public:
- btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape* childShape,btVector3 localScaling);
+ btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape* childShape,const btVector3& localScaling);
virtual ~btScaledBvhTriangleMeshShape();
- virtual int getShapeType() const
- {
- //use un-used 'FAST_CONCAVE_MESH_PROXYTYPE' for now, later add SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE to btBroadphaseProxy.h
- return SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE;
- }
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
virtual void setLocalScaling(const btVector3& scaling);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.cpp
index 15cfe432e27..cab7b277289 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.cpp
@@ -18,12 +18,6 @@ subject to the following restrictions:
#include "LinearMath/btQuaternion.h"
-
-btSphereShape ::btSphereShape (btScalar radius)
-{
- m_implicitShapeDimensions.setX(radius);
-}
-
btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
{
(void)vec;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.h
index a6d01cdca9d..bf163d3b501 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.h
@@ -27,8 +27,12 @@ ATTRIBUTE_ALIGNED16(class) btSphereShape : public btConvexInternalShape
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
- btSphereShape (btScalar radius);
-
+ btSphereShape (btScalar radius) : btConvexInternalShape ()
+ {
+ m_shapeType = SPHERE_SHAPE_PROXYTYPE;
+ m_implicitShapeDimensions.setX(radius);
+ m_collisionMargin = radius;
+ }
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
@@ -40,7 +44,6 @@ public:
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
- virtual int getShapeType() const { return SPHERE_SHAPE_PROXYTYPE; }
btScalar getRadius() const { return m_implicitShapeDimensions.getX() * m_localScaling.getX();}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp
index 3c98ca08ddc..17b8776d459 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp
@@ -19,10 +19,11 @@ subject to the following restrictions:
btStaticPlaneShape::btStaticPlaneShape(const btVector3& planeNormal,btScalar planeConstant)
-:m_planeNormal(planeNormal.normalized()),
+: btConcaveShape (), m_planeNormal(planeNormal.normalized()),
m_planeConstant(planeConstant),
m_localScaling(btScalar(0.),btScalar(0.),btScalar(0.))
{
+ m_shapeType = STATIC_PLANE_PROXYTYPE;
// btAssert( btFuzzyZero(m_planeNormal.length() - btScalar(1.)) );
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h
index ddebca73dea..a496013c077 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h
@@ -36,11 +36,6 @@ public:
virtual ~btStaticPlaneShape();
- virtual int getShapeType() const
- {
- return STATIC_PLANE_PROXYTYPE;
- }
-
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h
index 85020dd3f58..e61b11499d4 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.h
@@ -18,16 +18,9 @@ subject to the following restrictions:
#include "LinearMath/btVector3.h"
#include "btTriangleCallback.h"
+#include "btConcaveShape.h"
+
-/// PHY_ScalarType enumerates possible scalar types.
-/// See the btStridingMeshInterface for its use
-typedef enum PHY_ScalarType {
- PHY_FLOAT,
- PHY_DOUBLE,
- PHY_INTEGER,
- PHY_SHORT,
- PHY_FIXEDPOINT88
-} PHY_ScalarType;
/// The btStridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with btBvhTriangleMeshShape and some other collision shapes.
/// Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips.
@@ -77,8 +70,16 @@ class btStridingMeshInterface
virtual void preallocateIndices(int numindices)=0;
virtual bool hasPremadeAabb() const { return false; }
- virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const {}
- virtual void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const {}
+ virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
+ {
+ (void) aabbMin;
+ (void) aabbMax;
+ }
+ virtual void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const
+ {
+ (void) aabbMin;
+ (void) aabbMax;
+ }
const btVector3& getScaling() const {
return m_scaling;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.cpp
index 3aa1eda9964..7fd8fb4691b 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.cpp
@@ -16,35 +16,40 @@ subject to the following restrictions:
#include "btTetrahedronShape.h"
#include "LinearMath/btMatrix3x3.h"
-btBU_Simplex1to4::btBU_Simplex1to4()
-:m_numVertices(0)
+btBU_Simplex1to4::btBU_Simplex1to4() : btPolyhedralConvexShape (),
+m_numVertices(0)
{
+ m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
}
-btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0)
-:m_numVertices(0)
+btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0) : btPolyhedralConvexShape (),
+m_numVertices(0)
{
+ m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
addVertex(pt0);
}
-btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1)
-:m_numVertices(0)
+btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1) : btPolyhedralConvexShape (),
+m_numVertices(0)
{
+ m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
addVertex(pt0);
addVertex(pt1);
}
-btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2)
-:m_numVertices(0)
+btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2) : btPolyhedralConvexShape (),
+m_numVertices(0)
{
+ m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
addVertex(pt0);
addVertex(pt1);
addVertex(pt2);
}
-btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2,const btPoint3& pt3)
-:m_numVertices(0)
+btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2,const btVector3& pt3) : btPolyhedralConvexShape (),
+m_numVertices(0)
{
+ m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
addVertex(pt0);
addVertex(pt1);
addVertex(pt2);
@@ -55,7 +60,7 @@ btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const
-void btBU_Simplex1to4::addVertex(const btPoint3& pt)
+void btBU_Simplex1to4::addVertex(const btVector3& pt)
{
m_vertices[m_numVertices++] = pt;
@@ -87,7 +92,7 @@ int btBU_Simplex1to4::getNumEdges() const
return 0;
}
-void btBU_Simplex1to4::getEdge(int i,btPoint3& pa,btPoint3& pb) const
+void btBU_Simplex1to4::getEdge(int i,btVector3& pa,btVector3& pb) const
{
switch (m_numVertices)
@@ -151,7 +156,7 @@ void btBU_Simplex1to4::getEdge(int i,btPoint3& pa,btPoint3& pb) const
}
-void btBU_Simplex1to4::getVertex(int i,btPoint3& vtx) const
+void btBU_Simplex1to4::getVertex(int i,btVector3& vtx) const
{
vtx = m_vertices[i];
}
@@ -178,7 +183,7 @@ int btBU_Simplex1to4::getNumPlanes() const
}
-void btBU_Simplex1to4::getPlane(btVector3&, btPoint3& ,int ) const
+void btBU_Simplex1to4::getPlane(btVector3&, btVector3& ,int ) const
{
}
@@ -188,7 +193,7 @@ int btBU_Simplex1to4::getIndex(int ) const
return 0;
}
-bool btBU_Simplex1to4::isInside(const btPoint3& ,btScalar ) const
+bool btBU_Simplex1to4::isInside(const btVector3& ,btScalar ) const
{
return false;
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.h
index 09272d61dc2..114ae288bb0 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTetrahedronShape.h
@@ -27,15 +27,15 @@ class btBU_Simplex1to4 : public btPolyhedralConvexShape
protected:
int m_numVertices;
- btPoint3 m_vertices[4];
+ btVector3 m_vertices[4];
public:
btBU_Simplex1to4();
- btBU_Simplex1to4(const btPoint3& pt0);
- btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1);
- btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2);
- btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2,const btPoint3& pt3);
+ btBU_Simplex1to4(const btVector3& pt0);
+ btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1);
+ btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2);
+ btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2,const btVector3& pt3);
void reset()
@@ -44,9 +44,8 @@ public:
}
- virtual int getShapeType() const{ return TETRAHEDRAL_SHAPE_PROXYTYPE; }
- void addVertex(const btPoint3& pt);
+ void addVertex(const btVector3& pt);
//PolyhedralConvexShape interface
@@ -54,17 +53,17 @@ public:
virtual int getNumEdges() const;
- virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
+ virtual void getEdge(int i,btVector3& pa,btVector3& pb) const;
- virtual void getVertex(int i,btPoint3& vtx) const;
+ virtual void getVertex(int i,btVector3& vtx) const;
virtual int getNumPlanes() const;
- virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i) const;
+ virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i) const;
virtual int getIndex(int i) const;
- virtual bool isInside(const btPoint3& pt,btScalar tolerance) const;
+ virtual bool isInside(const btVector3& pt,btScalar tolerance) const;
///getName is for debugging
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h
index c739fc11e8f..adca38041b2 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h
@@ -28,7 +28,7 @@ struct btTriangle
int m_triangleIndex;
};
-///btTriangleBuffer can be useful to collect and store overlapping triangles between AABB and concave objects that support 'processAllTriangles'
+///The btTriangleBuffer callback can be useful to collect and store overlapping triangles between AABB and concave objects that support 'processAllTriangles'
///Example usage of this class:
/// btTriangleBuffer triBuf;
/// concaveShape->processAllTriangles(&triBuf,aabbMin, aabbMax);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp
index b962829041a..5f292532861 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp
@@ -82,7 +82,8 @@ bool btTriangleIndexVertexArray::hasPremadeAabb() const
return (m_hasAabb == 1);
}
-void btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax )
+
+void btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
{
m_aabbMin = aabbMin;
m_aabbMax = aabbMax;
@@ -95,3 +96,4 @@ void btTriangleIndexVertexArray::getPremadeAabb(btVector3* aabbMin, btVector3* a
*aabbMax = m_aabbMax;
}
+
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h
index e546675f802..eb79ff5e47d 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h
@@ -52,9 +52,9 @@ ATTRIBUTE_ALIGNED16( class) btTriangleIndexVertexArray : public btStridingMeshIn
protected:
IndexedMeshArray m_indexedMeshes;
int m_pad[2];
- int m_hasAabb; // using int instead of bool to maintain alignment
- btVector3 m_aabbMin;
- btVector3 m_aabbMax;
+ mutable int m_hasAabb; // using int instead of bool to maintain alignment
+ mutable btVector3 m_aabbMin;
+ mutable btVector3 m_aabbMax;
public:
@@ -106,7 +106,7 @@ public:
virtual void preallocateIndices(int numindices){(void) numindices;}
virtual bool hasPremadeAabb() const;
- virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax );
+ virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const;
virtual void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const;
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp
index 492854ff646..abefa71250a 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp
@@ -1,3 +1,4 @@
+
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp
index 29d26316316..5dcfa51c280 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp
@@ -35,13 +35,13 @@ m_weldingThreshold(0.0)
if (m_use32bitIndices)
{
m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3;
- m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0];
+ m_indexedMeshes[0].m_triangleIndexBase = 0;
m_indexedMeshes[0].m_indexType = PHY_INTEGER;
m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int);
} else
{
m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3;
- m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0];
+ m_indexedMeshes[0].m_triangleIndexBase = 0;
m_indexedMeshes[0].m_indexType = PHY_SHORT;
m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int);
}
@@ -49,12 +49,12 @@ m_weldingThreshold(0.0)
if (m_use4componentVertices)
{
m_indexedMeshes[0].m_numVertices = m_4componentVertices.size();
- m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];
+ m_indexedMeshes[0].m_vertexBase = 0;
m_indexedMeshes[0].m_vertexStride = sizeof(btVector3);
} else
{
m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3;
- m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
+ m_indexedMeshes[0].m_vertexBase = 0;
m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar);
}
@@ -74,17 +74,21 @@ void btTriangleMesh::addIndex(int index)
}
}
-int btTriangleMesh::findOrAddVertex(const btVector3& vertex)
+
+int btTriangleMesh::findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices)
{
//return index of new/existing vertex
- //todo: could use acceleration structure for this
+ ///@todo: could use acceleration structure for this
if (m_use4componentVertices)
{
- for (int i=0;i< m_4componentVertices.size();i++)
- {
- if ((m_4componentVertices[i]-vertex).length2() <= m_weldingThreshold)
+ if (removeDuplicateVertices)
+ {
+ for (int i=0;i< m_4componentVertices.size();i++)
{
- return i;
+ if ((m_4componentVertices[i]-vertex).length2() <= m_weldingThreshold)
+ {
+ return i;
+ }
}
}
m_indexedMeshes[0].m_numVertices++;
@@ -96,17 +100,20 @@ int btTriangleMesh::findOrAddVertex(const btVector3& vertex)
} else
{
- for (int i=0;i< m_3componentVertices.size();i+=3)
+ if (removeDuplicateVertices)
{
- btVector3 vtx(m_3componentVertices[i],m_3componentVertices[i+1],m_3componentVertices[i+2]);
- if ((vtx-vertex).length2() <= m_weldingThreshold)
+ for (int i=0;i< m_3componentVertices.size();i+=3)
{
- return i/3;
+ btVector3 vtx(m_3componentVertices[i],m_3componentVertices[i+1],m_3componentVertices[i+2]);
+ if ((vtx-vertex).length2() <= m_weldingThreshold)
+ {
+ return i/3;
+ }
}
- }
- m_3componentVertices.push_back(vertex.getX());
- m_3componentVertices.push_back(vertex.getY());
- m_3componentVertices.push_back(vertex.getZ());
+ }
+ m_3componentVertices.push_back((float)vertex.getX());
+ m_3componentVertices.push_back((float)vertex.getY());
+ m_3componentVertices.push_back((float)vertex.getZ());
m_indexedMeshes[0].m_numVertices++;
m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
return (m_3componentVertices.size()/3)-1;
@@ -114,13 +121,12 @@ int btTriangleMesh::findOrAddVertex(const btVector3& vertex)
}
-void btTriangleMesh::addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2)
+void btTriangleMesh::addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2,bool removeDuplicateVertices)
{
m_indexedMeshes[0].m_numTriangles++;
-
- addIndex(findOrAddVertex(vertex0));
- addIndex(findOrAddVertex(vertex1));
- addIndex(findOrAddVertex(vertex2));
+ addIndex(findOrAddVertex(vertex0,removeDuplicateVertices));
+ addIndex(findOrAddVertex(vertex1,removeDuplicateVertices));
+ addIndex(findOrAddVertex(vertex2,removeDuplicateVertices));
}
int btTriangleMesh::getNumTriangles() const
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
index 1f51b2f2c87..f06fbb7c22d 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
@@ -25,7 +25,6 @@ subject to the following restrictions:
///It allows either 32bit or 16bit indices, and 4 (x-y-z-w) or 3 (x-y-z) component vertices.
///If you want to share triangle/index data between graphics mesh and collision mesh (btBvhTriangleMeshShape), you can directly use btTriangleIndexVertexArray or derive your own class from btStridingMeshInterface.
///Performance of btTriangleMesh and btTriangleIndexVertexArray used in a btBvhTriangleMeshShape is the same.
-///It has a brute-force option to weld together closeby vertices.
class btTriangleMesh : public btTriangleIndexVertexArray
{
btAlignedObjectArray<btVector3> m_4componentVertices;
@@ -42,7 +41,7 @@ class btTriangleMesh : public btTriangleIndexVertexArray
btTriangleMesh (bool use32bitIndices=true,bool use4componentVertices=true);
- int findOrAddVertex(const btVector3& vertex);
+ int findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices);
void addIndex(int index);
bool getUse32bitIndices() const
@@ -54,8 +53,9 @@ class btTriangleMesh : public btTriangleIndexVertexArray
{
return m_use4componentVertices;
}
-
- void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2);
+ ///By default addTriangle won't search for duplicate vertices, because the search is very slow for large triangle meshes.
+ ///In general it is better to directly use btTriangleIndexVertexArray instead.
+ void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2, bool removeDuplicateVertices=false);
int getNumTriangles() const;
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp
index 0a2c77096d1..1bd7e84a4e7 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp
@@ -22,8 +22,9 @@ subject to the following restrictions:
btTriangleMeshShape::btTriangleMeshShape(btStridingMeshInterface* meshInterface)
-: m_meshInterface(meshInterface)
+: btConcaveShape (), m_meshInterface(meshInterface)
{
+ m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;
if(meshInterface->hasPremadeAabb())
{
meshInterface->getPremadeAabb(&m_localAabbMin, &m_localAabbMax);
@@ -52,7 +53,7 @@ void btTriangleMeshShape::getAabb(const btTransform& trans,btVector3& aabbMin,bt
btMatrix3x3 abs_b = trans.getBasis().absolute();
- btPoint3 center = trans(localCenter);
+ btVector3 center = trans(localCenter);
btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
abs_b[1].dot(localHalfExtents),
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h
index c9eabafe290..53d65799001 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h
@@ -40,7 +40,7 @@ public:
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const
{
- assert(0);
+ btAssert(0);
return localGetSupportingVertex(vec);
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h
index ba7aa0c32a0..4bfb0b9e881 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h
@@ -40,17 +40,13 @@ public:
{
vert = m_vertices1[index];
}
- virtual int getShapeType() const
- {
- return TRIANGLE_SHAPE_PROXYTYPE;
- }
virtual int getNumEdges() const
{
return 3;
}
- virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const
+ virtual void getEdge(int i,btVector3& pa,btVector3& pb) const
{
getVertex(i,pa);
getVertex((i+1)%3,pb);
@@ -83,15 +79,16 @@ public:
- btTriangleShape(const btVector3& p0,const btVector3& p1,const btVector3& p2)
+ btTriangleShape(const btVector3& p0,const btVector3& p1,const btVector3& p2) : btPolyhedralConvexShape ()
{
+ m_shapeType = TRIANGLE_SHAPE_PROXYTYPE;
m_vertices1[0] = p0;
m_vertices1[1] = p1;
m_vertices1[2] = p2;
}
- virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i) const
+ virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i) const
{
getPlaneEquation(i,planeNormal,planeSupport);
}
@@ -107,7 +104,7 @@ public:
normal.normalize();
}
- virtual void getPlaneEquation(int i, btVector3& planeNormal,btPoint3& planeSupport) const
+ virtual void getPlaneEquation(int i, btVector3& planeNormal,btVector3& planeSupport) const
{
(void)i;
calcNormal(planeNormal);
@@ -121,7 +118,7 @@ public:
inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
}
- virtual bool isInside(const btPoint3& pt,btScalar tolerance) const
+ virtual bool isInside(const btVector3& pt,btScalar tolerance) const
{
btVector3 normal;
calcNormal(normal);
@@ -135,7 +132,7 @@ public:
int i;
for (i=0;i<3;i++)
{
- btPoint3 pa,pb;
+ btVector3 pa,pb;
getEdge(i,pa,pb);
btVector3 edge = pb-pa;
btVector3 edgeNormal = edge.cross(normal);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
index ef340286cb0..4c1c716d519 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
@@ -16,9 +16,10 @@ subject to the following restrictions:
#include "btUniformScalingShape.h"
btUniformScalingShape::btUniformScalingShape( btConvexShape* convexChildShape,btScalar uniformScalingFactor):
-m_childConvexShape(convexChildShape),
+btConvexShape (), m_childConvexShape(convexChildShape),
m_uniformScalingFactor(uniformScalingFactor)
{
+ m_shapeType = UNIFORM_SCALING_SHAPE_PROXYTYPE;
}
btUniformScalingShape::~btUniformScalingShape()
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.h
index 1e17fc8e198..945976ac036 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btUniformScalingShape.h
@@ -61,7 +61,6 @@ class btUniformScalingShape : public btConvexShape
return "UniformScalingShape";
}
- virtual int getShapeType() const { return UNIFORM_SCALING_SHAPE_PROXYTYPE; }
///////////////////////////