diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-11-22 16:35:59 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-11-22 16:35:59 +0100 |
| commit | 000aad0a3c36083128765c534e30fd3a35736dce (patch) | |
| tree | bb40ac3f891338371af658419b476d6bc6bda9e7 /src | |
| parent | 8a9351516778e8ec1e0645f69d6147f317ad2eb7 (diff) | |
| download | rapier-000aad0a3c36083128765c534e30fd3a35736dce.tar.gz rapier-000aad0a3c36083128765c534e30fd3a35736dce.tar.bz2 rapier-000aad0a3c36083128765c534e30fd3a35736dce.zip | |
Fix NaNs in unused WAABB lanes during the creation of the WAABBTree.
Diffstat (limited to 'src')
| -rw-r--r-- | src/geometry/waabb.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/geometry/waabb.rs b/src/geometry/waabb.rs index 645ac04..1ebf528 100644 --- a/src/geometry/waabb.rs +++ b/src/geometry/waabb.rs @@ -105,7 +105,16 @@ impl WAABB { } pub fn dilate_by_factor(&mut self, factor: SimdFloat) { - let dilation = (self.maxs - self.mins) * factor; + // If some of the AABBs on this WAABB are invalid, + // don't, dilate them. + let is_valid = self.mins.x.simd_le(self.maxs.x); + let factor = factor.select(is_valid, SimdFloat::zero()); + + // NOTE: we multiply each by factor instead of doing + // (maxs - mins) * factor. That's to avoid overflows (and + // therefore NaNs if this WAABB contains some invalid + // AABBs initialised with f32::MAX + let dilation = self.maxs * factor - self.mins * factor; self.mins -= dilation; self.maxs += dilation; } |
