diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2006-11-29 08:24:52 +0300 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2006-11-29 08:24:52 +0300 |
commit | e720f86a836b9343388beafb56be5be9956a3629 (patch) | |
tree | a703505b43d0936b433dd0fc177644ebdbc2b64b /extern/bullet2/src/BulletCollision/CollisionShapes | |
parent | c5db2965fad723982857c9099114360330f90146 (diff) |
updated to latest Bullet 2.x
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes')
12 files changed, 163 insertions, 14 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h index e85a36c0b73..ee451a9b6c0 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h @@ -220,7 +220,7 @@ public: edgeVert1 = 7; 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 338527d58a4..3bd0a317545 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp @@ -15,7 +15,6 @@ subject to the following restrictions: //#define DISABLE_BVH - #include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" #include "BulletCollision/CollisionShapes/btOptimizedBvh.h" diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.cpp index 29f62828d04..7cd35a91860 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.cpp @@ -17,12 +17,12 @@ subject to the following restrictions: #include "btConcaveShape.h" -ConcaveShape::ConcaveShape() : m_collisionMargin(0.f) +btConcaveShape::btConcaveShape() : m_collisionMargin(0.f) { } -ConcaveShape::~ConcaveShape() +btConcaveShape::~btConcaveShape() { } diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h index 304654531ed..2bbba88bc44 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h @@ -24,15 +24,15 @@ subject to the following restrictions: ///Concave shape proves an interface concave shapes that can produce triangles that overlapping a given AABB. ///Static triangle mesh, infinite plane, height field/landscapes are example that implement this interface. -class ConcaveShape : public btCollisionShape +class btConcaveShape : public btCollisionShape { protected: float m_collisionMargin; public: - ConcaveShape(); + btConcaveShape(); - virtual ~ConcaveShape(); + virtual ~btConcaveShape(); virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const = 0; diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h index c92f42cdee8..c16149e55fb 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h @@ -29,7 +29,7 @@ subject to the following restrictions: /// btEmptyShape is a collision shape without actual collision detection. ///It can be replaced by another shape during runtime -class btEmptyShape : public ConcaveShape +class btEmptyShape : public btConcaveShape { public: btEmptyShape(); diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp new file mode 100644 index 00000000000..57132ee9512 --- /dev/null +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp @@ -0,0 +1,92 @@ +/* +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 "btHeightfieldTerrainShape.h" + +#include "LinearMath/btTransformUtil.h" + + +btHeightfieldTerrainShape::btHeightfieldTerrainShape() +:m_localScaling(0.f,0.f,0.f) +{ +} + + +btHeightfieldTerrainShape::~btHeightfieldTerrainShape() +{ +} + + + +void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const +{ + aabbMin.setValue(-1e30f,-1e30f,-1e30f); + aabbMax.setValue(1e30f,1e30f,1e30f); + +} + + + + +void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const +{ + + btVector3 halfExtents = (aabbMax - aabbMin) * 0.5f; + btScalar radius = halfExtents.length(); + btVector3 center = (aabbMax + aabbMin) * 0.5f; + + //TODO + //this is where the triangles are generated, given AABB and plane equation (normal/constant) +/* + btVector3 tangentDir0,tangentDir1; + + //tangentDir0/tangentDir1 can be precalculated + btPlaneSpace1(m_planeNormal,tangentDir0,tangentDir1); + + btVector3 supVertex0,supVertex1; + + btVector3 projectedCenter = center - (m_planeNormal.dot(center) - m_planeConstant)*m_planeNormal; + + btVector3 triangle[3]; + triangle[0] = projectedCenter + tangentDir0*radius + tangentDir1*radius; + triangle[1] = projectedCenter + tangentDir0*radius - tangentDir1*radius; + triangle[2] = projectedCenter - tangentDir0*radius - tangentDir1*radius; + + callback->processTriangle(triangle,0,0); + + triangle[0] = projectedCenter - tangentDir0*radius - tangentDir1*radius; + triangle[1] = projectedCenter - tangentDir0*radius + tangentDir1*radius; + triangle[2] = projectedCenter + tangentDir0*radius + tangentDir1*radius; + + callback->processTriangle(triangle,0,1); +*/ + +} + +void btHeightfieldTerrainShape::calculateLocalInertia(btScalar mass,btVector3& inertia) +{ + //moving concave objects not supported + + inertia.setValue(0.f,0.f,0.f); +} + +void btHeightfieldTerrainShape::setLocalScaling(const btVector3& scaling) +{ + m_localScaling = scaling; +} +const btVector3& btHeightfieldTerrainShape::getLocalScaling() const +{ + return m_localScaling; +} diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h new file mode 100644 index 00000000000..e4cc9d42d59 --- /dev/null +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h @@ -0,0 +1,58 @@ +/* +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 HEIGHTFIELD_TERRAIN_SHAPE_H +#define HEIGHTFIELD_TERRAIN_SHAPE_H + +#include "BulletCollision/CollisionShapes/btConcaveShape.h" + +///btHeightfieldTerrainShape simulates a 2D heightfield terrain +class btHeightfieldTerrainShape : public btConcaveShape +{ +protected: + btVector3 m_localAabbMin; + btVector3 m_localAabbMax; + + //todo: terrain data + + btVector3 m_localScaling; + +public: + btHeightfieldTerrainShape(); + + virtual ~btHeightfieldTerrainShape(); + + + virtual int getShapeType() const + { + return TERRAIN_SHAPE_PROXYTYPE; + } + + virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; + + virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; + + virtual void calculateLocalInertia(btScalar mass,btVector3& inertia); + + virtual void setLocalScaling(const btVector3& scaling); + + virtual const btVector3& getLocalScaling() const; + + //debugging + virtual char* getName()const {return "HEIGHTFIELD";} + +}; + +#endif //HEIGHTFIELD_TERRAIN_SHAPE_H diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h index 7414d470d7d..65b30e1ff06 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h @@ -21,7 +21,7 @@ subject to the following restrictions: ///StaticPlaneShape simulates an 'infinite' plane by dynamically reporting triangles approximated by intersection of the plane with the AABB. ///Assumed is that the other objects is not also infinite, so a reasonable sized AABB. -class btStaticPlaneShape : public ConcaveShape +class btStaticPlaneShape : public btConcaveShape { protected: btVector3 m_localAabbMin; diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp index f7507b29394..76b5859be7e 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp @@ -76,7 +76,7 @@ void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde break; } default: - ASSERT((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT)); + btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT)); } unLockReadOnlyVertexBase(part); diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp index 154b7145e68..7400d372bee 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp @@ -32,7 +32,7 @@ btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* tri void btTriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) { - ASSERT(subpart< getNumSubParts() ); + btAssert(subpart< getNumSubParts() ); btIndexedMesh& mesh = m_indexedMeshes[subpart]; diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h index 81cb1412db9..4bf000f0c8d 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h @@ -21,7 +21,7 @@ subject to the following restrictions: ///Concave triangle mesh. Uses an interface to access the triangles to allow for sharing graphics/physics triangles. -class btTriangleMeshShape : public ConcaveShape +class btTriangleMeshShape : public btConcaveShape { protected: btStridingMeshInterface* m_meshInterface; diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h index 8e6e2daa4fb..3284a599ea7 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h @@ -59,7 +59,7 @@ public: virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax)const { -// ASSERT(0); +// btAssert(0); getAabbSlow(t,aabbMin,aabbMax); } @@ -116,7 +116,7 @@ public: virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) { - ASSERT(0); + btAssert(0); inertia.setValue(0.f,0.f,0.f); } |