From fea1e609e6003f68a351438ebd9d00e109e930cc Mon Sep 17 00:00:00 2001 From: Rosyid Haryadi Date: Sat, 1 Mar 2025 12:07:31 +0700 Subject: fix type --- src/global.rs | 6 +++--- src/renderer.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/global.rs b/src/global.rs index b322746..9357920 100644 --- a/src/global.rs +++ b/src/global.rs @@ -8,9 +8,9 @@ pub const IMG_WIDTH: usize = 400; const IMG_HEIGHT_TMP: usize = (IMG_WIDTH as f32 / ASPECT_RATIO) as usize; pub const IMG_HEIGHT: usize = if (IMG_HEIGHT_TMP < 1) { 1 } else { IMG_HEIGHT_TMP }; -pub const VIEWPORT_HEIGHT: usize = 2; -pub const VIEWPORT_WIDTH: usize = VIEWPORT_HEIGHT * (IMG_WIDTH / IMG_HEIGHT); -pub const FOCAL_LENGTH: f32 = 2.0; +pub const VIEWPORT_HEIGHT: f32 = 2.0; +pub const VIEWPORT_WIDTH: f32 = VIEWPORT_HEIGHT * (IMG_WIDTH as f32 / IMG_HEIGHT as f32); +pub const FOCAL_LENGTH: f32 = 1.0; pub const CAMERA_CENTER: Point3 = Point3 { x: 0f32, y: 0f32, z: 0f32 }; #[derive(Debug, Copy, Clone)] diff --git a/src/renderer.rs b/src/renderer.rs index 7e46834..3f94437 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -16,7 +16,7 @@ fn hit_sphere(center: &Point3, radius: f32, ray: &Ray) -> bool { let oc = center.sub(&ray.origin); let a = ray.direction.dot_prod(&ray.direction); let b = -2.0 * ray.direction.dot_prod(&oc); - let mut c = oc.dot_prod(&oc) - radius * radius; + let c = oc.dot_prod(&oc) - radius * radius; let discriminant = b * b - 4.0 * a * c; discriminant >= 0.0 } -- cgit v1.2.3-70-g09d2