Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h @ 2041

Last change on this file since 2041 was 1972, checked in by rgrieder, 16 years ago

Downgraded Bullet to latest tagged version: 2.72
That should give us more stability.

  • Property svn:eol-style set to native
File size: 6.4 KB
RevLine 
[1963]1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 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
16#ifndef BROADPHASE_PROXY_H
17#define BROADPHASE_PROXY_H
18
19#include "LinearMath/btScalar.h" //for SIMD_FORCE_INLINE
20#include "LinearMath/btAlignedAllocator.h"
21
22
23/// btDispatcher uses these types
24/// IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and concave
25/// to facilitate type checking
26enum BroadphaseNativeTypes
27{
28        // polyhedral convex shapes
29        BOX_SHAPE_PROXYTYPE,
30        TRIANGLE_SHAPE_PROXYTYPE,
31        TETRAHEDRAL_SHAPE_PROXYTYPE,
32        CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE,
33        CONVEX_HULL_SHAPE_PROXYTYPE,
34        CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
35//implicit convex shapes
36IMPLICIT_CONVEX_SHAPES_START_HERE,
37        SPHERE_SHAPE_PROXYTYPE,
38        MULTI_SPHERE_SHAPE_PROXYTYPE,
39        CAPSULE_SHAPE_PROXYTYPE,
40        CONE_SHAPE_PROXYTYPE,
41        CONVEX_SHAPE_PROXYTYPE,
42        CYLINDER_SHAPE_PROXYTYPE,
43        UNIFORM_SCALING_SHAPE_PROXYTYPE,
44        MINKOWSKI_SUM_SHAPE_PROXYTYPE,
45        MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE,
46//concave shapes
47CONCAVE_SHAPES_START_HERE,
48        //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
49        TRIANGLE_MESH_SHAPE_PROXYTYPE,
50        SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE,
51        ///used for demo integration FAST/Swift collision library and Bullet
52        FAST_CONCAVE_MESH_PROXYTYPE,
53        //terrain
54        TERRAIN_SHAPE_PROXYTYPE,
55///Used for GIMPACT Trimesh integration
56        GIMPACT_SHAPE_PROXYTYPE,
57///Multimaterial mesh
58    MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
59       
60        EMPTY_SHAPE_PROXYTYPE,
61        STATIC_PLANE_PROXYTYPE,
62CONCAVE_SHAPES_END_HERE,
63
64        COMPOUND_SHAPE_PROXYTYPE,
65
66        SOFTBODY_SHAPE_PROXYTYPE,
67
68        INVALID_SHAPE_PROXYTYPE,
69
70        MAX_BROADPHASE_COLLISION_TYPES
71       
72};
73
74
75///The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
76///It stores collision shape type information, collision filter information and a client object, typically a btCollisionObject or btRigidBody.
77ATTRIBUTE_ALIGNED16(struct) btBroadphaseProxy
78{
79
80BT_DECLARE_ALIGNED_ALLOCATOR();
81       
82        ///optional filtering to cull potential collisions
83        enum CollisionFilterGroups
84        {
85                DefaultFilter = 1,
86                StaticFilter = 2,
87                KinematicFilter = 4,
88                DebrisFilter = 8,
89                        SensorTrigger = 16,
90                AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
91        };
92
93        //Usually the client btCollisionObject or Rigidbody class
94        void*   m_clientObject;
95
96        short int m_collisionFilterGroup;
97        short int m_collisionFilterMask;
98
99        void*   m_multiSapParentProxy;         
100
101
102        int                     m_uniqueId;//m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
103
104        SIMD_FORCE_INLINE int getUid() const
105        {
106                return m_uniqueId;
107        }
108
109        //used for memory pools
110        btBroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0)
111        {
112        }
113
[1972]114        btBroadphaseProxy(void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0)
115                :m_clientObject(userPtr),
[1963]116                m_collisionFilterGroup(collisionFilterGroup),
117                m_collisionFilterMask(collisionFilterMask)
118        {
119                m_multiSapParentProxy = multiSapParentProxy;
120        }
121
122       
123
124        static SIMD_FORCE_INLINE bool isPolyhedral(int proxyType)
125        {
126                return (proxyType  < IMPLICIT_CONVEX_SHAPES_START_HERE);
127        }
128
129        static SIMD_FORCE_INLINE bool   isConvex(int proxyType)
130        {
131                return (proxyType < CONCAVE_SHAPES_START_HERE);
132        }
133
134        static SIMD_FORCE_INLINE bool   isConcave(int proxyType)
135        {
136                return ((proxyType > CONCAVE_SHAPES_START_HERE) &&
137                        (proxyType < CONCAVE_SHAPES_END_HERE));
138        }
139        static SIMD_FORCE_INLINE bool   isCompound(int proxyType)
140        {
141                return (proxyType == COMPOUND_SHAPE_PROXYTYPE);
142        }
143        static SIMD_FORCE_INLINE bool isInfinite(int proxyType)
144        {
145                return (proxyType == STATIC_PLANE_PROXYTYPE);
146        }
147       
148}
149;
150
151class btCollisionAlgorithm;
152
153struct btBroadphaseProxy;
154
155
156
157///The btBroadphasePair class contains a pair of aabb-overlapping objects.
158///A btDispatcher can search a btCollisionAlgorithm that performs exact/narrowphase collision detection on the actual collision shapes.
159ATTRIBUTE_ALIGNED16(struct) btBroadphasePair
160{
161        btBroadphasePair ()
162                :
163        m_pProxy0(0),
164                m_pProxy1(0),
165                m_algorithm(0),
166                m_userInfo(0)
167        {
168        }
169
170BT_DECLARE_ALIGNED_ALLOCATOR();
171
172        btBroadphasePair(const btBroadphasePair& other)
173                :               m_pProxy0(other.m_pProxy0),
174                                m_pProxy1(other.m_pProxy1),
175                                m_algorithm(other.m_algorithm),
176                                m_userInfo(other.m_userInfo)
177        {
178        }
179        btBroadphasePair(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
180        {
181
182                //keep them sorted, so the std::set operations work
183                if (&proxy0 < &proxy1)
184        { 
185            m_pProxy0 = &proxy0; 
186            m_pProxy1 = &proxy1; 
187        }
188        else 
189        { 
190                        m_pProxy0 = &proxy1; 
191            m_pProxy1 = &proxy0; 
192        }
193
194                m_algorithm = 0;
195                m_userInfo = 0;
196
197        }
198       
199        btBroadphaseProxy* m_pProxy0;
200        btBroadphaseProxy* m_pProxy1;
201       
202        mutable btCollisionAlgorithm* m_algorithm;
203        mutable void* m_userInfo;
204
205};
206
207/*
208//comparison for set operation, see Solid DT_Encounter
209SIMD_FORCE_INLINE bool operator<(const btBroadphasePair& a, const btBroadphasePair& b)
210{
211    return a.m_pProxy0 < b.m_pProxy0 ||
212        (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 < b.m_pProxy1);
213}
214*/
215
216
217
218class btBroadphasePairSortPredicate
219{
220        public:
221
222                bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b )
223                {
224                         return a.m_pProxy0 > b.m_pProxy0 || 
225                                (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 > b.m_pProxy1) ||
226                                (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm); 
227                }
228};
229
230
231SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b) 
232{
233         return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1);
234}
235
236
237#endif //BROADPHASE_PROXY_H
238
Note: See TracBrowser for help on using the repository browser.