improved the clipping bugfix
parent
49a2862d8f
commit
e88f0bda1e
|
@ -126,20 +126,24 @@ AABB Triangle::getClippedAABB(const Point *positions, const AABB &aabb) const {
|
||||||
for (int j=0; j<3; ++j) {
|
for (int j=0; j<3; ++j) {
|
||||||
/* Now this is really paranoid! */
|
/* Now this is really paranoid! */
|
||||||
double pos_d = vertices1[i][j];
|
double pos_d = vertices1[i][j];
|
||||||
Float pos_f = (Float) pos_d;
|
float pos_f = (float) pos_d;
|
||||||
Float pos_roundedDown, pos_roundedUp;
|
Float pos_roundedDown, pos_roundedUp;
|
||||||
|
|
||||||
#if defined(SINGLE_PRECISION)
|
if (pos_f < pos_d) {
|
||||||
pos_roundedUp = nextafterf(pos_f,
|
/* Float value is too small */
|
||||||
std::numeric_limits<float>::infinity());
|
pos_roundedDown = pos_f;
|
||||||
pos_roundedDown = nextafterf(pos_f,
|
pos_roundedUp = nextafterf(pos_f,
|
||||||
-std::numeric_limits<float>::infinity());
|
std::numeric_limits<float>::infinity());
|
||||||
#else
|
} else if (pos_f > pos_d) {
|
||||||
pos_roundedUp = nextafter(pos_f,
|
/* Float value is too large */
|
||||||
std::numeric_limits<float>::infinity());
|
pos_roundedUp = pos_f;
|
||||||
pos_roundedDown = nextafter(pos_f,
|
pos_roundedDown = nextafterf(pos_f,
|
||||||
-std::numeric_limits<float>::infinity());
|
-std::numeric_limits<float>::infinity());
|
||||||
#endif
|
} else {
|
||||||
|
/* Double value is exactly representable */
|
||||||
|
pos_roundedDown = pos_roundedUp = pos_f;
|
||||||
|
}
|
||||||
|
|
||||||
result.min[j] = std::min(result.min[j], pos_roundedDown);
|
result.min[j] = std::min(result.min[j], pos_roundedDown);
|
||||||
result.max[j] = std::max(result.max[j], pos_roundedUp);
|
result.max[j] = std::max(result.max[j], pos_roundedUp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue