subtle gkdtree improvement (Eugene D'Eon reported some issues with primitive clipping in double precision builds)

metadata
Wenzel Jakob 2014-03-27 18:21:09 +01:00
parent 7d7e253b8f
commit cf98273c7c
1 changed files with 19 additions and 4 deletions

View File

@ -2198,6 +2198,21 @@ protected:
*newEventsLeftEnd = newEventsLeftStart, *newEventsLeftEnd = newEventsLeftStart,
*newEventsRightEnd = newEventsRightStart; *newEventsRightEnd = newEventsRightStart;
AABBType leftNodeAABB_enlarged(leftNodeAABB),
rightNodeAABB_enlarged(rightNodeAABB);
#if defined(DOUBLE_PRECISION)
int axis0 = (bestSplit.axis + 1)%3, axis1 = (bestSplit.axis + 2)%3;
leftNodeAABB_enlarged.min[axis0] = rightNodeAABB_enlarged.min[axis0] =
nextafterf((float) nodeAABB.min[axis0], -std::numeric_limits<float>::max());
leftNodeAABB_enlarged.max[axis0] = rightNodeAABB_enlarged.max[axis0] =
nextafterf((float) nodeAABB.max[axis0], std::numeric_limits<float>::max());
leftNodeAABB_enlarged.min[axis1] = rightNodeAABB_enlarged.min[axis1] =
nextafterf((float) nodeAABB.min[axis1], -std::numeric_limits<float>::max());
leftNodeAABB_enlarged.max[axis1] = rightNodeAABB_enlarged.max[axis1] =
nextafterf((float) nodeAABB.max[axis1], std::numeric_limits<float>::max());
#endif
for (EdgeEvent *event = eventStart; event<eventEnd; ++event) { for (EdgeEvent *event = eventStart; event<eventEnd; ++event) {
int classification = storage.get(event->index); int classification = storage.get(event->index);
@ -2212,11 +2227,11 @@ protected:
generate new events for each side */ generate new events for each side */
const IndexType index = event->index; const IndexType index = event->index;
AABBType clippedLeft = cast()->getClippedAABB(index, leftNodeAABB); AABBType clippedLeft = cast()->getClippedAABB(index, leftNodeAABB_enlarged);
AABBType clippedRight = cast()->getClippedAABB(index, rightNodeAABB); AABBType clippedRight = cast()->getClippedAABB(index, rightNodeAABB_enlarged);
KDAssert(leftNodeAABB.contains(clippedLeft)); KDAssert(leftNodeAABB_enlarged.contains(clippedLeft));
KDAssert(rightNodeAABB.contains(clippedRight)); KDAssert(rightNodeAABB_enlarged.contains(clippedRight));
if (clippedLeft.isValid() && clippedLeft.getSurfaceArea() > 0) { if (clippedLeft.isValid() && clippedLeft.getSurfaceArea() > 0) {
for (int axis=0; axis<PointType::dim; ++axis) { for (int axis=0; axis<PointType::dim; ++axis) {