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;
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] = {