Просмотр исходного кода

Switch boundig volumes to underscore_notation

taylor001 13 лет назад
Родитель
Сommit
37413722a6
8 измененных файлов с 135 добавлено и 135 удалено
  1. 36 36
      src/core/bv/Box.h
  2. 2 2
      src/core/bv/Circle.cpp
  3. 12 12
      src/core/bv/Circle.h
  4. 26 26
      src/core/bv/Frustum.cpp
  5. 4 4
      src/core/bv/Frustum.h
  6. 14 14
      src/core/bv/Rect.cpp
  7. 19 19
      src/core/bv/Rect.h
  8. 22 22
      src/core/bv/Sphere.h

+ 36 - 36
src/core/bv/Box.h

@@ -53,27 +53,27 @@ public:
 					Box(const Box& box);									//!< Copy constructor
 					~Box();													//!< Destructor
 
-	const Vec3&		GetMin() const;											//!< Returns the "min" corner
-	const Vec3&		GetMax() const;											//!< Returns the "max" corner
-	void			SetMin(const Vec3& min);								//!< Sets the "min" corner
-	void			SetMax(const Vec3& max);								//!< Sets the "max" corner
+	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			GetCenter() const;										//!< Returns the center
-	real			GetRadius() const;										//!< Returns the radius
-	real			GetVolume() const;										//!< Returns the volume
+	Vec3			get_center() const;										//!< Returns the center
+	real			get_radius() const;										//!< Returns the radius
+	real			get_volume() const;										//!< Returns the volume
 
-	void			AddPoint(const Vec3& p);								//!< Adds a point to the aabb
-	void			AddBox(const Box& box);									//!< Adds a Box to the aabb
+	void			add_point(const Vec3& p);								//!< Adds a point to the aabb
+	void			add_box(const Box& box);								//!< Adds a Box to the aabb
 
-	bool			ContainsPoint(const Vec3& p) const;						//!< Returns whether point "p" is contained
+	bool			contains_point(const Vec3& p) const;					//!< Returns whether point "p" is contained
 
-	Vec3			GetVertex(uint index) const;							//!< Returns a box's vertex
-	void			GetTransformed(const Mat4& mat, Box& result) const;		//!< Returns the box trasformed according to "mat" matrix
+	Vec3			get_vertex(uint index) const;							//!< Returns a box's vertex
+	void			get_transformed(const Mat4& mat, Box& result) const;	//!< Returns the box trasformed according to "mat" matrix
 
-	void			ToVertices(Vec3 v[8]) const;							//!< Returns the eight box's vertices
-	Sphere			ToSphere() const;										//!< Returns as a sphere
+	void			to_vertices(Vec3 v[8]) const;							//!< Returns the eight box's vertices
+	Sphere			to_sphere() const;										//!< Returns as a sphere
 
-	void			Zero();													//!< Sets min and max to zero
+	void			zero();													//!< Sets min and max to zero
 };
 
 //-----------------------------------------------------------------------------
@@ -97,31 +97,31 @@ inline Box::~Box()
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec3& Box::GetMin() const
+inline const Vec3& Box::get_min() const
 {
 	return min;
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::SetMin(const Vec3& min)
+inline void Box::set_min(const Vec3& min)
 {
 	this->min = min;
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec3& Box::GetMax() const
+inline const Vec3& Box::get_max() const
 {
 	return max;
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::SetMax(const Vec3& max)
+inline void Box::set_max(const Vec3& max)
 {
 	this->max = max;
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::AddPoint(const Vec3& p)
+inline void Box::add_point(const Vec3& p)
 {
 	if (p.x < min.x)
 	{
@@ -155,7 +155,7 @@ inline void Box::AddPoint(const Vec3& p)
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::AddBox(const Box& box)
+inline void Box::add_box(const Box& box)
 {
 	if (box.min.x < min.x)
 	{
@@ -189,26 +189,26 @@ inline void Box::AddBox(const Box& box)
 }
 
 //-----------------------------------------------------------------------------
-inline bool Box::ContainsPoint(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);
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Box::GetCenter() const
+inline Vec3 Box::get_center() const
 {
 	return (min + max) * 0.5;
 }
 
 //-----------------------------------------------------------------------------
-inline real Box::GetRadius() const
+inline real Box::get_radius() const
 {
-	return (max - (min + max) * 0.5).GetLength();
+	return (max - (min + max) * 0.5).length();
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::ToVertices(Vec3 v[8]) const
+inline void Box::to_vertices(Vec3 v[8]) const
 {
 	// 7 ---- 6
 	// |      |
@@ -253,7 +253,7 @@ inline void Box::ToVertices(Vec3 v[8]) const
 }
 
 //-----------------------------------------------------------------------------
-inline Vec3 Box::GetVertex(uint index) const
+inline Vec3 Box::get_vertex(uint index) const
 {
 	assert(index < 8);
 
@@ -279,38 +279,38 @@ inline Vec3 Box::GetVertex(uint index) const
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::GetTransformed(const Mat4& mat, Box& result) const
+inline void Box::get_transformed(const Mat4& mat, Box& result) const
 {
 	Vec3 vertices[8];
 
-	ToVertices(vertices);
+	to_vertices(vertices);
 
 	result.min = result.max = mat * vertices[0];
 
 	for (uint i = 1; i < 8; i++)
 	{
 		vertices[i] = mat * vertices[i];
-		result.AddPoint(vertices[i]);
+		result.add_point(vertices[i]);
 	}
 }
 
 //-----------------------------------------------------------------------------
-inline real Box::GetVolume() const
+inline real Box::get_volume() const
 {
 	return (max.x - min.x) * (max.y - min.y) * (max.z - min.z);
 }
 
 //-----------------------------------------------------------------------------
-inline void Box::Zero()
+inline void Box::zero()
 {
-	min.Zero();
-	max.Zero();
+	min.zero();
+	max.zero();
 }
 
 //-----------------------------------------------------------------------------
-inline Sphere Box::ToSphere() const
+inline Sphere Box::to_sphere() const
 {
-	return Sphere(GetCenter(), GetRadius());
+	return Sphere(get_center(), get_radius());
 }
 
 } // namespace Crown

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

@@ -29,11 +29,11 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace Crown
 {
 
-Rect Circle::ToRect() const
+Rect Circle::to_rect() const
 {
 	Rect b;
 
-	b.SetFromCenterAndDimensions(c, r * 2.0, r * 2.0);
+	b.set_from_center_and_dimensions(c, r * 2.0, r * 2.0);
 
 	return b;
 }

+ 12 - 12
src/core/bv/Circle.h

@@ -52,14 +52,14 @@ public:
 					Circle(const Circle& circle);				//!< Copy constructor
 					~Circle();									//!< Destructor
 
-	const Vec2&		GetCenter() const;							//!< Returns the center
-	real			GetRadius() const;							//!< Returns the radius
-	void			SetCenter(const Vec2& center);				//!< Sets the center
-	void			SetRadius(real radius);						//!< Sets the radius
+	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
 
-	real			GetArea() const;							//!< Returns the area
+	real			get_area() const;							//!< Returns the area
 
-	Rect			ToRect() const;								//!< Returns the equivalent rect
+	Rect			to_rect() const;							//!< Returns the equivalent rect
 };
 
 //-----------------------------------------------------------------------------
@@ -83,33 +83,33 @@ inline Circle::~Circle()
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec2& Circle::GetCenter() const
+inline const Vec2& Circle::get_center() const
 {
 	return c;
 }
 
 //-----------------------------------------------------------------------------
-inline real Circle::GetRadius() const
+inline real Circle::get_radius() const
 {
 	return r;
 }
 
 //-----------------------------------------------------------------------------
-inline void Circle::SetCenter(const Vec2& center)
+inline void Circle::set_center(const Vec2& center)
 {
 	c = center;
 }
 
 //-----------------------------------------------------------------------------
-inline void Circle::SetRadius(real radius)
+inline void Circle::set_radius(real radius)
 {
 	r = radius;
 }
 
 //-----------------------------------------------------------------------------
-inline real Circle::GetArea() const
+inline real Circle::get_area() const
 {
-	return r * r * Math::PI;
+	return r * r * math::PI;
 }
 
 } // namespace Crown

+ 26 - 26
src/core/bv/Frustum.cpp

@@ -58,20 +58,20 @@ Frustum::~Frustum()
 }
 
 //-----------------------------------------------------------------------------
-bool Frustum::ContainsPoint(const Vec3& point) const
+bool Frustum::contains_point(const Vec3& point) const
 {
-	if (mPlane[FP_LEFT].GetDistanceToPoint(point) < 0.0) return false;
-	if (mPlane[FP_RIGHT].GetDistanceToPoint(point) < 0.0) return false;
-	if (mPlane[FP_BOTTOM].GetDistanceToPoint(point) < 0.0) return false;
-	if (mPlane[FP_TOP].GetDistanceToPoint(point) < 0.0) return false;
-	if (mPlane[FP_NEAR].GetDistanceToPoint(point) < 0.0) return false;
-	if (mPlane[FP_FAR].GetDistanceToPoint(point) < 0.0) return false;
+	if (mPlane[FP_LEFT].get_distance_to_point(point) < 0.0) return false;
+	if (mPlane[FP_RIGHT].get_distance_to_point(point) < 0.0) return false;
+	if (mPlane[FP_BOTTOM].get_distance_to_point(point) < 0.0) return false;
+	if (mPlane[FP_TOP].get_distance_to_point(point) < 0.0) return false;
+	if (mPlane[FP_NEAR].get_distance_to_point(point) < 0.0) return false;
+	if (mPlane[FP_FAR].get_distance_to_point(point) < 0.0) return false;
 
 	return true;
 }
 
 //-----------------------------------------------------------------------------
-Vec3 Frustum::GetVertex(uint index) const
+Vec3 Frustum::get_vertex(uint index) const
 {
 	// 0 = Near bottom left
 	// 1 = Near bottom right
@@ -110,7 +110,7 @@ Vec3 Frustum::GetVertex(uint index) const
 }
 
 //-----------------------------------------------------------------------------
-void Frustum::FromMatrix(const Mat4& m)
+void Frustum::from_matrix(const Mat4& m)
 {
 	// Left plane
 	mPlane[FP_LEFT].n.x		= m.m[3] + m.m[0];
@@ -148,28 +148,28 @@ void Frustum::FromMatrix(const Mat4& m)
 	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();
+	mPlane[FP_LEFT].normalize();
+	mPlane[FP_RIGHT].normalize();
+	mPlane[FP_BOTTOM].normalize();
+	mPlane[FP_TOP].normalize();
+	mPlane[FP_NEAR].normalize();
+	mPlane[FP_FAR].normalize();
 }
 
 //-----------------------------------------------------------------------------
-Box Frustum::ToBox() const
+Box Frustum::to_box() const
 {
 	Box tmp;
-	tmp.Zero();
-
-	tmp.AddPoint(this->GetVertex(0));
-	tmp.AddPoint(this->GetVertex(1));
-	tmp.AddPoint(this->GetVertex(2));
-	tmp.AddPoint(this->GetVertex(3));
-	tmp.AddPoint(this->GetVertex(4));
-	tmp.AddPoint(this->GetVertex(5));
-	tmp.AddPoint(this->GetVertex(6));
-	tmp.AddPoint(this->GetVertex(7));
+	tmp.zero();
+
+	tmp.add_point(this->get_vertex(0));
+	tmp.add_point(this->get_vertex(1));
+	tmp.add_point(this->get_vertex(2));
+	tmp.add_point(this->get_vertex(3));
+	tmp.add_point(this->get_vertex(4));
+	tmp.add_point(this->get_vertex(5));
+	tmp.add_point(this->get_vertex(6));
+	tmp.add_point(this->get_vertex(7));
 
 	return tmp;
 }

+ 4 - 4
src/core/bv/Frustum.h

@@ -57,12 +57,12 @@ public:
 				Frustum(const Frustum& frustum);		//!< Copy constructor
 				~Frustum();								//!< Destructor
 
-	bool		ContainsPoint(const Vec3& point) const;	//!< Returns true if point intersects the frustum
-	Vec3		GetVertex(uint index) const;			//!< Returns one of the eight frustum's corners
+	bool		contains_point(const Vec3& point) const;	//!< Returns true if point intersects the frustum
+	Vec3		get_vertex(uint index) const;			//!< Returns one of the eight frustum's corners
 
-	void		FromMatrix(const Mat4& m);				//!< Builds the view frustum according to the matrix m
+	void		from_matrix(const Mat4& m);				//!< Builds the view frustum according to the matrix m
 
-	Box			ToBox() const;							//!< Returns a Box containing the frustum volume
+	Box			to_box() const;							//!< Returns a Box containing the frustum volume
 };
 
 } // namespace Crown

+ 14 - 14
src/core/bv/Rect.cpp

@@ -30,23 +30,23 @@ namespace Crown
 {
 
 //-----------------------------------------------------------------------------
-bool Rect::ContainsPoint(const Vec2& point) const
+bool Rect::contains_point(const Vec2& point) const
 {
 	return (point.x >= min.x && point.y >= min.y &&
 			point.x <= max.x && point.y <= max.y);
 }
 
 //-----------------------------------------------------------------------------
-bool Rect::IntersectsRect(const Rect& Rect) const
+bool Rect::intersects_rect(const Rect& Rect) const
 {
-	//return (ContainsPoint(Rect.min) || ContainsPoint(Rect.max));
+	//return (contains_point(Rect.min) || contains_point(Rect.max));
 	if (Rect.min.x > max.x || Rect.max.x < min.x || Rect.min.y > max.y || Rect.max.y < min.y)
 		return false;
 	return true;
 }
 
 //-----------------------------------------------------------------------------
-void Rect::SetFromCenterAndDimensions(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);
@@ -55,7 +55,7 @@ void Rect::SetFromCenterAndDimensions(Vec2 center, real width, real height)
 }
 
 //-----------------------------------------------------------------------------
-void Rect::GetVertices(Vec2 v[4]) const
+void Rect::get_vertices(Vec2 v[4]) const
 {
 	// 3 ---- 2
 	// |      |
@@ -72,7 +72,7 @@ void Rect::GetVertices(Vec2 v[4]) const
 }
 
 //-----------------------------------------------------------------------------
-Vec2 Rect::GetVertext(uint index) const
+Vec2 Rect::get_vertex(uint index) const
 {
 	assert(index < 4);
 
@@ -92,31 +92,31 @@ Vec2 Rect::GetVertext(uint index) const
 }
 
 //-----------------------------------------------------------------------------
-Vec2 Rect::GetCenter() const
+Vec2 Rect::get_center() const
 {
 	return (min + max) * 0.5;
 }
 
 //-----------------------------------------------------------------------------
-real Rect::GetRadius() const
+real Rect::get_radius() const
 {
-	return (max - (min + max) * 0.5).GetLength();
+	return (max - (min + max) * 0.5).length();
 }
 
 //-----------------------------------------------------------------------------
-real Rect::GetArea() const
+real Rect::get_area() const
 {
 	return (max.x - min.x) * (max.y - min.y);
 }
 
 //-----------------------------------------------------------------------------
-Vec2 Rect::GetSize() const
+Vec2 Rect::get_size() const
 {
 	return (max - min);
 }
 
 //-----------------------------------------------------------------------------
-void Rect::Fix()
+void Rect::fix()
 {
 	if (min.x > max.x)
 	{
@@ -134,9 +134,9 @@ void Rect::Fix()
 }
 
 //-----------------------------------------------------------------------------
-Circle Rect::ToCircle() const
+Circle Rect::to_circle() const
 {
-	return Circle(GetCenter(), GetRadius());
+	return Circle(get_center(), get_radius());
 }
 
 } // namespace Crown

+ 19 - 19
src/core/bv/Rect.h

@@ -53,25 +53,25 @@ public:
 					Rect(const Rect& rect);					//!< Copy construcor
 					~Rect();								//!< Destructor
 
-	const Vec2&		GetMin() const;							//!< Returns the "min" corner
-	const Vec2&		GetMax() const;							//!< Returns the "max" corner
-	void			SetMin(const Vec2& min);				//!< Sets the "min" corner
-	void			SetMax(const Vec2& max);				//!< Sets the "max" corner
+	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
 
-	Vec2			GetCenter() const;						//!< Returns the center
-	real			GetRadius() const;						//!< Returns the radius 
-	real			GetArea() const;						//!< Returns the area
-	Vec2			GetSize() const;						//!< Returns the diagonal
+	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
 
-	bool			ContainsPoint(const Vec2& point) const;	//!< Returns whether "point" is contained
-	bool			IntersectsRect(const Rect& r) const;	//!< Returns whether intersects "r"
-	void			SetFromCenterAndDimensions(Vec2 center, real width, real height);	//!< Sets the Rect from a center and a width - height
-	void			GetVertices(Vec2 v[4]) const;			//!< Returns the four rect's vertices
-	Vec2			GetVertext(uint index) const;			//!< Returns a rect's vertex
+	bool			contains_point(const Vec2& point) const;//!< Returns whether "point" is contained
+	bool			intersects_rect(const Rect& r) const;	//!< Returns whether intersects "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(uint index) const;			//!< Returns a rect's vertex
 
-	Circle			ToCircle() const;						//!< Returns the equivalent circle
+	Circle			to_circle() const;						//!< Returns the equivalent circle
 
-	void			Fix();									//!< Ensures that min and max aren't swapped
+	void			fix();									//!< Ensures that min and max aren't swapped
 };
 
 //-----------------------------------------------------------------------------
@@ -95,25 +95,25 @@ inline Rect::~Rect()
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec2& Rect::GetMin() const
+inline const Vec2& Rect::get_min() const
 {
 	return min;
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec2& Rect::GetMax() const
+inline const Vec2& Rect::get_max() const
 {
 	return max;
 }
 
 //-----------------------------------------------------------------------------
-inline void Rect::SetMin(const Vec2& min)
+inline void Rect::set_min(const Vec2& min)
 {
 	this->min = min;
 }
 
 //-----------------------------------------------------------------------------
-inline void Rect::SetMax(const Vec2& max)
+inline void Rect::set_max(const Vec2& max)
 {
 	this->max = max;
 }

+ 22 - 22
src/core/bv/Sphere.h

@@ -50,17 +50,17 @@ public:
 					Sphere(const Sphere& a);					//!< Copy constructor
 					~Sphere();									//!< Destructor
 
-	const Vec3&		GetCenter() const;							//!< Returns the center
-	real			GetRadius() const;							//!< Returns the radius
-	real			GetVolume() const;							//!< Returns the volume
+	const Vec3&		get_center() const;							//!< Returns the center
+	real			get_radius() const;							//!< Returns the radius
+	real			get_volume() const;							//!< Returns the volume
 
-	void			SetCenter(const Vec3& center);				//!< Sets the center
-	void			SetRadius(real radius);					//!< Sets the radius
+	void			set_center(const Vec3& center);				//!< Sets the center
+	void			set_radius(real radius);					//!< Sets the radius
 
-	void			AddPoint(const Vec3& p);					//!< Adds a point to the Sphere
-	void			AddSphere(const Sphere& s);					//!< Adds a Sphere to the Sphere
+	void			add_point(const Vec3& p);					//!< Adds a point to the Sphere
+	void			add_sphere(const Sphere& s);				//!< Adds a Sphere to the Sphere
 
-	bool			ContainsPoint(const Vec3& p) const;			//!< Returns whether point "p" is contained
+	bool			contains_point(const Vec3& p) const;		//!< Returns whether point "p" is contained
 };
 
 //-----------------------------------------------------------------------------
@@ -84,64 +84,64 @@ inline Sphere::~Sphere()
 }
 
 //-----------------------------------------------------------------------------
-inline const Vec3& Sphere::GetCenter() const
+inline const Vec3& Sphere::get_center() const
 {
 	return c;
 }
 
 //-----------------------------------------------------------------------------
-inline real Sphere::GetRadius() const
+inline real Sphere::get_radius() const
 {
 	return r;
 }
 
 //-----------------------------------------------------------------------------
-inline real Sphere::GetVolume() const
+inline real Sphere::get_volume() const
 {
-	return Math::FOUR_OVER_THREE_TIMES_PI * r * r * r;
+	return math::FOUR_OVER_THREE_TIMES_PI * r * r * r;
 }
 
 //-----------------------------------------------------------------------------
-inline void Sphere::SetCenter(const Vec3& center)
+inline void Sphere::set_center(const Vec3& center)
 {
 	c = center;
 }
 
 //-----------------------------------------------------------------------------
-inline void Sphere::SetRadius(real radius)
+inline void Sphere::set_radius(real radius)
 {
 	this->r = radius;
 }
 
 //-----------------------------------------------------------------------------
-inline void Sphere::AddPoint(const Vec3& p)
+inline void Sphere::add_point(const Vec3& p)
 {
-	real dist = (p - c).GetSquaredLength();
+	real dist = (p - c).squared_length();
 
 	if (dist < r * r)
 	{
 		return;
 	}
 
-	r = Math::Sqrt(dist);
+	r = math::sqrt(dist);
 }
 
 //-----------------------------------------------------------------------------
-inline void Sphere::AddSphere(const Sphere& s)
+inline void Sphere::add_sphere(const Sphere& s)
 {
-	real dist = (s.c - c).GetSquaredLength();
+	real dist = (s.c - c).squared_length();
 
 	if (dist < (s.r + r) * (s.r + r))
 		if (s.r * s.r > r * r)
 		{
-			r = Math::Sqrt(dist + s.r * s.r);
+			r = math::sqrt(dist + s.r * s.r);
 		}
 }
 
 //-----------------------------------------------------------------------------
-inline bool Sphere::ContainsPoint(const Vec3& p) const
+inline bool Sphere::contains_point(const Vec3& p) const
 {
-	real dist = (p - c).GetSquaredLength();
+	real dist = (p - c).squared_length();
 	return (dist < r * r);
 }