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) {
|
||||
/* Now this is really paranoid! */
|
||||
double pos_d = vertices1[i][j];
|
||||
Float pos_f = (Float) pos_d;
|
||||
float pos_f = (float) pos_d;
|
||||
Float pos_roundedDown, pos_roundedUp;
|
||||
|
||||
#if defined(SINGLE_PRECISION)
|
||||
pos_roundedUp = nextafterf(pos_f,
|
||||
std::numeric_limits<float>::infinity());
|
||||
pos_roundedDown = nextafterf(pos_f,
|
||||
-std::numeric_limits<float>::infinity());
|
||||
#else
|
||||
pos_roundedUp = nextafter(pos_f,
|
||||
std::numeric_limits<float>::infinity());
|
||||
pos_roundedDown = nextafter(pos_f,
|
||||
-std::numeric_limits<float>::infinity());
|
||||
#endif
|
||||
if (pos_f < pos_d) {
|
||||
/* Float value is too small */
|
||||
pos_roundedDown = pos_f;
|
||||
pos_roundedUp = nextafterf(pos_f,
|
||||
std::numeric_limits<float>::infinity());
|
||||
} else if (pos_f > pos_d) {
|
||||
/* Float value is too large */
|
||||
pos_roundedUp = pos_f;
|
||||
pos_roundedDown = nextafterf(pos_f,
|
||||
-std::numeric_limits<float>::infinity());
|
||||
} else {
|
||||
/* Double value is exactly representable */
|
||||
pos_roundedDown = pos_roundedUp = pos_f;
|
||||
}
|
||||
|
||||
result.min[j] = std::min(result.min[j], pos_roundedDown);
|
||||
result.max[j] = std::max(result.max[j], pos_roundedUp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue