|
|
|
|
@@ -30,11 +30,13 @@ subject to the following restrictions:
|
|
|
|
|
|
|
|
|
|
#ifdef DBVT_USE_TEMPLATE
|
|
|
|
|
#define DBVT_VIRTUAL
|
|
|
|
|
#define DBVT_VIRTUAL_DESTRUCTOR(a)
|
|
|
|
|
#define DBVT_PREFIX template <typename T>
|
|
|
|
|
#define DBVT_IPOLICY T& policy
|
|
|
|
|
#define DBVT_CHECKTYPE static const ICollide& typechecker=*(T*)0;
|
|
|
|
|
#else
|
|
|
|
|
#define DBVT_VIRTUAL virtual
|
|
|
|
|
#define DBVT_VIRTUAL_DESTRUCTOR(a) virtual ~a() {}
|
|
|
|
|
#define DBVT_VIRTUAL virtual
|
|
|
|
|
#define DBVT_PREFIX
|
|
|
|
|
#define DBVT_IPOLICY ICollide& policy
|
|
|
|
|
#define DBVT_CHECKTYPE
|
|
|
|
|
@@ -110,13 +112,13 @@ struct btDbvt
|
|
|
|
|
struct sStkNP
|
|
|
|
|
{
|
|
|
|
|
const Node* node;
|
|
|
|
|
unsigned mask;
|
|
|
|
|
int mask;
|
|
|
|
|
sStkNP(const Node* n,unsigned m) : node(n),mask(m) {}
|
|
|
|
|
};
|
|
|
|
|
struct sStkNPS
|
|
|
|
|
{
|
|
|
|
|
const Node* node;
|
|
|
|
|
unsigned mask;
|
|
|
|
|
int mask;
|
|
|
|
|
btScalar value;
|
|
|
|
|
sStkNPS(const Node* n,unsigned m,btScalar v) : node(n),mask(m),value(v) {}
|
|
|
|
|
};
|
|
|
|
|
@@ -125,6 +127,7 @@ struct btDbvt
|
|
|
|
|
/* ICollide */
|
|
|
|
|
struct ICollide
|
|
|
|
|
{
|
|
|
|
|
DBVT_VIRTUAL_DESTRUCTOR(ICollide)
|
|
|
|
|
DBVT_VIRTUAL void Process(const Node*,const Node*) {}
|
|
|
|
|
DBVT_VIRTUAL void Process(const Node*) {}
|
|
|
|
|
DBVT_VIRTUAL bool Descent(const Node*) { return(true); }
|
|
|
|
|
@@ -133,6 +136,7 @@ struct btDbvt
|
|
|
|
|
/* IWriter */
|
|
|
|
|
struct IWriter
|
|
|
|
|
{
|
|
|
|
|
virtual ~IWriter() {}
|
|
|
|
|
virtual void Prepare(const Node* root,int numnodes)=0;
|
|
|
|
|
virtual void WriteNode(const Node*,int index,int parent,int child0,int child1)=0;
|
|
|
|
|
virtual void WriteLeaf(const Node*,int index,int parent)=0;
|
|
|
|
|
@@ -178,27 +182,27 @@ struct btDbvt
|
|
|
|
|
const Node* root1,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
static void collideTV( const Node* root,
|
|
|
|
|
const Volume& volume,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
static void collideRAY( const Node* root,
|
|
|
|
|
const btVector3& origin,
|
|
|
|
|
const btVector3& direction,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
static void collideKDOP(const Node* root,
|
|
|
|
|
const btVector3* normals,
|
|
|
|
|
const btScalar* offsets,
|
|
|
|
|
int count,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
static void collideOCL( const Node* root,
|
|
|
|
|
const btVector3* normals,
|
|
|
|
|
const btScalar* offsets,
|
|
|
|
|
const btVector3& sortaxis,
|
|
|
|
|
int count,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
static void collideTV( const Node* root,
|
|
|
|
|
const Volume& volume,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
static void collideRAY( const Node* root,
|
|
|
|
|
const btVector3& origin,
|
|
|
|
|
const btVector3& direction,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
static void collideKDOP(const Node* root,
|
|
|
|
|
const btVector3* normals,
|
|
|
|
|
const btScalar* offsets,
|
|
|
|
|
int count,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
static void collideOCL( const Node* root,
|
|
|
|
|
const btVector3* normals,
|
|
|
|
|
const btScalar* offsets,
|
|
|
|
|
const btVector3& sortaxis,
|
|
|
|
|
int count,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
static void collideTU( const Node* root,
|
|
|
|
|
DBVT_IPOLICY);
|
|
|
|
|
@@ -454,93 +458,93 @@ inline void btDbvt::collideTT( const Node* root0,
|
|
|
|
|
DBVT_IPOLICY)
|
|
|
|
|
{
|
|
|
|
|
DBVT_CHECKTYPE
|
|
|
|
|
if(root0&&root1)
|
|
|
|
|
{
|
|
|
|
|
btAlignedObjectArray<sStkNN> stack;
|
|
|
|
|
stack.reserve(DOUBLE_STACKSIZE);
|
|
|
|
|
stack.push_back(sStkNN(root0,root1));
|
|
|
|
|
do {
|
|
|
|
|
sStkNN p=stack[stack.size()-1];
|
|
|
|
|
stack.pop_back();
|
|
|
|
|
if(p.a==p.b)
|
|
|
|
|
{
|
|
|
|
|
if(p.a->isinternal())
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.a->childs[0]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[1],p.a->childs[1]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.a->childs[1]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(Intersect(p.a->volume,p.b->volume))
|
|
|
|
|
{
|
|
|
|
|
if(p.a->isinternal())
|
|
|
|
|
{
|
|
|
|
|
if(p.b->isinternal())
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.b->childs[0]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[1],p.b->childs[0]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.b->childs[1]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[1],p.b->childs[1]));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.b));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[1],p.b));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(p.b->isinternal())
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(sStkNN(p.a,p.b->childs[0]));
|
|
|
|
|
stack.push_back(sStkNN(p.a,p.b->childs[1]));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
policy.Process(p.a,p.b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} while(stack.size()>0);
|
|
|
|
|
if(root0&&root1)
|
|
|
|
|
{
|
|
|
|
|
btAlignedObjectArray<sStkNN> stack;
|
|
|
|
|
stack.reserve(DOUBLE_STACKSIZE);
|
|
|
|
|
stack.push_back(sStkNN(root0,root1));
|
|
|
|
|
do {
|
|
|
|
|
sStkNN p=stack[stack.size()-1];
|
|
|
|
|
stack.pop_back();
|
|
|
|
|
if(p.a==p.b)
|
|
|
|
|
{
|
|
|
|
|
if(p.a->isinternal())
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.a->childs[0]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[1],p.a->childs[1]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.a->childs[1]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(Intersect(p.a->volume,p.b->volume))
|
|
|
|
|
{
|
|
|
|
|
if(p.a->isinternal())
|
|
|
|
|
{
|
|
|
|
|
if(p.b->isinternal())
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.b->childs[0]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[1],p.b->childs[0]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.b->childs[1]));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[1],p.b->childs[1]));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[0],p.b));
|
|
|
|
|
stack.push_back(sStkNN(p.a->childs[1],p.b));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(p.b->isinternal())
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(sStkNN(p.a,p.b->childs[0]));
|
|
|
|
|
stack.push_back(sStkNN(p.a,p.b->childs[1]));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
policy.Process(p.a,p.b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} while(stack.size()>0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
inline void btDbvt::collideTV( const Node* root,
|
|
|
|
|
const Volume& volume,
|
|
|
|
|
DBVT_IPOLICY)
|
|
|
|
|
{
|
|
|
|
|
DBVT_CHECKTYPE
|
|
|
|
|
if(root)
|
|
|
|
|
{
|
|
|
|
|
btAlignedObjectArray<const Node*> stack;
|
|
|
|
|
stack.reserve(SIMPLE_STACKSIZE);
|
|
|
|
|
stack.push_back(root);
|
|
|
|
|
do {
|
|
|
|
|
const Node* n=stack[stack.size()-1];
|
|
|
|
|
stack.pop_back();
|
|
|
|
|
if(Intersect(n->volume,volume))
|
|
|
|
|
{
|
|
|
|
|
if(n->isinternal())
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(n->childs[0]);
|
|
|
|
|
stack.push_back(n->childs[1]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
policy.Process(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} while(stack.size()>0);
|
|
|
|
|
}
|
|
|
|
|
inline void btDbvt::collideTV( const Node* root,
|
|
|
|
|
const Volume& volume,
|
|
|
|
|
DBVT_IPOLICY)
|
|
|
|
|
{
|
|
|
|
|
DBVT_CHECKTYPE
|
|
|
|
|
if(root)
|
|
|
|
|
{
|
|
|
|
|
btAlignedObjectArray<const Node*> stack;
|
|
|
|
|
stack.reserve(SIMPLE_STACKSIZE);
|
|
|
|
|
stack.push_back(root);
|
|
|
|
|
do {
|
|
|
|
|
const Node* n=stack[stack.size()-1];
|
|
|
|
|
stack.pop_back();
|
|
|
|
|
if(Intersect(n->volume,volume))
|
|
|
|
|
{
|
|
|
|
|
if(n->isinternal())
|
|
|
|
|
{
|
|
|
|
|
stack.push_back(n->childs[0]);
|
|
|
|
|
stack.push_back(n->childs[1]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
policy.Process(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} while(stack.size()>0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
inline void btDbvt::collideRAY( const Node* root,
|
|
|
|
|
const btVector3& origin,
|
|
|
|
|
const btVector3& direction,
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
inline void btDbvt::collideRAY( const Node* root,
|
|
|
|
|
const btVector3& origin,
|
|
|
|
|
const btVector3& direction,
|
|
|
|
|
DBVT_IPOLICY)
|
|
|
|
|
{
|
|
|
|
|
DBVT_CHECKTYPE
|
|
|
|
|
@@ -576,11 +580,11 @@ if(root)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
inline void btDbvt::collideKDOP(const Node* root,
|
|
|
|
|
const btVector3* normals,
|
|
|
|
|
const btScalar* offsets,
|
|
|
|
|
int count,
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
inline void btDbvt::collideKDOP(const Node* root,
|
|
|
|
|
const btVector3* normals,
|
|
|
|
|
const btScalar* offsets,
|
|
|
|
|
int count,
|
|
|
|
|
DBVT_IPOLICY)
|
|
|
|
|
{
|
|
|
|
|
DBVT_CHECKTYPE
|
|
|
|
|
@@ -631,12 +635,12 @@ if(root)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
inline void btDbvt::collideOCL( const Node* root,
|
|
|
|
|
const btVector3* normals,
|
|
|
|
|
const btScalar* offsets,
|
|
|
|
|
const btVector3& sortaxis,
|
|
|
|
|
int count,
|
|
|
|
|
DBVT_PREFIX
|
|
|
|
|
inline void btDbvt::collideOCL( const Node* root,
|
|
|
|
|
const btVector3* normals,
|
|
|
|
|
const btScalar* offsets,
|
|
|
|
|
const btVector3& sortaxis,
|
|
|
|
|
int count,
|
|
|
|
|
DBVT_IPOLICY)
|
|
|
|
|
{
|
|
|
|
|
DBVT_CHECKTYPE
|
|
|
|
|
@@ -734,6 +738,7 @@ if(root)
|
|
|
|
|
#ifdef DBVT_USE_TEMPLATE
|
|
|
|
|
#undef DBVT_USE_TEMPLATE
|
|
|
|
|
#endif
|
|
|
|
|
#undef DBVT_VIRTUAL_DESTRUCTOR
|
|
|
|
|
#undef DBVT_VIRTUAL
|
|
|
|
|
#undef DBVT_PREFIX
|
|
|
|
|
#undef DBVT_IPOLICY
|
|
|
|
|
|