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
path: root/extern
diff options
context:
space:
mode:
authorErwin Coumans <blender@erwincoumans.com>2006-11-29 08:24:52 +0300
committerErwin Coumans <blender@erwincoumans.com>2006-11-29 08:24:52 +0300
commite720f86a836b9343388beafb56be5be9956a3629 (patch)
treea703505b43d0936b433dd0fc177644ebdbc2b64b /extern
parentc5db2965fad723982857c9099114360330f90146 (diff)
updated to latest Bullet 2.x
Diffstat (limited to 'extern')
-rw-r--r--extern/bullet2/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h2
-rw-r--r--extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h5
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp6
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h4
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp17
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h18
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp4
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp63
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h17
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp1
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.cpp4
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConcaveShape.h6
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btEmptyShape.h2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp92
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h58
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMeshShape.h2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h4
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h3
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h6
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.cpp143
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.h3
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp4
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h2
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp13
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp2
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h2
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h4
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h8
-rw-r--r--extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp4
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp25
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h16
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h3
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp8
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h2
-rw-r--r--extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp6
-rw-r--r--extern/bullet2/src/LinearMath/btScalar.h4
-rw-r--r--extern/bullet2/src/LinearMath/btStackAlloc.h106
41 files changed, 418 insertions, 259 deletions
diff --git a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h
index 7b35df09db6..3ad2467886b 100644
--- a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h
+++ b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h
@@ -44,6 +44,8 @@ CONCAVE_SHAPES_START_HERE,
TRIANGLE_MESH_SHAPE_PROXYTYPE,
///used for demo integration FAST/Swift collision library and Bullet
FAST_CONCAVE_MESH_PROXYTYPE,
+ //terrain
+ TERRAIN_SHAPE_PROXYTYPE,
///Used for GIMPACT Trimesh integration
GIMPACT_SHAPE_PROXYTYPE,
diff --git a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h
index 415c398a101..1a471398638 100644
--- a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h
+++ b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h
@@ -29,6 +29,7 @@ enum btCollisionDispatcherId
};
class btPersistentManifold;
+class btStackAlloc;
struct btDispatcherInfo
{
@@ -45,7 +46,8 @@ struct btDispatcherInfo
m_useContinuous(false),
m_debugDraw(0),
m_enableSatConvex(false),
- m_enableSPU(false)
+ m_enableSPU(false),
+ m_stackAllocator(0)
{
}
@@ -57,6 +59,7 @@ struct btDispatcherInfo
class btIDebugDraw* m_debugDraw;
bool m_enableSatConvex;
bool m_enableSPU;
+ btStackAlloc* m_stackAllocator;
};
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
index c9d21f2d9a3..e8865a2c45a 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
@@ -101,7 +101,7 @@ btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1)
{
gNumManifold++;
- //ASSERT(gNumManifold < 65535);
+ //btAssert(gNumManifold < 65535);
btCollisionObject* body0 = (btCollisionObject*)b0;
@@ -145,7 +145,7 @@ void btCollisionDispatcher::releaseManifold(btPersistentManifold* manifold)
btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
{
-#define USE_DISPATCH_REGISTRY_ARRAY 1
+
#ifdef USE_DISPATCH_REGISTRY_ARRAY
btCollisionAlgorithmConstructionInfo ci;
@@ -194,6 +194,7 @@ btCollisionAlgorithmCreateFunc* btCollisionDispatcher::internalFindCreateFunc(in
}
+#ifndef USE_DISPATCH_REGISTRY_ARRAY
btCollisionAlgorithm* btCollisionDispatcher::internalFindAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
{
@@ -232,6 +233,7 @@ btCollisionAlgorithm* btCollisionDispatcher::internalFindAlgorithm(btCollisionOb
return new btEmptyAlgorithm(ci);
}
+#endif //USE_DISPATCH_REGISTRY_ARRAY
bool btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1)
{
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
index 4e97bce9d65..41bc98e1dca 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
@@ -30,7 +30,7 @@ class btOverlappingPairCache;
#include "btCollisionCreateFunc.h"
-
+#define USE_DISPATCH_REGISTRY_ARRAY 1
///btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
@@ -56,7 +56,9 @@ class btCollisionDispatcher : public btDispatcher
btCollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc;
btCollisionAlgorithmCreateFunc* m_emptyCreateFunc;
+#ifndef USE_DISPATCH_REGISTRY_ARRAY
btCollisionAlgorithm* internalFindAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0);
+#endif //USE_DISPATCH_REGISTRY_ARRAY
public:
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
index 775ed3e13d8..9df6d7186ec 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
@@ -25,6 +25,7 @@ subject to the following restrictions:
#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
#include "LinearMath/btAabbUtil2.h"
#include "LinearMath/btQuickprof.h"
+#include "LinearMath/btStackAlloc.h"
//When the user doesn't provide dispatcher or broadphase, create basic versions (and delete them in destructor)
#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
@@ -32,26 +33,22 @@ subject to the following restrictions:
#include <algorithm>
-btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache)
+btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache, int stackSize)
:m_dispatcher1(dispatcher),
m_broadphasePairCache(pairCache),
m_ownsDispatcher(false),
m_ownsBroadphasePairCache(false)
{
-}
-
-
-btCollisionWorld::btCollisionWorld()
-: m_dispatcher1(new btCollisionDispatcher()),
-m_broadphasePairCache(new btSimpleBroadphase()),
-m_ownsDispatcher(true),
-m_ownsBroadphasePairCache(true)
-{
+ m_stackAlloc = new btStackAlloc(stackSize);
+ m_dispatchInfo.m_stackAllocator = m_stackAlloc;
}
btCollisionWorld::~btCollisionWorld()
{
+ m_stackAlloc->destroy();
+ delete m_stackAlloc;
+
//clean up remaining objects
std::vector<btCollisionObject*>::iterator i;
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
index e212e520bda..9c548784829 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
@@ -64,7 +64,7 @@ subject to the following restrictions:
#ifndef COLLISION_WORLD_H
#define COLLISION_WORLD_H
-
+class btStackAlloc;
class btCollisionShape;
class btBroadphaseInterface;
#include "LinearMath/btVector3.h"
@@ -88,6 +88,10 @@ protected:
btDispatcher* m_dispatcher1;
+ btDispatcherInfo m_dispatchInfo;
+
+ btStackAlloc* m_stackAlloc;
+
btOverlappingPairCache* m_broadphasePairCache;
bool m_ownsDispatcher;
@@ -95,11 +99,8 @@ protected:
public:
- //this constructor will create and own a dispatcher and paircache and delete it at destruction
- btCollisionWorld();
-
//this constructor doesn't own the dispatcher and paircache/broadphase
- btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache);
+ btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache, int stackSize = 2*1024*1024);
virtual ~btCollisionWorld();
@@ -237,7 +238,12 @@ public:
void removeCollisionObject(btCollisionObject* collisionObject);
virtual void performDiscreteCollisionDetection( btDispatcherInfo& dispatchInfo);
-
+
+ btDispatcherInfo& getDispatchInfo()
+ {
+ return m_dispatchInfo;
+ }
+
};
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
index 8ad3967bac2..06adb3a04c8 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
@@ -172,7 +172,7 @@ void btConvexConcaveCollisionAlgorithm::processCollision (btCollisionObject* bod
btCollisionObject* triOb = triBody;
- ConcaveShape* concaveShape = static_cast<ConcaveShape*>( triOb->getCollisionShape());
+ btConcaveShape* concaveShape = static_cast<btConcaveShape*>( triOb->getCollisionShape());
if (convexBody->getCollisionShape()->isConvex())
{
@@ -288,7 +288,7 @@ float btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject
btCollisionObject* concavebody = triBody;
- ConcaveShape* triangleMesh = (ConcaveShape*) concavebody->getCollisionShape();
+ btConcaveShape* triangleMesh = (btConcaveShape*) concavebody->getCollisionShape();
if (triangleMesh)
{
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
index e896508bdb9..09457aea3e9 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
@@ -61,37 +61,28 @@ subject to the following restrictions:
#endif //USE_HULL
-bool gUseEpa = true;
-
-
-#ifdef WIN32
-void DrawRasterizerLine(const float* from,const float* to,int color);
-#endif
-
-
-
-
-//#define PROCESS_SINGLE_CONTACT
-#ifdef WIN32
-bool gForceBoxBox = false;//false;//true;
-
-#else
-bool gForceBoxBox = false;//false;//true;
-#endif
-bool gBoxBoxUseGjk = true;//true;//false;
-bool gDisableConvexCollision = false;
+btConvexConvexAlgorithm::CreateFunc::CreateFunc()
+{
+ m_ownsSolvers = true;
+ m_simplexSolver = new btVoronoiSimplexSolver();
+ m_pdSolver = new btGjkEpaPenetrationDepthSolver;
+}
+btConvexConvexAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
+{
+ m_ownsSolvers = false;
+ m_simplexSolver = simplexSolver;
+ m_pdSolver = pdSolver;
+}
-btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1)
+btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
: btCollisionAlgorithm(ci),
-m_gjkPairDetector(0,0,&m_simplexSolver,0),
-m_useEpa(!gUseEpa),
+m_gjkPairDetector(0,0,simplexSolver,pdSolver),
m_ownManifold (false),
m_manifoldPtr(mf),
m_lowLevelOfDetail(false)
{
- checkPenetrationDepthSolver();
}
@@ -115,27 +106,6 @@ void btConvexConvexAlgorithm ::setLowLevelOfDetail(bool useLowLevel)
-static btGjkEpaPenetrationDepthSolver gEpaPenetrationDepthSolver;
-static btMinkowskiPenetrationDepthSolver gPenetrationDepthSolver;
-
-
-
-void btConvexConvexAlgorithm::checkPenetrationDepthSolver()
-{
- if (m_useEpa != gUseEpa)
- {
- m_useEpa = gUseEpa;
- if (m_useEpa)
- {
- m_gjkPairDetector.setPenetrationDepthSolver(&gEpaPenetrationDepthSolver);
- } else
- {
- m_gjkPairDetector.setPenetrationDepthSolver(&gPenetrationDepthSolver);
- }
- }
-
-}
-
//
// Convex-Convex collision algorithm
@@ -164,7 +134,6 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
}
#else
- checkPenetrationDepthSolver();
btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
@@ -176,7 +145,8 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
m_gjkPairDetector.setMinkowskiB(min1);
input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
-
+ input.m_stackAlloc = dispatchInfo.m_stackAllocator;
+
// input.m_maximumDistanceSquared = 1e30f;
input.m_transformA = body0->getWorldTransform();
@@ -209,7 +179,6 @@ float btConvexConvexAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btC
if (disableCcd)
return 1.f;
- checkPenetrationDepthSolver();
//An adhoc way of testing the Continuous Collision Detection algorithms
//One object is approximated as a sphere, to simplify things
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h
index 1cd94408f1f..ccfe6d5b8cb 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h
@@ -28,23 +28,17 @@ class btConvexPenetrationDepthSolver;
///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations.
class btConvexConvexAlgorithm : public btCollisionAlgorithm
{
- //ConvexPenetrationDepthSolver* m_penetrationDepthSolver;
- btVoronoiSimplexSolver m_simplexSolver;
btGjkPairDetector m_gjkPairDetector;
- bool m_useEpa;
public:
bool m_ownManifold;
btPersistentManifold* m_manifoldPtr;
bool m_lowLevelOfDetail;
-
- void checkPenetrationDepthSolver();
-
public:
- btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
+ btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
virtual ~btConvexConvexAlgorithm();
@@ -62,9 +56,16 @@ public:
struct CreateFunc :public btCollisionAlgorithmCreateFunc
{
+ btConvexPenetrationDepthSolver* m_pdSolver;
+ btSimplexSolverInterface* m_simplexSolver;
+ bool m_ownsSolvers;
+
+ CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
+ CreateFunc();
+
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
{
- return new btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1);
+ return new btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver);
}
};
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);
}
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
index ba02ea56e83..188c8258c8e 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
@@ -17,6 +17,7 @@ subject to the following restrictions:
#ifndef CONVEX_PENETRATION_DEPTH_H
#define CONVEX_PENETRATION_DEPTH_H
+class btStackAlloc;
class btVector3;
#include "btSimplexSolverInterface.h"
class btConvexShape;
@@ -33,7 +34,7 @@ public:
btConvexShape* convexA,btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btPoint3& pa, btPoint3& pb,
- class btIDebugDraw* debugDraw
+ class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
) = 0;
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
index ef2b480fa62..e9db97d1b13 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
@@ -18,7 +18,7 @@ subject to the following restrictions:
#define DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
#include "LinearMath/btTransform.h"
#include "LinearMath/btVector3.h"
-
+class btStackAlloc;
/// This interface is made to be used by an iterative approach to do TimeOfImpact calculations
/// This interface allows to query for closest points and penetration depth between two (convex) objects
@@ -42,13 +42,15 @@ struct btDiscreteCollisionDetectorInterface
struct ClosestPointInput
{
ClosestPointInput()
- :m_maximumDistanceSquared(1e30f)
+ :m_maximumDistanceSquared(1e30f),
+ m_stackAlloc(0)
{
}
btTransform m_transformA;
btTransform m_transformB;
btScalar m_maximumDistanceSquared;
+ btStackAlloc* m_stackAlloc;
};
virtual ~btDiscreteCollisionDetectorInterface() {};
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.cpp
index ade4635c57b..8abdfdbb7e5 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.cpp
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.cpp
@@ -26,6 +26,15 @@ Nov.2006
#include "btGjkEpa.h"
#include <string.h> //for memset
+#include <LinearMath/btStackAlloc.h>
+
+#if defined(DEBUG) || defined (_DEBUG)
+#include <stdio.h> //for debug printf
+#ifdef __SPU__
+#include <spu_printf.h>
+#define printf spu_printf
+#endif //__SPU__
+#endif
namespace gjkepa_impl
{
@@ -58,21 +67,18 @@ typedef btMatrix3x3 Rotation;
// Const
//
-static const U chkPrecision =1/U(sizeof(F)==4);
-
-static const F cstInf =F(1/sin(0.));
-static const F cstPi =F(acos(-1.));
-static const F cst2Pi =cstPi*2;
-static const U GJK_maxiterations =128;
-static const U GJK_hashsize =1<<6;
-static const U GJK_hashmask =GJK_hashsize-1;
-static const F GJK_insimplex_eps =F(0.0001);
-static const F GJK_sqinsimplex_eps =GJK_insimplex_eps*GJK_insimplex_eps;
-
-static const U EPA_maxiterations =256;
-static const F EPA_inface_eps =F(0.01);
-static const F EPA_accuracy =F(0.001);
+#define cstInf SIMD_INFINITY
+#define cstPi SIMD_PI
+#define cst2Pi SIMD_2_PI
+#define GJK_maxiterations (128)
+#define GJK_hashsize (1<<6)
+#define GJK_hashmask (GJK_hashsize-1)
+#define GJK_insimplex_eps F(0.0001)
+#define GJK_sqinsimplex_eps (GJK_insimplex_eps*GJK_insimplex_eps)
+#define EPA_maxiterations 256
+#define EPA_inface_eps F(0.01)
+#define EPA_accuracy F(0.001)
//
// Utils
@@ -95,80 +101,7 @@ throw(object); }
template <typename T> static inline void Raise(const T&) {}
#endif
- struct Block
- {
- Block* previous;
- U1* address;
- };
-//
-// StackAlloc
-//
-struct StackAlloc
- {
-
-
- StackAlloc() { ctor(); }
- StackAlloc(U size) { ctor();Create(size); }
- ~StackAlloc() { Free(); }
- void Create(U size)
- {
- Free();
- data = new U1[size];
- totalsize = size;
- }
- void Free()
- {
- if(usedsize==0)
- {
- if(!ischild) delete[] data;
- data = 0;
- usedsize = 0;
- } else Raise(L"StackAlloc is still in use");
- }
- U1* Allocate(U size)
- {
- const U nus(usedsize+size);
- if(nus<totalsize)
- {
- usedsize=nus;
- return(data+(usedsize-size));
- }
- Raise(L"Not enough memory");
- return(0);
- }
- Block* BeginBlock()
- {
- Block* pb = (Block*)Allocate(sizeof(Block));
- pb->previous = current;
- pb->address = data+usedsize;
- current = pb;
- return(pb);
- }
- void EndBlock(Block* block)
- {
- if(block==current)
- {
- current = block->previous;
- usedsize = (U)((block->address-data)-sizeof(Block));
- } else Raise(L"Unmatched blocks");
- }
-
- private:
- void ctor()
- {
- data = 0;
- totalsize = 0;
- usedsize = 0;
- current = 0;
- ischild = false;
- }
- U1* data;
- U totalsize;
- U usedsize;
- Block* current;
- Z ischild;
- };
//
// GJK
@@ -185,8 +118,8 @@ struct GJK
Vector3 v;
He* n;
};
- StackAlloc* sa;
- Block* sablock;
+ btStackAlloc* sa;
+ btBlock* sablock;
He* table[GJK_hashsize];
Rotation wrotations[2];
Vector3 positions[2];
@@ -198,7 +131,7 @@ struct GJK
F margin;
Z failed;
//
- GJK(StackAlloc* psa,
+ GJK(btStackAlloc* psa,
const Rotation& wrot0,const Vector3& pos0,const btConvexShape* shape0,
const Rotation& wrot1,const Vector3& pos1,const btConvexShape* shape1,
F pmargin=0)
@@ -206,14 +139,14 @@ struct GJK
wrotations[0]=wrot0;positions[0]=pos0;shapes[0]=shape0;
wrotations[1]=wrot1;positions[1]=pos1;shapes[1]=shape1;
sa =psa;
- sablock =sa->BeginBlock();
+ sablock =sa->beginBlock();
margin =pmargin;
failed =false;
}
//
~GJK()
{
- sa->EndBlock(sablock);
+ sa->endBlock(sablock);
}
// vdh : very dumm hash
static inline U Hash(const Vector3& v)
@@ -243,7 +176,7 @@ struct GJK
const U h(Hash(ray));
He* e = (He*)(table[h]);
while(e) { if(e->v==ray) { --order;return(false); } else e=e->n; }
- e=(He*)sa->Allocate(sizeof(He));e->v=ray;e->n=table[h];table[h]=e;
+ e=(He*)sa->allocate(sizeof(He));e->v=ray;e->n=table[h];table[h]=e;
Support(ray,simplex[++order]);
return(ray.dot(SPXW(order))>0);
}
@@ -401,7 +334,7 @@ struct EPA
};
//
GJK* gjk;
- StackAlloc* sa;
+ btStackAlloc* sa;
Face* root;
U nfaces;
U iterations;
@@ -464,7 +397,7 @@ c) const
//
inline Face* NewFace(const GJK::Mkv* a,const GJK::Mkv* b,const GJK::Mkv* c)
{
- Face* pf = (Face*)sa->Allocate(sizeof(Face));
+ Face* pf = (Face*)sa->allocate(sizeof(Face));
if(Set(pf,a,b,c))
{
if(root) root->prev=pf;
@@ -506,7 +439,7 @@ c) const
//
GJK::Mkv* Support(const Vector3& w) const
{
- GJK::Mkv* v =(GJK::Mkv*)sa->Allocate(sizeof(GJK::Mkv));
+ GJK::Mkv* v =(GJK::Mkv*)sa->allocate(sizeof(GJK::Mkv));
gjk->Support(w,*v);
return(v);
}
@@ -540,7 +473,7 @@ ff)
//
inline F EvaluatePD(F accuracy=EPA_accuracy)
{
- Block* sablock = sa->BeginBlock();
+ btBlock* sablock = sa->beginBlock();
Face* bestface = 0;
U markid(1);
depth = -cstInf;
@@ -579,7 +512,7 @@ U eidx[9][4]={{0,0,4,0},{0,1,2,1},{0,2,1,2},{1,1,5,2},{1,0,2,0},{2,2,3,2},{3,1,5
U i;
for( i=0;i<=gjk->order;++i) {
-basemkv[i]=(GJK::Mkv*)sa->Allocate(sizeof(GJK::Mkv));*basemkv[i]=gjk->simplex[i];
+basemkv[i]=(GJK::Mkv*)sa->allocate(sizeof(GJK::Mkv));*basemkv[i]=gjk->simplex[i];
}
for( i=0;i<nfidx;++i,pfidx+=3) {
basefaces[i]=NewFace(basemkv[pfidx[0]],basemkv[pfidx[1]],basemkv[pfidx[2]]);
@@ -589,7 +522,7 @@ Link(basefaces[peidx[0]],peidx[1],basefaces[peidx[2]],peidx[3]); }
}
if(0==nfaces)
{
- sa->EndBlock(sablock);
+ sa->endBlock(sablock);
return(depth);
}
/* Expand hull */
@@ -632,7 +565,7 @@ nf+=BuildHorizon(markid,w,*bf->f[i],bf->e[i],cf,ff); }
nearest[0] = features[0][0]*b.x()+features[0][1]*b.y()+features[0][2]*b.z();
nearest[1] = features[1][0]*b.x()+features[1][1]*b.y()+features[1][2]*b.z();
} else failed=true;
- sa->EndBlock(sablock);
+ sa->endBlock(sablock);
return(depth);
}
};
@@ -644,17 +577,17 @@ nf+=BuildHorizon(markid,w,*bf->f[i],bf->e[i],cf,ff); }
using namespace gjkepa_impl;
-/* Need some kind of stackalloc , create a static one till bullet provide
-one. */
-static const U g_sasize((1024<<10)*2);
-static StackAlloc g_sa(g_sasize);
+
//
bool btGjkEpaSolver::Collide(btConvexShape *shape0,const btTransform &wtrs0,
btConvexShape *shape1,const btTransform &wtrs1,
btScalar radialmargin,
+ btStackAlloc* stackAlloc,
sResults& results)
{
+
+
/* Initialize */
results.witnesses[0] =
results.witnesses[1] =
@@ -664,7 +597,7 @@ results.status = sResults::Separated;
results.epa_iterations = 0;
results.gjk_iterations = 0;
/* Use GJK to locate origin */
-GJK gjk(&g_sa,
+GJK gjk(stackAlloc,
wtrs0.getBasis(),wtrs0.getOrigin(),shape0,
wtrs1.getBasis(),wtrs1.getOrigin(),shape1,
radialmargin+EPA_accuracy);
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.h
index d26ac9cdfe5..359829f8f31 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpa.h
@@ -23,6 +23,8 @@ Nov.2006
#define _05E48D53_04E0_49ad_BB0A_D74FE62E7366_
#include "BulletCollision/CollisionShapes/btConvexShape.h"
+class btStackAlloc;
+
///btGjkEpaSolver contributed under zlib by Nathanael Presson
struct btGjkEpaSolver
{
@@ -44,6 +46,7 @@ struct sResults
static bool Collide(btConvexShape* shape0,const btTransform& wtrs0,
btConvexShape* shape1,const btTransform& wtrs1,
btScalar radialmargin,
+ btStackAlloc* stackAlloc,
sResults& results);
};
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
index c2958b22b6a..3d252751c9a 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
@@ -23,7 +23,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
btConvexShape* pConvexA, btConvexShape* pConvexB,
const btTransform& transformA, const btTransform& transformB,
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
- class btIDebugDraw* debugDraw )
+ class btIDebugDraw* debugDraw, btStackAlloc* stackAlloc )
{
@@ -32,7 +32,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
btGjkEpaSolver::sResults results;
if(btGjkEpaSolver::Collide( pConvexA,transformA,
pConvexB,transformB,
- radialmargin,results))
+ radialmargin,stackAlloc,results))
{
// debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
index a7332a7a51a..3916ba0776c 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
@@ -29,7 +29,7 @@ class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
btConvexShape* pConvexA, btConvexShape* pConvexB,
const btTransform& transformA, const btTransform& transformB,
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
- class btIDebugDraw* debugDraw );
+ class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc );
private :
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
index 646c07a5d39..0ce04dcfad8 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
@@ -20,6 +20,10 @@ subject to the following restrictions:
#if defined(DEBUG) || defined (_DEBUG)
#include <stdio.h> //for debug printf
+#ifdef __SPU__
+#include <spu_printf.h>
+#define printf spu_printf
+#endif //__SPU__
#endif
//must be above the machine epsilon
@@ -29,10 +33,7 @@ subject to the following restrictions:
int gNumDeepPenetrationChecks = 0;
int gNumGjkChecks = 0;
-#ifdef __SPU__
-#include <spu_printf.h>
-#define printf spu_printf
-#endif //__SPU__
+
btGjkPairDetector::btGjkPairDetector(btConvexShape* objectA,btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver)
:m_cachedSeparatingAxis(0.f,0.f,1.f),
@@ -202,7 +203,7 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
normalInB *= rlen; //normalize
btScalar s = btSqrt(squaredDistance);
- ASSERT(s > btScalar(0.0));
+ btAssert(s > btScalar(0.0));
pointOnA -= m_cachedSeparatingAxis * (marginA / s);
pointOnB += m_cachedSeparatingAxis * (marginB / s);
distance = ((1.f/rlen) - margin);
@@ -236,7 +237,7 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
m_minkowskiA,m_minkowskiB,
localTransA,localTransB,
m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB,
- debugDraw
+ debugDraw,input.m_stackAlloc
);
if (isValid2)
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
index 74cf2b7c071..de6749a9b72 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
@@ -74,7 +74,7 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
btConvexShape* convexA,btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btPoint3& pa, btPoint3& pb,
- class btIDebugDraw* debugDraw
+ class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
)
{
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
index c287195317e..b348b21b52a 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
@@ -28,7 +28,7 @@ public:
btConvexShape* convexA,btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btPoint3& pa, btPoint3& pb,
- class btIDebugDraw* debugDraw
+ class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
);
};
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h
index ab0e8767e5d..c2372b648f6 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h
@@ -86,13 +86,13 @@ public:
inline const btManifoldPoint& getContactPoint(int index) const
{
- ASSERT(index < m_cachedPoints);
+ btAssert(index < m_cachedPoints);
return m_pointCache[index];
}
inline btManifoldPoint& getContactPoint(int index)
{
- ASSERT(index < m_cachedPoints);
+ btAssert(index < m_cachedPoints);
return m_pointCache[index];
}
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h
index bb2aecfb6d0..384e4f7bab5 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btJacobianEntry.h
@@ -50,7 +50,7 @@ public:
m_1MinvJt = inertiaInvB * m_bJ;
m_Adiag = massInvA + m_0MinvJt.dot(m_aJ) + massInvB + m_1MinvJt.dot(m_bJ);
- ASSERT(m_Adiag > 0.0f);
+ btAssert(m_Adiag > 0.0f);
}
//angular constraint between two different rigidbodies
@@ -67,7 +67,7 @@ public:
m_1MinvJt = inertiaInvB * m_bJ;
m_Adiag = m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ);
- ASSERT(m_Adiag > 0.0f);
+ btAssert(m_Adiag > 0.0f);
}
//angular constraint between two different rigidbodies
@@ -83,7 +83,7 @@ public:
m_1MinvJt = inertiaInvB * m_bJ;
m_Adiag = m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ);
- ASSERT(m_Adiag > 0.0f);
+ btAssert(m_Adiag > 0.0f);
}
//constraint on one rigidbody
@@ -101,7 +101,7 @@ public:
m_1MinvJt = btVector3(0.f,0.f,0.f);
m_Adiag = massInvA + m_0MinvJt.dot(m_aJ);
- ASSERT(m_Adiag > 0.0f);
+ btAssert(m_Adiag > 0.0f);
}
btScalar getDiagonal() const { return m_Adiag; }
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp
index bf92434b69b..edca6c8fa08 100644
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp
@@ -51,7 +51,7 @@ void btSolve2LinearConstraint::resolveUnilateralPairConstraint(
if (fabs(len) >= SIMD_EPSILON)
return;
- ASSERT(len < SIMD_EPSILON);
+ btAssert(len < SIMD_EPSILON);
//this jacobian entry could be re-used for all iterations
@@ -133,7 +133,7 @@ void btSolve2LinearConstraint::resolveBilateralPairConstraint(
if (fabs(len) >= SIMD_EPSILON)
return;
- ASSERT(len < SIMD_EPSILON);
+ btAssert(len < SIMD_EPSILON);
//this jacobian entry could be re-used for all iterations
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
index 0dece6b20e6..f59598f2a53 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
@@ -57,19 +57,6 @@ subject to the following restrictions:
#include <algorithm>
-btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btConstraintSolver* constraintSolver)
-:btDynamicsWorld(),
-m_constraintSolver(constraintSolver? constraintSolver: new btSequentialImpulseConstraintSolver),
-m_debugDrawer(0),
-m_gravity(0,-10,0),
-m_localTime(1.f/60.f),
-m_profileTimings(0)
-{
- m_islandManager = new btSimulationIslandManager();
- m_ownsIslandManager = true;
- m_ownsConstraintSolver = (constraintSolver==0);
-}
-
btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver)
:btDynamicsWorld(dispatcher,pairCache),
@@ -267,27 +254,27 @@ void btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep)
///apply gravity, predict motion
predictUnconstraintMotion(timeStep);
- btDispatcherInfo dispatchInfo;
+ btDispatcherInfo& dispatchInfo = getDispatchInfo();
+
dispatchInfo.m_timeStep = timeStep;
dispatchInfo.m_stepCount = 0;
dispatchInfo.m_debugDraw = getDebugDrawer();
-
///perform collision detection
performDiscreteCollisionDetection(dispatchInfo);
calculateSimulationIslands();
- btContactSolverInfo infoGlobal;
- infoGlobal.m_timeStep = timeStep;
+
+ getSolverInfo().m_timeStep = timeStep;
///solve non-contact constraints
- solveNoncontactConstraints(infoGlobal);
+ solveNoncontactConstraints(getSolverInfo());
///solve contact constraints
- solveContactConstraints(infoGlobal);
+ solveContactConstraints(getSolverInfo());
///CallbackTriggers();
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
index 4aa83683cd5..72619091c6f 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h
@@ -23,7 +23,8 @@ class btOverlappingPairCache;
class btConstraintSolver;
class btSimulationIslandManager;
class btTypedConstraint;
-struct btContactSolverInfo;
+#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
+
class btRaycastVehicle;
class btIDebugDraw;
@@ -52,6 +53,9 @@ protected:
bool m_ownsIslandManager;
bool m_ownsConstraintSolver;
+ btContactSolverInfo m_solverInfo;
+
+
std::vector<btRaycastVehicle*> m_vehicles;
int m_profileTimings;
@@ -83,11 +87,8 @@ public:
///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
- btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver=0);
+ btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver);
- ///this btDiscreteDynamicsWorld will create and own dispatcher, pairCache and constraintSolver, and deletes it in the destructor.
- btDiscreteDynamicsWorld(btConstraintSolver* constraintSolver = 0);
-
virtual ~btDiscreteDynamicsWorld();
///if maxSubSteps > 0, it will interpolate motion between fixedTimeStep's
@@ -144,6 +145,11 @@ public:
virtual const btTypedConstraint* getConstraint(int index) const;
+ btContactSolverInfo& getSolverInfo()
+ {
+ return m_solverInfo;
+ }
+
};
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h b/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h
index a991fdca79d..617ed98d2af 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h
@@ -27,9 +27,6 @@ class btDynamicsWorld : public btCollisionWorld
{
public:
- btDynamicsWorld()
- {
- }
btDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache)
:btCollisionWorld(dispatcher,pairCache)
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
index fe6a73939a7..ce5c76c58e2 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
@@ -22,13 +22,7 @@ subject to the following restrictions:
#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
-btSimpleDynamicsWorld::btSimpleDynamicsWorld()
-:m_constraintSolver(new btSequentialImpulseConstraintSolver),
-m_ownsConstraintSolver(true),
-m_debugDrawer(0),
-m_gravity(0,0,-10)
-{
-}
+
btSimpleDynamicsWorld::btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver)
:btDynamicsWorld(dispatcher,pairCache),
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h b/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h
index f74e2460732..cdc0c5559f6 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h
@@ -46,8 +46,6 @@ protected:
public:
- ///this btSimpleDynamicsWorld constructor creates and owns dispatcher, broadphase pairCache and constraintSolver
- btSimpleDynamicsWorld();
///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver
btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver);
diff --git a/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp b/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp
index 700bdb866cd..248ecfbce4e 100644
--- a/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp
+++ b/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp
@@ -386,21 +386,21 @@ void btRaycastVehicle::applyEngineForce(btScalar force, int wheel)
const btWheelInfo& btRaycastVehicle::getWheelInfo(int index) const
{
- ASSERT((index >= 0) && (index < getNumWheels()));
+ btAssert((index >= 0) && (index < getNumWheels()));
return m_wheelInfo[index];
}
btWheelInfo& btRaycastVehicle::getWheelInfo(int index)
{
- ASSERT((index >= 0) && (index < getNumWheels()));
+ btAssert((index >= 0) && (index < getNumWheels()));
return m_wheelInfo[index];
}
void btRaycastVehicle::setBrake(float brake,int wheelIndex)
{
- ASSERT((wheelIndex >= 0) && (wheelIndex < getNumWheels()));
+ btAssert((wheelIndex >= 0) && (wheelIndex < getNumWheels()));
getWheelInfo(wheelIndex).m_brake;
}
diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h
index aa046b89df0..46b8145a766 100644
--- a/extern/bullet2/src/LinearMath/btScalar.h
+++ b/extern/bullet2/src/LinearMath/btScalar.h
@@ -37,7 +37,7 @@ subject to the following restrictions:
//#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
#define ATTRIBUTE_ALIGNED16(a) a
#include <assert.h>
- #define ASSERT assert
+ #define btAssert assert
#else
//non-windows systems
@@ -47,7 +47,7 @@ subject to the following restrictions:
#ifndef assert
#include <assert.h>
#endif
- #define ASSERT assert
+ #define btAssert assert
#endif
diff --git a/extern/bullet2/src/LinearMath/btStackAlloc.h b/extern/bullet2/src/LinearMath/btStackAlloc.h
new file mode 100644
index 00000000000..d219b453537
--- /dev/null
+++ b/extern/bullet2/src/LinearMath/btStackAlloc.h
@@ -0,0 +1,106 @@
+/*
+Copyright (c) 2003-2006 Gino van den Bergen / 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.
+*/
+
+/*
+StackAlloc extracted from GJK-EPA collision solver by Nathanael Presson
+Nov.2006
+*/
+
+#ifndef BT_STACK_ALLOC
+#define BT_STACK_ALLOC
+
+#include "btScalar.h" //for btAssert
+
+struct btBlock
+{
+ btBlock* previous;
+ unsigned char* address;
+};
+
+///StackAlloc provides some fast stack-based memory allocator (LIFO last-in first-out)
+class btStackAlloc
+{
+public:
+
+ btStackAlloc(unsigned int size) { ctor();create(size); }
+ ~btStackAlloc() { destroy(); }
+
+ inline void create(unsigned int size)
+ {
+ destroy();
+ data = new unsigned char[size];
+ totalsize = size;
+ }
+ inline void destroy()
+ {
+ btAssert(usedsize==0);
+ //Raise(L"StackAlloc is still in use");
+
+ if(usedsize==0)
+ {
+ if(!ischild) delete[] data;
+ data = 0;
+ usedsize = 0;
+ }
+
+ }
+ unsigned char* allocate(unsigned int size)
+ {
+ const unsigned int nus(usedsize+size);
+ if(nus<totalsize)
+ {
+ usedsize=nus;
+ return(data+(usedsize-size));
+ }
+ btAssert(0);
+ //&& (L"Not enough memory"));
+
+ return(0);
+ }
+ inline btBlock* beginBlock()
+ {
+ btBlock* pb = (btBlock*)allocate(sizeof(btBlock));
+ pb->previous = current;
+ pb->address = data+usedsize;
+ current = pb;
+ return(pb);
+ }
+ inline void endBlock(btBlock* block)
+ {
+ btAssert(block==current);
+ //Raise(L"Unmatched blocks");
+ if(block==current)
+ {
+ current = block->previous;
+ usedsize = (unsigned int)((block->address-data)-sizeof(btBlock));
+ }
+ }
+
+private:
+ void ctor()
+ {
+ data = 0;
+ totalsize = 0;
+ usedsize = 0;
+ current = 0;
+ ischild = false;
+ }
+ unsigned char* data;
+ unsigned int totalsize;
+ unsigned int usedsize;
+ btBlock* current;
+ bool ischild;
+};
+
+#endif //BT_STACK_ALLOC