src/types/boundingbox.cpp

changeset 33
4c41bfe2ec6e
parent 23
3387a84ddaba
child 189
815fbaae9cb2
--- a/src/types/boundingbox.cpp	Sun Jan 26 01:06:27 2020 +0200
+++ b/src/types/boundingbox.cpp	Sun Jan 26 14:29:30 2020 +0200
@@ -18,13 +18,13 @@
 
 #include "boundingbox.h"
 
-BoundingBox& BoundingBox::operator<<(const Point3D& vertex)
+BoundingBox& BoundingBox::operator<<(const glm::vec3& vertex)
 {
 	this->consider(vertex);
 	return *this;
 }
 
-void BoundingBox::consider(const Point3D& vertex)
+void BoundingBox::consider(const glm::vec3& vertex)
 {
 	this->minimum.x = math::min(vertex.x, this->minimum.x);
 	this->minimum.y = math::min(vertex.y, this->minimum.y);
@@ -37,19 +37,19 @@
 /*
  * Returns the length of the bounding box on the longest measure.
  */
-double longestMeasure(const BoundingBox& box)
+float longestMeasure(const BoundingBox& box)
 {
 	if (box != emptyBoundingBox)
 	{
-		const double dx = std::abs(box.minimum.x - box.maximum.x);
-		const double dy = std::abs(box.minimum.y - box.maximum.y);
-		const double dz = std::abs(box.minimum.z - box.maximum.z);
-		const double size = std::max(std::max(dx, dy), dz);
-		return std::max(size / 2.0, 1.0);
+		const float dx = std::abs(box.minimum.x - box.maximum.x);
+		const float dy = std::abs(box.minimum.y - box.maximum.y);
+		const float dz = std::abs(box.minimum.z - box.maximum.z);
+		const float size = std::max(std::max(dx, dy), dz);
+		return std::max(size / 2.0f, 1.0f);
 	}
 	else
 	{
-		return 0.0;
+		return 0.0f;
 	}
 }
 
@@ -57,7 +57,7 @@
 /*
  * Yields the center of the bounding box.
  */
-Point3D boxCenter(const BoundingBox& box)
+glm::vec3 boxCenter(const BoundingBox& box)
 {
 	if (box != emptyBoundingBox)
 	{
@@ -69,16 +69,16 @@
 	}
 	else
 	{
-		return origin;
+		return glm::vec3{0, 0, 0};
 	}
 }
 
 /*
  * Returns the length of the bounding box's space diagonal.
  */
-double spaceDiagonal(const BoundingBox& box)
+float spaceDiagonal(const BoundingBox& box)
 {
-	return math::distance(box.minimum, box.maximum);
+	return glm::distance(box.minimum, box.maximum);
 }
 
 bool operator==(const BoundingBox &box_1, const BoundingBox &box_2)

mercurial