[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 MULTI_SPHERE_MINKOWSKI_H |
---|
| 17 | #define MULTI_SPHERE_MINKOWSKI_H |
---|
| 18 | |
---|
| 19 | #include "btConvexInternalShape.h" |
---|
| 20 | #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types |
---|
| 21 | |
---|
| 22 | #define MAX_NUM_SPHERES 5 |
---|
| 23 | |
---|
| 24 | ///The btMultiSphereShape represents the convex hull of a collection of spheres. You can create special capsules or other smooth volumes. |
---|
| 25 | ///It is possible to animate the spheres for deformation. |
---|
| 26 | class btMultiSphereShape : public btConvexInternalShape |
---|
| 27 | |
---|
| 28 | { |
---|
| 29 | |
---|
| 30 | btVector3 m_localPositions[MAX_NUM_SPHERES]; |
---|
| 31 | btScalar m_radi[MAX_NUM_SPHERES]; |
---|
| 32 | btVector3 m_inertiaHalfExtents; |
---|
| 33 | |
---|
| 34 | int m_numSpheres; |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | public: |
---|
| 40 | btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres); |
---|
| 41 | |
---|
| 42 | ///CollisionShape Interface |
---|
| 43 | virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; |
---|
| 44 | |
---|
| 45 | /// btConvexShape Interface |
---|
| 46 | virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; |
---|
| 47 | |
---|
| 48 | virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; |
---|
| 49 | |
---|
| 50 | int getSphereCount() const |
---|
| 51 | { |
---|
| 52 | return m_numSpheres; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | const btVector3& getSpherePosition(int index) const |
---|
| 56 | { |
---|
| 57 | return m_localPositions[index]; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | btScalar getSphereRadius(int index) const |
---|
| 61 | { |
---|
| 62 | return m_radi[index]; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | virtual const char* getName()const |
---|
| 67 | { |
---|
| 68 | return "MultiSphere"; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | }; |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | #endif //MULTI_SPHERE_MINKOWSKI_H |
---|