926191bddbbb9617c01f3cd1097f53f6a7785bea
[blender.git] / extern / bullet / Bullet / CollisionShapes / TriangleMeshShape.h
1 /*
2  * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
3  *
4  * Permission to use, copy, modify, distribute and sell this software
5  * and its documentation for any purpose is hereby granted without fee,
6  * provided that the above copyright notice appear in all copies.
7  * Erwin Coumans makes no representations about the suitability 
8  * of this software for any purpose.  
9  * It is provided "as is" without express or implied warranty.
10 */
11 #ifndef TRIANGLE_MESH_SHAPE_H
12 #define TRIANGLE_MESH_SHAPE_H
13
14 #include "CollisionShapes/CollisionShape.h"
15 #include "BroadphaseCollision/BroadphaseProxy.h" // for the types
16
17 #include "StridingMeshInterface.h"
18 #include "TriangleCallback.h"
19
20
21
22 ///Concave triangle mesh. Uses an interface to access the triangles to allow for sharing graphics/physics triangles.
23 class TriangleMeshShape : public CollisionShape
24 {
25
26         StridingMeshInterface* m_meshInterface;
27         float m_collisionMargin;
28
29 public:
30         TriangleMeshShape(StridingMeshInterface* meshInterface);
31
32         virtual ~TriangleMeshShape();
33
34
35         
36         virtual SimdVector3 LocalGetSupportingVertex(const SimdVector3& vec) const;
37
38         virtual SimdVector3     LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const
39         {
40                 assert(0);
41                 return LocalGetSupportingVertex(vec);
42         }
43
44         virtual int     GetShapeType() const
45         {
46                 return TRIANGLE_MESH_SHAPE_PROXYTYPE;
47         }
48
49         virtual void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const;
50
51         void    ProcessAllTriangles(TriangleCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const;
52
53         virtual void    CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia);
54
55         virtual void    setLocalScaling(const SimdVector3& scaling);
56         virtual const SimdVector3& getLocalScaling() const;
57         
58
59         //debugging
60         virtual char*   GetName()const {return "TRIANGLEMESH";}
61
62         
63         virtual float GetMargin() const {
64                 return m_collisionMargin;
65         }
66         virtual void SetMargin(float collisionMargin)
67         {
68                 m_collisionMargin = collisionMargin;
69         }
70
71
72
73 };
74
75 #endif //TRIANGLE_MESH_SHAPE_H