refactored vector classes to avoid reinterpret_cast
[xonotic/netradiant.git] / libs / math / aabb.h
index a2476e456eae42b8c77df13cbfd2315924a06592..1341a340bfc9c77dc250f5d00753485ab57e2ed0 100644 (file)
@@ -243,9 +243,9 @@ inline void aabb_corners(const AABB& aabb, Vector3 corners[8])
 
 inline void aabb_corners_oriented(const AABB& aabb, const Matrix4& rotation, Vector3 corners[8])
 {
-  Vector3 x = Vector3(rotation.x()) * aabb.extents.x();
-  Vector3 y = Vector3(rotation.y()) * aabb.extents.y();
-  Vector3 z = Vector3(rotation.z()) * aabb.extents.z();
+  Vector3 x = vector4_to_vector3(rotation.x()) * aabb.extents.x();
+  Vector3 y = vector4_to_vector3(rotation.y()) * aabb.extents.y();
+  Vector3 z = vector4_to_vector3(rotation.z()) * aabb.extents.z();
 
   corners[0] = aabb.origin + -x +  y +  z;
   corners[1] = aabb.origin +  x +  y +  z;
@@ -269,16 +269,16 @@ inline void aabb_planes(const AABB& aabb, Plane3 planes[6])
 
 inline void aabb_planes_oriented(const AABB& aabb, const Matrix4& rotation, Plane3 planes[6])
 {
-  double x = vector3_dot(Vector3(rotation.x()), aabb.origin);
-  double y = vector3_dot(Vector3(rotation.y()), aabb.origin);
-  double z = vector3_dot(Vector3(rotation.z()), aabb.origin);
-
-  planes[0] = Plane3(Vector3(rotation.x()), x + aabb.extents[0]);
-  planes[1] = Plane3(-Vector3(rotation.x()), -(x - aabb.extents[0]));
-  planes[2] = Plane3(Vector3(rotation.y()), y + aabb.extents[1]);
-  planes[3] = Plane3(-Vector3(rotation.y()), -(y - aabb.extents[1]));
-  planes[4] = Plane3(Vector3(rotation.z()), z + aabb.extents[2]);
-  planes[5] = Plane3(-Vector3(rotation.z()), -(z - aabb.extents[2]));
+  double x = vector3_dot(vector4_to_vector3(rotation.x()), aabb.origin);
+  double y = vector3_dot(vector4_to_vector3(rotation.y()), aabb.origin);
+  double z = vector3_dot(vector4_to_vector3(rotation.z()), aabb.origin);
+
+  planes[0] = Plane3(vector4_to_vector3(rotation.x()), x + aabb.extents[0]);
+  planes[1] = Plane3(-vector4_to_vector3(rotation.x()), -(x - aabb.extents[0]));
+  planes[2] = Plane3(vector4_to_vector3(rotation.y()), y + aabb.extents[1]);
+  planes[3] = Plane3(-vector4_to_vector3(rotation.y()), -(y - aabb.extents[1]));
+  planes[4] = Plane3(vector4_to_vector3(rotation.z()), z + aabb.extents[2]);
+  planes[5] = Plane3(-vector4_to_vector3(rotation.z()), -(z - aabb.extents[2]));
 }
 
 const Vector3 aabb_normals[6] = {