feat: fixed polygon test for small polys
This commit is contained in:
15
polygon.hpp
15
polygon.hpp
@@ -6,7 +6,7 @@ struct polygon {
|
|||||||
|
|
||||||
vec3 points[3];
|
vec3 points[3];
|
||||||
decimal delta[9];
|
decimal delta[9];
|
||||||
bool skip = false;
|
bool small = false;
|
||||||
|
|
||||||
decimal bounding[4]; // min x, max x, min y, max y
|
decimal bounding[4]; // min x, max x, min y, max y
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@ struct polygon {
|
|||||||
delta[i * 3 + 1] = points[n].x() - points[i].x();
|
delta[i * 3 + 1] = points[n].x() - points[i].x();
|
||||||
delta[i * 3 + 2] =
|
delta[i * 3 + 2] =
|
||||||
points[i].x() * points[n].y() - points[i].y() * points[n].x();
|
points[i].x() * points[n].y() - points[i].y() * points[n].x();
|
||||||
|
if (delta[i * 3].i == 0 && delta[i * 3 + 1].i == 0)
|
||||||
|
small = true;
|
||||||
}
|
}
|
||||||
bounding[0] = points[0].x();
|
bounding[0] = points[0].x();
|
||||||
bounding[1] = points[0].x();
|
bounding[1] = points[0].x();
|
||||||
@@ -38,17 +40,20 @@ struct polygon {
|
|||||||
if (bounding[3] < points[i].y())
|
if (bounding[3] < points[i].y())
|
||||||
bounding[3] = points[i].y();
|
bounding[3] = points[i].y();
|
||||||
}
|
}
|
||||||
|
/*if ((bounding[1].i - bounding[0].i < 1 << HALF_SHIFT) &&
|
||||||
|
(bounding[3].i - bounding[2].i < 1 << HALF_SHIFT))
|
||||||
|
small = true;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool contains(const vec3 &p) {
|
const bool contains(const vec3 &p) {
|
||||||
// if (skip)
|
// if (skip)
|
||||||
// return false;
|
// return false;
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
if (small)
|
||||||
|
return true;
|
||||||
vec3 d = p;
|
vec3 d = p;
|
||||||
if ((((d.x().i >> SHIFT_AMOUNT) * delta[i * 3].i +
|
if ((d.x() * delta[i * 3] + d.y() * delta[i * 3 + 1] +
|
||||||
(d.y().i >> SHIFT_AMOUNT) * delta[i * 3 + 1].i +
|
delta[i * 3 + 2]) > decimal(0))
|
||||||
delta[i * 3 + 2].i) >>
|
|
||||||
SHIFT_AMOUNT) > 0)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user