Bullet Collision Detection & Physics Library: btCollisionShape.h Source File

Bullet Collision Detection & Physics Library

btCollisionShape.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16 #ifndef BT_COLLISION_SHAPE_H
17 #define BT_COLLISION_SHAPE_H
18
19 #include "LinearMath/btTransform.h"
20 #include "LinearMath/btVector3.h"
21 #include "LinearMath/btMatrix3x3.h"
22 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types
23 class btSerializer;
24
25
27 ATTRIBUTE_ALIGNED16(class) btCollisionShape
28 {
29 protected:
30 int m_shapeType;
31 void* m_userPointer;
32 int m_userIndex;
33
34 public:
35
36 BT_DECLARE_ALIGNED_ALLOCATOR();
37
38 btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0), m_userIndex(-1)
39 {
40 }
41
42 virtual ~btCollisionShape()
43 {
44 }
45
47 virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0;
48
49 virtual void getBoundingSphere(btVector3& center,btScalar& radius) const;
50
52 virtual btScalar getAngularMotionDisc() const;
53
54 virtual btScalar getContactBreakingThreshold(btScalar defaultContactThresholdFactor) const;
55
56
59 void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const;
60
61
62
63 SIMD_FORCE_INLINE bool isPolyhedral() const
64 {
65 return btBroadphaseProxy::isPolyhedral(getShapeType());
66 }
67
68 SIMD_FORCE_INLINE bool isConvex2d() const
69 {
70 return btBroadphaseProxy::isConvex2d(getShapeType());
71 }
72
73 SIMD_FORCE_INLINE bool isConvex() const
74 {
75 return btBroadphaseProxy::isConvex(getShapeType());
76 }
77 SIMD_FORCE_INLINE bool isNonMoving() const
78 {
79 return btBroadphaseProxy::isNonMoving(getShapeType());
80 }
81 SIMD_FORCE_INLINE bool isConcave() const
82 {
83 return btBroadphaseProxy::isConcave(getShapeType());
84 }
85 SIMD_FORCE_INLINE bool isCompound() const
86 {
87 return btBroadphaseProxy::isCompound(getShapeType());
88 }
89
90 SIMD_FORCE_INLINE bool isSoftBody() const
91 {
92 return btBroadphaseProxy::isSoftBody(getShapeType());
93 }
94
96 SIMD_FORCE_INLINE bool isInfinite() const
97 {
98 return btBroadphaseProxy::isInfinite(getShapeType());
99 }
100
101 #ifndef __SPU__
102 virtual void setLocalScaling(const btVector3& scaling) =0;
103 virtual const btVector3& getLocalScaling() const =0;
104 virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const = 0;
105
106
107 //debugging support
108 virtual const char* getName()const =0 ;
109 #endif //__SPU__
110
111
112 int getShapeType() const { return m_shapeType; }
113
116 virtual btVector3 getAnisotropicRollingFrictionDirection() const
117 {
118 return btVector3(1,1,1);
119 }
120 virtual void setMargin(btScalar margin) = 0;
121 virtual btScalar getMargin() const = 0;
122
123
125 void setUserPointer(void* userPtr)
126 {
127 m_userPointer = userPtr;
128 }
129
130 void* getUserPointer() const
131 {
132 return m_userPointer;
133 }
134 void setUserIndex(int index)
135 {
136 m_userIndex = index;
137 }
138
139 int getUserIndex() const
140 {
141 return m_userIndex;
142 }
143
144
145 virtual int calculateSerializeBufferSize() const;
146
148 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
149
150 virtual void serializeSingleShape(btSerializer* serializer) const;
151
152 };
153
155 struct btCollisionShapeData
156 {
157 char *m_name;
158 int m_shapeType;
159 char m_padding[4];
160 };
161
162 SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize() const
163 {
164 return sizeof(btCollisionShapeData);
165 }
166
167
168
169 #endif //BT_COLLISION_SHAPE_H
170
btBroadphaseProxy::isInfinite
static bool isInfinite(int proxyType)
Definition: btBroadphaseProxy.h:163
btCollisionShape::isConvex
bool isConvex() const
Definition: btCollisionShape.h:73
btCollisionShape::m_userPointer
void * m_userPointer
Definition: btCollisionShape.h:31
btVector3.h
btCollisionShape::isInfinite
bool isInfinite() const
isInfinite is used to catch simulation error (aabb check)
Definition: btCollisionShape.h:96
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition: btCollisionShape.h:27
btCollisionShape::isConvex2d
bool isConvex2d() const
Definition: btCollisionShape.h:68
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:81
btTransform.h
btBroadphaseProxy::isCompound
static bool isCompound(int proxyType)
Definition: btBroadphaseProxy.h:153
btCollisionShapeData::m_shapeType
int m_shapeType
Definition: btCollisionShape.h:158
btMatrix3x3.h
btCollisionShape::m_userIndex
int m_userIndex
Definition: btCollisionShape.h:32
btBroadphaseProxy::isNonMoving
static bool isNonMoving(int proxyType)
Definition: btBroadphaseProxy.h:143
btSerializer
Definition: btSerializer.h:68
btCollisionShapeData::m_name
char * m_name
Definition: btCollisionShape.h:157
btCollisionShape::setUserPointer
void setUserPointer(void *userPtr)
optional user data pointer
Definition: btCollisionShape.h:125
btCollisionShape::isCompound
bool isCompound() const
Definition: btCollisionShape.h:85
btCollisionShape::getUserIndex
int getUserIndex() const
Definition: btCollisionShape.h:139
INVALID_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:76
btCollisionShape::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btCollisionShape.h:162
btCollisionShape::btCollisionShape
btCollisionShape()
Definition: btCollisionShape.h:38
btBroadphaseProxy.h
btCollisionShape::isConcave
bool isConcave() const
Definition: btCollisionShape.h:81
btCollisionShape::getAnisotropicRollingFrictionDirection
virtual btVector3 getAnisotropicRollingFrictionDirection() const
the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See...
Definition: btCollisionShape.h:116
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:82
btBroadphaseProxy::isPolyhedral
static bool isPolyhedral(int proxyType)
Definition: btBroadphaseProxy.h:133
btCollisionShape::isPolyhedral
bool isPolyhedral() const
Definition: btCollisionShape.h:63
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
btBroadphaseProxy::isSoftBody
static bool isSoftBody(int proxyType)
Definition: btBroadphaseProxy.h:158
btCollisionShape::isNonMoving
bool isNonMoving() const
Definition: btCollisionShape.h:77
btCollisionShape::isSoftBody
bool isSoftBody() const
Definition: btCollisionShape.h:90
BT_DECLARE_ALIGNED_ALLOCATOR
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:403
btBroadphaseProxy::isConvex2d
static bool isConvex2d(int proxyType)
Definition: btBroadphaseProxy.h:168
btBroadphaseProxy::isConcave
static bool isConcave(int proxyType)
Definition: btBroadphaseProxy.h:148
btCollisionShape::~btCollisionShape
virtual ~btCollisionShape()
Definition: btCollisionShape.h:42
btCollisionShape::getShapeType
int getShapeType() const
Definition: btCollisionShape.h:112
btCollisionShape::setUserIndex
void setUserIndex(int index)
Definition: btCollisionShape.h:134
btCollisionShape::getUserPointer
void * getUserPointer() const
Definition: btCollisionShape.h:130
btCollisionShape::m_shapeType
int m_shapeType
Definition: btCollisionShape.h:30
btCollisionShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btCollisionShape.h:155
btBroadphaseProxy::isConvex
static bool isConvex(int proxyType)
Definition: btBroadphaseProxy.h:138
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
btCollisionShapeData::m_padding
char m_padding[4]
Definition: btCollisionShape.h:159