diff --git a/rust/src/geometry.rs b/rust/src/geometry.rs index 10850f198..3936cefdc 100644 --- a/rust/src/geometry.rs +++ b/rust/src/geometry.rs @@ -10,9 +10,13 @@ pub struct Plane { } impl Plane { + pub fn new(normal: Vec3, d: f32) -> Plane { + Plane { normal, d } + } + pub fn normalized(&self) -> Plane { let mag = self.normal.magnitude(); - Plane { normal: self.normal / mag, d: self.d / mag } + Plane::new(self.normal / mag, self.d / mag) } pub fn negate(&mut self) { @@ -199,9 +203,9 @@ impl ConvexHull { let mut result = IntersectionState::Inside; for plane in &self.planes { let dist = plane.distance(center); - if dist < radius { + if dist < -radius { return IntersectionState::Outside; - } else if dist < -radius { + } else if dist < radius { result = IntersectionState::Intersection; } } @@ -248,9 +252,8 @@ impl ConvexHull { pub fn push_plane(&mut self, x: f32, y: f32, z: f32, d: f32) { // Normalize the plane equation so that sphere tests work. - let mut normal = Vec3::new(x, y, z); - let mag = normal.normalize_mut(); - self.planes.push(Plane { normal, d: d / mag }); + let plane = Plane::new(Vec3::new(x, y, z), d); + self.planes.push(plane.normalized()); } pub fn js_intersect_aabb(&mut self, min_x: f32, min_y: f32, min_z: f32, max_x: f32, max_y: f32, max_z: f32) -> IntersectionState { diff --git a/src/StarFoxAdventures/maps.ts b/src/StarFoxAdventures/maps.ts index 1d893ea58..e0a420c69 100644 --- a/src/StarFoxAdventures/maps.ts +++ b/src/StarFoxAdventures/maps.ts @@ -16,10 +16,6 @@ import { SFAAnimationController } from './animation.js'; import { SFATextureFetcher } from './textures.js'; import { ModelRenderContext, ModelInstance } from './models.js'; import { World } from './world.js'; -import { AABB } from '../Geometry.js'; -import { LightType } from './WorldLights.js'; -import { computeViewMatrix } from '../Camera.js'; -import { drawWorldSpacePoint, getDebugOverlayCanvas2D } from '../DebugJunk.js'; export interface BlockInfo { mod: number;