15#if defined(_WIN32) || defined(__i386__)
16#define BT_USE_SSE_IN_API
74 if (shiftVerticesByMargin)
80 for (
int p = 0; p < planeEquations.
size(); p++)
99#ifndef BT_RECONSTRUCT_FACES
103 for (
int p = 0; p < numVertices; p++)
109 for (
int j = 0; j < conv.
faces.
size(); j++)
126 edges[numEdges++] = newEdge;
154 combinedFace.
m_plane[3] = -planeEq;
163 faceNormals.
resize(numFaces);
167 tmpFaces.
resize(numFaces);
171 for (
int p = 0; p < numVertices; p++)
176 for (
int i = 0; i < numFaces; i++)
178 int face = convexUtil->
faces[i];
198 edges[numEdges++] = newEdge;
201 }
while (edge != firstEdge);
207 faceNormals[i] = edges[0].
cross(edges[1]);
208 faceNormals[i].normalize();
209 tmpFaces[i].m_plane[0] = faceNormals[i].getX();
210 tmpFaces[i].m_plane[1] = faceNormals[i].getY();
211 tmpFaces[i].m_plane[2] = faceNormals[i].getZ();
212 tmpFaces[i].m_plane[3] = planeEq;
217 faceNormals[i].setZero();
220 for (
int v = 0; v < tmpFaces[i].m_indices.
size(); v++)
228 tmpFaces[i].m_plane[3] = -planeEq;
233 btScalar faceWeldThreshold = 0.999f;
235 for (
int i = 0; i < tmpFaces.
size(); i++)
238 while (todoFaces.
size())
241 int refFace = todoFaces[todoFaces.
size() - 1];
244 btFace& faceA = tmpFaces[refFace];
248 for (
int j = todoFaces.
size() - 1; j >= 0; j--)
250 int i = todoFaces[j];
251 btFace& faceB = tmpFaces[i];
253 if (faceNormalA.
dot(faceNormalB) > faceWeldThreshold)
260 bool did_merge =
false;
261 if (coplanarFaceGroup.
size() > 1)
268 for (
int i = 0; i < coplanarFaceGroup.
size(); i++)
272 btFace& face = tmpFaces[coplanarFaceGroup[i]];
274 averageFaceNormal += faceNormal;
282 for (
int i = 0; i < orgpoints.
size(); i++)
285 if (orgpoints[i].m_orgIndex == orgIndex)
297 for (
int i = 0; i < 4; i++)
298 combinedFace.
m_plane[i] = tmpFaces[coplanarFaceGroup[0]].m_plane[i];
305 for (
int i = 0; i < hull.size(); i++)
308 for (
int k = 0; k < orgpoints.
size(); k++)
310 if (orgpoints[k].m_orgIndex == hull[i].m_orgIndex)
312 orgpoints[k].m_orgIndex = -1;
319 bool reject_merge =
false;
321 for (
int i = 0; i < orgpoints.
size(); i++)
323 if (orgpoints[i].m_orgIndex == -1)
326 for (
int j = 0; j < tmpFaces.
size(); j++)
328 btFace& face = tmpFaces[j];
330 bool is_in_current_group =
false;
331 for (
int k = 0; k < coplanarFaceGroup.
size(); k++)
333 if (coplanarFaceGroup[k] == j)
335 is_in_current_group =
true;
339 if (is_in_current_group)
344 if (face.
m_indices[v] == orgpoints[i].m_orgIndex)
367 for (
int i = 0; i < coplanarFaceGroup.
size(); i++)
369 btFace face = tmpFaces[coplanarFaceGroup[i]];
383#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
412 for (i = 0; i < inner_count; i++)
414 i = (int)vec.
maxDot(temp, inner_count, newDot);
434 for (i = 0; i < numVectors; i++)
439 for (
int j = 0; j < numVectors; j++)
447 for (i = 0; i < inner_count; i++)
449 i = (int)vec.
maxDot(temp, inner_count, newDot);
450 if (newDot > supportVerticesOut[j][3])
452 supportVerticesOut[j] = temp[i];
453 supportVerticesOut[j][3] = newDot;
471 getAabb(ident, aabbMin, aabbMax);
482 inertia = scaledmass * (
btVector3(y2 + z2, x2 + z2, x2 + y2));
494 m_localAabbMin(1, 1, 1),
495 m_localAabbMax(-1, -1, -1),
496 m_isLocalAabbValid(false)
530 for (
int i = 0; i < 3; ++i)
538 for (
int i = 0; i < 3; i++)
#define btAlignedFree(ptr)
#define btAlignedAlloc(size, alignment)
void GrahamScanConvexHull2D(btAlignedObjectArray< GrahamVector3 > &originalPoints, btAlignedObjectArray< GrahamVector3 > &hull, const btVector3 &normalAxis)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btSqrt(btScalar y)
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
void remove(const T &key)
T & expand(const T &fillValue=T())
void push_back(const T &_Val)
const Edge * getNextEdgeOfFace() const
int getSourceVertex() const
int getTargetVertex() const
Convex hull implementation based on Preparata and Hong See http://code.google.com/p/bullet/issues/det...
btScalar compute(const void *coords, bool doubleCoords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
btAlignedObjectArray< btVector3 > vertices
btAlignedObjectArray< int > faces
btAlignedObjectArray< Edge > edges
The btConvexInternalShape is an internal base class, shared by most convex shape implementations.
btScalar m_collisionMargin
virtual btVector3 localGetSupportingVertex(const btVector3 &vec) 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...
virtual void setLocalScaling(const btVector3 &scaling)
virtual btScalar getMargin() const
btAlignedObjectArray< btVector3 > m_vertices
virtual ~btConvexPolyhedron()
btAlignedObjectArray< btFace > m_faces
static void getVerticesFromPlaneEquations(const btAlignedObjectArray< btVector3 > &planeEquations, btAlignedObjectArray< btVector3 > &verticesOut)
static void getPlaneEquationsFromVertices(btAlignedObjectArray< btVector3 > &vertices, btAlignedObjectArray< btVector3 > &planeEquationsOut)
btPolyhedralConvexAabbCachingShape()
virtual void setLocalScaling(const btVector3 &scaling)
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...
void getNonvirtualAabb(const btTransform &trans, btVector3 &aabbMin, btVector3 &aabbMax, btScalar margin) const
The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
btPolyhedralConvexShape()
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3 &vec) const
virtual ~btPolyhedralConvexShape()
virtual bool initializePolyhedralFeatures(int shiftVerticesByMargin=0)
optional method mainly used to generate multiple contact points by clipping polyhedral features (face...
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
virtual void getVertex(int i, btVector3 &vtx) const =0
virtual void setPolyhedralFeatures(btConvexPolyhedron &polyhedron)
btConvexPolyhedron * m_polyhedron
virtual int getNumVertices() const =0
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
btVector3 can be used to represent 3D points and vectors.
const btScalar & getZ() const
Return the z value.
const btScalar & z() const
Return the z value.
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btScalar dot(const btVector3 &v) const
Return the dot product.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
long maxDot(const btVector3 *array, long array_count, btScalar &dotOut) const
returns index of maximum dot product between this and vectors in array[]
btScalar length2() const
Return the length of the vector squared.
const btScalar & getY() const
Return the y value.
const btScalar & x() const
Return the x value.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
const btScalar & getX() const
Return the x value.
const btScalar & y() const
Return the y value.
btAlignedObjectArray< int > m_indices