From 2f0a073fd561d6a6977c07e7a4eeb045bdedefd1 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 18 Sep 2023 19:04:21 -0700 Subject: [PATCH] fix aabb normals + face_mesh --- src/body.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/body.rs b/src/body.rs index d54a6eb3..46952e52 100644 --- a/src/body.rs +++ b/src/body.rs @@ -246,14 +246,20 @@ impl Model { Aabb::unit_face_vertices(face) } pub fn face_mesh(&self,face:TreyMeshFace) -> TreyMesh { - let mut aabb=Aabb::new(); - for &vertex in self.unit_face_vertices(face).iter() { - aabb.grow(glam::Vec4Swizzles::xyz(self.transform*vertex.extend(1.0))); + let mut aabb=self.mesh(); + //in this implementation face = worldspace aabb face + match face { + AabbFace::Right => aabb.min.x=aabb.max.x, + AabbFace::Top => aabb.min.y=aabb.max.y, + AabbFace::Back => aabb.min.z=aabb.max.z, + AabbFace::Left => aabb.max.x=aabb.min.x, + AabbFace::Bottom => aabb.max.y=aabb.min.y, + AabbFace::Front => aabb.max.z=aabb.min.z, } return aabb; } pub fn face_normal(&self,face:TreyMeshFace) -> glam::Vec3 { - glam::Vec4Swizzles::xyz(self.transform*Aabb::normal(face).extend(0.0))//this is wrong for scale + glam::Vec4Swizzles::xyz(Aabb::normal(face).extend(0.0))//this is wrong for scale } }