Remove double transpose

This commit is contained in:
Jarrod Doyle 2023-09-25 10:25:22 +01:00
parent 43d5259af2
commit dc749aa7be
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 24 additions and 1 deletions

View File

@ -68,6 +68,25 @@ impl Brush {
self.aabb.intersects(other.get_aabb()) self.aabb.intersects(other.get_aabb())
} }
pub fn planes_intersect_with(&self, other: &Brush) -> bool {
// TODO: Benchmark this
// Check our vertices against their planes
for pi in &self.raw_vertices {
if other.planes.iter().all(|bp| pi.in_halfspace_mat(&bp.plane)) {
return true;
}
}
// Check their vertices against our planes
for pi in &other.raw_vertices {
if self.planes.iter().all(|bp| pi.in_halfspace_mat(&bp.plane)) {
return true;
}
}
false
}
pub fn get_vertices(&self) -> Vec<Vec3> { pub fn get_vertices(&self) -> Vec<Vec3> {
self.vertices.clone() self.vertices.clone()
} }

View File

@ -110,7 +110,11 @@ impl PlaneIntersection {
let d1 = m1.determinant(); let d1 = m1.determinant();
// We can resolve the winding order problem by multiplying by the normal matrix determinant // We can resolve the winding order problem by multiplying by the normal matrix determinant
let m2 = self.get_matrix().transpose(); let m2 = glam::mat3(
self.planes[0].normal,
self.planes[1].normal,
self.planes[2].normal,
);
let d2 = m2.determinant(); let d2 = m2.determinant();
let dist = d1 * d2; let dist = d1 * d2;