Fix for AABox::touches(otherBox)

This commit is contained in:
Andrew Meadows 2014-01-27 17:51:05 -08:00
parent 31a2e467f4
commit 2fa3fc523d

View file

@ -119,10 +119,10 @@ bool AABox::contains(const AABox& otherBox) const {
bool AABox::touches(const AABox& otherBox) const {
glm::vec3 relativeCenter = _corner - otherBox._corner + (glm::vec3(_scale - otherBox._scale) * 0.5f);
float totalScale = _scale + otherBox._scale;
return fabs(relativeCenter.x) <= totalScale &&
fabs(relativeCenter.y) <= totalScale &&
fabs(relativeCenter.z) <= totalScale;
float totalHalfScale = 0.5f * (_scale + otherBox._scale);
return fabs(relativeCenter.x) <= totalHalfScale &&
fabs(relativeCenter.y) <= totalHalfScale &&
fabs(relativeCenter.z) <= totalHalfScale;
}
// determines whether a value is within the expanded extents