diff --git a/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h b/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h index e0bb67f85..a074a0b15 100644 --- a/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h +++ b/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h @@ -46,6 +46,7 @@ IMPLICIT_CONVEX_SHAPES_START_HERE, CONCAVE_SHAPES_START_HERE, //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy! TRIANGLE_MESH_SHAPE_PROXYTYPE, + SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE, ///used for demo integration FAST/Swift collision library and Bullet FAST_CONCAVE_MESH_PROXYTYPE, //terrain diff --git a/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp b/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp index c18a9b8c3..c64173171 100644 --- a/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp +++ b/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp @@ -117,5 +117,5 @@ const btVector3& btScaledBvhTriangleMeshShape::getLocalScaling() const void btScaledBvhTriangleMeshShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const { ///don't make this a movable object! - btAssert(0); +// btAssert(0); } diff --git a/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h b/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h index 7d4c44bbe..de140effc 100644 --- a/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h +++ b/src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h @@ -39,7 +39,7 @@ public: virtual int getShapeType() const { //use un-used 'FAST_CONCAVE_MESH_PROXYTYPE' for now, later add SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE to btBroadphaseProxy.h - return FAST_CONCAVE_MESH_PROXYTYPE; + return SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE; } virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; @@ -49,6 +49,16 @@ public: virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const; + btBvhTriangleMeshShape* getChildShape() + { + return m_bvhTriMeshShape; + } + + const btBvhTriangleMeshShape* getChildShape() const + { + return m_bvhTriMeshShape; + } + //debugging virtual const char* getName()const {return "SCALEDBVHTRIANGLEMESH";} diff --git a/src/BulletCollision/CollisionShapes/btTriangleBuffer.h b/src/BulletCollision/CollisionShapes/btTriangleBuffer.h index ebf45ae86..1db70a604 100644 --- a/src/BulletCollision/CollisionShapes/btTriangleBuffer.h +++ b/src/BulletCollision/CollisionShapes/btTriangleBuffer.h @@ -1,34 +1,34 @@ -/* -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_TRIANGLE_BUFFER_H -#define BT_TRIANGLE_BUFFER_H - -#include "btTriangleCallback.h" -#include "LinearMath/btAlignedObjectArray.h" - -struct btTriangle -{ - btVector3 m_vertex0; - btVector3 m_vertex1; - btVector3 m_vertex2; - int m_partId; - int m_triangleIndex; -}; - -///btTriangleBuffer can be useful to collect and store overlapping triangles between AABB and concave objects that support 'processAllTriangles' +/* +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_TRIANGLE_BUFFER_H +#define BT_TRIANGLE_BUFFER_H + +#include "btTriangleCallback.h" +#include "LinearMath/btAlignedObjectArray.h" + +struct btTriangle +{ + btVector3 m_vertex0; + btVector3 m_vertex1; + btVector3 m_vertex2; + int m_partId; + int m_triangleIndex; +}; + +///btTriangleBuffer 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); @@ -36,34 +36,34 @@ struct btTriangle /// { /// const btTriangle& tri = triBuf.getTriangle(i); /// //do something useful here with the triangle -/// } -class btTriangleBuffer : public btTriangleCallback -{ - - btAlignedObjectArray m_triangleBuffer; - -public: - - - virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex); - - int getNumTriangles() const - { - return int(m_triangleBuffer.size()); - } - - const btTriangle& getTriangle(int index) const - { - return m_triangleBuffer[index]; - } - - void clearBuffer() - { - m_triangleBuffer.clear(); - } - -}; - - -#endif //BT_TRIANGLE_BUFFER_H - +/// } +class btTriangleBuffer : public btTriangleCallback +{ + + btAlignedObjectArray m_triangleBuffer; + +public: + + + virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex); + + int getNumTriangles() const + { + return int(m_triangleBuffer.size()); + } + + const btTriangle& getTriangle(int index) const + { + return m_triangleBuffer[index]; + } + + void clearBuffer() + { + m_triangleBuffer.clear(); + } + +}; + + +#endif //BT_TRIANGLE_BUFFER_H + diff --git a/src/BulletSoftBody/btSoftBody.h b/src/BulletSoftBody/btSoftBody.h index 5f4942be6..1a10779ad 100644 --- a/src/BulletSoftBody/btSoftBody.h +++ b/src/BulletSoftBody/btSoftBody.h @@ -29,7 +29,7 @@ subject to the following restrictions: #include "BulletCollision/BroadphaseCollision/btDbvt.h" class btBroadphaseInterface; -class btCollisionDispatcher; +class btDispatcher; /* btSoftBodyWorldInfo */ struct btSoftBodyWorldInfo @@ -39,7 +39,7 @@ struct btSoftBodyWorldInfo btScalar water_offset; btVector3 water_normal; btBroadphaseInterface* m_broadphase; - btCollisionDispatcher* m_dispatcher; + btDispatcher* m_dispatcher; btVector3 m_gravity; btSparseSdf<3> m_sparsesdf; }; @@ -607,6 +607,7 @@ public: virtual ~btSoftBody(); /* Check for existing link */ + btAlignedObjectArray m_userIndexMapping; virtual void setCollisionShape(btCollisionShape* collisionShape) { diff --git a/src/BulletSoftBody/btSoftRigidDynamicsWorld.cpp b/src/BulletSoftBody/btSoftRigidDynamicsWorld.cpp index e076a0768..0bda96eda 100644 --- a/src/BulletSoftBody/btSoftRigidDynamicsWorld.cpp +++ b/src/BulletSoftBody/btSoftRigidDynamicsWorld.cpp @@ -21,6 +21,10 @@ subject to the following restrictions: #include "btSoftBody.h" #include "btSoftBodyHelpers.h" + + + + btSoftRigidDynamicsWorld::btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration) :btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration) { @@ -28,6 +32,11 @@ m_drawFlags = fDrawFlags::Std; m_drawNodeTree = true; m_drawFaceTree = false; m_drawClusterTree = false; +m_sbi.m_broadphase = pairCache; +m_sbi.m_dispatcher = dispatcher; +m_sbi.m_sparsesdf.Initialize(); +m_sbi.m_sparsesdf.Reset(); + } btSoftRigidDynamicsWorld::~btSoftRigidDynamicsWorld() diff --git a/src/BulletSoftBody/btSoftRigidDynamicsWorld.h b/src/BulletSoftBody/btSoftRigidDynamicsWorld.h index 1ffeeca33..ec97670e5 100644 --- a/src/BulletSoftBody/btSoftRigidDynamicsWorld.h +++ b/src/BulletSoftBody/btSoftRigidDynamicsWorld.h @@ -13,12 +13,12 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" - #ifndef BT_SOFT_RIGID_DYNAMICS_WORLD_H #define BT_SOFT_RIGID_DYNAMICS_WORLD_H -class btSoftBody; +#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" +#include "btSoftBody.h" + typedef btAlignedObjectArray btSoftBodyArray; class btSoftRigidDynamicsWorld : public btDiscreteDynamicsWorld @@ -29,7 +29,8 @@ class btSoftRigidDynamicsWorld : public btDiscreteDynamicsWorld bool m_drawNodeTree; bool m_drawFaceTree; bool m_drawClusterTree; - + btSoftBodyWorldInfo m_sbi; + protected: virtual void predictUnconstraintMotion(btScalar timeStep); @@ -40,7 +41,6 @@ protected: void solveSoftBodiesConstraints(); - public: @@ -57,6 +57,15 @@ public: int getDrawFlags() const { return(m_drawFlags); } void setDrawFlags(int f) { m_drawFlags=f; } + btSoftBodyWorldInfo& getWorldInfo() + { + return m_sbi; + } + const btSoftBodyWorldInfo& getWorldInfo() const + { + return m_sbi; + } + btSoftBodyArray& getSoftBodyArray() { diff --git a/src/LinearMath/CMakeLists.txt b/src/LinearMath/CMakeLists.txt index 02ffaad72..107c174ed 100644 --- a/src/LinearMath/CMakeLists.txt +++ b/src/LinearMath/CMakeLists.txt @@ -1,35 +1,35 @@ - -INCLUDE_DIRECTORIES( -${BULLET_PHYSICS_SOURCE_DIR}/src } -) - -ADD_LIBRARY(LibLinearMath - btAlignedObjectArray.h - btList.h - btPoolAllocator.h - btRandom.h - btVector3.h - btDefaultMotionState.h - btMatrix3x3.h - btQuadWord.h - btHashMap.h - btScalar.h - btAabbUtil2.h - btConvexHull.h - btConvexHull.cpp - btMinMax.h - btQuaternion.h - btStackAlloc.h - btGeometryUtil.h - btMotionState.h - btTransform.h - btAlignedAllocator.h - btIDebugDraw.h - btPoint3.h - btQuickprof.h - btTransformUtil.h - btQuickprof.cpp - btGeometryUtil.cpp - btAlignedAllocator.cpp -) - + +INCLUDE_DIRECTORIES( +${BULLET_PHYSICS_SOURCE_DIR}/src } +) + +ADD_LIBRARY(LibLinearMath + btAlignedObjectArray.h + btList.h + btPoolAllocator.h + btRandom.h + btVector3.h + btDefaultMotionState.h + btMatrix3x3.h + btQuadWord.h + btHashMap.h + btScalar.h + btAabbUtil2.h + btConvexHull.h + btConvexHull.cpp + btMinMax.h + btQuaternion.h + btStackAlloc.h + btGeometryUtil.h + btMotionState.h + btTransform.h + btAlignedAllocator.h + btIDebugDraw.h + btPoint3.h + btQuickprof.h + btTransformUtil.h + btQuickprof.cpp + btGeometryUtil.cpp + btAlignedAllocator.cpp +) + diff --git a/src/LinearMath/btConvexHull.cpp b/src/LinearMath/btConvexHull.cpp index fdeb0a179..210e74cbd 100644 --- a/src/LinearMath/btConvexHull.cpp +++ b/src/LinearMath/btConvexHull.cpp @@ -869,6 +869,8 @@ bool HullLibrary::CleanupVertices(unsigned int svcount, { if ( svcount == 0 ) return false; + m_vertexIndexMapping.resize(0); + #define EPSILON btScalar(0.000001) /* close enough to consider two btScalaring point numbers to be 'the same'. */ @@ -1027,6 +1029,7 @@ bool HullLibrary::CleanupVertices(unsigned int svcount, v[0] = px; v[1] = py; v[2] = pz; + } break; @@ -1041,6 +1044,7 @@ bool HullLibrary::CleanupVertices(unsigned int svcount, dest[2] = pz; vcount++; } + m_vertexIndexMapping.push_back(j); } } @@ -1116,13 +1120,22 @@ bool HullLibrary::CleanupVertices(unsigned int svcount, void HullLibrary::BringOutYourDead(const btVector3* verts,unsigned int vcount, btVector3* overts,unsigned int &ocount,unsigned int *indices,unsigned indexcount) { + btAlignedObjectArraytmpIndices; + tmpIndices.resize(m_vertexIndexMapping.size()); + int i; + + for (i=0;i(vcount)); memset(&usedIndices[0],0,sizeof(unsigned int)*vcount); ocount = 0; - for (unsigned int i=0; i=0 && ocount <= vcount ); usedIndices[static_cast(v)] = ocount; // assign new index remapping + + } } diff --git a/src/LinearMath/btConvexHull.h b/src/LinearMath/btConvexHull.h index 5caa73d89..dd830051c 100644 --- a/src/LinearMath/btConvexHull.h +++ b/src/LinearMath/btConvexHull.h @@ -192,6 +192,9 @@ class HullLibrary public: + btAlignedObjectArray m_vertexIndexMapping; + + HullError CreateConvexHull(const HullDesc& desc, // describes the input request HullResult& result); // contains the resulst HullError ReleaseResult(HullResult &result); // release memory allocated for this result, we are done with it.