00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_CONVEX_POINT_CLOUD_SHAPE_H
00017 #define BT_CONVEX_POINT_CLOUD_SHAPE_H
00018
00019 #include "btPolyhedralConvexShape.h"
00020 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
00021 #include "LinearMath/btAlignedObjectArray.h"
00022
00024 ATTRIBUTE_ALIGNED16(class) btConvexPointCloudShape : public btPolyhedralConvexAabbCachingShape
00025 {
00026 btVector3* m_unscaledPoints;
00027 int m_numPoints;
00028
00029 public:
00030 BT_DECLARE_ALIGNED_ALLOCATOR();
00031
00032 btConvexPointCloudShape()
00033 {
00034 m_localScaling.setValue(1.f,1.f,1.f);
00035 m_shapeType = CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE;
00036 m_unscaledPoints = 0;
00037 m_numPoints = 0;
00038 }
00039
00040 btConvexPointCloudShape(btVector3* points,int numPoints, const btVector3& localScaling,bool computeAabb = true)
00041 {
00042 m_localScaling = localScaling;
00043 m_shapeType = CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE;
00044 m_unscaledPoints = points;
00045 m_numPoints = numPoints;
00046
00047 if (computeAabb)
00048 recalcLocalAabb();
00049 }
00050
00051 void setPoints (btVector3* points, int numPoints, bool computeAabb = true,const btVector3& localScaling=btVector3(1.f,1.f,1.f))
00052 {
00053 m_unscaledPoints = points;
00054 m_numPoints = numPoints;
00055 m_localScaling = localScaling;
00056
00057 if (computeAabb)
00058 recalcLocalAabb();
00059 }
00060
00061 SIMD_FORCE_INLINE btVector3* getUnscaledPoints()
00062 {
00063 return m_unscaledPoints;
00064 }
00065
00066 SIMD_FORCE_INLINE const btVector3* getUnscaledPoints() const
00067 {
00068 return m_unscaledPoints;
00069 }
00070
00071 SIMD_FORCE_INLINE int getNumPoints() const
00072 {
00073 return m_numPoints;
00074 }
00075
00076 SIMD_FORCE_INLINE btVector3 getScaledPoint( int index) const
00077 {
00078 return m_unscaledPoints[index] * m_localScaling;
00079 }
00080
00081 #ifndef __SPU__
00082 virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
00083 virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
00084 virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00085 #endif
00086
00087
00088
00089 virtual const char* getName()const {return "ConvexPointCloud";}
00090
00091 virtual int getNumVertices() const;
00092 virtual int getNumEdges() const;
00093 virtual void getEdge(int i,btVector3& pa,btVector3& pb) const;
00094 virtual void getVertex(int i,btVector3& vtx) const;
00095 virtual int getNumPlanes() const;
00096 virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const;
00097 virtual bool isInside(const btVector3& pt,btScalar tolerance) const;
00098
00100 virtual void setLocalScaling(const btVector3& scaling);
00101 };
00102
00103
00104 #endif //BT_CONVEX_POINT_CLOUD_SHAPE_H
00105