feat: fixed polygon test for small polys

This commit is contained in:
2025-11-19 12:07:42 +01:00
parent 7c55eb3be4
commit eec4a0d44b

View File

@@ -6,7 +6,7 @@ struct polygon {
vec3 points[3];
decimal delta[9];
bool skip = false;
bool small = false;
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 + 2] =
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[1] = points[0].x();
@@ -38,17 +40,20 @@ struct polygon {
if (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) {
// if (skip)
// return false;
for (int i = 0; i < 3; i++) {
if (small)
return true;
vec3 d = p;
if ((((d.x().i >> SHIFT_AMOUNT) * delta[i * 3].i +
(d.y().i >> SHIFT_AMOUNT) * delta[i * 3 + 1].i +
delta[i * 3 + 2].i) >>
SHIFT_AMOUNT) > 0)
if ((d.x() * delta[i * 3] + d.y() * delta[i * 3 + 1] +
delta[i * 3 + 2]) > decimal(0))
return false;
}
return true;