34 int3(
int _x,
int _y,
int _z){
x=_x;
y=_y;
z=_z;}
73 potentialVertex += n3n1;
74 potentialVertex += n1n2;
75 potentialVertex *= quotient;
147 #define SPLIT (OVER|UNDER)
148 #define PAPERWIDTH (btScalar(0.001))
159 edges.resize(edges_size);
221 for(
int i=0;i<count;i++)
252 if(allow[m]==3)
return m;
299 if(a[i]!=b[i])
return 0;
309 return (
btDot(n,p-vertices[t[0]]) > epsilon);
317 if(t[i]==a && t[i1]==b)
return 1;
324 return (t[0]==v || t[1]==v || t[2]==v) ;
333 if(
hasedge(a,b[i1],b[i]))
return 1;
357 int &
neib(
int a,
int b);
369 if((*
this)[i]==a && (*this)[i1]==b)
return n[i2];
370 if((*
this)[i]==b && (*this)[i1]==a)
return n[i2];
447 ta->
n =
int3(t0->
n[0],n+1,n+2);
448 m_tris[t0->
n[0]]->neib(t[1],t[2]) = n+0;
450 tb->
n =
int3(t0->
n[1],n+2,n+0);
451 m_tris[t0->
n[1]]->neib(t[2],t[0]) = n+1;
453 tc->
n =
int3(t0->
n[2],n+0,n+1);
454 m_tris[t0->
n[2]]->neib(t[0],t[1]) = n+2;
476 return (t->
rise >epsilon)?t:NULL ;
486 int p0 =
maxdirsterid(verts,verts_count, basis[0],allow);
487 int p1 =
maxdirsterid(verts,verts_count,-basis[0],allow);
488 basis[0] = verts[p0]-verts[p1];
490 return int4(-1,-1,-1,-1);
500 int p2 =
maxdirsterid(verts,verts_count,basis[1],allow);
501 if(p2 == p0 || p2 == p1)
505 if(p2 == p0 || p2 == p1)
506 return int4(-1,-1,-1,-1);
507 basis[1] = verts[p2] - verts[p0];
509 int p3 =
maxdirsterid(verts,verts_count,basis[2],allow);
510 if(p3==p0||p3==p1||p3==p2) p3 =
maxdirsterid(verts,verts_count,-basis[2],allow);
511 if(p3==p0||p3==p1||p3==p2)
512 return int4(-1,-1,-1,-1);
513 btAssert(!(p0==p1||p0==p2||p0==p3||p1==p2||p1==p3||p2==p3));
514 if(
btDot(verts[p3]-verts[p0],
btCross(verts[p1]-verts[p0],verts[p2]-verts[p0])) <0) {
btSwap(p2,p3);}
515 return int4(p0,p1,p2,p3);
520 if(verts_count <4)
return 0;
521 if(vlimit==0) vlimit=1000000000;
525 isextreme.
reserve(verts_count);
529 for(j=0;j<verts_count;j++)
533 bmin.setMin (verts[j]);
541 if(p.
x==-1)
return 0;
545 btVector3 center = (verts[p[0]]+verts[p[1]]+verts[p[2]]+verts[p[3]]) /
btScalar(4.0);
550 isextreme[p[0]]=isextreme[p[1]]=isextreme[p[2]]=isextreme[p[3]]=1;
564 while(vlimit >0 && ((te=
extrudable(epsilon)) != 0))
601 if(t->
vmax>=0)
break;
604 if(isextreme[t->
vmax])
634 tris_count = ts.
size()/3;
637 for (i=0;i<ts.
size();i++)
639 tris_out[i] =
static_cast<unsigned int>(ts[i]);
655 if(!ret)
return false;
656 result.
mIndexCount = (
unsigned int) (tris_count*3);
657 result.
mFaceCount = (
unsigned int) tris_count;
659 result.
mVcount = (
unsigned int) vcount;
699 unsigned int vcount = desc.
mVcount;
700 if ( vcount < 8 ) vcount = 8;
703 vertexSource.
resize(static_cast<int>(vcount));
707 unsigned int ovcount;
717 for (
unsigned int i=0; i<ovcount; i++)
719 btVector3& v = vertexSource[
static_cast<int>(i)];
754 const unsigned int *source = &hr.
m_Indices[0];
755 unsigned int *dest = &result.
m_Indices[0];
784 const unsigned int *source = &hr.
m_Indices[0];
785 unsigned int *dest = &result.
m_Indices[0];
850 return dx*dx+dy*dy+dz*dz;
858 unsigned int &vcount,
863 if ( svcount == 0 )
return false;
868 #define EPSILON btScalar(0.000001)
881 btScalar bmin[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
882 btScalar bmax[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
884 const char *vtx = (
const char *) svertices;
888 for (
unsigned int i=0; i<svcount; i++)
894 for (
int j=0; j<3; j++)
896 if ( p[j] < bmin[j] ) bmin[j] = p[j];
897 if ( p[j] > bmax[j] ) bmax[j] = p[j];
908 center[0] = dx*
btScalar(0.5) + bmin[0];
909 center[1] = dy*
btScalar(0.5) + bmin[1];
910 center[2] = dz*
btScalar(0.5) + bmin[2];
917 if ( dx >
EPSILON && dx < len ) len = dx;
918 if ( dy >
EPSILON && dy < len ) len = dy;
919 if ( dz >
EPSILON && dz < len ) len = dz;
921 if ( len == FLT_MAX )
976 vtx = (
const char *) svertices;
978 for (
unsigned int i=0; i<svcount; i++)
998 for (j=0; j<vcount; j++)
1011 if ( dx < normalepsilon && dy < normalepsilon && dz < normalepsilon )
1020 if ( dist1 > dist2 )
1047 btScalar bmin[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
1048 btScalar bmax[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
1050 for (
unsigned int i=0; i<vcount; i++)
1053 for (
int j=0; j<3; j++)
1055 if ( p[j] < bmin[j] ) bmin[j] = p[j];
1056 if ( p[j] > bmax[j] ) bmax[j] = p[j];
1072 if ( dx >=
EPSILON && dx < len ) len = dx;
1073 if ( dy >=
EPSILON && dy < len ) len = dy;
1074 if ( dz >=
EPSILON && dz < len ) len = dz;
1076 if ( len == FLT_MAX )
1098 addPoint(vcount,vertices,x1,y1,z1);
1099 addPoint(vcount,vertices,x2,y1,z1);
1100 addPoint(vcount,vertices,x2,y2,z1);
1101 addPoint(vcount,vertices,x1,y2,z1);
1102 addPoint(vcount,vertices,x1,y1,z2);
1103 addPoint(vcount,vertices,x2,y1,z2);
1104 addPoint(vcount,vertices,x2,y2,z2);
1105 addPoint(vcount,vertices,x1,y2,z2);
1126 usedIndices.
resize(static_cast<int>(vcount));
1127 memset(&usedIndices[0],0,
sizeof(
unsigned int)*vcount);
1131 for (i=0; i<int (indexcount); i++)
1133 unsigned int v = indices[i];
1137 if ( usedIndices[static_cast<int>(v)] )
1139 indices[i] = usedIndices[
static_cast<int>(v)]-1;
1144 indices[i] = ocount;
1146 overts[ocount][0] = verts[v][0];
1147 overts[ocount][1] = verts[v][1];
1148 overts[ocount][2] = verts[v][2];
1152 if (tmpIndices[k]==
int(v))
1158 btAssert( ocount >=0 && ocount <= vcount );
1160 usedIndices[
static_cast<int>(v)] = ocount;
btScalar planetestepsilon
btScalar length(const btQuaternion &q)
Return the length of a quaternion.
void push_back(const T &_Val)
bool ComputeHull(unsigned int vcount, const btVector3 *vertices, PHullResult &result, unsigned int vlimit)
int maxdirsterid(const T *p, int count, const T &dir, btAlignedObjectArray< int > &allow)
btVector3 PlaneLineIntersection(const btPlane &plane, const btVector3 &p0, const btVector3 &p1)
btVector3 NormalOf(const btVector3 *vert, const int n)
int operator==(const btPlane &a, const btPlane &b)
int SplitTest(ConvexH &convex, const btPlane &plane)
float dist(const Point3 &pnt0, const Point3 &pnt1)
btScalar GetDist(btScalar px, btScalar py, btScalar pz, const btScalar *p2)
btVector3 ThreePlaneIntersection(const btPlane &p0, const btPlane &p1, const btPlane &p2)
btScalar btSin(btScalar x)
void extrude(class btHullTriangle *t0, int v)
btAlignedObjectArray< HalfEdge > edges
bool HasHullFlag(HullFlag flag) const
int hasvert(const int3 &t, int v)
int above(btVector3 *vertices, const int3 &t, const btVector3 &p, btScalar epsilon)
btAlignedObjectArray< unsigned int > m_Indices
btVector3 PlaneProject(const btPlane &plane, const btVector3 &point)
bool CleanupVertices(unsigned int svcount, const btVector3 *svertices, unsigned int stride, unsigned int &vcount, btVector3 *vertices, btScalar normalepsilon, btVector3 &scale)
void deAllocateTriangle(btHullTriangle *)
int PlaneTest(const btPlane &p, const btVector3 &v)
btScalar dot(const btVector3 &v) const
Return the dot product.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
const btScalar & getZ() const
Return the z value.
const btVector3 * mVertices
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0), to reduce performance overhead of run-time memory (de)allocations.
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
const Point3 scale(const Point3 &pnt, float scaleVal)
int size() const
return the number of elements in the array
btAlignedObjectArray< btVector3 > vertices
HullError CreateConvexHull(const HullDesc &desc, HullResult &result)
btAlignedObjectArray< class btHullTriangle * > m_tris
const int & operator[](int i) const
int hasedge(const int3 &t, int a, int b)
btAlignedObjectArray< int > m_vertexIndexMapping
static float4 fabs(const float4 &a)
btAlignedObjectArray< btPlane > facets
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btVector3 orth(const btVector3 &v)
const btScalar & getY() const
Return the y value.
#define btAlignedFree(ptr)
const btScalar & getX() const
Return the x value.
btScalar length() const
Return the length of the vector.
btAlignedObjectArray< btVector3 > m_OutputVertices
btScalar DistanceBetweenLines(const btVector3 &ustart, const btVector3 &udir, const btVector3 &vstart, const btVector3 &vdir, btVector3 *upoint=NULL, btVector3 *vpoint=NULL)
void b2bfix(btHullTriangle *s, btHullTriangle *t)
btVector3 can be used to represent 3D points and vectors.
btHullTriangle(int a, int b, int c)
void BringOutYourDead(const btVector3 *verts, unsigned int vcount, btVector3 *overts, unsigned int &ocount, unsigned int *indices, unsigned indexcount)
btVector3 normalized() const
Return a normalized version of this vector.
unsigned int mNumOutputVertices
int maxdirfiltered(const T *p, int count, const T &dir, btAlignedObjectArray< int > &allow)
void resize(int newsize, const T &fillData=T())
btHullTriangle * extrudable(btScalar epsilon)
unsigned int mVertexStride
int calchullgen(btVector3 *verts, int verts_count, int vlimit)
static void addPoint(unsigned int &vcount, btVector3 *p, btScalar x, btScalar y, btScalar z)
class btHullTriangle * allocateTriangle(int a, int b, int c)
#define btAlignedAlloc(size, alignment)
btVector3 TriNormal(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2)
int calchull(btVector3 *verts, int verts_count, TUIntArray &tris_out, int &tris_count, int vlimit)
int coplanar(const btPlane &a, const btPlane &b)
int3(int _x, int _y, int _z)
btScalar btDot(const btVector3 &v1, const btVector3 &v2)
Return the dot product between two vectors.
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
int shareedge(const int3 &a, const int3 &b)
void ReleaseHull(PHullResult &result)
HullError ReleaseResult(HullResult &result)
btPlane PlaneFlip(const btPlane &plane)
unsigned int mMaxVertices
void checkit(btHullTriangle *t)
#define SIMD_RADS_PER_DEG
int4 FindSimplex(btVector3 *verts, int verts_count, btAlignedObjectArray< int > &allow)
void removeb2b(btHullTriangle *s, btHullTriangle *t)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btCos(btScalar x)
ConvexH::HalfEdge HalfEdge
btScalar btFabs(btScalar x)