rename to b3 convention, to avoid naming conflicts when using in combination with Bullet 2.x

This commit is contained in:
erwincoumans
2013-04-29 15:19:36 -07:00
parent 7366e262fd
commit 55b69201a9
88 changed files with 1682 additions and 1584 deletions

View File

@@ -1,3 +1,17 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B3_BROADPHASE_CALLBACK_H
#define B3_BROADPHASE_CALLBACK_H

View File

@@ -1,6 +1,6 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
@@ -17,38 +17,38 @@ subject to the following restrictions:
#include "b3DynamicBvh.h"
//
typedef b3AlignedObjectArray<b3DbvtNode*> tNodeArray;
typedef b3AlignedObjectArray<const b3DbvtNode*> tConstNodeArray;
typedef b3AlignedObjectArray<b3DbvtNode*> b3NodeArray;
typedef b3AlignedObjectArray<const b3DbvtNode*> b3ConstNodeArray;
//
struct b3DbvtNodeEnumerator : b3DynamicBvh::ICollide
{
tConstNodeArray nodes;
b3ConstNodeArray nodes;
void Process(const b3DbvtNode* n) { nodes.push_back(n); }
};
//
static DBVT_INLINE int indexof(const b3DbvtNode* node)
static B3_DBVT_INLINE int b3IndexOf(const b3DbvtNode* node)
{
return(node->parent->childs[1]==node);
}
//
static DBVT_INLINE b3DbvtVolume merge( const b3DbvtVolume& a,
static B3_DBVT_INLINE b3DbvtVolume b3Merge( const b3DbvtVolume& a,
const b3DbvtVolume& b)
{
#if (DBVT_MERGE_IMPL==DBVT_IMPL_SSE)
ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtAabbMm)]);
#if (B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE)
B3_ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtAabbMm)]);
b3DbvtVolume& res=*(b3DbvtVolume*)locals;
#else
b3DbvtVolume res;
#endif
Merge(a,b,res);
b3Merge(a,b,res);
return(res);
}
// volume+edge lengths
static DBVT_INLINE b3Scalar size(const b3DbvtVolume& a)
static B3_DBVT_INLINE b3Scalar b3Size(const b3DbvtVolume& a)
{
const b3Vector3 edges=a.Lengths();
return( edges.x*edges.y*edges.z+
@@ -56,17 +56,17 @@ static DBVT_INLINE b3Scalar size(const b3DbvtVolume& a)
}
//
static void getmaxdepth(const b3DbvtNode* node,int depth,int& maxdepth)
static void b3GetMaxDepth(const b3DbvtNode* node,int depth,int& maxdepth)
{
if(node->isinternal())
{
getmaxdepth(node->childs[0],depth+1,maxdepth);
getmaxdepth(node->childs[1],depth+1,maxdepth);
b3GetMaxDepth(node->childs[0],depth+1,maxdepth);
b3GetMaxDepth(node->childs[1],depth+1,maxdepth);
} else maxdepth=b3Max(maxdepth,depth);
}
//
static DBVT_INLINE void deletenode( b3DynamicBvh* pdbvt,
static B3_DBVT_INLINE void b3DeleteNode( b3DynamicBvh* pdbvt,
b3DbvtNode* node)
{
b3AlignedFree(pdbvt->m_free);
@@ -74,20 +74,20 @@ static DBVT_INLINE void deletenode( b3DynamicBvh* pdbvt,
}
//
static void recursedeletenode( b3DynamicBvh* pdbvt,
static void b3RecurseDeleteNode( b3DynamicBvh* pdbvt,
b3DbvtNode* node)
{
if(!node->isleaf())
{
recursedeletenode(pdbvt,node->childs[0]);
recursedeletenode(pdbvt,node->childs[1]);
b3RecurseDeleteNode(pdbvt,node->childs[0]);
b3RecurseDeleteNode(pdbvt,node->childs[1]);
}
if(node==pdbvt->m_root) pdbvt->m_root=0;
deletenode(pdbvt,node);
b3DeleteNode(pdbvt,node);
}
//
static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt,
static B3_DBVT_INLINE b3DbvtNode* b3CreateNode( b3DynamicBvh* pdbvt,
b3DbvtNode* parent,
void* data)
{
@@ -103,30 +103,30 @@ static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt,
}
//
static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt,
static B3_DBVT_INLINE b3DbvtNode* b3CreateNode( b3DynamicBvh* pdbvt,
b3DbvtNode* parent,
const b3DbvtVolume& volume,
void* data)
{
b3DbvtNode* node=createnode(pdbvt,parent,data);
b3DbvtNode* node=b3CreateNode(pdbvt,parent,data);
node->volume=volume;
return(node);
}
//
static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt,
static B3_DBVT_INLINE b3DbvtNode* b3CreateNode( b3DynamicBvh* pdbvt,
b3DbvtNode* parent,
const b3DbvtVolume& volume0,
const b3DbvtVolume& volume1,
void* data)
{
b3DbvtNode* node=createnode(pdbvt,parent,data);
Merge(volume0,volume1,node->volume);
b3DbvtNode* node=b3CreateNode(pdbvt,parent,data);
b3Merge(volume0,volume1,node->volume);
return(node);
}
//
static void insertleaf( b3DynamicBvh* pdbvt,
static void b3InsertLeaf( b3DynamicBvh* pdbvt,
b3DbvtNode* root,
b3DbvtNode* leaf)
{
@@ -140,21 +140,21 @@ static void insertleaf( b3DynamicBvh* pdbvt,
if(!root->isleaf())
{
do {
root=root->childs[Select( leaf->volume,
root=root->childs[b3Select( leaf->volume,
root->childs[0]->volume,
root->childs[1]->volume)];
} while(!root->isleaf());
}
b3DbvtNode* prev=root->parent;
b3DbvtNode* node=createnode(pdbvt,prev,leaf->volume,root->volume,0);
b3DbvtNode* node=b3CreateNode(pdbvt,prev,leaf->volume,root->volume,0);
if(prev)
{
prev->childs[indexof(root)] = node;
prev->childs[b3IndexOf(root)] = node;
node->childs[0] = root;root->parent=node;
node->childs[1] = leaf;leaf->parent=node;
do {
if(!prev->volume.Contain(node->volume))
Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
b3Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
else
break;
node=prev;
@@ -170,7 +170,7 @@ static void insertleaf( b3DynamicBvh* pdbvt,
}
//
static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt,
static b3DbvtNode* b3RemoveLeaf( b3DynamicBvh* pdbvt,
b3DbvtNode* leaf)
{
if(leaf==pdbvt->m_root)
@@ -182,17 +182,17 @@ static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt,
{
b3DbvtNode* parent=leaf->parent;
b3DbvtNode* prev=parent->parent;
b3DbvtNode* sibling=parent->childs[1-indexof(leaf)];
b3DbvtNode* sibling=parent->childs[1-b3IndexOf(leaf)];
if(prev)
{
prev->childs[indexof(parent)]=sibling;
prev->childs[b3IndexOf(parent)]=sibling;
sibling->parent=prev;
deletenode(pdbvt,parent);
b3DeleteNode(pdbvt,parent);
while(prev)
{
const b3DbvtVolume pb=prev->volume;
Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
if(NotEqual(pb,prev->volume))
b3Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
if(b3NotEqual(pb,prev->volume))
{
prev=prev->parent;
} else break;
@@ -203,23 +203,23 @@ static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt,
{
pdbvt->m_root=sibling;
sibling->parent=0;
deletenode(pdbvt,parent);
b3DeleteNode(pdbvt,parent);
return(pdbvt->m_root);
}
}
}
//
static void fetchleaves(b3DynamicBvh* pdbvt,
static void b3FetchLeaves(b3DynamicBvh* pdbvt,
b3DbvtNode* root,
tNodeArray& leaves,
b3NodeArray& leaves,
int depth=-1)
{
if(root->isinternal()&&depth)
{
fetchleaves(pdbvt,root->childs[0],leaves,depth-1);
fetchleaves(pdbvt,root->childs[1],leaves,depth-1);
deletenode(pdbvt,root);
b3FetchLeaves(pdbvt,root->childs[0],leaves,depth-1);
b3FetchLeaves(pdbvt,root->childs[1],leaves,depth-1);
b3DeleteNode(pdbvt,root);
}
else
{
@@ -228,9 +228,9 @@ static void fetchleaves(b3DynamicBvh* pdbvt,
}
//
static void split( const tNodeArray& leaves,
tNodeArray& left,
tNodeArray& right,
static void b3Split( const b3NodeArray& leaves,
b3NodeArray& left,
b3NodeArray& right,
const b3Vector3& org,
const b3Vector3& axis)
{
@@ -246,10 +246,10 @@ static void split( const tNodeArray& leaves,
}
//
static b3DbvtVolume bounds( const tNodeArray& leaves)
static b3DbvtVolume b3Bounds( const b3NodeArray& leaves)
{
#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE
ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtVolume)]);
#if B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE
B3_ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtVolume)]);
b3DbvtVolume& volume=*(b3DbvtVolume*)locals;
volume=leaves[0]->volume;
#else
@@ -257,24 +257,24 @@ static b3DbvtVolume bounds( const tNodeArray& leaves)
#endif
for(int i=1,ni=leaves.size();i<ni;++i)
{
Merge(volume,leaves[i]->volume,volume);
b3Merge(volume,leaves[i]->volume,volume);
}
return(volume);
}
//
static void bottomup( b3DynamicBvh* pdbvt,
tNodeArray& leaves)
static void b3BottomUp( b3DynamicBvh* pdbvt,
b3NodeArray& leaves)
{
while(leaves.size()>1)
{
b3Scalar minsize=SIMD_INFINITY;
b3Scalar minsize=B3_INFINITY;
int minidx[2]={-1,-1};
for(int i=0;i<leaves.size();++i)
{
for(int j=i+1;j<leaves.size();++j)
{
const b3Scalar sz=size(merge(leaves[i]->volume,leaves[j]->volume));
const b3Scalar sz=b3Size(b3Merge(leaves[i]->volume,leaves[j]->volume));
if(sz<minsize)
{
minsize = sz;
@@ -284,7 +284,7 @@ static void bottomup( b3DynamicBvh* pdbvt,
}
}
b3DbvtNode* n[] = {leaves[minidx[0]],leaves[minidx[1]]};
b3DbvtNode* p = createnode(pdbvt,0,n[0]->volume,n[1]->volume,0);
b3DbvtNode* p = b3CreateNode(pdbvt,0,n[0]->volume,n[1]->volume,0);
p->childs[0] = n[0];
p->childs[1] = n[1];
n[0]->parent = p;
@@ -296,8 +296,8 @@ static void bottomup( b3DynamicBvh* pdbvt,
}
//
static b3DbvtNode* topdown(b3DynamicBvh* pdbvt,
tNodeArray& leaves,
static b3DbvtNode* b3TopDown(b3DynamicBvh* pdbvt,
b3NodeArray& leaves,
int bu_treshold)
{
static const b3Vector3 axis[]={b3Vector3(1,0,0),
@@ -307,9 +307,9 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt,
{
if(leaves.size()>bu_treshold)
{
const b3DbvtVolume vol=bounds(leaves);
const b3DbvtVolume vol=b3Bounds(leaves);
const b3Vector3 org=vol.Center();
tNodeArray sets[2];
b3NodeArray sets[2];
int bestaxis=-1;
int bestmidp=leaves.size();
int splitcount[3][2]={{0,0},{0,0},{0,0}};
@@ -338,7 +338,7 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt,
{
sets[0].reserve(splitcount[bestaxis][0]);
sets[1].reserve(splitcount[bestaxis][1]);
split(leaves,sets[0],sets[1],org,axis[bestaxis]);
b3Split(leaves,sets[0],sets[1],org,axis[bestaxis]);
}
else
{
@@ -349,16 +349,16 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt,
sets[i&1].push_back(leaves[i]);
}
}
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);
b3DbvtNode* node=b3CreateNode(pdbvt,0,vol,0);
node->childs[0]=b3TopDown(pdbvt,sets[0],bu_treshold);
node->childs[1]=b3TopDown(pdbvt,sets[1],bu_treshold);
node->childs[0]->parent=node;
node->childs[1]->parent=node;
return(node);
}
else
{
bottomup(pdbvt,leaves);
b3BottomUp(pdbvt,leaves);
return(leaves[0]);
}
}
@@ -366,18 +366,18 @@ static b3DbvtNode* topdown(b3DynamicBvh* pdbvt,
}
//
static DBVT_INLINE b3DbvtNode* sort(b3DbvtNode* n,b3DbvtNode*& r)
static B3_DBVT_INLINE b3DbvtNode* b3Sort(b3DbvtNode* n,b3DbvtNode*& r)
{
b3DbvtNode* p=n->parent;
b3Assert(n->isinternal());
if(p>n)
{
const int i=indexof(n);
const int i=b3IndexOf(n);
const int j=1-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;
if(q) q->childs[b3IndexOf(p)]=n; else r=n;
s->parent=n;
p->parent=n;
n->parent=q;
@@ -394,7 +394,7 @@ static DBVT_INLINE b3DbvtNode* sort(b3DbvtNode* n,b3DbvtNode*& r)
}
#if 0
static DBVT_INLINE b3DbvtNode* walkup(b3DbvtNode* n,int count)
static B3_DBVT_INLINE b3DbvtNode* walkup(b3DbvtNode* n,int count)
{
while(n&&(count--)) n=n->parent;
return(n);
@@ -425,7 +425,7 @@ b3DynamicBvh::~b3DynamicBvh()
void b3DynamicBvh::clear()
{
if(m_root)
recursedeletenode(this,m_root);
b3RecurseDeleteNode(this,m_root);
b3AlignedFree(m_free);
m_free=0;
m_lkhd = -1;
@@ -439,10 +439,10 @@ void b3DynamicBvh::optimizeBottomUp()
{
if(m_root)
{
tNodeArray leaves;
b3NodeArray leaves;
leaves.reserve(m_leaves);
fetchleaves(this,m_root,leaves);
bottomup(this,leaves);
b3FetchLeaves(this,m_root,leaves);
b3BottomUp(this,leaves);
m_root=leaves[0];
}
}
@@ -452,10 +452,10 @@ void b3DynamicBvh::optimizeTopDown(int bu_treshold)
{
if(m_root)
{
tNodeArray leaves;
b3NodeArray leaves;
leaves.reserve(m_leaves);
fetchleaves(this,m_root,leaves);
m_root=topdown(this,leaves,bu_treshold);
b3FetchLeaves(this,m_root,leaves);
m_root=b3TopDown(this,leaves,bu_treshold);
}
}
@@ -470,7 +470,7 @@ void b3DynamicBvh::optimizeIncremental(int passes)
unsigned bit=0;
while(node->isinternal())
{
node=sort(node,m_root)->childs[(m_opath>>bit)&1];
node=b3Sort(node,m_root)->childs[(m_opath>>bit)&1];
bit=(bit+1)&(sizeof(unsigned)*8-1);
}
update(node);
@@ -482,8 +482,8 @@ void b3DynamicBvh::optimizeIncremental(int passes)
//
b3DbvtNode* b3DynamicBvh::insert(const b3DbvtVolume& volume,void* data)
{
b3DbvtNode* leaf=createnode(this,0,volume,data);
insertleaf(this,m_root,leaf);
b3DbvtNode* leaf=b3CreateNode(this,0,volume,data);
b3InsertLeaf(this,m_root,leaf);
++m_leaves;
return(leaf);
}
@@ -491,7 +491,7 @@ b3DbvtNode* b3DynamicBvh::insert(const b3DbvtVolume& volume,void* data)
//
void b3DynamicBvh::update(b3DbvtNode* leaf,int lookahead)
{
b3DbvtNode* root=removeleaf(this,leaf);
b3DbvtNode* root=b3RemoveLeaf(this,leaf);
if(root)
{
if(lookahead>=0)
@@ -502,13 +502,13 @@ void b3DynamicBvh::update(b3DbvtNode* leaf,int lookahead)
}
} else root=m_root;
}
insertleaf(this,root,leaf);
b3InsertLeaf(this,root,leaf);
}
//
void b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume)
{
b3DbvtNode* root=removeleaf(this,leaf);
b3DbvtNode* root=b3RemoveLeaf(this,leaf);
if(root)
{
if(m_lkhd>=0)
@@ -520,7 +520,7 @@ void b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume)
} else root=m_root;
}
leaf->volume=volume;
insertleaf(this,root,leaf);
b3InsertLeaf(this,root,leaf);
}
//
@@ -554,8 +554,8 @@ bool b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume,b3Scalar margi
//
void b3DynamicBvh::remove(b3DbvtNode* leaf)
{
removeleaf(this,leaf);
deletenode(this,leaf);
b3RemoveLeaf(this,leaf);
b3DeleteNode(this,leaf);
--m_leaves;
}
@@ -596,7 +596,7 @@ void b3DynamicBvh::clone(b3DynamicBvh& dest,IClone* iclone) const
do {
const int i=stack.size()-1;
const sStkCLN e=stack[i];
b3DbvtNode* n=createnode(&dest,e.parent,e.node->volume,e.node->data);
b3DbvtNode* n=b3CreateNode(&dest,e.parent,e.node->volume,e.node->data);
stack.pop_back();
if(e.parent!=0)
e.parent->childs[i&1]=n;
@@ -619,7 +619,7 @@ void b3DynamicBvh::clone(b3DynamicBvh& dest,IClone* iclone) const
int b3DynamicBvh::maxdepth(const b3DbvtNode* node)
{
int depth=0;
if(node) getmaxdepth(node,1,depth);
if(node) b3GetMaxDepth(node,1,depth);
return(depth);
}
@@ -647,7 +647,7 @@ void b3DynamicBvh::extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray<c
}
//
#if DBVT_ENABLE_BENCHMARK
#if B3_DBVT_ENABLE_BENCHMARK
#include <stdio.h>
#include <stdlib.h>
@@ -692,7 +692,7 @@ struct b3DbvtBenchmark
{
struct NilPolicy : b3DynamicBvh::ICollide
{
NilPolicy() : m_pcount(0),m_depth(-SIMD_INFINITY),m_checksort(true) {}
NilPolicy() : m_pcount(0),m_depth(-B3_INFINITY),m_checksort(true) {}
void Process(const b3DbvtNode*,const b3DbvtNode*) { ++m_pcount; }
void Process(const b3DbvtNode*) { ++m_pcount; }
void Process(const b3DbvtNode*,b3Scalar depth)
@@ -768,7 +768,7 @@ struct b3DbvtBenchmark
{
b3Transform t;
t.setOrigin(RandVector3(cs));
t.setRotation(b3Quaternion(RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2).normalized());
t.setRotation(b3Quaternion(RandUnit()*B3_PI*2,RandUnit()*B3_PI*2,RandUnit()*B3_PI*2).normalized());
return(t);
}
static void RandTree(b3Scalar cs,b3Scalar eb,b3Scalar es,int leaves,b3DynamicBvh& dbvt)
@@ -1168,7 +1168,7 @@ void b3DynamicBvh::benchmark()
for(int i=0;i<cfgBenchmark13_Iterations;++i)
{
static const b3Scalar offset=0;
policy.m_depth=-SIMD_INFINITY;
policy.m_depth=-B3_INFINITY;
dbvt.collideOCL(dbvt.m_root,&vectors[i],&offset,vectors[i],1,policy);
}
const int time=(int)wallclock.getTimeMilliseconds();

View File

@@ -1,11 +1,11 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -28,48 +28,48 @@ subject to the following restrictions:
// Implementation profiles
#define DBVT_IMPL_GENERIC 0 // Generic implementation
#define DBVT_IMPL_SSE 1 // SSE
#define B3_DBVT_IMPL_GENERIC 0 // Generic implementation
#define B3_DBVT_IMPL_SSE 1 // SSE
// Template implementation of ICollide
#ifdef _WIN32
#if (defined (_MSC_VER) && _MSC_VER >= 1400)
#define DBVT_USE_TEMPLATE 1
#define B3_DBVT_USE_TEMPLATE 1
#else
#define DBVT_USE_TEMPLATE 0
#define B3_DBVT_USE_TEMPLATE 0
#endif
#else
#define DBVT_USE_TEMPLATE 0
#define B3_DBVT_USE_TEMPLATE 0
#endif
// Use only intrinsics instead of inline asm
#define DBVT_USE_INTRINSIC_SSE 1
#define B3_DBVT_USE_INTRINSIC_SSE 1
// Using memmov for collideOCL
#define DBVT_USE_MEMMOVE 1
#define B3_DBVT_USE_MEMMOVE 1
// Enable benchmarking code
#define DBVT_ENABLE_BENCHMARK 0
#define B3_DBVT_ENABLE_BENCHMARK 0
// Inlining
#define DBVT_INLINE SIMD_FORCE_INLINE
#define B3_DBVT_INLINE B3_FORCE_INLINE
// Specific methods implementation
//SSE gives errors on a MSVC 7.1
#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
#define B3_DBVT_SELECT_IMPL B3_DBVT_IMPL_SSE
#define B3_DBVT_MERGE_IMPL B3_DBVT_IMPL_SSE
#define B3_DBVT_INT0_IMPL B3_DBVT_IMPL_SSE
#else
#define DBVT_SELECT_IMPL DBVT_IMPL_GENERIC
#define DBVT_MERGE_IMPL DBVT_IMPL_GENERIC
#define DBVT_INT0_IMPL DBVT_IMPL_GENERIC
#define B3_DBVT_SELECT_IMPL B3_DBVT_IMPL_GENERIC
#define B3_DBVT_MERGE_IMPL B3_DBVT_IMPL_GENERIC
#define B3_DBVT_INT0_IMPL B3_DBVT_IMPL_GENERIC
#endif
#if (DBVT_SELECT_IMPL==DBVT_IMPL_SSE)|| \
(DBVT_MERGE_IMPL==DBVT_IMPL_SSE)|| \
(DBVT_INT0_IMPL==DBVT_IMPL_SSE)
#if (B3_DBVT_SELECT_IMPL==B3_DBVT_IMPL_SSE)|| \
(B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE)|| \
(B3_DBVT_INT0_IMPL==B3_DBVT_IMPL_SSE)
#include <emmintrin.h>
#endif
@@ -77,49 +77,49 @@ subject to the following restrictions:
// Auto config and checks
//
#if DBVT_USE_TEMPLATE
#define DBVT_VIRTUAL
#define DBVT_VIRTUAL_DTOR(a)
#define DBVT_PREFIX template <typename T>
#define DBVT_IPOLICY T& policy
#define DBVT_CHECKTYPE static const ICollide& typechecker=*(T*)1;(void)typechecker;
#if B3_DBVT_USE_TEMPLATE
#define B3_DBVT_VIRTUAL
#define B3_DBVT_VIRTUAL_DTOR(a)
#define B3_DBVT_PREFIX template <typename T>
#define B3_DBVT_IPOLICY T& policy
#define B3_DBVT_CHECKTYPE static const ICollide& typechecker=*(T*)1;(void)typechecker;
#else
#define DBVT_VIRTUAL_DTOR(a) virtual ~a() {}
#define DBVT_VIRTUAL virtual
#define DBVT_PREFIX
#define DBVT_IPOLICY ICollide& policy
#define DBVT_CHECKTYPE
#define B3_DBVT_VIRTUAL_DTOR(a) virtual ~a() {}
#define B3_DBVT_VIRTUAL virtual
#define B3_DBVT_PREFIX
#define B3_DBVT_IPOLICY ICollide& policy
#define B3_DBVT_CHECKTYPE
#endif
#if DBVT_USE_MEMMOVE
#if B3_DBVT_USE_MEMMOVE
#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__)
#include <memory.h>
#endif
#include <string.h>
#endif
#ifndef DBVT_USE_TEMPLATE
#error "DBVT_USE_TEMPLATE undefined"
#ifndef B3_DBVT_USE_TEMPLATE
#error "B3_DBVT_USE_TEMPLATE undefined"
#endif
#ifndef DBVT_USE_MEMMOVE
#error "DBVT_USE_MEMMOVE undefined"
#ifndef B3_DBVT_USE_MEMMOVE
#error "B3_DBVT_USE_MEMMOVE undefined"
#endif
#ifndef DBVT_ENABLE_BENCHMARK
#error "DBVT_ENABLE_BENCHMARK undefined"
#ifndef B3_DBVT_ENABLE_BENCHMARK
#error "B3_DBVT_ENABLE_BENCHMARK undefined"
#endif
#ifndef DBVT_SELECT_IMPL
#error "DBVT_SELECT_IMPL undefined"
#ifndef B3_DBVT_SELECT_IMPL
#error "B3_DBVT_SELECT_IMPL undefined"
#endif
#ifndef DBVT_MERGE_IMPL
#error "DBVT_MERGE_IMPL undefined"
#ifndef B3_DBVT_MERGE_IMPL
#error "B3_DBVT_MERGE_IMPL undefined"
#endif
#ifndef DBVT_INT0_IMPL
#error "DBVT_INT0_IMPL undefined"
#ifndef B3_DBVT_INT0_IMPL
#error "B3_DBVT_INT0_IMPL undefined"
#endif
//
@@ -129,43 +129,43 @@ subject to the following restrictions:
/* 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); }
B3_DBVT_INLINE b3Vector3 Center() const { return((mi+mx)/2); }
B3_DBVT_INLINE b3Vector3 Lengths() const { return(mx-mi); }
B3_DBVT_INLINE b3Vector3 Extents() const { return((mx-mi)/2); }
B3_DBVT_INLINE const b3Vector3& Mins() const { return(mi); }
B3_DBVT_INLINE const b3Vector3& Maxs() const { return(mx); }
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 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 b3DbvtAabbMm& a,
B3_DBVT_INLINE void Expand(const b3Vector3& e);
B3_DBVT_INLINE void SignedExpand(const b3Vector3& e);
B3_DBVT_INLINE bool Contain(const b3DbvtAabbMm& a) const;
B3_DBVT_INLINE int Classify(const b3Vector3& n,b3Scalar o,int s) const;
B3_DBVT_INLINE b3Scalar ProjectMinimum(const b3Vector3& v,unsigned signs) const;
B3_DBVT_INLINE friend bool b3Intersect( const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b);
DBVT_INLINE friend bool Intersect( const b3DbvtAabbMm& a,
B3_DBVT_INLINE friend bool b3Intersect( const b3DbvtAabbMm& a,
const b3Vector3& b);
DBVT_INLINE friend b3Scalar Proximity( const b3DbvtAabbMm& a,
B3_DBVT_INLINE friend b3Scalar b3Proximity( const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b);
DBVT_INLINE friend int Select( const b3DbvtAabbMm& o,
B3_DBVT_INLINE friend int b3Select( const b3DbvtAabbMm& o,
const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b);
DBVT_INLINE friend void Merge( const b3DbvtAabbMm& a,
B3_DBVT_INLINE friend void b3Merge( const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b,
b3DbvtAabbMm& r);
DBVT_INLINE friend bool NotEqual( const b3DbvtAabbMm& a,
B3_DBVT_INLINE friend bool b3NotEqual( const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b);
DBVT_INLINE b3Vector3& tMins() { return(mi); }
DBVT_INLINE b3Vector3& tMaxs() { return(mx); }
B3_DBVT_INLINE b3Vector3& tMins() { return(mi); }
B3_DBVT_INLINE b3Vector3& tMaxs() { return(mx); }
private:
DBVT_INLINE void AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const;
B3_DBVT_INLINE void AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const;
private:
b3Vector3 mi,mx;
};
@@ -178,8 +178,8 @@ struct b3DbvtNode
{
b3DbvtVolume volume;
b3DbvtNode* parent;
DBVT_INLINE bool isleaf() const { return(childs[1]==0); }
DBVT_INLINE bool isinternal() const { return(!isleaf()); }
B3_DBVT_INLINE bool isleaf() const { return(childs[1]==0); }
B3_DBVT_INLINE bool isinternal() const { return(!isleaf()); }
union
{
b3DbvtNode* childs[2];
@@ -226,12 +226,12 @@ struct b3DynamicBvh
/* ICollide */
struct ICollide
{
DBVT_VIRTUAL_DTOR(ICollide)
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); }
B3_DBVT_VIRTUAL_DTOR(ICollide)
B3_DBVT_VIRTUAL void Process(const b3DbvtNode*,const b3DbvtNode*) {}
B3_DBVT_VIRTUAL void Process(const b3DbvtNode*) {}
B3_DBVT_VIRTUAL void Process(const b3DbvtNode* n,b3Scalar) { Process(n); }
B3_DBVT_VIRTUAL bool Descent(const b3DbvtNode*) { return(true); }
B3_DBVT_VIRTUAL bool AllLeaves(const b3DbvtNode*) { return(true); }
};
/* IWriter */
struct IWriter
@@ -250,8 +250,8 @@ struct b3DynamicBvh
// Constants
enum {
SIMPLE_STACKSIZE = 64,
DOUBLE_STACKSIZE = SIMPLE_STACKSIZE*2
B3_SIMPLE_STACKSIZE = 64,
B3_DOUBLE_STACKSIZE = B3_SIMPLE_STACKSIZE*2
};
// Fields
@@ -286,55 +286,55 @@ struct b3DynamicBvh
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
#if B3_DBVT_ENABLE_BENCHMARK
static void benchmark();
#else
static void benchmark(){}
#endif
// DBVT_IPOLICY must support ICollide policy/interface
DBVT_PREFIX
// B3_DBVT_IPOLICY must support ICollide policy/interface
B3_DBVT_PREFIX
static void enumNodes( const b3DbvtNode* root,
DBVT_IPOLICY);
DBVT_PREFIX
B3_DBVT_IPOLICY);
B3_DBVT_PREFIX
static void enumLeaves( const b3DbvtNode* root,
DBVT_IPOLICY);
DBVT_PREFIX
B3_DBVT_IPOLICY);
B3_DBVT_PREFIX
void collideTT( const b3DbvtNode* root0,
const b3DbvtNode* root1,
DBVT_IPOLICY);
B3_DBVT_IPOLICY);
DBVT_PREFIX
B3_DBVT_PREFIX
void collideTTpersistentStack( const b3DbvtNode* root0,
const b3DbvtNode* root1,
DBVT_IPOLICY);
B3_DBVT_IPOLICY);
#if 0
DBVT_PREFIX
B3_DBVT_PREFIX
void collideTT( const b3DbvtNode* root0,
const b3DbvtNode* root1,
const b3Transform& xform,
DBVT_IPOLICY);
DBVT_PREFIX
B3_DBVT_IPOLICY);
B3_DBVT_PREFIX
void collideTT( const b3DbvtNode* root0,
const b3Transform& xform0,
const b3DbvtNode* root1,
const b3Transform& xform1,
DBVT_IPOLICY);
B3_DBVT_IPOLICY);
#endif
DBVT_PREFIX
B3_DBVT_PREFIX
void collideTV( const b3DbvtNode* root,
const b3DbvtVolume& volume,
DBVT_IPOLICY) const;
B3_DBVT_IPOLICY) const;
///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
B3_DBVT_PREFIX
static void rayTest( const b3DbvtNode* root,
const b3Vector3& rayFrom,
const b3Vector3& rayTo,
DBVT_IPOLICY);
B3_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
B3_DBVT_PREFIX
void rayTestInternal( const b3DbvtNode* root,
const b3Vector3& rayFrom,
const b3Vector3& rayTo,
@@ -343,27 +343,27 @@ struct b3DynamicBvh
b3Scalar lambda_max,
const b3Vector3& aabbMin,
const b3Vector3& aabbMax,
DBVT_IPOLICY) const;
B3_DBVT_IPOLICY) const;
DBVT_PREFIX
B3_DBVT_PREFIX
static void collideKDOP(const b3DbvtNode* root,
const b3Vector3* normals,
const b3Scalar* offsets,
int count,
DBVT_IPOLICY);
DBVT_PREFIX
B3_DBVT_IPOLICY);
B3_DBVT_PREFIX
static void collideOCL( const b3DbvtNode* root,
const b3Vector3* normals,
const b3Scalar* offsets,
const b3Vector3& sortaxis,
int count,
DBVT_IPOLICY,
B3_DBVT_IPOLICY,
bool fullsort=true);
DBVT_PREFIX
B3_DBVT_PREFIX
static void collideTU( const b3DbvtNode* root,
DBVT_IPOLICY);
B3_DBVT_IPOLICY);
// Helpers
static DBVT_INLINE int nearest(const int* i,const b3DynamicBvh::sStkNPS* a,b3Scalar v,int l,int h)
static B3_DBVT_INLINE int nearest(const int* i,const b3DynamicBvh::sStkNPS* a,b3Scalar v,int l,int h)
{
int m=0;
while(l<h)
@@ -373,7 +373,7 @@ struct b3DynamicBvh
}
return(h);
}
static DBVT_INLINE int allocate( b3AlignedObjectArray<int>& ifree,
static B3_DBVT_INLINE int allocate( b3AlignedObjectArray<int>& ifree,
b3AlignedObjectArray<sStkNPS>& stock,
const sStkNPS& value)
{
@@ -442,13 +442,13 @@ inline b3DbvtAabbMm b3DbvtAabbMm::FromPoints(const b3Vector3** ppts,int n)
}
//
DBVT_INLINE void b3DbvtAabbMm::Expand(const b3Vector3& e)
B3_DBVT_INLINE void b3DbvtAabbMm::Expand(const b3Vector3& e)
{
mi-=e;mx+=e;
}
//
DBVT_INLINE void b3DbvtAabbMm::SignedExpand(const b3Vector3& e)
B3_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 b3DbvtAabbMm::SignedExpand(const b3Vector3& e)
}
//
DBVT_INLINE bool b3DbvtAabbMm::Contain(const b3DbvtAabbMm& a) const
B3_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 b3DbvtAabbMm::Contain(const b3DbvtAabbMm& a) const
}
//
DBVT_INLINE int b3DbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) const
B3_DBVT_INLINE int b3DbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) const
{
b3Vector3 pi,px;
switch(s)
@@ -495,7 +495,7 @@ DBVT_INLINE int b3DbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) con
}
//
DBVT_INLINE b3Scalar b3DbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned signs) const
B3_DBVT_INLINE b3Scalar b3DbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned signs) const
{
const b3Vector3* b[]={&mx,&mi};
const b3Vector3 p( b[(signs>>0)&1]->x,
@@ -505,7 +505,7 @@ DBVT_INLINE b3Scalar b3DbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned si
}
//
DBVT_INLINE void b3DbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const
B3_DBVT_INLINE void b3DbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const
{
for(int i=0;i<3;++i)
{
@@ -517,10 +517,10 @@ DBVT_INLINE void b3DbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scala
}
//
DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a,
B3_DBVT_INLINE bool b3Intersect( const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b)
{
#if DBVT_INT0_IMPL == DBVT_IMPL_SSE
#if B3_DBVT_INT0_IMPL == B3_DBVT_IMPL_SSE
const __m128 rt(_mm_or_ps( _mm_cmplt_ps(_mm_load_ps(b.mx),_mm_load_ps(a.mi)),
_mm_cmplt_ps(_mm_load_ps(a.mx),_mm_load_ps(b.mi))));
#if defined (_WIN32)
@@ -542,7 +542,7 @@ DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a,
//
DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a,
B3_DBVT_INLINE bool b3Intersect( const b3DbvtAabbMm& a,
const b3Vector3& b)
{
return( (b.x>=a.mi.x)&&
@@ -561,7 +561,7 @@ DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a,
//
DBVT_INLINE b3Scalar Proximity( const b3DbvtAabbMm& a,
B3_DBVT_INLINE b3Scalar b3Proximity( const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b)
{
const b3Vector3 d=(a.mi+a.mx)-(b.mi+b.mx);
@@ -571,19 +571,19 @@ DBVT_INLINE b3Scalar Proximity( const b3DbvtAabbMm& a,
//
DBVT_INLINE int Select( const b3DbvtAabbMm& o,
B3_DBVT_INLINE int b3Select( const b3DbvtAabbMm& o,
const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b)
{
#if DBVT_SELECT_IMPL == DBVT_IMPL_SSE
#if B3_DBVT_SELECT_IMPL == B3_DBVT_IMPL_SSE
#if defined (_WIN32)
static ATTRIBUTE_ALIGNED16(const unsigned __int32) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff};
static B3_ATTRIBUTE_ALIGNED16(const unsigned __int32) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff};
#else
static ATTRIBUTE_ALIGNED16(const unsigned int) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x00000000 /*0x7fffffff*/};
static B3_ATTRIBUTE_ALIGNED16(const unsigned int) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x00000000 /*0x7fffffff*/};
#endif
///@todo: the intrinsic version is 11% slower
#if DBVT_USE_INTRINSIC_SSE
#if B3_DBVT_USE_INTRINSIC_SSE
union b3SSEUnion ///NOTE: if we use more intrinsics, move b3SSEUnion into the LinearMath directory
{
@@ -614,7 +614,7 @@ DBVT_INLINE int Select( const b3DbvtAabbMm& o,
return tmp.ints[0]&1;
#else
ATTRIBUTE_ALIGNED16(__int32 r[1]);
B3_ATTRIBUTE_ALIGNED16(__int32 r[1]);
__asm
{
mov eax,o
@@ -645,16 +645,16 @@ DBVT_INLINE int Select( const b3DbvtAabbMm& o,
return(r[0]&1);
#endif
#else
return(Proximity(o,a)<Proximity(o,b)?0:1);
return(b3Proximity(o,a)<b3Proximity(o,b)?0:1);
#endif
}
//
DBVT_INLINE void Merge( const b3DbvtAabbMm& a,
B3_DBVT_INLINE void b3Merge( const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b,
b3DbvtAabbMm& r)
{
#if DBVT_MERGE_IMPL==DBVT_IMPL_SSE
#if B3_DBVT_MERGE_IMPL==B3_DBVT_IMPL_SSE
__m128 ami(_mm_load_ps(a.mi));
__m128 amx(_mm_load_ps(a.mx));
__m128 bmi(_mm_load_ps(b.mi));
@@ -673,7 +673,7 @@ DBVT_INLINE void Merge( const b3DbvtAabbMm& a,
}
//
DBVT_INLINE bool NotEqual( const b3DbvtAabbMm& a,
B3_DBVT_INLINE bool b3NotEqual( const b3DbvtAabbMm& a,
const b3DbvtAabbMm& b)
{
return( (a.mi.x!=b.mi.x)||
@@ -689,11 +689,11 @@ DBVT_INLINE bool NotEqual( const b3DbvtAabbMm& a,
//
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::enumNodes( const b3DbvtNode* root,
DBVT_IPOLICY)
B3_DBVT_IPOLICY)
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
policy.Process(root);
if(root->isinternal())
{
@@ -703,11 +703,11 @@ inline void b3DynamicBvh::enumNodes( const b3DbvtNode* root,
}
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::enumLeaves( const b3DbvtNode* root,
DBVT_IPOLICY)
B3_DBVT_IPOLICY)
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root->isinternal())
{
enumLeaves(root->childs[0],policy);
@@ -720,18 +720,18 @@ inline void b3DynamicBvh::enumLeaves( const b3DbvtNode* root,
}
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
const b3DbvtNode* root1,
DBVT_IPOLICY)
B3_DBVT_IPOLICY)
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root0&&root1)
{
int depth=1;
int treshold=DOUBLE_STACKSIZE-4;
int treshold=B3_DOUBLE_STACKSIZE-4;
b3AlignedObjectArray<sStkNN> stkStack;
stkStack.resize(DOUBLE_STACKSIZE);
stkStack.resize(B3_DOUBLE_STACKSIZE);
stkStack[0]=sStkNN(root0,root1);
do {
sStkNN p=stkStack[--depth];
@@ -749,7 +749,7 @@ inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[1]);
}
}
else if(Intersect(p.a->volume,p.b->volume))
else if(b3Intersect(p.a->volume,p.b->volume))
{
if(p.a->isinternal())
{
@@ -785,18 +785,18 @@ inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0,
const b3DbvtNode* root1,
DBVT_IPOLICY)
B3_DBVT_IPOLICY)
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root0&&root1)
{
int depth=1;
int treshold=DOUBLE_STACKSIZE-4;
int treshold=B3_DOUBLE_STACKSIZE-4;
m_stkStack.resize(DOUBLE_STACKSIZE);
m_stkStack.resize(B3_DOUBLE_STACKSIZE);
m_stkStack[0]=sStkNN(root0,root1);
do {
sStkNN p=m_stkStack[--depth];
@@ -814,7 +814,7 @@ inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0,
m_stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[1]);
}
}
else if(Intersect(p.a->volume,p.b->volume))
else if(b3Intersect(p.a->volume,p.b->volume))
{
if(p.a->isinternal())
{
@@ -850,23 +850,23 @@ inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0,
#if 0
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
const b3DbvtNode* root1,
const b3Transform& xform,
DBVT_IPOLICY)
B3_DBVT_IPOLICY)
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root0&&root1)
{
int depth=1;
int treshold=DOUBLE_STACKSIZE-4;
int treshold=B3_DOUBLE_STACKSIZE-4;
b3AlignedObjectArray<sStkNN> stkStack;
stkStack.resize(DOUBLE_STACKSIZE);
stkStack.resize(B3_DOUBLE_STACKSIZE);
stkStack[0]=sStkNN(root0,root1);
do {
sStkNN p=stkStack[--depth];
if(Intersect(p.a->volume,p.b->volume,xform))
if(b3Intersect(p.a->volume,p.b->volume,xform))
{
if(depth>treshold)
{
@@ -905,12 +905,12 @@ inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
}
}
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
const b3Transform& xform0,
const b3DbvtNode* root1,
const b3Transform& xform1,
DBVT_IPOLICY)
B3_DBVT_IPOLICY)
{
const b3Transform xform=xform0.inverse()*xform1;
collideTT(root0,root1,xform,policy);
@@ -918,23 +918,23 @@ inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0,
#endif
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::collideTV( const b3DbvtNode* root,
const b3DbvtVolume& vol,
DBVT_IPOLICY) const
B3_DBVT_IPOLICY) const
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root)
{
ATTRIBUTE_ALIGNED16(b3DbvtVolume) volume(vol);
B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) volume(vol);
b3AlignedObjectArray<const b3DbvtNode*> stack;
stack.resize(0);
stack.reserve(SIMPLE_STACKSIZE);
stack.reserve(B3_SIMPLE_STACKSIZE);
stack.push_back(root);
do {
const b3DbvtNode* n=stack[stack.size()-1];
stack.pop_back();
if(Intersect(n->volume,volume))
if(b3Intersect(n->volume,volume))
{
if(n->isinternal())
{
@@ -950,7 +950,7 @@ inline void b3DynamicBvh::collideTV( const b3DbvtNode* root,
}
}
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root,
const b3Vector3& rayFrom,
const b3Vector3& rayTo,
@@ -959,18 +959,18 @@ inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root,
b3Scalar lambda_max,
const b3Vector3& aabbMin,
const b3Vector3& aabbMax,
DBVT_IPOLICY) const
B3_DBVT_IPOLICY) const
{
(void) rayTo;
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root)
{
b3Vector3 resultNormal;
int depth=1;
int treshold=DOUBLE_STACKSIZE-2;
int treshold=B3_DOUBLE_STACKSIZE-2;
b3AlignedObjectArray<const b3DbvtNode*>& stack = m_rayTestStack;
stack.resize(DOUBLE_STACKSIZE);
stack.resize(B3_DOUBLE_STACKSIZE);
stack[0]=root;
b3Vector3 bounds[2];
do
@@ -1003,13 +1003,13 @@ inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root,
}
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::rayTest( const b3DbvtNode* root,
const b3Vector3& rayFrom,
const b3Vector3& rayTo,
DBVT_IPOLICY)
B3_DBVT_IPOLICY)
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root)
{
b3Vector3 rayDir = (rayTo-rayFrom);
@@ -1029,9 +1029,9 @@ inline void b3DynamicBvh::rayTest( const b3DbvtNode* root,
b3AlignedObjectArray<const b3DbvtNode*> stack;
int depth=1;
int treshold=DOUBLE_STACKSIZE-2;
int treshold=B3_DOUBLE_STACKSIZE-2;
stack.resize(DOUBLE_STACKSIZE);
stack.resize(B3_DOUBLE_STACKSIZE);
stack[0]=root;
b3Vector3 bounds[2];
do {
@@ -1072,14 +1072,14 @@ inline void b3DynamicBvh::rayTest( const b3DbvtNode* root,
}
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root,
const b3Vector3* normals,
const b3Scalar* offsets,
int count,
DBVT_IPOLICY)
B3_DBVT_IPOLICY)
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root)
{
const int inside=(1<<count)-1;
@@ -1092,7 +1092,7 @@ inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root,
((normals[i].y>=0)?2:0)+
((normals[i].z>=0)?4:0);
}
stack.reserve(SIMPLE_STACKSIZE);
stack.reserve(B3_SIMPLE_STACKSIZE);
stack.push_back(sStkNP(root,0));
do {
sStkNP se=stack[stack.size()-1];
@@ -1127,16 +1127,16 @@ inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root,
}
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root,
const b3Vector3* normals,
const b3Scalar* offsets,
const b3Vector3& sortaxis,
int count,
DBVT_IPOLICY,
B3_DBVT_IPOLICY,
bool fsort)
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root)
{
const unsigned srtsgns=(sortaxis[0]>=0?1:0)+
@@ -1154,9 +1154,9 @@ inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root,
((normals[i].y>=0)?2:0)+
((normals[i].z>=0)?4:0);
}
stock.reserve(SIMPLE_STACKSIZE);
stack.reserve(SIMPLE_STACKSIZE);
ifree.reserve(SIMPLE_STACKSIZE);
stock.reserve(B3_SIMPLE_STACKSIZE);
stack.reserve(B3_SIMPLE_STACKSIZE);
ifree.reserve(B3_SIMPLE_STACKSIZE);
stack.push_back(allocate(ifree,stock,sStkNPS(root,0,root->volume.ProjectMinimum(sortaxis,srtsgns))));
do {
const int id=stack[stack.size()-1];
@@ -1193,7 +1193,7 @@ inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root,
/* Insert 0 */
j=nearest(&stack[0],&stock[0],nes[q].value,0,stack.size());
stack.push_back(0);
#if DBVT_USE_MEMMOVE
#if B3_DBVT_USE_MEMMOVE
memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
#else
for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
@@ -1202,7 +1202,7 @@ inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root,
/* Insert 1 */
j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size());
stack.push_back(0);
#if DBVT_USE_MEMMOVE
#if B3_DBVT_USE_MEMMOVE
memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
#else
for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
@@ -1225,15 +1225,15 @@ inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root,
}
//
DBVT_PREFIX
B3_DBVT_PREFIX
inline void b3DynamicBvh::collideTU( const b3DbvtNode* root,
DBVT_IPOLICY)
B3_DBVT_IPOLICY)
{
DBVT_CHECKTYPE
B3_DBVT_CHECKTYPE
if(root)
{
b3AlignedObjectArray<const b3DbvtNode*> stack;
stack.reserve(SIMPLE_STACKSIZE);
stack.reserve(B3_SIMPLE_STACKSIZE);
stack.push_back(root);
do {
const b3DbvtNode* n=stack[stack.size()-1];
@@ -1253,18 +1253,18 @@ inline void b3DynamicBvh::collideTU( const b3DbvtNode* root,
// PP Cleanup
//
#undef DBVT_USE_MEMMOVE
#undef DBVT_USE_TEMPLATE
#undef DBVT_VIRTUAL_DTOR
#undef DBVT_VIRTUAL
#undef DBVT_PREFIX
#undef DBVT_IPOLICY
#undef DBVT_CHECKTYPE
#undef DBVT_IMPL_GENERIC
#undef DBVT_IMPL_SSE
#undef DBVT_USE_INTRINSIC_SSE
#undef DBVT_SELECT_IMPL
#undef DBVT_MERGE_IMPL
#undef DBVT_INT0_IMPL
#undef B3_DBVT_USE_MEMMOVE
#undef B3_DBVT_USE_TEMPLATE
#undef B3_DBVT_VIRTUAL_DTOR
#undef B3_DBVT_VIRTUAL
#undef B3_DBVT_PREFIX
#undef B3_DBVT_IPOLICY
#undef B3_DBVT_CHECKTYPE
#undef B3_DBVT_IMPL_GENERIC
#undef B3_DBVT_IMPL_SSE
#undef B3_DBVT_USE_INTRINSIC_SSE
#undef B3_DBVT_SELECT_IMPL
#undef B3_DBVT_MERGE_IMPL
#undef B3_DBVT_INT0_IMPL
#endif

View File

@@ -1,11 +1,11 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -22,18 +22,18 @@ subject to the following restrictions:
// Profiling
//
#if DBVT_BP_PROFILE||DBVT_BP_ENABLE_BENCHMARK
#if B3_DBVT_BP_PROFILE||B3_DBVT_BP_ENABLE_BENCHMARK
#include <stdio.h>
#endif
#if DBVT_BP_PROFILE
struct ProfileScope
#if B3_DBVT_BP_PROFILE
struct b3ProfileScope
{
__forceinline ProfileScope(b3Clock& clock,unsigned long& value) :
__forceinline b3ProfileScope(b3Clock& clock,unsigned long& value) :
m_clock(&clock),m_value(&value),m_base(clock.getTimeMicroseconds())
{
}
__forceinline ~ProfileScope()
__forceinline ~b3ProfileScope()
{
(*m_value)+=m_clock->getTimeMicroseconds()-m_base;
}
@@ -41,9 +41,9 @@ struct ProfileScope
unsigned long* m_value;
unsigned long m_base;
};
#define SPC(_value_) ProfileScope spc_scope(m_clock,_value_)
#define b3SPC(_value_) b3ProfileScope spc_scope(m_clock,_value_)
#else
#define SPC(_value_)
#define b3SPC(_value_)
#endif
//
@@ -52,7 +52,7 @@ struct ProfileScope
//
template <typename T>
static inline void listappend(T* item,T*& list)
static inline void b3ListAppend(T* item,T*& list)
{
item->links[0]=0;
item->links[1]=list;
@@ -62,7 +62,7 @@ static inline void listappend(T* item,T*& list)
//
template <typename T>
static inline void listremove(T* item,T*& list)
static inline void b3ListRemove(T* item,T*& list)
{
if(item->links[0]) item->links[0]->links[1]=item->links[1]; else list=item->links[1];
if(item->links[1]) item->links[1]->links[0]=item->links[0];
@@ -70,7 +70,7 @@ static inline void listremove(T* item,T*& list)
//
template <typename T>
static inline int listcount(T* root)
static inline int b3ListCount(T* root)
{
int n=0;
while(root) { ++n;root=root->links[1]; }
@@ -79,7 +79,7 @@ static inline int listcount(T* root)
//
template <typename T>
static inline void clear(T& value)
static inline void b3Clear(T& value)
{
static const struct ZeroDummy : T {} zerodummy;
value=zerodummy;
@@ -101,7 +101,7 @@ struct b3DbvtTreeCollider : b3DynamicBvh::ICollide
{
b3DbvtProxy* pa=(b3DbvtProxy*)na->data;
b3DbvtProxy* pb=(b3DbvtProxy*)nb->data;
#if DBVT_BP_SORTPAIRS
#if B3_DBVT_BP_SORTPAIRS
if(pa->m_uniqueId>pb->m_uniqueId)
b3Swap(pa,pb);
#endif
@@ -143,8 +143,8 @@ b3DynamicBvhBroadphase::b3DynamicBvhBroadphase(int proxyCapacity, b3OverlappingP
{
m_stageRoots[i]=0;
}
#if DBVT_BP_PROFILE
clear(m_profiling);
#if B3_DBVT_BP_PROFILE
b3Clear(m_profiling);
#endif
m_proxies.resize(proxyCapacity);
}
@@ -178,7 +178,7 @@ b3BroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabb
proxy->stage = m_stageCurrent;
proxy->m_uniqueId = objectId;
proxy->leaf = m_sets[0].insert(aabb,proxy);
listappend(proxy,m_stageRoots[m_stageCurrent]);
b3ListAppend(proxy,m_stageRoots[m_stageCurrent]);
if(!m_deferedcollide)
{
b3DbvtTreeCollider collider(this);
@@ -198,7 +198,7 @@ void b3DynamicBvhBroadphase::destroyProxy( b3BroadphaseProxy* absproxy,
m_sets[1].remove(proxy->leaf);
else
m_sets[0].remove(proxy->leaf);
listremove(proxy,m_stageRoots[proxy->stage]);
b3ListRemove(proxy,m_stageRoots[proxy->stage]);
m_paircache->removeOverlappingPairsContainingProxy(proxy->getUid(),dispatcher);
m_needcleanup=true;
@@ -270,7 +270,7 @@ void b3DynamicBvhBroadphase::aabbTest(const b3Vector3& aabbMin,const b3Vector3&
{
BroadphaseAabbTester callback(aabbCallback);
const ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds=b3DbvtVolume::FromMM(aabbMin,aabbMax);
const B3_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);
@@ -286,9 +286,9 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy,
b3Dispatcher* /*dispatcher*/)
{
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
#if DBVT_BP_PREVENTFALSEUPDATE
if(NotEqual(aabb,proxy->leaf->volume))
B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
#if B3_DBVT_BP_PREVENTFALSEUPDATE
if(b3NotEqual(aabb,proxy->leaf->volume))
#endif
{
bool docollide=false;
@@ -301,7 +301,7 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy,
else
{/* dynamic set */
++m_updates_call;
if(Intersect(proxy->leaf->volume,aabb))
if(b3Intersect(proxy->leaf->volume,aabb))
{/* Moving */
const b3Vector3 delta=aabbMin-proxy->m_aabbMin;
@@ -310,8 +310,8 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy,
if(delta[1]<0) velocity[1]=-velocity[1];
if(delta[2]<0) velocity[2]=-velocity[2];
if (
#ifdef DBVT_BP_MARGIN
m_sets[0].update(proxy->leaf,aabb,velocity,DBVT_BP_MARGIN)
#ifdef B3_DBVT_BP_MARGIN
m_sets[0].update(proxy->leaf,aabb,velocity,B3_DBVT_BP_MARGIN)
#else
m_sets[0].update(proxy->leaf,aabb,velocity)
#endif
@@ -328,11 +328,11 @@ void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy,
docollide=true;
}
}
listremove(proxy,m_stageRoots[proxy->stage]);
b3ListRemove(proxy,m_stageRoots[proxy->stage]);
proxy->m_aabbMin = aabbMin;
proxy->m_aabbMax = aabbMax;
proxy->stage = m_stageCurrent;
listappend(proxy,m_stageRoots[m_stageCurrent]);
b3ListAppend(proxy,m_stageRoots[m_stageCurrent]);
if(docollide)
{
m_needcleanup=true;
@@ -354,7 +354,7 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* abspr
b3Dispatcher* /*dispatcher*/)
{
b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy;
ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax);
bool docollide=false;
if(proxy->stage==STAGECOUNT)
{/* fixed -> dynamic set */
@@ -370,11 +370,11 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* abspr
++m_updates_done;
docollide=true;
}
listremove(proxy,m_stageRoots[proxy->stage]);
b3ListRemove(proxy,m_stageRoots[proxy->stage]);
proxy->m_aabbMin = aabbMin;
proxy->m_aabbMax = aabbMax;
proxy->stage = m_stageCurrent;
listappend(proxy,m_stageRoots[m_stageCurrent]);
b3ListAppend(proxy,m_stageRoots[m_stageCurrent]);
if(docollide)
{
m_needcleanup=true;
@@ -391,22 +391,22 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* abspr
void b3DynamicBvhBroadphase::calculateOverlappingPairs(b3Dispatcher* dispatcher)
{
collide(dispatcher);
#if DBVT_BP_PROFILE
if(0==(m_pid%DBVT_BP_PROFILING_RATE))
#if B3_DBVT_BP_PROFILE
if(0==(m_pid%B3_DBVT_BP_PROFILING_RATE))
{
printf("fixed(%u) dynamics(%u) pairs(%u)\r\n",m_sets[1].m_leaves,m_sets[0].m_leaves,m_paircache->getNumOverlappingPairs());
unsigned int total=m_profiling.m_total;
if(total<=0) total=1;
printf("ddcollide: %u%% (%uus)\r\n",(50+m_profiling.m_ddcollide*100)/total,m_profiling.m_ddcollide/DBVT_BP_PROFILING_RATE);
printf("fdcollide: %u%% (%uus)\r\n",(50+m_profiling.m_fdcollide*100)/total,m_profiling.m_fdcollide/DBVT_BP_PROFILING_RATE);
printf("cleanup: %u%% (%uus)\r\n",(50+m_profiling.m_cleanup*100)/total,m_profiling.m_cleanup/DBVT_BP_PROFILING_RATE);
printf("total: %uus\r\n",total/DBVT_BP_PROFILING_RATE);
printf("ddcollide: %u%% (%uus)\r\n",(50+m_profiling.m_ddcollide*100)/total,m_profiling.m_ddcollide/B3_DBVT_BP_PROFILING_RATE);
printf("fdcollide: %u%% (%uus)\r\n",(50+m_profiling.m_fdcollide*100)/total,m_profiling.m_fdcollide/B3_DBVT_BP_PROFILING_RATE);
printf("cleanup: %u%% (%uus)\r\n",(50+m_profiling.m_cleanup*100)/total,m_profiling.m_cleanup/B3_DBVT_BP_PROFILING_RATE);
printf("total: %uus\r\n",total/B3_DBVT_BP_PROFILING_RATE);
const unsigned long sum=m_profiling.m_ddcollide+
m_profiling.m_fdcollide+
m_profiling.m_cleanup;
printf("leaked: %u%% (%uus)\r\n",100-((50+sum*100)/total),(total-sum)/DBVT_BP_PROFILING_RATE);
printf("job counts: %u%%\r\n",(m_profiling.m_jobcount*100)/((m_sets[0].m_leaves+m_sets[1].m_leaves)*DBVT_BP_PROFILING_RATE));
clear(m_profiling);
printf("leaked: %u%% (%uus)\r\n",100-((50+sum*100)/total),(total-sum)/B3_DBVT_BP_PROFILING_RATE);
printf("job counts: %u%%\r\n",(m_profiling.m_jobcount*100)/((m_sets[0].m_leaves+m_sets[1].m_leaves)*B3_DBVT_BP_PROFILING_RATE));
b3Clear(m_profiling);
m_clock.reset();
}
#endif
@@ -451,7 +451,7 @@ void b3DynamicBvhBroadphase::performDeferredRemoval(b3Dispatcher* dispatcher)
//important to perform AABB check that is consistent with the broadphase
b3DbvtProxy* pa=&m_proxies[pair.x];
b3DbvtProxy* pb=&m_proxies[pair.y];
bool hasOverlap = Intersect(pa->leaf->volume,pb->leaf->volume);
bool hasOverlap = b3Intersect(pa->leaf->volume,pb->leaf->volume);
if (hasOverlap)
{
@@ -504,7 +504,7 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher)
SPC(m_profiling.m_total);
b3SPC(m_profiling.m_total);
/* optimize */
m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100);
if(m_fixedleft)
@@ -521,16 +521,16 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher)
b3DbvtTreeCollider collider(this);
do {
b3DbvtProxy* next=current->links[1];
listremove(current,m_stageRoots[current->stage]);
listappend(current,m_stageRoots[STAGECOUNT]);
#if DBVT_BP_ACCURATESLEEPING
b3ListRemove(current,m_stageRoots[current->stage]);
b3ListAppend(current,m_stageRoots[STAGECOUNT]);
#if B3_DBVT_BP_ACCURATESLEEPING
m_paircache->removeOverlappingPairsContainingProxy(current,dispatcher);
collider.proxy=current;
b3DynamicBvh::collideTV(m_sets[0].m_root,current->aabb,collider);
b3DynamicBvh::collideTV(m_sets[1].m_root,current->aabb,collider);
#endif
m_sets[0].remove(current->leaf);
ATTRIBUTE_ALIGNED16(b3DbvtVolume) curAabb=b3DbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax);
B3_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;
@@ -543,19 +543,19 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher)
b3DbvtTreeCollider collider(this);
if(m_deferedcollide)
{
SPC(m_profiling.m_fdcollide);
b3SPC(m_profiling.m_fdcollide);
m_sets[0].collideTTpersistentStack(m_sets[0].m_root,m_sets[1].m_root,collider);
}
if(m_deferedcollide)
{
SPC(m_profiling.m_ddcollide);
b3SPC(m_profiling.m_ddcollide);
m_sets[0].collideTTpersistentStack(m_sets[0].m_root,m_sets[0].m_root,collider);
}
}
/* clean up */
if(m_needcleanup)
{
SPC(m_profiling.m_cleanup);
b3SPC(m_profiling.m_cleanup);
b3BroadphasePairArray& pairs=m_paircache->getOverlappingPairArray();
if(pairs.size()>0)
{
@@ -566,9 +566,9 @@ void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher)
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(!b3Intersect(pa->leaf->volume,pb->leaf->volume))
{
#if DBVT_BP_SORTPAIRS
#if B3_DBVT_BP_SORTPAIRS
if(pa->m_uniqueId>pb->m_uniqueId)
b3Swap(pa,pb);
#endif
@@ -613,10 +613,10 @@ const b3OverlappingPairCache* b3DynamicBvhBroadphase::getOverlappingPairCache()
void b3DynamicBvhBroadphase::getBroadphaseAabb(b3Vector3& aabbMin,b3Vector3& aabbMax) const
{
ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds;
B3_ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds;
if(!m_sets[0].empty())
if(!m_sets[1].empty()) Merge( m_sets[0].m_root->volume,
if(!m_sets[1].empty()) b3Merge( m_sets[0].m_root->volume,
m_sets[1].m_root->volume,bounds);
else
bounds=m_sets[0].m_root->volume;
@@ -663,7 +663,7 @@ void b3DynamicBvhBroadphase::printStats()
{}
//
#if DBVT_BP_ENABLE_BENCHMARK
#if B3_DBVT_BP_ENABLE_BENCHMARK
struct b3BroadphaseBenchmark
{
@@ -788,7 +788,7 @@ void b3DynamicBvhBroadphase::benchmark(b3BroadphaseInterface* pbi)
*/
#endif
#if DBVT_BP_PROFILE
#undef SPC
#if B3_DBVT_BP_PROFILE
#undef b3SPC
#endif

View File

@@ -1,11 +1,11 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -27,22 +27,22 @@ subject to the following restrictions:
// Compile time config
//
#define DBVT_BP_PROFILE 0
//#define DBVT_BP_SORTPAIRS 1
#define DBVT_BP_PREVENTFALSEUPDATE 0
#define DBVT_BP_ACCURATESLEEPING 0
#define DBVT_BP_ENABLE_BENCHMARK 0
#define DBVT_BP_MARGIN (b3Scalar)0.05
#define B3_DBVT_BP_PROFILE 0
//#define B3_DBVT_BP_SORTPAIRS 1
#define B3_DBVT_BP_PREVENTFALSEUPDATE 0
#define B3_DBVT_BP_ACCURATESLEEPING 0
#define B3_DBVT_BP_ENABLE_BENCHMARK 0
#define B3_DBVT_BP_MARGIN (b3Scalar)0.05
#if DBVT_BP_PROFILE
#define DBVT_BP_PROFILING_RATE 256
#if B3_DBVT_BP_PROFILE
#define B3_DBVT_BP_PROFILING_RATE 256
#include "LinearMath/b3Quickprof.h"
#endif
ATTRIBUTE_ALIGNED16(struct) b3BroadphaseProxy
B3_ATTRIBUTE_ALIGNED16(struct) b3BroadphaseProxy
{
B3_DECLARE_ALIGNED_ALLOCATOR();
@@ -69,7 +69,7 @@ B3_DECLARE_ALIGNED_ALLOCATOR();
b3Vector3 m_aabbMin;
b3Vector3 m_aabbMax;
SIMD_FORCE_INLINE int getUid() const
B3_FORCE_INLINE int getUid() const
{
return m_uniqueId;
}
@@ -148,7 +148,7 @@ struct b3DynamicBvhBroadphase
bool m_releasepaircache; // Release pair cache on delete
bool m_deferedcollide; // Defere dynamic/static collision to collide call
bool m_needcleanup; // Need to run cleanup?
#if DBVT_BP_PROFILE
#if B3_DBVT_BP_PROFILE
b3Clock m_clock;
struct {
unsigned long m_total;

View File

@@ -1,3 +1,18 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B3_OVERLAPPING_PAIR_H
#define B3_OVERLAPPING_PAIR_H
@@ -36,7 +51,7 @@ class b3BroadphasePairSortPredicate
}
};
SIMD_FORCE_INLINE bool operator==(const b3BroadphasePair& a, const b3BroadphasePair& b)
B3_FORCE_INLINE bool operator==(const b3BroadphasePair& a, const b3BroadphasePair& b)
{
return (a.x == b.x ) && (a.y == b.y );
}

View File

@@ -1,11 +1,11 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -23,11 +23,10 @@ subject to the following restrictions:
#include <stdio.h>
int gOverlappingPairs = 0;
int gRemovePairs =0;
int gAddedPairs =0;
int gFindPairs =0;
int b3g_overlappingPairs = 0;
int b3g_removePairs =0;
int b3g_addedPairs =0;
int b3g_findPairs =0;
@@ -136,7 +135,7 @@ void b3HashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro
b3BroadphasePair* b3HashedOverlappingPairCache::findPair(int proxy0, int proxy1)
{
gFindPairs++;
b3g_findPairs++;
if(proxy0 >proxy1)
b3Swap(proxy0,proxy1);
int proxyId1 = proxy0;
@@ -274,7 +273,7 @@ b3BroadphasePair* b3HashedOverlappingPairCache::internalAddPair(int proxy0, int
void* b3HashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1,b3Dispatcher* dispatcher)
{
gRemovePairs++;
b3g_removePairs++;
if(proxy0>proxy1)
b3Swap(proxy0,proxy1);
int proxyId1 = proxy0;
@@ -387,7 +386,7 @@ void b3HashedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback*
{
removeOverlappingPair(pair->x,pair->y,dispatcher);
gOverlappingPairs--;
b3g_overlappingPairs--;
} else
{
i++;
@@ -440,7 +439,7 @@ void* b3SortedOverlappingPairCache::removeOverlappingPair(int proxy0,int proxy1,
int findIndex = m_overlappingPairArray.findLinearSearch(findPair);
if (findIndex < m_overlappingPairArray.size())
{
gOverlappingPairs--;
b3g_overlappingPairs--;
b3BroadphasePair& pair = m_overlappingPairArray[findIndex];
cleanOverlappingPair(pair,dispatcher);
@@ -475,8 +474,8 @@ b3BroadphasePair* b3SortedOverlappingPairCache::addOverlappingPair(int proxy0,in
b3BroadphasePair* pair = new (mem) b3BroadphasePair(proxy0,proxy1);
gOverlappingPairs++;
gAddedPairs++;
b3g_overlappingPairs++;
b3g_addedPairs++;
// if (m_ghostPairCallback)
// m_ghostPairCallback->addOverlappingPair(proxy0, proxy1);
@@ -532,7 +531,7 @@ void b3SortedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback*
pair->y = -1;
m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
m_overlappingPairArray.pop_back();
gOverlappingPairs--;
b3g_overlappingPairs--;
} else
{
i++;
@@ -565,7 +564,7 @@ void b3SortedOverlappingPairCache::cleanOverlappingPair(b3BroadphasePair& pair,b
pair.m_algorithm->~b3CollisionAlgorithm();
dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
pair.m_algorithm=0;
gRemovePairs--;
b3g_removePairs--;
}
}
*/

View File

@@ -1,11 +1,11 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
@@ -49,9 +49,9 @@ struct b3OverlapFilterCallback
extern int gRemovePairs;
extern int gAddedPairs;
extern int gFindPairs;
extern int b3g_removePairs;
extern int b3g_addedPairs;
extern int b3g_findPairs;
const int B3_NULL_PAIR=0xffffffff;
@@ -110,7 +110,7 @@ public:
virtual void* removeOverlappingPair(int proxy0,int proxy1,b3Dispatcher* dispatcher);
SIMD_FORCE_INLINE bool needsBroadphaseCollision(int proxy0,int proxy1) const
B3_FORCE_INLINE bool needsBroadphaseCollision(int proxy0,int proxy1) const
{
if (m_overlapFilterCallback)
return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
@@ -125,7 +125,7 @@ public:
// no new pair is created and the old one is returned.
virtual b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1)
{
gAddedPairs++;
b3g_addedPairs++;
if (!needsBroadphaseCollision(proxy0,proxy1))
return 0;
@@ -189,7 +189,7 @@ private:
void growTables();
SIMD_FORCE_INLINE bool equalsPair(const b3BroadphasePair& pair, int proxyId1, int proxyId2)
B3_FORCE_INLINE bool equalsPair(const b3BroadphasePair& pair, int proxyId1, int proxyId2)
{
return pair.x == proxyId1 && pair.y == proxyId2;
}
@@ -197,7 +197,7 @@ private:
/*
// Thomas Wang's hash, see: http://www.concentric.net/~Ttwang/tech/inthash.htm
// This assumes proxyId1 and proxyId2 are 16-bit.
SIMD_FORCE_INLINE int getHash(int proxyId1, int proxyId2)
B3_FORCE_INLINE int getHash(int proxyId1, int proxyId2)
{
int key = (proxyId2 << 16) | proxyId1;
key = ~key + (key << 15);
@@ -212,7 +212,7 @@ private:
SIMD_FORCE_INLINE unsigned int getHash(unsigned int proxyId1, unsigned int proxyId2)
B3_FORCE_INLINE unsigned int getHash(unsigned int proxyId1, unsigned int proxyId2)
{
int key = static_cast<int>(((unsigned int)proxyId1) | (((unsigned int)proxyId2) <<16));
// Thomas Wang's hash
@@ -230,7 +230,7 @@ private:
SIMD_FORCE_INLINE b3BroadphasePair* internalFindPair(int proxy0, int proxy1, int hash)
B3_FORCE_INLINE b3BroadphasePair* internalFindPair(int proxy0, int proxy1, int hash)
{
int proxyId1 = proxy0;
int proxyId2 = proxy1;

View File

@@ -1,10 +1,25 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B3_CONTACT4_H
#define B3_CONTACT4_H
#include "Bullet3Common/b3Vector3.h"
ATTRIBUTE_ALIGNED16(struct) b3Contact4
B3_ATTRIBUTE_ALIGNED16(struct) b3Contact4
{
B3_DECLARE_ALIGNED_ALLOCATOR();

View File

@@ -1,10 +1,25 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B3_RIGID_BODY_CL
#define B3_RIGID_BODY_CL
#include "Bullet3Common/b3Scalar.h"
#include "Bullet3Common/b3Matrix3x3.h"
ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL
B3_ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL
{
B3_DECLARE_ALIGNED_ALLOCATOR();