summaryrefslogtreecommitdiff
path: root/Runtime/Geometry/BoundingVolumeConversion.h
blob: 059c16308eb261826919b8d00011e94538ff186f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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