Fix closest/furthest point functions for CAABox

This commit is contained in:
Jack Andersen 2018-06-03 15:03:54 -10:00
parent baba03bf91
commit 6fbebe0eb7
1 changed files with 6 additions and 6 deletions

View File

@ -265,16 +265,16 @@ public:
inline CVector3f closestPointAlongVector(const CVector3f& other) const inline CVector3f closestPointAlongVector(const CVector3f& other) const
{ {
CVector3f center = this->center(); return {(other.x >= 0.f ? min.x : max.x),
return {(other.x < center.x ? min.x : max.x), (other.y < center.y ? min.y : max.y), (other.y >= 0.f ? min.y : max.y),
(other.z < center.z ? min.z : max.z)}; (other.z >= 0.f ? min.z : max.z)};
} }
inline CVector3f furthestPointAlongVector(const CVector3f& other) const inline CVector3f furthestPointAlongVector(const CVector3f& other) const
{ {
CVector3f center = this->center(); return {(other.x >= 0.f ? max.x : min.x),
return {(other.x < center.x ? max.x : min.x), (other.y < center.y ? max.y : min.y), (other.y >= 0.f ? max.y : min.y),
(other.z < center.z ? max.z : min.z)}; (other.z >= 0.f ? max.z : min.z)};
} }
inline float distanceBetween(const CAABox& other) inline float distanceBetween(const CAABox& other)