diff options
author | eug-vs <eugene@eug-vs.xyz> | 2021-10-27 11:40:37 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2021-10-27 11:40:37 +0300 |
commit | 8391a35aaa35da3018744f89b296e57549b29255 (patch) | |
tree | 5d9ad2415bd5c577470762335a95c45a7b575735 /src/camera.rs | |
parent | 92d5cd982d87963165ee175b985a8a477154a5e7 (diff) | |
download | pistol-8391a35aaa35da3018744f89b296e57549b29255.tar.gz |
feat: add time parameter
Diffstat (limited to 'src/camera.rs')
-rw-r--r-- | src/camera.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/camera.rs b/src/camera.rs index 646307f..eb7cea2 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -32,6 +32,7 @@ impl fmt::Display for Buffer { #[derive(Debug)] pub struct Camera { + pub time: f32, pub position: Vector, pub direction: Vector, pub angle: f32, @@ -42,6 +43,7 @@ pub struct Camera { } fn softmin(left: f32, right: f32, k: f32) -> f32 { + // return left.min(right); let h = (k-(left-right).abs()).max(0.0) / k; return left.min(right) - h*h*k*(1.0/4.0); } @@ -53,7 +55,7 @@ impl Camera { // Sphere let center = Vector { x: 3.0, y: 0.0, z: 0.0 }; - let radius = 1.0; + let radius = 1.0 + 0.5 * self.time.sin(); let sphere_dist = (point - center).magnitude() - radius; // Small sphere @@ -62,7 +64,7 @@ impl Camera { let sphere2_dist = (point - center2).magnitude() - radius2; // Second sphere - let center3 = Vector { x: 3.0, y: -2.5, z: 0.0 }; + let center3 = Vector { x: 3.0 + self.time.sin() * 1.6, y: -2.5, z: 0.0 - self.time.sin() * 0.8 }; let radius3 = 1.0; let sphere3_dist = (point - center3).magnitude() - radius3; |