24#elif defined(_MSC_VER)
46#if defined(DEBUG_CONVEX_HULL) || defined(SHOW_ITERATIONS)
69 return (
x == 0) && (
y == 0) && (
z == 0);
74 return x * b.
x +
y * b.
y +
z * b.
z;
96 return (
x == b.
x) && (
y == b.
y) && (
z == b.
z);
101 return (
x != b.
x) || (
y != b.
y) || (
z != b.
z);
106 return (
x == 0) && (
y == 0) && (
z == 0);
121 return x * b.
x +
y * b.
y +
z * b.
z;
126 return x * b.
x +
y * b.
y +
z * b.
z;
175 __asm__ (
"addq %[bl], %[rl]\n\t"
176 "adcq %[bh], %[rh]\n\t"
191 __asm__ (
"subq %[bl], %[rl]\n\t"
192 "sbbq %[bh], %[rh]\n\t"
205 __asm__ (
"addq %[bl], %[rl]\n\t"
206 "adcq %[bh], %[rh]\n\t"
287 else if (numerator < 0)
301 else if (denominator < 0)
345 this->numerator = value;
350 this->numerator = -value;
447#ifdef DEBUG_CONVEX_HULL
492 if (
src->lastNearbyFace)
496 for (
Face* f =
src->firstNearbyFace; f; f = f->nextWithSameNearbyVertex)
499 f->nearbyVertex =
this;
533#ifdef DEBUG_CONVEX_HULL
579 template<
typename UWord,
typename UHWord>
class DMul
687 for (
int i = 0; i <
size; i++,
o++)
695 template <
typename T>
class Pool
819 void merge(IntermediateHull&
h0, IntermediateHull&
h1);
844 negative = !negative;
864 bool negative = a < 0;
871 negative = !negative;
900 return sign - b.
sign;
915 "movq %%rax, %[tmp]\n\t"
916 "movq %%rdx, %%rbx\n\t"
917 "movq %[tn], %%rax\n\t"
919 "subq %[tmp], %%rax\n\t"
920 "sbbq %%rbx, %%rdx\n\t"
922 "orq %%rdx, %%rax\n\t"
925 "shll $16, %%ebx\n\t"
927 :
"a"(denominator), [
bn]
"g"(b.numerator), [
tn]
"g"(numerator), [
bd]
"g"(b.denominator)
944 return sign - b.
sign;
972 return (a > b) ? 1 : (a < b) ? -1 : 0;
994 return numerator.ucmp(denominator * b) * sign;
1044 if ((
v1n->point.x <
v1p->point.x) || ((
v1n->point.x ==
v1p->point.x) && (
v1n->point.y <
v1p->point.y)))
1055 if ((
v1n->point.x >
v1p->point.x) || ((
v1n->point.x ==
v1p->point.x) && (
v1n->point.y >
v1p->point.y)))
1153 while (((
t =
side ?
w0->next :
w0->prev) != v0) && (
t->point.x == x) && (
t->point.y <=
y0))
1162 while (((
t =
side ?
w1->prev :
w1->next) != v1) && (
t->point.x == x) && (
t->point.y >=
y1))
1187 if (
h1.minXy->point.x <
h0.minXy->point.x)
1189 h0.minXy =
h1.minXy;
1191 if (
h1.maxXy->point.x >=
h0.maxXy->point.x)
1193 h0.maxXy =
h1.maxXy;
1196 h0.maxYx =
h1.maxYx;
1224 if ((
dx == 0) && (
dy == 0))
1247 if ((
dx < 0) || ((
dx == 0) && (
dy < 0)))
1258 if ((
dy < 0) || ((
dy == 0) && (
dx < 0)))
1321#ifdef DEBUG_CONVEX_HULL
1327#ifdef DEBUG_CONVEX_HULL
1333#ifdef DEBUG_CONVEX_HULL
1337 for (Vertex* v = minXy; v; )
1353 if (v->next->prev != v)
1355 printf(
" Inconsistency");
1366 minXy->copy = (minXy->copy == -1) ? -2 : -1;
1367 minXy->printGraph();
1371void btConvexHullInternal::Vertex::printGraph()
1383 }
while (e != edges);
1386 Vertex* v = e->target;
1387 if (v->copy != copy)
1393 }
while (e != edges);
1401 if (prev->
next == next)
1403 if (prev->
prev == next)
1414 else if (prev->
prev == next)
1428#ifdef DEBUG_CONVEX_HULL
1429 printf(
"find max edge for %d\n",
start->point.index);
1440#ifdef DEBUG_CONVEX_HULL
1466#ifdef DEBUG_CONVEX_HULL
1471 }
while (e !=
start->edges);
1489#ifdef DEBUG_CONVEX_HULL
1545#ifdef DEBUG_CONVEX_HULL
1579 if (
d1.dot(normal) == 0)
1587 et1 =
e1->target->point;
1631 if (
d0.dot(normal) == 0)
1639 et0 =
e0->target->point;
1654#ifdef DEBUG_CONVEX_HULL
1655 printf(
" Advanced edges to %d %d\n",
et0.index,
et1.index);
1709 }
while (e !=
c0->edges);
1728 }
while (e !=
c1->edges);
1764#ifdef DEBUG_CONVEX_HULL
1765 printf(
"\n Checking %d %d\n",
c0->point.index,
c1->point.index);
1785#ifdef DEBUG_CONVEX_HULL
1818#ifdef DEBUG_CONVEX_HULL
1819 printf(
" Found min edges to %d %d\n",
e0 ?
e0->target->point.index : -1,
e1 ?
e1->target->point.index : -1);
1827 if ((
cmp >= 0) &&
e1)
1863 if ((
cmp <= 0) &&
e0)
1953 return (p.
y <
q.y) || ((p.
y ==
q.y) && ((p.
x <
q.x) || ((p.
x ==
q.x) && (p.
z <
q.z))));
1963 for (
int i = 0; i < count; i++)
1965 const double* v = (
const double*)
ptr;
1974 for (
int i = 0; i < count; i++)
1976 const float* v = (
const float*)
ptr;
2020 for (
int i = 0; i < count; i++)
2022 const double* v = (
const double*)
ptr;
2034 for (
int i = 0; i < count; i++)
2036 const float* v = (
const float*)
ptr;
2051 for (
int i = 0; i < count; i++)
2073#ifdef DEBUG_CONVEX_HULL
2119 while (
stack.size() > 0)
2166 }
while (e != v->
edges);
2205 unsigned int seed = 243703;
2243#ifdef DEBUG_CONVEX_HULL
2244 printf(
"\nShrinking face (%d %d %d) (%d %d %d) (%d %d %d) by (%d %d %d)\n",
2245 face->
origin.
x, face->
origin.
y, face->
origin.
z, face->
dir0.
x, face->
dir0.
y, face->
dir0.
z, face->
dir1.
x, face->
dir1.
y, face->
dir1.
z,
shift.x,
shift.y,
shift.z);
2259#ifdef DEBUG_CONVEX_HULL
2260 printf(
"Start edge is ");
2262 printf(
", normal is (%lld %lld %lld), shifted dot is %lld\n", normal.
x, normal.
y, normal.
z,
shiftedDot);
2266#ifdef SHOW_ITERATIONS
2274#ifdef SHOW_ITERATIONS
2279#ifdef DEBUG_CONVEX_HULL
2280 printf(
"Moving downwards, edge is ");
2310#ifdef SHOW_ITERATIONS
2315#ifdef DEBUG_CONVEX_HULL
2316 printf(
"Moving upwards, edge is ");
2341#ifdef SHOW_ITERATIONS
2342 printf(
"Needed %d iterations to find initial intersection\n", n);
2348#ifdef SHOW_ITERATIONS
2353#ifdef SHOW_ITERATIONS
2361#ifdef DEBUG_CONVEX_HULL
2362 printf(
"Checking for outwards edge, current edge is ");
2367#ifdef SHOW_ITERATIONS
2368 printf(
"Needed %d iterations to check for complete containment\n", n);
2376#ifdef SHOW_ITERATIONS
2381#ifdef SHOW_ITERATIONS
2384#ifdef DEBUG_CONVEX_HULL
2385 printf(
"Intersecting edge is ");
2393#ifdef SHOW_ITERATIONS
2398#ifdef SHOW_ITERATIONS
2412#ifdef SHOW_ITERATIONS
2413 printf(
"Needed %d iterations to advance intersection\n", n);
2417#ifdef DEBUG_CONVEX_HULL
2418 printf(
"Advanced intersecting edge to ");
2437#ifdef SHOW_ITERATIONS
2442#ifdef SHOW_ITERATIONS
2448#ifdef DEBUG_CONVEX_HULL
2459#ifdef SHOW_ITERATIONS
2460 printf(
"Needed %d iterations to find other intersection of face\n", n);
2477#ifdef DEBUG_CONVEX_HULL
2548#ifdef DEBUG_CONVEX_HULL
2563#ifdef SHOW_ITERATIONS
2564 printf(
"Needed %d iterations to process all intersections\n",
m);
2581#ifdef DEBUG_CONVEX_HULL
2591#ifdef DEBUG_CONVEX_HULL
2592 printf(
"Removing part\n");
2594#ifdef SHOW_ITERATIONS
2604#ifdef DEBUG_CONVEX_HULL
2611#ifdef SHOW_ITERATIONS
2632#ifdef SHOW_ITERATIONS
2633 printf(
"Needed %d iterations to remove part\n", n);
2645 int index =
vertex->copy;
2648 index = vertices.
size();
2651#ifdef DEBUG_CONVEX_HULL
2652 printf(
"Vertex %d gets index *%d\n",
vertex->point.index, index);
2690 vertices.push_back(
hull.getCoordinates(v));
2701 int s = edges.size();
2702 edges.push_back(
Edge());
2703 edges.push_back(
Edge());
2704 Edge* c = &edges[
s];
2712#ifdef DEBUG_CONVEX_HULL
2732 for (
int i = 0; i <
copied; i++)
2743#ifdef DEBUG_CONVEX_HULL
2744 printf(
"Vertex *%d has edge to *%d\n", i, edges[e->
copy].getTargetVertex());
2746 faces.push_back(e->
copy);
2750#ifdef DEBUG_CONVEX_HULL
2751 printf(
" Face *%d\n", edges[f->
copy].getTargetVertex());
#define btAlignedFree(ptr)
#define btAlignedAlloc(size, alignment)
static int getVertexCopy(btConvexHullInternal::Vertex *vertex, btAlignedObjectArray< btConvexHullInternal::Vertex * > &vertices)
unsigned long long int uint64_t
const T & btMax(const T &a, const T &b)
const T & btMin(const T &a, const T &b)
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btAtan(btScalar x)
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
void push_back(const T &_Val)
int getTargetVertex() const
btScalar compute(const void *coords, bool doubleCoords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
static uint64_t high(Int128 value)
static void shlHalf(uint64_t &value)
static void shlHalf(Int128 &value)
static uint64_t low(Int128 value)
static uint32_t low(uint64_t value)
static void mul(UWord a, UWord b, UWord &resLow, UWord &resHigh)
static uint32_t high(uint64_t value)
static uint64_t mul(uint32_t a, uint32_t b)
static Int128 mul(uint64_t a, uint64_t b)
Face * nextWithSameNearbyVertex
void init(Vertex *a, Vertex *b, Vertex *c)
int ucmp(const Int128 &b) const
Int128 operator+(const Int128 &b) const
Int128 operator*(int64_t b) const
Int128(uint64_t low, uint64_t high)
bool operator<(const Int128 &b) const
Int128 operator-(const Int128 &b) const
btScalar toScalar() const
static Int128 mul(int64_t a, int64_t b)
Int128 & operator+=(const Int128 &b)
int64_t dot(const Point64 &b) const
Point32(int32_t x, int32_t y, int32_t z)
Point32 operator-(const Point32 &b) const
int64_t dot(const Point32 &b) const
bool operator!=(const Point32 &b) const
Point64 cross(const Point64 &b) const
Point32 operator+(const Point32 &b) const
Point64 cross(const Point32 &b) const
bool operator==(const Point32 &b) const
Point64(int64_t x, int64_t y, int64_t z)
int64_t dot(const Point64 &b) const
PointR128(Int128 x, Int128 y, Int128 z, Int128 denominator)
void setArraySize(int arraySize)
void freeObject(T *object)
PoolArray< T > * nextArray
btScalar toScalar() const
Rational128(const Int128 &numerator, const Int128 &denominator)
int compare(const Rational128 &b) const
Rational128(int64_t value)
bool isNegativeInfinity() const
btScalar toScalar() const
int compare(const Rational64 &b) const
Rational64(int64_t numerator, int64_t denominator)
Point32 operator-(const Vertex &b) const
Rational128 dot(const Point64 &b) const
void receiveNearbyFaces(Vertex *src)
bool mergeProjection(IntermediateHull &h0, IntermediateHull &h1, Vertex *&c0, Vertex *&c1)
btVector3 toBtVector(const Point32 &v)
void computeInternal(int start, int end, IntermediateHull &result)
void findEdgeForCoplanarFaces(Vertex *c0, Vertex *c1, Edge *&e0, Edge *&e1, Vertex *stop0, Vertex *stop1)
void compute(const void *coords, bool doubleCoords, int stride, int count)
bool shiftFace(Face *face, btScalar amount, btAlignedObjectArray< Vertex * > stack)
btVector3 getCoordinates(const Vertex *v)
btAlignedObjectArray< Vertex * > originalVertices
btScalar shrink(btScalar amount, btScalar clampAmount)
Edge * findMaxAngle(bool ccw, const Vertex *start, const Point32 &s, const Point64 &rxs, const Point64 &sxrxs, Rational64 &minCot)
static Orientation getOrientation(const Edge *prev, const Edge *next, const Point32 &s, const Point32 &t)
Pool< Vertex > vertexPool
Edge * newEdgePair(Vertex *from, Vertex *to)
void merge(IntermediateHull &h0, IntermediateHull &h1)
void removeEdgePair(Edge *edge)
btVector3 getBtNormal(Face *face)
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.
btVector3 normalized() const
Return a normalized version of this vector.
const btScalar & x() const
Return the x value.
int maxAxis() const
Return the axis with the largest value Note return values are 0,1,2 for x, y, or z.
const btScalar & y() const
Return the y value.