15 #if defined (_WIN32) || defined (__i386__)
16 #define BT_USE_SSE_IN_API
65 if (shiftVerticesByMargin)
71 for (
int p=0;p<planeEquations.
size();p++)
94 faceNormals.
resize(numFaces);
103 for (
int p=0;p<numVertices;p++)
109 for (
int i=0;i<numFaces;i++)
111 int face = convexUtil->
faces[i];
132 edges[numEdges++] = newEdge;
135 }
while (edge!=firstEdge);
142 faceNormals[i] = edges[0].
cross(edges[1]);
143 faceNormals[i].normalize();
144 tmpFaces[i].m_plane[0] = faceNormals[i].getX();
145 tmpFaces[i].m_plane[1] = faceNormals[i].getY();
146 tmpFaces[i].m_plane[2] = faceNormals[i].getZ();
147 tmpFaces[i].m_plane[3] = planeEq;
153 faceNormals[i].setZero();
156 for (
int v=0;v<tmpFaces[i].m_indices.
size();v++)
164 tmpFaces[i].m_plane[3] = -planeEq;
171 for (
int i=0;i<tmpFaces.
size();i++)
174 while (todoFaces.
size())
177 int refFace = todoFaces[todoFaces.
size()-1];
180 btFace& faceA = tmpFaces[refFace];
184 for (
int j=todoFaces.
size()-1;j>=0;j--)
186 int i = todoFaces[j];
187 btFace& faceB = tmpFaces[i];
189 if (faceNormalA.
dot(faceNormalB)>faceWeldThreshold)
197 bool did_merge =
false;
198 if (coplanarFaceGroup.
size()>1)
205 for (
int i=0;i<coplanarFaceGroup.
size();i++)
209 btFace& face = tmpFaces[coplanarFaceGroup[i]];
211 averageFaceNormal+=faceNormal;
219 for (
int i=0;i<orgpoints.
size();i++)
222 if (orgpoints[i].m_orgIndex == orgIndex)
236 for (
int i=0;i<4;i++)
237 combinedFace.
m_plane[i] = tmpFaces[coplanarFaceGroup[0]].m_plane[i];
244 for (
int i=0;i<hull.size();i++)
247 for(
int k = 0; k < orgpoints.
size(); k++)
249 if(orgpoints[k].m_orgIndex == hull[i].m_orgIndex)
251 orgpoints[k].m_orgIndex = -1;
258 bool reject_merge =
false;
262 for(
int i = 0; i < orgpoints.
size(); i++) {
263 if(orgpoints[i].m_orgIndex == -1)
266 for(
int j = 0; j < tmpFaces.
size(); j++) {
268 btFace& face = tmpFaces[j];
270 bool is_in_current_group =
false;
271 for(
int k = 0; k < coplanarFaceGroup.
size(); k++) {
272 if(coplanarFaceGroup[k] == j) {
273 is_in_current_group =
true;
277 if(is_in_current_group)
281 if(face.
m_indices[v] == orgpoints[i].m_orgIndex) {
303 for (
int i=0;i<coplanarFaceGroup.
size();i++)
305 btFace face = tmpFaces[coplanarFaceGroup[i]];
321 #define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
351 for( i = 0; i < inner_count; i++ )
353 i = (int) vec.
maxDot( temp, inner_count, newDot);
375 for (i=0;i<numVectors;i++)
380 for (
int j=0;j<numVectors;j++)
388 for( i = 0; i < inner_count; i++ )
390 i = (int) vec.
maxDot( temp, inner_count, newDot);
391 if (newDot > supportVerticesOut[j][3])
393 supportVerticesOut[j] = temp[i];
394 supportVerticesOut[j][3] = newDot;
414 getAabb(ident,aabbMin,aabbMax);
425 inertia = scaledmass * (
btVector3(y2+z2,x2+z2,x2+y2));
439 m_localAabbMin(1,1,1),
440 m_localAabbMax(-1,-1,-1),
441 m_isLocalAabbValid(false)
477 for (
int i = 0; i < 3; ++i )
485 for (
int i=0;i<3;i++)
btAlignedObjectArray< btVector3 > m_vertices
void push_back(const T &_Val)
const Edge * getNextEdgeOfFace() const
void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb's default implementation is brute force, expected derived classes to implement a fast dedicat...
btScalar m_collisionMargin
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
void getNonvirtualAabb(const btTransform &trans, btVector3 &aabbMin, btVector3 &aabbMax, btScalar margin) const
btAlignedObjectArray< Edge > edges
int getTargetVertex() const
The btConvexInternalShape is an internal base class, shared by most convex shape implementations.
virtual void setLocalScaling(const btVector3 &scaling)
btScalar btSqrt(btScalar y)
virtual void getVertex(int i, btVector3 &vtx) const =0
long maxDot(const btVector3 *array, long array_count, btScalar &dotOut) const
returns index of maximum dot product between this and vectors in array[]
int getSourceVertex() const
virtual ~btPolyhedralConvexShape()
Convex hull implementation based on Preparata and Hong See http://code.google.com/p/bullet/issues/det...
btScalar dot(const btVector3 &v) const
Return the dot product.
virtual btScalar getMargin() const
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
const btScalar & x() const
Return the x value.
btAlignedObjectArray< int > m_indices
int size() const
return the number of elements in the array
btAlignedObjectArray< btFace > m_faces
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb's default implementation is brute force, expected derived classes to implement a fast dedicat...
virtual bool initializePolyhedralFeatures(int shiftVerticesByMargin=0)
optional method mainly used to generate multiple contact points by clipping polyhedral features (face...
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
#define btAlignedFree(ptr)
The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
virtual ~btConvexPolyhedron()
virtual int getNumVertices() const =0
static void getPlaneEquationsFromVertices(btAlignedObjectArray< btVector3 > &vertices, btAlignedObjectArray< btVector3 > &planeEquationsOut)
const btScalar & y() const
Return the y value.
virtual btVector3 localGetSupportingVertex(const btVector3 &vec) const
btPolyhedralConvexAabbCachingShape()
btPolyhedralConvexShape()
btVector3 can be used to represent 3D points and vectors.
btScalar length2() const
Return the length of the vector squared.
btAlignedObjectArray< btVector3 > vertices
void remove(const T &key)
void resize(int newsize, const T &fillData=T())
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
T & expand(const T &fillValue=T())
btConvexPolyhedron * m_polyhedron
void GrahamScanConvexHull2D(btAlignedObjectArray< GrahamVector3 > &originalPoints, btAlignedObjectArray< GrahamVector3 > &hull, const btVector3 &normalAxis)
#define btAlignedAlloc(size, alignment)
virtual void setLocalScaling(const btVector3 &scaling)
btScalar compute(const void *coords, bool doubleCoords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
static void getVerticesFromPlaneEquations(const btAlignedObjectArray< btVector3 > &planeEquations, btAlignedObjectArray< btVector3 > &verticesOut)
btAlignedObjectArray< int > faces
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3 &vec) const
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
const btScalar & z() const
Return the z value.