summaryrefslogtreecommitdiff
path: root/Runtime/Geometry/BoundingVolumeConversion.h
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Geometry/BoundingVolumeConversion.h')
-rw-r--r--Runtime/Geometry/BoundingVolumeConversion.h32
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