diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Geometry/BoundingVolumeConversion.h |
Diffstat (limited to 'Runtime/Geometry/BoundingVolumeConversion.h')
-rw-r--r-- | Runtime/Geometry/BoundingVolumeConversion.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Runtime/Geometry/BoundingVolumeConversion.h b/Runtime/Geometry/BoundingVolumeConversion.h new file mode 100644 index 0000000..059c163 --- /dev/null +++ b/Runtime/Geometry/BoundingVolumeConversion.h @@ -0,0 +1,32 @@ +#ifndef BOUNDINGVOLUMECONVERSION_H +#define BOUNDINGVOLUMECONVERSION_H + +#include "AABB.h" +#include "Sphere.h" + +inline void AABBToSphere (const AABB& a, Sphere& s) +{ + s.GetCenter () = a.GetCenter (); + s.GetRadius () = Magnitude (a.GetExtent ()); +} + +inline void MinMaxAABBToSphere (const MinMaxAABB& a, Sphere& s) +{ + AABB aabb = a; + AABBToSphere (aabb, s); +} + +inline void SphereToAABB (const Sphere& s, AABB& a) +{ + a.GetCenter () = s.GetCenter (); + a.GetExtent () = Vector3f (s.GetRadius (), s.GetRadius (), s.GetRadius ()); +} + +inline void SphereToMinMaxAABB (const Sphere& s, MinMaxAABB& minmax) +{ + AABB aabb; + SphereToAABB (s, aabb); + minmax = aabb; +} + +#endif |