make the source code compile with older compilers again (Visual Studio 2006 in particular)
renamed btDbvt::Volume to btDbvtVolume and btDbvt::Node to btDbvtNode to distinguish from btSoftBody::Node
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -26,8 +26,13 @@ subject to the following restrictions:
|
||||
//
|
||||
|
||||
#ifdef WIN32
|
||||
//only define templates for visual studio 2005 and later, it just causes headaches for other compilers
|
||||
#if (defined (_MSC_VER) && _MSC_VER >= 1400)
|
||||
#define DBVT_USE_TEMPLATE 1 // Enable template for ICollide
|
||||
#else
|
||||
#define DBVT_USE_TEMPLATE 0 // Don't
|
||||
#endif
|
||||
#else
|
||||
#define DBVT_USE_TEMPLATE 0 // Enable template for ICollide
|
||||
#endif
|
||||
|
||||
@@ -117,51 +122,55 @@ private:
|
||||
btVector3 mi,mx;
|
||||
};
|
||||
|
||||
// Types
|
||||
typedef btDbvtAabbMm btDbvtVolume;
|
||||
|
||||
/* btDbvtNode */
|
||||
struct btDbvtNode
|
||||
{
|
||||
btDbvtVolume volume;
|
||||
btDbvtNode* parent;
|
||||
bool isleaf() const { return(childs[1]==0); }
|
||||
bool isinternal() const { return(!isleaf()); }
|
||||
union {
|
||||
btDbvtNode* childs[2];
|
||||
void* data;
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// Dynamic bounding volume tree
|
||||
//
|
||||
struct btDbvt
|
||||
{
|
||||
// Types
|
||||
typedef btDbvtAabbMm Volume;
|
||||
/* Node */
|
||||
struct Node
|
||||
{
|
||||
Volume volume;
|
||||
Node* parent;
|
||||
bool isleaf() const { return(childs[1]==0); }
|
||||
bool isinternal() const { return(!isleaf()); }
|
||||
union {
|
||||
Node* childs[2];
|
||||
void* data;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/* Stack element */
|
||||
struct sStkNN
|
||||
{
|
||||
const Node* a;
|
||||
const Node* b;
|
||||
sStkNN(const Node* na,const Node* nb) : a(na),b(nb) {}
|
||||
const btDbvtNode* a;
|
||||
const btDbvtNode* b;
|
||||
sStkNN(const btDbvtNode* na,const btDbvtNode* nb) : a(na),b(nb) {}
|
||||
};
|
||||
struct sStkNP
|
||||
{
|
||||
const Node* node;
|
||||
const btDbvtNode* node;
|
||||
int mask;
|
||||
sStkNP(const Node* n,unsigned m) : node(n),mask(m) {}
|
||||
sStkNP(const btDbvtNode* n,unsigned m) : node(n),mask(m) {}
|
||||
};
|
||||
struct sStkNPS
|
||||
{
|
||||
const Node* node;
|
||||
const btDbvtNode* node;
|
||||
int mask;
|
||||
btScalar value;
|
||||
sStkNPS() {}
|
||||
sStkNPS(const Node* n,unsigned m,btScalar v) : node(n),mask(m),value(v) {}
|
||||
sStkNPS(const btDbvtNode* n,unsigned m,btScalar v) : node(n),mask(m),value(v) {}
|
||||
};
|
||||
struct sStkCLN
|
||||
{
|
||||
const Node* node;
|
||||
Node* parent;
|
||||
sStkCLN(const Node* n,Node* p) : node(n),parent(p) {}
|
||||
const btDbvtNode* node;
|
||||
btDbvtNode* parent;
|
||||
sStkCLN(const btDbvtNode* n,btDbvtNode* p) : node(n),parent(p) {}
|
||||
};
|
||||
// Policies/Interfaces
|
||||
|
||||
@@ -169,25 +178,25 @@ struct btDbvt
|
||||
struct ICollide
|
||||
{
|
||||
DBVT_VIRTUAL_DTOR(ICollide)
|
||||
DBVT_VIRTUAL void Process(const Node*,const Node*) {}
|
||||
DBVT_VIRTUAL void Process(const Node*) {}
|
||||
DBVT_VIRTUAL void Process(const Node* n,btScalar) { Process(n); }
|
||||
DBVT_VIRTUAL bool Descent(const Node*) { return(true); }
|
||||
DBVT_VIRTUAL bool AllLeaves(const Node*) { return(true); }
|
||||
DBVT_VIRTUAL void Process(const btDbvtNode*,const btDbvtNode*) {}
|
||||
DBVT_VIRTUAL void Process(const btDbvtNode*) {}
|
||||
DBVT_VIRTUAL void Process(const btDbvtNode* n,btScalar) { Process(n); }
|
||||
DBVT_VIRTUAL bool Descent(const btDbvtNode*) { return(true); }
|
||||
DBVT_VIRTUAL bool AllLeaves(const btDbvtNode*) { return(true); }
|
||||
};
|
||||
/* IWriter */
|
||||
struct IWriter
|
||||
{
|
||||
virtual ~IWriter() {}
|
||||
virtual void Prepare(const Node* root,int numnodes)=0;
|
||||
virtual void WriteNode(const Node*,int index,int parent,int child0,int child1)=0;
|
||||
virtual void WriteLeaf(const Node*,int index,int parent)=0;
|
||||
virtual void Prepare(const btDbvtNode* root,int numnodes)=0;
|
||||
virtual void WriteNode(const btDbvtNode*,int index,int parent,int child0,int child1)=0;
|
||||
virtual void WriteLeaf(const btDbvtNode*,int index,int parent)=0;
|
||||
};
|
||||
/* IClone */
|
||||
struct IClone
|
||||
{
|
||||
virtual ~IClone() {}
|
||||
virtual void CloneLeaf(Node*) {}
|
||||
virtual void CloneLeaf(btDbvtNode*) {}
|
||||
};
|
||||
|
||||
// Constants
|
||||
@@ -197,8 +206,8 @@ struct btDbvt
|
||||
};
|
||||
|
||||
// Fields
|
||||
Node* m_root;
|
||||
Node* m_free;
|
||||
btDbvtNode* m_root;
|
||||
btDbvtNode* m_free;
|
||||
int m_lkhd;
|
||||
int m_leaves;
|
||||
unsigned m_opath;
|
||||
@@ -210,17 +219,17 @@ struct btDbvt
|
||||
void optimizeBottomUp();
|
||||
void optimizeTopDown(int bu_treshold=128);
|
||||
void optimizeIncremental(int passes);
|
||||
Node* insert(const Volume& box,void* data);
|
||||
void update(Node* leaf,int lookahead=-1);
|
||||
void update(Node* leaf,const Volume& volume);
|
||||
bool update(Node* leaf,Volume volume,const btVector3& velocity,btScalar margin);
|
||||
bool update(Node* leaf,Volume volume,const btVector3& velocity);
|
||||
bool update(Node* leaf,Volume volume,btScalar margin);
|
||||
void remove(Node* leaf);
|
||||
btDbvtNode* insert(const btDbvtVolume& box,void* data);
|
||||
void update(btDbvtNode* leaf,int lookahead=-1);
|
||||
void update(btDbvtNode* leaf,const btDbvtVolume& volume);
|
||||
bool update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity,btScalar margin);
|
||||
bool update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity);
|
||||
bool update(btDbvtNode* leaf,btDbvtVolume volume,btScalar margin);
|
||||
void remove(btDbvtNode* leaf);
|
||||
void write(IWriter* iwriter) const;
|
||||
void clone(btDbvt& dest,IClone* iclone=0) const;
|
||||
static int countLeaves(const Node* node);
|
||||
static void extractLeaves(const Node* node,btAlignedObjectArray<const Node*>& leaves);
|
||||
static int countLeaves(const btDbvtNode* node);
|
||||
static void extractLeaves(const btDbvtNode* node,btAlignedObjectArray<const btDbvtNode*>& leaves);
|
||||
#if DBVT_ENABLE_BENCHMARK
|
||||
static void benchmark();
|
||||
#else
|
||||
@@ -228,43 +237,43 @@ struct btDbvt
|
||||
#endif
|
||||
// DBVT_IPOLICY must support ICollide policy/interface
|
||||
DBVT_PREFIX
|
||||
static void enumNodes( const Node* root,
|
||||
static void enumNodes( const btDbvtNode* root,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void enumLeaves( const Node* root,
|
||||
static void enumLeaves( const btDbvtNode* root,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void collideTT( const Node* root0,
|
||||
const Node* root1,
|
||||
static void collideTT( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void collideTT( const Node* root0,
|
||||
const Node* root1,
|
||||
static void collideTT( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
const btTransform& xform,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void collideTT( const Node* root0,
|
||||
static void collideTT( const btDbvtNode* root0,
|
||||
const btTransform& xform0,
|
||||
const Node* root1,
|
||||
const btDbvtNode* root1,
|
||||
const btTransform& xform1,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void collideTV( const Node* root,
|
||||
const Volume& volume,
|
||||
static void collideTV( const btDbvtNode* root,
|
||||
const btDbvtVolume& volume,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void collideRAY( const Node* root,
|
||||
static void collideRAY( const btDbvtNode* root,
|
||||
const btVector3& origin,
|
||||
const btVector3& direction,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void collideKDOP(const Node* root,
|
||||
static void collideKDOP(const btDbvtNode* root,
|
||||
const btVector3* normals,
|
||||
const btScalar* offsets,
|
||||
int count,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void collideOCL( const Node* root,
|
||||
static void collideOCL( const btDbvtNode* root,
|
||||
const btVector3* normals,
|
||||
const btScalar* offsets,
|
||||
const btVector3& sortaxis,
|
||||
@@ -272,7 +281,7 @@ struct btDbvt
|
||||
DBVT_IPOLICY,
|
||||
bool fullsort=true);
|
||||
DBVT_PREFIX
|
||||
static void collideTU( const Node* root,
|
||||
static void collideTU( const btDbvtNode* root,
|
||||
DBVT_IPOLICY);
|
||||
// Helpers
|
||||
static inline int nearest(const int* i,const btDbvt::sStkNPS* a,btScalar v,int l,int h)
|
||||
@@ -286,8 +295,8 @@ struct btDbvt
|
||||
return(h);
|
||||
}
|
||||
static inline int allocate( btAlignedObjectArray<int>& ifree,
|
||||
btAlignedObjectArray<btDbvt::sStkNPS>& stock,
|
||||
const btDbvt::sStkNPS& value)
|
||||
btAlignedObjectArray<sStkNPS>& stock,
|
||||
const sStkNPS& value)
|
||||
{
|
||||
int i;
|
||||
if(ifree.size()>0)
|
||||
@@ -528,7 +537,7 @@ return( (a.mi.x()!=b.mi.x())||
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::enumNodes( const Node* root,
|
||||
inline void btDbvt::enumNodes( const btDbvtNode* root,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
@@ -542,7 +551,7 @@ if(root->isinternal())
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::enumLeaves( const Node* root,
|
||||
inline void btDbvt::enumLeaves( const btDbvtNode* root,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
@@ -559,8 +568,8 @@ if(root->isinternal())
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::collideTT( const Node* root0,
|
||||
const Node* root1,
|
||||
inline void btDbvt::collideTT( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
@@ -617,8 +626,8 @@ if(root0&&root1)
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::collideTT( const Node* root0,
|
||||
const Node* root1,
|
||||
inline void btDbvt::collideTT( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
const btTransform& xform,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
@@ -667,9 +676,9 @@ if(root0&&root1)
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::collideTT( const Node* root0,
|
||||
inline void btDbvt::collideTT( const btDbvtNode* root0,
|
||||
const btTransform& xform0,
|
||||
const Node* root1,
|
||||
const btDbvtNode* root1,
|
||||
const btTransform& xform1,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
@@ -679,18 +688,18 @@ collideTT(root0,root1,xform,policy);
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::collideTV( const Node* root,
|
||||
const Volume& volume,
|
||||
inline void btDbvt::collideTV( const btDbvtNode* root,
|
||||
const btDbvtVolume& volume,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
if(root)
|
||||
{
|
||||
btAlignedObjectArray<const Node*> stack;
|
||||
btAlignedObjectArray<const btDbvtNode*> stack;
|
||||
stack.reserve(SIMPLE_STACKSIZE);
|
||||
stack.push_back(root);
|
||||
do {
|
||||
const Node* n=stack[stack.size()-1];
|
||||
const btDbvtNode* n=stack[stack.size()-1];
|
||||
stack.pop_back();
|
||||
if(Intersect(n->volume,volume))
|
||||
{
|
||||
@@ -710,7 +719,7 @@ if(root)
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::collideRAY( const Node* root,
|
||||
inline void btDbvt::collideRAY( const btDbvtNode* root,
|
||||
const btVector3& origin,
|
||||
const btVector3& direction,
|
||||
DBVT_IPOLICY)
|
||||
@@ -725,11 +734,11 @@ if(root)
|
||||
const unsigned signs[]={ direction.x()<0,
|
||||
direction.y()<0,
|
||||
direction.z()<0};
|
||||
btAlignedObjectArray<const Node*> stack;
|
||||
btAlignedObjectArray<const btDbvtNode*> stack;
|
||||
stack.reserve(SIMPLE_STACKSIZE);
|
||||
stack.push_back(root);
|
||||
do {
|
||||
const Node* node=stack[stack.size()-1];
|
||||
const btDbvtNode* node=stack[stack.size()-1];
|
||||
stack.pop_back();
|
||||
if(Intersect(node->volume,origin,invdir,signs))
|
||||
{
|
||||
@@ -749,7 +758,7 @@ if(root)
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::collideKDOP(const Node* root,
|
||||
inline void btDbvt::collideKDOP(const btDbvtNode* root,
|
||||
const btVector3* normals,
|
||||
const btScalar* offsets,
|
||||
int count,
|
||||
@@ -804,7 +813,7 @@ if(root)
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::collideOCL( const Node* root,
|
||||
inline void btDbvt::collideOCL( const btDbvtNode* root,
|
||||
const btVector3* normals,
|
||||
const btScalar* offsets,
|
||||
const btVector3& sortaxis,
|
||||
@@ -859,7 +868,7 @@ if(root)
|
||||
{
|
||||
if(se.node->isinternal())
|
||||
{
|
||||
const Node* pns[]={ se.node->childs[0],se.node->childs[1]};
|
||||
const btDbvtNode* pns[]={ se.node->childs[0],se.node->childs[1]};
|
||||
sStkNPS nes[]={ sStkNPS(pns[0],se.mask,pns[0]->volume.ProjectMinimum(sortaxis,srtsgns)),
|
||||
sStkNPS(pns[1],se.mask,pns[1]->volume.ProjectMinimum(sortaxis,srtsgns))};
|
||||
const int q=nes[0].value<nes[1].value?1:0;
|
||||
@@ -902,17 +911,17 @@ if(root)
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void btDbvt::collideTU( const Node* root,
|
||||
inline void btDbvt::collideTU( const btDbvtNode* root,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
if(root)
|
||||
{
|
||||
btAlignedObjectArray<const Node*> stack;
|
||||
btAlignedObjectArray<const btDbvtNode*> stack;
|
||||
stack.reserve(SIMPLE_STACKSIZE);
|
||||
stack.push_back(root);
|
||||
do {
|
||||
const Node* n=stack[stack.size()-1];
|
||||
const btDbvtNode* n=stack[stack.size()-1];
|
||||
stack.pop_back();
|
||||
if(policy.Descent(n))
|
||||
{
|
||||
|
||||
@@ -92,9 +92,9 @@ struct btDbvtLeafCollider : btDbvt::ICollide
|
||||
btDbvtBroadphase* pbp;
|
||||
btDbvtProxy* ppx;
|
||||
btDbvtLeafCollider(btDbvtBroadphase* p,btDbvtProxy* px) : pbp(p),ppx(px) {}
|
||||
void Process(const btDbvt::Node* na)
|
||||
void Process(const btDbvtNode* na)
|
||||
{
|
||||
const btDbvt::Node* nb=ppx->leaf;
|
||||
const btDbvtNode* nb=ppx->leaf;
|
||||
if(nb!=na)
|
||||
{
|
||||
btDbvtProxy* pa=(btDbvtProxy*)na->data;
|
||||
@@ -115,7 +115,7 @@ struct btDbvtTreeCollider : btDbvt::ICollide
|
||||
{
|
||||
btDbvtBroadphase* pbp;
|
||||
btDbvtTreeCollider(btDbvtBroadphase* p) : pbp(p) {}
|
||||
void Process(const btDbvt::Node* na,const btDbvt::Node* nb)
|
||||
void Process(const btDbvtNode* na,const btDbvtNode* nb)
|
||||
{
|
||||
btDbvtProxy* pa=(btDbvtProxy*)na->data;
|
||||
btDbvtProxy* pb=(btDbvtProxy*)nb->data;
|
||||
|
||||
@@ -39,7 +39,7 @@ struct btDbvtProxy : btBroadphaseProxy
|
||||
{
|
||||
/* Fields */
|
||||
btDbvtAabbMm aabb;
|
||||
btDbvt::Node* leaf;
|
||||
btDbvtNode* leaf;
|
||||
btDbvtProxy* links[2];
|
||||
int stage;
|
||||
/* ctor */
|
||||
|
||||
@@ -209,8 +209,9 @@ void btMultiSapBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aab
|
||||
|
||||
|
||||
m_optimizedAabbTree->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax);
|
||||
int i;
|
||||
|
||||
for (int i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
btVector3 worldAabbMin,worldAabbMax;
|
||||
multiProxy->m_bridgeProxies[i]->m_childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax);
|
||||
@@ -307,7 +308,7 @@ void btMultiSapBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aab
|
||||
|
||||
|
||||
//update
|
||||
for (int i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
btBridgeProxy* bridgeProxyRef = multiProxy->m_bridgeProxies[i];
|
||||
bridgeProxyRef->m_childBroadphase->setAabb(bridgeProxyRef->m_childProxy,aabbMin,aabbMax,dispatcher);
|
||||
|
||||
@@ -83,7 +83,6 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase);
|
||||
|
||||
btAlignedObjectArray<btMultiSapProxy*> m_multiSapProxies;
|
||||
|
||||
@@ -107,7 +106,9 @@ public:
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
|
||||
|
||||
|
||||
void addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase);
|
||||
|
||||
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ static int intersectRectQuad2 (btScalar h[2], btScalar p[8], btScalar ret[16])
|
||||
return nr;
|
||||
}
|
||||
|
||||
#define dAtan2(y,x) ((float)atan2f((y),(x))) /* arc tangent with 2 args */
|
||||
|
||||
#define M__PI 3.14159265f
|
||||
|
||||
// given n points in the plane (array p, of size 2*n), generate m points that
|
||||
@@ -214,7 +214,7 @@ void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[])
|
||||
|
||||
// compute the angle of each point w.r.t. the centroid
|
||||
btScalar A[8];
|
||||
for (i=0; i<n; i++) A[i] = dAtan2(p[i*2+1]-cy,p[i*2]-cx);
|
||||
for (i=0; i<n; i++) A[i] = btAtan2(p[i*2+1]-cy,p[i*2]-cx);
|
||||
|
||||
// search for points that have angles closest to A[i0] + i*(2*pi/m).
|
||||
int avail[8];
|
||||
@@ -231,7 +231,7 @@ void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[])
|
||||
#endif
|
||||
for (i=0; i<n; i++) {
|
||||
if (avail[i]) {
|
||||
diff = fabsf (A[i]-a);
|
||||
diff = btFabs (A[i]-a);
|
||||
if (diff > M__PI) diff = 2*M__PI - diff;
|
||||
if (diff < maxdiff) {
|
||||
maxdiff = diff;
|
||||
@@ -284,9 +284,9 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
|
||||
R21 = dDOT44(R1+1,R2+0); R22 = dDOT44(R1+1,R2+1); R23 = dDOT44(R1+1,R2+2);
|
||||
R31 = dDOT44(R1+2,R2+0); R32 = dDOT44(R1+2,R2+1); R33 = dDOT44(R1+2,R2+2);
|
||||
|
||||
Q11 = fabsf(R11); Q12 = fabsf(R12); Q13 = fabsf(R13);
|
||||
Q21 = fabsf(R21); Q22 = fabsf(R22); Q23 = fabsf(R23);
|
||||
Q31 = fabsf(R31); Q32 = fabsf(R32); Q33 = fabsf(R33);
|
||||
Q11 = btFabs(R11); Q12 = btFabs(R12); Q13 = btFabs(R13);
|
||||
Q21 = btFabs(R21); Q22 = btFabs(R22); Q23 = btFabs(R23);
|
||||
Q31 = btFabs(R31); Q32 = btFabs(R32); Q33 = btFabs(R33);
|
||||
|
||||
// for all 15 possible separating axes:
|
||||
// * see if the axis separates the boxes. if so, return 0.
|
||||
@@ -299,7 +299,7 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
|
||||
// the normal should be flipped.
|
||||
|
||||
#define TST(expr1,expr2,norm,cc) \
|
||||
s2 = fabsf(expr1) - (expr2); \
|
||||
s2 = btFabs(expr1) - (expr2); \
|
||||
if (s2 > 0) return 0; \
|
||||
if (s2 > s) { \
|
||||
s = s2; \
|
||||
@@ -326,9 +326,9 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
|
||||
// normal (n1,n2,n3) is relative to box 1.
|
||||
#undef TST
|
||||
#define TST(expr1,expr2,n1,n2,n3,cc) \
|
||||
s2 = fabsf(expr1) - (expr2); \
|
||||
s2 = btFabs(expr1) - (expr2); \
|
||||
if (s2 > 0) return 0; \
|
||||
l = sqrtf((n1)*(n1) + (n2)*(n2) + (n3)*(n3)); \
|
||||
l = btSqrt((n1)*(n1) + (n2)*(n2) + (n3)*(n3)); \
|
||||
if (l > 0) { \
|
||||
s2 /= l; \
|
||||
if (s2*fudge_factor > s) { \
|
||||
@@ -461,9 +461,9 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
|
||||
normal2[2] = -normal[2];
|
||||
}
|
||||
dMULTIPLY1_331 (nr,Rb,normal2);
|
||||
anr[0] = fabsf (nr[0]);
|
||||
anr[1] = fabsf (nr[1]);
|
||||
anr[2] = fabsf (nr[2]);
|
||||
anr[0] = btFabs (nr[0]);
|
||||
anr[1] = btFabs (nr[1]);
|
||||
anr[2] = btFabs (nr[2]);
|
||||
|
||||
// find the largest compontent of anr: this corresponds to the normal
|
||||
// for the indident face. the other axis numbers of the indicent face
|
||||
|
||||
@@ -283,7 +283,7 @@ void* btCollisionDispatcher::allocateCollisionAlgorithm(int size)
|
||||
}
|
||||
|
||||
//warn user for overflow?
|
||||
return btAlignedAlloc(static_cast<std::size_t>(size), 16);
|
||||
return btAlignedAlloc(static_cast<size_t>(size), 16);
|
||||
}
|
||||
|
||||
void btCollisionDispatcher::freeCollisionAlgorithm(void* ptr)
|
||||
|
||||
@@ -99,6 +99,7 @@ struct MinkowskiDiff
|
||||
|
||||
typedef MinkowskiDiff tShape;
|
||||
|
||||
|
||||
// GJK
|
||||
struct GJK
|
||||
{
|
||||
@@ -515,6 +516,30 @@ sList m_stock;
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
||||
static inline void bind(sFace* fa,U ea,sFace* fb,U eb)
|
||||
{
|
||||
fa->e[ea]=(U1)eb;fa->f[ea]=fb;
|
||||
fb->e[eb]=(U1)ea;fb->f[eb]=fa;
|
||||
}
|
||||
static inline void append(sList& list,sFace* face)
|
||||
{
|
||||
face->l[0] = 0;
|
||||
face->l[1] = list.root;
|
||||
if(list.root) list.root->l[0]=face;
|
||||
list.root = face;
|
||||
++list.count;
|
||||
}
|
||||
static inline void remove(sList& list,sFace* face)
|
||||
{
|
||||
if(face->l[1]) face->l[1]->l[0]=face->l[0];
|
||||
if(face->l[0]) face->l[0]->l[1]=face->l[1];
|
||||
if(face==list.root) list.root=face->l[1];
|
||||
--list.count;
|
||||
}
|
||||
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
m_status = eStatus::Failed;
|
||||
@@ -531,10 +556,11 @@ eStatus::_ Evaluate(GJK& gjk,const btVector3& guess)
|
||||
GJK::sSimplex& simplex=*gjk.m_simplex;
|
||||
if((simplex.rank>1)&&gjk.EncloseOrigin())
|
||||
{
|
||||
|
||||
/* Clean up */
|
||||
while(m_hull.root)
|
||||
{
|
||||
sFace* f(m_hull.root);
|
||||
sFace* f = m_hull.root;
|
||||
remove(m_hull,f);
|
||||
append(m_stock,f);
|
||||
}
|
||||
@@ -716,26 +742,7 @@ bool expand(U pass,sSV* w,sFace* f,U e,sHorizon& horizon)
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
static inline void bind(sFace* fa,U ea,sFace* fb,U eb)
|
||||
{
|
||||
fa->e[ea]=(U1)eb;fa->f[ea]=fb;
|
||||
fb->e[eb]=(U1)ea;fb->f[eb]=fa;
|
||||
}
|
||||
static inline void append(sList& list,sFace* face)
|
||||
{
|
||||
face->l[0] = 0;
|
||||
face->l[1] = list.root;
|
||||
if(list.root) list.root->l[0]=face;
|
||||
list.root = face;
|
||||
++list.count;
|
||||
}
|
||||
static inline void remove(sList& list,sFace* face)
|
||||
{
|
||||
if(face->l[1]) face->l[1]->l[0]=face->l[0];
|
||||
if(face->l[0]) face->l[0]->l[1]=face->l[1];
|
||||
if(face==list.root) list.root=face->l[1];
|
||||
--list.count;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user