Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h @ 2259

Last change on this file since 2259 was 2192, checked in by rgrieder, 16 years ago

Reverted all changes of attempt to update physics branch.

  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2007 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15///btDbvtBroadphase implementation by Nathanael Presson
16#ifndef BT_DBVT_BROADPHASE_H
17#define BT_DBVT_BROADPHASE_H
18
19#include "BulletCollision/BroadphaseCollision/btDbvt.h"
20#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
21
22//
23// Compile time config
24//
25
26#define DBVT_BP_PROFILE                                 0
27#define DBVT_BP_SORTPAIRS                               1
28#define DBVT_BP_PREVENTFALSEUPDATE              0
29#define DBVT_BP_ACCURATESLEEPING                0
30#define DBVT_BP_ENABLE_BENCHMARK                0
31#define DBVT_BP_MARGIN                                  (btScalar)0.05
32
33#if DBVT_BP_PROFILE
34        #define DBVT_BP_PROFILING_RATE  256
35        #include "LinearMath/btQuickprof.h"
36#endif
37
38//
39// btDbvtProxy
40//
41struct btDbvtProxy : btBroadphaseProxy
42{
43/* Fields               */ 
44btDbvtAabbMm    aabb;
45btDbvtNode*             leaf;
46btDbvtProxy*    links[2];
47int                             stage;
48/* ctor                 */ 
49btDbvtProxy(void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
50        btBroadphaseProxy(userPtr,collisionFilterGroup,collisionFilterMask)
51        {
52        links[0]=links[1]=0;
53        }
54};
55
56typedef btAlignedObjectArray<btDbvtProxy*>      btDbvtProxyArray;
57
58///The btDbvtBroadphase implements a broadphase using two dynamic AABB bounding volume hierarchies/trees (see btDbvt).
59///One tree is used for static/non-moving objects, and another tree is used for dynamic objects. Objects can move from one tree to the other.
60///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.
61struct  btDbvtBroadphase : btBroadphaseInterface
62{
63/* Config               */ 
64enum    {
65                DYNAMIC_SET                     =       0,      /* Dynamic set index    */ 
66                FIXED_SET                       =       1,      /* Fixed set index              */ 
67                STAGECOUNT                      =       2       /* Number of stages             */ 
68                };
69/* Fields               */ 
70btDbvt                                  m_sets[2];                                      // Dbvt sets
71btDbvtProxy*                    m_stageRoots[STAGECOUNT+1];     // Stages list
72btOverlappingPairCache* m_paircache;                            // Pair cache
73btScalar                                m_prediction;                           // Velocity prediction
74int                                             m_stageCurrent;                         // Current stage
75int                                             m_fupdates;                                     // % of fixed updates per frame
76int                                             m_dupdates;                                     // % of dynamic updates per frame
77int                                             m_cupdates;                                     // % of cleanup updates per frame
78int                                             m_newpairs;                                     // Number of pairs created
79int                                             m_fixedleft;                            // Fixed optimization left
80unsigned                                m_updates_call;                         // Number of updates call
81unsigned                                m_updates_done;                         // Number of updates done
82btScalar                                m_updates_ratio;                        // m_updates_done/m_updates_call
83int                                             m_pid;                                          // Parse id
84int                                             m_cid;                                          // Cleanup index
85int                                             m_gid;                                          // Gen id
86bool                                    m_releasepaircache;                     // Release pair cache on delete
87bool                                    m_deferedcollide;                       // Defere dynamic/static collision to collide call
88bool                                    m_needcleanup;                          // Need to run cleanup?
89#if DBVT_BP_PROFILE
90btClock                                 m_clock;
91struct  {
92                unsigned long           m_total;
93                unsigned long           m_ddcollide;
94                unsigned long           m_fdcollide;
95                unsigned long           m_cleanup;
96                unsigned long           m_jobcount;
97                }                               m_profiling;
98#endif
99/* Methods              */ 
100btDbvtBroadphase(btOverlappingPairCache* paircache=0);
101~btDbvtBroadphase();
102void                                                    collide(btDispatcher* dispatcher);
103void                                                    optimize();
104/* btBroadphaseInterface Implementation */ 
105btBroadphaseProxy*                              createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
106void                                                    destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
107void                                                    setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
108void                                                    calculateOverlappingPairs(btDispatcher* dispatcher);
109btOverlappingPairCache*                 getOverlappingPairCache();
110const btOverlappingPairCache*   getOverlappingPairCache() const;
111void                                                    getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const;
112void                                                    printStats();
113static void                                             benchmark(btBroadphaseInterface*);
114};
115
116#endif
Note: See TracBrowser for help on using the repository browser.