merged most of the changes from the branch into trunk, except for COLLADA, libxml and glut glitches.

Still need to verify to make sure no unwanted renaming is introduced.
This commit is contained in:
ejcoumans
2006-09-27 20:43:51 +00:00
parent d1e9a885f3
commit eb23bb5c0c
263 changed files with 7528 additions and 6714 deletions

View File

@@ -4,7 +4,7 @@
//
// AxisSweep3
// btAxisSweep3
//
// Copyright (c) 2006 Simon Hobbs
//
@@ -21,7 +21,7 @@
#include <assert.h>
BroadphaseProxy* AxisSweep3::CreateProxy( const SimdVector3& min, const SimdVector3& max,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask)
btBroadphaseProxy* btAxisSweep3::CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask)
{
unsigned short handleId = AddHandle(min,max, userPtr,collisionFilterGroup,collisionFilterMask);
@@ -30,13 +30,13 @@ BroadphaseProxy* AxisSweep3::CreateProxy( const SimdVector3& min, const SimdVe
return handle;
}
void AxisSweep3::DestroyProxy(BroadphaseProxy* proxy)
void btAxisSweep3::DestroyProxy(btBroadphaseProxy* proxy)
{
Handle* handle = static_cast<Handle*>(proxy);
RemoveHandle(handle->m_handleId);
}
void AxisSweep3::SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const SimdVector3& aabbMax)
void btAxisSweep3::SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)
{
Handle* handle = static_cast<Handle*>(proxy);
UpdateHandle(handle->m_handleId,aabbMin,aabbMax);
@@ -47,8 +47,8 @@ void AxisSweep3::SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const
AxisSweep3::AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAabbMax, int maxHandles)
:OverlappingPairCache()
btAxisSweep3::btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles)
:btOverlappingPairCache()
{
//assert(bounds.HasVolume());
@@ -59,9 +59,9 @@ AxisSweep3::AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAab
m_worldAabbMin = worldAabbMin;
m_worldAabbMax = worldAabbMax;
SimdVector3 aabbSize = m_worldAabbMax - m_worldAabbMin;
btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin;
m_quantize = SimdVector3(65535.0f,65535.0f,65535.0f) / aabbSize;
m_quantize = btVector3(65535.0f,65535.0f,65535.0f) / aabbSize;
// allocate handles buffer and put all handles on free list
m_pHandles = new Handle[maxHandles];
@@ -99,7 +99,7 @@ AxisSweep3::AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAab
}
}
AxisSweep3::~AxisSweep3()
btAxisSweep3::~btAxisSweep3()
{
for (int i = 2; i >= 0; i--)
@@ -107,15 +107,15 @@ AxisSweep3::~AxisSweep3()
delete[] m_pHandles;
}
void AxisSweep3::Quantize(unsigned short* out, const SimdPoint3& point, int isMax) const
void btAxisSweep3::Quantize(unsigned short* out, const btPoint3& point, int isMax) const
{
SimdPoint3 clampedPoint(point);
btPoint3 clampedPoint(point);
/*
if (isMax)
clampedPoint += SimdVector3(10,10,10);
clampedPoint += btVector3(10,10,10);
else
{
clampedPoint -= SimdVector3(10,10,10);
clampedPoint -= btVector3(10,10,10);
}
*/
@@ -123,7 +123,7 @@ void AxisSweep3::Quantize(unsigned short* out, const SimdPoint3& point, int isMa
clampedPoint.setMax(m_worldAabbMin);
clampedPoint.setMin(m_worldAabbMax);
SimdVector3 v = (clampedPoint - m_worldAabbMin) * m_quantize;
btVector3 v = (clampedPoint - m_worldAabbMin) * m_quantize;
out[0] = (unsigned short)(((int)v.getX() & 0xfffc) | isMax);
out[1] = (unsigned short)(((int)v.getY() & 0xfffc) | isMax);
out[2] = (unsigned short)(((int)v.getZ() & 0xfffc) | isMax);
@@ -132,7 +132,7 @@ void AxisSweep3::Quantize(unsigned short* out, const SimdPoint3& point, int isMa
unsigned short AxisSweep3::AllocHandle()
unsigned short btAxisSweep3::AllocHandle()
{
assert(m_firstFreeHandle);
@@ -143,7 +143,7 @@ unsigned short AxisSweep3::AllocHandle()
return handle;
}
void AxisSweep3::FreeHandle(unsigned short handle)
void btAxisSweep3::FreeHandle(unsigned short handle)
{
assert(handle > 0 && handle < m_maxHandles);
@@ -155,7 +155,7 @@ void AxisSweep3::FreeHandle(unsigned short handle)
unsigned short AxisSweep3::AddHandle(const SimdPoint3& aabbMin,const SimdPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask)
unsigned short btAxisSweep3::AddHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask)
{
// quantize the bounds
unsigned short min[3], max[3];
@@ -208,7 +208,7 @@ unsigned short AxisSweep3::AddHandle(const SimdPoint3& aabbMin,const SimdPoint3&
}
void AxisSweep3::RemoveHandle(unsigned short handle)
void btAxisSweep3::RemoveHandle(unsigned short handle)
{
Handle* pHandle = GetHandle(handle);
@@ -256,7 +256,7 @@ void AxisSweep3::RemoveHandle(unsigned short handle)
}
bool AxisSweep3::TestOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB)
bool btAxisSweep3::TestOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB)
{
//optimization 1: check the array index (memory address), instead of the m_pos
@@ -287,7 +287,7 @@ bool AxisSweep3::TestOverlap(int ignoreAxis,const Handle* pHandleA, const Handle
return true;
}
void AxisSweep3::UpdateHandle(unsigned short handle, const SimdPoint3& aabbMin,const SimdPoint3& aabbMax)
void btAxisSweep3::UpdateHandle(unsigned short handle, const btPoint3& aabbMin,const btPoint3& aabbMax)
{
// assert(bounds.IsFinite());
//assert(bounds.HasVolume());
@@ -330,7 +330,7 @@ void AxisSweep3::UpdateHandle(unsigned short handle, const SimdPoint3& aabbMin,c
}
// sorting a min edge downwards can only ever *add* overlaps
void AxisSweep3::SortMinDown(int axis, unsigned short edge, bool updateOverlaps)
void btAxisSweep3::SortMinDown(int axis, unsigned short edge, bool updateOverlaps)
{
Edge* pEdge = m_pEdges[axis] + edge;
Edge* pPrev = pEdge - 1;
@@ -371,7 +371,7 @@ void AxisSweep3::SortMinDown(int axis, unsigned short edge, bool updateOverlaps)
}
// sorting a min edge upwards can only ever *remove* overlaps
void AxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps)
void btAxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps)
{
Edge* pEdge = m_pEdges[axis] + edge;
Edge* pNext = pEdge + 1;
@@ -388,7 +388,7 @@ void AxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps)
{
Handle* handle0 = GetHandle(pEdge->m_handle);
Handle* handle1 = GetHandle(pNext->m_handle);
BroadphasePair tmpPair(*handle0,*handle1);
btBroadphasePair tmpPair(*handle0,*handle1);
RemoveOverlappingPair(tmpPair);
}
@@ -413,7 +413,7 @@ void AxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps)
}
// sorting a max edge downwards can only ever *remove* overlaps
void AxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlaps)
void btAxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlaps)
{
Edge* pEdge = m_pEdges[axis] + edge;
Edge* pPrev = pEdge - 1;
@@ -430,7 +430,7 @@ void AxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlaps)
{
Handle* handle0 = GetHandle(pEdge->m_handle);
Handle* handle1 = GetHandle(pPrev->m_handle);
BroadphasePair* pair = FindPair(handle0,handle1);
btBroadphasePair* pair = FindPair(handle0,handle1);
//assert(pair);
if (pair)
@@ -459,7 +459,7 @@ void AxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlaps)
}
// sorting a max edge upwards can only ever *add* overlaps
void AxisSweep3::SortMaxUp(int axis, unsigned short edge, bool updateOverlaps)
void btAxisSweep3::SortMaxUp(int axis, unsigned short edge, bool updateOverlaps)
{
Edge* pEdge = m_pEdges[axis] + edge;
Edge* pNext = pEdge + 1;

View File

@@ -2,7 +2,7 @@
//Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
//
// AxisSweep3.h
// btAxisSweep3.h
//
// Copyright (c) 2006 Simon Hobbs
//
@@ -19,15 +19,15 @@
#ifndef AXIS_SWEEP_3_H
#define AXIS_SWEEP_3_H
#include "LinearMath/SimdPoint3.h"
#include "LinearMath/SimdVector3.h"
#include "LinearMath/btPoint3.h"
#include "LinearMath/btVector3.h"
#include "btOverlappingPairCache.h"
#include "btBroadphaseProxy.h"
/// AxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase.
/// btAxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase.
/// It uses arrays rather then lists for storage of the 3 axis. Also it operates using integer coordinates instead of floats.
/// The TestOverlap check is optimized to check the array index, rather then the actual AABB coordinates/pos
class AxisSweep3 : public OverlappingPairCache
class btAxisSweep3 : public btOverlappingPairCache
{
public:
@@ -43,7 +43,7 @@ public:
};
public:
class Handle : public BroadphaseProxy
class Handle : public btBroadphaseProxy
{
public:
@@ -52,7 +52,7 @@ public:
unsigned short m_handleId;
unsigned short m_pad;
//void* m_pOwner; this is now in BroadphaseProxy.m_clientObject
//void* m_pOwner; this is now in btBroadphaseProxy.m_clientObject
inline void SetNextFree(unsigned short next) {m_minEdges[0] = next;}
inline unsigned short GetNextFree() const {return m_minEdges[0];}
@@ -60,10 +60,10 @@ public:
private:
SimdPoint3 m_worldAabbMin; // overall system bounds
SimdPoint3 m_worldAabbMax; // overall system bounds
btPoint3 m_worldAabbMin; // overall system bounds
btPoint3 m_worldAabbMax; // overall system bounds
SimdVector3 m_quantize; // scaling factor for quantization
btVector3 m_quantize; // scaling factor for quantization
int m_numHandles; // number of active handles
int m_maxHandles; // max number of handles
@@ -83,7 +83,7 @@ private:
//Overlap* AddOverlap(unsigned short handleA, unsigned short handleB);
//void RemoveOverlap(unsigned short handleA, unsigned short handleB);
void Quantize(unsigned short* out, const SimdPoint3& point, int isMax) const;
void Quantize(unsigned short* out, const btPoint3& point, int isMax) const;
void SortMinDown(int axis, unsigned short edge, bool updateOverlaps = true);
void SortMinUp(int axis, unsigned short edge, bool updateOverlaps = true);
@@ -91,24 +91,24 @@ private:
void SortMaxUp(int axis, unsigned short edge, bool updateOverlaps = true);
public:
AxisSweep3(const SimdPoint3& worldAabbMin,const SimdPoint3& worldAabbMax, int maxHandles = 16384);
virtual ~AxisSweep3();
btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles = 16384);
virtual ~btAxisSweep3();
virtual void RefreshOverlappingPairs()
{
//this is replace by sweep and prune
}
unsigned short AddHandle(const SimdPoint3& aabbMin,const SimdPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask);
unsigned short AddHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask);
void RemoveHandle(unsigned short handle);
void UpdateHandle(unsigned short handle, const SimdPoint3& aabbMin,const SimdPoint3& aabbMax);
void UpdateHandle(unsigned short handle, const btPoint3& aabbMin,const btPoint3& aabbMax);
inline Handle* GetHandle(unsigned short index) const {return m_pHandles + index;}
//Broadphase Interface
virtual BroadphaseProxy* CreateProxy( const SimdVector3& min, const SimdVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
virtual void DestroyProxy(BroadphaseProxy* proxy);
virtual void SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const SimdVector3& aabbMax);
virtual btBroadphaseProxy* CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
virtual void DestroyProxy(btBroadphaseProxy* proxy);
virtual void SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax);
};

View File

@@ -18,21 +18,21 @@ subject to the following restrictions:
struct DispatcherInfo;
class Dispatcher;
struct BroadphaseProxy;
#include "LinearMath/SimdVector3.h"
struct btDispatcherInfo;
class btDispatcher;
struct btBroadphaseProxy;
#include "LinearMath/btVector3.h"
///BroadphaseInterface for aabb-overlapping object pairs
class BroadphaseInterface
class btBroadphaseInterface
{
public:
virtual ~BroadphaseInterface() {}
virtual ~btBroadphaseInterface() {}
virtual BroadphaseProxy* CreateProxy( const SimdVector3& min, const SimdVector3& max,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) =0;
virtual void DestroyProxy(BroadphaseProxy* proxy)=0;
virtual void SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const SimdVector3& aabbMax)=0;
virtual void CleanProxyFromPairs(BroadphaseProxy* proxy)=0;
virtual btBroadphaseProxy* CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) =0;
virtual void DestroyProxy(btBroadphaseProxy* proxy)=0;
virtual void SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)=0;
virtual void CleanProxyFromPairs(btBroadphaseProxy* proxy)=0;
};

View File

@@ -18,7 +18,7 @@ subject to the following restrictions:
/// Dispatcher uses these types
/// btDispatcher uses these types
/// IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and concave
/// to facilitate type checking
enum BroadphaseNativeTypes
@@ -56,18 +56,18 @@ CONCAVE_SHAPES_END_HERE,
///BroadphaseProxy
struct BroadphaseProxy
struct btBroadphaseProxy
{
//Usually the client CollisionObject or Rigidbody class
//Usually the client btCollisionObject or Rigidbody class
void* m_clientObject;
short int m_collisionFilterGroup;
short int m_collisionFilterMask;
//used for memory pools
BroadphaseProxy() :m_clientObject(0){}
btBroadphaseProxy() :m_clientObject(0){}
BroadphaseProxy(void* userPtr,short int collisionFilterGroup, short int collisionFilterMask)
btBroadphaseProxy(void* userPtr,short int collisionFilterGroup, short int collisionFilterMask)
:m_clientObject(userPtr),
m_collisionFilterGroup(collisionFilterGroup),
m_collisionFilterMask(collisionFilterMask)
@@ -96,17 +96,17 @@ struct BroadphaseProxy
};
class CollisionAlgorithm;
class btCollisionAlgorithm;
struct BroadphaseProxy;
struct btBroadphaseProxy;
//Increase SIMPLE_MAX_ALGORITHMS to allow multiple Dispatchers caching their own algorithms
//Increase SIMPLE_MAX_ALGORITHMS to allow multiple btDispatchers caching their own algorithms
#define SIMPLE_MAX_ALGORITHMS 1
/// contains a pair of aabb-overlapping objects
struct BroadphasePair
struct btBroadphasePair
{
BroadphasePair ()
btBroadphasePair ()
:
m_pProxy0(0),
m_pProxy1(0)
@@ -117,7 +117,7 @@ struct BroadphasePair
}
}
BroadphasePair(const BroadphasePair& other)
btBroadphasePair(const btBroadphasePair& other)
: m_pProxy0(other.m_pProxy0),
m_pProxy1(other.m_pProxy1)
{
@@ -126,7 +126,7 @@ struct BroadphasePair
m_algorithms[i] = other.m_algorithms[i];
}
}
BroadphasePair(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1)
btBroadphasePair(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
{
//keep them sorted, so the std::set operations work
@@ -148,15 +148,15 @@ struct BroadphasePair
}
BroadphaseProxy* m_pProxy0;
BroadphaseProxy* m_pProxy1;
btBroadphaseProxy* m_pProxy0;
btBroadphaseProxy* m_pProxy1;
mutable CollisionAlgorithm* m_algorithms[SIMPLE_MAX_ALGORITHMS];
mutable btCollisionAlgorithm* m_algorithms[SIMPLE_MAX_ALGORITHMS];
};
//comparison for set operation, see Solid DT_Encounter
inline bool operator<(const BroadphasePair& a, const BroadphasePair& b)
inline bool operator<(const btBroadphasePair& a, const btBroadphasePair& b)
{
return a.m_pProxy0 < b.m_pProxy0 ||
(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 < b.m_pProxy1);

View File

@@ -16,7 +16,7 @@ subject to the following restrictions:
#include "btCollisionAlgorithm.h"
#include "btDispatcher.h"
CollisionAlgorithm::CollisionAlgorithm(const CollisionAlgorithmConstructionInfo& ci)
btCollisionAlgorithm::btCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
{
m_dispatcher = ci.m_dispatcher;
}

View File

@@ -16,50 +16,50 @@ subject to the following restrictions:
#ifndef COLLISION_ALGORITHM_H
#define COLLISION_ALGORITHM_H
struct BroadphaseProxy;
class Dispatcher;
struct btBroadphaseProxy;
class btDispatcher;
struct CollisionAlgorithmConstructionInfo
struct btCollisionAlgorithmConstructionInfo
{
CollisionAlgorithmConstructionInfo()
btCollisionAlgorithmConstructionInfo()
:m_dispatcher(0)
{
}
CollisionAlgorithmConstructionInfo(Dispatcher* dispatcher,int temp)
btCollisionAlgorithmConstructionInfo(btDispatcher* dispatcher,int temp)
:m_dispatcher(dispatcher)
{
}
Dispatcher* m_dispatcher;
btDispatcher* m_dispatcher;
int GetDispatcherId();
};
///CollisionAlgorithm is an collision interface that is compatible with the Broadphase and Dispatcher.
///CollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatcher.
///It is persistent over frames
class CollisionAlgorithm
class btCollisionAlgorithm
{
protected:
Dispatcher* m_dispatcher;
btDispatcher* m_dispatcher;
protected:
int GetDispatcherId();
public:
CollisionAlgorithm() {};
btCollisionAlgorithm() {};
CollisionAlgorithm(const CollisionAlgorithmConstructionInfo& ci);
btCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci);
virtual ~CollisionAlgorithm() {};
virtual ~btCollisionAlgorithm() {};
virtual void ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const struct DispatcherInfo& dispatchInfo) = 0;
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const struct btDispatcherInfo& dispatchInfo) = 0;
virtual float CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const struct DispatcherInfo& dispatchInfo) = 0;
virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const struct btDispatcherInfo& dispatchInfo) = 0;
};

View File

@@ -15,7 +15,7 @@ subject to the following restrictions:
#include "btDispatcher.h"
Dispatcher::~Dispatcher()
btDispatcher::~btDispatcher()
{
}

View File

@@ -16,29 +16,29 @@ subject to the following restrictions:
#ifndef _DISPATCHER_H
#define _DISPATCHER_H
class CollisionAlgorithm;
struct BroadphaseProxy;
class RigidBody;
struct CollisionObject;
class ManifoldResult;
class OverlappingPairCache;
class btCollisionAlgorithm;
struct btBroadphaseProxy;
class btRigidBody;
struct btCollisionObject;
class btManifoldResult;
class btOverlappingPairCache;
enum CollisionDispatcherId
enum btCollisionDispatcherId
{
RIGIDBODY_DISPATCHER = 0,
USERCALLBACK_DISPATCHER
};
class PersistentManifold;
class btPersistentManifold;
struct DispatcherInfo
struct btDispatcherInfo
{
enum DispatchFunc
{
DISPATCH_DISCRETE = 1,
DISPATCH_CONTINUOUS
};
DispatcherInfo()
btDispatcherInfo()
:m_dispatchFunc(DISPATCH_DISCRETE),
m_timeOfImpact(1.f),
m_useContinuous(false),
@@ -52,46 +52,46 @@ struct DispatcherInfo
int m_dispatchFunc;
float m_timeOfImpact;
bool m_useContinuous;
class IDebugDraw* m_debugDraw;
class btIDebugDraw* m_debugDraw;
bool m_enableSatConvex;
};
/// Dispatcher can be used in combination with broadphase to dispatch overlapping pairs.
/// btDispatcher can be used in combination with broadphase to dispatch overlapping pairs.
/// For example for pairwise collision detection or user callbacks (game logic).
class Dispatcher
class btDispatcher
{
public:
virtual ~Dispatcher() ;
virtual ~btDispatcher() ;
virtual CollisionAlgorithm* FindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) = 0;
virtual btCollisionAlgorithm* FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) = 0;
//
// asume dispatchers to have unique id's in the range [0..max dispacher]
//
virtual int GetUniqueId() = 0;
virtual PersistentManifold* GetNewManifold(void* body0,void* body1)=0;
virtual btPersistentManifold* GetNewManifold(void* body0,void* body1)=0;
virtual void ReleaseManifold(PersistentManifold* manifold)=0;
virtual void ReleaseManifold(btPersistentManifold* manifold)=0;
virtual void ClearManifold(PersistentManifold* manifold)=0;
virtual void ClearManifold(btPersistentManifold* manifold)=0;
virtual bool NeedsCollision(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1) = 0;
virtual bool NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) = 0;
virtual bool NeedsResponse(const CollisionObject& colObj0,const CollisionObject& colObj1)=0;
virtual bool NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1)=0;
virtual ManifoldResult* GetNewManifoldResult(CollisionObject* obj0,CollisionObject* obj1,PersistentManifold* manifold) =0;
virtual btManifoldResult* GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold) =0;
virtual void ReleaseManifoldResult(ManifoldResult*)=0;
virtual void ReleaseManifoldResult(btManifoldResult*)=0;
virtual void DispatchAllCollisionPairs(OverlappingPairCache* pairCache,DispatcherInfo& dispatchInfo)=0;
virtual void DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo)=0;
virtual int GetNumManifolds() const = 0;
virtual PersistentManifold* GetManifoldByIndexInternal(int index) = 0;
virtual btPersistentManifold* GetManifoldByIndexInternal(int index) = 0;
};

View File

@@ -23,36 +23,36 @@ subject to the following restrictions:
int gOverlappingPairs = 0;
OverlappingPairCache::OverlappingPairCache():
btOverlappingPairCache::btOverlappingPairCache():
m_blockedForChanges(false)
//m_NumOverlapBroadphasePair(0)
{
}
OverlappingPairCache::~OverlappingPairCache()
btOverlappingPairCache::~btOverlappingPairCache()
{
//todo/test: show we erase/delete data, or is it automatic
}
void OverlappingPairCache::RemoveOverlappingPair(BroadphasePair& findPair)
void btOverlappingPairCache::RemoveOverlappingPair(btBroadphasePair& findPair)
{
std::set<BroadphasePair>::iterator it = m_overlappingPairSet.find(findPair);
std::set<btBroadphasePair>::iterator it = m_overlappingPairSet.find(findPair);
// assert(it != m_overlappingPairSet.end());
if (it != m_overlappingPairSet.end())
{
gOverlappingPairs--;
BroadphasePair* pair = (BroadphasePair*)(&(*it));
btBroadphasePair* pair = (btBroadphasePair*)(&(*it));
CleanOverlappingPair(*pair);
m_overlappingPairSet.erase(it);
}
}
void OverlappingPairCache::CleanOverlappingPair(BroadphasePair& pair)
void btOverlappingPairCache::CleanOverlappingPair(btBroadphasePair& pair)
{
for (int dispatcherId=0;dispatcherId<SIMPLE_MAX_ALGORITHMS;dispatcherId++)
{
@@ -70,7 +70,7 @@ void OverlappingPairCache::CleanOverlappingPair(BroadphasePair& pair)
void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1)
void btOverlappingPairCache::AddOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
{
//don't add overlap with own
assert(proxy0 != proxy1);
@@ -79,7 +79,7 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase
return;
BroadphasePair pair(*proxy0,*proxy1);
btBroadphasePair pair(*proxy0,*proxy1);
m_overlappingPairSet.insert(pair);
gOverlappingPairs++;
@@ -90,18 +90,18 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase
///use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed.
///we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address)
///Also we can use a 2D bitmap, which can be useful for a future GPU implementation
BroadphasePair* OverlappingPairCache::FindPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1)
btBroadphasePair* btOverlappingPairCache::FindPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
{
if (!NeedsCollision(proxy0,proxy1))
return 0;
BroadphasePair tmpPair(*proxy0,*proxy1);
std::set<BroadphasePair>::iterator it = m_overlappingPairSet.find(tmpPair);
btBroadphasePair tmpPair(*proxy0,*proxy1);
std::set<btBroadphasePair>::iterator it = m_overlappingPairSet.find(tmpPair);
if ((it == m_overlappingPairSet.end()))
return 0;
//assert(it != m_overlappingPairSet.end());
BroadphasePair* pair = (BroadphasePair*)(&(*it));
btBroadphasePair* pair = (btBroadphasePair*)(&(*it));
return pair;
}
@@ -109,21 +109,21 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase
void OverlappingPairCache::CleanProxyFromPairs(BroadphaseProxy* proxy)
void btOverlappingPairCache::CleanProxyFromPairs(btBroadphaseProxy* proxy)
{
class CleanPairCallback : public OverlapCallback
class CleanPairCallback : public btOverlapCallback
{
BroadphaseProxy* m_cleanProxy;
OverlappingPairCache* m_pairCache;
btBroadphaseProxy* m_cleanProxy;
btOverlappingPairCache* m_pairCache;
public:
CleanPairCallback(BroadphaseProxy* cleanProxy,OverlappingPairCache* pairCache)
CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache)
:m_cleanProxy(cleanProxy),
m_pairCache(pairCache)
{
}
virtual bool ProcessOverlap(BroadphasePair& pair)
virtual bool ProcessOverlap(btBroadphasePair& pair)
{
if ((pair.m_pProxy0 == m_cleanProxy) ||
(pair.m_pProxy1 == m_cleanProxy))
@@ -143,19 +143,19 @@ void OverlappingPairCache::CleanProxyFromPairs(BroadphaseProxy* proxy)
void OverlappingPairCache::RemoveOverlappingPairsContainingProxy(BroadphaseProxy* proxy)
void btOverlappingPairCache::RemoveOverlappingPairsContainingProxy(btBroadphaseProxy* proxy)
{
class RemovePairCallback : public OverlapCallback
class RemovePairCallback : public btOverlapCallback
{
BroadphaseProxy* m_obsoleteProxy;
btBroadphaseProxy* m_obsoleteProxy;
public:
RemovePairCallback(BroadphaseProxy* obsoleteProxy)
RemovePairCallback(btBroadphaseProxy* obsoleteProxy)
:m_obsoleteProxy(obsoleteProxy)
{
}
virtual bool ProcessOverlap(BroadphasePair& pair)
virtual bool ProcessOverlap(btBroadphasePair& pair)
{
return ((pair.m_pProxy0 == m_obsoleteProxy) ||
(pair.m_pProxy1 == m_obsoleteProxy));
@@ -171,18 +171,18 @@ void OverlappingPairCache::RemoveOverlappingPairsContainingProxy(BroadphaseProxy
void OverlappingPairCache::ProcessAllOverlappingPairs(OverlapCallback* callback)
void btOverlappingPairCache::ProcessAllOverlappingPairs(btOverlapCallback* callback)
{
std::set<BroadphasePair>::iterator it = m_overlappingPairSet.begin();
std::set<btBroadphasePair>::iterator it = m_overlappingPairSet.begin();
for (; !(it==m_overlappingPairSet.end());)
{
BroadphasePair* pair = (BroadphasePair*)(&(*it));
btBroadphasePair* pair = (btBroadphasePair*)(&(*it));
if (callback->ProcessOverlap(*pair))
{
CleanOverlappingPair(*pair);
std::set<BroadphasePair>::iterator it2 = it;
std::set<btBroadphasePair>::iterator it2 = it;
//why does next line not compile under OS X??
#ifdef MAC_OSX_FIXED_STL_SET
it2++;

View File

@@ -20,51 +20,51 @@ subject to the following restrictions:
#include "btBroadphaseInterface.h"
#include "btBroadphaseProxy.h"
#include "LinearMath/SimdPoint3.h"
#include "LinearMath/btPoint3.h"
#include <set>
struct OverlapCallback
struct btOverlapCallback
{
virtual ~OverlapCallback()
virtual ~btOverlapCallback()
{
}
//return true for deletion of the pair
virtual bool ProcessOverlap(BroadphasePair& pair) = 0;
virtual bool ProcessOverlap(btBroadphasePair& pair) = 0;
};
///OverlappingPairCache maintains the objects with overlapping AABB
///Typically managed by the Broadphase, Axis3Sweep or SimpleBroadphase
class OverlappingPairCache : public BroadphaseInterface
///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase
class btOverlappingPairCache : public btBroadphaseInterface
{
//avoid brute-force finding all the time
std::set<BroadphasePair> m_overlappingPairSet;
std::set<btBroadphasePair> m_overlappingPairSet;
//during the dispatch, check that user doesn't destroy/create proxy
bool m_blockedForChanges;
public:
OverlappingPairCache();
virtual ~OverlappingPairCache();
btOverlappingPairCache();
virtual ~btOverlappingPairCache();
void ProcessAllOverlappingPairs(OverlapCallback*);
void ProcessAllOverlappingPairs(btOverlapCallback*);
void RemoveOverlappingPair(BroadphasePair& pair);
void RemoveOverlappingPair(btBroadphasePair& pair);
void CleanOverlappingPair(BroadphasePair& pair);
void CleanOverlappingPair(btBroadphasePair& pair);
void AddOverlappingPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1);
void AddOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
BroadphasePair* FindPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1);
btBroadphasePair* FindPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
void CleanProxyFromPairs(BroadphaseProxy* proxy);
void CleanProxyFromPairs(btBroadphaseProxy* proxy);
void RemoveOverlappingPairsContainingProxy(BroadphaseProxy* proxy);
void RemoveOverlappingPairsContainingProxy(btBroadphaseProxy* proxy);
inline bool NeedsCollision(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1) const
inline bool NeedsCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
{
bool collides = proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask;
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);

View File

@@ -17,13 +17,13 @@ subject to the following restrictions:
#include <BulletCollision/BroadphaseCollision/btDispatcher.h>
#include <BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h>
#include "LinearMath/SimdVector3.h"
#include "LinearMath/SimdTransform.h"
#include "LinearMath/SimdMatrix3x3.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btTransform.h"
#include "LinearMath/btMatrix3x3.h"
#include <vector>
void SimpleBroadphase::validate()
void btSimpleBroadphase::validate()
{
for (int i=0;i<m_numProxies;i++)
{
@@ -35,16 +35,16 @@ void SimpleBroadphase::validate()
}
SimpleBroadphase::SimpleBroadphase(int maxProxies)
:OverlappingPairCache(),
btSimpleBroadphase::btSimpleBroadphase(int maxProxies)
:btOverlappingPairCache(),
m_firstFreeProxy(0),
m_numProxies(0),
m_maxProxies(maxProxies)
{
m_proxies = new SimpleBroadphaseProxy[maxProxies];
m_proxies = new btSimpleBroadphaseProxy[maxProxies];
m_freeProxies = new int[maxProxies];
m_pProxies = new SimpleBroadphaseProxy*[maxProxies];
m_pProxies = new btSimpleBroadphaseProxy*[maxProxies];
int i;
@@ -54,7 +54,7 @@ SimpleBroadphase::SimpleBroadphase(int maxProxies)
}
}
SimpleBroadphase::~SimpleBroadphase()
btSimpleBroadphase::~btSimpleBroadphase()
{
delete[] m_proxies;
delete []m_freeProxies;
@@ -70,7 +70,7 @@ SimpleBroadphase::~SimpleBroadphase()
}
BroadphaseProxy* SimpleBroadphase::CreateProxy( const SimdVector3& min, const SimdVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
btBroadphaseProxy* btSimpleBroadphase::CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
{
if (m_numProxies >= m_maxProxies)
{
@@ -80,10 +80,10 @@ BroadphaseProxy* SimpleBroadphase::CreateProxy( const SimdVector3& min, const
assert(min[0]<= max[0] && min[1]<= max[1] && min[2]<= max[2]);
int freeIndex= m_freeProxies[m_firstFreeProxy];
SimpleBroadphaseProxy* proxy = new (&m_proxies[freeIndex])SimpleBroadphaseProxy(min,max,shapeType,userPtr,collisionFilterGroup,collisionFilterMask);
btSimpleBroadphaseProxy* proxy = new (&m_proxies[freeIndex])btSimpleBroadphaseProxy(min,max,shapeType,userPtr,collisionFilterGroup,collisionFilterMask);
m_firstFreeProxy++;
SimpleBroadphaseProxy* proxy1 = &m_proxies[0];
btSimpleBroadphaseProxy* proxy1 = &m_proxies[0];
int index = proxy - proxy1;
assert(index == freeIndex);
@@ -95,10 +95,10 @@ BroadphaseProxy* SimpleBroadphase::CreateProxy( const SimdVector3& min, const
return proxy;
}
class RemovingOverlapCallback : public OverlapCallback
class RemovingOverlapCallback : public btOverlapCallback
{
protected:
virtual bool ProcessOverlap(BroadphasePair& pair)
virtual bool ProcessOverlap(btBroadphasePair& pair)
{
assert(0);
}
@@ -107,28 +107,28 @@ protected:
class RemovePairContainingProxy
{
BroadphaseProxy* m_targetProxy;
btBroadphaseProxy* m_targetProxy;
public:
virtual ~RemovePairContainingProxy()
{
}
protected:
virtual bool ProcessOverlap(BroadphasePair& pair)
virtual bool ProcessOverlap(btBroadphasePair& pair)
{
SimpleBroadphaseProxy* proxy0 = static_cast<SimpleBroadphaseProxy*>(pair.m_pProxy0);
SimpleBroadphaseProxy* proxy1 = static_cast<SimpleBroadphaseProxy*>(pair.m_pProxy1);
btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0);
btSimpleBroadphaseProxy* proxy1 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1);
return ((m_targetProxy == proxy0 || m_targetProxy == proxy1));
};
};
void SimpleBroadphase::DestroyProxy(BroadphaseProxy* proxyOrg)
void btSimpleBroadphase::DestroyProxy(btBroadphaseProxy* proxyOrg)
{
int i;
SimpleBroadphaseProxy* proxy0 = static_cast<SimpleBroadphaseProxy*>(proxyOrg);
SimpleBroadphaseProxy* proxy1 = &m_proxies[0];
btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxyOrg);
btSimpleBroadphaseProxy* proxy1 = &m_proxies[0];
int index = proxy0 - proxy1;
assert (index < m_maxProxies);
@@ -140,10 +140,10 @@ void SimpleBroadphase::DestroyProxy(BroadphaseProxy* proxyOrg)
//then remove non-overlapping ones
/*for (i=0;i<GetNumOverlappingPairs();i++)
{
BroadphasePair& pair = GetOverlappingPair(i);
btBroadphasePair& pair = GetOverlappingPair(i);
SimpleBroadphaseProxy* proxy0 = GetSimpleProxyFromProxy(pair.m_pProxy0);
SimpleBroadphaseProxy* proxy1 = GetSimpleProxyFromProxy(pair.m_pProxy1);
btSimpleBroadphaseProxy* proxy0 = GetSimpleProxyFromProxy(pair.m_pProxy0);
btSimpleBroadphaseProxy* proxy1 = GetSimpleProxyFromProxy(pair.m_pProxy1);
if ((proxy0==proxyOrg) || (proxy1==proxyOrg))
{
RemoveOverlappingPair(pair);
@@ -167,9 +167,9 @@ void SimpleBroadphase::DestroyProxy(BroadphaseProxy* proxyOrg)
}
void SimpleBroadphase::SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const SimdVector3& aabbMax)
void btSimpleBroadphase::SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)
{
SimpleBroadphaseProxy* sbp = GetSimpleProxyFromProxy(proxy);
btSimpleBroadphaseProxy* sbp = GetSimpleProxyFromProxy(proxy);
sbp->m_min = aabbMin;
sbp->m_max = aabbMax;
}
@@ -182,7 +182,7 @@ void SimpleBroadphase::SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin
bool SimpleBroadphase::AabbOverlap(SimpleBroadphaseProxy* proxy0,SimpleBroadphaseProxy* proxy1)
bool btSimpleBroadphase::AabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1)
{
return proxy0->m_min[0] <= proxy1->m_max[0] && proxy1->m_min[0] <= proxy0->m_max[0] &&
proxy0->m_min[1] <= proxy1->m_max[1] && proxy1->m_min[1] <= proxy0->m_max[1] &&
@@ -193,28 +193,28 @@ bool SimpleBroadphase::AabbOverlap(SimpleBroadphaseProxy* proxy0,SimpleBroadphas
//then remove non-overlapping ones
class CheckOverlapCallback : public OverlapCallback
class CheckOverlapCallback : public btOverlapCallback
{
public:
virtual bool ProcessOverlap(BroadphasePair& pair)
virtual bool ProcessOverlap(btBroadphasePair& pair)
{
return (!SimpleBroadphase::AabbOverlap(static_cast<SimpleBroadphaseProxy*>(pair.m_pProxy0),static_cast<SimpleBroadphaseProxy*>(pair.m_pProxy1)));
return (!btSimpleBroadphase::AabbOverlap(static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0),static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1)));
}
};
void SimpleBroadphase::RefreshOverlappingPairs()
void btSimpleBroadphase::RefreshOverlappingPairs()
{
//first check for new overlapping pairs
int i,j;
for (i=0;i<m_numProxies;i++)
{
BroadphaseProxy* proxy0 = m_pProxies[i];
btBroadphaseProxy* proxy0 = m_pProxies[i];
for (j=i+1;j<m_numProxies;j++)
{
BroadphaseProxy* proxy1 = m_pProxies[j];
SimpleBroadphaseProxy* p0 = GetSimpleProxyFromProxy(proxy0);
SimpleBroadphaseProxy* p1 = GetSimpleProxyFromProxy(proxy1);
btBroadphaseProxy* proxy1 = m_pProxies[j];
btSimpleBroadphaseProxy* p0 = GetSimpleProxyFromProxy(proxy0);
btSimpleBroadphaseProxy* p1 = GetSimpleProxyFromProxy(proxy1);
if (AabbOverlap(p0,p1))
{

View File

@@ -20,15 +20,15 @@ subject to the following restrictions:
#include "btOverlappingPairCache.h"
struct SimpleBroadphaseProxy : public BroadphaseProxy
struct btSimpleBroadphaseProxy : public btBroadphaseProxy
{
SimdVector3 m_min;
SimdVector3 m_max;
btVector3 m_min;
btVector3 m_max;
SimpleBroadphaseProxy() {};
btSimpleBroadphaseProxy() {};
SimpleBroadphaseProxy(const SimdPoint3& minpt,const SimdPoint3& maxpt,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask)
:BroadphaseProxy(userPtr,collisionFilterGroup,collisionFilterMask),
btSimpleBroadphaseProxy(const btPoint3& minpt,const btPoint3& maxpt,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask)
:btBroadphaseProxy(userPtr,collisionFilterGroup,collisionFilterMask),
m_min(minpt),m_max(maxpt)
{
}
@@ -37,14 +37,14 @@ struct SimpleBroadphaseProxy : public BroadphaseProxy
};
///SimpleBroadphase is a brute force aabb culling broadphase based on O(n^2) aabb checks
class SimpleBroadphase : public OverlappingPairCache
class btSimpleBroadphase : public btOverlappingPairCache
{
SimpleBroadphaseProxy* m_proxies;
btSimpleBroadphaseProxy* m_proxies;
int* m_freeProxies;
int m_firstFreeProxy;
SimpleBroadphaseProxy** m_pProxies;
btSimpleBroadphaseProxy** m_pProxies;
int m_numProxies;
@@ -52,9 +52,9 @@ class SimpleBroadphase : public OverlappingPairCache
int m_maxProxies;
inline SimpleBroadphaseProxy* GetSimpleProxyFromProxy(BroadphaseProxy* proxy)
inline btSimpleBroadphaseProxy* GetSimpleProxyFromProxy(btBroadphaseProxy* proxy)
{
SimpleBroadphaseProxy* proxy0 = static_cast<SimpleBroadphaseProxy*>(proxy);
btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxy);
return proxy0;
}
@@ -66,18 +66,18 @@ protected:
virtual void RefreshOverlappingPairs();
public:
SimpleBroadphase(int maxProxies=16384);
virtual ~SimpleBroadphase();
btSimpleBroadphase(int maxProxies=16384);
virtual ~btSimpleBroadphase();
static bool AabbOverlap(SimpleBroadphaseProxy* proxy0,SimpleBroadphaseProxy* proxy1);
static bool AabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1);
virtual BroadphaseProxy* CreateProxy( const SimdVector3& min, const SimdVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
virtual btBroadphaseProxy* CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
virtual void DestroyProxy(BroadphaseProxy* proxy);
virtual void SetAabb(BroadphaseProxy* proxy,const SimdVector3& aabbMin,const SimdVector3& aabbMax);
virtual void DestroyProxy(btBroadphaseProxy* proxy);
virtual void SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax);