Autoformat selection for soft body, btDbvt related classes (no code change, just layout using Visual Studio)
This commit is contained in:
1 parent
cac172d422
commit
60ce828419
20 files changed
+3941
-3941
No files matched your search
+394
-394
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -26,19 +26,19 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#if DBVT_BP_PROFILE
|
#if DBVT_BP_PROFILE
|
||||||
struct ProfileScope
|
struct ProfileScope
|
||||||
{
|
{
|
||||||
__forceinline ProfileScope(btClock& clock,unsigned long& value) :
|
__forceinline ProfileScope(btClock& clock,unsigned long& value) :
|
||||||
m_clock(&clock),m_value(&value),m_base(clock.getTimeMicroseconds())
|
m_clock(&clock),m_value(&value),m_base(clock.getTimeMicroseconds())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
__forceinline ~ProfileScope()
|
__forceinline ~ProfileScope()
|
||||||
{
|
{
|
||||||
(*m_value)+=m_clock->getTimeMicroseconds()-m_base;
|
(*m_value)+=m_clock->getTimeMicroseconds()-m_base;
|
||||||
}
|
}
|
||||||
btClock* m_clock;
|
btClock* m_clock;
|
||||||
unsigned long* m_value;
|
unsigned long* m_value;
|
||||||
unsigned long m_base;
|
unsigned long m_base;
|
||||||
};
|
};
|
||||||
#define SPC(_value_) ProfileScope spc_scope(m_clock,_value_)
|
#define SPC(_value_) ProfileScope spc_scope(m_clock,_value_)
|
||||||
#else
|
#else
|
||||||
#define SPC(_value_)
|
#define SPC(_value_)
|
||||||
@@ -52,35 +52,35 @@ struct ProfileScope
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
static inline void listappend(T* item,T*& list)
|
static inline void listappend(T* item,T*& list)
|
||||||
{
|
{
|
||||||
item->links[0]=0;
|
item->links[0]=0;
|
||||||
item->links[1]=list;
|
item->links[1]=list;
|
||||||
if(list) list->links[0]=item;
|
if(list) list->links[0]=item;
|
||||||
list=item;
|
list=item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline void listremove(T* item,T*& list)
|
static inline void listremove(T* item,T*& list)
|
||||||
{
|
{
|
||||||
if(item->links[0]) item->links[0]->links[1]=item->links[1]; else list=item->links[1];
|
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];
|
if(item->links[1]) item->links[1]->links[0]=item->links[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline int listcount(T* root)
|
static inline int listcount(T* root)
|
||||||
{
|
{
|
||||||
int n=0;
|
int n=0;
|
||||||
while(root) { ++n;root=root->links[1]; }
|
while(root) { ++n;root=root->links[1]; }
|
||||||
return(n);
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline void clear(T& value)
|
static inline void clear(T& value)
|
||||||
{
|
{
|
||||||
static const struct ZeroDummy : T {} zerodummy;
|
static const struct ZeroDummy : T {} zerodummy;
|
||||||
value=zerodummy;
|
value=zerodummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -90,25 +90,25 @@ value=zerodummy;
|
|||||||
/* Tree collider */
|
/* Tree collider */
|
||||||
struct btDbvtTreeCollider : btDbvt::ICollide
|
struct btDbvtTreeCollider : btDbvt::ICollide
|
||||||
{
|
{
|
||||||
btDbvtBroadphase* pbp;
|
btDbvtBroadphase* pbp;
|
||||||
btDbvtProxy* proxy;
|
btDbvtProxy* proxy;
|
||||||
btDbvtTreeCollider(btDbvtBroadphase* p) : pbp(p) {}
|
btDbvtTreeCollider(btDbvtBroadphase* p) : pbp(p) {}
|
||||||
void Process(const btDbvtNode* na,const btDbvtNode* nb)
|
void Process(const btDbvtNode* na,const btDbvtNode* nb)
|
||||||
{
|
{
|
||||||
if(na!=nb)
|
if(na!=nb)
|
||||||
{
|
{
|
||||||
btDbvtProxy* pa=(btDbvtProxy*)na->data;
|
btDbvtProxy* pa=(btDbvtProxy*)na->data;
|
||||||
btDbvtProxy* pb=(btDbvtProxy*)nb->data;
|
btDbvtProxy* pb=(btDbvtProxy*)nb->data;
|
||||||
#if DBVT_BP_SORTPAIRS
|
#if DBVT_BP_SORTPAIRS
|
||||||
if(pa>pb) btSwap(pa,pb);
|
if(pa>pb) btSwap(pa,pb);
|
||||||
#endif
|
#endif
|
||||||
pbp->m_paircache->addOverlappingPair(pa,pb);
|
pbp->m_paircache->addOverlappingPair(pa,pb);
|
||||||
++pbp->m_newpairs;
|
++pbp->m_newpairs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Process(const btDbvtNode* n)
|
void Process(const btDbvtNode* n)
|
||||||
{
|
{
|
||||||
Process(n,proxy->leaf);
|
Process(n,proxy->leaf);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -119,88 +119,88 @@ void Process(const btDbvtNode* n)
|
|||||||
//
|
//
|
||||||
btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCache* paircache)
|
btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCache* paircache)
|
||||||
{
|
{
|
||||||
m_deferedcollide = false;
|
m_deferedcollide = false;
|
||||||
m_needcleanup = true;
|
m_needcleanup = true;
|
||||||
m_releasepaircache = (paircache!=0)?false:true;
|
m_releasepaircache = (paircache!=0)?false:true;
|
||||||
m_prediction = 1/(btScalar)2;
|
m_prediction = 1/(btScalar)2;
|
||||||
m_stageCurrent = 0;
|
m_stageCurrent = 0;
|
||||||
m_fixedleft = 0;
|
m_fixedleft = 0;
|
||||||
m_fupdates = 1;
|
m_fupdates = 1;
|
||||||
m_dupdates = 0;
|
m_dupdates = 0;
|
||||||
m_cupdates = 10;
|
m_cupdates = 10;
|
||||||
m_newpairs = 1;
|
m_newpairs = 1;
|
||||||
m_updates_call = 0;
|
m_updates_call = 0;
|
||||||
m_updates_done = 0;
|
m_updates_done = 0;
|
||||||
m_updates_ratio = 0;
|
m_updates_ratio = 0;
|
||||||
m_paircache = paircache?
|
m_paircache = paircache?
|
||||||
paircache :
|
paircache :
|
||||||
new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
|
new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
|
||||||
m_gid = 0;
|
m_gid = 0;
|
||||||
m_pid = 0;
|
m_pid = 0;
|
||||||
m_cid = 0;
|
m_cid = 0;
|
||||||
for(int i=0;i<=STAGECOUNT;++i)
|
for(int i=0;i<=STAGECOUNT;++i)
|
||||||
{
|
{
|
||||||
m_stageRoots[i]=0;
|
m_stageRoots[i]=0;
|
||||||
}
|
}
|
||||||
#if DBVT_BP_PROFILE
|
#if DBVT_BP_PROFILE
|
||||||
clear(m_profiling);
|
clear(m_profiling);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
btDbvtBroadphase::~btDbvtBroadphase()
|
btDbvtBroadphase::~btDbvtBroadphase()
|
||||||
{
|
{
|
||||||
if(m_releasepaircache)
|
if(m_releasepaircache)
|
||||||
{
|
{
|
||||||
m_paircache->~btOverlappingPairCache();
|
m_paircache->~btOverlappingPairCache();
|
||||||
btAlignedFree(m_paircache);
|
btAlignedFree(m_paircache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
btBroadphaseProxy* btDbvtBroadphase::createProxy( const btVector3& aabbMin,
|
btBroadphaseProxy* btDbvtBroadphase::createProxy( const btVector3& aabbMin,
|
||||||
const btVector3& aabbMax,
|
const btVector3& aabbMax,
|
||||||
int /*shapeType*/,
|
int /*shapeType*/,
|
||||||
void* userPtr,
|
void* userPtr,
|
||||||
short int collisionFilterGroup,
|
short int collisionFilterGroup,
|
||||||
short int collisionFilterMask,
|
short int collisionFilterMask,
|
||||||
btDispatcher* /*dispatcher*/,
|
btDispatcher* /*dispatcher*/,
|
||||||
void* /*multiSapProxy*/)
|
void* /*multiSapProxy*/)
|
||||||
{
|
{
|
||||||
btDbvtProxy* proxy=new(btAlignedAlloc(sizeof(btDbvtProxy),16)) btDbvtProxy( aabbMin,aabbMax,userPtr,
|
btDbvtProxy* proxy=new(btAlignedAlloc(sizeof(btDbvtProxy),16)) btDbvtProxy( aabbMin,aabbMax,userPtr,
|
||||||
collisionFilterGroup,
|
collisionFilterGroup,
|
||||||
collisionFilterMask);
|
collisionFilterMask);
|
||||||
|
|
||||||
btDbvtAabbMm aabb = btDbvtVolume::FromMM(aabbMin,aabbMax);
|
btDbvtAabbMm aabb = btDbvtVolume::FromMM(aabbMin,aabbMax);
|
||||||
|
|
||||||
//bproxy->aabb = btDbvtVolume::FromMM(aabbMin,aabbMax);
|
//bproxy->aabb = btDbvtVolume::FromMM(aabbMin,aabbMax);
|
||||||
proxy->stage = m_stageCurrent;
|
proxy->stage = m_stageCurrent;
|
||||||
proxy->m_uniqueId = ++m_gid;
|
proxy->m_uniqueId = ++m_gid;
|
||||||
proxy->leaf = m_sets[0].insert(aabb,proxy);
|
proxy->leaf = m_sets[0].insert(aabb,proxy);
|
||||||
listappend(proxy,m_stageRoots[m_stageCurrent]);
|
listappend(proxy,m_stageRoots[m_stageCurrent]);
|
||||||
if(!m_deferedcollide)
|
if(!m_deferedcollide)
|
||||||
{
|
{
|
||||||
btDbvtTreeCollider collider(this);
|
btDbvtTreeCollider collider(this);
|
||||||
collider.proxy=proxy;
|
collider.proxy=proxy;
|
||||||
btDbvt::collideTV(m_sets[0].m_root,aabb,collider);
|
btDbvt::collideTV(m_sets[0].m_root,aabb,collider);
|
||||||
btDbvt::collideTV(m_sets[1].m_root,aabb,collider);
|
btDbvt::collideTV(m_sets[1].m_root,aabb,collider);
|
||||||
}
|
}
|
||||||
return(proxy);
|
return(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void btDbvtBroadphase::destroyProxy( btBroadphaseProxy* absproxy,
|
void btDbvtBroadphase::destroyProxy( btBroadphaseProxy* absproxy,
|
||||||
btDispatcher* dispatcher)
|
btDispatcher* dispatcher)
|
||||||
{
|
{
|
||||||
btDbvtProxy* proxy=(btDbvtProxy*)absproxy;
|
btDbvtProxy* proxy=(btDbvtProxy*)absproxy;
|
||||||
if(proxy->stage==STAGECOUNT)
|
if(proxy->stage==STAGECOUNT)
|
||||||
m_sets[1].remove(proxy->leaf);
|
m_sets[1].remove(proxy->leaf);
|
||||||
else
|
else
|
||||||
m_sets[0].remove(proxy->leaf);
|
m_sets[0].remove(proxy->leaf);
|
||||||
listremove(proxy,m_stageRoots[proxy->stage]);
|
listremove(proxy,m_stageRoots[proxy->stage]);
|
||||||
m_paircache->removeOverlappingPairsContainingProxy(proxy,dispatcher);
|
m_paircache->removeOverlappingPairsContainingProxy(proxy,dispatcher);
|
||||||
btAlignedFree(proxy);
|
btAlignedFree(proxy);
|
||||||
m_needcleanup=true;
|
m_needcleanup=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void btDbvtBroadphase::getAabb(btBroadphaseProxy* absproxy,btVector3& aabbMin, btVector3& aabbMax ) const
|
void btDbvtBroadphase::getAabb(btBroadphaseProxy* absproxy,btVector3& aabbMin, btVector3& aabbMax ) const
|
||||||
@@ -230,79 +230,79 @@ void btDbvtBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo,
|
|||||||
BroadphaseRayTester callback(rayCallback);
|
BroadphaseRayTester callback(rayCallback);
|
||||||
|
|
||||||
m_sets[0].rayTest( m_sets[0].m_root,
|
m_sets[0].rayTest( m_sets[0].m_root,
|
||||||
rayFrom,
|
rayFrom,
|
||||||
rayTo,
|
rayTo,
|
||||||
callback);
|
callback);
|
||||||
|
|
||||||
m_sets[1].rayTest( m_sets[1].m_root,
|
m_sets[1].rayTest( m_sets[1].m_root,
|
||||||
rayFrom,
|
rayFrom,
|
||||||
rayTo,
|
rayTo,
|
||||||
callback);
|
callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void btDbvtBroadphase::setAabb( btBroadphaseProxy* absproxy,
|
void btDbvtBroadphase::setAabb( btBroadphaseProxy* absproxy,
|
||||||
const btVector3& aabbMin,
|
const btVector3& aabbMin,
|
||||||
const btVector3& aabbMax,
|
const btVector3& aabbMax,
|
||||||
btDispatcher* /*dispatcher*/)
|
btDispatcher* /*dispatcher*/)
|
||||||
{
|
{
|
||||||
btDbvtProxy* proxy=(btDbvtProxy*)absproxy;
|
btDbvtProxy* proxy=(btDbvtProxy*)absproxy;
|
||||||
ATTRIBUTE_ALIGNED16(btDbvtVolume) aabb=btDbvtVolume::FromMM(aabbMin,aabbMax);
|
ATTRIBUTE_ALIGNED16(btDbvtVolume) aabb=btDbvtVolume::FromMM(aabbMin,aabbMax);
|
||||||
#if DBVT_BP_PREVENTFALSEUPDATE
|
#if DBVT_BP_PREVENTFALSEUPDATE
|
||||||
if(NotEqual(aabb,proxy->leaf->volume))
|
if(NotEqual(aabb,proxy->leaf->volume))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool docollide=false;
|
bool docollide=false;
|
||||||
if(proxy->stage==STAGECOUNT)
|
if(proxy->stage==STAGECOUNT)
|
||||||
{/* fixed -> dynamic set */
|
{/* fixed -> dynamic set */
|
||||||
m_sets[1].remove(proxy->leaf);
|
m_sets[1].remove(proxy->leaf);
|
||||||
proxy->leaf=m_sets[0].insert(aabb,proxy);
|
proxy->leaf=m_sets[0].insert(aabb,proxy);
|
||||||
docollide=true;
|
docollide=true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{/* dynamic set */
|
{/* dynamic set */
|
||||||
++m_updates_call;
|
++m_updates_call;
|
||||||
if(Intersect(proxy->leaf->volume,aabb))
|
if(Intersect(proxy->leaf->volume,aabb))
|
||||||
{/* Moving */
|
{/* Moving */
|
||||||
|
|
||||||
const btVector3 delta=aabbMin-proxy->m_aabbMin;
|
const btVector3 delta=aabbMin-proxy->m_aabbMin;
|
||||||
btVector3 velocity(((proxy->m_aabbMax-proxy->m_aabbMin)/2)*m_prediction);
|
btVector3 velocity(((proxy->m_aabbMax-proxy->m_aabbMin)/2)*m_prediction);
|
||||||
if(delta[0]<0) velocity[0]=-velocity[0];
|
if(delta[0]<0) velocity[0]=-velocity[0];
|
||||||
if(delta[1]<0) velocity[1]=-velocity[1];
|
if(delta[1]<0) velocity[1]=-velocity[1];
|
||||||
if(delta[2]<0) velocity[2]=-velocity[2];
|
if(delta[2]<0) velocity[2]=-velocity[2];
|
||||||
if (
|
if (
|
||||||
#ifdef DBVT_BP_MARGIN
|
#ifdef DBVT_BP_MARGIN
|
||||||
m_sets[0].update(proxy->leaf,aabb,velocity,DBVT_BP_MARGIN)
|
m_sets[0].update(proxy->leaf,aabb,velocity,DBVT_BP_MARGIN)
|
||||||
#else
|
#else
|
||||||
m_sets[0].update(proxy->leaf,aabb,velocity)
|
m_sets[0].update(proxy->leaf,aabb,velocity)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
++m_updates_done;
|
++m_updates_done;
|
||||||
docollide=true;
|
docollide=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{/* Teleporting */
|
{/* Teleporting */
|
||||||
m_sets[0].update(proxy->leaf,aabb);
|
m_sets[0].update(proxy->leaf,aabb);
|
||||||
++m_updates_done;
|
++m_updates_done;
|
||||||
docollide=true;
|
docollide=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listremove(proxy,m_stageRoots[proxy->stage]);
|
listremove(proxy,m_stageRoots[proxy->stage]);
|
||||||
proxy->m_aabbMin = aabbMin;
|
proxy->m_aabbMin = aabbMin;
|
||||||
proxy->m_aabbMax = aabbMax;
|
proxy->m_aabbMax = aabbMax;
|
||||||
proxy->stage = m_stageCurrent;
|
proxy->stage = m_stageCurrent;
|
||||||
listappend(proxy,m_stageRoots[m_stageCurrent]);
|
listappend(proxy,m_stageRoots[m_stageCurrent]);
|
||||||
if(docollide)
|
if(docollide)
|
||||||
{
|
{
|
||||||
m_needcleanup=true;
|
m_needcleanup=true;
|
||||||
if(!m_deferedcollide)
|
if(!m_deferedcollide)
|
||||||
{
|
{
|
||||||
btDbvtTreeCollider collider(this);
|
btDbvtTreeCollider collider(this);
|
||||||
btDbvt::collideTT(m_sets[1].m_root,proxy->leaf,collider);
|
btDbvt::collideTT(m_sets[1].m_root,proxy->leaf,collider);
|
||||||
btDbvt::collideTT(m_sets[0].m_root,proxy->leaf,collider);
|
btDbvt::collideTT(m_sets[0].m_root,proxy->leaf,collider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,24 +311,24 @@ if(NotEqual(aabb,proxy->leaf->volume))
|
|||||||
//
|
//
|
||||||
void btDbvtBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
void btDbvtBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||||
{
|
{
|
||||||
collide(dispatcher);
|
collide(dispatcher);
|
||||||
#if DBVT_BP_PROFILE
|
#if DBVT_BP_PROFILE
|
||||||
if(0==(m_pid%DBVT_BP_PROFILING_RATE))
|
if(0==(m_pid%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());
|
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;
|
unsigned int total=m_profiling.m_total;
|
||||||
if(total<=0) total=1;
|
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("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("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("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("total: %uus\r\n",total/DBVT_BP_PROFILING_RATE);
|
||||||
const unsigned long sum=m_profiling.m_ddcollide+
|
const unsigned long sum=m_profiling.m_ddcollide+
|
||||||
m_profiling.m_fdcollide+
|
m_profiling.m_fdcollide+
|
||||||
m_profiling.m_cleanup;
|
m_profiling.m_cleanup;
|
||||||
printf("leaked: %u%% (%uus)\r\n",100-((50+sum*100)/total),(total-sum)/DBVT_BP_PROFILING_RATE);
|
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));
|
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);
|
clear(m_profiling);
|
||||||
m_clock.reset();
|
m_clock.reset();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -336,108 +336,108 @@ if(0==(m_pid%DBVT_BP_PROFILING_RATE))
|
|||||||
//
|
//
|
||||||
void btDbvtBroadphase::collide(btDispatcher* dispatcher)
|
void btDbvtBroadphase::collide(btDispatcher* dispatcher)
|
||||||
{
|
{
|
||||||
SPC(m_profiling.m_total);
|
SPC(m_profiling.m_total);
|
||||||
/* optimize */
|
/* optimize */
|
||||||
m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100);
|
m_sets[0].optimizeIncremental(1+(m_sets[0].m_leaves*m_dupdates)/100);
|
||||||
if(m_fixedleft)
|
if(m_fixedleft)
|
||||||
{
|
{
|
||||||
const int count=1+(m_sets[1].m_leaves*m_fupdates)/100;
|
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_sets[1].optimizeIncremental(1+(m_sets[1].m_leaves*m_fupdates)/100);
|
||||||
m_fixedleft=btMax<int>(0,m_fixedleft-count);
|
m_fixedleft=btMax<int>(0,m_fixedleft-count);
|
||||||
}
|
}
|
||||||
/* dynamic -> fixed set */
|
/* dynamic -> fixed set */
|
||||||
m_stageCurrent=(m_stageCurrent+1)%STAGECOUNT;
|
m_stageCurrent=(m_stageCurrent+1)%STAGECOUNT;
|
||||||
btDbvtProxy* current=m_stageRoots[m_stageCurrent];
|
btDbvtProxy* current=m_stageRoots[m_stageCurrent];
|
||||||
if(current)
|
if(current)
|
||||||
{
|
{
|
||||||
btDbvtTreeCollider collider(this);
|
btDbvtTreeCollider collider(this);
|
||||||
do {
|
do {
|
||||||
btDbvtProxy* next=current->links[1];
|
btDbvtProxy* next=current->links[1];
|
||||||
listremove(current,m_stageRoots[current->stage]);
|
listremove(current,m_stageRoots[current->stage]);
|
||||||
listappend(current,m_stageRoots[STAGECOUNT]);
|
listappend(current,m_stageRoots[STAGECOUNT]);
|
||||||
#if DBVT_BP_ACCURATESLEEPING
|
#if DBVT_BP_ACCURATESLEEPING
|
||||||
m_paircache->removeOverlappingPairsContainingProxy(current,dispatcher);
|
m_paircache->removeOverlappingPairsContainingProxy(current,dispatcher);
|
||||||
collider.proxy=current;
|
collider.proxy=current;
|
||||||
btDbvt::collideTV(m_sets[0].m_root,current->aabb,collider);
|
btDbvt::collideTV(m_sets[0].m_root,current->aabb,collider);
|
||||||
btDbvt::collideTV(m_sets[1].m_root,current->aabb,collider);
|
btDbvt::collideTV(m_sets[1].m_root,current->aabb,collider);
|
||||||
#endif
|
#endif
|
||||||
m_sets[0].remove(current->leaf);
|
m_sets[0].remove(current->leaf);
|
||||||
ATTRIBUTE_ALIGNED16(btDbvtVolume) curAabb=btDbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax);
|
ATTRIBUTE_ALIGNED16(btDbvtVolume) curAabb=btDbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax);
|
||||||
current->leaf = m_sets[1].insert(curAabb,current);
|
current->leaf = m_sets[1].insert(curAabb,current);
|
||||||
current->stage = STAGECOUNT;
|
current->stage = STAGECOUNT;
|
||||||
current = next;
|
current = next;
|
||||||
} while(current);
|
} while(current);
|
||||||
m_fixedleft=m_sets[1].m_leaves;
|
m_fixedleft=m_sets[1].m_leaves;
|
||||||
m_needcleanup=true;
|
m_needcleanup=true;
|
||||||
}
|
}
|
||||||
/* collide dynamics */
|
/* collide dynamics */
|
||||||
{
|
{
|
||||||
btDbvtTreeCollider collider(this);
|
btDbvtTreeCollider collider(this);
|
||||||
if(m_deferedcollide)
|
if(m_deferedcollide)
|
||||||
{
|
{
|
||||||
SPC(m_profiling.m_fdcollide);
|
SPC(m_profiling.m_fdcollide);
|
||||||
btDbvt::collideTT(m_sets[0].m_root,m_sets[1].m_root,collider);
|
btDbvt::collideTT(m_sets[0].m_root,m_sets[1].m_root,collider);
|
||||||
}
|
}
|
||||||
if(m_deferedcollide)
|
if(m_deferedcollide)
|
||||||
{
|
{
|
||||||
SPC(m_profiling.m_ddcollide);
|
SPC(m_profiling.m_ddcollide);
|
||||||
btDbvt::collideTT(m_sets[0].m_root,m_sets[0].m_root,collider);
|
btDbvt::collideTT(m_sets[0].m_root,m_sets[0].m_root,collider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* clean up */
|
/* clean up */
|
||||||
if(m_needcleanup)
|
if(m_needcleanup)
|
||||||
{
|
{
|
||||||
SPC(m_profiling.m_cleanup);
|
SPC(m_profiling.m_cleanup);
|
||||||
btBroadphasePairArray& pairs=m_paircache->getOverlappingPairArray();
|
btBroadphasePairArray& pairs=m_paircache->getOverlappingPairArray();
|
||||||
if(pairs.size()>0)
|
if(pairs.size()>0)
|
||||||
{
|
{
|
||||||
const int ci=pairs.size();
|
const int ci=pairs.size();
|
||||||
int ni=btMin(ci,btMax<int>(m_newpairs,(ci*m_cupdates)/100));
|
int ni=btMin(ci,btMax<int>(m_newpairs,(ci*m_cupdates)/100));
|
||||||
for(int i=0;i<ni;++i)
|
for(int i=0;i<ni;++i)
|
||||||
{
|
{
|
||||||
btBroadphasePair& p=pairs[(m_cid+i)%ci];
|
btBroadphasePair& p=pairs[(m_cid+i)%ci];
|
||||||
btDbvtProxy* pa=(btDbvtProxy*)p.m_pProxy0;
|
btDbvtProxy* pa=(btDbvtProxy*)p.m_pProxy0;
|
||||||
btDbvtProxy* pb=(btDbvtProxy*)p.m_pProxy1;
|
btDbvtProxy* pb=(btDbvtProxy*)p.m_pProxy1;
|
||||||
if(!Intersect(pa->leaf->volume,pb->leaf->volume))
|
if(!Intersect(pa->leaf->volume,pb->leaf->volume))
|
||||||
{
|
{
|
||||||
#if DBVT_BP_SORTPAIRS
|
#if DBVT_BP_SORTPAIRS
|
||||||
if(pa>pb) btSwap(pa,pb);
|
if(pa>pb) btSwap(pa,pb);
|
||||||
#endif
|
#endif
|
||||||
m_paircache->removeOverlappingPair(pa,pb,dispatcher);
|
m_paircache->removeOverlappingPair(pa,pb,dispatcher);
|
||||||
--ni;--i;
|
--ni;--i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pairs.size()>0) m_cid=(m_cid+ni)%pairs.size(); else m_cid=0;
|
if(pairs.size()>0) m_cid=(m_cid+ni)%pairs.size(); else m_cid=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++m_pid;
|
++m_pid;
|
||||||
m_newpairs=1;
|
m_newpairs=1;
|
||||||
m_needcleanup=false;
|
m_needcleanup=false;
|
||||||
if(m_updates_call>0)
|
if(m_updates_call>0)
|
||||||
{ m_updates_ratio=m_updates_done/(btScalar)m_updates_call; }
|
{ m_updates_ratio=m_updates_done/(btScalar)m_updates_call; }
|
||||||
else
|
else
|
||||||
{ m_updates_ratio=0; }
|
{ m_updates_ratio=0; }
|
||||||
m_updates_done/=2;
|
m_updates_done/=2;
|
||||||
m_updates_call/=2;
|
m_updates_call/=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void btDbvtBroadphase::optimize()
|
void btDbvtBroadphase::optimize()
|
||||||
{
|
{
|
||||||
m_sets[0].optimizeTopDown();
|
m_sets[0].optimizeTopDown();
|
||||||
m_sets[1].optimizeTopDown();
|
m_sets[1].optimizeTopDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
btOverlappingPairCache* btDbvtBroadphase::getOverlappingPairCache()
|
btOverlappingPairCache* btDbvtBroadphase::getOverlappingPairCache()
|
||||||
{
|
{
|
||||||
return(m_paircache);
|
return(m_paircache);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
const btOverlappingPairCache* btDbvtBroadphase::getOverlappingPairCache() const
|
const btOverlappingPairCache* btDbvtBroadphase::getOverlappingPairCache() const
|
||||||
{
|
{
|
||||||
return(m_paircache);
|
return(m_paircache);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -446,16 +446,16 @@ void btDbvtBroadphase::getBroadphaseAabb(btVector3& aabbMin,btVector3& aab
|
|||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds;
|
ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds;
|
||||||
|
|
||||||
if(!m_sets[0].empty())
|
if(!m_sets[0].empty())
|
||||||
if(!m_sets[1].empty()) Merge( m_sets[0].m_root->volume,
|
if(!m_sets[1].empty()) Merge( m_sets[0].m_root->volume,
|
||||||
m_sets[1].m_root->volume,bounds);
|
m_sets[1].m_root->volume,bounds);
|
||||||
else
|
else
|
||||||
bounds=m_sets[0].m_root->volume;
|
bounds=m_sets[0].m_root->volume;
|
||||||
else if(!m_sets[1].empty()) bounds=m_sets[1].m_root->volume;
|
else if(!m_sets[1].empty()) bounds=m_sets[1].m_root->volume;
|
||||||
else
|
else
|
||||||
bounds=btDbvtVolume::FromCR(btVector3(0,0,0),0);
|
bounds=btDbvtVolume::FromCR(btVector3(0,0,0),0);
|
||||||
aabbMin=bounds.Mins();
|
aabbMin=bounds.Mins();
|
||||||
aabbMax=bounds.Maxs();
|
aabbMax=bounds.Maxs();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -466,9 +466,9 @@ void btDbvtBroadphase::printStats()
|
|||||||
#if DBVT_BP_ENABLE_BENCHMARK
|
#if DBVT_BP_ENABLE_BENCHMARK
|
||||||
|
|
||||||
struct btBroadphaseBenchmark
|
struct btBroadphaseBenchmark
|
||||||
{
|
{
|
||||||
struct Experiment
|
struct Experiment
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
int object_count;
|
int object_count;
|
||||||
int update_count;
|
int update_count;
|
||||||
@@ -476,109 +476,109 @@ struct btBroadphaseBenchmark
|
|||||||
int iterations;
|
int iterations;
|
||||||
btScalar speed;
|
btScalar speed;
|
||||||
btScalar amplitude;
|
btScalar amplitude;
|
||||||
};
|
};
|
||||||
struct Object
|
struct Object
|
||||||
{
|
{
|
||||||
btVector3 center;
|
btVector3 center;
|
||||||
btVector3 extents;
|
btVector3 extents;
|
||||||
btBroadphaseProxy* proxy;
|
btBroadphaseProxy* proxy;
|
||||||
btScalar time;
|
btScalar time;
|
||||||
void update(btScalar speed,btScalar amplitude,btBroadphaseInterface* pbi)
|
void update(btScalar speed,btScalar amplitude,btBroadphaseInterface* pbi)
|
||||||
{
|
{
|
||||||
time += speed;
|
time += speed;
|
||||||
center[0] = btCos(time*(btScalar)2.17)*amplitude+
|
center[0] = btCos(time*(btScalar)2.17)*amplitude+
|
||||||
btSin(time)*amplitude/2;
|
btSin(time)*amplitude/2;
|
||||||
center[1] = btCos(time*(btScalar)1.38)*amplitude+
|
center[1] = btCos(time*(btScalar)1.38)*amplitude+
|
||||||
btSin(time)*amplitude;
|
btSin(time)*amplitude;
|
||||||
center[2] = btSin(time*(btScalar)0.777)*amplitude;
|
center[2] = btSin(time*(btScalar)0.777)*amplitude;
|
||||||
pbi->setAabb(proxy,center-extents,center+extents,0);
|
pbi->setAabb(proxy,center-extents,center+extents,0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static int UnsignedRand(int range=RAND_MAX-1) { return(rand()%(range+1)); }
|
static int UnsignedRand(int range=RAND_MAX-1) { return(rand()%(range+1)); }
|
||||||
static btScalar UnitRand() { return(UnsignedRand(16384)/(btScalar)16384); }
|
static btScalar UnitRand() { return(UnsignedRand(16384)/(btScalar)16384); }
|
||||||
static void OutputTime(const char* name,btClock& c,unsigned count=0)
|
static void OutputTime(const char* name,btClock& c,unsigned count=0)
|
||||||
{
|
{
|
||||||
const unsigned long us=c.getTimeMicroseconds();
|
const unsigned long us=c.getTimeMicroseconds();
|
||||||
const unsigned long ms=(us+500)/1000;
|
const unsigned long ms=(us+500)/1000;
|
||||||
const btScalar sec=us/(btScalar)(1000*1000);
|
const btScalar sec=us/(btScalar)(1000*1000);
|
||||||
if(count>0)
|
if(count>0)
|
||||||
printf("%s : %u us (%u ms), %.2f/s\r\n",name,us,ms,count/sec);
|
printf("%s : %u us (%u ms), %.2f/s\r\n",name,us,ms,count/sec);
|
||||||
else
|
else
|
||||||
printf("%s : %u us (%u ms)\r\n",name,us,ms);
|
printf("%s : %u us (%u ms)\r\n",name,us,ms);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void btDbvtBroadphase::benchmark(btBroadphaseInterface* pbi)
|
void btDbvtBroadphase::benchmark(btBroadphaseInterface* pbi)
|
||||||
{
|
{
|
||||||
static const btBroadphaseBenchmark::Experiment experiments[]=
|
static const btBroadphaseBenchmark::Experiment experiments[]=
|
||||||
{
|
{
|
||||||
{"1024o.10%",1024,10,0,8192,(btScalar)0.005,(btScalar)100},
|
{"1024o.10%",1024,10,0,8192,(btScalar)0.005,(btScalar)100},
|
||||||
/*{"4096o.10%",4096,10,0,8192,(btScalar)0.005,(btScalar)100},
|
/*{"4096o.10%",4096,10,0,8192,(btScalar)0.005,(btScalar)100},
|
||||||
{"8192o.10%",8192,10,0,8192,(btScalar)0.005,(btScalar)100},*/
|
{"8192o.10%",8192,10,0,8192,(btScalar)0.005,(btScalar)100},*/
|
||||||
};
|
};
|
||||||
static const int nexperiments=sizeof(experiments)/sizeof(experiments[0]);
|
static const int nexperiments=sizeof(experiments)/sizeof(experiments[0]);
|
||||||
btAlignedObjectArray<btBroadphaseBenchmark::Object*> objects;
|
btAlignedObjectArray<btBroadphaseBenchmark::Object*> objects;
|
||||||
btClock wallclock;
|
btClock wallclock;
|
||||||
/* Begin */
|
/* Begin */
|
||||||
for(int iexp=0;iexp<nexperiments;++iexp)
|
for(int iexp=0;iexp<nexperiments;++iexp)
|
||||||
{
|
{
|
||||||
const btBroadphaseBenchmark::Experiment& experiment=experiments[iexp];
|
const btBroadphaseBenchmark::Experiment& experiment=experiments[iexp];
|
||||||
const int object_count=experiment.object_count;
|
const int object_count=experiment.object_count;
|
||||||
const int update_count=(object_count*experiment.update_count)/100;
|
const int update_count=(object_count*experiment.update_count)/100;
|
||||||
const int spawn_count=(object_count*experiment.spawn_count)/100;
|
const int spawn_count=(object_count*experiment.spawn_count)/100;
|
||||||
const btScalar speed=experiment.speed;
|
const btScalar speed=experiment.speed;
|
||||||
const btScalar amplitude=experiment.amplitude;
|
const btScalar amplitude=experiment.amplitude;
|
||||||
printf("Experiment #%u '%s':\r\n",iexp,experiment.name);
|
printf("Experiment #%u '%s':\r\n",iexp,experiment.name);
|
||||||
printf("\tObjects: %u\r\n",object_count);
|
printf("\tObjects: %u\r\n",object_count);
|
||||||
printf("\tUpdate: %u\r\n",update_count);
|
printf("\tUpdate: %u\r\n",update_count);
|
||||||
printf("\tSpawn: %u\r\n",spawn_count);
|
printf("\tSpawn: %u\r\n",spawn_count);
|
||||||
printf("\tSpeed: %f\r\n",speed);
|
printf("\tSpeed: %f\r\n",speed);
|
||||||
printf("\tAmplitude: %f\r\n",amplitude);
|
printf("\tAmplitude: %f\r\n",amplitude);
|
||||||
srand(180673);
|
srand(180673);
|
||||||
/* Create objects */
|
/* Create objects */
|
||||||
wallclock.reset();
|
wallclock.reset();
|
||||||
objects.reserve(object_count);
|
objects.reserve(object_count);
|
||||||
for(int i=0;i<object_count;++i)
|
for(int i=0;i<object_count;++i)
|
||||||
{
|
{
|
||||||
btBroadphaseBenchmark::Object* po=new btBroadphaseBenchmark::Object();
|
btBroadphaseBenchmark::Object* po=new btBroadphaseBenchmark::Object();
|
||||||
po->center[0]=btBroadphaseBenchmark::UnitRand()*50;
|
po->center[0]=btBroadphaseBenchmark::UnitRand()*50;
|
||||||
po->center[1]=btBroadphaseBenchmark::UnitRand()*50;
|
po->center[1]=btBroadphaseBenchmark::UnitRand()*50;
|
||||||
po->center[2]=btBroadphaseBenchmark::UnitRand()*50;
|
po->center[2]=btBroadphaseBenchmark::UnitRand()*50;
|
||||||
po->extents[0]=btBroadphaseBenchmark::UnitRand()*2+2;
|
po->extents[0]=btBroadphaseBenchmark::UnitRand()*2+2;
|
||||||
po->extents[1]=btBroadphaseBenchmark::UnitRand()*2+2;
|
po->extents[1]=btBroadphaseBenchmark::UnitRand()*2+2;
|
||||||
po->extents[2]=btBroadphaseBenchmark::UnitRand()*2+2;
|
po->extents[2]=btBroadphaseBenchmark::UnitRand()*2+2;
|
||||||
po->time=btBroadphaseBenchmark::UnitRand()*2000;
|
po->time=btBroadphaseBenchmark::UnitRand()*2000;
|
||||||
po->proxy=pbi->createProxy(po->center-po->extents,po->center+po->extents,0,po,1,1,0,0);
|
po->proxy=pbi->createProxy(po->center-po->extents,po->center+po->extents,0,po,1,1,0,0);
|
||||||
objects.push_back(po);
|
objects.push_back(po);
|
||||||
}
|
}
|
||||||
btBroadphaseBenchmark::OutputTime("\tInitialization",wallclock);
|
btBroadphaseBenchmark::OutputTime("\tInitialization",wallclock);
|
||||||
/* First update */
|
/* First update */
|
||||||
wallclock.reset();
|
wallclock.reset();
|
||||||
for(int i=0;i<objects.size();++i)
|
for(int i=0;i<objects.size();++i)
|
||||||
{
|
{
|
||||||
objects[i]->update(speed,amplitude,pbi);
|
objects[i]->update(speed,amplitude,pbi);
|
||||||
}
|
}
|
||||||
btBroadphaseBenchmark::OutputTime("\tFirst update",wallclock);
|
btBroadphaseBenchmark::OutputTime("\tFirst update",wallclock);
|
||||||
/* Updates */
|
/* Updates */
|
||||||
wallclock.reset();
|
wallclock.reset();
|
||||||
for(int i=0;i<experiment.iterations;++i)
|
for(int i=0;i<experiment.iterations;++i)
|
||||||
{
|
{
|
||||||
for(int j=0;j<update_count;++j)
|
for(int j=0;j<update_count;++j)
|
||||||
{
|
{
|
||||||
objects[j]->update(speed,amplitude,pbi);
|
objects[j]->update(speed,amplitude,pbi);
|
||||||
}
|
}
|
||||||
pbi->calculateOverlappingPairs(0);
|
pbi->calculateOverlappingPairs(0);
|
||||||
}
|
}
|
||||||
btBroadphaseBenchmark::OutputTime("\tUpdate",wallclock,experiment.iterations);
|
btBroadphaseBenchmark::OutputTime("\tUpdate",wallclock,experiment.iterations);
|
||||||
/* Clean up */
|
/* Clean up */
|
||||||
wallclock.reset();
|
wallclock.reset();
|
||||||
for(int i=0;i<objects.size();++i)
|
for(int i=0;i<objects.size();++i)
|
||||||
{
|
{
|
||||||
pbi->destroyProxy(objects[i]->proxy,0);
|
pbi->destroyProxy(objects[i]->proxy,0);
|
||||||
delete objects[i];
|
delete objects[i];
|
||||||
}
|
}
|
||||||
objects.resize(0);
|
objects.resize(0);
|
||||||
btBroadphaseBenchmark::OutputTime("\tRelease",wallclock);
|
btBroadphaseBenchmark::OutputTime("\tRelease",wallclock);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ subject to the following restrictions:
|
|||||||
#define DBVT_BP_MARGIN (btScalar)0.05
|
#define DBVT_BP_MARGIN (btScalar)0.05
|
||||||
|
|
||||||
#if DBVT_BP_PROFILE
|
#if DBVT_BP_PROFILE
|
||||||
#define DBVT_BP_PROFILING_RATE 256
|
#define DBVT_BP_PROFILING_RATE 256
|
||||||
#include "LinearMath/btQuickprof.h"
|
#include "LinearMath/btQuickprof.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -40,16 +40,16 @@ subject to the following restrictions:
|
|||||||
//
|
//
|
||||||
struct btDbvtProxy : btBroadphaseProxy
|
struct btDbvtProxy : btBroadphaseProxy
|
||||||
{
|
{
|
||||||
/* Fields */
|
/* Fields */
|
||||||
//btDbvtAabbMm aabb;
|
//btDbvtAabbMm aabb;
|
||||||
btDbvtNode* leaf;
|
btDbvtNode* leaf;
|
||||||
btDbvtProxy* links[2];
|
btDbvtProxy* links[2];
|
||||||
int stage;
|
int stage;
|
||||||
/* ctor */
|
/* ctor */
|
||||||
btDbvtProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
|
btDbvtProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
|
||||||
btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask)
|
btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask)
|
||||||
{
|
{
|
||||||
links[0]=links[1]=0;
|
links[0]=links[1]=0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -60,60 +60,60 @@ typedef btAlignedObjectArray<btDbvtProxy*> btDbvtProxyArray;
|
|||||||
///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 btAxisSweep3 and bt32BitAxisSweep3.
|
||||||
struct btDbvtBroadphase : btBroadphaseInterface
|
struct btDbvtBroadphase : btBroadphaseInterface
|
||||||
{
|
{
|
||||||
/* Config */
|
/* Config */
|
||||||
enum {
|
enum {
|
||||||
DYNAMIC_SET = 0, /* Dynamic set index */
|
DYNAMIC_SET = 0, /* Dynamic set index */
|
||||||
FIXED_SET = 1, /* Fixed set index */
|
FIXED_SET = 1, /* Fixed set index */
|
||||||
STAGECOUNT = 2 /* Number of stages */
|
STAGECOUNT = 2 /* Number of stages */
|
||||||
};
|
};
|
||||||
/* Fields */
|
/* Fields */
|
||||||
btDbvt m_sets[2]; // Dbvt sets
|
btDbvt m_sets[2]; // Dbvt sets
|
||||||
btDbvtProxy* m_stageRoots[STAGECOUNT+1]; // Stages list
|
btDbvtProxy* m_stageRoots[STAGECOUNT+1]; // Stages list
|
||||||
btOverlappingPairCache* m_paircache; // Pair cache
|
btOverlappingPairCache* m_paircache; // Pair cache
|
||||||
btScalar m_prediction; // Velocity prediction
|
btScalar m_prediction; // Velocity prediction
|
||||||
int m_stageCurrent; // Current stage
|
int m_stageCurrent; // Current stage
|
||||||
int m_fupdates; // % of fixed updates per frame
|
int m_fupdates; // % of fixed updates per frame
|
||||||
int m_dupdates; // % of dynamic updates per frame
|
int m_dupdates; // % of dynamic updates per frame
|
||||||
int m_cupdates; // % of cleanup updates per frame
|
int m_cupdates; // % of cleanup updates per frame
|
||||||
int m_newpairs; // Number of pairs created
|
int m_newpairs; // Number of pairs created
|
||||||
int m_fixedleft; // Fixed optimization left
|
int m_fixedleft; // Fixed optimization left
|
||||||
unsigned m_updates_call; // Number of updates call
|
unsigned m_updates_call; // Number of updates call
|
||||||
unsigned m_updates_done; // Number of updates done
|
unsigned m_updates_done; // Number of updates done
|
||||||
btScalar m_updates_ratio; // m_updates_done/m_updates_call
|
btScalar m_updates_ratio; // m_updates_done/m_updates_call
|
||||||
int m_pid; // Parse id
|
int m_pid; // Parse id
|
||||||
int m_cid; // Cleanup index
|
int m_cid; // Cleanup index
|
||||||
int m_gid; // Gen id
|
int m_gid; // Gen id
|
||||||
bool m_releasepaircache; // Release pair cache on delete
|
bool m_releasepaircache; // Release pair cache on delete
|
||||||
bool m_deferedcollide; // Defere dynamic/static collision to collide call
|
bool m_deferedcollide; // Defere dynamic/static collision to collide call
|
||||||
bool m_needcleanup; // Need to run cleanup?
|
bool m_needcleanup; // Need to run cleanup?
|
||||||
#if DBVT_BP_PROFILE
|
#if DBVT_BP_PROFILE
|
||||||
btClock m_clock;
|
btClock m_clock;
|
||||||
struct {
|
struct {
|
||||||
unsigned long m_total;
|
unsigned long m_total;
|
||||||
unsigned long m_ddcollide;
|
unsigned long m_ddcollide;
|
||||||
unsigned long m_fdcollide;
|
unsigned long m_fdcollide;
|
||||||
unsigned long m_cleanup;
|
unsigned long m_cleanup;
|
||||||
unsigned long m_jobcount;
|
unsigned long m_jobcount;
|
||||||
} m_profiling;
|
} m_profiling;
|
||||||
#endif
|
#endif
|
||||||
/* Methods */
|
/* Methods */
|
||||||
btDbvtBroadphase(btOverlappingPairCache* paircache=0);
|
btDbvtBroadphase(btOverlappingPairCache* paircache=0);
|
||||||
~btDbvtBroadphase();
|
~btDbvtBroadphase();
|
||||||
void collide(btDispatcher* dispatcher);
|
void collide(btDispatcher* dispatcher);
|
||||||
void optimize();
|
void optimize();
|
||||||
/* btBroadphaseInterface Implementation */
|
/* btBroadphaseInterface Implementation */
|
||||||
btBroadphaseProxy* createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
|
btBroadphaseProxy* createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
|
||||||
void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||||
void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
|
void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
|
||||||
virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback);
|
virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback);
|
||||||
|
|
||||||
virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
|
virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
|
||||||
void calculateOverlappingPairs(btDispatcher* dispatcher);
|
void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||||
btOverlappingPairCache* getOverlappingPairCache();
|
btOverlappingPairCache* getOverlappingPairCache();
|
||||||
const btOverlappingPairCache* getOverlappingPairCache() const;
|
const btOverlappingPairCache* getOverlappingPairCache() const;
|
||||||
void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const;
|
void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const;
|
||||||
void printStats();
|
void printStats();
|
||||||
static void benchmark(btBroadphaseInterface*);
|
static void benchmark(btBroadphaseInterface*);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+946
-946
File diff suppressed because it is too large.
Load diff
+115
-115
@@ -62,13 +62,13 @@ public:
|
|||||||
F_OneSided, ///Face normals are taken as it is
|
F_OneSided, ///Face normals are taken as it is
|
||||||
END
|
END
|
||||||
};};
|
};};
|
||||||
|
|
||||||
///eVSolver : velocities solvers
|
///eVSolver : velocities solvers
|
||||||
struct eVSolver { enum _ {
|
struct eVSolver { enum _ {
|
||||||
Linear, ///Linear solver
|
Linear, ///Linear solver
|
||||||
END
|
END
|
||||||
};};
|
};};
|
||||||
|
|
||||||
///ePSolver : positions solvers
|
///ePSolver : positions solvers
|
||||||
struct ePSolver { enum _ {
|
struct ePSolver { enum _ {
|
||||||
Linear, ///Linear solver
|
Linear, ///Linear solver
|
||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
SContacts, ///Soft contacts solver
|
SContacts, ///Soft contacts solver
|
||||||
END
|
END
|
||||||
};};
|
};};
|
||||||
|
|
||||||
///eSolverPresets
|
///eSolverPresets
|
||||||
struct eSolverPresets { enum _ {
|
struct eSolverPresets { enum _ {
|
||||||
Positions,
|
Positions,
|
||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
Default = Positions,
|
Default = Positions,
|
||||||
END
|
END
|
||||||
};};
|
};};
|
||||||
|
|
||||||
///eFeature
|
///eFeature
|
||||||
struct eFeature { enum _ {
|
struct eFeature { enum _ {
|
||||||
None,
|
None,
|
||||||
@@ -94,20 +94,20 @@ public:
|
|||||||
Face,
|
Face,
|
||||||
END
|
END
|
||||||
};};
|
};};
|
||||||
|
|
||||||
typedef btAlignedObjectArray<eVSolver::_> tVSolverArray;
|
typedef btAlignedObjectArray<eVSolver::_> tVSolverArray;
|
||||||
typedef btAlignedObjectArray<ePSolver::_> tPSolverArray;
|
typedef btAlignedObjectArray<ePSolver::_> tPSolverArray;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Flags
|
// Flags
|
||||||
//
|
//
|
||||||
|
|
||||||
///fCollision
|
///fCollision
|
||||||
struct fCollision { enum _ {
|
struct fCollision { enum _ {
|
||||||
RVSmask = 0x000f, ///Rigid versus soft mask
|
RVSmask = 0x000f, ///Rigid versus soft mask
|
||||||
SDF_RS = 0x0001, ///SDF based rigid vs soft
|
SDF_RS = 0x0001, ///SDF based rigid vs soft
|
||||||
CL_RS = 0x0002, ///Cluster vs convex rigid vs soft
|
CL_RS = 0x0002, ///Cluster vs convex rigid vs soft
|
||||||
|
|
||||||
SVSmask = 0x00f0, ///Rigid versus soft mask
|
SVSmask = 0x00f0, ///Rigid versus soft mask
|
||||||
VF_SS = 0x0010, ///Vertex vs face soft vs soft handling
|
VF_SS = 0x0010, ///Vertex vs face soft vs soft handling
|
||||||
CL_SS = 0x0020, ///Cluster vs cluster soft vs soft handling
|
CL_SS = 0x0020, ///Cluster vs cluster soft vs soft handling
|
||||||
@@ -115,7 +115,7 @@ public:
|
|||||||
Default = SDF_RS,
|
Default = SDF_RS,
|
||||||
END
|
END
|
||||||
};};
|
};};
|
||||||
|
|
||||||
///fMaterial
|
///fMaterial
|
||||||
struct fMaterial { enum _ {
|
struct fMaterial { enum _ {
|
||||||
DebugDraw = 0x0001, /// Enable debug draw
|
DebugDraw = 0x0001, /// Enable debug draw
|
||||||
@@ -123,11 +123,11 @@ public:
|
|||||||
Default = DebugDraw,
|
Default = DebugDraw,
|
||||||
END
|
END
|
||||||
};};
|
};};
|
||||||
|
|
||||||
//
|
//
|
||||||
// API Types
|
// API Types
|
||||||
//
|
//
|
||||||
|
|
||||||
/* sRayCast */
|
/* sRayCast */
|
||||||
struct sRayCast
|
struct sRayCast
|
||||||
{
|
{
|
||||||
@@ -136,13 +136,13 @@ public:
|
|||||||
int index; /// feature index
|
int index; /// feature index
|
||||||
btScalar fraction; /// time of impact fraction (rayorg+(rayto-rayfrom)*fraction)
|
btScalar fraction; /// time of impact fraction (rayorg+(rayto-rayfrom)*fraction)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ImplicitFn */
|
/* ImplicitFn */
|
||||||
struct ImplicitFn
|
struct ImplicitFn
|
||||||
{
|
{
|
||||||
virtual btScalar Eval(const btVector3& x)=0;
|
virtual btScalar Eval(const btVector3& x)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Internal types
|
// Internal types
|
||||||
//
|
//
|
||||||
@@ -180,7 +180,7 @@ public:
|
|||||||
btScalar m_kVST; // Volume stiffness coefficient [0,1]
|
btScalar m_kVST; // Volume stiffness coefficient [0,1]
|
||||||
int m_flags; // Flags
|
int m_flags; // Flags
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Feature */
|
/* Feature */
|
||||||
struct Feature : Element
|
struct Feature : Element
|
||||||
{
|
{
|
||||||
@@ -296,7 +296,7 @@ public:
|
|||||||
btScalar m_adamping;
|
btScalar m_adamping;
|
||||||
btScalar m_matching;
|
btScalar m_matching;
|
||||||
bool m_collide;
|
bool m_collide;
|
||||||
Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) {}
|
Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping(0),m_matching(0) {}
|
||||||
};
|
};
|
||||||
/* Impulse */
|
/* Impulse */
|
||||||
struct Impulse
|
struct Impulse
|
||||||
@@ -307,109 +307,109 @@ public:
|
|||||||
int m_asDrift:1;
|
int m_asDrift:1;
|
||||||
Impulse() : m_velocity(0,0,0),m_drift(0,0,0),m_asVelocity(0),m_asDrift(0) {}
|
Impulse() : m_velocity(0,0,0),m_drift(0,0,0),m_asVelocity(0),m_asDrift(0) {}
|
||||||
Impulse operator -() const
|
Impulse operator -() const
|
||||||
{
|
{
|
||||||
Impulse i=*this;
|
Impulse i=*this;
|
||||||
i.m_velocity=-i.m_velocity;
|
i.m_velocity=-i.m_velocity;
|
||||||
i.m_drift=-i.m_drift;
|
i.m_drift=-i.m_drift;
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
Impulse operator*(btScalar x) const
|
Impulse operator*(btScalar x) const
|
||||||
{
|
{
|
||||||
Impulse i=*this;
|
Impulse i=*this;
|
||||||
i.m_velocity*=x;
|
i.m_velocity*=x;
|
||||||
i.m_drift*=x;
|
i.m_drift*=x;
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/* Body */
|
/* Body */
|
||||||
struct Body
|
struct Body
|
||||||
{
|
{
|
||||||
Cluster* m_soft;
|
Cluster* m_soft;
|
||||||
btRigidBody* m_rigid;
|
btRigidBody* m_rigid;
|
||||||
Body() : m_soft(0),m_rigid(0) {}
|
Body() : m_soft(0),m_rigid(0) {}
|
||||||
Body(Cluster* p) : m_soft(p),m_rigid(0) {}
|
Body(Cluster* p) : m_soft(p),m_rigid(0) {}
|
||||||
Body(btRigidBody* p) : m_soft(0),m_rigid(p) {}
|
Body(btRigidBody* p) : m_soft(0),m_rigid(p) {}
|
||||||
void activate() const
|
void activate() const
|
||||||
{
|
{
|
||||||
if(m_rigid) m_rigid->activate();
|
if(m_rigid) m_rigid->activate();
|
||||||
}
|
}
|
||||||
const btMatrix3x3& invWorldInertia() const
|
const btMatrix3x3& invWorldInertia() const
|
||||||
{
|
{
|
||||||
static const btMatrix3x3 iwi(0,0,0,0,0,0,0,0,0);
|
static const btMatrix3x3 iwi(0,0,0,0,0,0,0,0,0);
|
||||||
if(m_rigid) return(m_rigid->getInvInertiaTensorWorld());
|
if(m_rigid) return(m_rigid->getInvInertiaTensorWorld());
|
||||||
if(m_soft) return(m_soft->m_invwi);
|
if(m_soft) return(m_soft->m_invwi);
|
||||||
return(iwi);
|
return(iwi);
|
||||||
}
|
}
|
||||||
btScalar invMass() const
|
btScalar invMass() const
|
||||||
{
|
{
|
||||||
if(m_rigid) return(m_rigid->getInvMass());
|
if(m_rigid) return(m_rigid->getInvMass());
|
||||||
if(m_soft) return(m_soft->m_imass);
|
if(m_soft) return(m_soft->m_imass);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
const btTransform& xform() const
|
const btTransform& xform() const
|
||||||
{
|
{
|
||||||
static const btTransform identity=btTransform::getIdentity();
|
static const btTransform identity=btTransform::getIdentity();
|
||||||
if(m_rigid) return(m_rigid->getInterpolationWorldTransform());
|
if(m_rigid) return(m_rigid->getInterpolationWorldTransform());
|
||||||
if(m_soft) return(m_soft->m_framexform);
|
if(m_soft) return(m_soft->m_framexform);
|
||||||
return(identity);
|
return(identity);
|
||||||
}
|
}
|
||||||
btVector3 linearVelocity() const
|
btVector3 linearVelocity() const
|
||||||
{
|
{
|
||||||
if(m_rigid) return(m_rigid->getLinearVelocity());
|
if(m_rigid) return(m_rigid->getLinearVelocity());
|
||||||
if(m_soft) return(m_soft->m_lv);
|
if(m_soft) return(m_soft->m_lv);
|
||||||
return(btVector3(0,0,0));
|
return(btVector3(0,0,0));
|
||||||
}
|
}
|
||||||
btVector3 angularVelocity(const btVector3& rpos) const
|
btVector3 angularVelocity(const btVector3& rpos) const
|
||||||
{
|
{
|
||||||
if(m_rigid) return(cross(m_rigid->getAngularVelocity(),rpos));
|
if(m_rigid) return(cross(m_rigid->getAngularVelocity(),rpos));
|
||||||
if(m_soft) return(cross(m_soft->m_av,rpos));
|
if(m_soft) return(cross(m_soft->m_av,rpos));
|
||||||
return(btVector3(0,0,0));
|
return(btVector3(0,0,0));
|
||||||
}
|
}
|
||||||
btVector3 angularVelocity() const
|
btVector3 angularVelocity() const
|
||||||
{
|
{
|
||||||
if(m_rigid) return(m_rigid->getAngularVelocity());
|
if(m_rigid) return(m_rigid->getAngularVelocity());
|
||||||
if(m_soft) return(m_soft->m_av);
|
if(m_soft) return(m_soft->m_av);
|
||||||
return(btVector3(0,0,0));
|
return(btVector3(0,0,0));
|
||||||
}
|
}
|
||||||
btVector3 velocity(const btVector3& rpos) const
|
btVector3 velocity(const btVector3& rpos) const
|
||||||
{
|
{
|
||||||
return(linearVelocity()+angularVelocity(rpos));
|
return(linearVelocity()+angularVelocity(rpos));
|
||||||
}
|
}
|
||||||
void applyVImpulse(const btVector3& impulse,const btVector3& rpos) const
|
void applyVImpulse(const btVector3& impulse,const btVector3& rpos) const
|
||||||
{
|
{
|
||||||
if(m_rigid) m_rigid->applyImpulse(impulse,rpos);
|
if(m_rigid) m_rigid->applyImpulse(impulse,rpos);
|
||||||
if(m_soft) btSoftBody::clusterVImpulse(m_soft,rpos,impulse);
|
if(m_soft) btSoftBody::clusterVImpulse(m_soft,rpos,impulse);
|
||||||
}
|
}
|
||||||
void applyDImpulse(const btVector3& impulse,const btVector3& rpos) const
|
void applyDImpulse(const btVector3& impulse,const btVector3& rpos) const
|
||||||
{
|
{
|
||||||
if(m_rigid) m_rigid->applyImpulse(impulse,rpos);
|
if(m_rigid) m_rigid->applyImpulse(impulse,rpos);
|
||||||
if(m_soft) btSoftBody::clusterDImpulse(m_soft,rpos,impulse);
|
if(m_soft) btSoftBody::clusterDImpulse(m_soft,rpos,impulse);
|
||||||
}
|
}
|
||||||
void applyImpulse(const Impulse& impulse,const btVector3& rpos) const
|
void applyImpulse(const Impulse& impulse,const btVector3& rpos) const
|
||||||
{
|
{
|
||||||
if(impulse.m_asVelocity) applyVImpulse(impulse.m_velocity,rpos);
|
if(impulse.m_asVelocity) applyVImpulse(impulse.m_velocity,rpos);
|
||||||
if(impulse.m_asDrift) applyDImpulse(impulse.m_drift,rpos);
|
if(impulse.m_asDrift) applyDImpulse(impulse.m_drift,rpos);
|
||||||
}
|
}
|
||||||
void applyVAImpulse(const btVector3& impulse) const
|
void applyVAImpulse(const btVector3& impulse) const
|
||||||
{
|
{
|
||||||
if(m_rigid) m_rigid->applyTorqueImpulse(impulse);
|
if(m_rigid) m_rigid->applyTorqueImpulse(impulse);
|
||||||
if(m_soft) btSoftBody::clusterVAImpulse(m_soft,impulse);
|
if(m_soft) btSoftBody::clusterVAImpulse(m_soft,impulse);
|
||||||
}
|
}
|
||||||
void applyDAImpulse(const btVector3& impulse) const
|
void applyDAImpulse(const btVector3& impulse) const
|
||||||
{
|
{
|
||||||
if(m_rigid) m_rigid->applyTorqueImpulse(impulse);
|
if(m_rigid) m_rigid->applyTorqueImpulse(impulse);
|
||||||
if(m_soft) btSoftBody::clusterDAImpulse(m_soft,impulse);
|
if(m_soft) btSoftBody::clusterDAImpulse(m_soft,impulse);
|
||||||
}
|
}
|
||||||
void applyAImpulse(const Impulse& impulse) const
|
void applyAImpulse(const Impulse& impulse) const
|
||||||
{
|
{
|
||||||
if(impulse.m_asVelocity) applyVAImpulse(impulse.m_velocity);
|
if(impulse.m_asVelocity) applyVAImpulse(impulse.m_velocity);
|
||||||
if(impulse.m_asDrift) applyDAImpulse(impulse.m_drift);
|
if(impulse.m_asDrift) applyDAImpulse(impulse.m_drift);
|
||||||
}
|
}
|
||||||
void applyDCImpulse(const btVector3& impulse) const
|
void applyDCImpulse(const btVector3& impulse) const
|
||||||
{
|
{
|
||||||
if(m_rigid) m_rigid->applyCentralImpulse(impulse);
|
if(m_rigid) m_rigid->applyCentralImpulse(impulse);
|
||||||
if(m_soft) btSoftBody::clusterDCImpulse(m_soft,impulse);
|
if(m_soft) btSoftBody::clusterDCImpulse(m_soft,impulse);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/* Joint */
|
/* Joint */
|
||||||
struct Joint
|
struct Joint
|
||||||
@@ -420,12 +420,12 @@ public:
|
|||||||
Contact,
|
Contact,
|
||||||
};};
|
};};
|
||||||
struct Specs
|
struct Specs
|
||||||
{
|
{
|
||||||
Specs() : erp(1),cfm(1),split(1) {}
|
Specs() : erp(1),cfm(1),split(1) {}
|
||||||
btScalar erp;
|
btScalar erp;
|
||||||
btScalar cfm;
|
btScalar cfm;
|
||||||
btScalar split;
|
btScalar split;
|
||||||
};
|
};
|
||||||
Body m_bodies[2];
|
Body m_bodies[2];
|
||||||
btVector3 m_refs[2];
|
btVector3 m_refs[2];
|
||||||
btScalar m_cfm;
|
btScalar m_cfm;
|
||||||
@@ -436,7 +436,7 @@ public:
|
|||||||
btMatrix3x3 m_massmatrix;
|
btMatrix3x3 m_massmatrix;
|
||||||
bool m_delete;
|
bool m_delete;
|
||||||
virtual ~Joint() {}
|
virtual ~Joint() {}
|
||||||
Joint() : m_delete(false) {}
|
Joint() : m_delete(false) {}
|
||||||
virtual void Prepare(btScalar dt,int iterations);
|
virtual void Prepare(btScalar dt,int iterations);
|
||||||
virtual void Solve(btScalar dt,btScalar sor)=0;
|
virtual void Solve(btScalar dt,btScalar sor)=0;
|
||||||
virtual void Terminate(btScalar dt)=0;
|
virtual void Terminate(btScalar dt)=0;
|
||||||
@@ -446,9 +446,9 @@ public:
|
|||||||
struct LJoint : Joint
|
struct LJoint : Joint
|
||||||
{
|
{
|
||||||
struct Specs : Joint::Specs
|
struct Specs : Joint::Specs
|
||||||
{
|
{
|
||||||
btVector3 position;
|
btVector3 position;
|
||||||
};
|
};
|
||||||
btVector3 m_rpos[2];
|
btVector3 m_rpos[2];
|
||||||
void Prepare(btScalar dt,int iterations);
|
void Prepare(btScalar dt,int iterations);
|
||||||
void Solve(btScalar dt,btScalar sor);
|
void Solve(btScalar dt,btScalar sor);
|
||||||
@@ -459,17 +459,17 @@ public:
|
|||||||
struct AJoint : Joint
|
struct AJoint : Joint
|
||||||
{
|
{
|
||||||
struct IControl
|
struct IControl
|
||||||
{
|
{
|
||||||
virtual void Prepare(AJoint*) {}
|
virtual void Prepare(AJoint*) {}
|
||||||
virtual btScalar Speed(AJoint*,btScalar current) { return(current); }
|
virtual btScalar Speed(AJoint*,btScalar current) { return(current); }
|
||||||
static IControl* Default() { static IControl def;return(&def); }
|
static IControl* Default() { static IControl def;return(&def); }
|
||||||
};
|
};
|
||||||
struct Specs : Joint::Specs
|
struct Specs : Joint::Specs
|
||||||
{
|
{
|
||||||
Specs() : icontrol(IControl::Default()) {}
|
Specs() : icontrol(IControl::Default()) {}
|
||||||
btVector3 axis;
|
btVector3 axis;
|
||||||
IControl* icontrol;
|
IControl* icontrol;
|
||||||
};
|
};
|
||||||
btVector3 m_axis[2];
|
btVector3 m_axis[2];
|
||||||
IControl* m_icontrol;
|
IControl* m_icontrol;
|
||||||
void Prepare(btScalar dt,int iterations);
|
void Prepare(btScalar dt,int iterations);
|
||||||
@@ -534,24 +534,24 @@ public:
|
|||||||
};
|
};
|
||||||
/// RayFromToCaster takes a ray from, ray to (instead of direction!)
|
/// RayFromToCaster takes a ray from, ray to (instead of direction!)
|
||||||
struct RayFromToCaster : btDbvt::ICollide
|
struct RayFromToCaster : btDbvt::ICollide
|
||||||
{
|
{
|
||||||
btVector3 m_rayFrom;
|
btVector3 m_rayFrom;
|
||||||
btVector3 m_rayTo;
|
btVector3 m_rayTo;
|
||||||
btVector3 m_rayNormalizedDirection;
|
btVector3 m_rayNormalizedDirection;
|
||||||
btScalar m_mint;
|
btScalar m_mint;
|
||||||
Face* m_face;
|
Face* m_face;
|
||||||
int m_tests;
|
int m_tests;
|
||||||
RayFromToCaster(const btVector3& rayFrom,const btVector3& rayTo,btScalar mxt);
|
RayFromToCaster(const btVector3& rayFrom,const btVector3& rayTo,btScalar mxt);
|
||||||
void Process(const btDbvtNode* leaf);
|
void Process(const btDbvtNode* leaf);
|
||||||
|
|
||||||
static inline btScalar rayFromToTriangle(const btVector3& rayFrom,
|
static inline btScalar rayFromToTriangle(const btVector3& rayFrom,
|
||||||
const btVector3& rayTo,
|
const btVector3& rayTo,
|
||||||
const btVector3& rayNormalizedDirection,
|
const btVector3& rayNormalizedDirection,
|
||||||
const btVector3& a,
|
const btVector3& a,
|
||||||
const btVector3& b,
|
const btVector3& b,
|
||||||
const btVector3& c,
|
const btVector3& c,
|
||||||
btScalar maxt=SIMD_INFINITY);
|
btScalar maxt=SIMD_INFINITY);
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Typedef's
|
// Typedef's
|
||||||
@@ -597,15 +597,15 @@ public:
|
|||||||
btDbvt m_fdbvt; // Faces tree
|
btDbvt m_fdbvt; // Faces tree
|
||||||
btDbvt m_cdbvt; // Clusters tree
|
btDbvt m_cdbvt; // Clusters tree
|
||||||
tClusterArray m_clusters; // Clusters
|
tClusterArray m_clusters; // Clusters
|
||||||
|
|
||||||
//
|
//
|
||||||
// Api
|
// Api
|
||||||
//
|
//
|
||||||
|
|
||||||
/* ctor */
|
/* ctor */
|
||||||
btSoftBody( btSoftBodyWorldInfo* worldInfo,int node_count,
|
btSoftBody( btSoftBodyWorldInfo* worldInfo,int node_count,
|
||||||
const btVector3* x,
|
const btVector3* x,
|
||||||
const btScalar* m);
|
const btScalar* m);
|
||||||
/* dtor */
|
/* dtor */
|
||||||
virtual ~btSoftBody();
|
virtual ~btSoftBody();
|
||||||
/* Check for existing link */
|
/* Check for existing link */
|
||||||
@@ -625,51 +625,51 @@ public:
|
|||||||
bool checkLink( int node0,
|
bool checkLink( int node0,
|
||||||
int node1) const;
|
int node1) const;
|
||||||
bool checkLink( const Node* node0,
|
bool checkLink( const Node* node0,
|
||||||
const Node* node1) const;
|
const Node* node1) const;
|
||||||
/* Check for existring face */
|
/* Check for existring face */
|
||||||
bool checkFace( int node0,
|
bool checkFace( int node0,
|
||||||
int node1,
|
int node1,
|
||||||
int node2) const;
|
int node2) const;
|
||||||
/* Append material */
|
/* Append material */
|
||||||
Material* appendMaterial();
|
Material* appendMaterial();
|
||||||
/* Append note */
|
/* Append note */
|
||||||
void appendNote( const char* text,
|
void appendNote( const char* text,
|
||||||
const btVector3& o,
|
const btVector3& o,
|
||||||
const btVector4& c=btVector4(1,0,0,0),
|
const btVector4& c=btVector4(1,0,0,0),
|
||||||
Node* n0=0,
|
Node* n0=0,
|
||||||
Node* n1=0,
|
Node* n1=0,
|
||||||
Node* n2=0,
|
Node* n2=0,
|
||||||
Node* n3=0);
|
Node* n3=0);
|
||||||
void appendNote( const char* text,
|
void appendNote( const char* text,
|
||||||
const btVector3& o,
|
const btVector3& o,
|
||||||
Node* feature);
|
Node* feature);
|
||||||
void appendNote( const char* text,
|
void appendNote( const char* text,
|
||||||
const btVector3& o,
|
const btVector3& o,
|
||||||
Link* feature);
|
Link* feature);
|
||||||
void appendNote( const char* text,
|
void appendNote( const char* text,
|
||||||
const btVector3& o,
|
const btVector3& o,
|
||||||
Face* feature);
|
Face* feature);
|
||||||
/* Append node */
|
/* Append node */
|
||||||
void appendNode( const btVector3& x,btScalar m);
|
void appendNode( const btVector3& x,btScalar m);
|
||||||
/* Append link */
|
/* Append link */
|
||||||
void appendLink(int model=-1,Material* mat=0);
|
void appendLink(int model=-1,Material* mat=0);
|
||||||
void appendLink( int node0,
|
void appendLink( int node0,
|
||||||
int node1,
|
int node1,
|
||||||
Material* mat=0,
|
Material* mat=0,
|
||||||
bool bcheckexist=false);
|
bool bcheckexist=false);
|
||||||
void appendLink( Node* node0,
|
void appendLink( Node* node0,
|
||||||
Node* node1,
|
Node* node1,
|
||||||
Material* mat=0,
|
Material* mat=0,
|
||||||
bool bcheckexist=false);
|
bool bcheckexist=false);
|
||||||
/* Append face */
|
/* Append face */
|
||||||
void appendFace(int model=-1,Material* mat=0);
|
void appendFace(int model=-1,Material* mat=0);
|
||||||
void appendFace( int node0,
|
void appendFace( int node0,
|
||||||
int node1,
|
int node1,
|
||||||
int node2,
|
int node2,
|
||||||
Material* mat=0);
|
Material* mat=0);
|
||||||
/* Append anchor */
|
/* Append anchor */
|
||||||
void appendAnchor( int node,
|
void appendAnchor( int node,
|
||||||
btRigidBody* body);
|
btRigidBody* body);
|
||||||
/* Append linear joint */
|
/* Append linear joint */
|
||||||
void appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1);
|
void appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1);
|
||||||
void appendLinearJoint(const LJoint::Specs& specs,Body body=Body());
|
void appendLinearJoint(const LJoint::Specs& specs,Body body=Body());
|
||||||
@@ -682,7 +682,7 @@ public:
|
|||||||
void addForce( const btVector3& force);
|
void addForce( const btVector3& force);
|
||||||
/* Add force (or gravity) to a node of the body */
|
/* Add force (or gravity) to a node of the body */
|
||||||
void addForce( const btVector3& force,
|
void addForce( const btVector3& force,
|
||||||
int node);
|
int node);
|
||||||
/* Add velocity to the entire body */
|
/* Add velocity to the entire body */
|
||||||
void addVelocity( const btVector3& velocity);
|
void addVelocity( const btVector3& velocity);
|
||||||
|
|
||||||
@@ -691,17 +691,17 @@ public:
|
|||||||
|
|
||||||
/* Add velocity to a node of the body */
|
/* Add velocity to a node of the body */
|
||||||
void addVelocity( const btVector3& velocity,
|
void addVelocity( const btVector3& velocity,
|
||||||
int node);
|
int node);
|
||||||
/* Set mass */
|
/* Set mass */
|
||||||
void setMass( int node,
|
void setMass( int node,
|
||||||
btScalar mass);
|
btScalar mass);
|
||||||
/* Get mass */
|
/* Get mass */
|
||||||
btScalar getMass( int node) const;
|
btScalar getMass( int node) const;
|
||||||
/* Get total mass */
|
/* Get total mass */
|
||||||
btScalar getTotalMass() const;
|
btScalar getTotalMass() const;
|
||||||
/* Set total mass (weighted by previous masses) */
|
/* Set total mass (weighted by previous masses) */
|
||||||
void setTotalMass( btScalar mass,
|
void setTotalMass( btScalar mass,
|
||||||
bool fromfaces=false);
|
bool fromfaces=false);
|
||||||
/* Set total density */
|
/* Set total density */
|
||||||
void setTotalDensity(btScalar density);
|
void setTotalDensity(btScalar density);
|
||||||
/* Transform */
|
/* Transform */
|
||||||
@@ -714,7 +714,7 @@ public:
|
|||||||
void scale( const btVector3& scl);
|
void scale( const btVector3& scl);
|
||||||
/* Set current state as pose */
|
/* Set current state as pose */
|
||||||
void setPose( bool bvolume,
|
void setPose( bool bvolume,
|
||||||
bool bframe);
|
bool bframe);
|
||||||
/* Return the volume */
|
/* Return the volume */
|
||||||
btScalar getVolume() const;
|
btScalar getVolume() const;
|
||||||
/* Cluster count */
|
/* Cluster count */
|
||||||
@@ -734,7 +734,7 @@ public:
|
|||||||
static void clusterDCImpulse(Cluster* cluster,const btVector3& impulse);
|
static void clusterDCImpulse(Cluster* cluster,const btVector3& impulse);
|
||||||
/* Generate bending constraints based on distance in the adjency graph */
|
/* Generate bending constraints based on distance in the adjency graph */
|
||||||
int generateBendingConstraints( int distance,
|
int generateBendingConstraints( int distance,
|
||||||
Material* mat=0);
|
Material* mat=0);
|
||||||
/* Randomize constraints to reduce solver bias */
|
/* Randomize constraints to reduce solver bias */
|
||||||
void randomizeConstraints();
|
void randomizeConstraints();
|
||||||
/* Release clusters */
|
/* Release clusters */
|
||||||
@@ -747,11 +747,11 @@ public:
|
|||||||
/* CutLink */
|
/* CutLink */
|
||||||
bool cutLink(int node0,int node1,btScalar position);
|
bool cutLink(int node0,int node1,btScalar position);
|
||||||
bool cutLink(const Node* node0,const Node* node1,btScalar position);
|
bool cutLink(const Node* node0,const Node* node1,btScalar position);
|
||||||
|
|
||||||
///Ray casting using rayFrom and rayTo in worldspace, (not direction!)
|
///Ray casting using rayFrom and rayTo in worldspace, (not direction!)
|
||||||
bool rayTest(const btVector3& rayFrom,
|
bool rayTest(const btVector3& rayFrom,
|
||||||
const btVector3& rayTo,
|
const btVector3& rayTo,
|
||||||
sRayCast& results);
|
sRayCast& results);
|
||||||
/* Solver presets */
|
/* Solver presets */
|
||||||
void setSolver(eSolverPresets::_ preset);
|
void setSolver(eSolverPresets::_ preset);
|
||||||
/* predictMotion */
|
/* predictMotion */
|
||||||
@@ -769,11 +769,11 @@ public:
|
|||||||
/* defaultCollisionHandlers */
|
/* defaultCollisionHandlers */
|
||||||
void defaultCollisionHandler(btCollisionObject* pco);
|
void defaultCollisionHandler(btCollisionObject* pco);
|
||||||
void defaultCollisionHandler(btSoftBody* psb);
|
void defaultCollisionHandler(btSoftBody* psb);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Cast
|
// Cast
|
||||||
//
|
//
|
||||||
|
|
||||||
static const btSoftBody* upcast(const btCollisionObject* colObj)
|
static const btSoftBody* upcast(const btCollisionObject* colObj)
|
||||||
{
|
{
|
||||||
if (colObj->getInternalType()==CO_SOFT_BODY)
|
if (colObj->getInternalType()==CO_SOFT_BODY)
|
||||||
@@ -803,7 +803,7 @@ public:
|
|||||||
void indicesToPointers(const int* map=0);
|
void indicesToPointers(const int* map=0);
|
||||||
|
|
||||||
int rayTest(const btVector3& rayFrom,const btVector3& rayTo,
|
int rayTest(const btVector3& rayFrom,const btVector3& rayTo,
|
||||||
btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const;
|
btScalar& mint,eFeature::_& feature,int& index,bool bcountonly) const;
|
||||||
void initializeFaceTree();
|
void initializeFaceTree();
|
||||||
btVector3 evaluateCom() const;
|
btVector3 evaluateCom() const;
|
||||||
bool checkContact(btRigidBody* prb,const btVector3& x,btScalar margin,btSoftBody::sCti& cti) const;
|
bool checkContact(btRigidBody* prb,const btVector3& x,btScalar margin,btSoftBody::sCti& cti) const;
|
||||||
@@ -826,7 +826,7 @@ public:
|
|||||||
static void VSolve_Links(btSoftBody* psb,btScalar kst);
|
static void VSolve_Links(btSoftBody* psb,btScalar kst);
|
||||||
static psolver_t getSolver(ePSolver::_ solver);
|
static psolver_t getSolver(ePSolver::_ solver);
|
||||||
static vsolver_t getSolver(eVSolver::_ solver);
|
static vsolver_t getSolver(eVSolver::_ solver);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,27 +50,27 @@ btSoftBodyConcaveCollisionAlgorithm::~btSoftBodyConcaveCollisionAlgorithm()
|
|||||||
|
|
||||||
|
|
||||||
btSoftBodyTriangleCallback::btSoftBodyTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped):
|
btSoftBodyTriangleCallback::btSoftBodyTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped):
|
||||||
m_dispatcher(dispatcher),
|
m_dispatcher(dispatcher),
|
||||||
m_dispatchInfoPtr(0)
|
m_dispatchInfoPtr(0)
|
||||||
{
|
{
|
||||||
m_softBody = (btSoftBody*) (isSwapped? body1:body0);
|
m_softBody = (btSoftBody*) (isSwapped? body1:body0);
|
||||||
m_triBody = isSwapped? body0:body1;
|
m_triBody = isSwapped? body0:body1;
|
||||||
|
|
||||||
//
|
|
||||||
// create the manifold from the dispatcher 'manifold pool'
|
|
||||||
//
|
|
||||||
// m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBody,m_triBody);
|
|
||||||
|
|
||||||
clearCache();
|
//
|
||||||
|
// create the manifold from the dispatcher 'manifold pool'
|
||||||
|
//
|
||||||
|
// m_manifoldPtr = m_dispatcher->getNewManifold(m_convexBody,m_triBody);
|
||||||
|
|
||||||
|
clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
btSoftBodyTriangleCallback::~btSoftBodyTriangleCallback()
|
btSoftBodyTriangleCallback::~btSoftBodyTriangleCallback()
|
||||||
{
|
{
|
||||||
clearCache();
|
clearCache();
|
||||||
// m_dispatcher->releaseManifold( m_manifoldPtr );
|
// m_dispatcher->releaseManifold( m_manifoldPtr );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void btSoftBodyTriangleCallback::clearCache()
|
void btSoftBodyTriangleCallback::clearCache()
|
||||||
{
|
{
|
||||||
@@ -88,13 +88,13 @@ void btSoftBodyTriangleCallback::clearCache()
|
|||||||
|
|
||||||
void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex)
|
void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex)
|
||||||
{
|
{
|
||||||
//just for debugging purposes
|
//just for debugging purposes
|
||||||
//printf("triangle %d",m_triangleCount++);
|
//printf("triangle %d",m_triangleCount++);
|
||||||
btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBody);
|
btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBody);
|
||||||
btCollisionAlgorithmConstructionInfo ci;
|
btCollisionAlgorithmConstructionInfo ci;
|
||||||
ci.m_dispatcher1 = m_dispatcher;
|
ci.m_dispatcher1 = m_dispatcher;
|
||||||
|
|
||||||
///debug drawing of the overlapping triangles
|
///debug drawing of the overlapping triangles
|
||||||
if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
|
if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
|
||||||
{
|
{
|
||||||
btVector3 color(255,255,0);
|
btVector3 color(255,255,0);
|
||||||
@@ -107,7 +107,7 @@ void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId,
|
|||||||
btTriIndex triIndex(partId,triangleIndex,0);
|
btTriIndex triIndex(partId,triangleIndex,0);
|
||||||
btHashKey<btTriIndex> triKey(triIndex.getUid());
|
btHashKey<btTriIndex> triKey(triIndex.getUid());
|
||||||
|
|
||||||
|
|
||||||
btTriIndex* shapeIndex = m_shapeCache[triKey];
|
btTriIndex* shapeIndex = m_shapeCache[triKey];
|
||||||
if (shapeIndex)
|
if (shapeIndex)
|
||||||
{
|
{
|
||||||
@@ -116,13 +116,13 @@ void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId,
|
|||||||
|
|
||||||
//copy over user pointers to temporary shape
|
//copy over user pointers to temporary shape
|
||||||
tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());
|
tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());
|
||||||
|
|
||||||
btCollisionShape* tmpShape = ob->getCollisionShape();
|
btCollisionShape* tmpShape = ob->getCollisionShape();
|
||||||
ob->internalSetTemporaryCollisionShape( tm );
|
ob->internalSetTemporaryCollisionShape( tm );
|
||||||
|
|
||||||
|
|
||||||
btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);
|
btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);
|
||||||
|
|
||||||
colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
||||||
colAlgo->~btCollisionAlgorithm();
|
colAlgo->~btCollisionAlgorithm();
|
||||||
ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
|
ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
|
||||||
@@ -133,56 +133,56 @@ void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId,
|
|||||||
//aabb filter is already applied!
|
//aabb filter is already applied!
|
||||||
|
|
||||||
//btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);
|
//btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);
|
||||||
|
|
||||||
// if (m_softBody->getCollisionShape()->getShapeType()==
|
// if (m_softBody->getCollisionShape()->getShapeType()==
|
||||||
{
|
{
|
||||||
// btVector3 other;
|
// btVector3 other;
|
||||||
btVector3 normal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]);
|
btVector3 normal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]);
|
||||||
normal.normalize();
|
normal.normalize();
|
||||||
normal*= BT_SOFTBODY_TRIANGLE_EXTRUSION;
|
normal*= BT_SOFTBODY_TRIANGLE_EXTRUSION;
|
||||||
// other=(triangle[0]+triangle[1]+triangle[2])*0.333333f;
|
// other=(triangle[0]+triangle[1]+triangle[2])*0.333333f;
|
||||||
// other+=normal*22.f;
|
// other+=normal*22.f;
|
||||||
btVector3 pts[6] = {triangle[0]+normal,
|
btVector3 pts[6] = {triangle[0]+normal,
|
||||||
triangle[1]+normal,
|
triangle[1]+normal,
|
||||||
triangle[2]+normal,
|
triangle[2]+normal,
|
||||||
triangle[0]-normal,
|
triangle[0]-normal,
|
||||||
triangle[1]-normal,
|
triangle[1]-normal,
|
||||||
triangle[2]-normal};
|
triangle[2]-normal};
|
||||||
|
|
||||||
btConvexHullShape* tm = new btConvexHullShape(&pts[0].getX(),6);
|
btConvexHullShape* tm = new btConvexHullShape(&pts[0].getX(),6);
|
||||||
|
|
||||||
|
|
||||||
// btBU_Simplex1to4 tm(triangle[0],triangle[1],triangle[2],other);
|
// btBU_Simplex1to4 tm(triangle[0],triangle[1],triangle[2],other);
|
||||||
|
|
||||||
//btTriangleShape tm(triangle[0],triangle[1],triangle[2]);
|
//btTriangleShape tm(triangle[0],triangle[1],triangle[2]);
|
||||||
// tm.setMargin(m_collisionMarginTriangle);
|
// tm.setMargin(m_collisionMarginTriangle);
|
||||||
|
|
||||||
//copy over user pointers to temporary shape
|
//copy over user pointers to temporary shape
|
||||||
tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());
|
tm->setUserPointer(ob->getRootCollisionShape()->getUserPointer());
|
||||||
|
|
||||||
btCollisionShape* tmpShape = ob->getCollisionShape();
|
btCollisionShape* tmpShape = ob->getCollisionShape();
|
||||||
ob->internalSetTemporaryCollisionShape( tm );
|
ob->internalSetTemporaryCollisionShape( tm );
|
||||||
|
|
||||||
|
|
||||||
btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);
|
btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_softBody,m_triBody,0);//m_manifoldPtr);
|
||||||
///this should use the btDispatcher, so the actual registered algorithm is used
|
///this should use the btDispatcher, so the actual registered algorithm is used
|
||||||
// btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody);
|
// btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody);
|
||||||
|
|
||||||
//m_resultOut->setShapeIdentifiers(-1,-1,partId,triangleIndex);
|
//m_resultOut->setShapeIdentifiers(-1,-1,partId,triangleIndex);
|
||||||
// cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
|
// cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
|
||||||
// cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
// cvxcvxalgo.processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
||||||
colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
colAlgo->processCollision(m_softBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
||||||
colAlgo->~btCollisionAlgorithm();
|
colAlgo->~btCollisionAlgorithm();
|
||||||
ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
|
ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
|
||||||
|
|
||||||
|
|
||||||
ob->internalSetTemporaryCollisionShape( tmpShape );
|
ob->internalSetTemporaryCollisionShape( tmpShape );
|
||||||
triIndex.m_childShape = tm;
|
triIndex.m_childShape = tm;
|
||||||
m_shapeCache.insert(triKey,triIndex);
|
m_shapeCache.insert(triKey,triIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ void btSoftBodyTriangleCallback::setTimeStepAndCounters(btScalar collisionMargin
|
|||||||
m_collisionMarginTriangle = collisionMarginTriangle+btScalar(BT_SOFTBODY_TRIANGLE_EXTRUSION);
|
m_collisionMarginTriangle = collisionMarginTriangle+btScalar(BT_SOFTBODY_TRIANGLE_EXTRUSION);
|
||||||
m_resultOut = resultOut;
|
m_resultOut = resultOut;
|
||||||
|
|
||||||
|
|
||||||
btVector3 aabbWorldSpaceMin,aabbWorldSpaceMax;
|
btVector3 aabbWorldSpaceMin,aabbWorldSpaceMax;
|
||||||
m_softBody->getAabb(aabbWorldSpaceMin,aabbWorldSpaceMax);
|
m_softBody->getAabb(aabbWorldSpaceMin,aabbWorldSpaceMax);
|
||||||
btVector3 halfExtents = (aabbWorldSpaceMax-aabbWorldSpaceMin)*btScalar(0.5);
|
btVector3 halfExtents = (aabbWorldSpaceMax-aabbWorldSpaceMin)*btScalar(0.5);
|
||||||
@@ -217,8 +217,8 @@ void btSoftBodyConcaveCollisionAlgorithm::clearCache()
|
|||||||
|
|
||||||
void btSoftBodyConcaveCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
void btSoftBodyConcaveCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
btCollisionObject* convexBody = m_isSwapped ? body1 : body0;
|
btCollisionObject* convexBody = m_isSwapped ? body1 : body0;
|
||||||
btCollisionObject* triBody = m_isSwapped ? body0 : body1;
|
btCollisionObject* triBody = m_isSwapped ? body0 : body1;
|
||||||
|
|
||||||
@@ -228,26 +228,26 @@ void btSoftBodyConcaveCollisionAlgorithm::processCollision (btCollisionObject* b
|
|||||||
|
|
||||||
btCollisionObject* triOb = triBody;
|
btCollisionObject* triOb = triBody;
|
||||||
btConcaveShape* concaveShape = static_cast<btConcaveShape*>( triOb->getCollisionShape());
|
btConcaveShape* concaveShape = static_cast<btConcaveShape*>( triOb->getCollisionShape());
|
||||||
|
|
||||||
// if (convexBody->getCollisionShape()->isConvex())
|
// if (convexBody->getCollisionShape()->isConvex())
|
||||||
{
|
{
|
||||||
btScalar collisionMarginTriangle = concaveShape->getMargin();
|
btScalar collisionMarginTriangle = concaveShape->getMargin();
|
||||||
|
|
||||||
// resultOut->setPersistentManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr);
|
// resultOut->setPersistentManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr);
|
||||||
m_btSoftBodyTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut);
|
m_btSoftBodyTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut);
|
||||||
|
|
||||||
//Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here.
|
//Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here.
|
||||||
//m_dispatcher->clearManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr);
|
//m_dispatcher->clearManifold(m_btSoftBodyTriangleCallback.m_manifoldPtr);
|
||||||
|
|
||||||
// m_btSoftBodyTriangleCallback.m_manifoldPtr->setBodies(convexBody,triBody);
|
// m_btSoftBodyTriangleCallback.m_manifoldPtr->setBodies(convexBody,triBody);
|
||||||
|
|
||||||
|
|
||||||
concaveShape->processAllTriangles( &m_btSoftBodyTriangleCallback,m_btSoftBodyTriangleCallback.getAabbMin(),m_btSoftBodyTriangleCallback.getAabbMax());
|
concaveShape->processAllTriangles( &m_btSoftBodyTriangleCallback,m_btSoftBodyTriangleCallback.getAabbMin(),m_btSoftBodyTriangleCallback.getAabbMax());
|
||||||
|
|
||||||
// resultOut->refreshContactPoints();
|
// resultOut->refreshContactPoints();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionO
|
|||||||
|
|
||||||
btScalar m_ccdSphereRadius;
|
btScalar m_ccdSphereRadius;
|
||||||
btScalar m_hitFraction;
|
btScalar m_hitFraction;
|
||||||
|
|
||||||
|
|
||||||
LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,btScalar ccdSphereRadius,btScalar hitFraction)
|
LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,btScalar ccdSphereRadius,btScalar hitFraction)
|
||||||
:m_ccdSphereFromTrans(from),
|
:m_ccdSphereFromTrans(from),
|
||||||
@@ -296,8 +296,8 @@ btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionO
|
|||||||
m_hitFraction(hitFraction)
|
m_hitFraction(hitFraction)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
|
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
|
||||||
{
|
{
|
||||||
(void)partId;
|
(void)partId;
|
||||||
@@ -327,9 +327,9 @@ btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionO
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (triBody->getCollisionShape()->isConcave())
|
if (triBody->getCollisionShape()->isConcave())
|
||||||
{
|
{
|
||||||
btVector3 rayAabbMin = convexFromLocal.getOrigin();
|
btVector3 rayAabbMin = convexFromLocal.getOrigin();
|
||||||
@@ -349,12 +349,12 @@ btScalar btSoftBodyConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionO
|
|||||||
btCollisionObject* concavebody = triBody;
|
btCollisionObject* concavebody = triBody;
|
||||||
|
|
||||||
btConcaveShape* triangleMesh = (btConcaveShape*) concavebody->getCollisionShape();
|
btConcaveShape* triangleMesh = (btConcaveShape*) concavebody->getCollisionShape();
|
||||||
|
|
||||||
if (triangleMesh)
|
if (triangleMesh)
|
||||||
{
|
{
|
||||||
triangleMesh->processAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax);
|
triangleMesh->processAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (raycastCallback.m_hitFraction < convexbody->getHitFraction())
|
if (raycastCallback.m_hitFraction < convexbody->getHitFraction())
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ struct btTriIndex
|
|||||||
{
|
{
|
||||||
int m_PartIdTriangleIndex;
|
int m_PartIdTriangleIndex;
|
||||||
class btCollisionShape* m_childShape;
|
class btCollisionShape* m_childShape;
|
||||||
|
|
||||||
btTriIndex(int partId,int triangleIndex,btCollisionShape* shape)
|
btTriIndex(int partId,int triangleIndex,btCollisionShape* shape)
|
||||||
{
|
{
|
||||||
m_PartIdTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex;
|
m_PartIdTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex;
|
||||||
@@ -75,11 +75,11 @@ class btSoftBodyTriangleCallback : public btTriangleCallback
|
|||||||
btScalar m_collisionMarginTriangle;
|
btScalar m_collisionMarginTriangle;
|
||||||
|
|
||||||
btHashMap<btHashKey<btTriIndex>,btTriIndex> m_shapeCache;
|
btHashMap<btHashKey<btTriIndex>,btTriIndex> m_shapeCache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int m_triangleCount;
|
int m_triangleCount;
|
||||||
|
|
||||||
// btPersistentManifold* m_manifoldPtr;
|
// btPersistentManifold* m_manifoldPtr;
|
||||||
|
|
||||||
btSoftBodyTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
|
btSoftBodyTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ int m_triangleCount;
|
|||||||
virtual ~btSoftBodyTriangleCallback();
|
virtual ~btSoftBodyTriangleCallback();
|
||||||
|
|
||||||
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
|
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
|
||||||
|
|
||||||
void clearCache();
|
void clearCache();
|
||||||
|
|
||||||
SIMD_FORCE_INLINE const btVector3& getAabbMin() const
|
SIMD_FORCE_INLINE const btVector3& getAabbMin() const
|
||||||
|
|||||||
@@ -22,57 +22,57 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
//
|
//
|
||||||
static void drawVertex( btIDebugDraw* idraw,
|
static void drawVertex( btIDebugDraw* idraw,
|
||||||
const btVector3& x,btScalar s,const btVector3& c)
|
const btVector3& x,btScalar s,const btVector3& c)
|
||||||
{
|
{
|
||||||
idraw->drawLine(x-btVector3(s,0,0),x+btVector3(s,0,0),c);
|
idraw->drawLine(x-btVector3(s,0,0),x+btVector3(s,0,0),c);
|
||||||
idraw->drawLine(x-btVector3(0,s,0),x+btVector3(0,s,0),c);
|
idraw->drawLine(x-btVector3(0,s,0),x+btVector3(0,s,0),c);
|
||||||
idraw->drawLine(x-btVector3(0,0,s),x+btVector3(0,0,s),c);
|
idraw->drawLine(x-btVector3(0,0,s),x+btVector3(0,0,s),c);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static void drawBox( btIDebugDraw* idraw,
|
static void drawBox( btIDebugDraw* idraw,
|
||||||
const btVector3& mins,
|
const btVector3& mins,
|
||||||
const btVector3& maxs,
|
const btVector3& maxs,
|
||||||
const btVector3& color)
|
const btVector3& color)
|
||||||
{
|
{
|
||||||
const btVector3 c[]={ btVector3(mins.x(),mins.y(),mins.z()),
|
const btVector3 c[]={ btVector3(mins.x(),mins.y(),mins.z()),
|
||||||
btVector3(maxs.x(),mins.y(),mins.z()),
|
btVector3(maxs.x(),mins.y(),mins.z()),
|
||||||
btVector3(maxs.x(),maxs.y(),mins.z()),
|
btVector3(maxs.x(),maxs.y(),mins.z()),
|
||||||
btVector3(mins.x(),maxs.y(),mins.z()),
|
btVector3(mins.x(),maxs.y(),mins.z()),
|
||||||
btVector3(mins.x(),mins.y(),maxs.z()),
|
btVector3(mins.x(),mins.y(),maxs.z()),
|
||||||
btVector3(maxs.x(),mins.y(),maxs.z()),
|
btVector3(maxs.x(),mins.y(),maxs.z()),
|
||||||
btVector3(maxs.x(),maxs.y(),maxs.z()),
|
btVector3(maxs.x(),maxs.y(),maxs.z()),
|
||||||
btVector3(mins.x(),maxs.y(),maxs.z())};
|
btVector3(mins.x(),maxs.y(),maxs.z())};
|
||||||
idraw->drawLine(c[0],c[1],color);idraw->drawLine(c[1],c[2],color);
|
idraw->drawLine(c[0],c[1],color);idraw->drawLine(c[1],c[2],color);
|
||||||
idraw->drawLine(c[2],c[3],color);idraw->drawLine(c[3],c[0],color);
|
idraw->drawLine(c[2],c[3],color);idraw->drawLine(c[3],c[0],color);
|
||||||
idraw->drawLine(c[4],c[5],color);idraw->drawLine(c[5],c[6],color);
|
idraw->drawLine(c[4],c[5],color);idraw->drawLine(c[5],c[6],color);
|
||||||
idraw->drawLine(c[6],c[7],color);idraw->drawLine(c[7],c[4],color);
|
idraw->drawLine(c[6],c[7],color);idraw->drawLine(c[7],c[4],color);
|
||||||
idraw->drawLine(c[0],c[4],color);idraw->drawLine(c[1],c[5],color);
|
idraw->drawLine(c[0],c[4],color);idraw->drawLine(c[1],c[5],color);
|
||||||
idraw->drawLine(c[2],c[6],color);idraw->drawLine(c[3],c[7],color);
|
idraw->drawLine(c[2],c[6],color);idraw->drawLine(c[3],c[7],color);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
static void drawTree( btIDebugDraw* idraw,
|
static void drawTree( btIDebugDraw* idraw,
|
||||||
const btDbvtNode* node,
|
const btDbvtNode* node,
|
||||||
int depth,
|
int depth,
|
||||||
const btVector3& ncolor,
|
const btVector3& ncolor,
|
||||||
const btVector3& lcolor,
|
const btVector3& lcolor,
|
||||||
int mindepth,
|
int mindepth,
|
||||||
int maxdepth)
|
int maxdepth)
|
||||||
{
|
{
|
||||||
if(node)
|
if(node)
|
||||||
{
|
{
|
||||||
if(node->isinternal()&&((depth<maxdepth)||(maxdepth<0)))
|
if(node->isinternal()&&((depth<maxdepth)||(maxdepth<0)))
|
||||||
{
|
{
|
||||||
drawTree(idraw,node->childs[0],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
drawTree(idraw,node->childs[0],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||||
drawTree(idraw,node->childs[1],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
drawTree(idraw,node->childs[1],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||||
}
|
}
|
||||||
if(depth>=mindepth)
|
if(depth>=mindepth)
|
||||||
{
|
{
|
||||||
const btScalar scl=(btScalar)(node->isinternal()?1:1);
|
const btScalar scl=(btScalar)(node->isinternal()?1:1);
|
||||||
const btVector3 mi=node->volume.Center()-node->volume.Extents()*scl;
|
const btVector3 mi=node->volume.Center()-node->volume.Extents()*scl;
|
||||||
const btVector3 mx=node->volume.Center()+node->volume.Extents()*scl;
|
const btVector3 mx=node->volume.Center()+node->volume.Extents()*scl;
|
||||||
drawBox(idraw,mi,mx,node->isleaf()?lcolor:ncolor);
|
drawBox(idraw,mi,mx,node->isleaf()?lcolor:ncolor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,25 +81,25 @@ if(node)
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
static inline T sum(const btAlignedObjectArray<T>& items)
|
static inline T sum(const btAlignedObjectArray<T>& items)
|
||||||
{
|
{
|
||||||
T v;
|
T v;
|
||||||
if(items.size())
|
if(items.size())
|
||||||
{
|
{
|
||||||
v=items[0];
|
v=items[0];
|
||||||
for(int i=1,ni=items.size();i<ni;++i)
|
for(int i=1,ni=items.size();i<ni;++i)
|
||||||
{
|
{
|
||||||
v+=items[i];
|
v+=items[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(v);
|
return(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
template <typename T,typename Q>
|
template <typename T,typename Q>
|
||||||
static inline void add(btAlignedObjectArray<T>& items,const Q& value)
|
static inline void add(btAlignedObjectArray<T>& items,const Q& value)
|
||||||
{
|
{
|
||||||
for(int i=0,ni=items.size();i<ni;++i)
|
for(int i=0,ni=items.size();i<ni;++i)
|
||||||
{
|
{
|
||||||
items[i]+=value;
|
items[i]+=value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,9 +107,9 @@ for(int i=0,ni=items.size();i<ni;++i)
|
|||||||
template <typename T,typename Q>
|
template <typename T,typename Q>
|
||||||
static inline void mul(btAlignedObjectArray<T>& items,const Q& value)
|
static inline void mul(btAlignedObjectArray<T>& items,const Q& value)
|
||||||
{
|
{
|
||||||
for(int i=0,ni=items.size();i<ni;++i)
|
for(int i=0,ni=items.size();i<ni;++i)
|
||||||
{
|
{
|
||||||
items[i]*=value;
|
items[i]*=value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,8 +117,8 @@ for(int i=0,ni=items.size();i<ni;++i)
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
static inline T average(const btAlignedObjectArray<T>& items)
|
static inline T average(const btAlignedObjectArray<T>& items)
|
||||||
{
|
{
|
||||||
const btScalar n=(btScalar)(items.size()>0?items.size():1);
|
const btScalar n=(btScalar)(items.size()>0?items.size():1);
|
||||||
return(sum(items)/n);
|
return(sum(items)/n);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -136,27 +136,27 @@ static inline btScalar tetravolume(const btVector3& x0,
|
|||||||
//
|
//
|
||||||
#if 0
|
#if 0
|
||||||
static btVector3 stresscolor(btScalar stress)
|
static btVector3 stresscolor(btScalar stress)
|
||||||
{
|
{
|
||||||
static const btVector3 spectrum[]= { btVector3(1,0,1),
|
static const btVector3 spectrum[]= { btVector3(1,0,1),
|
||||||
btVector3(0,0,1),
|
btVector3(0,0,1),
|
||||||
btVector3(0,1,1),
|
btVector3(0,1,1),
|
||||||
btVector3(0,1,0),
|
btVector3(0,1,0),
|
||||||
btVector3(1,1,0),
|
btVector3(1,1,0),
|
||||||
btVector3(1,0,0),
|
btVector3(1,0,0),
|
||||||
btVector3(1,0,0)};
|
btVector3(1,0,0)};
|
||||||
static const int ncolors=sizeof(spectrum)/sizeof(spectrum[0])-1;
|
static const int ncolors=sizeof(spectrum)/sizeof(spectrum[0])-1;
|
||||||
static const btScalar one=1;
|
static const btScalar one=1;
|
||||||
stress=btMax<btScalar>(0,btMin<btScalar>(1,stress))*ncolors;
|
stress=btMax<btScalar>(0,btMin<btScalar>(1,stress))*ncolors;
|
||||||
const int sel=(int)stress;
|
const int sel=(int)stress;
|
||||||
const btScalar frc=stress-sel;
|
const btScalar frc=stress-sel;
|
||||||
return(spectrum[sel]+(spectrum[sel+1]-spectrum[sel])*frc);
|
return(spectrum[sel]+(spectrum[sel+1]-spectrum[sel])*frc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
int drawflags)
|
int drawflags)
|
||||||
{
|
{
|
||||||
const btScalar scl=(btScalar)0.1;
|
const btScalar scl=(btScalar)0.1;
|
||||||
const btScalar nscl=scl*5;
|
const btScalar nscl=scl*5;
|
||||||
@@ -251,29 +251,29 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
|||||||
const btVector3 x[]={f.m_n[0]->m_x,f.m_n[1]->m_x,f.m_n[2]->m_x};
|
const btVector3 x[]={f.m_n[0]->m_x,f.m_n[1]->m_x,f.m_n[2]->m_x};
|
||||||
const btVector3 c=(x[0]+x[1]+x[2])/3;
|
const btVector3 c=(x[0]+x[1]+x[2])/3;
|
||||||
idraw->drawTriangle((x[0]-c)*scl+c,
|
idraw->drawTriangle((x[0]-c)*scl+c,
|
||||||
(x[1]-c)*scl+c,
|
(x[1]-c)*scl+c,
|
||||||
(x[2]-c)*scl+c,
|
(x[2]-c)*scl+c,
|
||||||
col,alp);
|
col,alp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Clusters */
|
/* Clusters */
|
||||||
if(0!=(drawflags&fDrawFlags::Clusters))
|
if(0!=(drawflags&fDrawFlags::Clusters))
|
||||||
{
|
{
|
||||||
srand(1806);
|
srand(1806);
|
||||||
for(i=0;i<psb->m_clusters.size();++i)
|
for(i=0;i<psb->m_clusters.size();++i)
|
||||||
{
|
{
|
||||||
if(psb->m_clusters[i]->m_collide)
|
if(psb->m_clusters[i]->m_collide)
|
||||||
{
|
{
|
||||||
btVector3 color( rand()/(btScalar)RAND_MAX,
|
btVector3 color( rand()/(btScalar)RAND_MAX,
|
||||||
rand()/(btScalar)RAND_MAX,
|
rand()/(btScalar)RAND_MAX,
|
||||||
rand()/(btScalar)RAND_MAX);
|
rand()/(btScalar)RAND_MAX);
|
||||||
color=color.normalized()*0.75;
|
color=color.normalized()*0.75;
|
||||||
btAlignedObjectArray<btVector3> vertices;
|
btAlignedObjectArray<btVector3> vertices;
|
||||||
vertices.resize(psb->m_clusters[i]->m_nodes.size());
|
vertices.resize(psb->m_clusters[i]->m_nodes.size());
|
||||||
for(j=0,nj=vertices.size();j<nj;++j)
|
for(j=0,nj=vertices.size();j<nj;++j)
|
||||||
{
|
{
|
||||||
vertices[j]=psb->m_clusters[i]->m_nodes[j]->m_x;
|
vertices[j]=psb->m_clusters[i]->m_nodes[j]->m_x;
|
||||||
}
|
}
|
||||||
HullDesc hdsc(QF_TRIANGLES,vertices.size(),&vertices[0]);
|
HullDesc hdsc(QF_TRIANGLES,vertices.size(),&vertices[0]);
|
||||||
HullResult hres;
|
HullResult hres;
|
||||||
HullLibrary hlib;
|
HullLibrary hlib;
|
||||||
@@ -284,32 +284,32 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
|||||||
mul(hres.m_OutputVertices,(btScalar)1);
|
mul(hres.m_OutputVertices,(btScalar)1);
|
||||||
add(hres.m_OutputVertices,center);
|
add(hres.m_OutputVertices,center);
|
||||||
for(j=0;j<(int)hres.mNumFaces;++j)
|
for(j=0;j<(int)hres.mNumFaces;++j)
|
||||||
{
|
{
|
||||||
const int idx[]={hres.m_Indices[j*3+0],hres.m_Indices[j*3+1],hres.m_Indices[j*3+2]};
|
const int idx[]={hres.m_Indices[j*3+0],hres.m_Indices[j*3+1],hres.m_Indices[j*3+2]};
|
||||||
idraw->drawTriangle(hres.m_OutputVertices[idx[0]],
|
idraw->drawTriangle(hres.m_OutputVertices[idx[0]],
|
||||||
hres.m_OutputVertices[idx[1]],
|
hres.m_OutputVertices[idx[1]],
|
||||||
hres.m_OutputVertices[idx[2]],
|
hres.m_OutputVertices[idx[2]],
|
||||||
color,1);
|
color,1);
|
||||||
}
|
|
||||||
hlib.ReleaseResult(hres);
|
|
||||||
}
|
}
|
||||||
|
hlib.ReleaseResult(hres);
|
||||||
|
}
|
||||||
/* Velocities */
|
/* Velocities */
|
||||||
#if 0
|
#if 0
|
||||||
for(int j=0;j<psb->m_clusters[i].m_nodes.size();++j)
|
for(int j=0;j<psb->m_clusters[i].m_nodes.size();++j)
|
||||||
{
|
{
|
||||||
const btSoftBody::Cluster& c=psb->m_clusters[i];
|
const btSoftBody::Cluster& c=psb->m_clusters[i];
|
||||||
const btVector3 r=c.m_nodes[j]->m_x-c.m_com;
|
const btVector3 r=c.m_nodes[j]->m_x-c.m_com;
|
||||||
const btVector3 v=c.m_lv+cross(c.m_av,r);
|
const btVector3 v=c.m_lv+cross(c.m_av,r);
|
||||||
idraw->drawLine(c.m_nodes[j]->m_x,c.m_nodes[j]->m_x+v,btVector3(1,0,0));
|
idraw->drawLine(c.m_nodes[j]->m_x,c.m_nodes[j]->m_x+v,btVector3(1,0,0));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Frame */
|
/* Frame */
|
||||||
btSoftBody::Cluster& c=*psb->m_clusters[i];
|
btSoftBody::Cluster& c=*psb->m_clusters[i];
|
||||||
idraw->drawLine(c.m_com,c.m_framexform*btVector3(10,0,0),btVector3(1,0,0));
|
idraw->drawLine(c.m_com,c.m_framexform*btVector3(10,0,0),btVector3(1,0,0));
|
||||||
idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,10,0),btVector3(0,1,0));
|
idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,10,0),btVector3(0,1,0));
|
||||||
idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,0,10),btVector3(0,0,1));
|
idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,0,10),btVector3(0,0,1));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Notes */
|
/* Notes */
|
||||||
if(0!=(drawflags&fDrawFlags::Notes))
|
if(0!=(drawflags&fDrawFlags::Notes))
|
||||||
{
|
{
|
||||||
@@ -318,9 +318,9 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
|||||||
const btSoftBody::Note& n=psb->m_notes[i];
|
const btSoftBody::Note& n=psb->m_notes[i];
|
||||||
btVector3 p=n.m_offset;
|
btVector3 p=n.m_offset;
|
||||||
for(int j=0;j<n.m_rank;++j)
|
for(int j=0;j<n.m_rank;++j)
|
||||||
{
|
{
|
||||||
p+=n.m_nodes[j]->m_x*n.m_coords[j];
|
p+=n.m_nodes[j]->m_x*n.m_coords[j];
|
||||||
}
|
}
|
||||||
idraw->draw3dText(p,n.m_text);
|
idraw->draw3dText(p,n.m_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,33 +333,33 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
|||||||
/* Joints */
|
/* Joints */
|
||||||
if(0!=(drawflags&fDrawFlags::Joints))
|
if(0!=(drawflags&fDrawFlags::Joints))
|
||||||
{
|
{
|
||||||
for(i=0;i<psb->m_joints.size();++i)
|
for(i=0;i<psb->m_joints.size();++i)
|
||||||
{
|
{
|
||||||
const btSoftBody::Joint* pj=psb->m_joints[i];
|
const btSoftBody::Joint* pj=psb->m_joints[i];
|
||||||
switch(pj->Type())
|
switch(pj->Type())
|
||||||
{
|
{
|
||||||
case btSoftBody::Joint::eType::Linear:
|
case btSoftBody::Joint::eType::Linear:
|
||||||
{
|
{
|
||||||
const btSoftBody::LJoint* pjl=(const btSoftBody::LJoint*)pj;
|
const btSoftBody::LJoint* pjl=(const btSoftBody::LJoint*)pj;
|
||||||
const btVector3 a0=pj->m_bodies[0].xform()*pjl->m_refs[0];
|
const btVector3 a0=pj->m_bodies[0].xform()*pjl->m_refs[0];
|
||||||
const btVector3 a1=pj->m_bodies[1].xform()*pjl->m_refs[1];
|
const btVector3 a1=pj->m_bodies[1].xform()*pjl->m_refs[1];
|
||||||
idraw->drawLine(pj->m_bodies[0].xform().getOrigin(),a0,btVector3(1,1,0));
|
idraw->drawLine(pj->m_bodies[0].xform().getOrigin(),a0,btVector3(1,1,0));
|
||||||
idraw->drawLine(pj->m_bodies[1].xform().getOrigin(),a1,btVector3(0,1,1));
|
idraw->drawLine(pj->m_bodies[1].xform().getOrigin(),a1,btVector3(0,1,1));
|
||||||
drawVertex(idraw,a0,0.25,btVector3(1,1,0));
|
drawVertex(idraw,a0,0.25,btVector3(1,1,0));
|
||||||
drawVertex(idraw,a1,0.25,btVector3(0,1,1));
|
drawVertex(idraw,a1,0.25,btVector3(0,1,1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case btSoftBody::Joint::eType::Angular:
|
case btSoftBody::Joint::eType::Angular:
|
||||||
{
|
{
|
||||||
const btSoftBody::AJoint* pja=(const btSoftBody::AJoint*)pj;
|
const btSoftBody::AJoint* pja=(const btSoftBody::AJoint*)pj;
|
||||||
const btVector3 o0=pj->m_bodies[0].xform().getOrigin();
|
const btVector3 o0=pj->m_bodies[0].xform().getOrigin();
|
||||||
const btVector3 o1=pj->m_bodies[1].xform().getOrigin();
|
const btVector3 o1=pj->m_bodies[1].xform().getOrigin();
|
||||||
const btVector3 a0=pj->m_bodies[0].xform().getBasis()*pj->m_refs[0];
|
const btVector3 a0=pj->m_bodies[0].xform().getBasis()*pj->m_refs[0];
|
||||||
const btVector3 a1=pj->m_bodies[1].xform().getBasis()*pj->m_refs[1];
|
const btVector3 a1=pj->m_bodies[1].xform().getBasis()*pj->m_refs[1];
|
||||||
idraw->drawLine(o0,o0+a0*10,btVector3(1,1,0));
|
idraw->drawLine(o0,o0+a0*10,btVector3(1,1,0));
|
||||||
idraw->drawLine(o0,o0+a1*10,btVector3(1,1,0));
|
idraw->drawLine(o0,o0+a1*10,btVector3(1,1,0));
|
||||||
idraw->drawLine(o1,o1+a0*10,btVector3(0,1,1));
|
idraw->drawLine(o1,o1+a0*10,btVector3(0,1,1));
|
||||||
idraw->drawLine(o1,o1+a1*10,btVector3(0,1,1));
|
idraw->drawLine(o1,o1+a1*10,btVector3(0,1,1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -368,10 +368,10 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
|||||||
|
|
||||||
//
|
//
|
||||||
void btSoftBodyHelpers::DrawInfos( btSoftBody* psb,
|
void btSoftBodyHelpers::DrawInfos( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
bool masses,
|
bool masses,
|
||||||
bool areas,
|
bool areas,
|
||||||
bool /*stress*/)
|
bool /*stress*/)
|
||||||
{
|
{
|
||||||
for(int i=0;i<psb->m_nodes.size();++i)
|
for(int i=0;i<psb->m_nodes.size();++i)
|
||||||
{
|
{
|
||||||
@@ -394,34 +394,34 @@ void btSoftBodyHelpers::DrawInfos( btSoftBody* psb,
|
|||||||
|
|
||||||
//
|
//
|
||||||
void btSoftBodyHelpers::DrawNodeTree( btSoftBody* psb,
|
void btSoftBodyHelpers::DrawNodeTree( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
int mindepth,
|
int mindepth,
|
||||||
int maxdepth)
|
int maxdepth)
|
||||||
{
|
{
|
||||||
drawTree(idraw,psb->m_ndbvt.m_root,0,btVector3(1,0,1),btVector3(1,1,1),mindepth,maxdepth);
|
drawTree(idraw,psb->m_ndbvt.m_root,0,btVector3(1,0,1),btVector3(1,1,1),mindepth,maxdepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void btSoftBodyHelpers::DrawFaceTree( btSoftBody* psb,
|
void btSoftBodyHelpers::DrawFaceTree( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
int mindepth,
|
int mindepth,
|
||||||
int maxdepth)
|
int maxdepth)
|
||||||
{
|
{
|
||||||
drawTree(idraw,psb->m_fdbvt.m_root,0,btVector3(0,1,0),btVector3(1,0,0),mindepth,maxdepth);
|
drawTree(idraw,psb->m_fdbvt.m_root,0,btVector3(0,1,0),btVector3(1,0,0),mindepth,maxdepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void btSoftBodyHelpers::DrawClusterTree( btSoftBody* psb,
|
void btSoftBodyHelpers::DrawClusterTree( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
int mindepth,
|
int mindepth,
|
||||||
int maxdepth)
|
int maxdepth)
|
||||||
{
|
{
|
||||||
drawTree(idraw,psb->m_cdbvt.m_root,0,btVector3(0,1,1),btVector3(1,0,0),mindepth,maxdepth);
|
drawTree(idraw,psb->m_cdbvt.m_root,0,btVector3(0,1,1),btVector3(1,0,0),mindepth,maxdepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void btSoftBodyHelpers::DrawFrame( btSoftBody* psb,
|
void btSoftBodyHelpers::DrawFrame( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw)
|
btIDebugDraw* idraw)
|
||||||
{
|
{
|
||||||
if(psb->m_pose.m_bframe)
|
if(psb->m_pose.m_bframe)
|
||||||
{
|
{
|
||||||
@@ -445,9 +445,9 @@ void btSoftBodyHelpers::DrawFrame( btSoftBody* psb,
|
|||||||
|
|
||||||
//
|
//
|
||||||
btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBodyWorldInfo& worldInfo, const btVector3& from,
|
btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBodyWorldInfo& worldInfo, const btVector3& from,
|
||||||
const btVector3& to,
|
const btVector3& to,
|
||||||
int res,
|
int res,
|
||||||
int fixeds)
|
int fixeds)
|
||||||
{
|
{
|
||||||
/* Create nodes */
|
/* Create nodes */
|
||||||
const int r=res+2;
|
const int r=res+2;
|
||||||
@@ -477,13 +477,13 @@ btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBodyWorldInfo& worldInfo, cons
|
|||||||
|
|
||||||
//
|
//
|
||||||
btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo,const btVector3& corner00,
|
btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo,const btVector3& corner00,
|
||||||
const btVector3& corner10,
|
const btVector3& corner10,
|
||||||
const btVector3& corner01,
|
const btVector3& corner01,
|
||||||
const btVector3& corner11,
|
const btVector3& corner11,
|
||||||
int resx,
|
int resx,
|
||||||
int resy,
|
int resy,
|
||||||
int fixeds,
|
int fixeds,
|
||||||
bool gendiags)
|
bool gendiags)
|
||||||
{
|
{
|
||||||
#define IDX(_x_,_y_) ((_y_)*rx+(_x_))
|
#define IDX(_x_,_y_) ((_y_)*rx+(_x_))
|
||||||
/* Create nodes */
|
/* Create nodes */
|
||||||
@@ -554,83 +554,83 @@ btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo,const
|
|||||||
|
|
||||||
//
|
//
|
||||||
btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||||
const btVector3& corner00,
|
const btVector3& corner00,
|
||||||
const btVector3& corner10,
|
const btVector3& corner10,
|
||||||
const btVector3& corner01,
|
const btVector3& corner01,
|
||||||
const btVector3& corner11,
|
const btVector3& corner11,
|
||||||
int resx,
|
int resx,
|
||||||
int resy,
|
int resy,
|
||||||
int fixeds,
|
int fixeds,
|
||||||
bool gendiags,
|
bool gendiags,
|
||||||
float* tex_coords)
|
float* tex_coords)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* corners:
|
* corners:
|
||||||
*
|
*
|
||||||
* [0][0] corner00 ------- corner01 [resx][0]
|
* [0][0] corner00 ------- corner01 [resx][0]
|
||||||
* | |
|
* | |
|
||||||
* | |
|
* | |
|
||||||
* [0][resy] corner10 -------- corner11 [resx][resy]
|
* [0][resy] corner10 -------- corner11 [resx][resy]
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* "fixedgs" map:
|
* "fixedgs" map:
|
||||||
*
|
*
|
||||||
* corner00 --> +1
|
* corner00 --> +1
|
||||||
* corner01 --> +2
|
* corner01 --> +2
|
||||||
* corner10 --> +4
|
* corner10 --> +4
|
||||||
* corner11 --> +8
|
* corner11 --> +8
|
||||||
* upper middle --> +16
|
* upper middle --> +16
|
||||||
* left middle --> +32
|
* left middle --> +32
|
||||||
* right middle --> +64
|
* right middle --> +64
|
||||||
* lower middle --> +128
|
* lower middle --> +128
|
||||||
* center --> +256
|
* center --> +256
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* tex_coords size (resx-1)*(resy-1)*12
|
* tex_coords size (resx-1)*(resy-1)*12
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* SINGLE QUAD INTERNALS
|
* SINGLE QUAD INTERNALS
|
||||||
*
|
*
|
||||||
* 1) btSoftBody's nodes and links,
|
* 1) btSoftBody's nodes and links,
|
||||||
* diagonal link is optional ("gendiags")
|
* diagonal link is optional ("gendiags")
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* node00 ------ node01
|
* node00 ------ node01
|
||||||
* | .
|
* | .
|
||||||
* | .
|
* | .
|
||||||
* | .
|
* | .
|
||||||
* | .
|
* | .
|
||||||
* | .
|
* | .
|
||||||
* node10 node11
|
* node10 node11
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* 2) Faces:
|
* 2) Faces:
|
||||||
* two triangles,
|
* two triangles,
|
||||||
* UV Coordinates (hier example for single quad)
|
* UV Coordinates (hier example for single quad)
|
||||||
*
|
*
|
||||||
* (0,1) (0,1) (1,1)
|
* (0,1) (0,1) (1,1)
|
||||||
* 1 |\ 3 \-----| 2
|
* 1 |\ 3 \-----| 2
|
||||||
* | \ \ |
|
* | \ \ |
|
||||||
* | \ \ |
|
* | \ \ |
|
||||||
* | \ \ |
|
* | \ \ |
|
||||||
* | \ \ |
|
* | \ \ |
|
||||||
* 2 |-----\ 3 \| 1
|
* 2 |-----\ 3 \| 1
|
||||||
* (0,0) (1,0) (1,0)
|
* (0,0) (1,0) (1,0)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define IDX(_x_,_y_) ((_y_)*rx+(_x_))
|
#define IDX(_x_,_y_) ((_y_)*rx+(_x_))
|
||||||
/* Create nodes */
|
/* Create nodes */
|
||||||
@@ -675,12 +675,12 @@ btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
|||||||
{
|
{
|
||||||
const bool mdx=(ix+1)<rx;
|
const bool mdx=(ix+1)<rx;
|
||||||
const bool mdy=(iy+1)<ry;
|
const bool mdy=(iy+1)<ry;
|
||||||
|
|
||||||
int node00=IDX(ix,iy);
|
int node00=IDX(ix,iy);
|
||||||
int node01=IDX(ix+1,iy);
|
int node01=IDX(ix+1,iy);
|
||||||
int node10=IDX(ix,iy+1);
|
int node10=IDX(ix,iy+1);
|
||||||
int node11=IDX(ix+1,iy+1);
|
int node11=IDX(ix+1,iy+1);
|
||||||
|
|
||||||
if(mdx) psb->appendLink(node00,node01);
|
if(mdx) psb->appendLink(node00,node01);
|
||||||
if(mdy) psb->appendLink(node00,node10);
|
if(mdy) psb->appendLink(node00,node10);
|
||||||
if(mdx&&mdy)
|
if(mdx&&mdy)
|
||||||
@@ -716,32 +716,32 @@ btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
|||||||
float btSoftBodyHelpers::CalculateUV(int resx,int resy,int ix,int iy,int id)
|
float btSoftBodyHelpers::CalculateUV(int resx,int resy,int ix,int iy,int id)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* node00 --- node01
|
* node00 --- node01
|
||||||
* | |
|
* | |
|
||||||
* node10 --- node11
|
* node10 --- node11
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* ID map:
|
* ID map:
|
||||||
*
|
*
|
||||||
* node00 s --> 0
|
* node00 s --> 0
|
||||||
* node00 t --> 1
|
* node00 t --> 1
|
||||||
*
|
*
|
||||||
* node01 s --> 3
|
* node01 s --> 3
|
||||||
* node01 t --> 1
|
* node01 t --> 1
|
||||||
*
|
*
|
||||||
* node10 s --> 0
|
* node10 s --> 0
|
||||||
* node10 t --> 2
|
* node10 t --> 2
|
||||||
*
|
*
|
||||||
* node11 s --> 3
|
* node11 s --> 3
|
||||||
* node11 t --> 2
|
* node11 t --> 2
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
float tc=0.0f;
|
float tc=0.0f;
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
tc = (1.0f/((resx-1))*ix);
|
tc = (1.0f/((resx-1))*ix);
|
||||||
}
|
}
|
||||||
@@ -754,12 +754,12 @@ float tc=0.0f;
|
|||||||
else if (id==3) {
|
else if (id==3) {
|
||||||
tc = (1.0f/((resx-1))*(ix+1));
|
tc = (1.0f/((resx-1))*(ix+1));
|
||||||
}
|
}
|
||||||
return tc;
|
return tc;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
btSoftBody* btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,const btVector3& center,
|
btSoftBody* btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,const btVector3& center,
|
||||||
const btVector3& radius,
|
const btVector3& radius,
|
||||||
int res)
|
int res)
|
||||||
{
|
{
|
||||||
struct Hammersley
|
struct Hammersley
|
||||||
{
|
{
|
||||||
@@ -790,8 +790,8 @@ btSoftBody* btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,c
|
|||||||
|
|
||||||
//
|
//
|
||||||
btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo,const btScalar* vertices,
|
btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo,const btScalar* vertices,
|
||||||
const int* triangles,
|
const int* triangles,
|
||||||
int ntriangles)
|
int ntriangles)
|
||||||
{
|
{
|
||||||
int maxidx=0;
|
int maxidx=0;
|
||||||
int i,j,ni;
|
int i,j,ni;
|
||||||
@@ -832,7 +832,7 @@ btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo
|
|||||||
|
|
||||||
//
|
//
|
||||||
btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldInfo, const btVector3* vertices,
|
btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldInfo, const btVector3* vertices,
|
||||||
int nvertices)
|
int nvertices)
|
||||||
{
|
{
|
||||||
HullDesc hdsc(QF_TRIANGLES,nvertices,vertices);
|
HullDesc hdsc(QF_TRIANGLES,nvertices,vertices);
|
||||||
HullResult hres;
|
HullResult hres;
|
||||||
|
|||||||
@@ -46,74 +46,74 @@ struct btSoftBodyHelpers
|
|||||||
{
|
{
|
||||||
/* Draw body */
|
/* Draw body */
|
||||||
static void Draw( btSoftBody* psb,
|
static void Draw( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
int drawflags=fDrawFlags::Std);
|
int drawflags=fDrawFlags::Std);
|
||||||
/* Draw body infos */
|
/* Draw body infos */
|
||||||
static void DrawInfos( btSoftBody* psb,
|
static void DrawInfos( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
bool masses,
|
bool masses,
|
||||||
bool areas,
|
bool areas,
|
||||||
bool stress);
|
bool stress);
|
||||||
/* Draw node tree */
|
/* Draw node tree */
|
||||||
static void DrawNodeTree( btSoftBody* psb,
|
static void DrawNodeTree( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
int mindepth=0,
|
int mindepth=0,
|
||||||
int maxdepth=-1);
|
int maxdepth=-1);
|
||||||
/* Draw face tree */
|
/* Draw face tree */
|
||||||
static void DrawFaceTree( btSoftBody* psb,
|
static void DrawFaceTree( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
int mindepth=0,
|
int mindepth=0,
|
||||||
int maxdepth=-1);
|
int maxdepth=-1);
|
||||||
/* Draw cluster tree */
|
/* Draw cluster tree */
|
||||||
static void DrawClusterTree(btSoftBody* psb,
|
static void DrawClusterTree(btSoftBody* psb,
|
||||||
btIDebugDraw* idraw,
|
btIDebugDraw* idraw,
|
||||||
int mindepth=0,
|
int mindepth=0,
|
||||||
int maxdepth=-1);
|
int maxdepth=-1);
|
||||||
/* Draw rigid frame */
|
/* Draw rigid frame */
|
||||||
static void DrawFrame( btSoftBody* psb,
|
static void DrawFrame( btSoftBody* psb,
|
||||||
btIDebugDraw* idraw);
|
btIDebugDraw* idraw);
|
||||||
/* Create a rope */
|
/* Create a rope */
|
||||||
static btSoftBody* CreateRope( btSoftBodyWorldInfo& worldInfo,
|
static btSoftBody* CreateRope( btSoftBodyWorldInfo& worldInfo,
|
||||||
const btVector3& from,
|
const btVector3& from,
|
||||||
const btVector3& to,
|
const btVector3& to,
|
||||||
int res,
|
int res,
|
||||||
int fixeds);
|
int fixeds);
|
||||||
/* Create a patch */
|
/* Create a patch */
|
||||||
static btSoftBody* CreatePatch(btSoftBodyWorldInfo& worldInfo,
|
static btSoftBody* CreatePatch(btSoftBodyWorldInfo& worldInfo,
|
||||||
const btVector3& corner00,
|
const btVector3& corner00,
|
||||||
const btVector3& corner10,
|
const btVector3& corner10,
|
||||||
const btVector3& corner01,
|
const btVector3& corner01,
|
||||||
const btVector3& corner11,
|
const btVector3& corner11,
|
||||||
int resx,
|
int resx,
|
||||||
int resy,
|
int resy,
|
||||||
int fixeds,
|
int fixeds,
|
||||||
bool gendiags);
|
bool gendiags);
|
||||||
/* Create a patch with UV Texture Coordinates */
|
/* Create a patch with UV Texture Coordinates */
|
||||||
static btSoftBody* CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
static btSoftBody* CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||||
const btVector3& corner00,
|
const btVector3& corner00,
|
||||||
const btVector3& corner10,
|
const btVector3& corner10,
|
||||||
const btVector3& corner01,
|
const btVector3& corner01,
|
||||||
const btVector3& corner11,
|
const btVector3& corner11,
|
||||||
int resx,
|
int resx,
|
||||||
int resy,
|
int resy,
|
||||||
int fixeds,
|
int fixeds,
|
||||||
bool gendiags,
|
bool gendiags,
|
||||||
float* tex_coords=0);
|
float* tex_coords=0);
|
||||||
static float CalculateUV(int resx,int resy,int ix,int iy,int id);
|
static float CalculateUV(int resx,int resy,int ix,int iy,int id);
|
||||||
/* Create an ellipsoid */
|
/* Create an ellipsoid */
|
||||||
static btSoftBody* CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,
|
static btSoftBody* CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,
|
||||||
const btVector3& center,
|
const btVector3& center,
|
||||||
const btVector3& radius,
|
const btVector3& radius,
|
||||||
int res);
|
int res);
|
||||||
/* Create from trimesh */
|
/* Create from trimesh */
|
||||||
static btSoftBody* CreateFromTriMesh( btSoftBodyWorldInfo& worldInfo,
|
static btSoftBody* CreateFromTriMesh( btSoftBodyWorldInfo& worldInfo,
|
||||||
const btScalar* vertices,
|
const btScalar* vertices,
|
||||||
const int* triangles,
|
const int* triangles,
|
||||||
int ntriangles);
|
int ntriangles);
|
||||||
/* Create from convex-hull */
|
/* Create from convex-hull */
|
||||||
static btSoftBody* CreateFromConvexHull( btSoftBodyWorldInfo& worldInfo,
|
static btSoftBody* CreateFromConvexHull( btSoftBodyWorldInfo& worldInfo,
|
||||||
const btVector3* vertices,
|
const btVector3* vertices,
|
||||||
int nvertices);
|
int nvertices);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SOFT_BODY_HELPERS_H
|
#endif //SOFT_BODY_HELPERS_H
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -29,10 +29,10 @@ btSoftBodyRigidBodyCollisionConfiguration::btSoftBodyRigidBodyCollisionConfigura
|
|||||||
|
|
||||||
mem = btAlignedAlloc(sizeof(btSoftSoftCollisionAlgorithm::CreateFunc),16);
|
mem = btAlignedAlloc(sizeof(btSoftSoftCollisionAlgorithm::CreateFunc),16);
|
||||||
m_softSoftCreateFunc = new(mem) btSoftSoftCollisionAlgorithm::CreateFunc;
|
m_softSoftCreateFunc = new(mem) btSoftSoftCollisionAlgorithm::CreateFunc;
|
||||||
|
|
||||||
mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16);
|
mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16);
|
||||||
m_softRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc;
|
m_softRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc;
|
||||||
|
|
||||||
mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16);
|
mem = btAlignedAlloc(sizeof(btSoftRigidCollisionAlgorithm::CreateFunc),16);
|
||||||
m_swappedSoftRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc;
|
m_swappedSoftRigidConvexCreateFunc = new(mem) btSoftRigidCollisionAlgorithm::CreateFunc;
|
||||||
m_swappedSoftRigidConvexCreateFunc->m_swapped=true;
|
m_swappedSoftRigidConvexCreateFunc->m_swapped=true;
|
||||||
@@ -40,20 +40,20 @@ btSoftBodyRigidBodyCollisionConfiguration::btSoftBodyRigidBodyCollisionConfigura
|
|||||||
#ifdef ENABLE_SOFTBODY_CONCAVE_COLLISIONS
|
#ifdef ENABLE_SOFTBODY_CONCAVE_COLLISIONS
|
||||||
mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16);
|
mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16);
|
||||||
m_softRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::CreateFunc;
|
m_softRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::CreateFunc;
|
||||||
|
|
||||||
mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16);
|
mem = btAlignedAlloc(sizeof(btSoftBodyConcaveCollisionAlgorithm::CreateFunc),16);
|
||||||
m_swappedSoftRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::SwappedCreateFunc;
|
m_swappedSoftRigidConcaveCreateFunc = new(mem) btSoftBodyConcaveCollisionAlgorithm::SwappedCreateFunc;
|
||||||
m_swappedSoftRigidConcaveCreateFunc->m_swapped=true;
|
m_swappedSoftRigidConcaveCreateFunc->m_swapped=true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//replace pool by a new one, with potential larger size
|
//replace pool by a new one, with potential larger size
|
||||||
|
|
||||||
if (m_ownsCollisionAlgorithmPool && m_collisionAlgorithmPool)
|
if (m_ownsCollisionAlgorithmPool && m_collisionAlgorithmPool)
|
||||||
{
|
{
|
||||||
int curElemSize = m_collisionAlgorithmPool->getElementSize();
|
int curElemSize = m_collisionAlgorithmPool->getElementSize();
|
||||||
///calculate maximum element size, big enough to fit any collision algorithm in the memory pool
|
///calculate maximum element size, big enough to fit any collision algorithm in the memory pool
|
||||||
|
|
||||||
|
|
||||||
int maxSize0 = sizeof(btSoftSoftCollisionAlgorithm);
|
int maxSize0 = sizeof(btSoftSoftCollisionAlgorithm);
|
||||||
int maxSize1 = sizeof(btSoftRigidCollisionAlgorithm);
|
int maxSize1 = sizeof(btSoftRigidCollisionAlgorithm);
|
||||||
int maxSize2 = sizeof(btSoftBodyConcaveCollisionAlgorithm);
|
int maxSize2 = sizeof(btSoftBodyConcaveCollisionAlgorithm);
|
||||||
@@ -92,7 +92,7 @@ btSoftBodyRigidBodyCollisionConfiguration::~btSoftBodyRigidBodyCollisionConfigur
|
|||||||
btAlignedFree( m_swappedSoftRigidConcaveCreateFunc);
|
btAlignedFree( m_swappedSoftRigidConcaveCreateFunc);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
///creation of soft-soft and soft-rigid, and otherwise fallback to base class implementation
|
///creation of soft-soft and soft-rigid, and otherwise fallback to base class implementation
|
||||||
btCollisionAlgorithmCreateFunc* btSoftBodyRigidBodyCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1)
|
btCollisionAlgorithmCreateFunc* btSoftBodyRigidBodyCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class btSoftBodyRigidBodyCollisionConfiguration : public btDefaultCollisionConfi
|
|||||||
btCollisionAlgorithmCreateFunc* m_swappedSoftRigidConvexCreateFunc;
|
btCollisionAlgorithmCreateFunc* m_swappedSoftRigidConvexCreateFunc;
|
||||||
btCollisionAlgorithmCreateFunc* m_softRigidConcaveCreateFunc;
|
btCollisionAlgorithmCreateFunc* m_softRigidConcaveCreateFunc;
|
||||||
btCollisionAlgorithmCreateFunc* m_swappedSoftRigidConcaveCreateFunc;
|
btCollisionAlgorithmCreateFunc* m_swappedSoftRigidConcaveCreateFunc;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btSoftBodyRigidBodyCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo());
|
btSoftBodyRigidBodyCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo());
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ m_isSwapped(isSwapped)
|
|||||||
|
|
||||||
btSoftRigidCollisionAlgorithm::~btSoftRigidCollisionAlgorithm()
|
btSoftRigidCollisionAlgorithm::~btSoftRigidCollisionAlgorithm()
|
||||||
{
|
{
|
||||||
|
|
||||||
//m_softBody->m_overlappingRigidBodies.remove(m_rigidCollisionObject);
|
//m_softBody->m_overlappingRigidBodies.remove(m_rigidCollisionObject);
|
||||||
|
|
||||||
/*if (m_ownManifold)
|
/*if (m_ownManifold)
|
||||||
{
|
{
|
||||||
if (m_manifoldPtr)
|
if (m_manifoldPtr)
|
||||||
m_dispatcher->releaseManifold(m_manifoldPtr);
|
m_dispatcher->releaseManifold(m_manifoldPtr);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ void btSoftRigidCollisionAlgorithm::processCollision (btCollisionObject* body0,b
|
|||||||
|
|
||||||
btSoftBody* softBody = m_isSwapped? (btSoftBody*)body1 : (btSoftBody*)body0;
|
btSoftBody* softBody = m_isSwapped? (btSoftBody*)body1 : (btSoftBody*)body0;
|
||||||
btCollisionObject* rigidCollisionObject = m_isSwapped? body0 : body1;
|
btCollisionObject* rigidCollisionObject = m_isSwapped? body0 : body1;
|
||||||
|
|
||||||
softBody->defaultCollisionHandler(rigidCollisionObject);
|
softBody->defaultCollisionHandler(rigidCollisionObject);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,15 +28,15 @@ class btSoftBody;
|
|||||||
/// btSoftRigidCollisionAlgorithm provides collision detection between btSoftBody and btRigidBody
|
/// btSoftRigidCollisionAlgorithm provides collision detection between btSoftBody and btRigidBody
|
||||||
class btSoftRigidCollisionAlgorithm : public btCollisionAlgorithm
|
class btSoftRigidCollisionAlgorithm : public btCollisionAlgorithm
|
||||||
{
|
{
|
||||||
// bool m_ownManifold;
|
// bool m_ownManifold;
|
||||||
// btPersistentManifold* m_manifoldPtr;
|
// btPersistentManifold* m_manifoldPtr;
|
||||||
|
|
||||||
btSoftBody* m_softBody;
|
btSoftBody* m_softBody;
|
||||||
btCollisionObject* m_rigidCollisionObject;
|
btCollisionObject* m_rigidCollisionObject;
|
||||||
|
|
||||||
///for rigid versus soft (instead of soft versus rigid), we use this swapped boolean
|
///for rigid versus soft (instead of soft versus rigid), we use this swapped boolean
|
||||||
bool m_isSwapped;
|
bool m_isSwapped;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btSoftRigidCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
|
btSoftRigidCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
|
||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
//we don't add any manifolds
|
//we don't add any manifolds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||||
{
|
{
|
||||||
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
||||||
|
|||||||
@@ -28,17 +28,17 @@ subject to the following restrictions:
|
|||||||
btSoftRigidDynamicsWorld::btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
|
btSoftRigidDynamicsWorld::btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
|
||||||
:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration)
|
:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration)
|
||||||
{
|
{
|
||||||
m_drawFlags = fDrawFlags::Std;
|
m_drawFlags = fDrawFlags::Std;
|
||||||
m_drawNodeTree = true;
|
m_drawNodeTree = true;
|
||||||
m_drawFaceTree = false;
|
m_drawFaceTree = false;
|
||||||
m_drawClusterTree = false;
|
m_drawClusterTree = false;
|
||||||
m_sbi.m_broadphase = pairCache;
|
m_sbi.m_broadphase = pairCache;
|
||||||
m_sbi.m_dispatcher = dispatcher;
|
m_sbi.m_dispatcher = dispatcher;
|
||||||
m_sbi.m_sparsesdf.Initialize();
|
m_sbi.m_sparsesdf.Initialize();
|
||||||
m_sbi.m_sparsesdf.Reset();
|
m_sbi.m_sparsesdf.Reset();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btSoftRigidDynamicsWorld::~btSoftRigidDynamicsWorld()
|
btSoftRigidDynamicsWorld::~btSoftRigidDynamicsWorld()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ void btSoftRigidDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
|
|||||||
psb->predictMotion(timeStep);
|
psb->predictMotion(timeStep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void btSoftRigidDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
|
void btSoftRigidDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
|
||||||
{
|
{
|
||||||
btDiscreteDynamicsWorld::internalSingleStepSimulation( timeStep );
|
btDiscreteDynamicsWorld::internalSingleStepSimulation( timeStep );
|
||||||
@@ -71,7 +71,7 @@ void btSoftRigidDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
|
|||||||
void btSoftRigidDynamicsWorld::updateSoftBodies()
|
void btSoftRigidDynamicsWorld::updateSoftBodies()
|
||||||
{
|
{
|
||||||
BT_PROFILE("updateSoftBodies");
|
BT_PROFILE("updateSoftBodies");
|
||||||
|
|
||||||
for ( int i=0;i<m_softBodies.size();i++)
|
for ( int i=0;i<m_softBodies.size();i++)
|
||||||
{
|
{
|
||||||
btSoftBody* psb=(btSoftBody*)m_softBodies[i];
|
btSoftBody* psb=(btSoftBody*)m_softBodies[i];
|
||||||
@@ -82,12 +82,12 @@ void btSoftRigidDynamicsWorld::updateSoftBodies()
|
|||||||
void btSoftRigidDynamicsWorld::solveSoftBodiesConstraints()
|
void btSoftRigidDynamicsWorld::solveSoftBodiesConstraints()
|
||||||
{
|
{
|
||||||
BT_PROFILE("solveSoftConstraints");
|
BT_PROFILE("solveSoftConstraints");
|
||||||
|
|
||||||
if(m_softBodies.size())
|
if(m_softBodies.size())
|
||||||
{
|
{
|
||||||
btSoftBody::solveClusters(m_softBodies);
|
btSoftBody::solveClusters(m_softBodies);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0;i<m_softBodies.size();++i)
|
for(int i=0;i<m_softBodies.size();++i)
|
||||||
{
|
{
|
||||||
btSoftBody* psb=(btSoftBody*)m_softBodies[i];
|
btSoftBody* psb=(btSoftBody*)m_softBodies[i];
|
||||||
@@ -100,8 +100,8 @@ void btSoftRigidDynamicsWorld::addSoftBody(btSoftBody* body)
|
|||||||
m_softBodies.push_back(body);
|
m_softBodies.push_back(body);
|
||||||
|
|
||||||
btCollisionWorld::addCollisionObject(body,
|
btCollisionWorld::addCollisionObject(body,
|
||||||
btBroadphaseProxy::DefaultFilter,
|
btBroadphaseProxy::DefaultFilter,
|
||||||
btBroadphaseProxy::AllFilter);
|
btBroadphaseProxy::AllFilter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ typedef btAlignedObjectArray<btSoftBody*> btSoftBodyArray;
|
|||||||
|
|
||||||
class btSoftRigidDynamicsWorld : public btDiscreteDynamicsWorld
|
class btSoftRigidDynamicsWorld : public btDiscreteDynamicsWorld
|
||||||
{
|
{
|
||||||
|
|
||||||
btSoftBodyArray m_softBodies;
|
btSoftBodyArray m_softBodies;
|
||||||
int m_drawFlags;
|
int m_drawFlags;
|
||||||
bool m_drawNodeTree;
|
bool m_drawNodeTree;
|
||||||
@@ -32,9 +32,9 @@ class btSoftRigidDynamicsWorld : public btDiscreteDynamicsWorld
|
|||||||
btSoftBodyWorldInfo m_sbi;
|
btSoftBodyWorldInfo m_sbi;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void predictUnconstraintMotion(btScalar timeStep);
|
virtual void predictUnconstraintMotion(btScalar timeStep);
|
||||||
|
|
||||||
virtual void internalSingleStepSimulation( btScalar timeStep);
|
virtual void internalSingleStepSimulation( btScalar timeStep);
|
||||||
|
|
||||||
void updateSoftBodies();
|
void updateSoftBodies();
|
||||||
@@ -43,17 +43,17 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
|
btSoftRigidDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration);
|
||||||
|
|
||||||
virtual ~btSoftRigidDynamicsWorld();
|
virtual ~btSoftRigidDynamicsWorld();
|
||||||
|
|
||||||
virtual void debugDrawWorld();
|
virtual void debugDrawWorld();
|
||||||
|
|
||||||
void addSoftBody(btSoftBody* body);
|
void addSoftBody(btSoftBody* body);
|
||||||
|
|
||||||
void removeSoftBody(btSoftBody* body);
|
void removeSoftBody(btSoftBody* body);
|
||||||
|
|
||||||
int getDrawFlags() const { return(m_drawFlags); }
|
int getDrawFlags() const { return(m_drawFlags); }
|
||||||
void setDrawFlags(int f) { m_drawFlags=f; }
|
void setDrawFlags(int f) { m_drawFlags=f; }
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
return m_sbi;
|
return m_sbi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
btSoftBodyArray& getSoftBodyArray()
|
btSoftBodyArray& getSoftBodyArray()
|
||||||
{
|
{
|
||||||
return m_softBodies;
|
return m_softBodies;
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
{
|
{
|
||||||
return m_softBodies;
|
return m_softBodies;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //BT_SOFT_RIGID_DYNAMICS_WORLD_H
|
#endif //BT_SOFT_RIGID_DYNAMICS_WORLD_H
|
||||||
@@ -33,7 +33,7 @@ class btSoftSoftCollisionAlgorithm : public btCollisionAlgorithm
|
|||||||
btSoftBody* m_softBody0;
|
btSoftBody* m_softBody0;
|
||||||
btSoftBody* m_softBody1;
|
btSoftBody* m_softBody1;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btSoftSoftCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
btSoftSoftCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
||||||
: btCollisionAlgorithm(ci) {}
|
: btCollisionAlgorithm(ci) {}
|
||||||
|
|||||||
@@ -23,139 +23,139 @@ subject to the following restrictions:
|
|||||||
// Modified Paul Hsieh hash
|
// Modified Paul Hsieh hash
|
||||||
template <const int DWORDLEN>
|
template <const int DWORDLEN>
|
||||||
unsigned int HsiehHash(const void* pdata)
|
unsigned int HsiehHash(const void* pdata)
|
||||||
{
|
{
|
||||||
const unsigned short* data=(const unsigned short*)pdata;
|
const unsigned short* data=(const unsigned short*)pdata;
|
||||||
unsigned hash=DWORDLEN<<2,tmp;
|
unsigned hash=DWORDLEN<<2,tmp;
|
||||||
for(int i=0;i<DWORDLEN;++i)
|
for(int i=0;i<DWORDLEN;++i)
|
||||||
{
|
{
|
||||||
hash += data[0];
|
hash += data[0];
|
||||||
tmp = (data[1]<<11)^hash;
|
tmp = (data[1]<<11)^hash;
|
||||||
hash = (hash<<16)^tmp;
|
hash = (hash<<16)^tmp;
|
||||||
data += 2;
|
data += 2;
|
||||||
hash += hash>>11;
|
hash += hash>>11;
|
||||||
}
|
}
|
||||||
hash^=hash<<3;hash+=hash>>5;
|
hash^=hash<<3;hash+=hash>>5;
|
||||||
hash^=hash<<4;hash+=hash>>17;
|
hash^=hash<<4;hash+=hash>>17;
|
||||||
hash^=hash<<25;hash+=hash>>6;
|
hash^=hash<<25;hash+=hash>>6;
|
||||||
return(hash);
|
return(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <const int CELLSIZE>
|
template <const int CELLSIZE>
|
||||||
struct btSparseSdf
|
struct btSparseSdf
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Inner types
|
// Inner types
|
||||||
//
|
//
|
||||||
struct IntFrac
|
struct IntFrac
|
||||||
{
|
{
|
||||||
int b;
|
int b;
|
||||||
int i;
|
int i;
|
||||||
btScalar f;
|
btScalar f;
|
||||||
};
|
};
|
||||||
struct Cell
|
struct Cell
|
||||||
{
|
{
|
||||||
btScalar d[CELLSIZE+1][CELLSIZE+1][CELLSIZE+1];
|
btScalar d[CELLSIZE+1][CELLSIZE+1][CELLSIZE+1];
|
||||||
int c[3];
|
int c[3];
|
||||||
int puid;
|
int puid;
|
||||||
unsigned hash;
|
unsigned hash;
|
||||||
btCollisionShape* pclient;
|
btCollisionShape* pclient;
|
||||||
Cell* next;
|
Cell* next;
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
// Fields
|
// Fields
|
||||||
//
|
//
|
||||||
|
|
||||||
btAlignedObjectArray<Cell*> cells;
|
btAlignedObjectArray<Cell*> cells;
|
||||||
btScalar voxelsz;
|
btScalar voxelsz;
|
||||||
int puid;
|
int puid;
|
||||||
int ncells;
|
int ncells;
|
||||||
int nprobes;
|
int nprobes;
|
||||||
int nqueries;
|
int nqueries;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Methods
|
// Methods
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
void Initialize(int hashsize=2383)
|
void Initialize(int hashsize=2383)
|
||||||
{
|
{
|
||||||
cells.resize(hashsize,0);
|
cells.resize(hashsize,0);
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
for(int i=0,ni=cells.size();i<ni;++i)
|
for(int i=0,ni=cells.size();i<ni;++i)
|
||||||
{
|
{
|
||||||
Cell* pc=cells[i];
|
Cell* pc=cells[i];
|
||||||
cells[i]=0;
|
cells[i]=0;
|
||||||
while(pc)
|
while(pc)
|
||||||
{
|
{
|
||||||
Cell* pn=pc->next;
|
Cell* pn=pc->next;
|
||||||
delete pc;
|
delete pc;
|
||||||
pc=pn;
|
pc=pn;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
voxelsz =0.25;
|
voxelsz =0.25;
|
||||||
puid =0;
|
puid =0;
|
||||||
ncells =0;
|
ncells =0;
|
||||||
nprobes =1;
|
nprobes =1;
|
||||||
nqueries =1;
|
nqueries =1;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
void GarbageCollect(int lifetime=256)
|
void GarbageCollect(int lifetime=256)
|
||||||
{
|
{
|
||||||
const int life=puid-lifetime;
|
const int life=puid-lifetime;
|
||||||
for(int i=0;i<cells.size();++i)
|
for(int i=0;i<cells.size();++i)
|
||||||
{
|
{
|
||||||
Cell*& root=cells[i];
|
Cell*& root=cells[i];
|
||||||
Cell* pp=0;
|
Cell* pp=0;
|
||||||
Cell* pc=root;
|
Cell* pc=root;
|
||||||
while(pc)
|
while(pc)
|
||||||
{
|
{
|
||||||
Cell* pn=pc->next;
|
Cell* pn=pc->next;
|
||||||
if(pc->puid<life)
|
if(pc->puid<life)
|
||||||
{
|
{
|
||||||
if(pp) pp->next=pn; else root=pn;
|
if(pp) pp->next=pn; else root=pn;
|
||||||
delete pc;pc=pp;--ncells;
|
delete pc;pc=pp;--ncells;
|
||||||
}
|
|
||||||
pp=pc;pc=pn;
|
|
||||||
}
|
}
|
||||||
|
pp=pc;pc=pn;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//printf("GC[%d]: %d cells, PpQ: %f\r\n",puid,ncells,nprobes/(btScalar)nqueries);
|
//printf("GC[%d]: %d cells, PpQ: %f\r\n",puid,ncells,nprobes/(btScalar)nqueries);
|
||||||
nqueries=1;
|
nqueries=1;
|
||||||
nprobes=1;
|
nprobes=1;
|
||||||
++puid; /* TODO: Reset puid's when int range limit is reached */
|
++puid; /* TODO: Reset puid's when int range limit is reached */
|
||||||
/* else setup a priority list... */
|
/* else setup a priority list... */
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
int RemoveReferences(btCollisionShape* pcs)
|
int RemoveReferences(btCollisionShape* pcs)
|
||||||
{
|
{
|
||||||
int refcount=0;
|
int refcount=0;
|
||||||
for(int i=0;i<cells.size();++i)
|
for(int i=0;i<cells.size();++i)
|
||||||
{
|
{
|
||||||
Cell*& root=cells[i];
|
Cell*& root=cells[i];
|
||||||
Cell* pp=0;
|
Cell* pp=0;
|
||||||
Cell* pc=root;
|
Cell* pc=root;
|
||||||
while(pc)
|
while(pc)
|
||||||
{
|
{
|
||||||
Cell* pn=pc->next;
|
Cell* pn=pc->next;
|
||||||
if(pc->pclient==pcs)
|
if(pc->pclient==pcs)
|
||||||
{
|
{
|
||||||
if(pp) pp->next=pn; else root=pn;
|
if(pp) pp->next=pn; else root=pn;
|
||||||
delete pc;pc=pp;++refcount;
|
delete pc;pc=pp;++refcount;
|
||||||
}
|
|
||||||
pp=pc;pc=pn;
|
|
||||||
}
|
}
|
||||||
|
pp=pc;pc=pn;
|
||||||
}
|
}
|
||||||
return(refcount);
|
|
||||||
}
|
}
|
||||||
|
return(refcount);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
btScalar Evaluate( const btVector3& x,
|
btScalar Evaluate( const btVector3& x,
|
||||||
btCollisionShape* shape,
|
btCollisionShape* shape,
|
||||||
btVector3& normal,
|
btVector3& normal,
|
||||||
btScalar margin)
|
btScalar margin)
|
||||||
{
|
{
|
||||||
/* Lookup cell */
|
/* Lookup cell */
|
||||||
const btVector3 scx=x/voxelsz;
|
const btVector3 scx=x/voxelsz;
|
||||||
const IntFrac ix=Decompose(scx.x());
|
const IntFrac ix=Decompose(scx.x());
|
||||||
@@ -166,19 +166,19 @@ struct btSparseSdf
|
|||||||
Cell* c=root;
|
Cell* c=root;
|
||||||
++nqueries;
|
++nqueries;
|
||||||
while(c)
|
while(c)
|
||||||
{
|
{
|
||||||
++nprobes;
|
++nprobes;
|
||||||
if( (c->hash==h) &&
|
if( (c->hash==h) &&
|
||||||
(c->c[0]==ix.b) &&
|
(c->c[0]==ix.b) &&
|
||||||
(c->c[1]==iy.b) &&
|
(c->c[1]==iy.b) &&
|
||||||
(c->c[2]==iz.b) &&
|
(c->c[2]==iz.b) &&
|
||||||
(c->pclient==shape))
|
(c->pclient==shape))
|
||||||
{ break; }
|
{ break; }
|
||||||
else
|
else
|
||||||
{ c=c->next; }
|
{ c=c->next; }
|
||||||
}
|
}
|
||||||
if(!c)
|
if(!c)
|
||||||
{
|
{
|
||||||
++nprobes;
|
++nprobes;
|
||||||
++ncells;
|
++ncells;
|
||||||
c=new Cell();
|
c=new Cell();
|
||||||
@@ -187,82 +187,82 @@ struct btSparseSdf
|
|||||||
c->hash=h;
|
c->hash=h;
|
||||||
c->c[0]=ix.b;c->c[1]=iy.b;c->c[2]=iz.b;
|
c->c[0]=ix.b;c->c[1]=iy.b;c->c[2]=iz.b;
|
||||||
BuildCell(*c);
|
BuildCell(*c);
|
||||||
}
|
}
|
||||||
c->puid=puid;
|
c->puid=puid;
|
||||||
/* Extract infos */
|
/* Extract infos */
|
||||||
const int o[]={ ix.i,iy.i,iz.i};
|
const int o[]={ ix.i,iy.i,iz.i};
|
||||||
const btScalar d[]={ c->d[o[0]+0][o[1]+0][o[2]+0],
|
const btScalar d[]={ c->d[o[0]+0][o[1]+0][o[2]+0],
|
||||||
c->d[o[0]+1][o[1]+0][o[2]+0],
|
c->d[o[0]+1][o[1]+0][o[2]+0],
|
||||||
c->d[o[0]+1][o[1]+1][o[2]+0],
|
c->d[o[0]+1][o[1]+1][o[2]+0],
|
||||||
c->d[o[0]+0][o[1]+1][o[2]+0],
|
c->d[o[0]+0][o[1]+1][o[2]+0],
|
||||||
c->d[o[0]+0][o[1]+0][o[2]+1],
|
c->d[o[0]+0][o[1]+0][o[2]+1],
|
||||||
c->d[o[0]+1][o[1]+0][o[2]+1],
|
c->d[o[0]+1][o[1]+0][o[2]+1],
|
||||||
c->d[o[0]+1][o[1]+1][o[2]+1],
|
c->d[o[0]+1][o[1]+1][o[2]+1],
|
||||||
c->d[o[0]+0][o[1]+1][o[2]+1]};
|
c->d[o[0]+0][o[1]+1][o[2]+1]};
|
||||||
/* Normal */
|
/* Normal */
|
||||||
#if 1
|
#if 1
|
||||||
const btScalar gx[]={ d[1]-d[0],d[2]-d[3],
|
const btScalar gx[]={ d[1]-d[0],d[2]-d[3],
|
||||||
d[5]-d[4],d[6]-d[7]};
|
d[5]-d[4],d[6]-d[7]};
|
||||||
const btScalar gy[]={ d[3]-d[0],d[2]-d[1],
|
const btScalar gy[]={ d[3]-d[0],d[2]-d[1],
|
||||||
d[7]-d[4],d[6]-d[5]};
|
d[7]-d[4],d[6]-d[5]};
|
||||||
const btScalar gz[]={ d[4]-d[0],d[5]-d[1],
|
const btScalar gz[]={ d[4]-d[0],d[5]-d[1],
|
||||||
d[7]-d[3],d[6]-d[2]};
|
d[7]-d[3],d[6]-d[2]};
|
||||||
normal.setX(Lerp( Lerp(gx[0],gx[1],iy.f),
|
normal.setX(Lerp( Lerp(gx[0],gx[1],iy.f),
|
||||||
Lerp(gx[2],gx[3],iy.f),iz.f));
|
Lerp(gx[2],gx[3],iy.f),iz.f));
|
||||||
normal.setY(Lerp( Lerp(gy[0],gy[1],ix.f),
|
normal.setY(Lerp( Lerp(gy[0],gy[1],ix.f),
|
||||||
Lerp(gy[2],gy[3],ix.f),iz.f));
|
Lerp(gy[2],gy[3],ix.f),iz.f));
|
||||||
normal.setZ(Lerp( Lerp(gz[0],gz[1],ix.f),
|
normal.setZ(Lerp( Lerp(gz[0],gz[1],ix.f),
|
||||||
Lerp(gz[2],gz[3],ix.f),iy.f));
|
Lerp(gz[2],gz[3],ix.f),iy.f));
|
||||||
normal = normal.normalized();
|
normal = normal.normalized();
|
||||||
#else
|
#else
|
||||||
normal = btVector3(d[1]-d[0],d[3]-d[0],d[4]-d[0]).normalized();
|
normal = btVector3(d[1]-d[0],d[3]-d[0],d[4]-d[0]).normalized();
|
||||||
#endif
|
#endif
|
||||||
/* Distance */
|
/* Distance */
|
||||||
const btScalar d0=Lerp(Lerp(d[0],d[1],ix.f),
|
const btScalar d0=Lerp(Lerp(d[0],d[1],ix.f),
|
||||||
Lerp(d[3],d[2],ix.f),iy.f);
|
Lerp(d[3],d[2],ix.f),iy.f);
|
||||||
const btScalar d1=Lerp(Lerp(d[4],d[5],ix.f),
|
const btScalar d1=Lerp(Lerp(d[4],d[5],ix.f),
|
||||||
Lerp(d[7],d[6],ix.f),iy.f);
|
Lerp(d[7],d[6],ix.f),iy.f);
|
||||||
return(Lerp(d0,d1,iz.f)-margin);
|
return(Lerp(d0,d1,iz.f)-margin);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
void BuildCell(Cell& c)
|
void BuildCell(Cell& c)
|
||||||
{
|
{
|
||||||
const btVector3 org=btVector3( (btScalar)c.c[0],
|
const btVector3 org=btVector3( (btScalar)c.c[0],
|
||||||
(btScalar)c.c[1],
|
(btScalar)c.c[1],
|
||||||
(btScalar)c.c[2]) *
|
(btScalar)c.c[2]) *
|
||||||
CELLSIZE*voxelsz;
|
CELLSIZE*voxelsz;
|
||||||
for(int k=0;k<=CELLSIZE;++k)
|
for(int k=0;k<=CELLSIZE;++k)
|
||||||
{
|
{
|
||||||
const btScalar z=voxelsz*k+org.z();
|
const btScalar z=voxelsz*k+org.z();
|
||||||
for(int j=0;j<=CELLSIZE;++j)
|
for(int j=0;j<=CELLSIZE;++j)
|
||||||
{
|
{
|
||||||
const btScalar y=voxelsz*j+org.y();
|
const btScalar y=voxelsz*j+org.y();
|
||||||
for(int i=0;i<=CELLSIZE;++i)
|
for(int i=0;i<=CELLSIZE;++i)
|
||||||
{
|
{
|
||||||
const btScalar x=voxelsz*i+org.x();
|
const btScalar x=voxelsz*i+org.x();
|
||||||
c.d[i][j][k]=DistanceToShape( btVector3(x,y,z),
|
c.d[i][j][k]=DistanceToShape( btVector3(x,y,z),
|
||||||
c.pclient);
|
c.pclient);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
static inline btScalar DistanceToShape(const btVector3& x,
|
static inline btScalar DistanceToShape(const btVector3& x,
|
||||||
btCollisionShape* shape)
|
btCollisionShape* shape)
|
||||||
{
|
{
|
||||||
btTransform unit;
|
btTransform unit;
|
||||||
unit.setIdentity();
|
unit.setIdentity();
|
||||||
if(shape->isConvex())
|
if(shape->isConvex())
|
||||||
{
|
{
|
||||||
btGjkEpaSolver2::sResults res;
|
btGjkEpaSolver2::sResults res;
|
||||||
btConvexShape* csh=static_cast<btConvexShape*>(shape);
|
btConvexShape* csh=static_cast<btConvexShape*>(shape);
|
||||||
return(btGjkEpaSolver2::SignedDistance(x,0,csh,unit,res));
|
return(btGjkEpaSolver2::SignedDistance(x,0,csh,unit,res));
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
static inline IntFrac Decompose(btScalar x)
|
static inline IntFrac Decompose(btScalar x)
|
||||||
{
|
{
|
||||||
/* That one need a lot of improvements... */
|
/* That one need a lot of improvements... */
|
||||||
/* Remove test, faster floor... */
|
/* Remove test, faster floor... */
|
||||||
IntFrac r;
|
IntFrac r;
|
||||||
@@ -272,18 +272,18 @@ struct btSparseSdf
|
|||||||
const btScalar k=(x-r.b)*CELLSIZE;
|
const btScalar k=(x-r.b)*CELLSIZE;
|
||||||
r.i=(int)k;r.f=k-r.i;r.b-=o;
|
r.i=(int)k;r.f=k-r.i;r.b-=o;
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
static inline btScalar Lerp(btScalar a,btScalar b,btScalar t)
|
static inline btScalar Lerp(btScalar a,btScalar b,btScalar t)
|
||||||
{
|
{
|
||||||
return(a+(b-a)*t);
|
return(a+(b-a)*t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
static inline unsigned int Hash(int x,int y,int z,btCollisionShape* shape)
|
static inline unsigned int Hash(int x,int y,int z,btCollisionShape* shape)
|
||||||
{
|
{
|
||||||
struct btS
|
struct btS
|
||||||
{
|
{
|
||||||
int x,y,z;
|
int x,y,z;
|
||||||
@@ -291,16 +291,16 @@ struct btSparseSdf
|
|||||||
};
|
};
|
||||||
|
|
||||||
btS myset;
|
btS myset;
|
||||||
|
|
||||||
myset.x=x;myset.y=y;myset.z=z;myset.p=shape;
|
myset.x=x;myset.y=y;myset.z=z;myset.p=shape;
|
||||||
const void* ptr = &myset;
|
const void* ptr = &myset;
|
||||||
|
|
||||||
unsigned int result = HsiehHash<sizeof(btS)/4> (ptr);
|
unsigned int result = HsiehHash<sizeof(btS)/4> (ptr);
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in new issue
Block a user