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 
28 {
29 protected:
32 
33 public:
34 
36 
37  btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0)
38  {
39  }
40 
41  virtual ~btCollisionShape()
42  {
43  }
44 
46  virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0;
47 
48  virtual void getBoundingSphere(btVector3& center,btScalar& radius) const;
49 
51  virtual btScalar getAngularMotionDisc() const;
52 
53  virtual btScalar getContactBreakingThreshold(btScalar defaultContactThresholdFactor) const;
54 
55 
58  void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const;
59 
60 
61 
62  SIMD_FORCE_INLINE bool isPolyhedral() const
63  {
64  return btBroadphaseProxy::isPolyhedral(getShapeType());
65  }
66 
67  SIMD_FORCE_INLINE bool isConvex2d() const
68  {
69  return btBroadphaseProxy::isConvex2d(getShapeType());
70  }
71 
72  SIMD_FORCE_INLINE bool isConvex() const
73  {
74  return btBroadphaseProxy::isConvex(getShapeType());
75  }
76  SIMD_FORCE_INLINE bool isNonMoving() const
77  {
78  return btBroadphaseProxy::isNonMoving(getShapeType());
79  }
80  SIMD_FORCE_INLINE bool isConcave() const
81  {
82  return btBroadphaseProxy::isConcave(getShapeType());
83  }
84  SIMD_FORCE_INLINE bool isCompound() const
85  {
86  return btBroadphaseProxy::isCompound(getShapeType());
87  }
88 
89  SIMD_FORCE_INLINE bool isSoftBody() const
90  {
91  return btBroadphaseProxy::isSoftBody(getShapeType());
92  }
93 
95  SIMD_FORCE_INLINE bool isInfinite() const
96  {
97  return btBroadphaseProxy::isInfinite(getShapeType());
98  }
99 
100 #ifndef __SPU__
101  virtual void setLocalScaling(const btVector3& scaling) =0;
102  virtual const btVector3& getLocalScaling() const =0;
103  virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const = 0;
104 
105 
106 //debugging support
107  virtual const char* getName()const =0 ;
108 #endif //__SPU__
109 
110 
111  int getShapeType() const { return m_shapeType; }
112 
115  virtual btVector3 getAnisotropicRollingFrictionDirection() const
116  {
117  return btVector3(1,1,1);
118  }
119  virtual void setMargin(btScalar margin) = 0;
120  virtual btScalar getMargin() const = 0;
121 
122 
124  void setUserPointer(void* userPtr)
125  {
126  m_userPointer = userPtr;
127  }
128 
129  void* getUserPointer() const
130  {
131  return m_userPointer;
132  }
133 
134  virtual int calculateSerializeBufferSize() const;
135 
137  virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
138 
139  virtual void serializeSingleShape(btSerializer* serializer) const;
140 
141 };
142 
145 {
146  char *m_name;
148  char m_padding[4];
149 };
150 
152 {
153  return sizeof(btCollisionShapeData);
154 }
155 
156 
157 
158 #endif //BT_COLLISION_SHAPE_H
159