text
stringlengths 0
2.2M
|
---|
}
|
else if (e.polyEdge[1] != 0xff)
|
{
|
unsigned short* p0 = &polys[e.poly[0]*MAX_VERTS_PER_POLY*2];
|
p0[MAX_VERTS_PER_POLY + e.polyEdge[0]] = 0x8000 | (unsigned short)e.polyEdge[1];
|
}
|
}
|
return true;
|
}
|
// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).
|
inline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }
|
inline int next(int i, int n) { return i+1 < n ? i+1 : 0; }
|
inline int area2(const unsigned char* a, const unsigned char* b, const unsigned char* c)
|
{
|
return ((int)b[0] - (int)a[0]) * ((int)c[2] - (int)a[2]) - ((int)c[0] - (int)a[0]) * ((int)b[2] - (int)a[2]);
|
}
|
// Exclusive or: true iff exactly one argument is true.
|
// The arguments are negated to ensure that they are 0/1
|
// values. Then the bitwise Xor operator may apply.
|
// (This idea is due to Michael Baldwin.)
|
inline bool xorb(bool x, bool y)
|
{
|
return !x ^ !y;
|
}
|
// Returns true iff c is strictly to the left of the directed
|
// line through a to b.
|
inline bool left(const unsigned char* a, const unsigned char* b, const unsigned char* c)
|
{
|
return area2(a, b, c) < 0;
|
}
|
inline bool leftOn(const unsigned char* a, const unsigned char* b, const unsigned char* c)
|
{
|
return area2(a, b, c) <= 0;
|
}
|
inline bool collinear(const unsigned char* a, const unsigned char* b, const unsigned char* c)
|
{
|
return area2(a, b, c) == 0;
|
}
|
// Returns true iff ab properly intersects cd: they share
|
// a point interior to both segments. The properness of the
|
// intersection is ensured by using strict leftness.
|
static bool intersectProp(const unsigned char* a, const unsigned char* b,
|
const unsigned char* c, const unsigned char* d)
|
{
|
// Eliminate improper cases.
|
if (collinear(a,b,c) || collinear(a,b,d) ||
|
collinear(c,d,a) || collinear(c,d,b))
|
return false;
|
return xorb(left(a,b,c), left(a,b,d)) && xorb(left(c,d,a), left(c,d,b));
|
}
|
// Returns T iff (a,b,c) are collinear and point c lies
|
// on the closed segement ab.
|
static bool between(const unsigned char* a, const unsigned char* b, const unsigned char* c)
|
{
|
if (!collinear(a, b, c))
|
return false;
|
// If ab not vertical, check betweenness on x; else on y.
|
if (a[0] != b[0])
|
return ((a[0] <= c[0]) && (c[0] <= b[0])) || ((a[0] >= c[0]) && (c[0] >= b[0]));
|
else
|
return ((a[2] <= c[2]) && (c[2] <= b[2])) || ((a[2] >= c[2]) && (c[2] >= b[2]));
|
}
|
// Returns true iff segments ab and cd intersect, properly or improperly.
|
static bool intersect(const unsigned char* a, const unsigned char* b,
|
const unsigned char* c, const unsigned char* d)
|
{
|
if (intersectProp(a, b, c, d))
|
return true;
|
else if (between(a, b, c) || between(a, b, d) ||
|
between(c, d, a) || between(c, d, b))
|
return true;
|
else
|
return false;
|
}
|
static bool vequal(const unsigned char* a, const unsigned char* b)
|
{
|
return a[0] == b[0] && a[2] == b[2];
|
}
|
// Returns T iff (v_i, v_j) is a proper internal *or* external
|
// diagonal of P, *ignoring edges incident to v_i and v_j*.
|
static bool diagonalie(int i, int j, int n, const unsigned char* verts, const unsigned short* indices)
|
{
|
const unsigned char* d0 = &verts[(indices[i] & 0x7fff) * 4];
|
const unsigned char* d1 = &verts[(indices[j] & 0x7fff) * 4];
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.