Skip to content

Commit 91d5cac

Browse files
committed
Fix division by zero causing FP exception during unit test run.
FIXES #2091 Signed-off-by: Bram Stolk <[email protected]>
1 parent 5938a49 commit 91d5cac

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

openvdb/openvdb/points/IndexFilter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ class RandomLeafFilter
240240
currentPoints += iter->pointCount();
241241
}
242242

243-
const float factor = targetPoints > currentPoints ? 1.0f : float(targetPoints) / float(currentPoints);
243+
const float denom = currentPoints > 0 ? float(currentPoints) : 1.0f; // Do not divide by zero.
244+
const float factor = targetPoints > currentPoints ? 1.0f : float(targetPoints) / denom;
244245

245246
std::mt19937 generator(seed);
246247
std::uniform_int_distribution<unsigned int> dist(0, std::numeric_limits<unsigned int>::max() - 1);

0 commit comments

Comments
 (0)