bt -> b3 and BT -> B3 rename for content and filenames
This commit is contained in:
@@ -3,24 +3,24 @@
|
||||
#define B3_BROADPHASE_CALLBACK_H
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
struct btBroadphaseProxy;
|
||||
struct b3BroadphaseProxy;
|
||||
|
||||
|
||||
struct btBroadphaseAabbCallback
|
||||
struct b3BroadphaseAabbCallback
|
||||
{
|
||||
virtual ~btBroadphaseAabbCallback() {}
|
||||
virtual bool process(const btBroadphaseProxy* proxy) = 0;
|
||||
virtual ~b3BroadphaseAabbCallback() {}
|
||||
virtual bool process(const b3BroadphaseProxy* proxy) = 0;
|
||||
};
|
||||
|
||||
|
||||
struct btBroadphaseRayCallback : public btBroadphaseAabbCallback
|
||||
struct b3BroadphaseRayCallback : public b3BroadphaseAabbCallback
|
||||
{
|
||||
///added some cached data to accelerate ray-AABB tests
|
||||
b3Vector3 m_rayDirectionInverse;
|
||||
unsigned int m_signs[3];
|
||||
b3Scalar m_lambda_max;
|
||||
|
||||
virtual ~btBroadphaseRayCallback() {}
|
||||
virtual ~b3BroadphaseRayCallback() {}
|
||||
};
|
||||
|
||||
#endif //B3_BROADPHASE_CALLBACK_H
|
||||
|
||||
@@ -17,38 +17,38 @@ subject to the following restrictions:
|
||||
#include "b3DynamicBvh.h"
|
||||
|
||||
//
|
||||
typedef b3AlignedObjectArray<btDbvtNode*> tNodeArray;
|
||||
typedef b3AlignedObjectArray<const btDbvtNode*> tConstNodeArray;
|
||||
typedef b3AlignedObjectArray<b3DbvtNode*> tNodeArray;
|
||||
typedef b3AlignedObjectArray<const b3DbvtNode*> tConstNodeArray;
|
||||
|
||||
//
|
||||
struct btDbvtNodeEnumerator : b3DynamicBvh::ICollide
|
||||
struct b3DbvtNodeEnumerator : b3DynamicBvh::ICollide
|
||||
{
|
||||
tConstNodeArray nodes;
|
||||
void Process(const btDbvtNode* n) { nodes.push_back(n); }
|
||||
void Process(const b3DbvtNode* n) { nodes.push_back(n); }
|
||||
};
|
||||
|
||||
//
|
||||
static DBVT_INLINE int indexof(const btDbvtNode* node)
|
||||
static DBVT_INLINE int indexof(const b3DbvtNode* node)
|
||||
{
|
||||
return(node->parent->childs[1]==node);
|
||||
}
|
||||
|
||||
//
|
||||
static DBVT_INLINE btDbvtVolume merge( const btDbvtVolume& a,
|
||||
const btDbvtVolume& b)
|
||||
static DBVT_INLINE b3DbvtVolume merge( const b3DbvtVolume& a,
|
||||
const b3DbvtVolume& b)
|
||||
{
|
||||
#if (DBVT_MERGE_IMPL==DBVT_IMPL_SSE)
|
||||
ATTRIBUTE_ALIGNED16(char locals[sizeof(btDbvtAabbMm)]);
|
||||
btDbvtVolume& res=*(btDbvtVolume*)locals;
|
||||
ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtAabbMm)]);
|
||||
b3DbvtVolume& res=*(b3DbvtVolume*)locals;
|
||||
#else
|
||||
btDbvtVolume res;
|
||||
b3DbvtVolume res;
|
||||
#endif
|
||||
Merge(a,b,res);
|
||||
return(res);
|
||||
}
|
||||
|
||||
// volume+edge lengths
|
||||
static DBVT_INLINE b3Scalar size(const btDbvtVolume& a)
|
||||
static DBVT_INLINE b3Scalar size(const b3DbvtVolume& a)
|
||||
{
|
||||
const b3Vector3 edges=a.Lengths();
|
||||
return( edges.x*edges.y*edges.z+
|
||||
@@ -56,26 +56,26 @@ static DBVT_INLINE b3Scalar size(const btDbvtVolume& a)
|
||||
}
|
||||
|
||||
//
|
||||
static void getmaxdepth(const btDbvtNode* node,int depth,int& maxdepth)
|
||||
static void getmaxdepth(const b3DbvtNode* node,int depth,int& maxdepth)
|
||||
{
|
||||
if(node->isinternal())
|
||||
{
|
||||
getmaxdepth(node->childs[0],depth+1,maxdepth);
|
||||
getmaxdepth(node->childs[1],depth+1,maxdepth);
|
||||
} else maxdepth=btMax(maxdepth,depth);
|
||||
} else maxdepth=b3Max(maxdepth,depth);
|
||||
}
|
||||
|
||||
//
|
||||
static DBVT_INLINE void deletenode( b3DynamicBvh* pdbvt,
|
||||
btDbvtNode* node)
|
||||
b3DbvtNode* node)
|
||||
{
|
||||
btAlignedFree(pdbvt->m_free);
|
||||
b3AlignedFree(pdbvt->m_free);
|
||||
pdbvt->m_free=node;
|
||||
}
|
||||
|
||||
//
|
||||
static void recursedeletenode( b3DynamicBvh* pdbvt,
|
||||
btDbvtNode* node)
|
||||
b3DbvtNode* node)
|
||||
{
|
||||
if(!node->isleaf())
|
||||
{
|
||||
@@ -87,15 +87,15 @@ static void recursedeletenode( b3DynamicBvh* pdbvt,
|
||||
}
|
||||
|
||||
//
|
||||
static DBVT_INLINE btDbvtNode* createnode( b3DynamicBvh* pdbvt,
|
||||
btDbvtNode* parent,
|
||||
static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt,
|
||||
b3DbvtNode* parent,
|
||||
void* data)
|
||||
{
|
||||
btDbvtNode* node;
|
||||
b3DbvtNode* node;
|
||||
if(pdbvt->m_free)
|
||||
{ node=pdbvt->m_free;pdbvt->m_free=0; }
|
||||
else
|
||||
{ node=new(btAlignedAlloc(sizeof(btDbvtNode),16)) btDbvtNode(); }
|
||||
{ node=new(b3AlignedAlloc(sizeof(b3DbvtNode),16)) b3DbvtNode(); }
|
||||
node->parent = parent;
|
||||
node->data = data;
|
||||
node->childs[1] = 0;
|
||||
@@ -103,32 +103,32 @@ static DBVT_INLINE btDbvtNode* createnode( b3DynamicBvh* pdbvt,
|
||||
}
|
||||
|
||||
//
|
||||
static DBVT_INLINE btDbvtNode* createnode( b3DynamicBvh* pdbvt,
|
||||
btDbvtNode* parent,
|
||||
const btDbvtVolume& volume,
|
||||
static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt,
|
||||
b3DbvtNode* parent,
|
||||
const b3DbvtVolume& volume,
|
||||
void* data)
|
||||
{
|
||||
btDbvtNode* node=createnode(pdbvt,parent,data);
|
||||
b3DbvtNode* node=createnode(pdbvt,parent,data);
|
||||
node->volume=volume;
|
||||
return(node);
|
||||
}
|
||||
|
||||
//
|
||||
static DBVT_INLINE btDbvtNode* createnode( b3DynamicBvh* pdbvt,
|
||||
btDbvtNode* parent,
|
||||
const btDbvtVolume& volume0,
|
||||
const btDbvtVolume& volume1,
|
||||
static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt,
|
||||
b3DbvtNode* parent,
|
||||
const b3DbvtVolume& volume0,
|
||||
const b3DbvtVolume& volume1,
|
||||
void* data)
|
||||
{
|
||||
btDbvtNode* node=createnode(pdbvt,parent,data);
|
||||
b3DbvtNode* node=createnode(pdbvt,parent,data);
|
||||
Merge(volume0,volume1,node->volume);
|
||||
return(node);
|
||||
}
|
||||
|
||||
//
|
||||
static void insertleaf( b3DynamicBvh* pdbvt,
|
||||
btDbvtNode* root,
|
||||
btDbvtNode* leaf)
|
||||
b3DbvtNode* root,
|
||||
b3DbvtNode* leaf)
|
||||
{
|
||||
if(!pdbvt->m_root)
|
||||
{
|
||||
@@ -145,8 +145,8 @@ static void insertleaf( b3DynamicBvh* pdbvt,
|
||||
root->childs[1]->volume)];
|
||||
} while(!root->isleaf());
|
||||
}
|
||||
btDbvtNode* prev=root->parent;
|
||||
btDbvtNode* node=createnode(pdbvt,prev,leaf->volume,root->volume,0);
|
||||
b3DbvtNode* prev=root->parent;
|
||||
b3DbvtNode* node=createnode(pdbvt,prev,leaf->volume,root->volume,0);
|
||||
if(prev)
|
||||
{
|
||||
prev->childs[indexof(root)] = node;
|
||||
@@ -170,8 +170,8 @@ static void insertleaf( b3DynamicBvh* pdbvt,
|
||||
}
|
||||
|
||||
//
|
||||
static btDbvtNode* removeleaf( b3DynamicBvh* pdbvt,
|
||||
btDbvtNode* leaf)
|
||||
static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt,
|
||||
b3DbvtNode* leaf)
|
||||
{
|
||||
if(leaf==pdbvt->m_root)
|
||||
{
|
||||
@@ -180,9 +180,9 @@ static btDbvtNode* removeleaf( b3DynamicBvh* pdbvt,
|
||||
}
|
||||
else
|
||||
{
|
||||
btDbvtNode* parent=leaf->parent;
|
||||
btDbvtNode* prev=parent->parent;
|
||||
btDbvtNode* sibling=parent->childs[1-indexof(leaf)];
|
||||
b3DbvtNode* parent=leaf->parent;
|
||||
b3DbvtNode* prev=parent->parent;
|
||||
b3DbvtNode* sibling=parent->childs[1-indexof(leaf)];
|
||||
if(prev)
|
||||
{
|
||||
prev->childs[indexof(parent)]=sibling;
|
||||
@@ -190,7 +190,7 @@ static btDbvtNode* removeleaf( b3DynamicBvh* pdbvt,
|
||||
deletenode(pdbvt,parent);
|
||||
while(prev)
|
||||
{
|
||||
const btDbvtVolume pb=prev->volume;
|
||||
const b3DbvtVolume pb=prev->volume;
|
||||
Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
|
||||
if(NotEqual(pb,prev->volume))
|
||||
{
|
||||
@@ -211,7 +211,7 @@ static btDbvtNode* removeleaf( b3DynamicBvh* pdbvt,
|
||||
|
||||
//
|
||||
static void fetchleaves(b3DynamicBvh* pdbvt,
|
||||
btDbvtNode* root,
|
||||
b3DbvtNode* root,
|
||||
tNodeArray& leaves,
|
||||
int depth=-1)
|
||||
{
|
||||
@@ -238,7 +238,7 @@ static void split( const tNodeArray& leaves,
|
||||
right.resize(0);
|
||||
for(int i=0,ni=leaves.size();i<ni;++i)
|
||||
{
|
||||
if(btDot(axis,leaves[i]->volume.Center()-org)<0)
|
||||
if(b3Dot(axis,leaves[i]->volume.Center()-org)<0)
|
||||
left.push_back(leaves[i]);
|
||||
else
|
||||
right.push_back(leaves[i]);
|
||||
@@ -246,14 +246,14 @@ static void split( const tNodeArray& leaves,
|
||||
}
|
||||
|
||||
//
|
||||
static btDbvtVolume bounds( const tNodeArray& leaves)
|
||||
static b3DbvtVolume bounds( const tNodeArray& leaves)
|
||||
{
|
||||
#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE
|
||||
ATTRIBUTE_ALIGNED16(char locals[sizeof(btDbvtVolume)]);
|
||||
btDbvtVolume& volume=*(btDbvtVolume*)locals;
|
||||
ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtVolume)]);
|
||||
b3DbvtVolume& volume=*(b3DbvtVolume*)locals;
|
||||
volume=leaves[0]->volume;
|
||||
#else
|
||||
btDbvtVolume volume=leaves[0]->volume;
|
||||
b3DbvtVolume volume=leaves[0]->volume;
|
||||
#endif
|
||||
for(int i=1,ni=leaves.size();i<ni;++i)
|
||||
{
|
||||
@@ -283,8 +283,8 @@ static void bottomup( b3DynamicBvh* pdbvt,
|
||||
}
|
||||
}
|
||||
}
|
||||
btDbvtNode* n[] = {leaves[minidx[0]],leaves[minidx[1]]};
|
||||
btDbvtNode* p = createnode(pdbvt,0,n[0]->volume,n[1]->volume,0);
|
||||
b3DbvtNode* n[] = {leaves[minidx[0]],leaves[minidx[1]]};
|
||||
b3DbvtNode* p = createnode(pdbvt,0,n[0]->volume,n[1]->volume,0);
|
||||
p->childs[0] = n[0];
|
||||
p->childs[1] = n[1];
|
||||
n[0]->parent = p;
|
||||
@@ -296,7 +296,7 @@ static void bottomup( b3DynamicBvh* pdbvt,
|
||||
}
|
||||
|
||||
//
|
||||
static btDbvtNode* topdown(b3DynamicBvh* pdbvt,
|
||||
static b3DbvtNode* topdown(b3DynamicBvh* pdbvt,
|
||||
tNodeArray& leaves,
|
||||
int bu_treshold)
|
||||
{
|
||||
@@ -307,7 +307,7 @@ static btDbvtNode* topdown(b3DynamicBvh* pdbvt,
|
||||
{
|
||||
if(leaves.size()>bu_treshold)
|
||||
{
|
||||
const btDbvtVolume vol=bounds(leaves);
|
||||
const b3DbvtVolume vol=bounds(leaves);
|
||||
const b3Vector3 org=vol.Center();
|
||||
tNodeArray sets[2];
|
||||
int bestaxis=-1;
|
||||
@@ -319,14 +319,14 @@ static btDbvtNode* topdown(b3DynamicBvh* pdbvt,
|
||||
const b3Vector3 x=leaves[i]->volume.Center()-org;
|
||||
for(int j=0;j<3;++j)
|
||||
{
|
||||
++splitcount[j][btDot(x,axis[j])>0?1:0];
|
||||
++splitcount[j][b3Dot(x,axis[j])>0?1:0];
|
||||
}
|
||||
}
|
||||
for( i=0;i<3;++i)
|
||||
{
|
||||
if((splitcount[i][0]>0)&&(splitcount[i][1]>0))
|
||||
{
|
||||
const int midp=(int)btFabs(b3Scalar(splitcount[i][0]-splitcount[i][1]));
|
||||
const int midp=(int)b3Fabs(b3Scalar(splitcount[i][0]-splitcount[i][1]));
|
||||
if(midp<bestmidp)
|
||||
{
|
||||
bestaxis=i;
|
||||
@@ -349,7 +349,7 @@ static btDbvtNode* topdown(b3DynamicBvh* pdbvt,
|
||||
sets[i&1].push_back(leaves[i]);
|
||||
}
|
||||
}
|
||||
btDbvtNode* node=createnode(pdbvt,0,vol,0);
|
||||
b3DbvtNode* node=createnode(pdbvt,0,vol,0);
|
||||
node->childs[0]=topdown(pdbvt,sets[0],bu_treshold);
|
||||
node->childs[1]=topdown(pdbvt,sets[1],bu_treshold);
|
||||
node->childs[0]->parent=node;
|
||||
@@ -366,17 +366,17 @@ static btDbvtNode* topdown(b3DynamicBvh* pdbvt,
|
||||
}
|
||||
|
||||
//
|
||||
static DBVT_INLINE btDbvtNode* sort(btDbvtNode* n,btDbvtNode*& r)
|
||||
static DBVT_INLINE b3DbvtNode* sort(b3DbvtNode* n,b3DbvtNode*& r)
|
||||
{
|
||||
btDbvtNode* p=n->parent;
|
||||
btAssert(n->isinternal());
|
||||
b3DbvtNode* p=n->parent;
|
||||
b3Assert(n->isinternal());
|
||||
if(p>n)
|
||||
{
|
||||
const int i=indexof(n);
|
||||
const int j=1-i;
|
||||
btDbvtNode* s=p->childs[j];
|
||||
btDbvtNode* q=p->parent;
|
||||
btAssert(n==p->childs[i]);
|
||||
b3DbvtNode* s=p->childs[j];
|
||||
b3DbvtNode* q=p->parent;
|
||||
b3Assert(n==p->childs[i]);
|
||||
if(q) q->childs[indexof(p)]=n; else r=n;
|
||||
s->parent=n;
|
||||
p->parent=n;
|
||||
@@ -387,14 +387,14 @@ static DBVT_INLINE btDbvtNode* sort(btDbvtNode* n,btDbvtNode*& r)
|
||||
n->childs[1]->parent=p;
|
||||
n->childs[i]=p;
|
||||
n->childs[j]=s;
|
||||
btSwap(p->volume,n->volume);
|
||||
b3Swap(p->volume,n->volume);
|
||||
return(p);
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static DBVT_INLINE btDbvtNode* walkup(btDbvtNode* n,int count)
|
||||
static DBVT_INLINE b3DbvtNode* walkup(b3DbvtNode* n,int count)
|
||||
{
|
||||
while(n&&(count--)) n=n->parent;
|
||||
return(n);
|
||||
@@ -426,7 +426,7 @@ void b3DynamicBvh::clear()
|
||||
{
|
||||
if(m_root)
|
||||
recursedeletenode(this,m_root);
|
||||
btAlignedFree(m_free);
|
||||
b3AlignedFree(m_free);
|
||||
m_free=0;
|
||||
m_lkhd = -1;
|
||||
m_stkStack.clear();
|
||||
@@ -466,7 +466,7 @@ void b3DynamicBvh::optimizeIncremental(int passes)
|
||||
if(m_root&&(passes>0))
|
||||
{
|
||||
do {
|
||||
btDbvtNode* node=m_root;
|
||||
b3DbvtNode* node=m_root;
|
||||
unsigned bit=0;
|
||||
while(node->isinternal())
|
||||
{
|
||||
@@ -480,18 +480,18 @@ void b3DynamicBvh::optimizeIncremental(int passes)
|
||||
}
|
||||
|
||||
//
|
||||
btDbvtNode* b3DynamicBvh::insert(const btDbvtVolume& volume,void* data)
|
||||
b3DbvtNode* b3DynamicBvh::insert(const b3DbvtVolume& volume,void* data)
|
||||
{
|
||||
btDbvtNode* leaf=createnode(this,0,volume,data);
|
||||
b3DbvtNode* leaf=createnode(this,0,volume,data);
|
||||
insertleaf(this,m_root,leaf);
|
||||
++m_leaves;
|
||||
return(leaf);
|
||||
}
|
||||
|
||||
//
|
||||
void b3DynamicBvh::update(btDbvtNode* leaf,int lookahead)
|
||||
void b3DynamicBvh::update(b3DbvtNode* leaf,int lookahead)
|
||||
{
|
||||
btDbvtNode* root=removeleaf(this,leaf);
|
||||
b3DbvtNode* root=removeleaf(this,leaf);
|
||||
if(root)
|
||||
{
|
||||
if(lookahead>=0)
|
||||
@@ -506,9 +506,9 @@ void b3DynamicBvh::update(btDbvtNode* leaf,int lookahead)
|
||||
}
|
||||
|
||||
//
|
||||
void b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume)
|
||||
void b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume)
|
||||
{
|
||||
btDbvtNode* root=removeleaf(this,leaf);
|
||||
b3DbvtNode* root=removeleaf(this,leaf);
|
||||
if(root)
|
||||
{
|
||||
if(m_lkhd>=0)
|
||||
@@ -524,7 +524,7 @@ void b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume)
|
||||
}
|
||||
|
||||
//
|
||||
bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector3& velocity,b3Scalar margin)
|
||||
bool b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume,const b3Vector3& velocity,b3Scalar margin)
|
||||
{
|
||||
if(leaf->volume.Contain(volume)) return(false);
|
||||
volume.Expand(b3Vector3(margin,margin,margin));
|
||||
@@ -534,7 +534,7 @@ bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector
|
||||
}
|
||||
|
||||
//
|
||||
bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector3& velocity)
|
||||
bool b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume,const b3Vector3& velocity)
|
||||
{
|
||||
if(leaf->volume.Contain(volume)) return(false);
|
||||
volume.SignedExpand(velocity);
|
||||
@@ -543,7 +543,7 @@ bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector
|
||||
}
|
||||
|
||||
//
|
||||
bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,b3Scalar margin)
|
||||
bool b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume,b3Scalar margin)
|
||||
{
|
||||
if(leaf->volume.Contain(volume)) return(false);
|
||||
volume.Expand(b3Vector3(margin,margin,margin));
|
||||
@@ -552,7 +552,7 @@ bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,b3Scalar margi
|
||||
}
|
||||
|
||||
//
|
||||
void b3DynamicBvh::remove(btDbvtNode* leaf)
|
||||
void b3DynamicBvh::remove(b3DbvtNode* leaf)
|
||||
{
|
||||
removeleaf(this,leaf);
|
||||
deletenode(this,leaf);
|
||||
@@ -562,13 +562,13 @@ void b3DynamicBvh::remove(btDbvtNode* leaf)
|
||||
//
|
||||
void b3DynamicBvh::write(IWriter* iwriter) const
|
||||
{
|
||||
btDbvtNodeEnumerator nodes;
|
||||
b3DbvtNodeEnumerator nodes;
|
||||
nodes.nodes.reserve(m_leaves*2);
|
||||
enumNodes(m_root,nodes);
|
||||
iwriter->Prepare(m_root,nodes.nodes.size());
|
||||
for(int i=0;i<nodes.nodes.size();++i)
|
||||
{
|
||||
const btDbvtNode* n=nodes.nodes[i];
|
||||
const b3DbvtNode* n=nodes.nodes[i];
|
||||
int p=-1;
|
||||
if(n->parent) p=nodes.nodes.findLinearSearch(n->parent);
|
||||
if(n->isinternal())
|
||||
@@ -596,7 +596,7 @@ void b3DynamicBvh::clone(b3DynamicBvh& dest,IClone* iclone) const
|
||||
do {
|
||||
const int i=stack.size()-1;
|
||||
const sStkCLN e=stack[i];
|
||||
btDbvtNode* n=createnode(&dest,e.parent,e.node->volume,e.node->data);
|
||||
b3DbvtNode* n=createnode(&dest,e.parent,e.node->volume,e.node->data);
|
||||
stack.pop_back();
|
||||
if(e.parent!=0)
|
||||
e.parent->childs[i&1]=n;
|
||||
@@ -616,7 +616,7 @@ void b3DynamicBvh::clone(b3DynamicBvh& dest,IClone* iclone) const
|
||||
}
|
||||
|
||||
//
|
||||
int b3DynamicBvh::maxdepth(const btDbvtNode* node)
|
||||
int b3DynamicBvh::maxdepth(const b3DbvtNode* node)
|
||||
{
|
||||
int depth=0;
|
||||
if(node) getmaxdepth(node,1,depth);
|
||||
@@ -624,7 +624,7 @@ int b3DynamicBvh::maxdepth(const btDbvtNode* node)
|
||||
}
|
||||
|
||||
//
|
||||
int b3DynamicBvh::countLeaves(const btDbvtNode* node)
|
||||
int b3DynamicBvh::countLeaves(const b3DbvtNode* node)
|
||||
{
|
||||
if(node->isinternal())
|
||||
return(countLeaves(node->childs[0])+countLeaves(node->childs[1]));
|
||||
@@ -633,7 +633,7 @@ int b3DynamicBvh::countLeaves(const btDbvtNode* node)
|
||||
}
|
||||
|
||||
//
|
||||
void b3DynamicBvh::extractLeaves(const btDbvtNode* node,b3AlignedObjectArray<const btDbvtNode*>& leaves)
|
||||
void b3DynamicBvh::extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray<const b3DbvtNode*>& leaves)
|
||||
{
|
||||
if(node->isinternal())
|
||||
{
|
||||
@@ -651,7 +651,7 @@ void b3DynamicBvh::extractLeaves(const btDbvtNode* node,b3AlignedObjectArray<c
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "LinearMath/btQuickProf.h"
|
||||
#include "LinearMath/b3QuickProf.h"
|
||||
|
||||
/*
|
||||
q6600,2.4ghz
|
||||
@@ -667,10 +667,10 @@ World scale: 100.000000
|
||||
Extents base: 1.000000
|
||||
Extents range: 4.000000
|
||||
Leaves: 8192
|
||||
sizeof(btDbvtVolume): 32 bytes
|
||||
sizeof(btDbvtNode): 44 bytes
|
||||
[1] btDbvtVolume intersections: 3499 ms (-1%)
|
||||
[2] btDbvtVolume merges: 1934 ms (0%)
|
||||
sizeof(b3DbvtVolume): 32 bytes
|
||||
sizeof(b3DbvtNode): 44 bytes
|
||||
[1] b3DbvtVolume intersections: 3499 ms (-1%)
|
||||
[2] b3DbvtVolume merges: 1934 ms (0%)
|
||||
[3] b3DynamicBvh::collideTT: 5485 ms (-21%)
|
||||
[4] b3DynamicBvh::collideTT self: 2814 ms (-20%)
|
||||
[5] b3DynamicBvh::collideTT xform: 7379 ms (-1%)
|
||||
@@ -680,22 +680,22 @@ sizeof(btDbvtNode): 44 bytes
|
||||
[9] updates (teleport): 1879 ms (-3%),(1116100 u/s)
|
||||
[10] updates (jitter): 1244 ms (-4%),(1685813 u/s)
|
||||
[11] optimize (incremental): 2514 ms (0%),(1668000 o/s)
|
||||
[12] btDbvtVolume notequal: 3659 ms (0%)
|
||||
[12] b3DbvtVolume notequal: 3659 ms (0%)
|
||||
[13] culling(OCL+fullsort): 2218 ms (0%),(461 t/s)
|
||||
[14] culling(OCL+qsort): 3688 ms (5%),(2221 t/s)
|
||||
[15] culling(KDOP+qsort): 1139 ms (-1%),(7192 t/s)
|
||||
[16] insert/remove batch(256): 5092 ms (0%),(823704 bir/s)
|
||||
[17] btDbvtVolume select: 3419 ms (0%)
|
||||
[17] b3DbvtVolume select: 3419 ms (0%)
|
||||
*/
|
||||
|
||||
struct btDbvtBenchmark
|
||||
struct b3DbvtBenchmark
|
||||
{
|
||||
struct NilPolicy : b3DynamicBvh::ICollide
|
||||
{
|
||||
NilPolicy() : m_pcount(0),m_depth(-SIMD_INFINITY),m_checksort(true) {}
|
||||
void Process(const btDbvtNode*,const btDbvtNode*) { ++m_pcount; }
|
||||
void Process(const btDbvtNode*) { ++m_pcount; }
|
||||
void Process(const btDbvtNode*,b3Scalar depth)
|
||||
void Process(const b3DbvtNode*,const b3DbvtNode*) { ++m_pcount; }
|
||||
void Process(const b3DbvtNode*) { ++m_pcount; }
|
||||
void Process(const b3DbvtNode*,b3Scalar depth)
|
||||
{
|
||||
++m_pcount;
|
||||
if(m_checksort)
|
||||
@@ -709,10 +709,10 @@ struct btDbvtBenchmark
|
||||
{
|
||||
struct Node
|
||||
{
|
||||
const btDbvtNode* leaf;
|
||||
const b3DbvtNode* leaf;
|
||||
b3Scalar depth;
|
||||
};
|
||||
void Process(const btDbvtNode* leaf,b3Scalar depth)
|
||||
void Process(const b3DbvtNode* leaf,b3Scalar depth)
|
||||
{
|
||||
Node n;
|
||||
n.leaf = leaf;
|
||||
@@ -730,10 +730,10 @@ struct btDbvtBenchmark
|
||||
{
|
||||
struct Node
|
||||
{
|
||||
const btDbvtNode* leaf;
|
||||
const b3DbvtNode* leaf;
|
||||
b3Scalar depth;
|
||||
};
|
||||
void Process(const btDbvtNode* leaf)
|
||||
void Process(const b3DbvtNode* leaf)
|
||||
{
|
||||
Node n;
|
||||
n.leaf = leaf;
|
||||
@@ -760,15 +760,15 @@ struct btDbvtBenchmark
|
||||
{
|
||||
return(RandVector3()*cs-b3Vector3(cs,cs,cs)/2);
|
||||
}
|
||||
static btDbvtVolume RandVolume(b3Scalar cs,b3Scalar eb,b3Scalar es)
|
||||
static b3DbvtVolume RandVolume(b3Scalar cs,b3Scalar eb,b3Scalar es)
|
||||
{
|
||||
return(btDbvtVolume::FromCE(RandVector3(cs),b3Vector3(eb,eb,eb)+RandVector3()*es));
|
||||
return(b3DbvtVolume::FromCE(RandVector3(cs),b3Vector3(eb,eb,eb)+RandVector3()*es));
|
||||
}
|
||||
static b3Transform RandTransform(b3Scalar cs)
|
||||
{
|
||||
b3Transform t;
|
||||
t.setOrigin(RandVector3(cs));
|
||||
t.setRotation(btQuaternion(RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2).normalized());
|
||||
t.setRotation(b3Quaternion(RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2).normalized());
|
||||
return(t);
|
||||
}
|
||||
static void RandTree(b3Scalar cs,b3Scalar eb,b3Scalar es,int leaves,b3DynamicBvh& dbvt)
|
||||
@@ -789,11 +789,11 @@ void b3DynamicBvh::benchmark()
|
||||
static const int cfgLeaves = 8192;
|
||||
static const bool cfgEnable = true;
|
||||
|
||||
//[1] btDbvtVolume intersections
|
||||
//[1] b3DbvtVolume intersections
|
||||
bool cfgBenchmark1_Enable = cfgEnable;
|
||||
static const int cfgBenchmark1_Iterations = 8;
|
||||
static const int cfgBenchmark1_Reference = 3499;
|
||||
//[2] btDbvtVolume merges
|
||||
//[2] b3DbvtVolume merges
|
||||
bool cfgBenchmark2_Enable = cfgEnable;
|
||||
static const int cfgBenchmark2_Iterations = 4;
|
||||
static const int cfgBenchmark2_Reference = 1945;
|
||||
@@ -841,7 +841,7 @@ void b3DynamicBvh::benchmark()
|
||||
static const int cfgBenchmark11_Passes = 64;
|
||||
static const int cfgBenchmark11_Iterations = 65536;
|
||||
static const int cfgBenchmark11_Reference = 2510;
|
||||
//[12] btDbvtVolume notequal
|
||||
//[12] b3DbvtVolume notequal
|
||||
bool cfgBenchmark12_Enable = cfgEnable;
|
||||
static const int cfgBenchmark12_Iterations = 32;
|
||||
static const int cfgBenchmark12_Reference = 3677;
|
||||
@@ -867,26 +867,26 @@ void b3DynamicBvh::benchmark()
|
||||
static const int cfgBenchmark17_Iterations = 4;
|
||||
static const int cfgBenchmark17_Reference = 3390;
|
||||
|
||||
btClock wallclock;
|
||||
b3Clock wallclock;
|
||||
printf("Benchmarking dbvt...\r\n");
|
||||
printf("\tWorld scale: %f\r\n",cfgVolumeCenterScale);
|
||||
printf("\tExtents base: %f\r\n",cfgVolumeExentsBase);
|
||||
printf("\tExtents range: %f\r\n",cfgVolumeExentsScale);
|
||||
printf("\tLeaves: %u\r\n",cfgLeaves);
|
||||
printf("\tsizeof(btDbvtVolume): %u bytes\r\n",sizeof(btDbvtVolume));
|
||||
printf("\tsizeof(btDbvtNode): %u bytes\r\n",sizeof(btDbvtNode));
|
||||
printf("\tsizeof(b3DbvtVolume): %u bytes\r\n",sizeof(b3DbvtVolume));
|
||||
printf("\tsizeof(b3DbvtNode): %u bytes\r\n",sizeof(b3DbvtNode));
|
||||
if(cfgBenchmark1_Enable)
|
||||
{// Benchmark 1
|
||||
srand(380843);
|
||||
b3AlignedObjectArray<btDbvtVolume> volumes;
|
||||
b3AlignedObjectArray<b3DbvtVolume> volumes;
|
||||
b3AlignedObjectArray<bool> results;
|
||||
volumes.resize(cfgLeaves);
|
||||
results.resize(cfgLeaves);
|
||||
for(int i=0;i<cfgLeaves;++i)
|
||||
{
|
||||
volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
|
||||
volumes[i]=b3DbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
|
||||
}
|
||||
printf("[1] btDbvtVolume intersections: ");
|
||||
printf("[1] b3DbvtVolume intersections: ");
|
||||
wallclock.reset();
|
||||
for(int i=0;i<cfgBenchmark1_Iterations;++i)
|
||||
{
|
||||
@@ -904,15 +904,15 @@ void b3DynamicBvh::benchmark()
|
||||
if(cfgBenchmark2_Enable)
|
||||
{// Benchmark 2
|
||||
srand(380843);
|
||||
b3AlignedObjectArray<btDbvtVolume> volumes;
|
||||
b3AlignedObjectArray<btDbvtVolume> results;
|
||||
b3AlignedObjectArray<b3DbvtVolume> volumes;
|
||||
b3AlignedObjectArray<b3DbvtVolume> results;
|
||||
volumes.resize(cfgLeaves);
|
||||
results.resize(cfgLeaves);
|
||||
for(int i=0;i<cfgLeaves;++i)
|
||||
{
|
||||
volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
|
||||
volumes[i]=b3DbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
|
||||
}
|
||||
printf("[2] btDbvtVolume merges: ");
|
||||
printf("[2] b3DbvtVolume merges: ");
|
||||
wallclock.reset();
|
||||
for(int i=0;i<cfgBenchmark2_Iterations;++i)
|
||||
{
|
||||
@@ -931,9 +931,9 @@ void b3DynamicBvh::benchmark()
|
||||
{// Benchmark 3
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt[2];
|
||||
btDbvtBenchmark::NilPolicy policy;
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[0]);
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[1]);
|
||||
b3DbvtBenchmark::NilPolicy policy;
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[0]);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[1]);
|
||||
dbvt[0].optimizeTopDown();
|
||||
dbvt[1].optimizeTopDown();
|
||||
printf("[3] b3DynamicBvh::collideTT: ");
|
||||
@@ -949,8 +949,8 @@ void b3DynamicBvh::benchmark()
|
||||
{// Benchmark 4
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
btDbvtBenchmark::NilPolicy policy;
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3DbvtBenchmark::NilPolicy policy;
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
printf("[4] b3DynamicBvh::collideTT self: ");
|
||||
wallclock.reset();
|
||||
@@ -966,14 +966,14 @@ void b3DynamicBvh::benchmark()
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt[2];
|
||||
b3AlignedObjectArray<b3Transform> transforms;
|
||||
btDbvtBenchmark::NilPolicy policy;
|
||||
b3DbvtBenchmark::NilPolicy policy;
|
||||
transforms.resize(cfgBenchmark5_Iterations);
|
||||
for(int i=0;i<transforms.size();++i)
|
||||
{
|
||||
transforms[i]=btDbvtBenchmark::RandTransform(cfgVolumeCenterScale*cfgBenchmark5_OffsetScale);
|
||||
transforms[i]=b3DbvtBenchmark::RandTransform(cfgVolumeCenterScale*cfgBenchmark5_OffsetScale);
|
||||
}
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[0]);
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[1]);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[0]);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt[1]);
|
||||
dbvt[0].optimizeTopDown();
|
||||
dbvt[1].optimizeTopDown();
|
||||
printf("[5] b3DynamicBvh::collideTT xform: ");
|
||||
@@ -990,13 +990,13 @@ void b3DynamicBvh::benchmark()
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
b3AlignedObjectArray<b3Transform> transforms;
|
||||
btDbvtBenchmark::NilPolicy policy;
|
||||
b3DbvtBenchmark::NilPolicy policy;
|
||||
transforms.resize(cfgBenchmark6_Iterations);
|
||||
for(int i=0;i<transforms.size();++i)
|
||||
{
|
||||
transforms[i]=btDbvtBenchmark::RandTransform(cfgVolumeCenterScale*cfgBenchmark6_OffsetScale);
|
||||
transforms[i]=b3DbvtBenchmark::RandTransform(cfgVolumeCenterScale*cfgBenchmark6_OffsetScale);
|
||||
}
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
printf("[6] b3DynamicBvh::collideTT xform,self: ");
|
||||
wallclock.reset();
|
||||
@@ -1013,15 +1013,15 @@ void b3DynamicBvh::benchmark()
|
||||
b3DynamicBvh dbvt;
|
||||
b3AlignedObjectArray<b3Vector3> rayorg;
|
||||
b3AlignedObjectArray<b3Vector3> raydir;
|
||||
btDbvtBenchmark::NilPolicy policy;
|
||||
b3DbvtBenchmark::NilPolicy policy;
|
||||
rayorg.resize(cfgBenchmark7_Iterations);
|
||||
raydir.resize(cfgBenchmark7_Iterations);
|
||||
for(int i=0;i<rayorg.size();++i)
|
||||
{
|
||||
rayorg[i]=btDbvtBenchmark::RandVector3(cfgVolumeCenterScale*2);
|
||||
raydir[i]=btDbvtBenchmark::RandVector3(cfgVolumeCenterScale*2);
|
||||
rayorg[i]=b3DbvtBenchmark::RandVector3(cfgVolumeCenterScale*2);
|
||||
raydir[i]=b3DbvtBenchmark::RandVector3(cfgVolumeCenterScale*2);
|
||||
}
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
printf("[7] b3DynamicBvh::rayTest: ");
|
||||
wallclock.reset();
|
||||
@@ -1040,7 +1040,7 @@ void b3DynamicBvh::benchmark()
|
||||
{// Benchmark 8
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
printf("[8] insert/remove: ");
|
||||
wallclock.reset();
|
||||
@@ -1048,7 +1048,7 @@ void b3DynamicBvh::benchmark()
|
||||
{
|
||||
for(int j=0;j<cfgBenchmark8_Iterations;++j)
|
||||
{
|
||||
dbvt.remove(dbvt.insert(btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale),0));
|
||||
dbvt.remove(dbvt.insert(b3DbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale),0));
|
||||
}
|
||||
}
|
||||
const int time=(int)wallclock.getTimeMilliseconds();
|
||||
@@ -1059,8 +1059,8 @@ void b3DynamicBvh::benchmark()
|
||||
{// Benchmark 9
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
b3AlignedObjectArray<const btDbvtNode*> leaves;
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3AlignedObjectArray<const b3DbvtNode*> leaves;
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
dbvt.extractLeaves(dbvt.m_root,leaves);
|
||||
printf("[9] updates (teleport): ");
|
||||
@@ -1069,8 +1069,8 @@ void b3DynamicBvh::benchmark()
|
||||
{
|
||||
for(int j=0;j<cfgBenchmark9_Iterations;++j)
|
||||
{
|
||||
dbvt.update(const_cast<btDbvtNode*>(leaves[rand()%cfgLeaves]),
|
||||
btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale));
|
||||
dbvt.update(const_cast<b3DbvtNode*>(leaves[rand()%cfgLeaves]),
|
||||
b3DbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale));
|
||||
}
|
||||
}
|
||||
const int time=(int)wallclock.getTimeMilliseconds();
|
||||
@@ -1081,14 +1081,14 @@ void b3DynamicBvh::benchmark()
|
||||
{// Benchmark 10
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
b3AlignedObjectArray<const btDbvtNode*> leaves;
|
||||
b3AlignedObjectArray<const b3DbvtNode*> leaves;
|
||||
b3AlignedObjectArray<b3Vector3> vectors;
|
||||
vectors.resize(cfgBenchmark10_Iterations);
|
||||
for(int i=0;i<vectors.size();++i)
|
||||
{
|
||||
vectors[i]=(btDbvtBenchmark::RandVector3()*2-b3Vector3(1,1,1))*cfgBenchmark10_Scale;
|
||||
vectors[i]=(b3DbvtBenchmark::RandVector3()*2-b3Vector3(1,1,1))*cfgBenchmark10_Scale;
|
||||
}
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
dbvt.extractLeaves(dbvt.m_root,leaves);
|
||||
printf("[10] updates (jitter): ");
|
||||
@@ -1099,8 +1099,8 @@ void b3DynamicBvh::benchmark()
|
||||
for(int j=0;j<cfgBenchmark10_Iterations;++j)
|
||||
{
|
||||
const b3Vector3& d=vectors[j];
|
||||
btDbvtNode* l=const_cast<btDbvtNode*>(leaves[rand()%cfgLeaves]);
|
||||
btDbvtVolume v=btDbvtVolume::FromMM(l->volume.Mins()+d,l->volume.Maxs()+d);
|
||||
b3DbvtNode* l=const_cast<b3DbvtNode*>(leaves[rand()%cfgLeaves]);
|
||||
b3DbvtVolume v=b3DbvtVolume::FromMM(l->volume.Mins()+d,l->volume.Maxs()+d);
|
||||
dbvt.update(l,v);
|
||||
}
|
||||
}
|
||||
@@ -1112,7 +1112,7 @@ void b3DynamicBvh::benchmark()
|
||||
{// Benchmark 11
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
printf("[11] optimize (incremental): ");
|
||||
wallclock.reset();
|
||||
@@ -1127,15 +1127,15 @@ void b3DynamicBvh::benchmark()
|
||||
if(cfgBenchmark12_Enable)
|
||||
{// Benchmark 12
|
||||
srand(380843);
|
||||
b3AlignedObjectArray<btDbvtVolume> volumes;
|
||||
b3AlignedObjectArray<b3DbvtVolume> volumes;
|
||||
b3AlignedObjectArray<bool> results;
|
||||
volumes.resize(cfgLeaves);
|
||||
results.resize(cfgLeaves);
|
||||
for(int i=0;i<cfgLeaves;++i)
|
||||
{
|
||||
volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
|
||||
volumes[i]=b3DbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
|
||||
}
|
||||
printf("[12] btDbvtVolume notequal: ");
|
||||
printf("[12] b3DbvtVolume notequal: ");
|
||||
wallclock.reset();
|
||||
for(int i=0;i<cfgBenchmark12_Iterations;++i)
|
||||
{
|
||||
@@ -1155,13 +1155,13 @@ void b3DynamicBvh::benchmark()
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
b3AlignedObjectArray<b3Vector3> vectors;
|
||||
btDbvtBenchmark::NilPolicy policy;
|
||||
b3DbvtBenchmark::NilPolicy policy;
|
||||
vectors.resize(cfgBenchmark13_Iterations);
|
||||
for(int i=0;i<vectors.size();++i)
|
||||
{
|
||||
vectors[i]=(btDbvtBenchmark::RandVector3()*2-b3Vector3(1,1,1)).normalized();
|
||||
vectors[i]=(b3DbvtBenchmark::RandVector3()*2-b3Vector3(1,1,1)).normalized();
|
||||
}
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
printf("[13] culling(OCL+fullsort): ");
|
||||
wallclock.reset();
|
||||
@@ -1180,13 +1180,13 @@ void b3DynamicBvh::benchmark()
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
b3AlignedObjectArray<b3Vector3> vectors;
|
||||
btDbvtBenchmark::P14 policy;
|
||||
b3DbvtBenchmark::P14 policy;
|
||||
vectors.resize(cfgBenchmark14_Iterations);
|
||||
for(int i=0;i<vectors.size();++i)
|
||||
{
|
||||
vectors[i]=(btDbvtBenchmark::RandVector3()*2-b3Vector3(1,1,1)).normalized();
|
||||
vectors[i]=(b3DbvtBenchmark::RandVector3()*2-b3Vector3(1,1,1)).normalized();
|
||||
}
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
policy.m_nodes.reserve(cfgLeaves);
|
||||
printf("[14] culling(OCL+qsort): ");
|
||||
@@ -1196,7 +1196,7 @@ void b3DynamicBvh::benchmark()
|
||||
static const b3Scalar offset=0;
|
||||
policy.m_nodes.resize(0);
|
||||
dbvt.collideOCL(dbvt.m_root,&vectors[i],&offset,vectors[i],1,policy,false);
|
||||
policy.m_nodes.quickSort(btDbvtBenchmark::P14::sortfnc);
|
||||
policy.m_nodes.quickSort(b3DbvtBenchmark::P14::sortfnc);
|
||||
}
|
||||
const int time=(int)wallclock.getTimeMilliseconds();
|
||||
const int t=cfgBenchmark14_Iterations;
|
||||
@@ -1207,13 +1207,13 @@ void b3DynamicBvh::benchmark()
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
b3AlignedObjectArray<b3Vector3> vectors;
|
||||
btDbvtBenchmark::P15 policy;
|
||||
b3DbvtBenchmark::P15 policy;
|
||||
vectors.resize(cfgBenchmark15_Iterations);
|
||||
for(int i=0;i<vectors.size();++i)
|
||||
{
|
||||
vectors[i]=(btDbvtBenchmark::RandVector3()*2-b3Vector3(1,1,1)).normalized();
|
||||
vectors[i]=(b3DbvtBenchmark::RandVector3()*2-b3Vector3(1,1,1)).normalized();
|
||||
}
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
policy.m_nodes.reserve(cfgLeaves);
|
||||
printf("[15] culling(KDOP+qsort): ");
|
||||
@@ -1224,7 +1224,7 @@ void b3DynamicBvh::benchmark()
|
||||
policy.m_nodes.resize(0);
|
||||
policy.m_axis=vectors[i];
|
||||
dbvt.collideKDOP(dbvt.m_root,&vectors[i],&offset,1,policy);
|
||||
policy.m_nodes.quickSort(btDbvtBenchmark::P15::sortfnc);
|
||||
policy.m_nodes.quickSort(b3DbvtBenchmark::P15::sortfnc);
|
||||
}
|
||||
const int time=(int)wallclock.getTimeMilliseconds();
|
||||
const int t=cfgBenchmark15_Iterations;
|
||||
@@ -1234,8 +1234,8 @@ void b3DynamicBvh::benchmark()
|
||||
{// Benchmark 16
|
||||
srand(380843);
|
||||
b3DynamicBvh dbvt;
|
||||
b3AlignedObjectArray<btDbvtNode*> batch;
|
||||
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
b3AlignedObjectArray<b3DbvtNode*> batch;
|
||||
b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
|
||||
dbvt.optimizeTopDown();
|
||||
batch.reserve(cfgBenchmark16_BatchCount);
|
||||
printf("[16] insert/remove batch(%u): ",cfgBenchmark16_BatchCount);
|
||||
@@ -1244,7 +1244,7 @@ void b3DynamicBvh::benchmark()
|
||||
{
|
||||
for(int j=0;j<cfgBenchmark16_BatchCount;++j)
|
||||
{
|
||||
batch.push_back(dbvt.insert(btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale),0));
|
||||
batch.push_back(dbvt.insert(b3DbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale),0));
|
||||
}
|
||||
for(int j=0;j<cfgBenchmark16_BatchCount;++j)
|
||||
{
|
||||
@@ -1259,7 +1259,7 @@ void b3DynamicBvh::benchmark()
|
||||
if(cfgBenchmark17_Enable)
|
||||
{// Benchmark 17
|
||||
srand(380843);
|
||||
b3AlignedObjectArray<btDbvtVolume> volumes;
|
||||
b3AlignedObjectArray<b3DbvtVolume> volumes;
|
||||
b3AlignedObjectArray<int> results;
|
||||
b3AlignedObjectArray<int> indices;
|
||||
volumes.resize(cfgLeaves);
|
||||
@@ -1268,13 +1268,13 @@ void b3DynamicBvh::benchmark()
|
||||
for(int i=0;i<cfgLeaves;++i)
|
||||
{
|
||||
indices[i]=i;
|
||||
volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
|
||||
volumes[i]=b3DbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
|
||||
}
|
||||
for(int i=0;i<cfgLeaves;++i)
|
||||
{
|
||||
btSwap(indices[i],indices[rand()%cfgLeaves]);
|
||||
b3Swap(indices[i],indices[rand()%cfgLeaves]);
|
||||
}
|
||||
printf("[17] btDbvtVolume select: ");
|
||||
printf("[17] b3DbvtVolume select: ");
|
||||
wallclock.reset();
|
||||
for(int i=0;i<cfgBenchmark17_Iterations;++i)
|
||||
{
|
||||
|
||||
@@ -14,8 +14,8 @@ subject to the following restrictions:
|
||||
*/
|
||||
///b3DynamicBvh implementation by Nathanael Presson
|
||||
|
||||
#ifndef BT_DYNAMIC_BOUNDING_VOLUME_TREE_H
|
||||
#define BT_DYNAMIC_BOUNDING_VOLUME_TREE_H
|
||||
#ifndef B3_DYNAMIC_BOUNDING_VOLUME_TREE_H
|
||||
#define B3_DYNAMIC_BOUNDING_VOLUME_TREE_H
|
||||
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
@@ -57,7 +57,7 @@ subject to the following restrictions:
|
||||
// Specific methods implementation
|
||||
|
||||
//SSE gives errors on a MSVC 7.1
|
||||
#if defined (BT_USE_SSE) //&& defined (_WIN32)
|
||||
#if defined (B3_USE_SSE) //&& defined (_WIN32)
|
||||
#define DBVT_SELECT_IMPL DBVT_IMPL_SSE
|
||||
#define DBVT_MERGE_IMPL DBVT_IMPL_SSE
|
||||
#define DBVT_INT0_IMPL DBVT_IMPL_SSE
|
||||
@@ -126,40 +126,40 @@ subject to the following restrictions:
|
||||
// Defaults volumes
|
||||
//
|
||||
|
||||
/* btDbvtAabbMm */
|
||||
struct btDbvtAabbMm
|
||||
/* b3DbvtAabbMm */
|
||||
struct b3DbvtAabbMm
|
||||
{
|
||||
DBVT_INLINE b3Vector3 Center() const { return((mi+mx)/2); }
|
||||
DBVT_INLINE b3Vector3 Lengths() const { return(mx-mi); }
|
||||
DBVT_INLINE b3Vector3 Extents() const { return((mx-mi)/2); }
|
||||
DBVT_INLINE const b3Vector3& Mins() const { return(mi); }
|
||||
DBVT_INLINE const b3Vector3& Maxs() const { return(mx); }
|
||||
static inline btDbvtAabbMm FromCE(const b3Vector3& c,const b3Vector3& e);
|
||||
static inline btDbvtAabbMm FromCR(const b3Vector3& c,b3Scalar r);
|
||||
static inline btDbvtAabbMm FromMM(const b3Vector3& mi,const b3Vector3& mx);
|
||||
static inline btDbvtAabbMm FromPoints(const b3Vector3* pts,int n);
|
||||
static inline btDbvtAabbMm FromPoints(const b3Vector3** ppts,int n);
|
||||
static inline b3DbvtAabbMm FromCE(const b3Vector3& c,const b3Vector3& e);
|
||||
static inline b3DbvtAabbMm FromCR(const b3Vector3& c,b3Scalar r);
|
||||
static inline b3DbvtAabbMm FromMM(const b3Vector3& mi,const b3Vector3& mx);
|
||||
static inline b3DbvtAabbMm FromPoints(const b3Vector3* pts,int n);
|
||||
static inline b3DbvtAabbMm FromPoints(const b3Vector3** ppts,int n);
|
||||
DBVT_INLINE void Expand(const b3Vector3& e);
|
||||
DBVT_INLINE void SignedExpand(const b3Vector3& e);
|
||||
DBVT_INLINE bool Contain(const btDbvtAabbMm& a) const;
|
||||
DBVT_INLINE bool Contain(const b3DbvtAabbMm& a) const;
|
||||
DBVT_INLINE int Classify(const b3Vector3& n,b3Scalar o,int s) const;
|
||||
DBVT_INLINE b3Scalar ProjectMinimum(const b3Vector3& v,unsigned signs) const;
|
||||
DBVT_INLINE friend bool Intersect( const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b);
|
||||
DBVT_INLINE friend bool Intersect( const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b);
|
||||
|
||||
DBVT_INLINE friend bool Intersect( const btDbvtAabbMm& a,
|
||||
DBVT_INLINE friend bool Intersect( const b3DbvtAabbMm& a,
|
||||
const b3Vector3& b);
|
||||
|
||||
DBVT_INLINE friend b3Scalar Proximity( const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b);
|
||||
DBVT_INLINE friend int Select( const btDbvtAabbMm& o,
|
||||
const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b);
|
||||
DBVT_INLINE friend void Merge( const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b,
|
||||
btDbvtAabbMm& r);
|
||||
DBVT_INLINE friend bool NotEqual( const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b);
|
||||
DBVT_INLINE friend b3Scalar Proximity( const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b);
|
||||
DBVT_INLINE friend int Select( const b3DbvtAabbMm& o,
|
||||
const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b);
|
||||
DBVT_INLINE friend void Merge( const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b,
|
||||
b3DbvtAabbMm& r);
|
||||
DBVT_INLINE friend bool NotEqual( const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b);
|
||||
|
||||
DBVT_INLINE b3Vector3& tMins() { return(mi); }
|
||||
DBVT_INLINE b3Vector3& tMaxs() { return(mx); }
|
||||
@@ -171,18 +171,18 @@ private:
|
||||
};
|
||||
|
||||
// Types
|
||||
typedef btDbvtAabbMm btDbvtVolume;
|
||||
typedef b3DbvtAabbMm b3DbvtVolume;
|
||||
|
||||
/* btDbvtNode */
|
||||
struct btDbvtNode
|
||||
/* b3DbvtNode */
|
||||
struct b3DbvtNode
|
||||
{
|
||||
btDbvtVolume volume;
|
||||
btDbvtNode* parent;
|
||||
b3DbvtVolume volume;
|
||||
b3DbvtNode* parent;
|
||||
DBVT_INLINE bool isleaf() const { return(childs[1]==0); }
|
||||
DBVT_INLINE bool isinternal() const { return(!isleaf()); }
|
||||
union
|
||||
{
|
||||
btDbvtNode* childs[2];
|
||||
b3DbvtNode* childs[2];
|
||||
void* data;
|
||||
int dataAsInt;
|
||||
};
|
||||
@@ -190,36 +190,36 @@ struct btDbvtNode
|
||||
|
||||
///The b3DynamicBvh class implements a fast dynamic bounding volume tree based on axis aligned bounding boxes (aabb tree).
|
||||
///This b3DynamicBvh is used for soft body collision detection and for the b3DynamicBvhBroadphase. It has a fast insert, remove and update of nodes.
|
||||
///Unlike the btQuantizedBvh, nodes can be dynamically moved around, which allows for change in topology of the underlying data structure.
|
||||
///Unlike the b3QuantizedBvh, nodes can be dynamically moved around, which allows for change in topology of the underlying data structure.
|
||||
struct b3DynamicBvh
|
||||
{
|
||||
/* Stack element */
|
||||
struct sStkNN
|
||||
{
|
||||
const btDbvtNode* a;
|
||||
const btDbvtNode* b;
|
||||
const b3DbvtNode* a;
|
||||
const b3DbvtNode* b;
|
||||
sStkNN() {}
|
||||
sStkNN(const btDbvtNode* na,const btDbvtNode* nb) : a(na),b(nb) {}
|
||||
sStkNN(const b3DbvtNode* na,const b3DbvtNode* nb) : a(na),b(nb) {}
|
||||
};
|
||||
struct sStkNP
|
||||
{
|
||||
const btDbvtNode* node;
|
||||
const b3DbvtNode* node;
|
||||
int mask;
|
||||
sStkNP(const btDbvtNode* n,unsigned m) : node(n),mask(m) {}
|
||||
sStkNP(const b3DbvtNode* n,unsigned m) : node(n),mask(m) {}
|
||||
};
|
||||
struct sStkNPS
|
||||
{
|
||||
const btDbvtNode* node;
|
||||
const b3DbvtNode* node;
|
||||
int mask;
|
||||
b3Scalar value;
|
||||
sStkNPS() {}
|
||||
sStkNPS(const btDbvtNode* n,unsigned m,b3Scalar v) : node(n),mask(m),value(v) {}
|
||||
sStkNPS(const b3DbvtNode* n,unsigned m,b3Scalar v) : node(n),mask(m),value(v) {}
|
||||
};
|
||||
struct sStkCLN
|
||||
{
|
||||
const btDbvtNode* node;
|
||||
btDbvtNode* parent;
|
||||
sStkCLN(const btDbvtNode* n,btDbvtNode* p) : node(n),parent(p) {}
|
||||
const b3DbvtNode* node;
|
||||
b3DbvtNode* parent;
|
||||
sStkCLN(const b3DbvtNode* n,b3DbvtNode* p) : node(n),parent(p) {}
|
||||
};
|
||||
// Policies/Interfaces
|
||||
|
||||
@@ -227,25 +227,25 @@ struct b3DynamicBvh
|
||||
struct ICollide
|
||||
{
|
||||
DBVT_VIRTUAL_DTOR(ICollide)
|
||||
DBVT_VIRTUAL void Process(const btDbvtNode*,const btDbvtNode*) {}
|
||||
DBVT_VIRTUAL void Process(const btDbvtNode*) {}
|
||||
DBVT_VIRTUAL void Process(const btDbvtNode* n,b3Scalar) { Process(n); }
|
||||
DBVT_VIRTUAL bool Descent(const btDbvtNode*) { return(true); }
|
||||
DBVT_VIRTUAL bool AllLeaves(const btDbvtNode*) { return(true); }
|
||||
DBVT_VIRTUAL void Process(const b3DbvtNode*,const b3DbvtNode*) {}
|
||||
DBVT_VIRTUAL void Process(const b3DbvtNode*) {}
|
||||
DBVT_VIRTUAL void Process(const b3DbvtNode* n,b3Scalar) { Process(n); }
|
||||
DBVT_VIRTUAL bool Descent(const b3DbvtNode*) { return(true); }
|
||||
DBVT_VIRTUAL bool AllLeaves(const b3DbvtNode*) { return(true); }
|
||||
};
|
||||
/* IWriter */
|
||||
struct IWriter
|
||||
{
|
||||
virtual ~IWriter() {}
|
||||
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;
|
||||
virtual void Prepare(const b3DbvtNode* root,int numnodes)=0;
|
||||
virtual void WriteNode(const b3DbvtNode*,int index,int parent,int child0,int child1)=0;
|
||||
virtual void WriteLeaf(const b3DbvtNode*,int index,int parent)=0;
|
||||
};
|
||||
/* IClone */
|
||||
struct IClone
|
||||
{
|
||||
virtual ~IClone() {}
|
||||
virtual void CloneLeaf(btDbvtNode*) {}
|
||||
virtual void CloneLeaf(b3DbvtNode*) {}
|
||||
};
|
||||
|
||||
// Constants
|
||||
@@ -255,15 +255,15 @@ struct b3DynamicBvh
|
||||
};
|
||||
|
||||
// Fields
|
||||
btDbvtNode* m_root;
|
||||
btDbvtNode* m_free;
|
||||
b3DbvtNode* m_root;
|
||||
b3DbvtNode* m_free;
|
||||
int m_lkhd;
|
||||
int m_leaves;
|
||||
unsigned m_opath;
|
||||
|
||||
|
||||
b3AlignedObjectArray<sStkNN> m_stkStack;
|
||||
mutable b3AlignedObjectArray<const btDbvtNode*> m_rayTestStack;
|
||||
mutable b3AlignedObjectArray<const b3DbvtNode*> m_rayTestStack;
|
||||
|
||||
|
||||
// Methods
|
||||
@@ -274,18 +274,18 @@ struct b3DynamicBvh
|
||||
void optimizeBottomUp();
|
||||
void optimizeTopDown(int bu_treshold=128);
|
||||
void optimizeIncremental(int passes);
|
||||
btDbvtNode* insert(const btDbvtVolume& box,void* data);
|
||||
void update(btDbvtNode* leaf,int lookahead=-1);
|
||||
void update(btDbvtNode* leaf,btDbvtVolume& volume);
|
||||
bool update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector3& velocity,b3Scalar margin);
|
||||
bool update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector3& velocity);
|
||||
bool update(btDbvtNode* leaf,btDbvtVolume& volume,b3Scalar margin);
|
||||
void remove(btDbvtNode* leaf);
|
||||
b3DbvtNode* insert(const b3DbvtVolume& box,void* data);
|
||||
void update(b3DbvtNode* leaf,int lookahead=-1);
|
||||
void update(b3DbvtNode* leaf,b3DbvtVolume& volume);
|
||||
bool update(b3DbvtNode* leaf,b3DbvtVolume& volume,const b3Vector3& velocity,b3Scalar margin);
|
||||
bool update(b3DbvtNode* leaf,b3DbvtVolume& volume,const b3Vector3& velocity);
|
||||
bool update(b3DbvtNode* leaf,b3DbvtVolume& volume,b3Scalar margin);
|
||||
void remove(b3DbvtNode* leaf);
|
||||
void write(IWriter* iwriter) const;
|
||||
void clone(b3DynamicBvh& dest,IClone* iclone=0) const;
|
||||
static int maxdepth(const btDbvtNode* node);
|
||||
static int countLeaves(const btDbvtNode* node);
|
||||
static void extractLeaves(const btDbvtNode* node,b3AlignedObjectArray<const btDbvtNode*>& leaves);
|
||||
static int maxdepth(const b3DbvtNode* node);
|
||||
static int countLeaves(const b3DbvtNode* node);
|
||||
static void extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray<const b3DbvtNode*>& leaves);
|
||||
#if DBVT_ENABLE_BENCHMARK
|
||||
static void benchmark();
|
||||
#else
|
||||
@@ -293,49 +293,49 @@ struct b3DynamicBvh
|
||||
#endif
|
||||
// DBVT_IPOLICY must support ICollide policy/interface
|
||||
DBVT_PREFIX
|
||||
static void enumNodes( const btDbvtNode* root,
|
||||
static void enumNodes( const b3DbvtNode* root,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void enumLeaves( const btDbvtNode* root,
|
||||
static void enumLeaves( const b3DbvtNode* root,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
void collideTT( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
void collideTT( const b3DbvtNode* root0,
|
||||
const b3DbvtNode* root1,
|
||||
DBVT_IPOLICY);
|
||||
|
||||
DBVT_PREFIX
|
||||
void collideTTpersistentStack( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
void collideTTpersistentStack( const b3DbvtNode* root0,
|
||||
const b3DbvtNode* root1,
|
||||
DBVT_IPOLICY);
|
||||
#if 0
|
||||
DBVT_PREFIX
|
||||
void collideTT( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
void collideTT( const b3DbvtNode* root0,
|
||||
const b3DbvtNode* root1,
|
||||
const b3Transform& xform,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
void collideTT( const btDbvtNode* root0,
|
||||
void collideTT( const b3DbvtNode* root0,
|
||||
const b3Transform& xform0,
|
||||
const btDbvtNode* root1,
|
||||
const b3DbvtNode* root1,
|
||||
const b3Transform& xform1,
|
||||
DBVT_IPOLICY);
|
||||
#endif
|
||||
|
||||
DBVT_PREFIX
|
||||
void collideTV( const btDbvtNode* root,
|
||||
const btDbvtVolume& volume,
|
||||
void collideTV( const b3DbvtNode* root,
|
||||
const b3DbvtVolume& volume,
|
||||
DBVT_IPOLICY) const;
|
||||
///rayTest is a re-entrant ray test, and can be called in parallel as long as the btAlignedAlloc is thread-safe (uses locking etc)
|
||||
///rayTest is a re-entrant ray test, and can be called in parallel as long as the b3AlignedAlloc is thread-safe (uses locking etc)
|
||||
///rayTest is slower than rayTestInternal, because it builds a local stack, using memory allocations, and it recomputes signs/rayDirectionInverses each time
|
||||
DBVT_PREFIX
|
||||
static void rayTest( const btDbvtNode* root,
|
||||
static void rayTest( const b3DbvtNode* root,
|
||||
const b3Vector3& rayFrom,
|
||||
const b3Vector3& rayTo,
|
||||
DBVT_IPOLICY);
|
||||
///rayTestInternal is faster than rayTest, because it uses a persistent stack (to reduce dynamic memory allocations to a minimum) and it uses precomputed signs/rayInverseDirections
|
||||
///rayTestInternal is used by b3DynamicBvhBroadphase to accelerate world ray casts
|
||||
DBVT_PREFIX
|
||||
void rayTestInternal( const btDbvtNode* root,
|
||||
void rayTestInternal( const b3DbvtNode* root,
|
||||
const b3Vector3& rayFrom,
|
||||
const b3Vector3& rayTo,
|
||||
const b3Vector3& rayDirectionInverse,
|
||||
@@ -346,13 +346,13 @@ struct b3DynamicBvh
|
||||
DBVT_IPOLICY) const;
|
||||
|
||||
DBVT_PREFIX
|
||||
static void collideKDOP(const btDbvtNode* root,
|
||||
static void collideKDOP(const b3DbvtNode* root,
|
||||
const b3Vector3* normals,
|
||||
const b3Scalar* offsets,
|
||||
int count,
|
||||
DBVT_IPOLICY);
|
||||
DBVT_PREFIX
|
||||
static void collideOCL( const btDbvtNode* root,
|
||||
static void collideOCL( const b3DbvtNode* root,
|
||||
const b3Vector3* normals,
|
||||
const b3Scalar* offsets,
|
||||
const b3Vector3& sortaxis,
|
||||
@@ -360,7 +360,7 @@ struct b3DynamicBvh
|
||||
DBVT_IPOLICY,
|
||||
bool fullsort=true);
|
||||
DBVT_PREFIX
|
||||
static void collideTU( const btDbvtNode* root,
|
||||
static void collideTU( const b3DbvtNode* root,
|
||||
DBVT_IPOLICY);
|
||||
// Helpers
|
||||
static DBVT_INLINE int nearest(const int* i,const b3DynamicBvh::sStkNPS* a,b3Scalar v,int l,int h)
|
||||
@@ -394,31 +394,31 @@ private:
|
||||
//
|
||||
|
||||
//
|
||||
inline btDbvtAabbMm btDbvtAabbMm::FromCE(const b3Vector3& c,const b3Vector3& e)
|
||||
inline b3DbvtAabbMm b3DbvtAabbMm::FromCE(const b3Vector3& c,const b3Vector3& e)
|
||||
{
|
||||
btDbvtAabbMm box;
|
||||
b3DbvtAabbMm box;
|
||||
box.mi=c-e;box.mx=c+e;
|
||||
return(box);
|
||||
}
|
||||
|
||||
//
|
||||
inline btDbvtAabbMm btDbvtAabbMm::FromCR(const b3Vector3& c,b3Scalar r)
|
||||
inline b3DbvtAabbMm b3DbvtAabbMm::FromCR(const b3Vector3& c,b3Scalar r)
|
||||
{
|
||||
return(FromCE(c,b3Vector3(r,r,r)));
|
||||
}
|
||||
|
||||
//
|
||||
inline btDbvtAabbMm btDbvtAabbMm::FromMM(const b3Vector3& mi,const b3Vector3& mx)
|
||||
inline b3DbvtAabbMm b3DbvtAabbMm::FromMM(const b3Vector3& mi,const b3Vector3& mx)
|
||||
{
|
||||
btDbvtAabbMm box;
|
||||
b3DbvtAabbMm box;
|
||||
box.mi=mi;box.mx=mx;
|
||||
return(box);
|
||||
}
|
||||
|
||||
//
|
||||
inline btDbvtAabbMm btDbvtAabbMm::FromPoints(const b3Vector3* pts,int n)
|
||||
inline b3DbvtAabbMm b3DbvtAabbMm::FromPoints(const b3Vector3* pts,int n)
|
||||
{
|
||||
btDbvtAabbMm box;
|
||||
b3DbvtAabbMm box;
|
||||
box.mi=box.mx=pts[0];
|
||||
for(int i=1;i<n;++i)
|
||||
{
|
||||
@@ -429,9 +429,9 @@ inline btDbvtAabbMm btDbvtAabbMm::FromPoints(const b3Vector3* pts,int n)
|
||||
}
|
||||
|
||||
//
|
||||
inline btDbvtAabbMm btDbvtAabbMm::FromPoints(const b3Vector3** ppts,int n)
|
||||
inline b3DbvtAabbMm b3DbvtAabbMm::FromPoints(const b3Vector3** ppts,int n)
|
||||
{
|
||||
btDbvtAabbMm box;
|
||||
b3DbvtAabbMm box;
|
||||
box.mi=box.mx=*ppts[0];
|
||||
for(int i=1;i<n;++i)
|
||||
{
|
||||
@@ -442,13 +442,13 @@ inline btDbvtAabbMm btDbvtAabbMm::FromPoints(const b3Vector3** ppts,int n)
|
||||
}
|
||||
|
||||
//
|
||||
DBVT_INLINE void btDbvtAabbMm::Expand(const b3Vector3& e)
|
||||
DBVT_INLINE void b3DbvtAabbMm::Expand(const b3Vector3& e)
|
||||
{
|
||||
mi-=e;mx+=e;
|
||||
}
|
||||
|
||||
//
|
||||
DBVT_INLINE void btDbvtAabbMm::SignedExpand(const b3Vector3& e)
|
||||
DBVT_INLINE void b3DbvtAabbMm::SignedExpand(const b3Vector3& e)
|
||||
{
|
||||
if(e.x>0) mx.setX(mx.x+e[0]); else mi.setX(mi.x+e[0]);
|
||||
if(e.y>0) mx.setY(mx.y+e[1]); else mi.setY(mi.y+e[1]);
|
||||
@@ -456,7 +456,7 @@ DBVT_INLINE void btDbvtAabbMm::SignedExpand(const b3Vector3& e)
|
||||
}
|
||||
|
||||
//
|
||||
DBVT_INLINE bool btDbvtAabbMm::Contain(const btDbvtAabbMm& a) const
|
||||
DBVT_INLINE bool b3DbvtAabbMm::Contain(const b3DbvtAabbMm& a) const
|
||||
{
|
||||
return( (mi.x<=a.mi.x)&&
|
||||
(mi.y<=a.mi.y)&&
|
||||
@@ -467,7 +467,7 @@ DBVT_INLINE bool btDbvtAabbMm::Contain(const btDbvtAabbMm& a) const
|
||||
}
|
||||
|
||||
//
|
||||
DBVT_INLINE int btDbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) const
|
||||
DBVT_INLINE int b3DbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) const
|
||||
{
|
||||
b3Vector3 pi,px;
|
||||
switch(s)
|
||||
@@ -489,23 +489,23 @@ DBVT_INLINE int btDbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) con
|
||||
case (1+2+4): px=b3Vector3(mx.x,mx.y,mx.z);
|
||||
pi=b3Vector3(mi.x,mi.y,mi.z);break;
|
||||
}
|
||||
if((btDot(n,px)+o)<0) return(-1);
|
||||
if((btDot(n,pi)+o)>=0) return(+1);
|
||||
if((b3Dot(n,px)+o)<0) return(-1);
|
||||
if((b3Dot(n,pi)+o)>=0) return(+1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
DBVT_INLINE b3Scalar btDbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned signs) const
|
||||
DBVT_INLINE b3Scalar b3DbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned signs) const
|
||||
{
|
||||
const b3Vector3* b[]={&mx,&mi};
|
||||
const b3Vector3 p( b[(signs>>0)&1]->x,
|
||||
b[(signs>>1)&1]->y,
|
||||
b[(signs>>2)&1]->z);
|
||||
return(btDot(p,v));
|
||||
return(b3Dot(p,v));
|
||||
}
|
||||
|
||||
//
|
||||
DBVT_INLINE void btDbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const
|
||||
DBVT_INLINE void b3DbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const
|
||||
{
|
||||
for(int i=0;i<3;++i)
|
||||
{
|
||||
@@ -517,8 +517,8 @@ DBVT_INLINE void btDbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scala
|
||||
}
|
||||
|
||||
//
|
||||
DBVT_INLINE bool Intersect( const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b)
|
||||
DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b)
|
||||
{
|
||||
#if DBVT_INT0_IMPL == DBVT_IMPL_SSE
|
||||
const __m128 rt(_mm_or_ps( _mm_cmplt_ps(_mm_load_ps(b.mx),_mm_load_ps(a.mi)),
|
||||
@@ -542,7 +542,7 @@ DBVT_INLINE bool Intersect( const btDbvtAabbMm& a,
|
||||
|
||||
|
||||
//
|
||||
DBVT_INLINE bool Intersect( const btDbvtAabbMm& a,
|
||||
DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a,
|
||||
const b3Vector3& b)
|
||||
{
|
||||
return( (b.x>=a.mi.x)&&
|
||||
@@ -561,19 +561,19 @@ DBVT_INLINE bool Intersect( const btDbvtAabbMm& a,
|
||||
|
||||
|
||||
//
|
||||
DBVT_INLINE b3Scalar Proximity( const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b)
|
||||
DBVT_INLINE b3Scalar Proximity( const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b)
|
||||
{
|
||||
const b3Vector3 d=(a.mi+a.mx)-(b.mi+b.mx);
|
||||
return(btFabs(d.x)+btFabs(d.y)+btFabs(d.z));
|
||||
return(b3Fabs(d.x)+b3Fabs(d.y)+b3Fabs(d.z));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
DBVT_INLINE int Select( const btDbvtAabbMm& o,
|
||||
const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b)
|
||||
DBVT_INLINE int Select( const b3DbvtAabbMm& o,
|
||||
const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b)
|
||||
{
|
||||
#if DBVT_SELECT_IMPL == DBVT_IMPL_SSE
|
||||
|
||||
@@ -585,7 +585,7 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o,
|
||||
///@todo: the intrinsic version is 11% slower
|
||||
#if DBVT_USE_INTRINSIC_SSE
|
||||
|
||||
union btSSEUnion ///NOTE: if we use more intrinsics, move btSSEUnion into the LinearMath directory
|
||||
union b3SSEUnion ///NOTE: if we use more intrinsics, move b3SSEUnion into the LinearMath directory
|
||||
{
|
||||
__m128 ssereg;
|
||||
float floats[4];
|
||||
@@ -609,7 +609,7 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o,
|
||||
bmi=_mm_add_ps(bmi,t1);
|
||||
bmi=_mm_add_ss(bmi,_mm_shuffle_ps(bmi,bmi,1));
|
||||
|
||||
btSSEUnion tmp;
|
||||
b3SSEUnion tmp;
|
||||
tmp.ssereg = _mm_cmple_ss(bmi,ami);
|
||||
return tmp.ints[0]&1;
|
||||
|
||||
@@ -650,9 +650,9 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o,
|
||||
}
|
||||
|
||||
//
|
||||
DBVT_INLINE void Merge( const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b,
|
||||
btDbvtAabbMm& r)
|
||||
DBVT_INLINE void Merge( const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b,
|
||||
b3DbvtAabbMm& r)
|
||||
{
|
||||
#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE
|
||||
__m128 ami(_mm_load_ps(a.mi));
|
||||
@@ -673,8 +673,8 @@ DBVT_INLINE void Merge( const btDbvtAabbMm& a,
|
||||
}
|
||||
|
||||
//
|
||||
DBVT_INLINE bool NotEqual( const btDbvtAabbMm& a,
|
||||
const btDbvtAabbMm& b)
|
||||
DBVT_INLINE bool NotEqual( const b3DbvtAabbMm& a,
|
||||
const b3DbvtAabbMm& b)
|
||||
{
|
||||
return( (a.mi.x!=b.mi.x)||
|
||||
(a.mi.y!=b.mi.y)||
|
||||
@@ -690,7 +690,7 @@ DBVT_INLINE bool NotEqual( const btDbvtAabbMm& a,
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::enumNodes( const btDbvtNode* root,
|
||||
inline void b3DynamicBvh::enumNodes( const b3DbvtNode* root,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
@@ -704,7 +704,7 @@ inline void b3DynamicBvh::enumNodes( const btDbvtNode* root,
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::enumLeaves( const btDbvtNode* root,
|
||||
inline void b3DynamicBvh::enumLeaves( const b3DbvtNode* root,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
@@ -721,8 +721,8 @@ inline void b3DynamicBvh::enumLeaves( const btDbvtNode* root,
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::collideTT( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
|
||||
const b3DbvtNode* root1,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
@@ -786,8 +786,8 @@ inline void b3DynamicBvh::collideTT( const btDbvtNode* root0,
|
||||
|
||||
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::collideTTpersistentStack( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0,
|
||||
const b3DbvtNode* root1,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
@@ -851,8 +851,8 @@ inline void b3DynamicBvh::collideTTpersistentStack( const btDbvtNode* root0,
|
||||
#if 0
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::collideTT( const btDbvtNode* root0,
|
||||
const btDbvtNode* root1,
|
||||
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
|
||||
const b3DbvtNode* root1,
|
||||
const b3Transform& xform,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
@@ -906,9 +906,9 @@ inline void b3DynamicBvh::collideTT( const btDbvtNode* root0,
|
||||
}
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::collideTT( const btDbvtNode* root0,
|
||||
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
|
||||
const b3Transform& xform0,
|
||||
const btDbvtNode* root1,
|
||||
const b3DbvtNode* root1,
|
||||
const b3Transform& xform1,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
@@ -919,20 +919,20 @@ inline void b3DynamicBvh::collideTT( const btDbvtNode* root0,
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::collideTV( const btDbvtNode* root,
|
||||
const btDbvtVolume& vol,
|
||||
inline void b3DynamicBvh::collideTV( const b3DbvtNode* root,
|
||||
const b3DbvtVolume& vol,
|
||||
DBVT_IPOLICY) const
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
if(root)
|
||||
{
|
||||
ATTRIBUTE_ALIGNED16(btDbvtVolume) volume(vol);
|
||||
b3AlignedObjectArray<const btDbvtNode*> stack;
|
||||
ATTRIBUTE_ALIGNED16(b3DbvtVolume) volume(vol);
|
||||
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
||||
stack.resize(0);
|
||||
stack.reserve(SIMPLE_STACKSIZE);
|
||||
stack.push_back(root);
|
||||
do {
|
||||
const btDbvtNode* n=stack[stack.size()-1];
|
||||
const b3DbvtNode* n=stack[stack.size()-1];
|
||||
stack.pop_back();
|
||||
if(Intersect(n->volume,volume))
|
||||
{
|
||||
@@ -951,7 +951,7 @@ inline void b3DynamicBvh::collideTV( const btDbvtNode* root,
|
||||
}
|
||||
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::rayTestInternal( const btDbvtNode* root,
|
||||
inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root,
|
||||
const b3Vector3& rayFrom,
|
||||
const b3Vector3& rayTo,
|
||||
const b3Vector3& rayDirectionInverse,
|
||||
@@ -969,18 +969,18 @@ inline void b3DynamicBvh::rayTestInternal( const btDbvtNode* root,
|
||||
|
||||
int depth=1;
|
||||
int treshold=DOUBLE_STACKSIZE-2;
|
||||
b3AlignedObjectArray<const btDbvtNode*>& stack = m_rayTestStack;
|
||||
b3AlignedObjectArray<const b3DbvtNode*>& stack = m_rayTestStack;
|
||||
stack.resize(DOUBLE_STACKSIZE);
|
||||
stack[0]=root;
|
||||
b3Vector3 bounds[2];
|
||||
do
|
||||
{
|
||||
const btDbvtNode* node=stack[--depth];
|
||||
const b3DbvtNode* node=stack[--depth];
|
||||
bounds[0] = node->volume.Mins()-aabbMax;
|
||||
bounds[1] = node->volume.Maxs()-aabbMin;
|
||||
b3Scalar tmin=1.f,lambda_min=0.f;
|
||||
unsigned int result1=false;
|
||||
result1 = btRayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max);
|
||||
result1 = b3RayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max);
|
||||
if(result1)
|
||||
{
|
||||
if(node->isinternal())
|
||||
@@ -1004,7 +1004,7 @@ inline void b3DynamicBvh::rayTestInternal( const btDbvtNode* root,
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::rayTest( const btDbvtNode* root,
|
||||
inline void b3DynamicBvh::rayTest( const b3DbvtNode* root,
|
||||
const b3Vector3& rayFrom,
|
||||
const b3Vector3& rayTo,
|
||||
DBVT_IPOLICY)
|
||||
@@ -1015,18 +1015,18 @@ inline void b3DynamicBvh::rayTest( const btDbvtNode* root,
|
||||
b3Vector3 rayDir = (rayTo-rayFrom);
|
||||
rayDir.normalize ();
|
||||
|
||||
///what about division by zero? --> just set rayDirection[i] to INF/BT_LARGE_FLOAT
|
||||
///what about division by zero? --> just set rayDirection[i] to INF/B3_LARGE_FLOAT
|
||||
b3Vector3 rayDirectionInverse;
|
||||
rayDirectionInverse[0] = rayDir[0] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[0];
|
||||
rayDirectionInverse[1] = rayDir[1] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[1];
|
||||
rayDirectionInverse[2] = rayDir[2] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[2];
|
||||
rayDirectionInverse[0] = rayDir[0] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[0];
|
||||
rayDirectionInverse[1] = rayDir[1] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[1];
|
||||
rayDirectionInverse[2] = rayDir[2] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[2];
|
||||
unsigned int signs[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0};
|
||||
|
||||
b3Scalar lambda_max = rayDir.dot(rayTo-rayFrom);
|
||||
|
||||
b3Vector3 resultNormal;
|
||||
|
||||
b3AlignedObjectArray<const btDbvtNode*> stack;
|
||||
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
||||
|
||||
int depth=1;
|
||||
int treshold=DOUBLE_STACKSIZE-2;
|
||||
@@ -1035,18 +1035,18 @@ inline void b3DynamicBvh::rayTest( const btDbvtNode* root,
|
||||
stack[0]=root;
|
||||
b3Vector3 bounds[2];
|
||||
do {
|
||||
const btDbvtNode* node=stack[--depth];
|
||||
const b3DbvtNode* node=stack[--depth];
|
||||
|
||||
bounds[0] = node->volume.Mins();
|
||||
bounds[1] = node->volume.Maxs();
|
||||
|
||||
b3Scalar tmin=1.f,lambda_min=0.f;
|
||||
unsigned int result1 = btRayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max);
|
||||
unsigned int result1 = b3RayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max);
|
||||
|
||||
#ifdef COMPARE_BTRAY_AABB2
|
||||
b3Scalar param=1.f;
|
||||
bool result2 = btRayAabb(rayFrom,rayTo,node->volume.Mins(),node->volume.Maxs(),param,resultNormal);
|
||||
btAssert(result1 == result2);
|
||||
bool result2 = b3RayAabb(rayFrom,rayTo,node->volume.Mins(),node->volume.Maxs(),param,resultNormal);
|
||||
b3Assert(result1 == result2);
|
||||
#endif //TEST_BTRAY_AABB2
|
||||
|
||||
if(result1)
|
||||
@@ -1073,7 +1073,7 @@ inline void b3DynamicBvh::rayTest( const btDbvtNode* root,
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::collideKDOP(const btDbvtNode* root,
|
||||
inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root,
|
||||
const b3Vector3* normals,
|
||||
const b3Scalar* offsets,
|
||||
int count,
|
||||
@@ -1085,7 +1085,7 @@ inline void b3DynamicBvh::collideKDOP(const btDbvtNode* root,
|
||||
const int inside=(1<<count)-1;
|
||||
b3AlignedObjectArray<sStkNP> stack;
|
||||
int signs[sizeof(unsigned)*8];
|
||||
btAssert(count<int (sizeof(signs)/sizeof(signs[0])));
|
||||
b3Assert(count<int (sizeof(signs)/sizeof(signs[0])));
|
||||
for(int i=0;i<count;++i)
|
||||
{
|
||||
signs[i]= ((normals[i].x>=0)?1:0)+
|
||||
@@ -1128,7 +1128,7 @@ inline void b3DynamicBvh::collideKDOP(const btDbvtNode* root,
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::collideOCL( const btDbvtNode* root,
|
||||
inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root,
|
||||
const b3Vector3* normals,
|
||||
const b3Scalar* offsets,
|
||||
const b3Vector3& sortaxis,
|
||||
@@ -1147,7 +1147,7 @@ inline void b3DynamicBvh::collideOCL( const btDbvtNode* root,
|
||||
b3AlignedObjectArray<int> ifree;
|
||||
b3AlignedObjectArray<int> stack;
|
||||
int signs[sizeof(unsigned)*8];
|
||||
btAssert(count<int (sizeof(signs)/sizeof(signs[0])));
|
||||
b3Assert(count<int (sizeof(signs)/sizeof(signs[0])));
|
||||
for(int i=0;i<count;++i)
|
||||
{
|
||||
signs[i]= ((normals[i].x>=0)?1:0)+
|
||||
@@ -1183,7 +1183,7 @@ inline void b3DynamicBvh::collideOCL( const btDbvtNode* root,
|
||||
{
|
||||
if(se.node->isinternal())
|
||||
{
|
||||
const btDbvtNode* pns[]={ se.node->childs[0],se.node->childs[1]};
|
||||
const b3DbvtNode* 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;
|
||||
@@ -1226,17 +1226,17 @@ inline void b3DynamicBvh::collideOCL( const btDbvtNode* root,
|
||||
|
||||
//
|
||||
DBVT_PREFIX
|
||||
inline void b3DynamicBvh::collideTU( const btDbvtNode* root,
|
||||
inline void b3DynamicBvh::collideTU( const b3DbvtNode* root,
|
||||
DBVT_IPOLICY)
|
||||
{
|
||||
DBVT_CHECKTYPE
|
||||
if(root)
|
||||
{
|
||||
b3AlignedObjectArray<const btDbvtNode*> stack;
|
||||
b3AlignedObjectArray<const b3DbvtNode*> stack;
|
||||
stack.reserve(SIMPLE_STACKSIZE);
|
||||
stack.push_back(root);
|
||||
do {
|
||||
const btDbvtNode* n=stack[stack.size()-1];
|
||||
const b3DbvtNode* n=stack[stack.size()-1];
|
||||
stack.pop_back();
|
||||
if(policy.Descent(n))
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ subject to the following restrictions:
|
||||
#if DBVT_BP_PROFILE
|
||||
struct ProfileScope
|
||||
{
|
||||
__forceinline ProfileScope(btClock& clock,unsigned long& value) :
|
||||
__forceinline ProfileScope(b3Clock& clock,unsigned long& value) :
|
||||
m_clock(&clock),m_value(&value),m_base(clock.getTimeMicroseconds())
|
||||
{
|
||||
}
|
||||
@@ -37,7 +37,7 @@ struct ProfileScope
|
||||
{
|
||||
(*m_value)+=m_clock->getTimeMicroseconds()-m_base;
|
||||
}
|
||||
btClock* m_clock;
|
||||
b3Clock* m_clock;
|
||||
unsigned long* m_value;
|
||||
unsigned long m_base;
|
||||
};
|
||||
@@ -90,26 +90,26 @@ static inline void clear(T& value)
|
||||
//
|
||||
|
||||
/* Tree collider */
|
||||
struct btDbvtTreeCollider : b3DynamicBvh::ICollide
|
||||
struct b3DbvtTreeCollider : b3DynamicBvh::ICollide
|
||||
{
|
||||
b3DynamicBvhBroadphase* pbp;
|
||||
btDbvtProxy* proxy;
|
||||
btDbvtTreeCollider(b3DynamicBvhBroadphase* p) : pbp(p) {}
|
||||
void Process(const btDbvtNode* na,const btDbvtNode* nb)
|
||||
b3DbvtProxy* proxy;
|
||||
b3DbvtTreeCollider(b3DynamicBvhBroadphase* p) : pbp(p) {}
|
||||
void Process(const b3DbvtNode* na,const b3DbvtNode* nb)
|
||||
{
|
||||
if(na!=nb)
|
||||
{
|
||||
btDbvtProxy* pa=(btDbvtProxy*)na->data;
|
||||
btDbvtProxy* pb=(btDbvtProxy*)nb->data;
|
||||
b3DbvtProxy* pa=(b3DbvtProxy*)na->data;
|
||||
b3DbvtProxy* pb=(b3DbvtProxy*)nb->data;
|
||||
#if DBVT_BP_SORTPAIRS
|
||||
if(pa->m_uniqueId>pb->m_uniqueId)
|
||||
btSwap(pa,pb);
|
||||
b3Swap(pa,pb);
|
||||
#endif
|
||||
pbp->m_paircache->addOverlappingPair(pa->getUid(),pb->getUid());
|
||||
++pbp->m_newpairs;
|
||||
}
|
||||
}
|
||||
void Process(const btDbvtNode* n)
|
||||
void Process(const b3DbvtNode* n)
|
||||
{
|
||||
Process(n,proxy->leaf);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ b3DynamicBvhBroadphase::b3DynamicBvhBroadphase(int proxyCapacity, b3OverlappingP
|
||||
m_updates_call = 0;
|
||||
m_updates_done = 0;
|
||||
m_updates_ratio = 0;
|
||||
m_paircache = paircache? paircache : new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
|
||||
m_paircache = paircache? paircache : new(b3AlignedAlloc(sizeof(b3HashedOverlappingPairCache),16)) b3HashedOverlappingPairCache();
|
||||
|
||||
m_pid = 0;
|
||||
m_cid = 0;
|
||||
@@ -155,33 +155,33 @@ b3DynamicBvhBroadphase::~b3DynamicBvhBroadphase()
|
||||
if(m_releasepaircache)
|
||||
{
|
||||
m_paircache->~b3OverlappingPairCache();
|
||||
btAlignedFree(m_paircache);
|
||||
b3AlignedFree(m_paircache);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
btBroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabbMin,
|
||||
b3BroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabbMin,
|
||||
const b3Vector3& aabbMax,
|
||||
int objectId,
|
||||
void* userPtr,
|
||||
short int collisionFilterGroup,
|
||||
short int collisionFilterMask)
|
||||
{
|
||||
btDbvtProxy* mem = &m_proxies[objectId];
|
||||
btDbvtProxy* proxy=new(mem) btDbvtProxy( aabbMin,aabbMax,userPtr,
|
||||
b3DbvtProxy* mem = &m_proxies[objectId];
|
||||
b3DbvtProxy* proxy=new(mem) b3DbvtProxy( aabbMin,aabbMax,userPtr,
|
||||
collisionFilterGroup,
|
||||
collisionFilterMask);
|
||||
|
||||
btDbvtAabbMm aabb = btDbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
b3DbvtAabbMm aabb = b3DbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
|
||||
//bproxy->aabb = btDbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
//bproxy->aabb = b3DbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
proxy->stage = m_stageCurrent;
|
||||
proxy->m_uniqueId = objectId;
|
||||
proxy->leaf = m_sets[0].insert(aabb,proxy);
|
||||
listappend(proxy,m_stageRoots[m_stageCurrent]);
|
||||
if(!m_deferedcollide)
|
||||
{
|
||||
btDbvtTreeCollider collider(this);
|
||||
b3DbvtTreeCollider collider(this);
|
||||
collider.proxy=proxy;
|
||||
m_sets[0].collideTV(m_sets[0].m_root,aabb,collider);
|
||||
m_sets[1].collideTV(m_sets[1].m_root,aabb,collider);
|
||||
@@ -190,10 +190,10 @@ btBroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabb
|
||||
}
|
||||
|
||||
//
|
||||
void b3DynamicBvhBroadphase::destroyProxy( btBroadphaseProxy* absproxy,
|
||||
btDispatcher* dispatcher)
|
||||
void b3DynamicBvhBroadphase::destroyProxy( b3BroadphaseProxy* absproxy,
|
||||
b3Dispatcher* dispatcher)
|
||||
{
|
||||
btDbvtProxy* proxy=(btDbvtProxy*)absproxy;
|
||||
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
|
||||
if(proxy->stage==STAGECOUNT)
|
||||
m_sets[1].remove(proxy->leaf);
|
||||
else
|
||||
@@ -204,28 +204,28 @@ void b3DynamicBvhBroadphase::destroyProxy( btBroadphaseProxy* absproxy,
|
||||
m_needcleanup=true;
|
||||
}
|
||||
|
||||
void b3DynamicBvhBroadphase::getAabb(btBroadphaseProxy* absproxy,b3Vector3& aabbMin, b3Vector3& aabbMax ) const
|
||||
void b3DynamicBvhBroadphase::getAabb(b3BroadphaseProxy* absproxy,b3Vector3& aabbMin, b3Vector3& aabbMax ) const
|
||||
{
|
||||
btDbvtProxy* proxy=(btDbvtProxy*)absproxy;
|
||||
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
|
||||
aabbMin = proxy->m_aabbMin;
|
||||
aabbMax = proxy->m_aabbMax;
|
||||
}
|
||||
|
||||
struct BroadphaseRayTester : b3DynamicBvh::ICollide
|
||||
{
|
||||
btBroadphaseRayCallback& m_rayCallback;
|
||||
BroadphaseRayTester(btBroadphaseRayCallback& orgCallback)
|
||||
b3BroadphaseRayCallback& m_rayCallback;
|
||||
BroadphaseRayTester(b3BroadphaseRayCallback& orgCallback)
|
||||
:m_rayCallback(orgCallback)
|
||||
{
|
||||
}
|
||||
void Process(const btDbvtNode* leaf)
|
||||
void Process(const b3DbvtNode* leaf)
|
||||
{
|
||||
btDbvtProxy* proxy=(btDbvtProxy*)leaf->data;
|
||||
b3DbvtProxy* proxy=(b3DbvtProxy*)leaf->data;
|
||||
m_rayCallback.process(proxy);
|
||||
}
|
||||
};
|
||||
|
||||
void b3DynamicBvhBroadphase::rayTest(const b3Vector3& rayFrom,const b3Vector3& rayTo, btBroadphaseRayCallback& rayCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax)
|
||||
void b3DynamicBvhBroadphase::rayTest(const b3Vector3& rayFrom,const b3Vector3& rayTo, b3BroadphaseRayCallback& rayCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax)
|
||||
{
|
||||
BroadphaseRayTester callback(rayCallback);
|
||||
|
||||
@@ -254,23 +254,23 @@ void b3DynamicBvhBroadphase::rayTest(const b3Vector3& rayFrom,const b3Vector3& r
|
||||
|
||||
struct BroadphaseAabbTester : b3DynamicBvh::ICollide
|
||||
{
|
||||
btBroadphaseAabbCallback& m_aabbCallback;
|
||||
BroadphaseAabbTester(btBroadphaseAabbCallback& orgCallback)
|
||||
b3BroadphaseAabbCallback& m_aabbCallback;
|
||||
BroadphaseAabbTester(b3BroadphaseAabbCallback& orgCallback)
|
||||
:m_aabbCallback(orgCallback)
|
||||
{
|
||||
}
|
||||
void Process(const btDbvtNode* leaf)
|
||||
void Process(const b3DbvtNode* leaf)
|
||||
{
|
||||
btDbvtProxy* proxy=(btDbvtProxy*)leaf->data;
|
||||
b3DbvtProxy* proxy=(b3DbvtProxy*)leaf->data;
|
||||
m_aabbCallback.process(proxy);
|
||||
}
|
||||
};
|
||||
|
||||
void b3DynamicBvhBroadphase::aabbTest(const b3Vector3& aabbMin,const b3Vector3& aabbMax,btBroadphaseAabbCallback& aabbCallback)
|
||||
void b3DynamicBvhBroadphase::aabbTest(const b3Vector3& aabbMin,const b3Vector3& aabbMax,b3BroadphaseAabbCallback& aabbCallback)
|
||||
{
|
||||
BroadphaseAabbTester callback(aabbCallback);
|
||||
|
||||
const ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
const ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds=b3DbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
//process all children, that overlap with the given AABB bounds
|
||||
m_sets[0].collideTV(m_sets[0].m_root,bounds,callback);
|
||||
m_sets[1].collideTV(m_sets[1].m_root,bounds,callback);
|
||||
@@ -280,13 +280,13 @@ void b3DynamicBvhBroadphase::aabbTest(const b3Vector3& aabbMin,const b3Vector3&
|
||||
|
||||
|
||||
//
|
||||
void b3DynamicBvhBroadphase::setAabb( btBroadphaseProxy* absproxy,
|
||||
void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy,
|
||||
const b3Vector3& aabbMin,
|
||||
const b3Vector3& aabbMax,
|
||||
btDispatcher* /*dispatcher*/)
|
||||
b3Dispatcher* /*dispatcher*/)
|
||||
{
|
||||
btDbvtProxy* proxy=(btDbvtProxy*)absproxy;
|
||||
ATTRIBUTE_ALIGNED16(btDbvtVolume) aabb=btDbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
|
||||
ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
#if DBVT_BP_PREVENTFALSEUPDATE
|
||||
if(NotEqual(aabb,proxy->leaf->volume))
|
||||
#endif
|
||||
@@ -338,7 +338,7 @@ void b3DynamicBvhBroadphase::setAabb( btBroadphaseProxy* absproxy,
|
||||
m_needcleanup=true;
|
||||
if(!m_deferedcollide)
|
||||
{
|
||||
btDbvtTreeCollider collider(this);
|
||||
b3DbvtTreeCollider collider(this);
|
||||
m_sets[1].collideTTpersistentStack(m_sets[1].m_root,proxy->leaf,collider);
|
||||
m_sets[0].collideTTpersistentStack(m_sets[0].m_root,proxy->leaf,collider);
|
||||
}
|
||||
@@ -348,13 +348,13 @@ void b3DynamicBvhBroadphase::setAabb( btBroadphaseProxy* absproxy,
|
||||
|
||||
|
||||
//
|
||||
void b3DynamicBvhBroadphase::setAabbForceUpdate( btBroadphaseProxy* absproxy,
|
||||
void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* absproxy,
|
||||
const b3Vector3& aabbMin,
|
||||
const b3Vector3& aabbMax,
|
||||
btDispatcher* /*dispatcher*/)
|
||||
b3Dispatcher* /*dispatcher*/)
|
||||
{
|
||||
btDbvtProxy* proxy=(btDbvtProxy*)absproxy;
|
||||
ATTRIBUTE_ALIGNED16(btDbvtVolume) aabb=btDbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
|
||||
ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
|
||||
bool docollide=false;
|
||||
if(proxy->stage==STAGECOUNT)
|
||||
{/* fixed -> dynamic set */
|
||||
@@ -380,7 +380,7 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( btBroadphaseProxy* abspr
|
||||
m_needcleanup=true;
|
||||
if(!m_deferedcollide)
|
||||
{
|
||||
btDbvtTreeCollider collider(this);
|
||||
b3DbvtTreeCollider collider(this);
|
||||
m_sets[1].collideTTpersistentStack(m_sets[1].m_root,proxy->leaf,collider);
|
||||
m_sets[0].collideTTpersistentStack(m_sets[0].m_root,proxy->leaf,collider);
|
||||
}
|
||||
@@ -388,7 +388,7 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( btBroadphaseProxy* abspr
|
||||
}
|
||||
|
||||
//
|
||||
void b3DynamicBvhBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
void b3DynamicBvhBroadphase::calculateOverlappingPairs(b3Dispatcher* dispatcher)
|
||||
{
|
||||
collide(dispatcher);
|
||||
#if DBVT_BP_PROFILE
|
||||
@@ -415,30 +415,30 @@ void b3DynamicBvhBroadphase::calculateOverlappingPairs(btDispatcher* dispa
|
||||
|
||||
}
|
||||
|
||||
void b3DynamicBvhBroadphase::performDeferredRemoval(btDispatcher* dispatcher)
|
||||
void b3DynamicBvhBroadphase::performDeferredRemoval(b3Dispatcher* dispatcher)
|
||||
{
|
||||
|
||||
if (m_paircache->hasDeferredRemoval())
|
||||
{
|
||||
|
||||
btBroadphasePairArray& overlappingPairArray = m_paircache->getOverlappingPairArray();
|
||||
b3BroadphasePairArray& overlappingPairArray = m_paircache->getOverlappingPairArray();
|
||||
|
||||
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
|
||||
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
|
||||
overlappingPairArray.quickSort(b3BroadphasePairSortPredicate());
|
||||
|
||||
int invalidPair = 0;
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
btBroadphasePair previousPair(-1,-1);
|
||||
b3BroadphasePair previousPair(-1,-1);
|
||||
|
||||
|
||||
|
||||
for (i=0;i<overlappingPairArray.size();i++)
|
||||
{
|
||||
|
||||
btBroadphasePair& pair = overlappingPairArray[i];
|
||||
b3BroadphasePair& pair = overlappingPairArray[i];
|
||||
|
||||
bool isDuplicate = (pair == previousPair);
|
||||
|
||||
@@ -449,8 +449,8 @@ void b3DynamicBvhBroadphase::performDeferredRemoval(btDispatcher* dispatcher)
|
||||
if (!isDuplicate)
|
||||
{
|
||||
//important to perform AABB check that is consistent with the broadphase
|
||||
btDbvtProxy* pa=&m_proxies[pair.x];
|
||||
btDbvtProxy* pb=&m_proxies[pair.y];
|
||||
b3DbvtProxy* pa=&m_proxies[pair.x];
|
||||
b3DbvtProxy* pb=&m_proxies[pair.y];
|
||||
bool hasOverlap = Intersect(pa->leaf->volume,pb->leaf->volume);
|
||||
|
||||
if (hasOverlap)
|
||||
@@ -479,13 +479,13 @@ void b3DynamicBvhBroadphase::performDeferredRemoval(btDispatcher* dispatcher)
|
||||
}
|
||||
|
||||
//perform a sort, to sort 'invalid' pairs to the end
|
||||
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
|
||||
overlappingPairArray.quickSort(b3BroadphasePairSortPredicate());
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - invalidPair);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher)
|
||||
void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher)
|
||||
{
|
||||
/*printf("---------------------------------------------------------\n");
|
||||
printf("m_sets[0].m_leaves=%d\n",m_sets[0].m_leaves);
|
||||
@@ -511,16 +511,16 @@ void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher)
|
||||
{
|
||||
const int count=1+(m_sets[1].m_leaves*m_fupdates)/100;
|
||||
m_sets[1].optimizeIncremental(1+(m_sets[1].m_leaves*m_fupdates)/100);
|
||||
m_fixedleft=btMax<int>(0,m_fixedleft-count);
|
||||
m_fixedleft=b3Max<int>(0,m_fixedleft-count);
|
||||
}
|
||||
/* dynamic -> fixed set */
|
||||
m_stageCurrent=(m_stageCurrent+1)%STAGECOUNT;
|
||||
btDbvtProxy* current=m_stageRoots[m_stageCurrent];
|
||||
b3DbvtProxy* current=m_stageRoots[m_stageCurrent];
|
||||
if(current)
|
||||
{
|
||||
btDbvtTreeCollider collider(this);
|
||||
b3DbvtTreeCollider collider(this);
|
||||
do {
|
||||
btDbvtProxy* next=current->links[1];
|
||||
b3DbvtProxy* next=current->links[1];
|
||||
listremove(current,m_stageRoots[current->stage]);
|
||||
listappend(current,m_stageRoots[STAGECOUNT]);
|
||||
#if DBVT_BP_ACCURATESLEEPING
|
||||
@@ -530,7 +530,7 @@ void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher)
|
||||
b3DynamicBvh::collideTV(m_sets[1].m_root,current->aabb,collider);
|
||||
#endif
|
||||
m_sets[0].remove(current->leaf);
|
||||
ATTRIBUTE_ALIGNED16(btDbvtVolume) curAabb=btDbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax);
|
||||
ATTRIBUTE_ALIGNED16(b3DbvtVolume) curAabb=b3DbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax);
|
||||
current->leaf = m_sets[1].insert(curAabb,current);
|
||||
current->stage = STAGECOUNT;
|
||||
current = next;
|
||||
@@ -540,7 +540,7 @@ void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher)
|
||||
}
|
||||
/* collide dynamics */
|
||||
{
|
||||
btDbvtTreeCollider collider(this);
|
||||
b3DbvtTreeCollider collider(this);
|
||||
if(m_deferedcollide)
|
||||
{
|
||||
SPC(m_profiling.m_fdcollide);
|
||||
@@ -556,21 +556,21 @@ void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher)
|
||||
if(m_needcleanup)
|
||||
{
|
||||
SPC(m_profiling.m_cleanup);
|
||||
btBroadphasePairArray& pairs=m_paircache->getOverlappingPairArray();
|
||||
b3BroadphasePairArray& pairs=m_paircache->getOverlappingPairArray();
|
||||
if(pairs.size()>0)
|
||||
{
|
||||
|
||||
int ni=btMin(pairs.size(),btMax<int>(m_newpairs,(pairs.size()*m_cupdates)/100));
|
||||
int ni=b3Min(pairs.size(),b3Max<int>(m_newpairs,(pairs.size()*m_cupdates)/100));
|
||||
for(int i=0;i<ni;++i)
|
||||
{
|
||||
btBroadphasePair& p=pairs[(m_cid+i)%pairs.size()];
|
||||
btDbvtProxy* pa=&m_proxies[p.x];
|
||||
btDbvtProxy* pb=&m_proxies[p.y];
|
||||
b3BroadphasePair& p=pairs[(m_cid+i)%pairs.size()];
|
||||
b3DbvtProxy* pa=&m_proxies[p.x];
|
||||
b3DbvtProxy* pb=&m_proxies[p.y];
|
||||
if(!Intersect(pa->leaf->volume,pb->leaf->volume))
|
||||
{
|
||||
#if DBVT_BP_SORTPAIRS
|
||||
if(pa->m_uniqueId>pb->m_uniqueId)
|
||||
btSwap(pa,pb);
|
||||
b3Swap(pa,pb);
|
||||
#endif
|
||||
m_paircache->removeOverlappingPair(pa->getUid(),pb->getUid(),dispatcher);
|
||||
--ni;--i;
|
||||
@@ -613,7 +613,7 @@ const b3OverlappingPairCache* b3DynamicBvhBroadphase::getOverlappingPairCache()
|
||||
void b3DynamicBvhBroadphase::getBroadphaseAabb(b3Vector3& aabbMin,b3Vector3& aabbMax) const
|
||||
{
|
||||
|
||||
ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds;
|
||||
ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds;
|
||||
|
||||
if(!m_sets[0].empty())
|
||||
if(!m_sets[1].empty()) Merge( m_sets[0].m_root->volume,
|
||||
@@ -622,12 +622,12 @@ void b3DynamicBvhBroadphase::getBroadphaseAabb(b3Vector3& aabbMin,b3Vector
|
||||
bounds=m_sets[0].m_root->volume;
|
||||
else if(!m_sets[1].empty()) bounds=m_sets[1].m_root->volume;
|
||||
else
|
||||
bounds=btDbvtVolume::FromCR(b3Vector3(0,0,0),0);
|
||||
bounds=b3DbvtVolume::FromCR(b3Vector3(0,0,0),0);
|
||||
aabbMin=bounds.Mins();
|
||||
aabbMax=bounds.Maxs();
|
||||
}
|
||||
|
||||
void b3DynamicBvhBroadphase::resetPool(btDispatcher* dispatcher)
|
||||
void b3DynamicBvhBroadphase::resetPool(b3Dispatcher* dispatcher)
|
||||
{
|
||||
|
||||
int totalObjects = m_sets[0].m_leaves + m_sets[1].m_leaves;
|
||||
@@ -665,7 +665,7 @@ void b3DynamicBvhBroadphase::printStats()
|
||||
//
|
||||
#if DBVT_BP_ENABLE_BENCHMARK
|
||||
|
||||
struct btBroadphaseBenchmark
|
||||
struct b3BroadphaseBenchmark
|
||||
{
|
||||
struct Experiment
|
||||
{
|
||||
@@ -681,22 +681,22 @@ struct btBroadphaseBenchmark
|
||||
{
|
||||
b3Vector3 center;
|
||||
b3Vector3 extents;
|
||||
btBroadphaseProxy* proxy;
|
||||
b3BroadphaseProxy* proxy;
|
||||
b3Scalar time;
|
||||
void update(b3Scalar speed,b3Scalar amplitude,btBroadphaseInterface* pbi)
|
||||
void update(b3Scalar speed,b3Scalar amplitude,b3BroadphaseInterface* pbi)
|
||||
{
|
||||
time += speed;
|
||||
center[0] = btCos(time*(b3Scalar)2.17)*amplitude+
|
||||
btSin(time)*amplitude/2;
|
||||
center[1] = btCos(time*(b3Scalar)1.38)*amplitude+
|
||||
btSin(time)*amplitude;
|
||||
center[2] = btSin(time*(b3Scalar)0.777)*amplitude;
|
||||
center[0] = b3Cos(time*(b3Scalar)2.17)*amplitude+
|
||||
b3Sin(time)*amplitude/2;
|
||||
center[1] = b3Cos(time*(b3Scalar)1.38)*amplitude+
|
||||
b3Sin(time)*amplitude;
|
||||
center[2] = b3Sin(time*(b3Scalar)0.777)*amplitude;
|
||||
pbi->setAabb(proxy,center-extents,center+extents,0);
|
||||
}
|
||||
};
|
||||
static int UnsignedRand(int range=RAND_MAX-1) { return(rand()%(range+1)); }
|
||||
static b3Scalar UnitRand() { return(UnsignedRand(16384)/(b3Scalar)16384); }
|
||||
static void OutputTime(const char* name,btClock& c,unsigned count=0)
|
||||
static void OutputTime(const char* name,b3Clock& c,unsigned count=0)
|
||||
{
|
||||
const unsigned long us=c.getTimeMicroseconds();
|
||||
const unsigned long ms=(us+500)/1000;
|
||||
@@ -708,21 +708,21 @@ struct btBroadphaseBenchmark
|
||||
}
|
||||
};
|
||||
|
||||
void b3DynamicBvhBroadphase::benchmark(btBroadphaseInterface* pbi)
|
||||
void b3DynamicBvhBroadphase::benchmark(b3BroadphaseInterface* pbi)
|
||||
{
|
||||
static const btBroadphaseBenchmark::Experiment experiments[]=
|
||||
static const b3BroadphaseBenchmark::Experiment experiments[]=
|
||||
{
|
||||
{"1024o.10%",1024,10,0,8192,(b3Scalar)0.005,(b3Scalar)100},
|
||||
/*{"4096o.10%",4096,10,0,8192,(b3Scalar)0.005,(b3Scalar)100},
|
||||
{"8192o.10%",8192,10,0,8192,(b3Scalar)0.005,(b3Scalar)100},*/
|
||||
};
|
||||
static const int nexperiments=sizeof(experiments)/sizeof(experiments[0]);
|
||||
b3AlignedObjectArray<btBroadphaseBenchmark::Object*> objects;
|
||||
btClock wallclock;
|
||||
b3AlignedObjectArray<b3BroadphaseBenchmark::Object*> objects;
|
||||
b3Clock wallclock;
|
||||
/* Begin */
|
||||
for(int iexp=0;iexp<nexperiments;++iexp)
|
||||
{
|
||||
const btBroadphaseBenchmark::Experiment& experiment=experiments[iexp];
|
||||
const b3BroadphaseBenchmark::Experiment& experiment=experiments[iexp];
|
||||
const int object_count=experiment.object_count;
|
||||
const int update_count=(object_count*experiment.update_count)/100;
|
||||
const int spawn_count=(object_count*experiment.spawn_count)/100;
|
||||
@@ -740,25 +740,25 @@ void b3DynamicBvhBroadphase::benchmark(btBroadphaseInterface* pbi)
|
||||
objects.reserve(object_count);
|
||||
for(int i=0;i<object_count;++i)
|
||||
{
|
||||
btBroadphaseBenchmark::Object* po=new btBroadphaseBenchmark::Object();
|
||||
po->center[0]=btBroadphaseBenchmark::UnitRand()*50;
|
||||
po->center[1]=btBroadphaseBenchmark::UnitRand()*50;
|
||||
po->center[2]=btBroadphaseBenchmark::UnitRand()*50;
|
||||
po->extents[0]=btBroadphaseBenchmark::UnitRand()*2+2;
|
||||
po->extents[1]=btBroadphaseBenchmark::UnitRand()*2+2;
|
||||
po->extents[2]=btBroadphaseBenchmark::UnitRand()*2+2;
|
||||
po->time=btBroadphaseBenchmark::UnitRand()*2000;
|
||||
b3BroadphaseBenchmark::Object* po=new b3BroadphaseBenchmark::Object();
|
||||
po->center[0]=b3BroadphaseBenchmark::UnitRand()*50;
|
||||
po->center[1]=b3BroadphaseBenchmark::UnitRand()*50;
|
||||
po->center[2]=b3BroadphaseBenchmark::UnitRand()*50;
|
||||
po->extents[0]=b3BroadphaseBenchmark::UnitRand()*2+2;
|
||||
po->extents[1]=b3BroadphaseBenchmark::UnitRand()*2+2;
|
||||
po->extents[2]=b3BroadphaseBenchmark::UnitRand()*2+2;
|
||||
po->time=b3BroadphaseBenchmark::UnitRand()*2000;
|
||||
po->proxy=pbi->createProxy(po->center-po->extents,po->center+po->extents,0,po,1,1,0,0);
|
||||
objects.push_back(po);
|
||||
}
|
||||
btBroadphaseBenchmark::OutputTime("\tInitialization",wallclock);
|
||||
b3BroadphaseBenchmark::OutputTime("\tInitialization",wallclock);
|
||||
/* First update */
|
||||
wallclock.reset();
|
||||
for(int i=0;i<objects.size();++i)
|
||||
{
|
||||
objects[i]->update(speed,amplitude,pbi);
|
||||
}
|
||||
btBroadphaseBenchmark::OutputTime("\tFirst update",wallclock);
|
||||
b3BroadphaseBenchmark::OutputTime("\tFirst update",wallclock);
|
||||
/* Updates */
|
||||
wallclock.reset();
|
||||
for(int i=0;i<experiment.iterations;++i)
|
||||
@@ -769,7 +769,7 @@ void b3DynamicBvhBroadphase::benchmark(btBroadphaseInterface* pbi)
|
||||
}
|
||||
pbi->calculateOverlappingPairs(0);
|
||||
}
|
||||
btBroadphaseBenchmark::OutputTime("\tUpdate",wallclock,experiment.iterations);
|
||||
b3BroadphaseBenchmark::OutputTime("\tUpdate",wallclock,experiment.iterations);
|
||||
/* Clean up */
|
||||
wallclock.reset();
|
||||
for(int i=0;i<objects.size();++i)
|
||||
@@ -778,12 +778,12 @@ void b3DynamicBvhBroadphase::benchmark(btBroadphaseInterface* pbi)
|
||||
delete objects[i];
|
||||
}
|
||||
objects.resize(0);
|
||||
btBroadphaseBenchmark::OutputTime("\tRelease",wallclock);
|
||||
b3BroadphaseBenchmark::OutputTime("\tRelease",wallclock);
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
/*void b3DynamicBvhBroadphase::benchmark(btBroadphaseInterface*)
|
||||
/*void b3DynamicBvhBroadphase::benchmark(b3BroadphaseInterface*)
|
||||
{}
|
||||
*/
|
||||
#endif
|
||||
|
||||
@@ -14,8 +14,8 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
///b3DynamicBvhBroadphase implementation by Nathanael Presson
|
||||
#ifndef BT_DBVT_BROADPHASE_H
|
||||
#define BT_DBVT_BROADPHASE_H
|
||||
#ifndef B3_DBVT_BROADPHASE_H
|
||||
#define B3_DBVT_BROADPHASE_H
|
||||
|
||||
#include "Bullet3Collision/BroadPhaseCollision/b3DynamicBvh.h"
|
||||
#include "Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h"
|
||||
@@ -36,16 +36,16 @@ subject to the following restrictions:
|
||||
|
||||
#if DBVT_BP_PROFILE
|
||||
#define DBVT_BP_PROFILING_RATE 256
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#include "LinearMath/b3Quickprof.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
ATTRIBUTE_ALIGNED16(struct) btBroadphaseProxy
|
||||
ATTRIBUTE_ALIGNED16(struct) b3BroadphaseProxy
|
||||
{
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
///optional filtering to cull potential collisions
|
||||
enum CollisionFilterGroups
|
||||
@@ -59,7 +59,7 @@ BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
|
||||
};
|
||||
|
||||
//Usually the client btCollisionObject or Rigidbody class
|
||||
//Usually the client b3CollisionObject or Rigidbody class
|
||||
void* m_clientObject;
|
||||
short int m_collisionFilterGroup;
|
||||
short int m_collisionFilterMask;
|
||||
@@ -75,11 +75,11 @@ BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
}
|
||||
|
||||
//used for memory pools
|
||||
btBroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0)
|
||||
b3BroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0)
|
||||
{
|
||||
}
|
||||
|
||||
btBroadphaseProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0)
|
||||
b3BroadphaseProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0)
|
||||
:m_clientObject(userPtr),
|
||||
m_collisionFilterGroup(collisionFilterGroup),
|
||||
m_collisionFilterMask(collisionFilterMask),
|
||||
@@ -95,30 +95,30 @@ BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
|
||||
//
|
||||
// btDbvtProxy
|
||||
// b3DbvtProxy
|
||||
//
|
||||
struct btDbvtProxy : btBroadphaseProxy
|
||||
struct b3DbvtProxy : b3BroadphaseProxy
|
||||
{
|
||||
/* Fields */
|
||||
//btDbvtAabbMm aabb;
|
||||
btDbvtNode* leaf;
|
||||
btDbvtProxy* links[2];
|
||||
//b3DbvtAabbMm aabb;
|
||||
b3DbvtNode* leaf;
|
||||
b3DbvtProxy* links[2];
|
||||
int stage;
|
||||
/* ctor */
|
||||
|
||||
explicit btDbvtProxy() {}
|
||||
btDbvtProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
|
||||
btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask)
|
||||
explicit b3DbvtProxy() {}
|
||||
b3DbvtProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
|
||||
b3BroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask)
|
||||
{
|
||||
links[0]=links[1]=0;
|
||||
}
|
||||
};
|
||||
|
||||
typedef b3AlignedObjectArray<btDbvtProxy*> btDbvtProxyArray;
|
||||
typedef b3AlignedObjectArray<b3DbvtProxy*> b3DbvtProxyArray;
|
||||
|
||||
///The b3DynamicBvhBroadphase implements a broadphase using two dynamic AABB bounding volume hierarchies/trees (see b3DynamicBvh).
|
||||
///One tree is used for static/non-moving objects, and another tree is used for dynamic objects. Objects can move from one tree to the other.
|
||||
///This is a very fast broadphase, especially for very dynamic worlds where many objects are moving. Its insert/add and remove of objects is generally faster than the sweep and prune broadphases btAxisSweep3 and bt32BitAxisSweep3.
|
||||
///This is a very fast broadphase, especially for very dynamic worlds where many objects are moving. Its insert/add and remove of objects is generally faster than the sweep and prune broadphases b3AxisSweep3 and b332BitAxisSweep3.
|
||||
struct b3DynamicBvhBroadphase
|
||||
{
|
||||
/* Config */
|
||||
@@ -129,9 +129,9 @@ struct b3DynamicBvhBroadphase
|
||||
};
|
||||
/* Fields */
|
||||
b3DynamicBvh m_sets[2]; // Dbvt sets
|
||||
btDbvtProxy* m_stageRoots[STAGECOUNT+1]; // Stages list
|
||||
b3DbvtProxy* m_stageRoots[STAGECOUNT+1]; // Stages list
|
||||
|
||||
b3AlignedObjectArray<btDbvtProxy> m_proxies;
|
||||
b3AlignedObjectArray<b3DbvtProxy> m_proxies;
|
||||
b3OverlappingPairCache* m_paircache; // Pair cache
|
||||
b3Scalar m_prediction; // Velocity prediction
|
||||
int m_stageCurrent; // Current stage
|
||||
@@ -149,7 +149,7 @@ struct b3DynamicBvhBroadphase
|
||||
bool m_deferedcollide; // Defere dynamic/static collision to collide call
|
||||
bool m_needcleanup; // Need to run cleanup?
|
||||
#if DBVT_BP_PROFILE
|
||||
btClock m_clock;
|
||||
b3Clock m_clock;
|
||||
struct {
|
||||
unsigned long m_total;
|
||||
unsigned long m_ddcollide;
|
||||
@@ -161,18 +161,18 @@ struct b3DynamicBvhBroadphase
|
||||
/* Methods */
|
||||
b3DynamicBvhBroadphase(int proxyCapacity, b3OverlappingPairCache* paircache=0);
|
||||
~b3DynamicBvhBroadphase();
|
||||
void collide(btDispatcher* dispatcher);
|
||||
void collide(b3Dispatcher* dispatcher);
|
||||
void optimize();
|
||||
|
||||
/* btBroadphaseInterface Implementation */
|
||||
btBroadphaseProxy* createProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const b3Vector3& aabbMin,const b3Vector3& aabbMax,btDispatcher* dispatcher);
|
||||
virtual void rayTest(const b3Vector3& rayFrom,const b3Vector3& rayTo, btBroadphaseRayCallback& rayCallback, const b3Vector3& aabbMin=b3Vector3(0,0,0), const b3Vector3& aabbMax = b3Vector3(0,0,0));
|
||||
virtual void aabbTest(const b3Vector3& aabbMin, const b3Vector3& aabbMax, btBroadphaseAabbCallback& callback);
|
||||
/* b3BroadphaseInterface Implementation */
|
||||
b3BroadphaseProxy* createProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask);
|
||||
virtual void destroyProxy(b3BroadphaseProxy* proxy,b3Dispatcher* dispatcher);
|
||||
virtual void setAabb(b3BroadphaseProxy* proxy,const b3Vector3& aabbMin,const b3Vector3& aabbMax,b3Dispatcher* dispatcher);
|
||||
virtual void rayTest(const b3Vector3& rayFrom,const b3Vector3& rayTo, b3BroadphaseRayCallback& rayCallback, const b3Vector3& aabbMin=b3Vector3(0,0,0), const b3Vector3& aabbMax = b3Vector3(0,0,0));
|
||||
virtual void aabbTest(const b3Vector3& aabbMin, const b3Vector3& aabbMax, b3BroadphaseAabbCallback& callback);
|
||||
|
||||
virtual void getAabb(btBroadphaseProxy* proxy,b3Vector3& aabbMin, b3Vector3& aabbMax ) const;
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher=0);
|
||||
virtual void getAabb(b3BroadphaseProxy* proxy,b3Vector3& aabbMin, b3Vector3& aabbMax ) const;
|
||||
virtual void calculateOverlappingPairs(b3Dispatcher* dispatcher=0);
|
||||
virtual b3OverlappingPairCache* getOverlappingPairCache();
|
||||
virtual const b3OverlappingPairCache* getOverlappingPairCache() const;
|
||||
virtual void getBroadphaseAabb(b3Vector3& aabbMin,b3Vector3& aabbMax) const;
|
||||
@@ -180,9 +180,9 @@ struct b3DynamicBvhBroadphase
|
||||
|
||||
|
||||
///reset broadphase internal structures, to ensure determinism/reproducability
|
||||
virtual void resetPool(btDispatcher* dispatcher);
|
||||
virtual void resetPool(b3Dispatcher* dispatcher);
|
||||
|
||||
void performDeferredRemoval(btDispatcher* dispatcher);
|
||||
void performDeferredRemoval(b3Dispatcher* dispatcher);
|
||||
|
||||
void setVelocityPrediction(b3Scalar prediction)
|
||||
{
|
||||
@@ -194,12 +194,12 @@ struct b3DynamicBvhBroadphase
|
||||
}
|
||||
|
||||
///this setAabbForceUpdate is similar to setAabb but always forces the aabb update.
|
||||
///it is not part of the btBroadphaseInterface but specific to b3DynamicBvhBroadphase.
|
||||
///it is not part of the b3BroadphaseInterface but specific to b3DynamicBvhBroadphase.
|
||||
///it bypasses certain optimizations that prevent aabb updates (when the aabb shrinks), see
|
||||
///http://code.google.com/p/bullet/issues/detail?id=223
|
||||
void setAabbForceUpdate( btBroadphaseProxy* absproxy,const b3Vector3& aabbMin,const b3Vector3& aabbMax,btDispatcher* /*dispatcher*/);
|
||||
void setAabbForceUpdate( b3BroadphaseProxy* absproxy,const b3Vector3& aabbMin,const b3Vector3& aabbMax,b3Dispatcher* /*dispatcher*/);
|
||||
|
||||
//static void benchmark(btBroadphaseInterface*);
|
||||
//static void benchmark(b3BroadphaseInterface*);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef B3_OVERLAPPING_PAIR_H
|
||||
#define B3_OVERLAPPING_PAIR_H
|
||||
|
||||
#include "Bullet3Common/btInt2.h"
|
||||
#include "Bullet3Common/b3Int2.h"
|
||||
|
||||
//typedef btInt2 btBroadphasePair;
|
||||
struct btBroadphasePair : public btInt2
|
||||
//typedef b3Int2 b3BroadphasePair;
|
||||
struct b3BroadphasePair : public b3Int2
|
||||
{
|
||||
explicit btBroadphasePair(){}
|
||||
btBroadphasePair(int xx,int yy)
|
||||
explicit b3BroadphasePair(){}
|
||||
b3BroadphasePair(int xx,int yy)
|
||||
{
|
||||
if (xx < yy)
|
||||
{
|
||||
@@ -22,11 +22,11 @@ struct btBroadphasePair : public btInt2
|
||||
}
|
||||
};
|
||||
|
||||
class btBroadphasePairSortPredicate
|
||||
class b3BroadphasePairSortPredicate
|
||||
{
|
||||
public:
|
||||
|
||||
bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b ) const
|
||||
bool operator() ( const b3BroadphasePair& a, const b3BroadphasePair& b ) const
|
||||
{
|
||||
const int uidA0 = a.x;
|
||||
const int uidB0 = b.x;
|
||||
@@ -36,7 +36,7 @@ class btBroadphasePairSortPredicate
|
||||
}
|
||||
};
|
||||
|
||||
SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b)
|
||||
SIMD_FORCE_INLINE bool operator==(const b3BroadphasePair& a, const b3BroadphasePair& b)
|
||||
{
|
||||
return (a.x == b.x ) && (a.y == b.y );
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ subject to the following restrictions:
|
||||
|
||||
#include "b3OverlappingPairCache.h"
|
||||
|
||||
//#include "btDispatcher.h"
|
||||
//#include "btCollisionAlgorithm.h"
|
||||
//#include "b3Dispatcher.h"
|
||||
//#include "b3CollisionAlgorithm.h"
|
||||
#include "Bullet3Geometry/b3AabbUtil.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -32,7 +32,7 @@ int gFindPairs =0;
|
||||
|
||||
|
||||
|
||||
btHashedOverlappingPairCache::btHashedOverlappingPairCache():
|
||||
b3HashedOverlappingPairCache::b3HashedOverlappingPairCache():
|
||||
m_overlapFilterCallback(0),
|
||||
m_blockedForChanges(false)
|
||||
{
|
||||
@@ -44,18 +44,18 @@ btHashedOverlappingPairCache::btHashedOverlappingPairCache():
|
||||
|
||||
|
||||
|
||||
btHashedOverlappingPairCache::~btHashedOverlappingPairCache()
|
||||
b3HashedOverlappingPairCache::~b3HashedOverlappingPairCache()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher)
|
||||
void b3HashedOverlappingPairCache::cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher)
|
||||
{
|
||||
/* if (pair.m_algorithm)
|
||||
{
|
||||
{
|
||||
pair.m_algorithm->~btCollisionAlgorithm();
|
||||
pair.m_algorithm->~b3CollisionAlgorithm();
|
||||
dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
|
||||
pair.m_algorithm=0;
|
||||
}
|
||||
@@ -67,23 +67,23 @@ void btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,b
|
||||
|
||||
|
||||
|
||||
void btHashedOverlappingPairCache::cleanProxyFromPairs(int proxy,btDispatcher* dispatcher)
|
||||
void b3HashedOverlappingPairCache::cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher)
|
||||
{
|
||||
|
||||
class CleanPairCallback : public btOverlapCallback
|
||||
class CleanPairCallback : public b3OverlapCallback
|
||||
{
|
||||
int m_cleanProxy;
|
||||
b3OverlappingPairCache* m_pairCache;
|
||||
btDispatcher* m_dispatcher;
|
||||
b3Dispatcher* m_dispatcher;
|
||||
|
||||
public:
|
||||
CleanPairCallback(int cleanProxy,b3OverlappingPairCache* pairCache,btDispatcher* dispatcher)
|
||||
CleanPairCallback(int cleanProxy,b3OverlappingPairCache* pairCache,b3Dispatcher* dispatcher)
|
||||
:m_cleanProxy(cleanProxy),
|
||||
m_pairCache(pairCache),
|
||||
m_dispatcher(dispatcher)
|
||||
{
|
||||
}
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(b3BroadphasePair& pair)
|
||||
{
|
||||
if ((pair.x == m_cleanProxy) ||
|
||||
(pair.y == m_cleanProxy))
|
||||
@@ -104,10 +104,10 @@ void btHashedOverlappingPairCache::cleanProxyFromPairs(int proxy,btDispatcher* d
|
||||
|
||||
|
||||
|
||||
void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int proxy,btDispatcher* dispatcher)
|
||||
void b3HashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int proxy,b3Dispatcher* dispatcher)
|
||||
{
|
||||
|
||||
class RemovePairCallback : public btOverlapCallback
|
||||
class RemovePairCallback : public b3OverlapCallback
|
||||
{
|
||||
int m_obsoleteProxy;
|
||||
|
||||
@@ -116,7 +116,7 @@ void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro
|
||||
:m_obsoleteProxy(obsoleteProxy)
|
||||
{
|
||||
}
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(b3BroadphasePair& pair)
|
||||
{
|
||||
return ((pair.x == m_obsoleteProxy) ||
|
||||
(pair.y == m_obsoleteProxy));
|
||||
@@ -134,16 +134,16 @@ void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro
|
||||
|
||||
|
||||
|
||||
btBroadphasePair* btHashedOverlappingPairCache::findPair(int proxy0, int proxy1)
|
||||
b3BroadphasePair* b3HashedOverlappingPairCache::findPair(int proxy0, int proxy1)
|
||||
{
|
||||
gFindPairs++;
|
||||
if(proxy0 >proxy1)
|
||||
btSwap(proxy0,proxy1);
|
||||
b3Swap(proxy0,proxy1);
|
||||
int proxyId1 = proxy0;
|
||||
int proxyId2 = proxy1;
|
||||
|
||||
/*if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);*/
|
||||
b3Swap(proxyId1, proxyId2);*/
|
||||
|
||||
int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1), static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));
|
||||
|
||||
@@ -153,24 +153,24 @@ btBroadphasePair* btHashedOverlappingPairCache::findPair(int proxy0, int proxy1)
|
||||
}
|
||||
|
||||
int index = m_hashTable[hash];
|
||||
while (index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false)
|
||||
while (index != B3_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false)
|
||||
{
|
||||
index = m_next[index];
|
||||
}
|
||||
|
||||
if (index == BT_NULL_PAIR)
|
||||
if (index == B3_NULL_PAIR)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
btAssert(index < m_overlappingPairArray.size());
|
||||
b3Assert(index < m_overlappingPairArray.size());
|
||||
|
||||
return &m_overlappingPairArray[index];
|
||||
}
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
void btHashedOverlappingPairCache::growTables()
|
||||
void b3HashedOverlappingPairCache::growTables()
|
||||
{
|
||||
|
||||
int newCapacity = m_overlappingPairArray.capacity();
|
||||
@@ -188,21 +188,21 @@ void btHashedOverlappingPairCache::growTables()
|
||||
|
||||
for (i= 0; i < newCapacity; ++i)
|
||||
{
|
||||
m_hashTable[i] = BT_NULL_PAIR;
|
||||
m_hashTable[i] = B3_NULL_PAIR;
|
||||
}
|
||||
for (i = 0; i < newCapacity; ++i)
|
||||
{
|
||||
m_next[i] = BT_NULL_PAIR;
|
||||
m_next[i] = B3_NULL_PAIR;
|
||||
}
|
||||
|
||||
for(i=0;i<curHashtableSize;i++)
|
||||
{
|
||||
|
||||
const btBroadphasePair& pair = m_overlappingPairArray[i];
|
||||
const b3BroadphasePair& pair = m_overlappingPairArray[i];
|
||||
int proxyId1 = pair.x;
|
||||
int proxyId2 = pair.y;
|
||||
/*if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);*/
|
||||
b3Swap(proxyId1, proxyId2);*/
|
||||
int hashValue = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask
|
||||
m_next[i] = m_hashTable[hashValue];
|
||||
m_hashTable[hashValue] = i;
|
||||
@@ -212,20 +212,20 @@ void btHashedOverlappingPairCache::growTables()
|
||||
}
|
||||
}
|
||||
|
||||
btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(int proxy0, int proxy1)
|
||||
b3BroadphasePair* b3HashedOverlappingPairCache::internalAddPair(int proxy0, int proxy1)
|
||||
{
|
||||
if(proxy0>proxy1)
|
||||
btSwap(proxy0,proxy1);
|
||||
b3Swap(proxy0,proxy1);
|
||||
int proxyId1 = proxy0;
|
||||
int proxyId2 = proxy1;
|
||||
|
||||
/*if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);*/
|
||||
b3Swap(proxyId1, proxyId2);*/
|
||||
|
||||
int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask
|
||||
|
||||
|
||||
btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash);
|
||||
b3BroadphasePair* pair = internalFindPair(proxy0, proxy1, hash);
|
||||
if (pair != NULL)
|
||||
{
|
||||
return pair;
|
||||
@@ -256,7 +256,7 @@ btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(int proxy0, int
|
||||
hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));
|
||||
}
|
||||
|
||||
pair = new (mem) btBroadphasePair(proxy0,proxy1);
|
||||
pair = new (mem) b3BroadphasePair(proxy0,proxy1);
|
||||
|
||||
// pair->m_pProxy0 = proxy0;
|
||||
// pair->m_pProxy1 = proxy1;
|
||||
@@ -272,20 +272,20 @@ btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(int proxy0, int
|
||||
|
||||
|
||||
|
||||
void* btHashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1,btDispatcher* dispatcher)
|
||||
void* b3HashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1,b3Dispatcher* dispatcher)
|
||||
{
|
||||
gRemovePairs++;
|
||||
if(proxy0>proxy1)
|
||||
btSwap(proxy0,proxy1);
|
||||
b3Swap(proxy0,proxy1);
|
||||
int proxyId1 = proxy0;
|
||||
int proxyId2 = proxy1;
|
||||
|
||||
/*if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);*/
|
||||
b3Swap(proxyId1, proxyId2);*/
|
||||
|
||||
int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));
|
||||
|
||||
btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash);
|
||||
b3BroadphasePair* pair = internalFindPair(proxy0, proxy1, hash);
|
||||
if (pair == NULL)
|
||||
{
|
||||
return 0;
|
||||
@@ -296,22 +296,22 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1
|
||||
|
||||
|
||||
int pairIndex = int(pair - &m_overlappingPairArray[0]);
|
||||
btAssert(pairIndex < m_overlappingPairArray.size());
|
||||
b3Assert(pairIndex < m_overlappingPairArray.size());
|
||||
|
||||
// Remove the pair from the hash table.
|
||||
int index = m_hashTable[hash];
|
||||
btAssert(index != BT_NULL_PAIR);
|
||||
b3Assert(index != B3_NULL_PAIR);
|
||||
|
||||
int previous = BT_NULL_PAIR;
|
||||
int previous = B3_NULL_PAIR;
|
||||
while (index != pairIndex)
|
||||
{
|
||||
previous = index;
|
||||
index = m_next[index];
|
||||
}
|
||||
|
||||
if (previous != BT_NULL_PAIR)
|
||||
if (previous != B3_NULL_PAIR)
|
||||
{
|
||||
btAssert(m_next[previous] == pairIndex);
|
||||
b3Assert(m_next[previous] == pairIndex);
|
||||
m_next[previous] = m_next[pairIndex];
|
||||
}
|
||||
else
|
||||
@@ -336,23 +336,23 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1
|
||||
}
|
||||
|
||||
// Remove the last pair from the hash table.
|
||||
const btBroadphasePair* last = &m_overlappingPairArray[lastPairIndex];
|
||||
const b3BroadphasePair* last = &m_overlappingPairArray[lastPairIndex];
|
||||
/* missing swap here too, Nat. */
|
||||
int lastHash = static_cast<int>(getHash(static_cast<unsigned int>(last->x), static_cast<unsigned int>(last->y)) & (m_overlappingPairArray.capacity()-1));
|
||||
|
||||
index = m_hashTable[lastHash];
|
||||
btAssert(index != BT_NULL_PAIR);
|
||||
b3Assert(index != B3_NULL_PAIR);
|
||||
|
||||
previous = BT_NULL_PAIR;
|
||||
previous = B3_NULL_PAIR;
|
||||
while (index != lastPairIndex)
|
||||
{
|
||||
previous = index;
|
||||
index = m_next[index];
|
||||
}
|
||||
|
||||
if (previous != BT_NULL_PAIR)
|
||||
if (previous != B3_NULL_PAIR)
|
||||
{
|
||||
btAssert(m_next[previous] == lastPairIndex);
|
||||
b3Assert(m_next[previous] == lastPairIndex);
|
||||
m_next[previous] = m_next[lastPairIndex];
|
||||
}
|
||||
else
|
||||
@@ -373,7 +373,7 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1
|
||||
}
|
||||
//#include <stdio.h>
|
||||
|
||||
void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher)
|
||||
void b3HashedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback* callback,b3Dispatcher* dispatcher)
|
||||
{
|
||||
|
||||
int i;
|
||||
@@ -382,7 +382,7 @@ void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback*
|
||||
for (i=0;i<m_overlappingPairArray.size();)
|
||||
{
|
||||
|
||||
btBroadphasePair* pair = &m_overlappingPairArray[i];
|
||||
b3BroadphasePair* pair = &m_overlappingPairArray[i];
|
||||
if (callback->processOverlap(*pair))
|
||||
{
|
||||
removeOverlappingPair(pair->x,pair->y,dispatcher);
|
||||
@@ -399,10 +399,10 @@ void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback*
|
||||
|
||||
|
||||
|
||||
void btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
|
||||
void b3HashedOverlappingPairCache::sortOverlappingPairs(b3Dispatcher* dispatcher)
|
||||
{
|
||||
///need to keep hashmap in sync with pair address, so rebuild all
|
||||
btBroadphasePairArray tmpPairs;
|
||||
b3BroadphasePairArray tmpPairs;
|
||||
int i;
|
||||
for (i=0;i<m_overlappingPairArray.size();i++)
|
||||
{
|
||||
@@ -416,10 +416,10 @@ void btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher
|
||||
|
||||
for (i = 0; i < m_next.size(); i++)
|
||||
{
|
||||
m_next[i] = BT_NULL_PAIR;
|
||||
m_next[i] = B3_NULL_PAIR;
|
||||
}
|
||||
|
||||
tmpPairs.quickSort(btBroadphasePairSortPredicate());
|
||||
tmpPairs.quickSort(b3BroadphasePairSortPredicate());
|
||||
|
||||
for (i=0;i<tmpPairs.size();i++)
|
||||
{
|
||||
@@ -430,18 +430,18 @@ void btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher
|
||||
}
|
||||
|
||||
|
||||
void* btSortedOverlappingPairCache::removeOverlappingPair(int proxy0,int proxy1, btDispatcher* dispatcher )
|
||||
void* b3SortedOverlappingPairCache::removeOverlappingPair(int proxy0,int proxy1, b3Dispatcher* dispatcher )
|
||||
{
|
||||
if (!hasDeferredRemoval())
|
||||
{
|
||||
btBroadphasePair findPair(proxy0,proxy1);
|
||||
b3BroadphasePair findPair(proxy0,proxy1);
|
||||
|
||||
|
||||
int findIndex = m_overlappingPairArray.findLinearSearch(findPair);
|
||||
if (findIndex < m_overlappingPairArray.size())
|
||||
{
|
||||
gOverlappingPairs--;
|
||||
btBroadphasePair& pair = m_overlappingPairArray[findIndex];
|
||||
b3BroadphasePair& pair = m_overlappingPairArray[findIndex];
|
||||
|
||||
cleanOverlappingPair(pair,dispatcher);
|
||||
//if (m_ghostPairCallback)
|
||||
@@ -463,16 +463,16 @@ void* btSortedOverlappingPairCache::removeOverlappingPair(int proxy0,int proxy1,
|
||||
|
||||
|
||||
|
||||
btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(int proxy0,int proxy1)
|
||||
b3BroadphasePair* b3SortedOverlappingPairCache::addOverlappingPair(int proxy0,int proxy1)
|
||||
{
|
||||
//don't add overlap with own
|
||||
btAssert(proxy0 != proxy1);
|
||||
b3Assert(proxy0 != proxy1);
|
||||
|
||||
if (!needsBroadphaseCollision(proxy0,proxy1))
|
||||
return 0;
|
||||
|
||||
void* mem = &m_overlappingPairArray.expandNonInitializing();
|
||||
btBroadphasePair* pair = new (mem) btBroadphasePair(proxy0,proxy1);
|
||||
b3BroadphasePair* pair = new (mem) b3BroadphasePair(proxy0,proxy1);
|
||||
|
||||
|
||||
gOverlappingPairs++;
|
||||
@@ -488,18 +488,18 @@ btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(int proxy0,in
|
||||
///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
|
||||
btBroadphasePair* btSortedOverlappingPairCache::findPair(int proxy0,int proxy1)
|
||||
b3BroadphasePair* b3SortedOverlappingPairCache::findPair(int proxy0,int proxy1)
|
||||
{
|
||||
if (!needsBroadphaseCollision(proxy0,proxy1))
|
||||
return 0;
|
||||
|
||||
btBroadphasePair tmpPair(proxy0,proxy1);
|
||||
b3BroadphasePair tmpPair(proxy0,proxy1);
|
||||
int findIndex = m_overlappingPairArray.findLinearSearch(tmpPair);
|
||||
|
||||
if (findIndex < m_overlappingPairArray.size())
|
||||
{
|
||||
//btAssert(it != m_overlappingPairSet.end());
|
||||
btBroadphasePair* pair = &m_overlappingPairArray[findIndex];
|
||||
//b3Assert(it != m_overlappingPairSet.end());
|
||||
b3BroadphasePair* pair = &m_overlappingPairArray[findIndex];
|
||||
return pair;
|
||||
}
|
||||
return 0;
|
||||
@@ -516,7 +516,7 @@ btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(int proxy0,in
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher)
|
||||
void b3SortedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback* callback,b3Dispatcher* dispatcher)
|
||||
{
|
||||
|
||||
int i;
|
||||
@@ -524,7 +524,7 @@ void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback*
|
||||
for (i=0;i<m_overlappingPairArray.size();)
|
||||
{
|
||||
|
||||
btBroadphasePair* pair = &m_overlappingPairArray[i];
|
||||
b3BroadphasePair* pair = &m_overlappingPairArray[i];
|
||||
if (callback->processOverlap(*pair))
|
||||
{
|
||||
cleanOverlappingPair(*pair,dispatcher);
|
||||
@@ -543,7 +543,7 @@ void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback*
|
||||
|
||||
|
||||
|
||||
btSortedOverlappingPairCache::btSortedOverlappingPairCache():
|
||||
b3SortedOverlappingPairCache::b3SortedOverlappingPairCache():
|
||||
m_blockedForChanges(false),
|
||||
m_hasDeferredRemoval(true),
|
||||
m_overlapFilterCallback(0)
|
||||
@@ -553,16 +553,16 @@ btSortedOverlappingPairCache::btSortedOverlappingPairCache():
|
||||
m_overlappingPairArray.reserve(initialAllocatedSize);
|
||||
}
|
||||
|
||||
btSortedOverlappingPairCache::~btSortedOverlappingPairCache()
|
||||
b3SortedOverlappingPairCache::~b3SortedOverlappingPairCache()
|
||||
{
|
||||
}
|
||||
|
||||
void btSortedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher)
|
||||
void b3SortedOverlappingPairCache::cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher)
|
||||
{
|
||||
/* if (pair.m_algorithm)
|
||||
{
|
||||
{
|
||||
pair.m_algorithm->~btCollisionAlgorithm();
|
||||
pair.m_algorithm->~b3CollisionAlgorithm();
|
||||
dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
|
||||
pair.m_algorithm=0;
|
||||
gRemovePairs--;
|
||||
@@ -572,23 +572,23 @@ void btSortedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,b
|
||||
}
|
||||
|
||||
|
||||
void btSortedOverlappingPairCache::cleanProxyFromPairs(int proxy,btDispatcher* dispatcher)
|
||||
void b3SortedOverlappingPairCache::cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher)
|
||||
{
|
||||
|
||||
class CleanPairCallback : public btOverlapCallback
|
||||
class CleanPairCallback : public b3OverlapCallback
|
||||
{
|
||||
int m_cleanProxy;
|
||||
b3OverlappingPairCache* m_pairCache;
|
||||
btDispatcher* m_dispatcher;
|
||||
b3Dispatcher* m_dispatcher;
|
||||
|
||||
public:
|
||||
CleanPairCallback(int cleanProxy,b3OverlappingPairCache* pairCache,btDispatcher* dispatcher)
|
||||
CleanPairCallback(int cleanProxy,b3OverlappingPairCache* pairCache,b3Dispatcher* dispatcher)
|
||||
:m_cleanProxy(cleanProxy),
|
||||
m_pairCache(pairCache),
|
||||
m_dispatcher(dispatcher)
|
||||
{
|
||||
}
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(b3BroadphasePair& pair)
|
||||
{
|
||||
if ((pair.x == m_cleanProxy) ||
|
||||
(pair.y == m_cleanProxy))
|
||||
@@ -607,10 +607,10 @@ void btSortedOverlappingPairCache::cleanProxyFromPairs(int proxy,btDispatcher* d
|
||||
}
|
||||
|
||||
|
||||
void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(int proxy,btDispatcher* dispatcher)
|
||||
void b3SortedOverlappingPairCache::removeOverlappingPairsContainingProxy(int proxy,b3Dispatcher* dispatcher)
|
||||
{
|
||||
|
||||
class RemovePairCallback : public btOverlapCallback
|
||||
class RemovePairCallback : public b3OverlapCallback
|
||||
{
|
||||
int m_obsoleteProxy;
|
||||
|
||||
@@ -619,7 +619,7 @@ void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro
|
||||
:m_obsoleteProxy(obsoleteProxy)
|
||||
{
|
||||
}
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(b3BroadphasePair& pair)
|
||||
{
|
||||
return ((pair.x == m_obsoleteProxy) ||
|
||||
(pair.y == m_obsoleteProxy));
|
||||
@@ -632,7 +632,7 @@ void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro
|
||||
processAllOverlappingPairs(&removeCallback,dispatcher);
|
||||
}
|
||||
|
||||
void btSortedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
|
||||
void b3SortedOverlappingPairCache::sortOverlappingPairs(b3Dispatcher* dispatcher)
|
||||
{
|
||||
//should already be sorted
|
||||
}
|
||||
|
||||
@@ -13,31 +13,31 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef BT_OVERLAPPING_PAIR_CACHE_H
|
||||
#define BT_OVERLAPPING_PAIR_CACHE_H
|
||||
#ifndef B3_OVERLAPPING_PAIR_CACHE_H
|
||||
#define B3_OVERLAPPING_PAIR_CACHE_H
|
||||
|
||||
#include "Bullet3Common/btInt2.h"
|
||||
#include "Bullet3Common/b3Int2.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
|
||||
class btDispatcher;
|
||||
class b3Dispatcher;
|
||||
#include "b3OverlappingPair.h"
|
||||
|
||||
|
||||
|
||||
typedef b3AlignedObjectArray<btBroadphasePair> btBroadphasePairArray;
|
||||
typedef b3AlignedObjectArray<b3BroadphasePair> b3BroadphasePairArray;
|
||||
|
||||
struct btOverlapCallback
|
||||
struct b3OverlapCallback
|
||||
{
|
||||
virtual ~btOverlapCallback()
|
||||
virtual ~b3OverlapCallback()
|
||||
{}
|
||||
//return true for deletion of the pair
|
||||
virtual bool processOverlap(btBroadphasePair& pair) = 0;
|
||||
virtual bool processOverlap(b3BroadphasePair& pair) = 0;
|
||||
|
||||
};
|
||||
|
||||
struct btOverlapFilterCallback
|
||||
struct b3OverlapFilterCallback
|
||||
{
|
||||
virtual ~btOverlapFilterCallback()
|
||||
virtual ~b3OverlapFilterCallback()
|
||||
{}
|
||||
// return true when pairs need collision
|
||||
virtual bool needBroadphaseCollision(int proxy0,int proxy1) const = 0;
|
||||
@@ -53,62 +53,62 @@ extern int gRemovePairs;
|
||||
extern int gAddedPairs;
|
||||
extern int gFindPairs;
|
||||
|
||||
const int BT_NULL_PAIR=0xffffffff;
|
||||
const int B3_NULL_PAIR=0xffffffff;
|
||||
|
||||
///The b3OverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
|
||||
///The btHashedOverlappingPairCache and btSortedOverlappingPairCache classes are two implementations.
|
||||
///The b3OverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the b3BroadphaseInterface broadphases.
|
||||
///The b3HashedOverlappingPairCache and b3SortedOverlappingPairCache classes are two implementations.
|
||||
class b3OverlappingPairCache
|
||||
{
|
||||
public:
|
||||
virtual ~b3OverlappingPairCache() {} // this is needed so we can get to the derived class destructor
|
||||
|
||||
virtual btBroadphasePair* getOverlappingPairArrayPtr() = 0;
|
||||
virtual b3BroadphasePair* getOverlappingPairArrayPtr() = 0;
|
||||
|
||||
virtual const btBroadphasePair* getOverlappingPairArrayPtr() const = 0;
|
||||
virtual const b3BroadphasePair* getOverlappingPairArrayPtr() const = 0;
|
||||
|
||||
virtual btBroadphasePairArray& getOverlappingPairArray() = 0;
|
||||
virtual b3BroadphasePairArray& getOverlappingPairArray() = 0;
|
||||
|
||||
virtual void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) = 0;
|
||||
virtual void cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher) = 0;
|
||||
|
||||
virtual int getNumOverlappingPairs() const = 0;
|
||||
|
||||
virtual void cleanProxyFromPairs(int proxy,btDispatcher* dispatcher) = 0;
|
||||
virtual void cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher) = 0;
|
||||
|
||||
virtual void setOverlapFilterCallback(btOverlapFilterCallback* callback) = 0;
|
||||
virtual void setOverlapFilterCallback(b3OverlapFilterCallback* callback) = 0;
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher) = 0;
|
||||
virtual void processAllOverlappingPairs(b3OverlapCallback*,b3Dispatcher* dispatcher) = 0;
|
||||
|
||||
virtual btBroadphasePair* findPair(int proxy0, int proxy1) = 0;
|
||||
virtual b3BroadphasePair* findPair(int proxy0, int proxy1) = 0;
|
||||
|
||||
virtual bool hasDeferredRemoval() = 0;
|
||||
|
||||
//virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)=0;
|
||||
//virtual void setInternalGhostPairCallback(b3OverlappingPairCallback* ghostPairCallback)=0;
|
||||
|
||||
virtual btBroadphasePair* addOverlappingPair(int proxy0,int proxy1)=0;
|
||||
virtual void* removeOverlappingPair(int proxy0,int proxy1,btDispatcher* dispatcher)=0;
|
||||
virtual void removeOverlappingPairsContainingProxy(int /*proxy0*/,btDispatcher* /*dispatcher*/)=0;
|
||||
virtual b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1)=0;
|
||||
virtual void* removeOverlappingPair(int proxy0,int proxy1,b3Dispatcher* dispatcher)=0;
|
||||
virtual void removeOverlappingPairsContainingProxy(int /*proxy0*/,b3Dispatcher* /*dispatcher*/)=0;
|
||||
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher) = 0;
|
||||
virtual void sortOverlappingPairs(b3Dispatcher* dispatcher) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
/// Hash-space based Pair Cache, thanks to Erin Catto, Box2D, http://www.box2d.org, and Pierre Terdiman, Codercorner, http://codercorner.com
|
||||
class btHashedOverlappingPairCache : public b3OverlappingPairCache
|
||||
class b3HashedOverlappingPairCache : public b3OverlappingPairCache
|
||||
{
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
btOverlapFilterCallback* m_overlapFilterCallback;
|
||||
b3BroadphasePairArray m_overlappingPairArray;
|
||||
b3OverlapFilterCallback* m_overlapFilterCallback;
|
||||
bool m_blockedForChanges;
|
||||
|
||||
|
||||
public:
|
||||
btHashedOverlappingPairCache();
|
||||
virtual ~btHashedOverlappingPairCache();
|
||||
b3HashedOverlappingPairCache();
|
||||
virtual ~b3HashedOverlappingPairCache();
|
||||
|
||||
|
||||
virtual void removeOverlappingPairsContainingProxy(int proxy,btDispatcher* dispatcher);
|
||||
virtual void removeOverlappingPairsContainingProxy(int proxy,b3Dispatcher* dispatcher);
|
||||
|
||||
virtual void* removeOverlappingPair(int proxy0,int proxy1,btDispatcher* dispatcher);
|
||||
virtual void* removeOverlappingPair(int proxy0,int proxy1,b3Dispatcher* dispatcher);
|
||||
|
||||
SIMD_FORCE_INLINE bool needsBroadphaseCollision(int proxy0,int proxy1) const
|
||||
{
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
|
||||
// Add a pair and return the new pair. If the pair already exists,
|
||||
// no new pair is created and the old one is returned.
|
||||
virtual btBroadphasePair* addOverlappingPair(int proxy0,int proxy1)
|
||||
virtual b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1)
|
||||
{
|
||||
gAddedPairs++;
|
||||
|
||||
@@ -135,46 +135,46 @@ public:
|
||||
|
||||
|
||||
|
||||
void cleanProxyFromPairs(int proxy,btDispatcher* dispatcher);
|
||||
void cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher);
|
||||
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher);
|
||||
virtual void processAllOverlappingPairs(b3OverlapCallback*,b3Dispatcher* dispatcher);
|
||||
|
||||
virtual btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
virtual b3BroadphasePair* getOverlappingPairArrayPtr()
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
|
||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||
const b3BroadphasePair* getOverlappingPairArrayPtr() const
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
b3BroadphasePairArray& getOverlappingPairArray()
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
const btBroadphasePairArray& getOverlappingPairArray() const
|
||||
const b3BroadphasePairArray& getOverlappingPairArray() const
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
|
||||
void cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher);
|
||||
|
||||
|
||||
|
||||
btBroadphasePair* findPair(int proxy0, int proxy1);
|
||||
b3BroadphasePair* findPair(int proxy0, int proxy1);
|
||||
|
||||
int GetCount() const { return m_overlappingPairArray.size(); }
|
||||
// btBroadphasePair* GetPairs() { return m_pairs; }
|
||||
// b3BroadphasePair* GetPairs() { return m_pairs; }
|
||||
|
||||
btOverlapFilterCallback* getOverlapFilterCallback()
|
||||
b3OverlapFilterCallback* getOverlapFilterCallback()
|
||||
{
|
||||
return m_overlapFilterCallback;
|
||||
}
|
||||
|
||||
void setOverlapFilterCallback(btOverlapFilterCallback* callback)
|
||||
void setOverlapFilterCallback(b3OverlapFilterCallback* callback)
|
||||
{
|
||||
m_overlapFilterCallback = callback;
|
||||
}
|
||||
@@ -185,11 +185,11 @@ public:
|
||||
}
|
||||
private:
|
||||
|
||||
btBroadphasePair* internalAddPair(int proxy0,int proxy1);
|
||||
b3BroadphasePair* internalAddPair(int proxy0,int proxy1);
|
||||
|
||||
void growTables();
|
||||
|
||||
SIMD_FORCE_INLINE bool equalsPair(const btBroadphasePair& pair, int proxyId1, int proxyId2)
|
||||
SIMD_FORCE_INLINE bool equalsPair(const b3BroadphasePair& pair, int proxyId1, int proxyId2)
|
||||
{
|
||||
return pair.x == proxyId1 && pair.y == proxyId2;
|
||||
}
|
||||
@@ -230,28 +230,28 @@ private:
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE btBroadphasePair* internalFindPair(int proxy0, int proxy1, int hash)
|
||||
SIMD_FORCE_INLINE b3BroadphasePair* internalFindPair(int proxy0, int proxy1, int hash)
|
||||
{
|
||||
int proxyId1 = proxy0;
|
||||
int proxyId2 = proxy1;
|
||||
#if 0 // wrong, 'equalsPair' use unsorted uids, copy-past devil striked again. Nat.
|
||||
if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);
|
||||
b3Swap(proxyId1, proxyId2);
|
||||
#endif
|
||||
|
||||
int index = m_hashTable[hash];
|
||||
|
||||
while( index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false)
|
||||
while( index != B3_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false)
|
||||
{
|
||||
index = m_next[index];
|
||||
}
|
||||
|
||||
if ( index == BT_NULL_PAIR )
|
||||
if ( index == B3_NULL_PAIR )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
btAssert(index < m_overlappingPairArray.size());
|
||||
b3Assert(index < m_overlappingPairArray.size());
|
||||
|
||||
return &m_overlappingPairArray[index];
|
||||
}
|
||||
@@ -261,33 +261,33 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
/* virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)
|
||||
/* virtual void setInternalGhostPairCallback(b3OverlappingPairCallback* ghostPairCallback)
|
||||
{
|
||||
m_ghostPairCallback = ghostPairCallback;
|
||||
}
|
||||
*/
|
||||
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher);
|
||||
virtual void sortOverlappingPairs(b3Dispatcher* dispatcher);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
b3AlignedObjectArray<int> m_hashTable;
|
||||
b3AlignedObjectArray<int> m_next;
|
||||
// btOverlappingPairCallback* m_ghostPairCallback;
|
||||
// b3OverlappingPairCallback* m_ghostPairCallback;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
///btSortedOverlappingPairCache maintains the objects with overlapping AABB
|
||||
///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase
|
||||
class btSortedOverlappingPairCache : public b3OverlappingPairCache
|
||||
///b3SortedOverlappingPairCache maintains the objects with overlapping AABB
|
||||
///Typically managed by the Broadphase, Axis3Sweep or b3SimpleBroadphase
|
||||
class b3SortedOverlappingPairCache : public b3OverlappingPairCache
|
||||
{
|
||||
protected:
|
||||
//avoid brute-force finding all the time
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
b3BroadphasePairArray m_overlappingPairArray;
|
||||
|
||||
//during the dispatch, check that user doesn't destroy/create proxy
|
||||
bool m_blockedForChanges;
|
||||
@@ -296,29 +296,29 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache
|
||||
bool m_hasDeferredRemoval;
|
||||
|
||||
//if set, use the callback instead of the built in filter in needBroadphaseCollision
|
||||
btOverlapFilterCallback* m_overlapFilterCallback;
|
||||
b3OverlapFilterCallback* m_overlapFilterCallback;
|
||||
|
||||
// btOverlappingPairCallback* m_ghostPairCallback;
|
||||
// b3OverlappingPairCallback* m_ghostPairCallback;
|
||||
|
||||
public:
|
||||
|
||||
btSortedOverlappingPairCache();
|
||||
virtual ~btSortedOverlappingPairCache();
|
||||
b3SortedOverlappingPairCache();
|
||||
virtual ~b3SortedOverlappingPairCache();
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher);
|
||||
virtual void processAllOverlappingPairs(b3OverlapCallback*,b3Dispatcher* dispatcher);
|
||||
|
||||
void* removeOverlappingPair(int proxy0,int proxy1,btDispatcher* dispatcher);
|
||||
void* removeOverlappingPair(int proxy0,int proxy1,b3Dispatcher* dispatcher);
|
||||
|
||||
void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
|
||||
void cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher);
|
||||
|
||||
btBroadphasePair* addOverlappingPair(int proxy0,int proxy1);
|
||||
b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1);
|
||||
|
||||
btBroadphasePair* findPair(int proxy0,int proxy1);
|
||||
b3BroadphasePair* findPair(int proxy0,int proxy1);
|
||||
|
||||
|
||||
void cleanProxyFromPairs(int proxy,btDispatcher* dispatcher);
|
||||
void cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher);
|
||||
|
||||
virtual void removeOverlappingPairsContainingProxy(int proxy,btDispatcher* dispatcher);
|
||||
virtual void removeOverlappingPairsContainingProxy(int proxy,b3Dispatcher* dispatcher);
|
||||
|
||||
|
||||
inline bool needsBroadphaseCollision(int proxy0,int proxy1) const
|
||||
@@ -332,12 +332,12 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache
|
||||
return collides;
|
||||
}
|
||||
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
b3BroadphasePairArray& getOverlappingPairArray()
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
const btBroadphasePairArray& getOverlappingPairArray() const
|
||||
const b3BroadphasePairArray& getOverlappingPairArray() const
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
@@ -345,12 +345,12 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache
|
||||
|
||||
|
||||
|
||||
btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
b3BroadphasePair* getOverlappingPairArrayPtr()
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
|
||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||
const b3BroadphasePair* getOverlappingPairArrayPtr() const
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
@@ -360,12 +360,12 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache
|
||||
return m_overlappingPairArray.size();
|
||||
}
|
||||
|
||||
btOverlapFilterCallback* getOverlapFilterCallback()
|
||||
b3OverlapFilterCallback* getOverlapFilterCallback()
|
||||
{
|
||||
return m_overlapFilterCallback;
|
||||
}
|
||||
|
||||
void setOverlapFilterCallback(btOverlapFilterCallback* callback)
|
||||
void setOverlapFilterCallback(b3OverlapFilterCallback* callback)
|
||||
{
|
||||
m_overlapFilterCallback = callback;
|
||||
}
|
||||
@@ -375,40 +375,40 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache
|
||||
return m_hasDeferredRemoval;
|
||||
}
|
||||
|
||||
/* virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)
|
||||
/* virtual void setInternalGhostPairCallback(b3OverlappingPairCallback* ghostPairCallback)
|
||||
{
|
||||
m_ghostPairCallback = ghostPairCallback;
|
||||
}
|
||||
*/
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher);
|
||||
virtual void sortOverlappingPairs(b3Dispatcher* dispatcher);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
///btNullPairCache skips add/removal of overlapping pairs. Userful for benchmarking and unit testing.
|
||||
class btNullPairCache : public b3OverlappingPairCache
|
||||
///b3NullPairCache skips add/removal of overlapping pairs. Userful for benchmarking and unit testing.
|
||||
class b3NullPairCache : public b3OverlappingPairCache
|
||||
{
|
||||
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
b3BroadphasePairArray m_overlappingPairArray;
|
||||
|
||||
public:
|
||||
|
||||
virtual btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
virtual b3BroadphasePair* getOverlappingPairArrayPtr()
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||
const b3BroadphasePair* getOverlappingPairArrayPtr() const
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
b3BroadphasePairArray& getOverlappingPairArray()
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
virtual void cleanOverlappingPair(btBroadphasePair& /*pair*/,btDispatcher* /*dispatcher*/)
|
||||
virtual void cleanOverlappingPair(b3BroadphasePair& /*pair*/,b3Dispatcher* /*dispatcher*/)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -418,20 +418,20 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void cleanProxyFromPairs(int /*proxy*/,btDispatcher* /*dispatcher*/)
|
||||
virtual void cleanProxyFromPairs(int /*proxy*/,b3Dispatcher* /*dispatcher*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void setOverlapFilterCallback(btOverlapFilterCallback* /*callback*/)
|
||||
virtual void setOverlapFilterCallback(b3OverlapFilterCallback* /*callback*/)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* /*dispatcher*/)
|
||||
virtual void processAllOverlappingPairs(b3OverlapCallback*,b3Dispatcher* /*dispatcher*/)
|
||||
{
|
||||
}
|
||||
|
||||
virtual btBroadphasePair* findPair(int /*proxy0*/, int /*proxy1*/)
|
||||
virtual b3BroadphasePair* findPair(int /*proxy0*/, int /*proxy1*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -441,26 +441,26 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// virtual void setInternalGhostPairCallback(btOverlappingPairCallback* /* ghostPairCallback */)
|
||||
// virtual void setInternalGhostPairCallback(b3OverlappingPairCallback* /* ghostPairCallback */)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
virtual btBroadphasePair* addOverlappingPair(int /*proxy0*/,int /*proxy1*/)
|
||||
virtual b3BroadphasePair* addOverlappingPair(int /*proxy0*/,int /*proxy1*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void* removeOverlappingPair(int /*proxy0*/,int /*proxy1*/,btDispatcher* /*dispatcher*/)
|
||||
virtual void* removeOverlappingPair(int /*proxy0*/,int /*proxy1*/,b3Dispatcher* /*dispatcher*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void removeOverlappingPairsContainingProxy(int /*proxy0*/,btDispatcher* /*dispatcher*/)
|
||||
virtual void removeOverlappingPairsContainingProxy(int /*proxy0*/,b3Dispatcher* /*dispatcher*/)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher)
|
||||
virtual void sortOverlappingPairs(b3Dispatcher* dispatcher)
|
||||
{
|
||||
(void) dispatcher;
|
||||
}
|
||||
@@ -469,6 +469,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif //BT_OVERLAPPING_PAIR_CACHE_H
|
||||
#endif //B3_OVERLAPPING_PAIR_CACHE_H
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef BT_CONTACT4_H
|
||||
#define BT_CONTACT4_H
|
||||
#ifndef B3_CONTACT4_H
|
||||
#define B3_CONTACT4_H
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
|
||||
|
||||
ATTRIBUTE_ALIGNED16(struct) b3Contact4
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
b3Vector3 m_worldPos[4];
|
||||
b3Vector3 m_worldNormal;
|
||||
@@ -27,9 +27,9 @@ ATTRIBUTE_ALIGNED16(struct) b3Contact4
|
||||
int& getBatchIdx() { return m_batchIdx; }
|
||||
const int& getBatchIdx() const { return m_batchIdx; }
|
||||
float getRestituitionCoeff() const { return ((float)m_restituitionCoeffCmp/(float)0xffff); }
|
||||
void setRestituitionCoeff( float c ) { btAssert( c >= 0.f && c <= 1.f ); m_restituitionCoeffCmp = (unsigned short)(c*0xffff); }
|
||||
void setRestituitionCoeff( float c ) { b3Assert( c >= 0.f && c <= 1.f ); m_restituitionCoeffCmp = (unsigned short)(c*0xffff); }
|
||||
float getFrictionCoeff() const { return ((float)m_frictionCoeffCmp/(float)0xffff); }
|
||||
void setFrictionCoeff( float c ) { btAssert( c >= 0.f && c <= 1.f ); m_frictionCoeffCmp = (unsigned short)(c*0xffff); }
|
||||
void setFrictionCoeff( float c ) { b3Assert( c >= 0.f && c <= 1.f ); m_frictionCoeffCmp = (unsigned short)(c*0xffff); }
|
||||
|
||||
float& getNPoints() { return m_worldNormal[3]; }
|
||||
float getNPoints() const { return m_worldNormal[3]; }
|
||||
@@ -39,4 +39,4 @@ ATTRIBUTE_ALIGNED16(struct) b3Contact4
|
||||
bool isInvalid() const { return (getBodyA()==0 || getBodyB()==0); }
|
||||
};
|
||||
|
||||
#endif //BT_CONTACT4_H
|
||||
#endif //B3_CONTACT4_H
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef BT_RIGID_BODY_CL
|
||||
#define BT_RIGID_BODY_CL
|
||||
#ifndef B3_RIGID_BODY_CL
|
||||
#define B3_RIGID_BODY_CL
|
||||
|
||||
#include "Bullet3Common/b3Scalar.h"
|
||||
#include "Bullet3Common/b3Matrix3x3.h"
|
||||
|
||||
ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
b3Vector3 m_pos;
|
||||
b3Quaternion m_quat;
|
||||
@@ -25,11 +25,11 @@ ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL
|
||||
};
|
||||
|
||||
|
||||
struct btInertiaCL
|
||||
struct b3InertiaCL
|
||||
{
|
||||
b3Matrix3x3 m_invInertiaWorld;
|
||||
b3Matrix3x3 m_initInvInertia;
|
||||
};
|
||||
|
||||
|
||||
#endif//BT_RIGID_BODY_CL
|
||||
#endif//B3_RIGID_BODY_CL
|
||||
|
||||
Reference in New Issue
Block a user