mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
fix for ray-vs-AACubeShape intersection test
This commit is contained in:
parent
a9957ac7df
commit
825be3e1e7
1 changed files with 5 additions and 4 deletions
|
@ -36,11 +36,12 @@ bool AACubeShape::findRayIntersection(RayIntersectionInfo& intersection) const {
|
|||
}
|
||||
|
||||
// check for tuncated/short ray
|
||||
const float maxBA = glm::min(intersection._rayLength, intersection._hitDistance) + halfSide;
|
||||
if (maxBA * maxBA > a * a + b2) {
|
||||
// maxLength = maximum possible distance between rayStart and center of cube
|
||||
const float maxLength = glm::min(intersection._rayLength, intersection._hitDistance) + r;
|
||||
float maxBA2 = maxLength * maxLength;
|
||||
if (a * a + b2 > maxLength * maxLength) {
|
||||
// ray is not long enough to reach cube's bounding sphere
|
||||
// NOTE: we don't fall in here when ray's length if FLT_MAX because maxBA^2 will be NaN
|
||||
// and all NaN comparisons are false
|
||||
// NOTE: we don't fall in here when ray's length if FLT_MAX because maxLength^2 will be inf or nan
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue