// // Created by dtouch on 23-5-14. // #ifndef RENDERSDF_AABB_H #define RENDERSDF_AABB_H #include "Common.h" extern float minFloat; extern float maxFloat; class AABB { public: EVec3f pMin, pMax; public: AABB(); explicit AABB(const EVec3f& p); AABB(const EVec3f& p1, const EVec3f& p2); void unionSelf(const AABB &b2); void unionSelf(const EVec3f &p); static inline AABB getUnion(const AABB &b1, const AABB &b2) { AABB b = b1; b.unionSelf(b2); return b; } static inline AABB getUnion(const AABB &b1, const EVec3f &p) { AABB b = b1; b.unionSelf(p); return b; } static inline bool intersect(const AABB &b1, const AABB &b2) { return (b1.pMin.x() <= b2.pMax.x() && b1.pMax.x() >= b2.pMin.x()) && (b1.pMin.y() <= b2.pMax.y() && b1.pMax.y() >= b2.pMin.y()) && (b1.pMin.z() <= b2.pMax.z() && b1.pMax.z() >= b2.pMin.z()); } private: static inline float greaterFloat(float a, float b) { return a > b ? a : b; } static inline float smallerFloat(float a, float b) { return a < b ? a : b; } }; #endif //RENDERSDF_AABB_H