From 60bd926ce184f3684d7d986002fc2daadeb509a2 Mon Sep 17 00:00:00 2001
From: Quaternions <krakow20@gmail.com>
Date: Wed, 11 Sep 2024 15:58:13 -0700
Subject: [PATCH] wip wip

---
 src/model_physics.rs |  8 ++++----
 src/physics.rs       | 19 ++++++++++---------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/model_physics.rs b/src/model_physics.rs
index 0815e4f..dc9e342 100644
--- a/src/model_physics.rs
+++ b/src/model_physics.rs
@@ -342,9 +342,9 @@ impl TryFrom<&model::Mesh> for PhysicsMesh{
 						let v0=mesh.unique_pos[vert0_id.get() as usize];
 						let v1=mesh.unique_pos[vert1_id.get() as usize];
 						normal+=Planar64Vec3::new(
-							(v0.y()-v1.y())*(v0.z()+v1.z()),
-							(v0.z()-v1.z())*(v0.x()+v1.x()),
-							(v0.x()-v1.x())*(v0.y()+v1.y()),
+							(v0.y-v1.y)*(v0.z+v1.z),
+							(v0.z-v1.z)*(v0.x+v1.x),
+							(v0.x-v1.x)*(v0.y+v1.y),
 						);
 						//get/create edge and push face into it
 						let (edge_ref_verts,is_sorted)=EdgeRefVerts::new(submesh_vert0_id,submesh_vert1_id);
@@ -955,7 +955,7 @@ fn is_empty_volume(normals:Vec<Planar64Vec3>)->bool{
 				if k!=i&&k!=j{
 					let d=n.dot(normals[k]);
 					if let Some(comp)=&d_comp{
-						if *comp*d<Planar64::ZERO{
+						if comp.is_negative()&&d.is_negative()||comp.is_positive()&&d.is_positive(){
 							return true;
 						}
 					}else{
diff --git a/src/physics.rs b/src/physics.rs
index 4a78d37..15ff6b9 100644
--- a/src/physics.rs
+++ b/src/physics.rs
@@ -413,7 +413,7 @@ impl HitboxMesh{
 			aabb.grow(vert);
 		}
 		Self{
-			halfsize:aabb.size()/2,
+			halfsize:aabb.size()>>1,
 			mesh,
 			transform,
 		}
@@ -475,7 +475,7 @@ impl StyleHelper for StyleModifiers{
 			gameplay_style::HitboxMesh::Box=>PhysicsMesh::unit_cube(),
 			gameplay_style::HitboxMesh::Cylinder=>PhysicsMesh::unit_cylinder(),
 		};
-		let transform=integer::Planar64Affine3::new(Planar64Mat3::from_diagonal(self.hitbox.halfsize),Planar64Vec3::ZERO);
+		let transform=Planar64Mat3::from_diagonal(self.hitbox.halfsize).extend(Planar64Vec3::ZERO);
 		HitboxMesh::new(mesh,transform)
 	}
 }
@@ -851,20 +851,20 @@ impl Body{
 		aabb.grow(self.extrapolated_position(t1));
 		//v+a*t==0
 		//goober code
-		if self.acceleration.x()!=Planar64::ZERO{
-			let t=Time::from(-self.velocity.x()/self.acceleration.x());
+		if self.acceleration.x!=Planar64::ZERO{
+			let t=Time::from(-self.velocity.x/self.acceleration.x);
 			if t0<t&&t<t1{
 				aabb.grow(self.extrapolated_position(t));
 			}
 		}
-		if self.acceleration.y()!=Planar64::ZERO{
-			let t=Time::from(-self.velocity.y()/self.acceleration.y());
+		if self.acceleration.y!=Planar64::ZERO{
+			let t=Time::from(-self.velocity.y/self.acceleration.y);
 			if t0<t&&t<t1{
 				aabb.grow(self.extrapolated_position(t));
 			}
 		}
-		if self.acceleration.z()!=Planar64::ZERO{
-			let t=Time::from(-self.velocity.z()/self.acceleration.z());
+		if self.acceleration.z!=Planar64::ZERO{
+			let t=Time::from(-self.velocity.z/self.acceleration.z);
 			if t0<t&&t<t1{
 				aabb.grow(self.extrapolated_position(t));
 			}
@@ -1403,8 +1403,9 @@ fn teleport_to_spawn(
 	input_state:&InputState,
 	time:Time,
 )->Result<(),TeleportToSpawnError>{
+	const EPSILON:Planar64=Planar64::raw((1<<32)/16);
 	let transform=models.get_model_transform(stage.spawn()).ok_or(TeleportToSpawnError::NoModel)?;
-	let point=transform.vertex.transform_point3(Planar64Vec3::Y)+Planar64Vec3::Y*(style.hitbox.halfsize.y()+Planar64::ONE/16);
+	let point=transform.vertex.y_axis+Planar64Vec3::new([Planar64::ZERO,style.hitbox.halfsize.y+EPSILON,Planar64::ZERO]);
 	teleport(point,move_state,body,touching,run,mode_state,Some(mode),models,hitbox_mesh,bvh,style,camera,input_state,time);
 	Ok(())
 }