Fix COBBox::calculateAABox

This commit is contained in:
Jack Andersen 2018-11-18 15:19:14 -10:00
parent a427e0a8a2
commit d881e58f62
2 changed files with 3 additions and 4 deletions

View File

@ -35,7 +35,7 @@ public:
COBBox(const CTransform& xf, const CVector3f& extents) : transform(xf), extents(extents) {} COBBox(const CTransform& xf, const CVector3f& extents) : transform(xf), extents(extents) {}
CAABox calculateAABox(const CTransform& transform = CTransform()) const; CAABox calculateAABox(const CTransform& worldXf = CTransform()) const;
static COBBox FromAABox(const CAABox& box, const CTransform& xf) static COBBox FromAABox(const CAABox& box, const CTransform& xf)
{ {

View File

@ -3,15 +3,14 @@
namespace zeus namespace zeus
{ {
CAABox COBBox::calculateAABox(const CTransform& transform) const CAABox COBBox::calculateAABox(const CTransform& worldXf) const
{ {
CAABox ret = CAABox::skInvertedBox; CAABox ret = CAABox::skInvertedBox;
CTransform trans = transform * transform; CTransform trans = worldXf * transform;
static const CVector3f basis[8] = {{1.f, 1.f, 1.f}, {1.f, 1.f, -1.f}, {1.f, -1.f, 1.f}, {1.f, -1.f, -1.f}, static const CVector3f basis[8] = {{1.f, 1.f, 1.f}, {1.f, 1.f, -1.f}, {1.f, -1.f, 1.f}, {1.f, -1.f, -1.f},
{-1.f, -1.f, -1.f}, {-1.f, -1.f, 1.f}, {-1.f, 1.f, -1.f}, {-1.f, 1.f, 1.f}}; {-1.f, -1.f, -1.f}, {-1.f, -1.f, 1.f}, {-1.f, 1.f, -1.f}, {-1.f, 1.f, 1.f}};
CVector3f p = extents * basis[0]; CVector3f p = extents * basis[0];
ret.accumulateBounds(trans * p); ret.accumulateBounds(trans * p);
p = extents * basis[1]; p = extents * basis[1];
ret.accumulateBounds(trans * p); ret.accumulateBounds(trans * p);