rename to b3 convention, to avoid naming conflicts when using in combination with Bullet 2.x
This commit is contained in:
@@ -21,16 +21,20 @@ subject to the following restrictions:
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdint.h>
|
||||
typedef int32_t btInt32_t;
|
||||
typedef int64_t btInt64_t;
|
||||
typedef uint32_t btUint32_t;
|
||||
typedef uint64_t btUint64_t;
|
||||
#elif defined(_MSC_VER)
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int32 btInt32_t;
|
||||
typedef __int64 btInt64_t;
|
||||
typedef unsigned __int32 btUint32_t;
|
||||
typedef unsigned __int64 btUint64_t;
|
||||
#else
|
||||
typedef int int32_t;
|
||||
typedef long long int int64_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long long int uint64_t;
|
||||
typedef int btInt32_t;
|
||||
typedef long long int btInt64_t;
|
||||
typedef unsigned int btUint32_t;
|
||||
typedef unsigned long long int btUint64_t;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -56,11 +60,11 @@ class b3ConvexHullInternal
|
||||
class Point64
|
||||
{
|
||||
public:
|
||||
int64_t x;
|
||||
int64_t y;
|
||||
int64_t z;
|
||||
btInt64_t x;
|
||||
btInt64_t y;
|
||||
btInt64_t z;
|
||||
|
||||
Point64(int64_t x, int64_t y, int64_t z): x(x), y(y), z(z)
|
||||
Point64(btInt64_t x, btInt64_t y, btInt64_t z): x(x), y(y), z(z)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -69,7 +73,7 @@ class b3ConvexHullInternal
|
||||
return (x == 0) && (y == 0) && (z == 0);
|
||||
}
|
||||
|
||||
int64_t dot(const Point64& b) const
|
||||
btInt64_t dot(const Point64& b) const
|
||||
{
|
||||
return x * b.x + y * b.y + z * b.z;
|
||||
}
|
||||
@@ -78,16 +82,16 @@ class b3ConvexHullInternal
|
||||
class Point32
|
||||
{
|
||||
public:
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
btInt32_t x;
|
||||
btInt32_t y;
|
||||
btInt32_t z;
|
||||
int index;
|
||||
|
||||
Point32()
|
||||
{
|
||||
}
|
||||
|
||||
Point32(int32_t x, int32_t y, int32_t z): x(x), y(y), z(z), index(-1)
|
||||
Point32(btInt32_t x, btInt32_t y, btInt32_t z): x(x), y(y), z(z), index(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -116,12 +120,12 @@ class b3ConvexHullInternal
|
||||
return Point64(y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x);
|
||||
}
|
||||
|
||||
int64_t dot(const Point32& b) const
|
||||
btInt64_t dot(const Point32& b) const
|
||||
{
|
||||
return x * b.x + y * b.y + z * b.z;
|
||||
}
|
||||
|
||||
int64_t dot(const Point64& b) const
|
||||
btInt64_t dot(const Point64& b) const
|
||||
{
|
||||
return x * b.x + y * b.y + z * b.z;
|
||||
}
|
||||
@@ -140,32 +144,32 @@ class b3ConvexHullInternal
|
||||
class Int128
|
||||
{
|
||||
public:
|
||||
uint64_t low;
|
||||
uint64_t high;
|
||||
btUint64_t low;
|
||||
btUint64_t high;
|
||||
|
||||
Int128()
|
||||
{
|
||||
}
|
||||
|
||||
Int128(uint64_t low, uint64_t high): low(low), high(high)
|
||||
Int128(btUint64_t low, btUint64_t high): low(low), high(high)
|
||||
{
|
||||
}
|
||||
|
||||
Int128(uint64_t low): low(low), high(0)
|
||||
Int128(btUint64_t low): low(low), high(0)
|
||||
{
|
||||
}
|
||||
|
||||
Int128(int64_t value): low(value), high((value >= 0) ? 0 : (uint64_t) -1LL)
|
||||
Int128(btInt64_t value): low(value), high((value >= 0) ? 0 : (btUint64_t) -1LL)
|
||||
{
|
||||
}
|
||||
|
||||
static Int128 mul(int64_t a, int64_t b);
|
||||
static Int128 mul(btInt64_t a, btInt64_t b);
|
||||
|
||||
static Int128 mul(uint64_t a, uint64_t b);
|
||||
static Int128 mul(btUint64_t a, btUint64_t b);
|
||||
|
||||
Int128 operator-() const
|
||||
{
|
||||
return Int128((uint64_t) -(int64_t)low, ~high + (low == 0));
|
||||
return Int128((btUint64_t) -(btInt64_t)low, ~high + (low == 0));
|
||||
}
|
||||
|
||||
Int128 operator+(const Int128& b) const
|
||||
@@ -179,7 +183,7 @@ class b3ConvexHullInternal
|
||||
: "cc" );
|
||||
return result;
|
||||
#else
|
||||
uint64_t lo = low + b.low;
|
||||
btUint64_t lo = low + b.low;
|
||||
return Int128(lo, high + b.high + (lo < low));
|
||||
#endif
|
||||
}
|
||||
@@ -208,7 +212,7 @@ class b3ConvexHullInternal
|
||||
: "0"(low), "1"(high), [bl] "g"(b.low), [bh] "g"(b.high)
|
||||
: "cc" );
|
||||
#else
|
||||
uint64_t lo = low + b.low;
|
||||
btUint64_t lo = low + b.low;
|
||||
if (lo < low)
|
||||
{
|
||||
++high;
|
||||
@@ -228,17 +232,17 @@ class b3ConvexHullInternal
|
||||
return *this;
|
||||
}
|
||||
|
||||
Int128 operator*(int64_t b) const;
|
||||
Int128 operator*(btInt64_t b) const;
|
||||
|
||||
b3Scalar toScalar() const
|
||||
{
|
||||
return ((int64_t) high >= 0) ? b3Scalar(high) * (b3Scalar(0x100000000LL) * b3Scalar(0x100000000LL)) + b3Scalar(low)
|
||||
return ((btInt64_t) high >= 0) ? b3Scalar(high) * (b3Scalar(0x100000000LL) * b3Scalar(0x100000000LL)) + b3Scalar(low)
|
||||
: -(-*this).toScalar();
|
||||
}
|
||||
|
||||
int getSign() const
|
||||
{
|
||||
return ((int64_t) high < 0) ? -1 : (high || low) ? 1 : 0;
|
||||
return ((btInt64_t) high < 0) ? -1 : (high || low) ? 1 : 0;
|
||||
}
|
||||
|
||||
bool operator<(const Int128& b) const
|
||||
@@ -272,22 +276,22 @@ class b3ConvexHullInternal
|
||||
class Rational64
|
||||
{
|
||||
private:
|
||||
uint64_t m_numerator;
|
||||
uint64_t m_denominator;
|
||||
btUint64_t m_numerator;
|
||||
btUint64_t m_denominator;
|
||||
int sign;
|
||||
|
||||
public:
|
||||
Rational64(int64_t numerator, int64_t denominator)
|
||||
Rational64(btInt64_t numerator, btInt64_t denominator)
|
||||
{
|
||||
if (numerator > 0)
|
||||
{
|
||||
sign = 1;
|
||||
m_numerator = (uint64_t) numerator;
|
||||
m_numerator = (btUint64_t) numerator;
|
||||
}
|
||||
else if (numerator < 0)
|
||||
{
|
||||
sign = -1;
|
||||
m_numerator = (uint64_t) -numerator;
|
||||
m_numerator = (btUint64_t) -numerator;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -296,12 +300,12 @@ class b3ConvexHullInternal
|
||||
}
|
||||
if (denominator > 0)
|
||||
{
|
||||
m_denominator = (uint64_t) denominator;
|
||||
m_denominator = (btUint64_t) denominator;
|
||||
}
|
||||
else if (denominator < 0)
|
||||
{
|
||||
sign = -sign;
|
||||
m_denominator = (uint64_t) -denominator;
|
||||
m_denominator = (btUint64_t) -denominator;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -323,7 +327,7 @@ class b3ConvexHullInternal
|
||||
|
||||
b3Scalar toScalar() const
|
||||
{
|
||||
return sign * ((m_denominator == 0) ? SIMD_INFINITY : (b3Scalar) m_numerator / m_denominator);
|
||||
return sign * ((m_denominator == 0) ? B3_INFINITY : (b3Scalar) m_numerator / m_denominator);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -337,7 +341,7 @@ class b3ConvexHullInternal
|
||||
bool isInt64;
|
||||
|
||||
public:
|
||||
Rational128(int64_t value)
|
||||
Rational128(btInt64_t value)
|
||||
{
|
||||
if (value > 0)
|
||||
{
|
||||
@@ -352,9 +356,9 @@ class b3ConvexHullInternal
|
||||
else
|
||||
{
|
||||
sign = 0;
|
||||
this->numerator = (uint64_t) 0;
|
||||
this->numerator = (btUint64_t) 0;
|
||||
}
|
||||
this->denominator = (uint64_t) 1;
|
||||
this->denominator = (btUint64_t) 1;
|
||||
isInt64 = true;
|
||||
}
|
||||
|
||||
@@ -384,11 +388,11 @@ class b3ConvexHullInternal
|
||||
|
||||
int compare(const Rational128& b) const;
|
||||
|
||||
int compare(int64_t b) const;
|
||||
int compare(btInt64_t b) const;
|
||||
|
||||
b3Scalar toScalar() const
|
||||
{
|
||||
return sign * ((denominator.getSign() == 0) ? SIMD_INFINITY : numerator.toScalar() / denominator.toScalar());
|
||||
return sign * ((denominator.getSign() == 0) ? B3_INFINITY : numerator.toScalar() / denominator.toScalar());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -579,37 +583,37 @@ class b3ConvexHullInternal
|
||||
template<typename UWord, typename UHWord> class DMul
|
||||
{
|
||||
private:
|
||||
static uint32_t high(uint64_t value)
|
||||
static btUint32_t high(btUint64_t value)
|
||||
{
|
||||
return (uint32_t) (value >> 32);
|
||||
return (btUint32_t) (value >> 32);
|
||||
}
|
||||
|
||||
static uint32_t low(uint64_t value)
|
||||
static btUint32_t low(btUint64_t value)
|
||||
{
|
||||
return (uint32_t) value;
|
||||
return (btUint32_t) value;
|
||||
}
|
||||
|
||||
static uint64_t mul(uint32_t a, uint32_t b)
|
||||
static btUint64_t mul(btUint32_t a, btUint32_t b)
|
||||
{
|
||||
return (uint64_t) a * (uint64_t) b;
|
||||
return (btUint64_t) a * (btUint64_t) b;
|
||||
}
|
||||
|
||||
static void shlHalf(uint64_t& value)
|
||||
static void shlHalf(btUint64_t& value)
|
||||
{
|
||||
value <<= 32;
|
||||
}
|
||||
|
||||
static uint64_t high(Int128 value)
|
||||
static btUint64_t high(Int128 value)
|
||||
{
|
||||
return value.high;
|
||||
}
|
||||
|
||||
static uint64_t low(Int128 value)
|
||||
static btUint64_t low(Int128 value)
|
||||
{
|
||||
return value.low;
|
||||
}
|
||||
|
||||
static Int128 mul(uint64_t a, uint64_t b)
|
||||
static Int128 mul(btUint64_t a, btUint64_t b)
|
||||
{
|
||||
return Int128::mul(a, b);
|
||||
}
|
||||
@@ -835,21 +839,21 @@ class b3ConvexHullInternal
|
||||
};
|
||||
|
||||
|
||||
b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::operator*(int64_t b) const
|
||||
b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::operator*(btInt64_t b) const
|
||||
{
|
||||
bool negative = (int64_t) high < 0;
|
||||
bool negative = (btInt64_t) high < 0;
|
||||
Int128 a = negative ? -*this : *this;
|
||||
if (b < 0)
|
||||
{
|
||||
negative = !negative;
|
||||
b = -b;
|
||||
}
|
||||
Int128 result = mul(a.low, (uint64_t) b);
|
||||
result.high += a.high * (uint64_t) b;
|
||||
Int128 result = mul(a.low, (btUint64_t) b);
|
||||
result.high += a.high * (btUint64_t) b;
|
||||
return negative ? -result : result;
|
||||
}
|
||||
|
||||
b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(int64_t a, int64_t b)
|
||||
b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(btInt64_t a, btInt64_t b)
|
||||
{
|
||||
Int128 result;
|
||||
|
||||
@@ -871,12 +875,12 @@ b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(int64_t a, int64_
|
||||
negative = !negative;
|
||||
b = -b;
|
||||
}
|
||||
DMul<uint64_t, uint32_t>::mul((uint64_t) a, (uint64_t) b, result.low, result.high);
|
||||
DMul<btUint64_t, btUint32_t>::mul((btUint64_t) a, (btUint64_t) b, result.low, result.high);
|
||||
return negative ? -result : result;
|
||||
#endif
|
||||
}
|
||||
|
||||
b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(uint64_t a, uint64_t b)
|
||||
b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(btUint64_t a, btUint64_t b)
|
||||
{
|
||||
Int128 result;
|
||||
|
||||
@@ -887,7 +891,7 @@ b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(uint64_t a, uint6
|
||||
: "cc" );
|
||||
|
||||
#else
|
||||
DMul<uint64_t, uint32_t>::mul(a, b, result.low, result.high);
|
||||
DMul<btUint64_t, btUint32_t>::mul(a, b, result.low, result.high);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
@@ -909,8 +913,8 @@ int b3ConvexHullInternal::Rational64::compare(const Rational64& b) const
|
||||
#ifdef USE_X86_64_ASM
|
||||
|
||||
int result;
|
||||
int64_t tmp;
|
||||
int64_t dummy;
|
||||
btInt64_t tmp;
|
||||
btInt64_t dummy;
|
||||
__asm__ ("mulq %[bn]\n\t"
|
||||
"movq %%rax, %[tmp]\n\t"
|
||||
"movq %%rdx, %%rbx\n\t"
|
||||
@@ -949,12 +953,12 @@ int b3ConvexHullInternal::Rational128::compare(const Rational128& b) const
|
||||
}
|
||||
if (isInt64)
|
||||
{
|
||||
return -b.compare(sign * (int64_t) numerator.low);
|
||||
return -b.compare(sign * (btInt64_t) numerator.low);
|
||||
}
|
||||
|
||||
Int128 nbdLow, nbdHigh, dbnLow, dbnHigh;
|
||||
DMul<Int128, uint64_t>::mul(numerator, b.denominator, nbdLow, nbdHigh);
|
||||
DMul<Int128, uint64_t>::mul(denominator, b.numerator, dbnLow, dbnHigh);
|
||||
DMul<Int128, btUint64_t>::mul(numerator, b.denominator, nbdLow, nbdHigh);
|
||||
DMul<Int128, btUint64_t>::mul(denominator, b.numerator, dbnLow, dbnHigh);
|
||||
|
||||
int cmp = nbdHigh.ucmp(dbnHigh);
|
||||
if (cmp)
|
||||
@@ -964,11 +968,11 @@ int b3ConvexHullInternal::Rational128::compare(const Rational128& b) const
|
||||
return nbdLow.ucmp(dbnLow) * sign;
|
||||
}
|
||||
|
||||
int b3ConvexHullInternal::Rational128::compare(int64_t b) const
|
||||
int b3ConvexHullInternal::Rational128::compare(btInt64_t b) const
|
||||
{
|
||||
if (isInt64)
|
||||
{
|
||||
int64_t a = sign * (int64_t) numerator.low;
|
||||
btInt64_t a = sign * (btInt64_t) numerator.low;
|
||||
return (a > b) ? 1 : (a < b) ? -1 : 0;
|
||||
}
|
||||
if (b > 0)
|
||||
@@ -1067,22 +1071,22 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
||||
v1 = h1.maxXy;
|
||||
Vertex* v00 = NULL;
|
||||
Vertex* v10 = NULL;
|
||||
int32_t sign = 1;
|
||||
btInt32_t sign = 1;
|
||||
|
||||
for (int side = 0; side <= 1; side++)
|
||||
{
|
||||
int32_t dx = (v1->point.x - v0->point.x) * sign;
|
||||
btInt32_t dx = (v1->point.x - v0->point.x) * sign;
|
||||
if (dx > 0)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int32_t dy = v1->point.y - v0->point.y;
|
||||
btInt32_t dy = v1->point.y - v0->point.y;
|
||||
|
||||
Vertex* w0 = side ? v0->next : v0->prev;
|
||||
if (w0 != v0)
|
||||
{
|
||||
int32_t dx0 = (w0->point.x - v0->point.x) * sign;
|
||||
int32_t dy0 = w0->point.y - v0->point.y;
|
||||
btInt32_t dx0 = (w0->point.x - v0->point.x) * sign;
|
||||
btInt32_t dy0 = w0->point.y - v0->point.y;
|
||||
if ((dy0 <= 0) && ((dx0 == 0) || ((dx0 < 0) && (dy0 * dx <= dy * dx0))))
|
||||
{
|
||||
v0 = w0;
|
||||
@@ -1094,9 +1098,9 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
||||
Vertex* w1 = side ? v1->next : v1->prev;
|
||||
if (w1 != v1)
|
||||
{
|
||||
int32_t dx1 = (w1->point.x - v1->point.x) * sign;
|
||||
int32_t dy1 = w1->point.y - v1->point.y;
|
||||
int32_t dxn = (w1->point.x - v0->point.x) * sign;
|
||||
btInt32_t dx1 = (w1->point.x - v1->point.x) * sign;
|
||||
btInt32_t dy1 = w1->point.y - v1->point.y;
|
||||
btInt32_t dxn = (w1->point.x - v0->point.x) * sign;
|
||||
if ((dxn > 0) && (dy1 < 0) && ((dx1 == 0) || ((dx1 < 0) && (dy1 * dx < dy * dx1))))
|
||||
{
|
||||
v1 = w1;
|
||||
@@ -1112,13 +1116,13 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int32_t dy = v1->point.y - v0->point.y;
|
||||
btInt32_t dy = v1->point.y - v0->point.y;
|
||||
|
||||
Vertex* w1 = side ? v1->prev : v1->next;
|
||||
if (w1 != v1)
|
||||
{
|
||||
int32_t dx1 = (w1->point.x - v1->point.x) * sign;
|
||||
int32_t dy1 = w1->point.y - v1->point.y;
|
||||
btInt32_t dx1 = (w1->point.x - v1->point.x) * sign;
|
||||
btInt32_t dy1 = w1->point.y - v1->point.y;
|
||||
if ((dy1 >= 0) && ((dx1 == 0) || ((dx1 < 0) && (dy1 * dx <= dy * dx1))))
|
||||
{
|
||||
v1 = w1;
|
||||
@@ -1130,9 +1134,9 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
||||
Vertex* w0 = side ? v0->prev : v0->next;
|
||||
if (w0 != v0)
|
||||
{
|
||||
int32_t dx0 = (w0->point.x - v0->point.x) * sign;
|
||||
int32_t dy0 = w0->point.y - v0->point.y;
|
||||
int32_t dxn = (v1->point.x - w0->point.x) * sign;
|
||||
btInt32_t dx0 = (w0->point.x - v0->point.x) * sign;
|
||||
btInt32_t dy0 = w0->point.y - v0->point.y;
|
||||
btInt32_t dxn = (v1->point.x - w0->point.x) * sign;
|
||||
if ((dxn < 0) && (dy0 > 0) && ((dx0 == 0) || ((dx0 < 0) && (dy0 * dx < dy * dx0))))
|
||||
{
|
||||
v0 = w0;
|
||||
@@ -1146,8 +1150,8 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t x = v0->point.x;
|
||||
int32_t y0 = v0->point.y;
|
||||
btInt32_t x = v0->point.x;
|
||||
btInt32_t y0 = v0->point.y;
|
||||
Vertex* w0 = v0;
|
||||
Vertex* t;
|
||||
while (((t = side ? w0->next : w0->prev) != v0) && (t->point.x == x) && (t->point.y <= y0))
|
||||
@@ -1157,7 +1161,7 @@ bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul
|
||||
}
|
||||
v0 = w0;
|
||||
|
||||
int32_t y1 = v1->point.y;
|
||||
btInt32_t y1 = v1->point.y;
|
||||
Vertex* w1 = v1;
|
||||
while (((t = side ? w1->prev : w1->next) != v1) && (t->point.x == x) && (t->point.y >= y1))
|
||||
{
|
||||
@@ -1218,8 +1222,8 @@ void b3ConvexHullInternal::computeInternal(int start, int end, IntermediateHull&
|
||||
Vertex* w = v + 1;
|
||||
if (v->point != w->point)
|
||||
{
|
||||
int32_t dx = v->point.x - w->point.x;
|
||||
int32_t dy = v->point.y - w->point.y;
|
||||
btInt32_t dx = v->point.x - w->point.x;
|
||||
btInt32_t dy = v->point.y - w->point.y;
|
||||
|
||||
if ((dx == 0) && (dy == 0))
|
||||
{
|
||||
@@ -1392,7 +1396,7 @@ b3ConvexHullInternal::Orientation b3ConvexHullInternal::getOrientation(const Edg
|
||||
Point64 n = t.cross(s);
|
||||
Point64 m = (*prev->target - *next->reverse->target).cross(*next->target - *next->reverse->target);
|
||||
b3Assert(!m.isZero());
|
||||
int64_t dot = n.dot(m);
|
||||
btInt64_t dot = n.dot(m);
|
||||
b3Assert(dot != 0);
|
||||
return (dot > 0) ? COUNTER_CLOCKWISE : CLOCKWISE;
|
||||
}
|
||||
@@ -1468,7 +1472,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
||||
Point32 et1 = start1 ? start1->target->point : c1->point;
|
||||
Point32 s = c1->point - c0->point;
|
||||
Point64 normal = ((start0 ? start0 : start1)->target->point - c0->point).cross(s);
|
||||
int64_t dist = c0->point.dot(normal);
|
||||
btInt64_t dist = c0->point.dot(normal);
|
||||
b3Assert(!start1 || (start1->target->point.dot(normal) == dist));
|
||||
Point64 perp = s.cross(normal);
|
||||
b3Assert(!perp.isZero());
|
||||
@@ -1477,7 +1481,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
||||
printf(" Advancing %d %d (%p %p, %d %d)\n", c0->point.index, c1->point.index, start0, start1, start0 ? start0->target->point.index : -1, start1 ? start1->target->point.index : -1);
|
||||
#endif
|
||||
|
||||
int64_t maxDot0 = et0.dot(perp);
|
||||
btInt64_t maxDot0 = et0.dot(perp);
|
||||
if (e0)
|
||||
{
|
||||
while (e0->target != stop0)
|
||||
@@ -1492,7 +1496,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
||||
{
|
||||
break;
|
||||
}
|
||||
int64_t dot = e->target->point.dot(perp);
|
||||
btInt64_t dot = e->target->point.dot(perp);
|
||||
if (dot <= maxDot0)
|
||||
{
|
||||
break;
|
||||
@@ -1503,7 +1507,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
||||
}
|
||||
}
|
||||
|
||||
int64_t maxDot1 = et1.dot(perp);
|
||||
btInt64_t maxDot1 = et1.dot(perp);
|
||||
if (e1)
|
||||
{
|
||||
while (e1->target != stop1)
|
||||
@@ -1518,7 +1522,7 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
||||
{
|
||||
break;
|
||||
}
|
||||
int64_t dot = e->target->point.dot(perp);
|
||||
btInt64_t dot = e->target->point.dot(perp);
|
||||
if (dot <= maxDot1)
|
||||
{
|
||||
break;
|
||||
@@ -1533,20 +1537,20 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
||||
printf(" Starting at %d %d\n", et0.index, et1.index);
|
||||
#endif
|
||||
|
||||
int64_t dx = maxDot1 - maxDot0;
|
||||
btInt64_t dx = maxDot1 - maxDot0;
|
||||
if (dx > 0)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int64_t dy = (et1 - et0).dot(s);
|
||||
btInt64_t dy = (et1 - et0).dot(s);
|
||||
|
||||
if (e0 && (e0->target != stop0))
|
||||
{
|
||||
Edge* f0 = e0->next->reverse;
|
||||
if (f0->copy > mergeStamp)
|
||||
{
|
||||
int64_t dx0 = (f0->target->point - et0).dot(perp);
|
||||
int64_t dy0 = (f0->target->point - et0).dot(s);
|
||||
btInt64_t dx0 = (f0->target->point - et0).dot(perp);
|
||||
btInt64_t dy0 = (f0->target->point - et0).dot(s);
|
||||
if ((dx0 == 0) ? (dy0 < 0) : ((dx0 < 0) && (Rational64(dy0, dx0).compare(Rational64(dy, dx)) >= 0)))
|
||||
{
|
||||
et0 = f0->target->point;
|
||||
@@ -1565,9 +1569,9 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
||||
Point32 d1 = f1->target->point - et1;
|
||||
if (d1.dot(normal) == 0)
|
||||
{
|
||||
int64_t dx1 = d1.dot(perp);
|
||||
int64_t dy1 = d1.dot(s);
|
||||
int64_t dxn = (f1->target->point - et0).dot(perp);
|
||||
btInt64_t dx1 = d1.dot(perp);
|
||||
btInt64_t dy1 = d1.dot(s);
|
||||
btInt64_t dxn = (f1->target->point - et0).dot(perp);
|
||||
if ((dxn > 0) && ((dx1 == 0) ? (dy1 < 0) : ((dx1 < 0) && (Rational64(dy1, dx1).compare(Rational64(dy, dx)) > 0))))
|
||||
{
|
||||
e1 = f1;
|
||||
@@ -1590,15 +1594,15 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int64_t dy = (et1 - et0).dot(s);
|
||||
btInt64_t dy = (et1 - et0).dot(s);
|
||||
|
||||
if (e1 && (e1->target != stop1))
|
||||
{
|
||||
Edge* f1 = e1->prev->reverse;
|
||||
if (f1->copy > mergeStamp)
|
||||
{
|
||||
int64_t dx1 = (f1->target->point - et1).dot(perp);
|
||||
int64_t dy1 = (f1->target->point - et1).dot(s);
|
||||
btInt64_t dx1 = (f1->target->point - et1).dot(perp);
|
||||
btInt64_t dy1 = (f1->target->point - et1).dot(s);
|
||||
if ((dx1 == 0) ? (dy1 > 0) : ((dx1 < 0) && (Rational64(dy1, dx1).compare(Rational64(dy, dx)) <= 0)))
|
||||
{
|
||||
et1 = f1->target->point;
|
||||
@@ -1617,9 +1621,9 @@ void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge
|
||||
Point32 d0 = f0->target->point - et0;
|
||||
if (d0.dot(normal) == 0)
|
||||
{
|
||||
int64_t dx0 = d0.dot(perp);
|
||||
int64_t dy0 = d0.dot(s);
|
||||
int64_t dxn = (et1 - f0->target->point).dot(perp);
|
||||
btInt64_t dx0 = d0.dot(perp);
|
||||
btInt64_t dy0 = d0.dot(s);
|
||||
btInt64_t dxn = (et1 - f0->target->point).dot(perp);
|
||||
if ((dxn < 0) && ((dx0 == 0) ? (dy0 > 0) : ((dx0 < 0) && (Rational64(dy0, dx0).compare(Rational64(dy, dx)) < 0))))
|
||||
{
|
||||
e0 = f0;
|
||||
@@ -1683,7 +1687,7 @@ void b3ConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1)
|
||||
{
|
||||
do
|
||||
{
|
||||
int64_t dot = (*e->target - *c0).dot(normal);
|
||||
btInt64_t dot = (*e->target - *c0).dot(normal);
|
||||
b3Assert(dot <= 0);
|
||||
if ((dot == 0) && ((*e->target - *c0).dot(t) > 0))
|
||||
{
|
||||
@@ -1702,7 +1706,7 @@ void b3ConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1)
|
||||
{
|
||||
do
|
||||
{
|
||||
int64_t dot = (*e->target - *c1).dot(normal);
|
||||
btInt64_t dot = (*e->target - *c1).dot(normal);
|
||||
b3Assert(dot <= 0);
|
||||
if ((dot == 0) && ((*e->target - *c1).dot(t) > 0))
|
||||
{
|
||||
@@ -1932,7 +1936,7 @@ void b3ConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1)
|
||||
}
|
||||
|
||||
|
||||
static bool pointCmp(const b3ConvexHullInternal::Point32& p, const b3ConvexHullInternal::Point32& q)
|
||||
static bool b3PointCmp(const b3ConvexHullInternal::Point32& p, const b3ConvexHullInternal::Point32& q)
|
||||
{
|
||||
return (p.y < q.y) || ((p.y == q.y) && ((p.x < q.x) || ((p.x == q.x) && (p.z < q.z))));
|
||||
}
|
||||
@@ -2006,9 +2010,9 @@ void b3ConvexHullInternal::compute(const void* coords, bool doubleCoords, int st
|
||||
b3Vector3 p((b3Scalar) v[0], (b3Scalar) v[1], (b3Scalar) v[2]);
|
||||
ptr += stride;
|
||||
p = (p - center) * s;
|
||||
points[i].x = (int32_t) p[medAxis];
|
||||
points[i].y = (int32_t) p[maxAxis];
|
||||
points[i].z = (int32_t) p[minAxis];
|
||||
points[i].x = (btInt32_t) p[medAxis];
|
||||
points[i].y = (btInt32_t) p[maxAxis];
|
||||
points[i].z = (btInt32_t) p[minAxis];
|
||||
points[i].index = i;
|
||||
}
|
||||
}
|
||||
@@ -2020,13 +2024,13 @@ void b3ConvexHullInternal::compute(const void* coords, bool doubleCoords, int st
|
||||
b3Vector3 p(v[0], v[1], v[2]);
|
||||
ptr += stride;
|
||||
p = (p - center) * s;
|
||||
points[i].x = (int32_t) p[medAxis];
|
||||
points[i].y = (int32_t) p[maxAxis];
|
||||
points[i].z = (int32_t) p[minAxis];
|
||||
points[i].x = (btInt32_t) p[medAxis];
|
||||
points[i].y = (btInt32_t) p[maxAxis];
|
||||
points[i].z = (btInt32_t) p[minAxis];
|
||||
points[i].index = i;
|
||||
}
|
||||
}
|
||||
points.quickSort(pointCmp);
|
||||
points.quickSort(b3PointCmp);
|
||||
|
||||
vertexPool.reset();
|
||||
vertexPool.setArraySize(count);
|
||||
@@ -2126,7 +2130,7 @@ b3Scalar b3ConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount)
|
||||
{
|
||||
if (a && b)
|
||||
{
|
||||
int64_t vol = (v->point - ref).dot((a->point - ref).cross(b->point - ref));
|
||||
btInt64_t vol = (v->point - ref).dot((a->point - ref).cross(b->point - ref));
|
||||
b3Assert(vol >= 0);
|
||||
Point32 c = v->point + a->point + b->point + ref;
|
||||
hullCenterX += vol * c.x;
|
||||
@@ -2166,7 +2170,7 @@ b3Scalar b3ConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount)
|
||||
|
||||
if (clampAmount > 0)
|
||||
{
|
||||
b3Scalar minDist = SIMD_INFINITY;
|
||||
b3Scalar minDist = B3_INFINITY;
|
||||
for (int i = 0; i < faceCount; i++)
|
||||
{
|
||||
b3Vector3 normal = getBtNormal(faces[i]);
|
||||
@@ -2217,7 +2221,7 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec
|
||||
{
|
||||
origShift[2] /= scaling[2];
|
||||
}
|
||||
Point32 shift((int32_t) origShift[medAxis], (int32_t) origShift[maxAxis], (int32_t) origShift[minAxis]);
|
||||
Point32 shift((btInt32_t) origShift[medAxis], (btInt32_t) origShift[maxAxis], (btInt32_t) origShift[minAxis]);
|
||||
if (shift.isZero())
|
||||
{
|
||||
return true;
|
||||
@@ -2227,9 +2231,9 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec
|
||||
printf("\nShrinking face (%d %d %d) (%d %d %d) (%d %d %d) by (%d %d %d)\n",
|
||||
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);
|
||||
#endif
|
||||
int64_t origDot = face->origin.dot(normal);
|
||||
btInt64_t origDot = face->origin.dot(normal);
|
||||
Point32 shiftedOrigin = face->origin + shift;
|
||||
int64_t shiftedDot = shiftedOrigin.dot(normal);
|
||||
btInt64_t shiftedDot = shiftedOrigin.dot(normal);
|
||||
b3Assert(shiftedDot <= origDot);
|
||||
if (shiftedDot >= origDot)
|
||||
{
|
||||
@@ -2463,12 +2467,12 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec
|
||||
|
||||
Point64 n0 = intersection->face->getNormal();
|
||||
Point64 n1 = intersection->reverse->face->getNormal();
|
||||
int64_t m00 = face->dir0.dot(n0);
|
||||
int64_t m01 = face->dir1.dot(n0);
|
||||
int64_t m10 = face->dir0.dot(n1);
|
||||
int64_t m11 = face->dir1.dot(n1);
|
||||
int64_t r0 = (intersection->face->origin - shiftedOrigin).dot(n0);
|
||||
int64_t r1 = (intersection->reverse->face->origin - shiftedOrigin).dot(n1);
|
||||
btInt64_t m00 = face->dir0.dot(n0);
|
||||
btInt64_t m01 = face->dir1.dot(n0);
|
||||
btInt64_t m10 = face->dir0.dot(n1);
|
||||
btInt64_t m11 = face->dir1.dot(n1);
|
||||
btInt64_t r0 = (intersection->face->origin - shiftedOrigin).dot(n0);
|
||||
btInt64_t r1 = (intersection->reverse->face->origin - shiftedOrigin).dot(n1);
|
||||
Int128 det = Int128::mul(m00, m11) - Int128::mul(m01, m10);
|
||||
b3Assert(det.getSign() != 0);
|
||||
Vertex* v = vertexPool.newObject();
|
||||
@@ -2481,9 +2485,9 @@ bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec
|
||||
Int128::mul(face->dir0.z * r0, m11) - Int128::mul(face->dir0.z * r1, m01)
|
||||
+ Int128::mul(face->dir1.z * r1, m00) - Int128::mul(face->dir1.z * r0, m10) + det * shiftedOrigin.z,
|
||||
det);
|
||||
v->point.x = (int32_t) v->point128.xvalue();
|
||||
v->point.y = (int32_t) v->point128.yvalue();
|
||||
v->point.z = (int32_t) v->point128.zvalue();
|
||||
v->point.x = (btInt32_t) v->point128.xvalue();
|
||||
v->point.y = (btInt32_t) v->point128.yvalue();
|
||||
v->point.z = (btInt32_t) v->point128.zvalue();
|
||||
intersection->target = v;
|
||||
v->edges = e;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user