Kaynağa Gözat

Fix a ton of 'typos', improve somewhat the docs and other small fixes

Daniele Bartolini 12 yıl önce
ebeveyn
işleme
58463d65c2

+ 3 - 3
samples/terrain/terrain.cpp

@@ -181,8 +181,8 @@ public:
 
 
 		if (cam->IsActive())
 		if (cam->IsActive())
 		{
 		{
-			ray.origin = cam->GetPosition();
-			ray.direction = cam->GetLookAt();
+			ray.set_origin(cam->GetPosition());
+			ray.set_direction(cam->GetLookAt());
 		}
 		}
 
 
 		/* Render the terrain */
 		/* Render the terrain */
@@ -212,7 +212,7 @@ public:
 		if (terrain.TraceRay(ray, tri, tri2, dist))
 		if (terrain.TraceRay(ray, tri, tri2, dist))
 		{
 		{
 			renderer->set_depth_test(false);
 			renderer->set_depth_test(false);
-			Vec3 intersectionPoint = ray.origin + (ray.direction * dist);
+			Vec3 intersectionPoint = ray.origin() + (ray.direction() * dist);
 			if (mouseLeftPressed)
 			if (mouseLeftPressed)
 			{
 			{
 				terrain.ApplyBrush(intersectionPoint, 0.09f);
 				terrain.ApplyBrush(intersectionPoint, 0.09f);

+ 4 - 8
src/Terrain.cpp

@@ -233,11 +233,7 @@ bool Terrain::TraceRay(const Ray& ray, Triangle& result, Triangle& /*tri2*/, rea
 
 
 	for (uint32_t i = 0; i < mIndexCount; i += 3)
 	for (uint32_t i = 0; i < mIndexCount; i += 3)
 	{
 	{
-		Triangle tri;
-
-		tri.v1 = mVertices[mIndices[i + 0]];
-		tri.v2 = mVertices[mIndices[i + 1]];
-		tri.v3 = mVertices[mIndices[i + 2]];
+		Triangle tri(mVertices[mIndices[i + 0]], mVertices[mIndices[i + 1]], mVertices[mIndices[i + 2]]);
 
 
 		real ret;
 		real ret;
 		Vec3 int32_tersectionPoint32_t;
 		Vec3 int32_tersectionPoint32_t;
@@ -344,15 +340,15 @@ void Terrain::PlotCircle(int32_t xx, int32_t yy, int32_t radius, int32_t i)
 
 
 			if (i == 0)
 			if (i == 0)
 			{
 			{
-				mBrush[(y + yy) * MAX_BRUSH_SIZE + (x + xx)] = Interpolation::linear(0.0f, 1.0f, rDist);
+				mBrush[(y + yy) * MAX_BRUSH_SIZE + (x + xx)] = interpolation::linear(0.0f, 1.0f, rDist);
 			}
 			}
 			else if (i == 1)
 			else if (i == 1)
 			{
 			{
-				mBrush[(y + yy) * MAX_BRUSH_SIZE + (x + xx)] = Interpolation::cosine(0.0f, 1.0f, rDist);
+				mBrush[(y + yy) * MAX_BRUSH_SIZE + (x + xx)] = interpolation::cosine(0.0f, 1.0f, rDist);
 			}
 			}
 			else if (i == 2)
 			else if (i == 2)
 			{
 			{
-				mBrush[(y + yy) * MAX_BRUSH_SIZE + (x + xx)] = Interpolation::cubic(0.0f, 1.0f, rDist);
+				mBrush[(y + yy) * MAX_BRUSH_SIZE + (x + xx)] = interpolation::cubic(0.0f, 1.0f, rDist);
 			}
 			}
 		}
 		}
 }
 }

+ 170 - 149
src/core/bv/Box.h

@@ -34,177 +34,193 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	Axially aligned bounding box.
-
-	Used mainly for collision detection and int32_tersection tests.
-*/
+/// Axially aligned bounding box.
+///
+/// Used mainly for collision detection and intersection tests.
 class Box
 class Box
 {
 {
-
 public:
 public:
 
 
-	Vec3			min;
-	Vec3			max;
+	/// Does nothing for efficiency.
+					Box();
 
 
+	/// Constructs from @min and @max.
+					Box(const Vec3& min, const Vec3& max);			
+					Box(const Box& box);
 
 
-					Box();													//!< Constructor
-					Box(const Vec3& newMin, const Vec3& newMax);			//!< Constructs from min and max
-					Box(const Box& box);									//!< Copy constructor
-					~Box();													//!< Destructor
+	const Vec3&		min() const;
+	const Vec3&		max() const;
+	void			set_min(const Vec3& min);
+	void			set_max(const Vec3& max);
 
 
-	const Vec3&		get_min() const;										//!< Returns the "min" corner
-	const Vec3&		get_max() const;										//!< Returns the "max" corner
-	void			set_min(const Vec3& min);								//!< Sets the "min" corner
-	void			set_max(const Vec3& max);								//!< Sets the "max" corner
+	Vec3			center() const;
+	real			radius() const;
+	real			volume() const;
 
 
-	Vec3			get_center() const;										//!< Returns the center
-	real			get_radius() const;										//!< Returns the radius
-	real			get_volume() const;										//!< Returns the volume
+	/// Adds @count @points expanding if necessary.
+	void			add_points(const Vec3* points, uint32_t count);
 
 
-	void			add_point32_t(const Vec3& p);								//!< Adds a point32_t to the aabb
-	void			add_box(const Box& box);								//!< Adds a Box to the aabb
+	/// Adds @count @boxes expanding if necessay.
+	void			add_boxes(const Box* boxes, uint32_t count);
 
 
-	bool			contains_point32_t(const Vec3& p) const;					//!< Returns whether point32_t "p" is contained
+	/// Returns whether point32_t "p" is contained.
+	bool			contains_point(const Vec3& p) const;
 
 
-	Vec3			get_vertex(uint32_t index) const;							//!< Returns a box's vertex
-	void			get_transformed(const Mat4& mat, Box& result) const;	//!< Returns the box trasformed according to "mat" matrix
+	/// Returns a box's vertex.
+	Vec3			vertex(uint32_t index) const;		
 
 
-	void			to_vertices(Vec3 v[8]) const;							//!< Returns the eight box's vertices
-	Sphere			to_sphere() const;										//!< Returns as a sphere
+	/// Returns the box trasformed according to "mat" matrix.
+	void			transformed(const Mat4& mat, Box& result) const;	
 
 
-	void			zero();													//!< Sets min and max to zero
-};
+	/// Returns the eight box's vertices
+	void			to_vertices(Vec3 v[8]) const;	
 
 
-//-----------------------------------------------------------------------------
-inline Box::Box() : min(0.0, 0.0, 0.0), max(0.0, 0.0, 0.0)
-{
-}
+	/// Returns as a sphere						
+	Sphere			to_sphere() const;										
+
+	/// Sets min and max to zero
+	void			zero();													
+
+private:
+
+	Vec3			m_min;
+	Vec3			m_max;
+};
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Box::Box(const Box& box) : min(box.min), max(box.max)
+inline Box::Box()
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Box::Box(const Vec3& newMin, const Vec3& newMax) : min(newMin), max(newMax)
+inline Box::Box(const Box& box) : m_min(box.m_min), m_max(box.m_max)
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Box::~Box()
+inline Box::Box(const Vec3& min, const Vec3& max) : m_min(min), m_max(max)
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline const Vec3& Box::get_min() const
+inline const Vec3& Box::min() const
 {
 {
-	return min;
+	return m_min;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline void Box::set_min(const Vec3& min)
 inline void Box::set_min(const Vec3& min)
 {
 {
-	this->min = min;
+	m_min = min;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline const Vec3& Box::get_max() const
+inline const Vec3& Box::max() const
 {
 {
-	return max;
+	return m_max;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline void Box::set_max(const Vec3& max)
 inline void Box::set_max(const Vec3& max)
 {
 {
-	this->max = max;
+	m_max = max;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline void Box::add_point32_t(const Vec3& p)
+inline void Box::add_points(const Vec3* points, uint32_t count)
 {
 {
-	if (p.x < min.x)
-	{
-		min.x = p.x;
-	}
-
-	if (p.y < min.y)
-	{
-		min.y = p.y;
-	}
-
-	if (p.z < min.z)
-	{
-		min.z = p.z;
-	}
-
-	if (p.x > max.x)
-	{
-		max.x = p.x;
-	}
-
-	if (p.y > max.y)
-	{
-		max.y = p.y;
-	}
-
-	if (p.z > max.z)
+	for (uint32_t i = 0; i < count; i++)
 	{
 	{
-		max.z = p.z;
+		const Vec3& p = points[i];
+
+		if (p.x < m_min.x)
+		{
+			m_min.x = p.x;
+		}
+
+		if (p.y < m_min.y)
+		{
+			m_min.y = p.y;
+		}
+
+		if (p.z < m_min.z)
+		{
+			m_min.z = p.z;
+		}
+
+		if (p.x > m_max.x)
+		{
+			m_max.x = p.x;
+		}
+
+		if (p.y > m_max.y)
+		{
+			m_max.y = p.y;
+		}
+
+		if (p.z > m_max.z)
+		{
+			m_max.z = p.z;
+		}
 	}
 	}
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline void Box::add_box(const Box& box)
+inline void Box::add_boxes(const Box* boxes, uint32_t count)
 {
 {
-	if (box.min.x < min.x)
-	{
-		min.x = box.min.x;
-	}
-
-	if (box.min.y < min.y)
-	{
-		min.y = box.min.y;
-	}
-
-	if (box.min.z < min.z)
-	{
-		min.z = box.min.z;
-	}
-
-	if (box.max.x > max.x)
-	{
-		max.x = box.max.x;
-	}
-
-	if (box.max.y > max.y)
+	for (uint32_t i = 0; i < count; i++)
 	{
 	{
-		max.y = box.max.y;
-	}
-
-	if (box.max.z > max.z)
-	{
-		max.z = box.max.z;
+		const Box& box = boxes[i];
+
+		if (box.m_min.x < m_min.x)
+		{
+			m_min.x = box.m_min.x;
+		}
+
+		if (box.m_min.y < m_min.y)
+		{
+			m_min.y = box.m_min.y;
+		}
+
+		if (box.m_min.z < m_min.z)
+		{
+			m_min.z = box.m_min.z;
+		}
+
+		if (box.m_max.x > m_max.x)
+		{
+			m_max.x = box.m_max.x;
+		}
+
+		if (box.m_max.y > m_max.y)
+		{
+			m_max.y = box.m_max.y;
+		}
+
+		if (box.m_max.z > m_max.z)
+		{
+			m_max.z = box.m_max.z;
+		}
 	}
 	}
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline bool Box::contains_point32_t(const Vec3& p) const
+inline bool Box::contains_point(const Vec3& p) const
 {
 {
-	return (p.x > min.x && p.y > min.y && p.z > min.z &&
-		p.x < max.x && p.y < max.y && p.z < max.z);
+	return (p.x > m_min.x && p.y > m_min.y && p.z > m_min.z &&
+		p.x < m_max.x && p.y < m_max.y && p.z < m_max.z);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Vec3 Box::get_center() const
+inline Vec3 Box::center() const
 {
 {
-	return (min + max) * 0.5;
+	return (m_min + m_max) * 0.5;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline real Box::get_radius() const
+inline real Box::radius() const
 {
 {
-	return (max - (min + max) * 0.5).length();
+	return (m_max - (m_min + m_max) * 0.5).length();
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -219,98 +235,103 @@ inline void Box::to_vertices(Vec3 v[8]) const
 	// |      |
 	// |      |
 	// |      |  <--- Bottom face
 	// |      |  <--- Bottom face
 	// 0 ---- 1
 	// 0 ---- 1
-	v[0].x = min.x;
-	v[0].y = min.y;
-	v[0].z = max.z;
+	v[0].x = m_min.x;
+	v[0].y = m_min.y;
+	v[0].z = m_max.z;
 
 
-	v[1].x = max.x;
-	v[1].y = min.y;
-	v[1].z = max.z;
+	v[1].x = m_max.x;
+	v[1].y = m_min.y;
+	v[1].z = m_max.z;
 
 
-	v[2].x = max.x;
-	v[2].y = min.y;
-	v[2].z = min.z;
+	v[2].x = m_max.x;
+	v[2].y = m_min.y;
+	v[2].z = m_min.z;
 
 
-	v[3].x = min.x;
-	v[3].y = min.y;
-	v[3].z = min.z;
+	v[3].x = m_min.x;
+	v[3].y = m_min.y;
+	v[3].z = m_min.z;
 
 
-	v[4].x = min.x;
-	v[4].y = max.y;
-	v[4].z = max.z;
+	v[4].x = m_min.x;
+	v[4].y = m_max.y;
+	v[4].z = m_max.z;
 
 
-	v[5].x = max.x;
-	v[5].y = max.y;
-	v[5].z = max.z;
+	v[5].x = m_max.x;
+	v[5].y = m_max.y;
+	v[5].z = m_max.z;
 
 
-	v[6].x = max.x;
-	v[6].y = max.y;
-	v[6].z = min.z;
+	v[6].x = m_max.x;
+	v[6].y = m_max.y;
+	v[6].z = m_min.z;
 
 
-	v[7].x = min.x;
-	v[7].y = max.y;
-	v[7].z = min.z;
+	v[7].x = m_min.x;
+	v[7].y = m_max.y;
+	v[7].z = m_min.z;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Vec3 Box::get_vertex(uint32_t index) const
+inline Vec3 Box::vertex(uint32_t index) const
 {
 {
 	assert(index < 8);
 	assert(index < 8);
 
 
 	switch (index)
 	switch (index)
 	{
 	{
 		case 0:
 		case 0:
-			return Vec3(min.x, min.y, min.z);
+			return Vec3(m_min.x, m_min.y, m_min.z);
 		case 1:
 		case 1:
-			return Vec3(max.x, min.y, min.z);
+			return Vec3(m_max.x, m_min.y, m_min.z);
 		case 2:
 		case 2:
-			return Vec3(max.x, min.y, max.z);
+			return Vec3(m_max.x, m_min.y, m_max.z);
 		case 3:
 		case 3:
-			return Vec3(min.x, min.y, max.z);
+			return Vec3(m_min.x, m_min.y, m_max.z);
 		case 4:
 		case 4:
-			return Vec3(min.x, max.y, min.z);
+			return Vec3(m_min.x, m_max.y, m_min.z);
 		case 5:
 		case 5:
-			return Vec3(max.x, max.y, min.z);
+			return Vec3(m_max.x, m_max.y, m_min.z);
 		case 6:
 		case 6:
-			return Vec3(max.x, max.y, max.z);
+			return Vec3(m_max.x, m_max.y, m_max.z);
 		case 7:
 		case 7:
-			return Vec3(min.x, max.y, max.z);
+			return Vec3(m_min.x, m_max.y, m_max.z);
 	}
 	}
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline void Box::get_transformed(const Mat4& mat, Box& result) const
+inline void Box::transformed(const Mat4& mat, Box& result) const
 {
 {
 	Vec3 vertices[8];
 	Vec3 vertices[8];
 
 
 	to_vertices(vertices);
 	to_vertices(vertices);
 
 
-	result.min = result.max = mat * vertices[0];
+	result.m_min = mat * vertices[0];
+	result.m_max = mat * vertices[0];
 
 
-	for (uint32_t i = 1; i < 8; i++)
-	{
-		vertices[i] = mat * vertices[i];
-		result.add_point32_t(vertices[i]);
-	}
+	vertices[1] = mat * vertices[1];
+	vertices[2] = mat * vertices[2];
+	vertices[3] = mat * vertices[3];
+	vertices[4] = mat * vertices[4];
+	vertices[5] = mat * vertices[5];
+	vertices[6] = mat * vertices[6];
+	vertices[7] = mat * vertices[7];
+
+	result.add_points(&vertices[1], 7);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline real Box::get_volume() const
+inline real Box::volume() const
 {
 {
-	return (max.x - min.x) * (max.y - min.y) * (max.z - min.z);
+	return (m_max.x - m_min.x) * (m_max.y - m_min.y) * (m_max.z - m_min.z);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline void Box::zero()
 inline void Box::zero()
 {
 {
-	min.zero();
-	max.zero();
+	m_min.zero();
+	m_max.zero();
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline Sphere Box::to_sphere() const
 inline Sphere Box::to_sphere() const
 {
 {
-	return Sphere(get_center(), get_radius());
+	return Sphere(center(), radius());
 }
 }
 
 
 } // namespace crown
 } // namespace crown

+ 1 - 1
src/core/bv/Circle.cpp

@@ -33,7 +33,7 @@ Rect Circle::to_rect() const
 {
 {
 	Rect b;
 	Rect b;
 
 
-	b.set_from_center_and_dimensions(c, r * 2.0, r * 2.0);
+	b.set_from_center_and_dimensions(m_center, m_radius * 2.0, m_radius * 2.0);
 
 
 	return b;
 	return b;
 }
 }

+ 31 - 33
src/core/bv/Circle.h

@@ -34,32 +34,35 @@ namespace crown
 
 
 class Rect;
 class Rect;
 
 
-/**
-	Circle.
-
-	Used mainly for collision detection and int32_tersection tests.
-*/
+/// Circle.
+///
+/// Used mainly for collision detection and intersection tests.
 class Circle
 class Circle
 {
 {
-
 public:
 public:
 
 
-	Vec2			c;
-	real			r;
+	/// Does nothing for efficiency
+					Circle();
+					
+	/// Constructs from @center and @radius
+					Circle(const Vec2& center, real radius);	
+					Circle(const Circle& circle);				
+
+	const Vec2&		center() const;							
+	real			radius() const;				
+
+	void			set_center(const Vec2& center);			
+	void			set_radius(real radius);				
 
 
-					Circle();									//!< Constructor, does nothing for efficiency
-					Circle(const Vec2& center, real radius);	//!< Constructs from center and radius
-					Circle(const Circle& circle);				//!< Copy constructor
-					~Circle();									//!< Destructor
+	real			area() const;						
 
 
-	const Vec2&		get_center() const;							//!< Returns the center
-	real			get_radius() const;							//!< Returns the radius
-	void			set_center(const Vec2& center);				//!< Sets the center
-	void			set_radius(real radius);					//!< Sets the radius
+	/// Returns a Rect containing the circle
+	Rect			to_rect() const;
 
 
-	real			get_area() const;							//!< Returns the area
+private:
 
 
-	Rect			to_rect() const;							//!< Returns the equivalent rect
+	Vec2			m_center;
+	real			m_radius;
 };
 };
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -68,48 +71,43 @@ inline Circle::Circle()
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Circle::Circle(const Vec2& c, real r) : c(c), r(r)
-{
-}
-
-//-----------------------------------------------------------------------------
-inline Circle::Circle(const Circle& circle) : c(circle.c), r(circle.r)
+inline Circle::Circle(const Vec2& center, real radius) : m_center(center), m_radius(radius)
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Circle::~Circle()
+inline Circle::Circle(const Circle& circle) : m_center(circle.m_center), m_radius(circle.m_radius)
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline const Vec2& Circle::get_center() const
+inline const Vec2& Circle::center() const
 {
 {
-	return c;
+	return m_center;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline real Circle::get_radius() const
+inline real Circle::radius() const
 {
 {
-	return r;
+	return m_radius;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline void Circle::set_center(const Vec2& center)
 inline void Circle::set_center(const Vec2& center)
 {
 {
-	c = center;
+	m_center = center;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline void Circle::set_radius(real radius)
 inline void Circle::set_radius(real radius)
 {
 {
-	r = radius;
+	m_radius = radius;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline real Circle::get_area() const
+inline real Circle::area() const
 {
 {
-	return r * r * math::PI;
+	return m_radius * m_radius * math::PI;
 }
 }
 
 
 } // namespace crown
 } // namespace crown

+ 75 - 74
src/core/bv/Frustum.cpp

@@ -26,6 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Frustum.h"
 #include "Frustum.h"
 #include "Types.h"
 #include "Types.h"
 #include "Intersection.h"
 #include "Intersection.h"
+#include "Mat4.h"
 
 
 namespace crown
 namespace crown
 {
 {
@@ -33,46 +34,43 @@ namespace crown
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 Frustum::Frustum()
 Frustum::Frustum()
 {
 {
-	mPlane[FP_LEFT]		= Plane::ZERO;
-	mPlane[FP_RIGHT]	= Plane::ZERO;
-	mPlane[FP_BOTTOM]	= Plane::ZERO;
-	mPlane[FP_TOP]		= Plane::ZERO;
-	mPlane[FP_NEAR]		= Plane::ZERO;
-	mPlane[FP_FAR]		= Plane::ZERO;
+	m_planes[FP_LEFT]		= Plane::ZERO;
+	m_planes[FP_RIGHT]		= Plane::ZERO;
+	m_planes[FP_BOTTOM]		= Plane::ZERO;
+	m_planes[FP_TOP]		= Plane::ZERO;
+	m_planes[FP_NEAR]		= Plane::ZERO;
+	m_planes[FP_FAR]		= Plane::ZERO;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 Frustum::Frustum(const Frustum& frustum)
 Frustum::Frustum(const Frustum& frustum)
 {
 {
-	mPlane[FP_LEFT]		= frustum.mPlane[FP_LEFT];
-	mPlane[FP_RIGHT]	= frustum.mPlane[FP_RIGHT];
-	mPlane[FP_BOTTOM]	= frustum.mPlane[FP_BOTTOM];
-	mPlane[FP_TOP]		= frustum.mPlane[FP_TOP];
-	mPlane[FP_NEAR]		= frustum.mPlane[FP_NEAR];
-	mPlane[FP_FAR]		= frustum.mPlane[FP_FAR];
+	m_planes[FP_LEFT]		= frustum.m_planes[FP_LEFT];
+	m_planes[FP_RIGHT]		= frustum.m_planes[FP_RIGHT];
+	m_planes[FP_BOTTOM]		= frustum.m_planes[FP_BOTTOM];
+	m_planes[FP_TOP]		= frustum.m_planes[FP_TOP];
+	m_planes[FP_NEAR]		= frustum.m_planes[FP_NEAR];
+	m_planes[FP_FAR]		= frustum.m_planes[FP_FAR];
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-Frustum::~Frustum()
+bool Frustum::contains_point(const Vec3& point) const
 {
 {
-}
-
-//-----------------------------------------------------------------------------
-bool Frustum::contains_point32_t(const Vec3& point32_t) const
-{
-	if (mPlane[FP_LEFT].get_distance_to_point32_t(point32_t) < 0.0) return false;
-	if (mPlane[FP_RIGHT].get_distance_to_point32_t(point32_t) < 0.0) return false;
-	if (mPlane[FP_BOTTOM].get_distance_to_point32_t(point32_t) < 0.0) return false;
-	if (mPlane[FP_TOP].get_distance_to_point32_t(point32_t) < 0.0) return false;
-	if (mPlane[FP_NEAR].get_distance_to_point32_t(point32_t) < 0.0) return false;
-	if (mPlane[FP_FAR].get_distance_to_point32_t(point32_t) < 0.0) return false;
+	if (m_planes[FP_LEFT].distance_to_point(point) < 0.0) return false;
+	if (m_planes[FP_RIGHT].distance_to_point(point) < 0.0) return false;
+	if (m_planes[FP_BOTTOM].distance_to_point(point) < 0.0) return false;
+	if (m_planes[FP_TOP].distance_to_point(point) < 0.0) return false;
+	if (m_planes[FP_NEAR].distance_to_point(point) < 0.0) return false;
+	if (m_planes[FP_FAR].distance_to_point(point) < 0.0) return false;
 
 
 	return true;
 	return true;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-Vec3 Frustum::get_vertex(uint32_t index) const
+Vec3 Frustum::vertex(uint32_t index) const
 {
 {
+	assert(index < 8);
+
 	// 0 = Near bottom left
 	// 0 = Near bottom left
 	// 1 = Near bottom right
 	// 1 = Near bottom right
 	// 2 = Near top right
 	// 2 = Near top right
@@ -82,28 +80,28 @@ Vec3 Frustum::get_vertex(uint32_t index) const
 	// 6 = Far top right
 	// 6 = Far top right
 	// 7 = Far top left
 	// 7 = Far top left
 
 
-	Vec3 ip(0, 0, 0);
+	Vec3 ip;
 
 
 	switch (index)
 	switch (index)
 	{
 	{
 		case 0:
 		case 0:
-			Intersection::TestPlane3(mPlane[4], mPlane[0], mPlane[2], ip);
+			return Intersection::TestPlane3(m_planes[4], m_planes[0], m_planes[2], ip);
 		case 1:
 		case 1:
-			Intersection::TestPlane3(mPlane[4], mPlane[1], mPlane[2], ip);
+			return Intersection::TestPlane3(m_planes[4], m_planes[1], m_planes[2], ip);
 		case 2:
 		case 2:
-			Intersection::TestPlane3(mPlane[4], mPlane[1], mPlane[3], ip);
+			return Intersection::TestPlane3(m_planes[4], m_planes[1], m_planes[3], ip);
 		case 3:
 		case 3:
-			Intersection::TestPlane3(mPlane[4], mPlane[0], mPlane[3], ip);
+			return Intersection::TestPlane3(m_planes[4], m_planes[0], m_planes[3], ip);
 		case 4:
 		case 4:
-			Intersection::TestPlane3(mPlane[5], mPlane[0], mPlane[2], ip);
+			return Intersection::TestPlane3(m_planes[5], m_planes[0], m_planes[2], ip);
 		case 5:
 		case 5:
-			Intersection::TestPlane3(mPlane[5], mPlane[1], mPlane[2], ip);
+			return Intersection::TestPlane3(m_planes[5], m_planes[1], m_planes[2], ip);
 		case 6:
 		case 6:
-			Intersection::TestPlane3(mPlane[5], mPlane[1], mPlane[3], ip);
+			return Intersection::TestPlane3(m_planes[5], m_planes[1], m_planes[3], ip);
 		case 7:
 		case 7:
-			Intersection::TestPlane3(mPlane[5], mPlane[0], mPlane[3], ip);
+			return Intersection::TestPlane3(m_planes[5], m_planes[0], m_planes[3], ip);
 		default:
 		default:
-			return ip;
+			break;
 	}
 	}
 
 
 	return ip;
 	return ip;
@@ -113,47 +111,47 @@ Vec3 Frustum::get_vertex(uint32_t index) const
 void Frustum::from_matrix(const Mat4& m)
 void Frustum::from_matrix(const Mat4& m)
 {
 {
 	// Left plane
 	// Left plane
-	mPlane[FP_LEFT].n.x		= m.m[3] + m.m[0];
-	mPlane[FP_LEFT].n.y		= m.m[7] + m.m[4];
-	mPlane[FP_LEFT].n.z		= m.m[11] + m.m[8];
-	mPlane[FP_LEFT].d		= m.m[15] + m.m[12];
+	m_planes[FP_LEFT].n.x		= m.m[3] + m.m[0];
+	m_planes[FP_LEFT].n.y		= m.m[7] + m.m[4];
+	m_planes[FP_LEFT].n.z		= m.m[11] + m.m[8];
+	m_planes[FP_LEFT].d			= m.m[15] + m.m[12];
 
 
 	// Right plane
 	// Right plane
-	mPlane[FP_RIGHT].n.x	= m.m[3] - m.m[0];
-	mPlane[FP_RIGHT].n.y	= m.m[7] - m.m[4];
-	mPlane[FP_RIGHT].n.z	= m.m[11] - m.m[8];
-	mPlane[FP_RIGHT].d		= m.m[15] - m.m[12];
+	m_planes[FP_RIGHT].n.x		= m.m[3] - m.m[0];
+	m_planes[FP_RIGHT].n.y		= m.m[7] - m.m[4];
+	m_planes[FP_RIGHT].n.z		= m.m[11] - m.m[8];
+	m_planes[FP_RIGHT].d		= m.m[15] - m.m[12];
 
 
 	// Bottom plane
 	// Bottom plane
-	mPlane[FP_BOTTOM].n.x	= m.m[3] + m.m[1];
-	mPlane[FP_BOTTOM].n.y	= m.m[7] + m.m[5];
-	mPlane[FP_BOTTOM].n.z	= m.m[11] + m.m[9];
-	mPlane[FP_BOTTOM].d		= m.m[15] + m.m[13];
+	m_planes[FP_BOTTOM].n.x		= m.m[3] + m.m[1];
+	m_planes[FP_BOTTOM].n.y		= m.m[7] + m.m[5];
+	m_planes[FP_BOTTOM].n.z		= m.m[11] + m.m[9];
+	m_planes[FP_BOTTOM].d		= m.m[15] + m.m[13];
 
 
 	// Top plane
 	// Top plane
-	mPlane[FP_TOP].n.x		= m.m[3] - m.m[1];
-	mPlane[FP_TOP].n.y		= m.m[7] - m.m[5];
-	mPlane[FP_TOP].n.z		= m.m[11] - m.m[9];
-	mPlane[FP_TOP].d		= m.m[15] - m.m[13];
+	m_planes[FP_TOP].n.x		= m.m[3] - m.m[1];
+	m_planes[FP_TOP].n.y		= m.m[7] - m.m[5];
+	m_planes[FP_TOP].n.z		= m.m[11] - m.m[9];
+	m_planes[FP_TOP].d			= m.m[15] - m.m[13];
 
 
 	// Near plane
 	// Near plane
-	mPlane[FP_NEAR].n.x		= m.m[3] + m.m[2];
-	mPlane[FP_NEAR].n.y		= m.m[7] + m.m[6];
-	mPlane[FP_NEAR].n.z		= m.m[11] + m.m[10];
-	mPlane[FP_NEAR].d		= m.m[15] + m.m[14];
+	m_planes[FP_NEAR].n.x		= m.m[3] + m.m[2];
+	m_planes[FP_NEAR].n.y		= m.m[7] + m.m[6];
+	m_planes[FP_NEAR].n.z		= m.m[11] + m.m[10];
+	m_planes[FP_NEAR].d			= m.m[15] + m.m[14];
 
 
 	// Far plane
 	// Far plane
-	mPlane[FP_FAR].n.x		= m.m[3] - m.m[2];
-	mPlane[FP_FAR].n.y		= m.m[7] - m.m[6];
-	mPlane[FP_FAR].n.z		= m.m[11] - m.m[10];
-	mPlane[FP_FAR].d		= m.m[15] - m.m[14];
-
-	mPlane[FP_LEFT].normalize();
-	mPlane[FP_RIGHT].normalize();
-	mPlane[FP_BOTTOM].normalize();
-	mPlane[FP_TOP].normalize();
-	mPlane[FP_NEAR].normalize();
-	mPlane[FP_FAR].normalize();
+	m_planes[FP_FAR].n.x		= m.m[3] - m.m[2];
+	m_planes[FP_FAR].n.y		= m.m[7] - m.m[6];
+	m_planes[FP_FAR].n.z		= m.m[11] - m.m[10];
+	m_planes[FP_FAR].d			= m.m[15] - m.m[14];
+
+	m_planes[FP_LEFT].normalize();
+	m_planes[FP_RIGHT].normalize();
+	m_planes[FP_BOTTOM].normalize();
+	m_planes[FP_TOP].normalize();
+	m_planes[FP_NEAR].normalize();
+	m_planes[FP_FAR].normalize();
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -162,14 +160,17 @@ Box Frustum::to_box() const
 	Box tmp;
 	Box tmp;
 	tmp.zero();
 	tmp.zero();
 
 
-	tmp.add_point32_t(this->get_vertex(0));
-	tmp.add_point32_t(this->get_vertex(1));
-	tmp.add_point32_t(this->get_vertex(2));
-	tmp.add_point32_t(this->get_vertex(3));
-	tmp.add_point32_t(this->get_vertex(4));
-	tmp.add_point32_t(this->get_vertex(5));
-	tmp.add_point32_t(this->get_vertex(6));
-	tmp.add_point32_t(this->get_vertex(7));
+	Vec3 vertices[8];
+	vertices[0] = vertex(0);
+	vertices[1] = vertex(1);
+	vertices[2] = vertex(2);
+	vertices[3] = vertex(3);
+	vertices[4] = vertex(4);
+	vertices[5] = vertex(5);
+	vertices[6] = vertex(6);
+	vertices[7] = vertex(7);
+
+	tmp.add_points(vertices, 8);
 
 
 	return tmp;
 	return tmp;
 }
 }

+ 18 - 12
src/core/bv/Frustum.h

@@ -27,10 +27,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 
 #include "Types.h"
 #include "Types.h"
 #include "Box.h"
 #include "Box.h"
-#include "Mat4.h"
-#include "Plane.h"
-#include "Sphere.h"
 #include "Vec3.h"
 #include "Vec3.h"
+#include "Plane.h"
 
 
 namespace crown
 namespace crown
 {
 {
@@ -45,24 +43,32 @@ enum FrustumPlane
 	FP_FAR		= 5
 	FP_FAR		= 5
 };
 };
 
 
+class Mat4;
+
 class Frustum
 class Frustum
 {
 {
-
 public:
 public:
 
 
-	Plane		mPlane[6];
+				Frustum();				
+				Frustum(const Frustum& frustum);
+
+	/// Returns whether @point is contained into the frustum
+	bool		contains_point(const Vec3& point) const;	
+
+	/// Returns one of the eight frustum's corners
+	Vec3		vertex(uint32_t index) const;			
 
 
+	/// Builds the view frustum according to the matrix @m
+	void		from_matrix(const Mat4& m);				
 
 
-				Frustum();								//!< Constructor
-				Frustum(const Frustum& frustum);		//!< Copy constructor
-				~Frustum();								//!< Destructor
+	/// Returns a Box containing the frustum volume
+	Box			to_box() const;							
 
 
-	bool		contains_point32_t(const Vec3& point32_t) const;	//!< Returns true if point32_t int32_tersects the frustum
-	Vec3		get_vertex(uint32_t index) const;			//!< Returns one of the eight frustum's corners
+private:
 
 
-	void		from_matrix(const Mat4& m);				//!< Builds the view frustum according to the matrix m
+	Plane		m_planes[6];
 
 
-	Box			to_box() const;							//!< Returns a Box containing the frustum volume
+	friend class Intersection;
 };
 };
 
 
 } // namespace crown
 } // namespace crown

+ 37 - 41
src/core/bv/Rect.cpp

@@ -25,22 +25,22 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 
 #include "Rect.h"
 #include "Rect.h"
 #include "Circle.h"
 #include "Circle.h"
+#include "MathUtils.h"
 
 
 namespace crown
 namespace crown
 {
 {
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-bool Rect::contains_point32_t(const Vec2& point32_t) const
+bool Rect::contains_point(const Vec2& point) const
 {
 {
-	return (point32_t.x >= min.x && point32_t.y >= min.y &&
-			point32_t.x <= max.x && point32_t.y <= max.y);
+	return (point.x >= m_min.x && point.y >= m_min.y &&
+			point.x <= m_max.x && point.y <= m_max.y);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-bool Rect::int32_tersects_rect(const Rect& Rect) const
+bool Rect::intersects_rect(const Rect& rect) const
 {
 {
-	//return (contains_point32_t(Rect.min) || contains_point32_t(Rect.max));
-	if (Rect.min.x > max.x || Rect.max.x < min.x || Rect.min.y > max.y || Rect.max.y < min.y)
+	if (rect.m_min.x > m_max.x || rect.m_max.x < m_min.x || rect.m_min.y > m_max.y || rect.m_max.y < m_min.y)
 		return false;
 		return false;
 	return true;
 	return true;
 }
 }
@@ -48,95 +48,91 @@ bool Rect::int32_tersects_rect(const Rect& Rect) const
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void Rect::set_from_center_and_dimensions(Vec2 center, real width, real height)
 void Rect::set_from_center_and_dimensions(Vec2 center, real width, real height)
 {
 {
-	min.x = (real)(center.x - width  / 2.0);
-	min.y = (real)(center.y - height / 2.0);
-	max.x = (real)(center.x + width  / 2.0);
-	max.y = (real)(center.y + height / 2.0);
+	m_min.x = (real)(center.x - width  / 2.0);
+	m_min.y = (real)(center.y - height / 2.0);
+	m_max.x = (real)(center.x + width  / 2.0);
+	m_max.y = (real)(center.y + height / 2.0);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void Rect::get_vertices(Vec2 v[4]) const
+void Rect::vertices(Vec2 v[4]) const
 {
 {
 	// 3 ---- 2
 	// 3 ---- 2
 	// |      |
 	// |      |
 	// |      |
 	// |      |
 	// 0 ---- 1
 	// 0 ---- 1
-	v[0].x = min.x;
-	v[0].y = min.y;
-	v[1].x = max.x;
-	v[1].y = min.y;
-	v[2].x = max.x;
-	v[2].y = max.y;
-	v[3].x = min.x;
-	v[3].y = max.y;
+	v[0].x = m_min.x;
+	v[0].y = m_min.y;
+	v[1].x = m_max.x;
+	v[1].y = m_min.y;
+	v[2].x = m_max.x;
+	v[2].y = m_max.y;
+	v[3].x = m_min.x;
+	v[3].y = m_max.y;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-Vec2 Rect::get_vertex(uint32_t index) const
+Vec2 Rect::vertex(uint32_t index) const
 {
 {
 	assert(index < 4);
 	assert(index < 4);
 
 
 	switch (index)
 	switch (index)
 	{
 	{
 		case 0:
 		case 0:
-			return Vec2(min.x, min.y);
+			return Vec2(m_min.x, m_min.y);
 		case 1:
 		case 1:
-			return Vec2(max.x, min.y);
+			return Vec2(m_max.x, m_min.y);
 		case 2:
 		case 2:
-			return Vec2(max.x, max.y);
+			return Vec2(m_max.x, m_max.y);
 		case 3:
 		case 3:
-			return Vec2(min.x, max.y);
+			return Vec2(m_min.x, m_max.y);
 	}
 	}
 
 
 	return Vec2::ZERO;
 	return Vec2::ZERO;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-Vec2 Rect::get_center() const
+Vec2 Rect::center() const
 {
 {
-	return (min + max) * 0.5;
+	return (m_min + m_max) * 0.5;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-real Rect::get_radius() const
+real Rect::radius() const
 {
 {
-	return (max - (min + max) * 0.5).length();
+	return (m_max - (m_min + m_max) * 0.5).length();
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-real Rect::get_area() const
+real Rect::area() const
 {
 {
-	return (max.x - min.x) * (max.y - min.y);
+	return (m_max.x - m_min.x) * (m_max.y - m_min.y);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-Vec2 Rect::get_size() const
+Vec2 Rect::size() const
 {
 {
-	return (max - min);
+	return (m_max - m_min);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void Rect::fix()
 void Rect::fix()
 {
 {
-	if (min.x > max.x)
+	if (m_min.x > m_max.x)
 	{
 	{
-		real tmp = min.x;
-		min.x = max.x;
-		max.x = tmp;
+		math::swap(m_min.x, m_max.x);
 	}
 	}
 
 
-	if (min.y > max.y)
+	if (m_min.y > m_max.y)
 	{
 	{
-		real tmp = min.y;
-		min.y = max.y;
-		max.y = tmp;
+		math::swap(m_min.y, m_max.y);
 	}
 	}
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 Circle Rect::to_circle() const
 Circle Rect::to_circle() const
 {
 {
-	return Circle(get_center(), get_radius());
+	return Circle(center(), radius());
 }
 }
 
 
 } // namespace crown
 } // namespace crown

+ 49 - 40
src/core/bv/Rect.h

@@ -35,43 +35,57 @@ namespace crown
 
 
 class Circle;
 class Circle;
 
 
-/**
-	2D rectangle.
-
-	Used mainly for collision detection and int32_tersection tests.
-*/
+/// 2D rectangle.
+///
+/// Used mainly for collision detection and intersection tests.
 class Rect
 class Rect
 {
 {
-
 public:
 public:
 
 
-	Vec2			min;
-	Vec2			max;
+	/// Does nothing for efficiency.
+					Rect();		
+
+	/// Constructs from  @min and @max
+					Rect(const Vec2& min, const Vec2& max);		
+					Rect(const Rect& rect);	
+
+	const Vec2&		min() const;					
+	const Vec2&		max() const;					
+	void			set_min(const Vec2& min);				
+	void			set_max(const Vec2& max);			
+
+	Vec2			center() const;					
+	real			radius() const;					
+	real			area() const;		
+
+	/// Returns the diagonal
+	Vec2			size() const;						
 
 
-					Rect();									//!< Constructor
-					Rect(const Vec2& a, const Vec2& b);		//!< Builds from "a" min value and "b" max value
-					Rect(const Rect& rect);					//!< Copy construcor
-					~Rect();								//!< Destructor
+	/// Returns whether @point is contained
+	bool			contains_point(const Vec2& point) const;
 
 
-	const Vec2&		get_min() const;						//!< Returns the "min" corner
-	const Vec2&		get_max() const;						//!< Returns the "max" corner
-	void			set_min(const Vec2& min);				//!< Sets the "min" corner
-	void			set_max(const Vec2& max);				//!< Sets the "max" corner
+	/// Returns whether intersects @r
+	bool			intersects_rect(const Rect& rect) const;	
 
 
-	Vec2			get_center() const;						//!< Returns the center
-	real			get_radius() const;						//!< Returns the radius 
-	real			get_area() const;						//!< Returns the area
-	Vec2			get_size() const;						//!< Returns the diagonal
+	/// Sets the Rect from a center and a width - height
+	void			set_from_center_and_dimensions(Vec2 center, real width, real height);	
 
 
-	bool			contains_point32_t(const Vec2& point32_t) const;//!< Returns whether "point32_t" is contained
-	bool			int32_tersects_rect(const Rect& r) const;	//!< Returns whether int32_tersects "r"
-	void			set_from_center_and_dimensions(Vec2 center, real width, real height);	//!< Sets the Rect from a center and a width - height
-	void			get_vertices(Vec2 v[4]) const;			//!< Returns the four rect's vertices
-	Vec2			get_vertex(uint32_t index) const;			//!< Returns a rect's vertex
+	/// Returns the four rect's vertices
+	void			vertices(Vec2 v[4]) const;
 
 
-	Circle			to_circle() const;						//!< Returns the equivalent circle
+	/// Returns a rect's vertex
+	Vec2			vertex(uint32_t index) const;			
 
 
-	void			fix();									//!< Ensures that min and max aren't swapped
+	/// Returns the equivalent circle
+	Circle			to_circle() const;
+
+	/// Ensures that min and max aren't swapped
+	void			fix();									
+
+private:
+
+	Vec2			m_min;
+	Vec2			m_max;
 };
 };
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -80,42 +94,37 @@ inline Rect::Rect()
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Rect::Rect(const Vec2& a, const Vec2& b) : min(a), max(b)
-{
-}
-
-//-----------------------------------------------------------------------------
-inline Rect::Rect(const Rect& rect) : min(rect.min), max(rect.max)
+inline Rect::Rect(const Vec2& min, const Vec2& max) : m_min(min), m_max(max)
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Rect::~Rect()
+inline Rect::Rect(const Rect& rect) : m_min(rect.m_min), m_max(rect.m_max)
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline const Vec2& Rect::get_min() const
+inline const Vec2& Rect::min() const
 {
 {
-	return min;
+	return m_min;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline const Vec2& Rect::get_max() const
+inline const Vec2& Rect::max() const
 {
 {
-	return max;
+	return m_max;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline void Rect::set_min(const Vec2& min)
 inline void Rect::set_min(const Vec2& min)
 {
 {
-	this->min = min;
+	m_min = min;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline void Rect::set_max(const Vec2& max)
 inline void Rect::set_max(const Vec2& max)
 {
 {
-	this->max = max;
+	m_max = max;
 }
 }
 
 
 } // namespace crown
 } // namespace crown

+ 60 - 49
src/core/bv/Sphere.h

@@ -32,35 +32,41 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	Sphere.
 
 
-	Used mainly for collision detection and int32_tersection tests.
-*/
+/// Sphere.
+///
+/// Used mainly for collision detection and intersection tests.
 class Sphere
 class Sphere
 {
 {
-
 public:
 public:
 
 
-	Vec3			c;
-	real			r;
+	/// Does nothing for efficiency.
+					Sphere();
+
+	/// Constructs from center and radius.
+					Sphere(const Vec3& center, real radius);
+					Sphere(const Sphere& a);
+
+	const Vec3&		center() const;		
+	real			radius() const;	
+	real			volume() const;	
+
+	void			set_center(const Vec3& center);
+	void			set_radius(real radius);
 
 
-					Sphere();									//!< Constructor
-					Sphere(const Vec3& center, real radius);	//!< Constructs from center and radius
-					Sphere(const Sphere& a);					//!< Copy constructor
-					~Sphere();									//!< Destructor
+	/// Adds a point expanding if necessary.
+	void			add_points(const Vec3* points, uint32_t count);	
 
 
-	const Vec3&		get_center() const;							//!< Returns the center
-	real			get_radius() const;							//!< Returns the radius
-	real			get_volume() const;							//!< Returns the volume
+	/// Adds a sphere expanding if necessary.
+	void			add_spheres(const Sphere* spheres, uint32_t count);	
 
 
-	void			set_center(const Vec3& center);				//!< Sets the center
-	void			set_radius(real radius);					//!< Sets the radius
+	/// Returns whether point @p is contained.
+	bool			contains_point(const Vec3& p) const;		
 
 
-	void			add_point32_t(const Vec3& p);					//!< Adds a point32_t to the Sphere
-	void			add_sphere(const Sphere& s);				//!< Adds a Sphere to the Sphere
+private:
 
 
-	bool			contains_point32_t(const Vec3& p) const;		//!< Returns whether point32_t "p" is contained
+	Vec3			m_center;
+	real			m_radius;
 };
 };
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -69,80 +75,85 @@ inline Sphere::Sphere()
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Sphere::Sphere(const Vec3& center, real radius) : c(center), r(radius)
-{
-}
-
-//-----------------------------------------------------------------------------
-inline Sphere::Sphere(const Sphere& a) : c(a.c), r(a.r)
+inline Sphere::Sphere(const Vec3& center, real radius) : m_center(center), m_radius(radius)
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Sphere::~Sphere()
+inline Sphere::Sphere(const Sphere& a) : m_center(a.m_center), m_radius(a.m_radius)
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline const Vec3& Sphere::get_center() const
+inline const Vec3& Sphere::center() const
 {
 {
-	return c;
+	return m_center;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline real Sphere::get_radius() const
+inline real Sphere::radius() const
 {
 {
-	return r;
+	return m_radius;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline real Sphere::get_volume() const
+inline real Sphere::volume() const
 {
 {
-	return math::FOUR_OVER_THREE_TIMES_PI * r * r * r;
+	return math::FOUR_OVER_THREE_TIMES_PI * m_radius * m_radius * m_radius;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline void Sphere::set_center(const Vec3& center)
 inline void Sphere::set_center(const Vec3& center)
 {
 {
-	c = center;
+	m_center = center;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline void Sphere::set_radius(real radius)
 inline void Sphere::set_radius(real radius)
 {
 {
-	this->r = radius;
+	m_radius = radius;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline void Sphere::add_point32_t(const Vec3& p)
+inline void Sphere::add_points(const Vec3* points, uint32_t count)
 {
 {
-	real dist = (p - c).squared_length();
-
-	if (dist < r * r)
+	for (uint32_t i = 0; i < count; i++)
 	{
 	{
-		return;
-	}
+		const Vec3& p = points[i];
+
+		real dist = (p - m_center).squared_length();
 
 
-	r = math::sqrt(dist);
+		if (dist >= m_radius * m_radius)
+		{
+			m_radius = math::sqrt(dist);
+		}
+	}
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline void Sphere::add_sphere(const Sphere& s)
+inline void Sphere::add_spheres(const Sphere* spheres, uint32_t count)
 {
 {
-	real dist = (s.c - c).squared_length();
+	for (uint32_t i = 0; i < count; i++)
+	{
+		const Sphere& s = spheres[i];
 
 
-	if (dist < (s.r + r) * (s.r + r))
-		if (s.r * s.r > r * r)
+		real dist = (s.m_center - m_center).squared_length();
+
+		if (dist < (s.m_radius + m_radius) * (s.m_radius + m_radius))
 		{
 		{
-			r = math::sqrt(dist + s.r * s.r);
+			if (s.m_radius * s.m_radius > m_radius * m_radius)
+			{
+				m_radius = math::sqrt(dist + s.m_radius * s.m_radius);
+			}
 		}
 		}
+	}
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline bool Sphere::contains_point32_t(const Vec3& p) const
+inline bool Sphere::contains_point(const Vec3& p) const
 {
 {
-	real dist = (p - c).squared_length();
-	return (dist < r * r);
+	real dist = (p - m_center).squared_length();
+	return (dist < m_radius * m_radius);
 }
 }
 
 
 } // namespace crown
 } // namespace crown

+ 2 - 2
src/core/compressors/Compressor.h

@@ -17,11 +17,11 @@ public:
 
 
 protected:
 protected:
 	
 	
-	Allocator* 			m_allocator;
+	Allocator& 			m_allocator;
 };
 };
 
 
 inline Compressor::Compressor(Allocator& allocator) :
 inline Compressor::Compressor(Allocator& allocator) :
-	m_allocator(&allocator)
+	m_allocator(allocator)
 {
 {
 
 
 }
 }

+ 2 - 2
src/core/compressors/ZipCompressor.cpp

@@ -21,7 +21,7 @@ uint8_t* ZipCompressor::compress(const void* data, size_t in_size, size_t& out_s
 {
 {
 	out_size = in_size + in_size * 0.1f + 12;
 	out_size = in_size + in_size * 0.1f + 12;
 	
 	
- 	uint8_t* dest = (uint8_t*)m_allocator->allocate(out_size);
+ 	uint8_t* dest = (uint8_t*)m_allocator.allocate(out_size);
 	
 	
 	int32_t ret = ::compress((Bytef*)dest, (uLongf*)&out_size, (const Bytef*)data, (uLongf)in_size);
 	int32_t ret = ::compress((Bytef*)dest, (uLongf*)&out_size, (const Bytef*)data, (uLongf)in_size);
 	
 	
@@ -34,7 +34,7 @@ uint8_t* ZipCompressor::uncompress(const void* data, size_t in_size, size_t& out
 {
 {
 	out_size = in_size + in_size * 0.1f + 12;
 	out_size = in_size + in_size * 0.1f + 12;
 	
 	
- 	uint8_t* dest = (uint8_t*)m_allocator->allocate(out_size);
+ 	uint8_t* dest = (uint8_t*)m_allocator.allocate(out_size);
 	
 	
 	int32_t ret = ::uncompress((Bytef*)dest, (uLongf*)&out_size, (const Bytef*)data, (uLongf)in_size);
 	int32_t ret = ::uncompress((Bytef*)dest, (uLongf*)&out_size, (const Bytef*)data, (uLongf)in_size);
 	
 	

+ 65 - 50
src/core/math/Color4.h

@@ -31,56 +31,71 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	RGBA color.
-
-	Maint32_tains 3 float values each representing a primary
-	color int32_tensity. An extra component is used as transparency
-	coefficient. Each component ranges from 0.0 to 1.0; the higher
-	the value the brighter the color. An alpha value of 0.0 means
-	totally transparent while a value of 1.0 means totally opaque.
-
-	It also offers a set of color name constants compliant with SVG 1.0.
-*/
+/// RGBA color.
+/// 
+/// Maintains 3 float values each representing a primary
+/// color intensity. An extra component is used as transparency
+/// coefficient. Each component ranges from 0.0 to 1.0; the higher
+/// the value the brighter the color. An alpha value of 0.0 means
+/// totally transparent while a value of 1.0 means totally opaque.
+/// 
+/// It also offers a set of color name constants compliant with SVG 1.0.
 class Color4
 class Color4
 {
 {
-
 public:
 public:
 
 
 	float					r, g, b, a;
 	float					r, g, b, a;
 
 
-							Color4();									//!< Constructor, does nothing for efficiency
-							~Color4();									//!< Destructor
-							Color4(const Color4& c);					//!< Copy constructor
-							Color4(float r, float g, float b);			//!< Construct from three values
-							Color4(int32_t r, int32_t g, int32_t b);				//!< Construct from three values
-							Color4(float r, float g, float b, float a); //!< Construct from four values
-							Color4(int32_t r, int32_t g, int32_t b, int32_t a);			//!< Construct from four values
-	explicit				Color4(float c[4]);							//!< Construct from four values
-	explicit				Color4(uint32_t rgba);							//!< Construct from 32-bit int32_teger (red at MSB, alpha at LSB)
-
-	uint32_t				get_as_rgb() const;	//!< Returns the color as a single 32-bit packed value. (RGBA order, alpha assumed = 255)
-	uint32_t				get_as_bgr() const;	//!< Returns the color as a single 32-bit packed value. (ABGR order, alpha assumed = 255)
-	uint32_t				get_as_rgba() const;	//!< Returns the color as a single 32-bit packed value. (RGBA order)
-	uint32_t				get_as_abgr() const;	//!< Returns the color as a single 32-bit packed value. (ABGR order)
-
-	float					operator[](uint32_t i) const;					//!< Random access by index
-	float&					operator[](uint32_t i);							//!< Random access by index
-
-	Color4					operator+(const Color4& c) const;			//!< Addition
-	Color4&					operator+=(const Color4& c);				//!< Addition
-	Color4					operator-(const Color4& c) const;			//!< Subtraction
-	Color4&					operator-=(const Color4& c);				//!< Subtraction
-	Color4					operator*(const Color4& c) const;			//!< Multiplication
-	Color4&					operator*=(const Color4& c);				//!< Multiplication
-	Color4					operator*(float scalar) const;				//!< Scalar multiplication
-	Color4&					operator*=(float scalar);					//!< Scalar multiplication
-
-	bool					operator==(const Color4& other) const;		//!< Equality operator
-	bool					operator!=(const Color4& other) const;		//!< Disequality operator
-
-	float*					to_float_ptr();								//!< Returns the point32_ter to the color's data.
-	const float*			to_float_ptr() const;							//!< Returns the point32_ter to the color's data.
+public:
+
+	/// Does nothing for efficiency
+							Color4();					
+							~Color4();								
+							Color4(const Color4& c);				
+							Color4(float r, float g, float b);		
+							Color4(int r, int g, int b);			
+							Color4(float r, float g, float b, float a);
+							Color4(int r, int g, int b, int a);		
+	explicit				Color4(float c[4]);	
+
+	/// Construct from 32-bit integer (red at MSB, alpha at LSB)					
+	explicit				Color4(uint32_t rgba);
+
+	/// Returns the color as a packed 32-bit integer. (RGBA order, alpha assumed = 255)
+	uint32_t				to_rgb() const;		
+
+	/// Returns the color as a packed 32-bit integer. (ABGR order, alpha assumed = 255)
+	uint32_t				to_bgr() const;	
+
+	/// Returns the color as a packed 32-bit integer. (RGBA order)	
+	uint32_t				to_rgba() const;	
+
+	/// Returns the color as a packed 32-bit integer. (ABGR order)
+	uint32_t				to_abgr() const;	
+
+	/// Random access by index. (red = 0, alpha = 3)
+	float					operator[](uint32_t i) const;		
+
+	/// Random access by index. (red = 0, alpha = 3)		
+	float&					operator[](uint32_t i);				
+
+	Color4					operator+(const Color4& c) const;
+	Color4&					operator+=(const Color4& c);		
+	Color4					operator-(const Color4& c) const;		
+	Color4&					operator-=(const Color4& c);		
+	Color4					operator*(const Color4& c) const;		
+	Color4&					operator*=(const Color4& c);		
+	Color4					operator*(float scalar) const;				
+	Color4&					operator*=(float scalar);				
+
+	bool					operator==(const Color4& other) const;
+	bool					operator!=(const Color4& other) const;	
+
+	/// Returns the pointer to the color's data.
+	float*					to_float_ptr();		
+
+	/// Returns the pointer to the color's data.						
+	const float*			to_float_ptr() const;
 
 
 	// SVG 1.0 color names
 	// SVG 1.0 color names
 	static const Color4		ALICEBLUE;
 	static const Color4		ALICEBLUE;
@@ -257,7 +272,7 @@ inline Color4::Color4(float r, float g, float b)
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Color4::Color4(int32_t r, int32_t g, int32_t b)
+inline Color4::Color4(int r, int g, int b)
 {
 {
 	this->r = r * math::ONE_OVER_255;
 	this->r = r * math::ONE_OVER_255;
 	this->g = g * math::ONE_OVER_255;
 	this->g = g * math::ONE_OVER_255;
@@ -275,7 +290,7 @@ inline Color4::Color4(float r, float g, float b, float a)
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Color4::Color4(int32_t r, int32_t g, int32_t b, int32_t a)
+inline Color4::Color4(int r, int g, int b, int a)
 {
 {
 	this->r = r * math::ONE_OVER_255;
 	this->r = r * math::ONE_OVER_255;
 	this->g = g * math::ONE_OVER_255;
 	this->g = g * math::ONE_OVER_255;
@@ -314,7 +329,7 @@ inline const float* Color4::to_float_ptr() const
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline uint32_t Color4::get_as_rgb() const
+inline uint32_t Color4::to_rgb() const
 {
 {
 	uint32_t rgba;
 	uint32_t rgba;
 
 
@@ -327,7 +342,7 @@ inline uint32_t Color4::get_as_rgb() const
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline uint32_t Color4::get_as_bgr() const
+inline uint32_t Color4::to_bgr() const
 {
 {
 	uint32_t abgr;
 	uint32_t abgr;
 
 
@@ -340,7 +355,7 @@ inline uint32_t Color4::get_as_bgr() const
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline uint32_t Color4::get_as_rgba() const
+inline uint32_t Color4::to_rgba() const
 {
 {
 	uint32_t rgba;
 	uint32_t rgba;
 
 
@@ -353,7 +368,7 @@ inline uint32_t Color4::get_as_rgba() const
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline uint32_t Color4::get_as_abgr() const
+inline uint32_t Color4::to_abgr() const
 {
 {
 	uint32_t abgr;
 	uint32_t abgr;
 
 

+ 27 - 70
src/core/math/Interpolation.h

@@ -28,84 +28,40 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	Interpolation utilities.
-*/
-class Interpolation
+/// Interpolation utilities.
+namespace interpolation
 {
 {
 
 
-public:
-
-							/**
-								linear int32_terpolation between a pair of values.
-							@param start
-								The start value
-							@param end
-								The end value
-							@param t
-								An int32_terval ranging from 0.0 to 1.0
-							@return
-								The int32_terpolated value
-							*/
-	template <typename T>
-	static T				linear(const T& p0, const T& p1, real t);
-
-							/**
-								cosine int32_terpolation between a pair of values.
-							@param start
-								The start value
-							@param end
-								The end value
-							@param t
-								An int32_terval ranging from 0.0 to 1.0
-							@return
-								The int32_terpolated value
-							*/
-	template <typename T>
-	static T				cosine(const T& p0, const T& p1, real t);
-
-							/**
-								cubic int32_terpolation between a pair of values.
-							@param start
-								The start value
-							@param end
-								The end value
-							@param t
-								An int32_terval ranging from 0.0 to 1.0
-							@return
-								The int32_terpolated value
-							*/
-	template <typename T>
-	static T				cubic(const T& p0, const T& p1, real t);
-
-							/**
-								bezier int32_terpolation.
-							*/
-	template <typename T>
-	static T				bezier(const T& p1, const T& p2, const T& p3, const T& p4, real t);
-
-							/**
-								Catmull-Rom spline int32_terpolation.
-							*/
-	template <typename T>
-	static T				catmull_rom(const T& p0, const T& p1, const T& p2, const T& p3, real t);
-
-private:
-
-	// Disable construction
-	Interpolation();
-};
+/// Returns the linear interpolated value between @p0 and @p1 at time @t
+template <typename T>
+static T	linear(const T& p0, const T& p1, real t);
+
+/// Returns the cosine interpolated value between @p0 and @p1 at time @t
+template <typename T>
+static T	cosine(const T& p0, const T& p1, real t);
+
+/// Returns the cubic interpolated value between @p0 and @p1 at time @t
+template <typename T>
+static T	cubic(const T& p0, const T& p1, real t);
+
+/// Bezier interpolation
+template <typename T>
+static T	bezier(const T& p1, const T& p2, const T& p3, const T& p4, real t);
+
+/// Catmull-Rom interpolation
+template <typename T>
+static T	catmull_rom(const T& p0, const T& p1, const T& p2, const T& p3, real t);
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline T Interpolation::linear(const T& p0, const T& p1, real t)
+inline T linear(const T& p0, const T& p1, real t)
 {
 {
 	return p0 + (t * (p1 - p0));
 	return p0 + (t * (p1 - p0));
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline T Interpolation::cosine(const T& p0, const T& p1, real t)
+inline T cosine(const T& p0, const T& p1, real t)
 {
 {
 	real f = t * math::PI;
 	real f = t * math::PI;
 	real g = (1.0 - math::cos(f)) * 0.5;
 	real g = (1.0 - math::cos(f)) * 0.5;
@@ -115,7 +71,7 @@ inline T Interpolation::cosine(const T& p0, const T& p1, real t)
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline T Interpolation::cubic(const T& p0, const T& p1, real t)
+inline T cubic(const T& p0, const T& p1, real t)
 {
 {
 	real tt = t * t;
 	real tt = t * t;
 	real ttt = tt * t;
 	real ttt = tt * t;
@@ -125,7 +81,7 @@ inline T Interpolation::cubic(const T& p0, const T& p1, real t)
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline T Interpolation::bezier(const T& p0, const T& p1, const T& p2, const T& p3, real t)
+inline T bezier(const T& p0, const T& p1, const T& p2, const T& p3, real t)
 {
 {
 	real u = 1.0 - t;
 	real u = 1.0 - t;
 	real tt = t * t ;
 	real tt = t * t ;
@@ -143,7 +99,7 @@ inline T Interpolation::bezier(const T& p0, const T& p1, const T& p2, const T& p
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 template <typename T>
 template <typename T>
-inline T Interpolation::catmull_rom(const T& p0, const T& p1, const T& p2, const T& p3, real t)
+inline T catmull_rom(const T& p0, const T& p1, const T& p2, const T& p3, real t)
 {
 {
 	real tt = t * t;
 	real tt = t * t;
 	real ttt = tt * t;
 	real ttt = tt * t;
@@ -156,5 +112,6 @@ inline T Interpolation::catmull_rom(const T& p0, const T& p1, const T& p2, const
 	return tmp * 0.5;
 	return tmp * 0.5;
 }
 }
 
 
+} // namespace interpolation
 } // namespace crown
 } // namespace crown
 
 

+ 92 - 92
src/core/math/Intersection.h

@@ -121,8 +121,8 @@ private:
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestRayPlane(const Ray& r, const Plane& p, real& distance, Vec3& intersectionPoint)
 inline bool Intersection::TestRayPlane(const Ray& r, const Plane& p, real& distance, Vec3& intersectionPoint)
 {
 {
-	real nd = r.direction.dot(p.n);
-	real orpn = r.origin.dot(p.n);
+	real nd = r.direction().dot(p.n);
+	real orpn = r.origin().dot(p.n);
 
 
 	if (nd < 0.0)
 	if (nd < 0.0)
 	{
 	{
@@ -130,7 +130,7 @@ inline bool Intersection::TestRayPlane(const Ray& r, const Plane& p, real& dista
 		if (dist > 0.0)
 		if (dist > 0.0)
 		{
 		{
 			distance = dist;
 			distance = dist;
-			intersectionPoint = r.origin + r.direction * distance;
+			intersectionPoint = r.origin() + r.direction() * distance;
 			return true;
 			return true;
 		}
 		}
 	}
 	}
@@ -141,17 +141,17 @@ inline bool Intersection::TestRayPlane(const Ray& r, const Plane& p, real& dista
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestRaySphere(const Ray& r, const Sphere& s, real& distance, Vec3& intersectionPoint)
 inline bool Intersection::TestRaySphere(const Ray& r, const Sphere& s, real& distance, Vec3& intersectionPoint)
 {
 {
-	Vec3 v = s.c - r.origin;
-	real b = v.dot(r.direction);
-	real det = (s.r * s.r) - v.dot(v) + (b * b);
+	Vec3 v = s.center() - r.origin();
+	real b = v.dot(r.direction());
+	real det = (s.radius() * s.radius()) - v.dot(v) + (b * b);
 
 
-	if (det < 0.0 || b < s.r)
+	if (det < 0.0 || b < s.radius())
 	{
 	{
 		return false;
 		return false;
 	}
 	}
 
 
 	distance = b - math::sqrt(det);
 	distance = b - math::sqrt(det);
-	intersectionPoint = r.origin + r.direction * distance;
+	intersectionPoint = r.origin() + r.direction() * distance;
 
 
 	return true;
 	return true;
 }
 }
@@ -159,49 +159,49 @@ inline bool Intersection::TestRaySphere(const Ray& r, const Sphere& s, real& dis
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestRayBox(const Ray& r, const Box& b, real& /*distance*/, Vec3& /*intersectionPoint*/)
 inline bool Intersection::TestRayBox(const Ray& r, const Box& b, real& /*distance*/, Vec3& /*intersectionPoint*/)
 {
 {
-	if (r.origin.x < b.min.x)
+	if (r.origin().x < b.min().x)
 	{
 	{
-		if (r.direction.x < 0.0)
+		if (r.direction().x < 0.0)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
 	}
 	}
 
 
-	if (r.origin.x > b.max.x)
+	if (r.origin().x > b.max().x)
 	{
 	{
-		if (r.direction.x > 0.0)
+		if (r.direction().x > 0.0)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
 	}
 	}
 
 
-	if (r.origin.y < b.min.y)
+	if (r.origin().y < b.min().y)
 	{
 	{
-		if (r.direction.y < 0.0)
+		if (r.direction().y < 0.0)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
 	}
 	}
 
 
-	if (r.origin.y > b.max.y)
+	if (r.origin().y > b.max().y)
 	{
 	{
-		if (r.direction.y > 0.0)
+		if (r.direction().y > 0.0)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
 	}
 	}
 
 
-	if (r.origin.z < b.min.z)
+	if (r.origin().z < b.min().z)
 	{
 	{
-		if (r.direction.z < 0.0)
+		if (r.direction().z < 0.0)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
 	}
 	}
 
 
-	if (r.origin.z > b.max.z)
+	if (r.origin().z > b.max().z)
 	{
 	{
-		if (r.direction.z > 0.0)
+		if (r.direction().z > 0.0)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
@@ -218,7 +218,7 @@ inline bool Intersection::TestRayTriangle(const Ray& r, const Triangle& t, real&
 {
 {
 	if (Intersection::TestRayPlane(r, t.to_plane(), distance, intersectionPoint))
 	if (Intersection::TestRayPlane(r, t.to_plane(), distance, intersectionPoint))
 	{
 	{
-		if (t.contains_point32_t(intersectionPoint))
+		if (t.contains_point(intersectionPoint))
 		{
 		{
 			return true;
 			return true;
 		}
 		}
@@ -250,7 +250,7 @@ inline bool Intersection::TestPlane3(const Plane& p1, const Plane& p2, const Pla
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestStaticSpherePlane(const Sphere& s, const Plane& p)
 inline bool Intersection::TestStaticSpherePlane(const Sphere& s, const Plane& p)
 {
 {
-	if (math::abs(p.get_distance_to_point32_t(s.c)) < s.r)
+	if (math::abs(p.distance_to_point(s.center())) < s.radius())
 	{
 	{
 		return true;
 		return true;
 	}
 	}
@@ -261,20 +261,20 @@ inline bool Intersection::TestStaticSpherePlane(const Sphere& s, const Plane& p)
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestStaticSphereSphere(const Sphere& a, const Sphere& b)
 inline bool Intersection::TestStaticSphereSphere(const Sphere& a, const Sphere& b)
 {
 {
-	real dist = (b.c - a.c).squared_length();
-	return (dist < (b.r + a.r) * (b.r + a.r));
+	real dist = (b.center() - a.center()).squared_length();
+	return (dist < (b.radius() + a.radius()) * (b.radius() + a.radius()));
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestDynamicSpherePlane(const Sphere& s, const Vec3& d, const Plane& p, real& it, Vec3& intersectionPoint)
 inline bool Intersection::TestDynamicSpherePlane(const Sphere& s, const Vec3& d, const Plane& p, real& it, Vec3& intersectionPoint)
 {
 {
-	const Vec3& sphereCenter = s.c;
-	const real sphereRadius = s.r;
+	const Vec3& sphereCenter = s.center();
+	const real sphereRadius = s.radius();
 
 
 	real t0;	// Time at which the sphere int32_tersects the plane remaining at the front side of the plane
 	real t0;	// Time at which the sphere int32_tersects the plane remaining at the front side of the plane
 	real t1;	// Time at which the sphere int32_tersects the plane remaining at the back side of the plane
 	real t1;	// Time at which the sphere int32_tersects the plane remaining at the back side of the plane
 
 
-	real sphereToPlaneDistance = p.get_distance_to_point32_t(sphereCenter);
+	real sphereToPlaneDistance = p.distance_to_point(sphereCenter);
 	real planeNormalDotVelocity = p.n.dot(d);
 	real planeNormalDotVelocity = p.n.dot(d);
 
 
 	if (planeNormalDotVelocity > 0.0)
 	if (planeNormalDotVelocity > 0.0)
@@ -292,7 +292,7 @@ inline bool Intersection::TestDynamicSpherePlane(const Sphere& s, const Vec3& d,
 			t1 = 1.0;
 			t1 = 1.0;
 
 
 			it = t0;
 			it = t0;
-			intersectionPoint = s.c - p.n * s.r;
+			intersectionPoint = s.center() - p.n * s.radius();
 			return true;
 			return true;
 		}
 		}
 
 
@@ -306,7 +306,7 @@ inline bool Intersection::TestDynamicSpherePlane(const Sphere& s, const Vec3& d,
 	if (t0 >= 0.0 && t0 <= 1.0)
 	if (t0 >= 0.0 && t0 <= 1.0)
 	{
 	{
 		it = math::min(t0, t1);
 		it = math::min(t0, t1);
-		intersectionPoint = s.c - p.n * s.r + (d * it);
+		intersectionPoint = s.center() - p.n * s.radius() + (d * it);
 		return true;
 		return true;
 	}
 	}
 
 
@@ -326,7 +326,7 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	}
 	}
 
 
 	// Check if the int32_tersection point32_t lies inside the triangle
 	// Check if the int32_tersection point32_t lies inside the triangle
-	if (tri.contains_point32_t(intersectionPoint))
+	if (tri.contains_point(intersectionPoint))
 	{
 	{
 		it = spherePlaneIt;
 		it = spherePlaneIt;
 		// intersectionPoint is already returned by the above call to TestDynamicSpherePlane
 		// intersectionPoint is already returned by the above call to TestDynamicSpherePlane
@@ -343,35 +343,35 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 
 
 	// v1
 	// v1
 	a = d.dot(d);
 	a = d.dot(d);
-	b = 2.0 * (d.dot(s.c - tri.v1));
-	c = (tri.v1 - s.c).dot(tri.v1 - s.c) - (s.r * s.r);
+	b = 2.0 * (d.dot(s.center() - tri.m_vertex[0]));
+	c = (tri.m_vertex[0] - s.center()).dot(tri.m_vertex[0] - s.center()) - (s.radius() * s.radius());
 
 
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
 	{
 		it = math::min(x1, it);
 		it = math::min(x1, it);
-		intersectionPoint = tri.v1;
+		intersectionPoint = tri.m_vertex[0];
 		collisionFound = true;
 		collisionFound = true;
 	}
 	}
 
 
 	// v2
 	// v2
-	b = 2.0 * (d.dot(s.c - tri.v2));
-	c = (tri.v2 - s.c).dot(tri.v2 - s.c) - (s.r * s.r);
+	b = 2.0 * (d.dot(s.center() - tri.m_vertex[1]));
+	c = (tri.m_vertex[1] - s.center()).dot(tri.m_vertex[1] - s.center()) - (s.radius() * s.radius());
 
 
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
 	{
 		it = math::min(x1, it);
 		it = math::min(x1, it);
-		intersectionPoint = tri.v2;
+		intersectionPoint = tri.m_vertex[1];
 		collisionFound = true;
 		collisionFound = true;
 	}
 	}
 
 
 	// v3
 	// v3
-	b = 2.0 * (d.dot(s.c - tri.v3));
-	c = (tri.v3 - s.c).dot(tri.v3 - s.c) - (s.r * s.r);
+	b = 2.0 * (d.dot(s.center() - tri.m_vertex[2]));
+	c = (tri.m_vertex[2] - s.center()).dot(tri.m_vertex[2] - s.center()) - (s.radius() * s.radius());
 
 
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
 	{
 		it = math::min(x1, it);
 		it = math::min(x1, it);
-		intersectionPoint = tri.v3;
+		intersectionPoint = tri.m_vertex[2];
 		collisionFound = true;
 		collisionFound = true;
 	}
 	}
 
 
@@ -386,8 +386,8 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	velocitySquaredLength = d.squared_length();
 	velocitySquaredLength = d.squared_length();
 
 
 	// e1
 	// e1
-	edge = tri.v2 - tri.v1;
-	centerToVertex = tri.v1 - s.c;
+	edge = tri.m_vertex[1] - tri.m_vertex[0];
+	centerToVertex = tri.m_vertex[0] - s.center();
 	edgeDotVelocity = edge.dot(d);
 	edgeDotVelocity = edge.dot(d);
 	edgeDotCenterToVertex = edge.dot(centerToVertex);
 	edgeDotCenterToVertex = edge.dot(centerToVertex);
 	edgeSquaredLength = edge.squared_length();
 	edgeSquaredLength = edge.squared_length();
@@ -396,7 +396,7 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	a = edgeSquaredLength * -velocitySquaredLength + edgeDotVelocity * edgeDotVelocity;
 	a = edgeSquaredLength * -velocitySquaredLength + edgeDotVelocity * edgeDotVelocity;
 	b = edgeSquaredLength * (2.0 * d.dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
 	b = edgeSquaredLength * (2.0 * d.dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
 
 
-	c = edgeSquaredLength * ((s.r * s.r) - centerToVertex.squared_length()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
+	c = edgeSquaredLength * ((s.radius() * s.radius()) - centerToVertex.squared_length()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
 
 
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
 	{
@@ -405,14 +405,14 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 		if (f0 >= 0.0 && f0 <= 1.0)
 		if (f0 >= 0.0 && f0 <= 1.0)
 		{
 		{
 			it = math::min(x1, it);
 			it = math::min(x1, it);
-			intersectionPoint = tri.v1 + f0 * edge;
+			intersectionPoint = tri.m_vertex[0] + f0 * edge;
 			collisionFound = true;
 			collisionFound = true;
 		}
 		}
 	}
 	}
 
 
 	// e2
 	// e2
-	edge = tri.v3 - tri.v2;
-	centerToVertex = tri.v2 - s.c;
+	edge = tri.m_vertex[2] - tri.m_vertex[1];
+	centerToVertex = tri.m_vertex[1] - s.center();
 	edgeDotVelocity = edge.dot(d);
 	edgeDotVelocity = edge.dot(d);
 	edgeDotCenterToVertex = edge.dot(centerToVertex);
 	edgeDotCenterToVertex = edge.dot(centerToVertex);
 	edgeSquaredLength = edge.squared_length();
 	edgeSquaredLength = edge.squared_length();
@@ -421,7 +421,7 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	a = edgeSquaredLength * -velocitySquaredLength + edgeDotVelocity * edgeDotVelocity;
 	a = edgeSquaredLength * -velocitySquaredLength + edgeDotVelocity * edgeDotVelocity;
 	b = edgeSquaredLength * (2.0 * d.dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
 	b = edgeSquaredLength * (2.0 * d.dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
 
 
-	c = edgeSquaredLength * ((s.r * s.r) - centerToVertex.squared_length()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
+	c = edgeSquaredLength * ((s.radius() * s.radius()) - centerToVertex.squared_length()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
 
 
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
 	{
@@ -430,14 +430,14 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 		if (f0 >= 0.0 && f0 <= 1.0)
 		if (f0 >= 0.0 && f0 <= 1.0)
 		{
 		{
 			it = math::min(x1, it);
 			it = math::min(x1, it);
-			intersectionPoint = tri.v2 + f0 * edge;
+			intersectionPoint = tri.m_vertex[1] + f0 * edge;
 			collisionFound = true;
 			collisionFound = true;
 		}
 		}
 	}
 	}
 
 
 	// e3
 	// e3
-	edge = tri.v1 - tri.v3;
-	centerToVertex = tri.v3 - s.c;
+	edge = tri.m_vertex[0] - tri.m_vertex[2];
+	centerToVertex = tri.m_vertex[2] - s.center();
 	edgeDotVelocity = edge.dot(d);
 	edgeDotVelocity = edge.dot(d);
 	edgeDotCenterToVertex = edge.dot(centerToVertex);
 	edgeDotCenterToVertex = edge.dot(centerToVertex);
 	edgeSquaredLength = edge.squared_length();
 	edgeSquaredLength = edge.squared_length();
@@ -446,7 +446,7 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 	a = edgeSquaredLength * -velocitySquaredLength + edgeDotVelocity * edgeDotVelocity;
 	a = edgeSquaredLength * -velocitySquaredLength + edgeDotVelocity * edgeDotVelocity;
 	b = edgeSquaredLength * (2.0 * d.dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
 	b = edgeSquaredLength * (2.0 * d.dot(centerToVertex)) - (2.0 * edgeDotVelocity * edgeDotCenterToVertex);
 
 
-	c = edgeSquaredLength * ((s.r * s.r) - centerToVertex.squared_length()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
+	c = edgeSquaredLength * ((s.radius() * s.radius()) - centerToVertex.squared_length()) + (edgeDotCenterToVertex * edgeDotCenterToVertex);
 
 
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	if (math::solve_quadratic_equation(a, b, c, x1, x2))
 	{
 	{
@@ -455,7 +455,7 @@ inline bool Intersection::TestDynamicSphereTriangle(const Sphere& s, const Vec3&
 		if (f0 >= 0.0 && f0 <= 1.0)
 		if (f0 >= 0.0 && f0 <= 1.0)
 		{
 		{
 			it = math::min(x1, it);
 			it = math::min(x1, it);
-			intersectionPoint = tri.v3 + f0 * edge;
+			intersectionPoint = tri.m_vertex[2] + f0 * edge;
 			collisionFound = true;
 			collisionFound = true;
 		}
 		}
 	}
 	}
@@ -471,11 +471,11 @@ inline bool Intersection::TestDynamicSphereSphere(const Sphere& s1, const Vec3&
 	Vec3 d = d2 - d1;
 	Vec3 d = d2 - d1;
 	d.normalize();
 	d.normalize();
 
 
-	const Vec3& cs = s1.c;
-	const Vec3& cm = s2.c;
+	const Vec3& cs = s1.center();
+	const Vec3& cm = s2.center();
 
 
 	Vec3 e = cs - cm;
 	Vec3 e = cs - cm;
-	real r = s1.r + s2.r;
+	real r = s1.radius() + s2.radius();
 
 
 	// If ||e|| < r, int32_tersection occurs at t = 0
 	// If ||e|| < r, int32_tersection occurs at t = 0
 	if (e.length() < r)
 	if (e.length() < r)
@@ -510,17 +510,17 @@ inline bool Intersection::TestDynamicSphereSphere(const Sphere& s1, const Vec3&
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestStaticBoxBox(const Box& b1, const Box& b2)
 inline bool Intersection::TestStaticBoxBox(const Box& b1, const Box& b2)
 {
 {
-	if (b1.min.x > b2.max.x || b1.max.x < b2.min.x)
+	if (b1.min().x > b2.max().x || b1.max().x < b2.min().x)
 	{
 	{
 		return false;
 		return false;
 	}
 	}
 
 
-	if (b1.min.y > b2.max.y || b1.max.y < b2.min.y)
+	if (b1.min().y > b2.max().y || b1.max().y < b2.min().y)
 	{
 	{
 		return false;
 		return false;
 	}
 	}
 
 
-	if (b1.min.z > b2.max.z || b1.max.z < b2.min.z)
+	if (b1.min().z > b2.max().z || b1.max().z < b2.min().z)
 	{
 	{
 		return false;
 		return false;
 	}
 	}
@@ -543,7 +543,7 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 	// If the resulting displacement equals zero, then fallback to static int32_tersection test
 	// If the resulting displacement equals zero, then fallback to static int32_tersection test
 	if (math::equals(d.x, (real)0.0))
 	if (math::equals(d.x, (real)0.0))
 	{
 	{
-		if (b1.min.x > b2.max.x || b1.max.x < b2.min.x)
+		if (b1.min().x > b2.max().x || b1.max().x < b2.min().x)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
@@ -551,7 +551,7 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 
 
 	if (math::equals(d.y, (real)0.0))
 	if (math::equals(d.y, (real)0.0))
 	{
 	{
-		if (b1.min.y > b2.max.y || b1.max.y < b2.min.y)
+		if (b1.min().y > b2.max().y || b1.max().y < b2.min().y)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
@@ -559,7 +559,7 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 
 
 	if (math::equals(d.z, (real)0.0))
 	if (math::equals(d.z, (real)0.0))
 	{
 	{
-		if (b1.min.z > b2.max.z || b1.max.z < b2.min.z)
+		if (b1.min().z > b2.max().z || b1.max().z < b2.min().z)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
@@ -567,16 +567,16 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 
 
 	// Otherwise, compute the enter/leave times aint64_t each axis
 	// Otherwise, compute the enter/leave times aint64_t each axis
 	real oneOverD = (real)(1.0 / d.x);
 	real oneOverD = (real)(1.0 / d.x);
-	tEnterXYZ.x = (b1.min.x - b2.max.x) * oneOverD;
-	tLeaveXYZ.x = (b1.max.x - b2.min.x) * oneOverD;
+	tEnterXYZ.x = (b1.min().x - b2.max().x) * oneOverD;
+	tLeaveXYZ.x = (b1.max().x - b2.min().x) * oneOverD;
 
 
 	oneOverD = (real)(1.0 / d.y);
 	oneOverD = (real)(1.0 / d.y);
-	tEnterXYZ.y = (b1.min.y - b2.max.y) * oneOverD;
-	tLeaveXYZ.y = (b1.max.y - b2.min.y) * oneOverD;
+	tEnterXYZ.y = (b1.min().y - b2.max().y) * oneOverD;
+	tLeaveXYZ.y = (b1.max().y - b2.min().y) * oneOverD;
 
 
 	oneOverD = (real)(1.0 / d.z);
 	oneOverD = (real)(1.0 / d.z);
-	tEnterXYZ.z = (b1.min.z - b2.max.z) * oneOverD;
-	tLeaveXYZ.z = (b1.max.z - b2.min.z) * oneOverD;
+	tEnterXYZ.z = (b1.min().z - b2.max().z) * oneOverD;
+	tLeaveXYZ.z = (b1.max().z - b2.min().z) * oneOverD;
 
 
 	// We must ensure that enter time < leave time
 	// We must ensure that enter time < leave time
 	if (tLeaveXYZ.x < tEnterXYZ.x)
 	if (tLeaveXYZ.x < tEnterXYZ.x)
@@ -612,17 +612,17 @@ inline bool Intersection::TestDynamicBoxBox(const Box& b1, const Vec3& v1, const
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestFrustumSphere(const Frustum& f, const Sphere& s)
 inline bool Intersection::TestFrustumSphere(const Frustum& f, const Sphere& s)
 {
 {
-	if (f.mPlane[0].get_distance_to_point32_t(s.c) < -s.r || f.mPlane[1].get_distance_to_point32_t(s.c) < -s.r)
+	if (f.m_planes[0].distance_to_point(s.center()) < -s.radius() || f.m_planes[1].distance_to_point(s.center()) < -s.radius())
 	{
 	{
 		return false;
 		return false;
 	}
 	}
 
 
-	if (f.mPlane[2].get_distance_to_point32_t(s.c) < -s.r || f.mPlane[3].get_distance_to_point32_t(s.c) < -s.r)
+	if (f.m_planes[2].distance_to_point(s.center()) < -s.radius() || f.m_planes[3].distance_to_point(s.center()) < -s.radius())
 	{
 	{
 		return false;
 		return false;
 	}
 	}
 
 
-	if (f.mPlane[4].get_distance_to_point32_t(s.c) < -s.r || f.mPlane[5].get_distance_to_point32_t(s.c) < -s.r)
+	if (f.m_planes[4].distance_to_point(s.center()) < -s.radius() || f.m_planes[5].distance_to_point(s.center()) < -s.radius())
 	{
 	{
 		return false;
 		return false;
 	}
 	}
@@ -641,7 +641,7 @@ inline bool Intersection::TestFrustumBox(const Frustum& f, const Box& b)
 
 
 		for (uint32_t j = 0; j < 8; j++)
 		for (uint32_t j = 0; j < 8; j++)
 		{
 		{
-			if (f.mPlane[i].get_distance_to_point32_t(b.get_vertex(j)) < 0.0)
+			if (f.m_planes[i].distance_to_point(b.vertex(j)) < 0.0)
 			{
 			{
 				vertexOutCount++;
 				vertexOutCount++;
 			}
 			}
@@ -661,9 +661,9 @@ inline bool Intersection::TestFrustumBox(const Frustum& f, const Box& b)
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline bool Intersection::TestCircleCircle(const Circle& c1, const Circle& c2, Vec2& penetration)
 inline bool Intersection::TestCircleCircle(const Circle& c1, const Circle& c2, Vec2& penetration)
 {
 {
-	Vec2 distance = c1.c - c2.c;
+	Vec2 distance = c1.center() - c2.center();
 	real distanceLen2 = distance.squared_length();
 	real distanceLen2 = distance.squared_length();
-	real radiusSum = c1.r + c2.r;
+	real radiusSum = c1.radius() + c2.radius();
 	if (distanceLen2 > radiusSum*radiusSum)
 	if (distanceLen2 > radiusSum*radiusSum)
 	{
 	{
 		return false;
 		return false;
@@ -671,11 +671,11 @@ inline bool Intersection::TestCircleCircle(const Circle& c1, const Circle& c2, V
 
 
 	if (distanceLen2 < 0.001)
 	if (distanceLen2 < 0.001)
 	{
 	{
-		penetration = Vec2(c1.r, 0.0);
+		penetration = Vec2(c1.radius(), 0.0);
 	}
 	}
 	else
 	else
 	{
 	{
-	  distanceLen2 = math::sqrt(distanceLen2);
+		distanceLen2 = math::sqrt(distanceLen2);
 		penetration = distance * ((radiusSum - distanceLen2) / distanceLen2);
 		penetration = distance * ((radiusSum - distanceLen2) / distanceLen2);
 	}
 	}
 	return true;
 	return true;
@@ -689,11 +689,11 @@ inline bool Intersection::TestDynamicCircleCircle(const Circle& c1, const Vec2&
 	Vec2 d = d2 - d1;
 	Vec2 d = d2 - d1;
 	d.normalize();
 	d.normalize();
 
 
-	const Vec2& cs = c1.c;
-	const Vec2& cm = c2.c;
+	const Vec2& cs = c1.center();
+	const Vec2& cm = c2.center();
 
 
 	Vec2 e = cs - cm;
 	Vec2 e = cs - cm;
-	real r = c1.r + c2.r;
+	real r = c1.radius() + c2.radius();
 
 
 	// If ||e|| < r, int32_tersection occurs at t = 0
 	// If ||e|| < r, int32_tersection occurs at t = 0
 	if (e.length() < r)
 	if (e.length() < r)
@@ -729,8 +729,8 @@ inline bool Intersection::TestDynamicCircleCircle(const Circle& c1, const Vec2&
 inline bool Intersection::TestRectRect(const Rect& r1, const Rect& r2, Vec2& penetration)
 inline bool Intersection::TestRectRect(const Rect& r1, const Rect& r2, Vec2& penetration)
 {
 {
 	//x
 	//x
-	real min1MinusMax2 = r1.min.x - r2.max.x;
-	real min2MinusMax1 = r2.min.x - r1.max.x;
+	real min1MinusMax2 = r1.min().x - r2.max().x;
+	real min2MinusMax1 = r2.min().x - r1.max().x;
 
 
 	if (min1MinusMax2 > min2MinusMax1)
 	if (min1MinusMax2 > min2MinusMax1)
 	{
 	{
@@ -750,8 +750,8 @@ inline bool Intersection::TestRectRect(const Rect& r1, const Rect& r2, Vec2& pen
 	}
 	}
 
 
 	//y
 	//y
-	min1MinusMax2 = r1.min.y - r2.max.y;
-	min2MinusMax1 = r2.min.y - r1.max.y;
+	min1MinusMax2 = r1.min().y - r2.max().y;
+	min2MinusMax1 = r2.min().y - r1.max().y;
 
 
 	if (min1MinusMax2 > min2MinusMax1)
 	if (min1MinusMax2 > min2MinusMax1)
 	{
 	{
@@ -786,30 +786,30 @@ inline bool Intersection::TestRectRect(const Rect& r1, const Rect& r2, Vec2& pen
 inline bool Intersection::TestCircleRect(const Circle& c1, const Rect& r2, Vec2& penetration)
 inline bool Intersection::TestCircleRect(const Circle& c1, const Rect& r2, Vec2& penetration)
 {
 {
 	bool circleIsAtRight;
 	bool circleIsAtRight;
-	if (c1.c.x > (r2.min.x + r2.max.x) / 2)
+	if (c1.center().x > (r2.min().x + r2.max().x) / 2)
 	{
 	{
-		penetration.x = (c1.c.x - c1.r) - r2.max.x;
+		penetration.x = (c1.center().x - c1.radius()) - r2.max().x;
 		circleIsAtRight = true;
 		circleIsAtRight = true;
 	}
 	}
 	else
 	else
 	{
 	{
-		penetration.x = r2.min.x - (c1.c.x + c1.r);
+		penetration.x = r2.min().x - (c1.center().x + c1.radius());
 		circleIsAtRight = false;
 		circleIsAtRight = false;
 	}
 	}
 
 
 	bool circleIsAtTop;
 	bool circleIsAtTop;
-	if (c1.c.y > (r2.min.y + r2.max.y) / 2)
+	if (c1.center().y > (r2.min().y + r2.max().y) / 2)
 	{
 	{
-		penetration.y = (c1.c.y - c1.r) - r2.max.y;
+		penetration.y = (c1.center().y - c1.radius()) - r2.max().y;
 		circleIsAtTop = true;
 		circleIsAtTop = true;
 	}
 	}
 	else
 	else
 	{
 	{
-		penetration.y = r2.min.y - (c1.c.y + c1.r);
+		penetration.y = r2.min().y - (c1.center().y + c1.radius());
 		circleIsAtTop = false;
 		circleIsAtTop = false;
 	}
 	}
 
 
-	if (penetration.x < -c1.r || penetration.y < -c1.r)
+	if (penetration.x < -c1.radius() || penetration.y < -c1.radius())
 	{
 	{
 		if (penetration.y > 0 || penetration.x > 0)
 		if (penetration.y > 0 || penetration.x > 0)
 		{
 		{
@@ -824,7 +824,7 @@ inline bool Intersection::TestCircleRect(const Circle& c1, const Rect& r2, Vec2&
 			penetration.x = 0;
 			penetration.x = 0;
 		}
 		}
 	}
 	}
-	//else if (penetration.y < -c1.r)
+	//else if (penetration.y < -c1.radius())
 	//{
 	//{
 	//	if (penetration.x > 0)
 	//	if (penetration.x > 0)
 	//	{
 	//	{
@@ -834,14 +834,14 @@ inline bool Intersection::TestCircleRect(const Circle& c1, const Rect& r2, Vec2&
 	//}
 	//}
 	else
 	else
 	{
 	{
-		penetration += Vec2(c1.r, c1.r);
+		penetration += Vec2(c1.radius(), c1.radius());
 		real len = math::sqrt(penetration.squared_length());
 		real len = math::sqrt(penetration.squared_length());
-		if (len > c1.r)
+		if (len > c1.radius())
 		{
 		{
 			return false;
 			return false;
 		}
 		}
 		//The - is to point32_t outwards
 		//The - is to point32_t outwards
-		penetration *= - (c1.r - len) / len;
+		penetration *= - (c1.radius() - len) / len;
 	}
 	}
 
 
 	if (circleIsAtRight)
 	if (circleIsAtRight)

+ 22 - 24
src/core/math/Mat3.h

@@ -34,28 +34,26 @@ class Mat4;
 class Quat;
 class Quat;
 class Vec3;
 class Vec3;
 
 
-/**
-	Column major 3x3 matrix.
-
-	The engine uses column vectors for coordinate space transformations
-	so you'll have to specify transformations in reverse order.
-	e.g. (rotation translation vector) will produce the result of first translating
-	and then rotating the vector.
-	Also note that a column major matrix needs to be placed to the left of a
-	vector by matrix multiplication, so, to multiply a vector by a matrix you'll have
-	to write something like: matrix vector. Since we are also using column vectors, inverting
-	the operands would result in an impossible operation.
-
-@verbatim:
-	  X base vector
-		| Y base vector
-		|   | Z base vector
-		|   |   |
-	1 [ Xx  Yx  Zx ]
-	2 | Xy  Yy  Zy |
-	3 [ Xz  Yz  Zz ]
-		1   2   3
-*/
+/// Column major 3x3 matrix.
+/// 
+/// The engine uses column vectors for coordinate space transformations
+/// so you'll have to specify transformations in reverse order.
+/// e.g. (rotation translation vector) will produce the result of first translating
+/// and then rotating the vector.
+/// Also note that a column major matrix needs to be placed to the left of a
+/// vector by matrix multiplication, so, to multiply a vector by a matrix you'll have
+/// to write something like: matrix vector. Since we are also using column vectors, inverting
+/// the operands would result in an impossible operation.
+/// 
+/// @verbatim:
+///   X base vector
+///     | Y base vector
+///     |   | Z base vector
+///     |   |   |
+/// 1 [ Xx  Yx  Zx ]
+/// 2 | Xy  Yy  Zy |
+/// 3 [ Xz  Yz  Zz ]
+///     1   2   3
 class Mat3
 class Mat3
 {
 {
 
 
@@ -107,8 +105,8 @@ public:
 	Vec3				get_scale() const;							//!< Returns a Vec3 containing the matrix's scale portion
 	Vec3				get_scale() const;							//!< Returns a Vec3 containing the matrix's scale portion
 	void				set_scale(const Vec3& scale);				//!< Fills the matrix's scale portion with the values contained in "scale"
 	void				set_scale(const Vec3& scale);				//!< Fills the matrix's scale portion with the values contained in "scale"
 
 
-	real*				to_float_ptr();								//!< Returns the point32_ter to the matrix's data
-	const real*			to_float_ptr() const;						//!< Returns the point32_ter to the matrix's data
+	real*				to_float_ptr();								//!< Returns the pointer to the matrix's data
+	const real*			to_float_ptr() const;						//!< Returns the pointer to the matrix's data
 	Mat4				to_mat4() const;							//!< Returns a 4x4 matrix according to the matrix's rotation portion
 	Mat4				to_mat4() const;							//!< Returns a 4x4 matrix according to the matrix's rotation portion
 	Quat				to_quat() const;							//!< Returns a quaternion according to the matrix's rotation portion
 	Quat				to_quat() const;							//!< Returns a quaternion according to the matrix's rotation portion
 
 

+ 1 - 1
src/core/math/Mat4.cpp

@@ -757,7 +757,7 @@ void Mat4::build_look_at_lh(const Vec3& pos, const Vec3& target, const Vec3& up)
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void Mat4::build_viewpoint32_t_billboard(const Vec3& pos, const Vec3& target, const Vec3& up)
+void Mat4::build_viewpoint_billboard(const Vec3& pos, const Vec3& target, const Vec3& up)
 {
 {
 	Vec3 zAxis = target - pos;
 	Vec3 zAxis = target - pos;
 	zAxis.normalize();
 	zAxis.normalize();

+ 26 - 28
src/core/math/Mat4.h

@@ -35,30 +35,28 @@ class Quat;
 class Vec3;
 class Vec3;
 class Vec4;
 class Vec4;
 
 
-/**
-	Column major 4x4 matrix.
-
-	The engine uses column vectors for coordinate space transformations
-	so you'll have to specify transformations in reverse order.
-	e.g. (rotation * translation * vector) will produce the result of first translating
-	and then rotating the vector.
-	Also note that a column major matrix needs to be placed to the left of a
-	vector by matrix multiplication, so, to multiply a vector by a matrix you'll have
-	to write something like: matrix * vector. Since we are also using column vectors, inverting
-	the operands would result in an impossible operation.
-
-@verbatim:
-	  X base vector
-		| Y base vector
-		|   | Z base vector
-		|   |   | Translation vector
-		|   |   |   |
-	1 [ Xx  Yx  Zx  Tx ]
-	2 | Xy  Yy  Zy  Ty |
-	3 | Xz  Yz  Zz  Tz |
-	4 [ 0   0   0   1  ]
-		1   2   3   4
-*/
+/// Column-major 4x4 matrix.
+/// 
+/// The engine uses column vectors for coordinate space transformations
+/// so you'll have to specify transformations in reverse order.
+/// e.g. (rotation * translation * vector) will produce the result of first translating
+/// and then rotating the vector.
+/// Also note that a column major matrix needs to be placed to the left of a
+/// vector by matrix multiplication, so, to multiply a vector by a matrix you'll have
+/// to write something like: matrix * vector. Since we are also using column vectors, inverting
+/// the operands would result in an impossible operation.
+/// 
+/// @verbatim:
+///   X base vector
+///     | Y base vector
+///     |   | Z base vector
+///     |   |   | Translation vector
+///     |   |   |   |
+/// 1 [ Xx  Yx  Zx  Tx ]
+/// 2 | Xy  Yy  Zy  Ty |
+/// 3 | Xz  Yz  Zz  Tz |
+/// 4 [ 0   0   0   1  ]
+///     1   2   3   4
 class Mat4
 class Mat4
 {
 {
 
 
@@ -107,8 +105,8 @@ public:
 
 
 	void				build_look_at_rh(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Righ-Handed look-at" matrix from a position, a target, and an up vector
 	void				build_look_at_rh(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Righ-Handed look-at" matrix from a position, a target, and an up vector
 	void				build_look_at_lh(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Left-Handed look-at" matrix from a position, a target, and an up vector
 	void				build_look_at_lh(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Left-Handed look-at" matrix from a position, a target, and an up vector
-	void				build_viewpoint32_t_billboard(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Viewpoint32_t-Oriented billboard" matrix which can be used to make an object face a specific point32_t in space
-	void				build_axis_billboard(const Vec3& pos, const Vec3& target, const Vec3& axis);	//!< Builds a "Arbitrary-Axis billboard" matrix which can be used to make an object face a specific point32_t in space
+	void				build_viewpoint_billboard(const Vec3& pos, const Vec3& target, const Vec3& up);	//!< Builds a "Viewpoint-Oriented billboard" matrix which can be used to make an object face a specific point in space
+	void				build_axis_billboard(const Vec3& pos, const Vec3& target, const Vec3& axis);	//!< Builds a "Arbitrary-Axis billboard" matrix which can be used to make an object face a specific point in space
 
 
 	Mat4&				transpose();								//!< Transposes the matrix
 	Mat4&				transpose();								//!< Transposes the matrix
 	Mat4				get_transposed() const;						//!< Returns the transposed of the matrix
 	Mat4				get_transposed() const;						//!< Returns the transposed of the matrix
@@ -124,8 +122,8 @@ public:
 	Vec3				get_scale() const;							//!< Returns a Vec3 containing the matrix's scale portion
 	Vec3				get_scale() const;							//!< Returns a Vec3 containing the matrix's scale portion
 	void				set_scale(const Vec3& scale);				//!< Fills the matrix's scale portion with the values contained in "scale"
 	void				set_scale(const Vec3& scale);				//!< Fills the matrix's scale portion with the values contained in "scale"
 
 
-	real*				to_float_ptr();								//!< Returns the point32_ter to the matrix's data
-	const real*			to_float_ptr() const;						//!< Returns the point32_ter to the matrix's data
+	real*				to_float_ptr();								//!< Returns the pointer to the matrix's data
+	const real*			to_float_ptr() const;						//!< Returns the pointer to the matrix's data
 	Mat3				to_mat3() const;							//!< Returns a 3x3 matrix according to the matrix's rotation portion
 	Mat3				to_mat3() const;							//!< Returns a 3x3 matrix according to the matrix's rotation portion
 	Quat				to_quat() const;							//!< Returns a quaternion according to the matrix's rotation portion
 	Quat				to_quat() const;							//!< Returns a quaternion according to the matrix's rotation portion
 
 

+ 2 - 10
src/core/math/MathUtils.h

@@ -32,18 +32,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 
 #define BIT(i) (1 << i)
 #define BIT(i) (1 << i)
 
 
-#define FLOATSIGNBITSET(f)		((*(const unsigned long *)&(f)) >> 31)
-// #define FLOATSIGNBITNOTSET(f)	((~(*(const unsigned long *)&(f))) >> 31)
-// #define FLOATNOTZERO(f)			((*(const unsigned long *)&(f)) & ~(1<<31) )
-// #define INTSIGNBITSET(i)		(((const unsigned long)(i)) >> 31)
-// #define INTSIGNBITNOTSET(i)		((~((const unsigned long)(i))) >> 31)
-
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	Math utilities.
-*/
+/// Math utilities.
 namespace math
 namespace math
 {
 {
 
 
@@ -94,7 +86,7 @@ real			acos(real x);					//!< Returns the arc cosine of @x
 real			tan(real x);					//!< Returns the tangent of @x
 real			tan(real x);					//!< Returns the tangent of @x
 real			atan2(real y, real x);			//!< Returns the arc tangent of @y/@x
 real			atan2(real y, real x);			//!< Returns the arc tangent of @y/@x
 real			abs(real x);					//!< Returns the absolute value of @x
 real			abs(real x);					//!< Returns the absolute value of @x
-real			fmod(real n, real d);			//!< Returns the realing-point32_t remainder of numerator/denominator
+real			fmod(real n, real d);			//!< Returns the realing-point remainder of numerator/denominator
 
 
 
 
 				//! Returns true if there are solutions and puts them in 'x1' and 'x2' (x1 <= x2)
 				//! Returns true if there are solutions and puts them in 'x1' and 'x2' (x1 <= x2)

+ 2 - 2
src/core/math/Plane.cpp

@@ -74,13 +74,13 @@ Plane& Plane::normalize()
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-real Plane::get_distance_to_point32_t(const Vec3& p) const
+real Plane::distance_to_point(const Vec3& p) const
 {
 {
 	return n.dot(p) + d;
 	return n.dot(p) + d;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-bool Plane::contains_point32_t(const Vec3& p) const
+bool Plane::contains_point(const Vec3& p) const
 {
 {
 	return math::equals(n.dot(p) + d, (real)0.0);
 	return math::equals(n.dot(p) + d, (real)0.0);
 }
 }

+ 8 - 8
src/core/math/Plane.h

@@ -32,12 +32,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	3D Plane.
-
-	The form is ax + by + cz + d = 0
-	where: d = -n.Dot(p)
-*/
+/// 3D Plane.
+/// 
+/// The form is ax + by + cz + d = 0
+/// where: d = -n.Dot(p)
 class Plane
 class Plane
 {
 {
 public:
 public:
@@ -45,6 +43,8 @@ public:
 	Vec3				n;
 	Vec3				n;
 	real				d;
 	real				d;
 
 
+public:
+
 						Plane();									//!< Constructor, does nothing for efficiency
 						Plane();									//!< Constructor, does nothing for efficiency
 						Plane(const Plane& p);						//!< Copy constructor
 						Plane(const Plane& p);						//!< Copy constructor
 						Plane(const Vec3& normal, real dist);		//!< Constructs from a normal and distance factor
 						Plane(const Vec3& normal, real dist);		//!< Constructs from a normal and distance factor
@@ -52,8 +52,8 @@ public:
 
 
 	Plane&				normalize();								//!< Normalizes the plane
 	Plane&				normalize();								//!< Normalizes the plane
 
 
-	real				get_distance_to_point32_t(const Vec3& p) const;	//!< Returns the signed distance between point32_t "p" and the plane
-	bool				contains_point32_t(const Vec3& p) const;		//!< Returns whether the plane contains the point32_t
+	real				distance_to_point(const Vec3& p) const;		//!< Returns the signed distance between point @p and the plane
+	bool				contains_point(const Vec3& p) const;		//!< Returns whether the plane contains the point
 
 
 	static const Plane	ZERO;
 	static const Plane	ZERO;
 	static const Plane	XAXIS;
 	static const Plane	XAXIS;

+ 4 - 4
src/core/math/Point2.h

@@ -34,14 +34,14 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	2D point32_t.
-*/
+/// 2D point.
 class Point2
 class Point2
 {
 {
 public:
 public:
 
 
-	int32_t						x, y;
+	int32_t					x, y;
+
+public:
 
 
 							Point2();							//!< Constructor, does nothing for efficiency
 							Point2();							//!< Constructor, does nothing for efficiency
 							Point2(int32_t nx, int32_t ny);		//! Constructs from two components
 							Point2(int32_t nx, int32_t ny);		//! Constructs from two components

+ 13 - 13
src/core/math/Quat.h

@@ -34,19 +34,17 @@ namespace crown
 class Mat3;
 class Mat3;
 class Mat4;
 class Mat4;
 
 
-/**
-	Quaternion.
-
-@Note:
-	This implementation uses the standard quaternion
-	multiplication equation, so, the order of multiplication
-	for multiple rotations is in a reverse fashion:
-	p' = qpq^-1 where p is the point32_t and q the rotation quaternion
-
-	p' = (ba)p(ba)^-1 where p is the point32_t and (ba) the concatenation of two successive rotations
-	In this case, the point32_t p is first rotated by the quaternion a and then by the quaternion b.
-	The transformation order is reversed.
-*/
+/// Quaternion.
+///
+/// @Note:
+/// This implementation uses the standard quaternion
+/// multiplication equation, so, the order of multiplication
+/// for multiple rotations is in a reverse fashion:
+/// p' = qpq^-1 where p is the point and q the rotation quaternion
+/// 
+/// p' = (ba)p(ba)^-1 where p is the point and (ba) the concatenation of two successive rotations
+/// In this case, the point p is first rotated by the quaternion a and then by the quaternion b.
+/// The transformation order is reversed.
 class Quat
 class Quat
 {
 {
 public:
 public:
@@ -54,6 +52,8 @@ public:
 	Vec3		v;
 	Vec3		v;
 	real		w;
 	real		w;
 
 
+public:
+
 				Quat();								//!< Constructor
 				Quat();								//!< Constructor
 				Quat(real angle, const Vec3& v);	//!< Builds the quaternion from an angle and a vector
 				Quat(real angle, const Vec3& v);	//!< Builds the quaternion from an angle and a vector
 				~Quat();							//!< Destructor
 				~Quat();							//!< Destructor

+ 3 - 2
src/core/math/Random.h

@@ -35,12 +35,13 @@ class Random
 {
 {
 public:
 public:
 
 
+	/// Initializes the generator with the given @seed.
 				Random(int32_t seed);
 				Random(int32_t seed);
 
 
-	/// Returns a pseudo-random int32_teger in the range [0, 32767].
+	/// Returns a pseudo-random integer in the range [0, 32767].
 	int32_t		integer();
 	int32_t		integer();
 
 
-	/// Returns a pseudo-random int32_teger in the range [0, max).
+	/// Returns a pseudo-random integer in the range [0, max).
 	int32_t		integer(int32_t max);
 	int32_t		integer(int32_t max);
 
 
 	/// Returns a pseudo-random float in the range [0.0, 1.0].
 	/// Returns a pseudo-random float in the range [0.0, 1.0].

+ 43 - 15
src/core/math/Ray.h

@@ -26,29 +26,33 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 #pragma once
 
 
 #include "Types.h"
 #include "Types.h"
-#include "Box.h"
-#include "Plane.h"
-#include "Sphere.h"
 #include "Vec3.h"
 #include "Vec3.h"
 
 
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	3D Ray.
-
-	Defined by the origin and the unit-length direction vector.
-*/
+/// 3D Ray.
+///
+/// Defined by the origin and the unit-length direction vector.
 class Ray
 class Ray
 {
 {
 public:
 public:
 
 
-	Vec3	origin;
-	Vec3	direction;
+	/// Does nothing for efficiency.
+					Ray();
+					Ray(const Vec3& origin, const Vec3& direction);
+					Ray(const Ray& ray);
+
+	const Vec3&		origin() const;
+	const Vec3&		direction() const;
 
 
-			Ray();					//!< Constructor, does nothing for efficiency
-			Ray(const Ray& ray);	//!< Copy constructor
-			~Ray();					//!< Destructor
+	void			set_origin(const Vec3& origin);
+	void			set_direction(const Vec3& direction);
+
+private:
+
+	Vec3			m_origin;
+	Vec3			m_direction;
 };
 };
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -57,13 +61,37 @@ inline Ray::Ray()
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Ray::Ray(const Ray& ray) : origin(ray.origin), direction(ray.direction)
+inline Ray::Ray(const Vec3& origin, const Vec3& direction) : m_origin(origin), m_direction(direction)
+{
+}
+
+//-----------------------------------------------------------------------------
+inline Ray::Ray(const Ray& ray) : m_origin(ray.m_origin), m_direction(ray.m_direction)
+{
+}
+
+//-----------------------------------------------------------------------------
+inline const Vec3& Ray::origin() const
+{
+	return m_origin;
+}
+
+//-----------------------------------------------------------------------------
+inline const Vec3& Ray::direction() const
+{
+	return m_direction;
+}
+
+//-----------------------------------------------------------------------------
+inline void Ray::set_origin(const Vec3& origin)
 {
 {
+	m_origin = origin;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Ray::~Ray()
+inline void Ray::set_direction(const Vec3& direction)
 {
 {
+	m_direction = direction;
 }
 }
 
 
 } // namespace crown
 } // namespace crown

+ 6 - 3
src/core/math/Shape.cpp

@@ -28,18 +28,21 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
+//-----------------------------------------------------------------------------
 Shape::Shape(ShapeType type):
 Shape::Shape(ShapeType type):
-	mType(type)
+	m_type(type)
 {
 {
 }
 }
 
 
+//-----------------------------------------------------------------------------
 Shape::~Shape()
 Shape::~Shape()
 {
 {
 }
 }
 
 
-ShapeType Shape::get_shape_type()
+//-----------------------------------------------------------------------------
+ShapeType Shape::type()
 {
 {
-	return mType;
+	return m_type;
 }
 }
 
 
 }
 }

+ 4 - 5
src/core/math/Shape.h

@@ -53,13 +53,12 @@ public:
 					Shape(ShapeType type);
 					Shape(ShapeType type);
 					~Shape();
 					~Shape();
 
 
-	ShapeType		get_shape_type();
+	ShapeType		type();
 
 
 private:
 private:
 
 
-	ShapeType		mType;
-	void*			mShape;
+	ShapeType		m_type;
+	void*			m_shape;
 };
 };
 
 
-}
-
+} // namespace crown

+ 45 - 36
src/core/math/Triangle.h

@@ -32,38 +32,52 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	3D Triangle.
 
 
-	Used mainly for collision detection.
-*/
+///	3D Triangle.
+///
+/// Used mainly for collision detection.
 class Triangle
 class Triangle
 {
 {
 public:
 public:
 
 
-	Vec3		v1, v2, v3;				//!< Vertices, CCW order
+	/// Does nothing for efficiency.
+				Triangle();
+				Triangle(const Vec3& v1, const Vec3& v2, const Vec3& v3);
+				~Triangle();
+
+	real		area() const;
+
+	/// Returns the center of gravity (a.k.a. "centroid").
+	Vec3		centroid() const;
+
+	/// Returns the barycentric coordinates of point @p in respect to the triangle.
+	Vec3		barycentric_coords(const Vec3& p) const;
 
 
-				Triangle();				//!< Constructor
-				Triangle(const Vec3& nv1, const Vec3& nv2, const Vec3& nv3);	//!< Constructor
-				~Triangle();			//!< Destructor
+	/// Returns whether the triangle contains the @p point.
+	bool		contains_point(const Vec3& p) const;
 
 
-	real		get_area() const;		//!< Returns the area
-	Vec3		get_centroid() const;	//!< Returns the center of gravity (a.k.a. centroid.)
-	Vec3		get_barycentric_coords(const Vec3& p) const;	//!< Returns the barycentric coordinates of point32_t "p"
+	/// Returns the plane containing the triangle.
+	Plane		to_plane() const;
 
 
-	bool		contains_point32_t(const Vec3& p) const;		//!< Returns whether the triangle contains the "p" point32_t
+private:
 
 
-	Plane		to_plane() const;		//!< Returns the plane containing the triangle
+	// Vertices in CCW order
+	Vec3		m_vertex[3];
+
+	friend class Intersection;
 };
 };
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Triangle::Triangle() : v1(Vec3::ZERO), v2(Vec3::ZERO), v3(Vec3::ZERO)
+inline Triangle::Triangle()
 {
 {
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Triangle::Triangle(const Vec3& nv1, const Vec3& nv2, const Vec3& nv3) : v1(nv1), v2(nv2), v3(nv3)
+inline Triangle::Triangle(const Vec3& v1, const Vec3& v2, const Vec3& v3)
 {
 {
+	m_vertex[0] = v1;
+	m_vertex[1] = v2;
+	m_vertex[2] = v3;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -72,31 +86,27 @@ inline Triangle::~Triangle()
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline real Triangle::get_area() const
+inline real Triangle::area() const
 {
 {
-	return ((v2 - v1).cross(v3 - v1)).length() * (real)0.5;
+	return ((m_vertex[1] - m_vertex[0]).cross(m_vertex[2] - m_vertex[0])).length() * (real)0.5;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Vec3 Triangle::get_centroid() const
+inline Vec3 Triangle::centroid() const
 {
 {
-	return (v1 + v2 + v3) * math::ONE_OVER_THREE;
+	return (m_vertex[0] + m_vertex[1] + m_vertex[2]) * math::ONE_OVER_THREE;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline Vec3 Triangle::get_barycentric_coords(const Vec3& p) const
+inline Vec3 Triangle::barycentric_coords(const Vec3& p) const
 {
 {
-//	Vec3 e1 = v1 - v3;
-//	Vec3 e2 = v2 - v1;
-//	Vec3 e3 = v3 - v2;
-
-	Vec3 e1 = v3 - v2;
-	Vec3 e2 = v1 - v3;
-	Vec3 e3 = v2 - v1;
+	Vec3 e1 = m_vertex[2] - m_vertex[1];
+	Vec3 e2 = m_vertex[0] - m_vertex[2];
+	Vec3 e3 = m_vertex[1] - m_vertex[0];
 
 
-	Vec3 d1 = p - v1;
-	Vec3 d2 = p - v2;
-	Vec3 d3 = p - v3;
+	Vec3 d1 = p - m_vertex[0];
+	Vec3 d2 = p - m_vertex[1];
+	Vec3 d3 = p - m_vertex[2];
 
 
 	Vec3 n = e1.cross(e2) / e1.cross(e2).length();
 	Vec3 n = e1.cross(e2) / e1.cross(e2).length();
 
 
@@ -113,9 +123,9 @@ inline Vec3 Triangle::get_barycentric_coords(const Vec3& p) const
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-inline bool Triangle::contains_point32_t(const Vec3& p) const
+inline bool Triangle::contains_point(const Vec3& p) const
 {
 {
-	Vec3 bc = get_barycentric_coords(p);
+	Vec3 bc = barycentric_coords(p);
 
 
 	if (bc.x < 0.0 || bc.y < 0.0 || bc.z < 0.0)
 	if (bc.x < 0.0 || bc.y < 0.0 || bc.z < 0.0)
 	{
 	{
@@ -128,14 +138,13 @@ inline bool Triangle::contains_point32_t(const Vec3& p) const
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 inline Plane Triangle::to_plane() const
 inline Plane Triangle::to_plane() const
 {
 {
-	Vec3 e1 = v3 - v2;
-	Vec3 e2 = v2 - v1;
+	Vec3 e1 = m_vertex[2] - m_vertex[1];
+	Vec3 e2 = m_vertex[1] - m_vertex[0];
 
 
 	Vec3 n = e2.cross(e1).normalize();
 	Vec3 n = e2.cross(e1).normalize();
-	real d = -n.dot(v1);
+	real d = -n.dot(m_vertex[0]);
 
 
 	return Plane(n, d);
 	return Plane(n, d);
 }
 }
 
 
 } // namespace crown
 } // namespace crown
-

+ 4 - 4
src/core/math/Vec2.h

@@ -32,7 +32,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-//!< 2D column vector
+/// 2D column vector.
 class Vec2
 class Vec2
 {
 {
 public:
 public:
@@ -46,8 +46,8 @@ public:
 						Vec2(const Vec2& a);					//!< Copy constructor
 						Vec2(const Vec2& a);					//!< Copy constructor
 						~Vec2();								//!< Destructor
 						~Vec2();								//!< Destructor
 
 
-	real				operator[](uint32_t i) const;				//!< Random access by index
-	real&				operator[](uint32_t i);						//!< Random access by index
+	real				operator[](uint32_t i) const;			//!< Random access by index
+	real&				operator[](uint32_t i);					//!< Random access by index
 
 
 	Vec2				operator+(const Vec2& a) const;			//!< Addition
 	Vec2				operator+(const Vec2& a) const;			//!< Addition
 	Vec2&				operator+=(const Vec2& a);				//!< Addition
 	Vec2&				operator+=(const Vec2& a);				//!< Addition
@@ -57,7 +57,7 @@ public:
 	Vec2&				operator*=(real k);						//!< Multiplication by scalar
 	Vec2&				operator*=(real k);						//!< Multiplication by scalar
 	Vec2				operator/(real k) const;				//!< Division by scalar
 	Vec2				operator/(real k) const;				//!< Division by scalar
 	Vec2&				operator/=(real k);						//!< Division by scalar
 	Vec2&				operator/=(real k);						//!< Division by scalar
-	real				dot(const Vec2& a) const;				//!< dot product
+	real				dot(const Vec2& a) const;				//!< Dot product
 
 
 	friend Vec2			operator*(real k, const Vec2& a);		//!< For simmetry
 	friend Vec2			operator*(real k, const Vec2& a);		//!< For simmetry
 
 

+ 5 - 7
src/core/math/Vec3.h

@@ -33,9 +33,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	3D column vector.
-*/
+/// 3D column vector.
 class Vec3
 class Vec3
 {
 {
 public:
 public:
@@ -49,8 +47,8 @@ public:
 						Vec3(const Vec3& a);					//!< Copy constructor
 						Vec3(const Vec3& a);					//!< Copy constructor
 						~Vec3();								//!< Destructor
 						~Vec3();								//!< Destructor
 
 
-	real				operator[](uint32_t i) const;				//!< Random access by index
-	real&				operator[](uint32_t i);						//!< Random access by index
+	real				operator[](uint32_t i) const;			//!< Random access by index
+	real&				operator[](uint32_t i);					//!< Random access by index
 
 
 	Vec3				operator+(const Vec3& a) const;			//!< Addition
 	Vec3				operator+(const Vec3& a) const;			//!< Addition
 	Vec3&				operator+=(const Vec3& a);				//!< Addition
 	Vec3&				operator+=(const Vec3& a);				//!< Addition
@@ -60,8 +58,8 @@ public:
 	Vec3&				operator*=(real k);						//!< Multiplication by scalar
 	Vec3&				operator*=(real k);						//!< Multiplication by scalar
 	Vec3				operator/(real k) const;				//!< Division by scalar
 	Vec3				operator/(real k) const;				//!< Division by scalar
 	Vec3&				operator/=(real k);						//!< Division by scalar
 	Vec3&				operator/=(real k);						//!< Division by scalar
-	real				dot(const Vec3& a) const;				//!< dot product
-	Vec3				cross(const Vec3& a) const;				//!< cross product
+	real				dot(const Vec3& a) const;				//!< Dot product
+	Vec3				cross(const Vec3& a) const;				//!< Cross product
 
 
 	friend Vec3			operator*(real k, const Vec3& a);		//!< For simmetry
 	friend Vec3			operator*(real k, const Vec3& a);		//!< For simmetry
 
 

+ 4 - 6
src/core/math/Vec4.h

@@ -32,9 +32,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-/**
-	4D column vector.
-*/
+/// 4D column vector.
 class Vec4
 class Vec4
 {
 {
 public:
 public:
@@ -48,8 +46,8 @@ public:
 						Vec4(const Vec4& a);						//!< Copy constructor
 						Vec4(const Vec4& a);						//!< Copy constructor
 						~Vec4();									//!< Destructor
 						~Vec4();									//!< Destructor
 
 
-	real				operator[](uint32_t i) const;					//!< Random access by index
-	real&				operator[](uint32_t i);							//!< Random access by index
+	real				operator[](uint32_t i) const;				//!< Random access by index
+	real&				operator[](uint32_t i);						//!< Random access by index
 
 
 	Vec4				operator+(const Vec4& a) const;				//!< Addition
 	Vec4				operator+(const Vec4& a) const;				//!< Addition
 	Vec4&				operator+=(const Vec4& a);					//!< Addition
 	Vec4&				operator+=(const Vec4& a);					//!< Addition
@@ -59,7 +57,7 @@ public:
 	Vec4&				operator*=(real k);							//!< Multiplication by scalar
 	Vec4&				operator*=(real k);							//!< Multiplication by scalar
 	Vec4				operator/(real k) const;					//!< Division by scalar
 	Vec4				operator/(real k) const;					//!< Division by scalar
 	Vec4&				operator/=(real k);							//!< Division by scalar
 	Vec4&				operator/=(real k);							//!< Division by scalar
-	real				dot(const Vec4& a) const;					//!< dot product
+	real				dot(const Vec4& a) const;					//!< Dot product
 
 
 	friend Vec4			operator*(real k, const Vec4& a);			//!< For simmetry
 	friend Vec4			operator*(real k, const Vec4& a);			//!< For simmetry