From a916068d16bdd2b210c7ea1f07efdda6ba129457 Mon Sep 17 00:00:00 2001
From: Quaternions <krakow20@gmail.com>
Date: Thu, 22 Aug 2024 11:51:44 -0700
Subject: [PATCH] move function into struct impls

---
 src/push_solve.rs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/push_solve.rs b/src/push_solve.rs
index 2b53f41..a02c0b5 100644
--- a/src/push_solve.rs
+++ b/src/push_solve.rs
@@ -34,6 +34,10 @@ impl Contact{
 	fn relative_dot(&self,direction:Planar64Vec3)->Planar64{
 		(direction-self.velocity).dot(self.normal)
 	}
+	/// Calculate the time of intersection. (previously get_touch_time)
+	fn solve(&self,ray:&Ray)->Planar64{
+		(self.position-ray.origin).dot(self.normal)/(ray.direction-self.velocity).dot(self.normal)
+	}
 }
 
 //A reference to a Contact and its respective index, paired together
@@ -288,9 +292,6 @@ fn get_best_push_ray_and_indices(
 	}
 }
 
-fn get_touch_time(ray:&Ray,c:&Contact)->Planar64{
-	(ray.origin-c.position).dot(c.normal)/(c.velocity-ray.direction).dot(c.normal)
-}
 fn get_first_touch(conts:&Vec<Contact>,ray:&Ray,indices:&Indices)->Option<(Planar64,usize)>{
 	conts.iter()
 		.enumerate()
@@ -298,7 +299,7 @@ fn get_first_touch(conts:&Vec<Contact>,ray:&Ray,indices:&Indices)->Option<(Plana
 			!indices.contains(&i)
 			&&contact.relative_dot(ray.direction)< -EPSILON
 		)
-		.map(|(i,contact)|(get_touch_time(ray,contact),i))
+		.map(|(i,contact)|(contact.solve(ray),i))
 		.min_by_key(|&(t,_)|t)
 }