Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "btConvexPointCloudShape.h"
00017 #include "BulletCollision/CollisionShapes/btCollisionMargin.h"
00018
00019 #include "LinearMath/btQuaternion.h"
00020
00021 void btConvexPointCloudShape::setLocalScaling(const btVector3& scaling)
00022 {
00023 m_localScaling = scaling;
00024 recalcLocalAabb();
00025 }
00026
00027 #ifndef __SPU__
00028 btVector3 btConvexPointCloudShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
00029 {
00030 btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
00031 btScalar maxDot = btScalar(-BT_LARGE_FLOAT);
00032
00033 btVector3 vec = vec0;
00034 btScalar lenSqr = vec.length2();
00035 if (lenSqr < btScalar(0.0001))
00036 {
00037 vec.setValue(1,0,0);
00038 } else
00039 {
00040 btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
00041 vec *= rlen;
00042 }
00043
00044 if( m_numPoints > 0 )
00045 {
00046
00047
00048 int index = (int) vec.maxDot( &m_unscaledPoints[0], m_numPoints, maxDot);
00049 return getScaledPoint(index);
00050 }
00051
00052 return supVec;
00053 }
00054
00055 void btConvexPointCloudShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
00056 {
00057 for( int j = 0; j < numVectors; j++ )
00058 {
00059 const btVector3& vec = vectors[j] * m_localScaling;
00060 btScalar maxDot;
00061 int index = (int) vec.maxDot( &m_unscaledPoints[0], m_numPoints, maxDot);
00062 supportVerticesOut[j][3] = btScalar(-BT_LARGE_FLOAT);
00063 if( 0 <= index )
00064 {
00065
00066 supportVerticesOut[j] = getScaledPoint(index);
00067 supportVerticesOut[j][3] = maxDot;
00068 }
00069 }
00070
00071 }
00072
00073
00074
00075 btVector3 btConvexPointCloudShape::localGetSupportingVertex(const btVector3& vec)const
00076 {
00077 btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
00078
00079 if ( getMargin()!=btScalar(0.) )
00080 {
00081 btVector3 vecnorm = vec;
00082 if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
00083 {
00084 vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
00085 }
00086 vecnorm.normalize();
00087 supVertex+= getMargin() * vecnorm;
00088 }
00089 return supVertex;
00090 }
00091
00092
00093 #endif
00094
00095
00096
00097
00098
00099
00100
00101
00102 int btConvexPointCloudShape::getNumVertices() const
00103 {
00104 return m_numPoints;
00105 }
00106
00107 int btConvexPointCloudShape::getNumEdges() const
00108 {
00109 return 0;
00110 }
00111
00112 void btConvexPointCloudShape::getEdge(int i,btVector3& pa,btVector3& pb) const
00113 {
00114 btAssert (0);
00115 }
00116
00117 void btConvexPointCloudShape::getVertex(int i,btVector3& vtx) const
00118 {
00119 vtx = m_unscaledPoints[i]*m_localScaling;
00120 }
00121
00122 int btConvexPointCloudShape::getNumPlanes() const
00123 {
00124 return 0;
00125 }
00126
00127 void btConvexPointCloudShape::getPlane(btVector3& ,btVector3& ,int ) const
00128 {
00129
00130 btAssert(0);
00131 }
00132
00133
00134 bool btConvexPointCloudShape::isInside(const btVector3& ,btScalar ) const
00135 {
00136 btAssert(0);
00137 return false;
00138 }
00139