Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00017 #ifndef BT_DBVT_BROADPHASE_H
00018 #define BT_DBVT_BROADPHASE_H
00019
00020 #include "BulletCollision/BroadphaseCollision/btDbvt.h"
00021 #include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
00022
00023
00024
00025
00026
00027 #define DBVT_BP_PROFILE 0
00028
00029 #define DBVT_BP_PREVENTFALSEUPDATE 0
00030 #define DBVT_BP_ACCURATESLEEPING 0
00031 #define DBVT_BP_ENABLE_BENCHMARK 0
00032 #define DBVT_BP_MARGIN (btScalar)0.05
00033
00034 #if DBVT_BP_PROFILE
00035 #define DBVT_BP_PROFILING_RATE 256
00036 #include "LinearMath/btQuickprof.h"
00037 #endif
00038
00039
00040
00041
00042 struct btDbvtProxy : btBroadphaseProxy
00043 {
00044
00045
00046 btDbvtNode* leaf;
00047 btDbvtProxy* links[2];
00048 int stage;
00049
00050 btDbvtProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
00051 btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask)
00052 {
00053 links[0]=links[1]=0;
00054 }
00055 };
00056
00057 typedef btAlignedObjectArray<btDbvtProxy*> btDbvtProxyArray;
00058
00062 struct btDbvtBroadphase : btBroadphaseInterface
00063 {
00064
00065 enum {
00066 DYNAMIC_SET = 0,
00067 FIXED_SET = 1,
00068 STAGECOUNT = 2
00069 };
00070
00071 btDbvt m_sets[2];
00072 btDbvtProxy* m_stageRoots[STAGECOUNT+1];
00073 btOverlappingPairCache* m_paircache;
00074 btScalar m_prediction;
00075 int m_stageCurrent;
00076 int m_fupdates;
00077 int m_dupdates;
00078 int m_cupdates;
00079 int m_newpairs;
00080 int m_fixedleft;
00081 unsigned m_updates_call;
00082 unsigned m_updates_done;
00083 btScalar m_updates_ratio;
00084 int m_pid;
00085 int m_cid;
00086 int m_gid;
00087 bool m_releasepaircache;
00088 bool m_deferedcollide;
00089 bool m_needcleanup;
00090 #if DBVT_BP_PROFILE
00091 btClock m_clock;
00092 struct {
00093 unsigned long m_total;
00094 unsigned long m_ddcollide;
00095 unsigned long m_fdcollide;
00096 unsigned long m_cleanup;
00097 unsigned long m_jobcount;
00098 } m_profiling;
00099 #endif
00100
00101 btDbvtBroadphase(btOverlappingPairCache* paircache=0);
00102 ~btDbvtBroadphase();
00103 void collide(btDispatcher* dispatcher);
00104 void optimize();
00105
00106
00107 btBroadphaseProxy* createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
00108 virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
00109 virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
00110 virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0));
00111 virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback);
00112
00113 virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
00114 virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
00115 virtual btOverlappingPairCache* getOverlappingPairCache();
00116 virtual const btOverlappingPairCache* getOverlappingPairCache() const;
00117 virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const;
00118 virtual void printStats();
00119
00120
00122 virtual void resetPool(btDispatcher* dispatcher);
00123
00124 void performDeferredRemoval(btDispatcher* dispatcher);
00125
00126 void setVelocityPrediction(btScalar prediction)
00127 {
00128 m_prediction = prediction;
00129 }
00130 btScalar getVelocityPrediction() const
00131 {
00132 return m_prediction;
00133 }
00134
00139 void setAabbForceUpdate( btBroadphaseProxy* absproxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* );
00140
00141 static void benchmark(btBroadphaseInterface*);
00142
00143
00144 };
00145
00146 #endif