[1963] | 1 | /* |
---|
| 2 | Bullet Continuous Collision Detection and Physics Library |
---|
| 3 | Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ |
---|
| 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 COLLISION_SHAPE_H |
---|
| 17 | #define 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 | |
---|
| 24 | ///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects. |
---|
| 25 | class btCollisionShape |
---|
| 26 | { |
---|
| 27 | protected: |
---|
| 28 | int m_shapeType; |
---|
| 29 | void* m_userPointer; |
---|
| 30 | |
---|
| 31 | public: |
---|
| 32 | |
---|
| 33 | btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0) |
---|
| 34 | { |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | virtual ~btCollisionShape() |
---|
| 38 | { |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | ///getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t. |
---|
| 42 | virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0; |
---|
| 43 | |
---|
| 44 | virtual void getBoundingSphere(btVector3& center,btScalar& radius) const; |
---|
| 45 | |
---|
| 46 | ///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations. |
---|
| 47 | virtual btScalar getAngularMotionDisc() const; |
---|
| 48 | |
---|
[2430] | 49 | virtual btScalar getContactBreakingThreshold() const; |
---|
[1963] | 50 | |
---|
[2430] | 51 | |
---|
[1963] | 52 | ///calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep) |
---|
| 53 | ///result is conservative |
---|
| 54 | void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const; |
---|
| 55 | |
---|
| 56 | #ifndef __SPU__ |
---|
| 57 | |
---|
| 58 | SIMD_FORCE_INLINE bool isPolyhedral() const |
---|
| 59 | { |
---|
| 60 | return btBroadphaseProxy::isPolyhedral(getShapeType()); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | SIMD_FORCE_INLINE bool isConvex() const |
---|
| 64 | { |
---|
| 65 | return btBroadphaseProxy::isConvex(getShapeType()); |
---|
| 66 | } |
---|
| 67 | SIMD_FORCE_INLINE bool isConcave() const |
---|
| 68 | { |
---|
| 69 | return btBroadphaseProxy::isConcave(getShapeType()); |
---|
| 70 | } |
---|
| 71 | SIMD_FORCE_INLINE bool isCompound() const |
---|
| 72 | { |
---|
| 73 | return btBroadphaseProxy::isCompound(getShapeType()); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | ///isInfinite is used to catch simulation error (aabb check) |
---|
| 77 | SIMD_FORCE_INLINE bool isInfinite() const |
---|
| 78 | { |
---|
| 79 | return btBroadphaseProxy::isInfinite(getShapeType()); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | virtual void setLocalScaling(const btVector3& scaling) =0; |
---|
| 84 | virtual const btVector3& getLocalScaling() const =0; |
---|
| 85 | virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const = 0; |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | //debugging support |
---|
| 89 | virtual const char* getName()const =0 ; |
---|
| 90 | #endif //__SPU__ |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | int getShapeType() const { return m_shapeType; } |
---|
| 94 | virtual void setMargin(btScalar margin) = 0; |
---|
| 95 | virtual btScalar getMargin() const = 0; |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | ///optional user data pointer |
---|
| 99 | void setUserPointer(void* userPtr) |
---|
| 100 | { |
---|
| 101 | m_userPointer = userPtr; |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | void* getUserPointer() const |
---|
| 105 | { |
---|
| 106 | return m_userPointer; |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | }; |
---|
| 110 | |
---|
| 111 | #endif //COLLISION_SHAPE_H |
---|
| 112 | |
---|