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++)
93 int numFaces = conv.
faces.size();
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;
212 for (
int f=0;f<face.
m_indices.size();f++)
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++)
246 combinedFace.
m_indices.push_back(hull[i].m_orgIndex);
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)
280 for(
int v = 0; v < face.
m_indices.size(); v++) {
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));
439m_localAabbMin(1,1,1),
440m_localAabbMax(-1,-1,-1),
441m_isLocalAabbValid(false)
477 for (
int i = 0; i < 3; ++i )
485 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
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 & 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 & x() const
Return the x value.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
const btScalar & y() const
Return the y value.
btAlignedObjectArray< int > m_indices