2018-10-06 20:39:40 -07:00
|
|
|
#pragma once
|
2015-08-11 18:41:28 -07:00
|
|
|
|
2016-03-04 15:03:26 -08:00
|
|
|
#include "zeus/CTransform.hpp"
|
|
|
|
#include "zeus/CVector3f.hpp"
|
|
|
|
#include "zeus/CAABox.hpp"
|
2016-06-25 18:11:55 -07:00
|
|
|
#include "zeus/CMRay.hpp"
|
2015-08-11 18:41:28 -07:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
namespace zeus {
|
|
|
|
class COBBox {
|
2015-08-11 18:41:28 -07:00
|
|
|
public:
|
2016-04-26 03:36:44 -07:00
|
|
|
#if ZE_ATHENA_TYPES
|
2018-12-07 17:16:50 -08:00
|
|
|
|
|
|
|
void readBig(athena::io::IStreamReader& in) {
|
|
|
|
transform.read34RowMajor(in);
|
|
|
|
extents.readBig(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
static COBBox ReadBig(athena::io::IStreamReader& in) {
|
|
|
|
COBBox out;
|
|
|
|
out.readBig(in);
|
|
|
|
return out;
|
|
|
|
}
|
2016-04-26 03:36:44 -07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
CTransform transform;
|
|
|
|
CVector3f extents;
|
2015-08-11 18:41:28 -07:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
COBBox() = default;
|
2015-08-11 18:41:28 -07:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
COBBox(const CAABox& aabb) : extents(aabb.extents()) { transform.origin = aabb.center(); }
|
2015-08-11 18:41:28 -07:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
COBBox(const CTransform& xf, const CVector3f& extents) : transform(xf), extents(extents) {}
|
2016-04-26 03:36:44 -07:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
CAABox calculateAABox(const CTransform& worldXf = CTransform()) const;
|
2016-04-26 03:36:44 -07:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
static COBBox FromAABox(const CAABox& box, const CTransform& xf) {
|
|
|
|
const CVector3f extents = box.max - box.center();
|
|
|
|
const CTransform newXf = CTransform::Translate(box.center()) * xf;
|
|
|
|
return COBBox(newXf, extents);
|
|
|
|
}
|
2016-12-22 12:35:29 -08:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
bool OBBIntersectsBox(const COBBox& other) const;
|
2017-01-23 02:10:35 -08:00
|
|
|
|
2018-12-07 21:23:50 -08:00
|
|
|
bool AABoxIntersectsBox(const CAABox& other) { return OBBIntersectsBox(FromAABox(other, CTransform::Identity())); }
|
2015-08-11 18:41:28 -07:00
|
|
|
};
|
2018-12-07 21:23:50 -08:00
|
|
|
} // namespace zeus
|