a06bcb1e9dcdbc27b7be815c4f91cf222bc9b60c
[blender.git] / extern / bullet / Bullet / CollisionShapes / ConvexHullShape.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
12 #ifndef CONVEX_HULL_SHAPE_H
13 #define CONVEX_HULL_SHAPE_H
14
15 #include "PolyhedralConvexShape.h"
16 #include "BroadphaseCollision/BroadphaseProxy.h" // for the types
17
18 #include <vector>
19
20 ///ConvexHullShape implements an implicit (getSupportingVertex) Convex Hull of a Point Cloud (vertices)
21 ///No connectivity is needed. LocalGetSupportingVertex iterates linearly though all vertices.
22 ///on modern hardware, due to cache coherency this isn't that bad. Complex algorithms tend to trash the cash.
23 ///(memory is much slower then the cpu)
24 class ConvexHullShape : public PolyhedralConvexShape
25 {
26         std::vector<SimdPoint3> m_points;
27
28 public:
29         ConvexHullShape(SimdPoint3* points,int numPoints);
30
31         void AddPoint(const SimdPoint3& point)
32         {
33                 m_points.push_back(point);
34         }
35         virtual SimdVector3     LocalGetSupportingVertex(const SimdVector3& vec)const;
36         virtual SimdVector3     LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const;
37
38         virtual void    CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia);
39
40         virtual int     GetShapeType()const { return CONVEX_HULL_SHAPE_PROXYTYPE; }
41
42         //debugging
43         virtual char*   GetName()const {return "Convex";}
44
45         
46         virtual int     GetNumVertices() const;
47         virtual int GetNumEdges() const;
48         virtual void GetEdge(int i,SimdPoint3& pa,SimdPoint3& pb) const;
49         virtual void GetVertex(int i,SimdPoint3& vtx) const;
50         virtual int     GetNumPlanes() const;
51         virtual void GetPlane(SimdVector3& planeNormal,SimdPoint3& planeSupport,int i ) const;
52         virtual bool IsInside(const SimdPoint3& pt,SimdScalar tolerance) const;
53
54
55
56 };
57
58
59 #endif //CONVEX_HULL_SHAPE_H