From a79b04114a2e0a584e6d2ca92d531341ba0cd78a Mon Sep 17 00:00:00 2001 From: Adrian G L Date: Fri, 3 Oct 2025 14:03:53 +0200 Subject: [PATCH 1/4] feat: add key-controlled sliding animation for helicopter door --- src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.rs b/src/main.rs index 4f66950..e37b8c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -376,6 +376,7 @@ fn main() { // The main rendering loop let first_frame_time = std::time::Instant::now(); let mut previous_frame_time = first_frame_time; + let mut door_slide = 0.0f32; loop { // Compute time passed since the previous frame and since the start of the program let now = std::time::Instant::now(); @@ -428,6 +429,7 @@ fn main() { // clamp pitch to avoid flipping let pitch_limit = std::f32::consts::FRAC_PI_2 - 0.01; cam_pitch = cam_pitch.clamp(-pitch_limit, pitch_limit); + door_slide = if keys.contains(&O) { 2.0 } else { 0.0 }; } // Handle mouse movement. delta contains the x and y movement of the mouse since last frame in pixels if let Ok(mut delta) = mouse_delta.lock() { @@ -474,6 +476,14 @@ fn main() { (&mut (*node.children[3]).rotation).x = elapsed * 10.0; } } + // Animate door sliding + { + let mut pin = root.as_mut(); + let node = unsafe { pin.get_unchecked_mut() }; + unsafe { + (*node.children[1]).position.z = door_slide; + } + } } // Draw scene via scene graph -- 2.51.2 From 0cc59fdc152a87c2f75e31e3fe2877a462186381 Mon Sep 17 00:00:00 2001 From: Adrian G L Date: Fri, 3 Oct 2025 14:05:19 +0200 Subject: [PATCH 2/4] fix: avoid implicit autoref by explicitly mutably referencing raw pointer target --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e37b8c4..9a86e05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -481,7 +481,8 @@ fn main() { let mut pin = root.as_mut(); let node = unsafe { pin.get_unchecked_mut() }; unsafe { - (*node.children[1]).position.z = door_slide; + let door_node = &mut *node.children[1]; + door_node.position.z = door_slide; } } } -- 2.51.2 From 15036109bfd038d5a4995c3e6f409b16b7a940f7 Mon Sep 17 00:00:00 2001 From: Adrian G L Date: Fri, 3 Oct 2025 14:17:06 +0200 Subject: [PATCH 3/4] fix: add terrain bump mapping noise calculation in fragment shader --- shaders/simple.frag | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shaders/simple.frag b/shaders/simple.frag index daab36e..e50fcfc 100644 --- a/shaders/simple.frag +++ b/shaders/simple.frag @@ -10,11 +10,13 @@ void main() { // ambient component float ambientStrength = 0.1; vec3 ambient = ambientStrength * vColor.rgb; + // terrain bump mapping with multi‐octave noise based on world position float bumpStrength = 0.4; float n1 = fract(sin(dot(vPosition.xz, vec2(12.9898, 78.233))) * 43758.5453); float n2 = fract(sin(dot(vPosition.xz * 0.5, vec2(93.9898, 67.345))) * 24634.6345); float noiseVal = mix(n1, n2, 0.5); + vec3 bumpNormal = normalize(vNormal + bumpStrength * (noiseVal - 0.5) * vec3(1.0)); // diffuse component (Lambert) with bump float lambert = max(0.0, dot(normalize(bumpNormal), -lightDirection)); -- 2.51.2 From 1b0a437ac93af5ba392d5539d8d601142b51596c Mon Sep 17 00:00:00 2001 From: Adrian G L Date: Fri, 3 Oct 2025 14:28:54 +0200 Subject: [PATCH 4/4] fix: reduce noice based bumpmap --- shaders/simple.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shaders/simple.frag b/shaders/simple.frag index e50fcfc..7aff559 100644 --- a/shaders/simple.frag +++ b/shaders/simple.frag @@ -12,7 +12,7 @@ void main() { vec3 ambient = ambientStrength * vColor.rgb; // terrain bump mapping with multi‐octave noise based on world position - float bumpStrength = 0.4; + float bumpStrength = 0.1; float n1 = fract(sin(dot(vPosition.xz, vec2(12.9898, 78.233))) * 43758.5453); float n2 = fract(sin(dot(vPosition.xz * 0.5, vec2(93.9898, 67.345))) * 24634.6345); float noiseVal = mix(n1, n2, 0.5); -- 2.51.2