aboutsummaryrefslogtreecommitdiff
path: root/src/sdf.rs
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2024-05-19 19:25:08 +0200
committereug-vs <eugene@eug-vs.xyz>2024-05-19 19:25:34 +0200
commit8e2e7bd7057925bb950d571dc0ac3e876ce32d54 (patch)
treee03093b3fdc1db92c01228cef703193b02f21a5c /src/sdf.rs
parentb6fcd2b3ad1e84197867de13c783eba60fe465ba (diff)
downloadpistol-8e2e7bd7057925bb950d571dc0ac3e876ce32d54.tar.gz
feat: run at 60 FPS
Diffstat (limited to 'src/sdf.rs')
-rw-r--r--src/sdf.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/sdf.rs b/src/sdf.rs
index d940f39..3204305 100644
--- a/src/sdf.rs
+++ b/src/sdf.rs
@@ -14,8 +14,8 @@ pub struct Sphere {
}
impl Object for Sphere {
- fn sdf(&self, point: Vector, _time: f32) -> f32 {
- (point - self.center).magnitude() - self.radius
+ fn sdf(&self, point: Vector, time: f32) -> f32 {
+ (point - self.center).magnitude() - self.radius + (time % 5.0) / 50.0
}
}
@@ -41,6 +41,7 @@ pub struct Gear {
impl Object for Gear {
fn sdf(&self, point: Vector, time: f32) -> f32 {
+ let point = point - self.center;
let mut dist: f32;
let thickness_over_2 = self.thickness / 2.0;
@@ -48,8 +49,8 @@ impl Object for Gear {
// Ring
{
- let cylinder_dist = (Vector::new(0.0, point.y, point.z) - self.center).magnitude()
- - (self.radius - thickness_over_4);
+ let cylinder_dist =
+ (Vector::new(0.0, point.y, point.z)).magnitude() - (self.radius - thickness_over_4);
dist = cylinder_dist.abs() - thickness_over_2; // Make cylinder hollow
}
// Teeth