fix: clamp camera pitch before vertical #927

Merged
SakulFlee merged 1 commit from sakulflee/fix-912-camera-pitch-clamp into main 2026-10-24 23:25:50 +00:00 AGit
Owner

Clamps camera pitch on mouse, gamepad, and touch input so the view cannot cross straight up or down. Previously only touch look clamped pitch; mouse and gamepad could flip the up vector and make the camera appear to revolve around itself.

  • Add Rotation::pitch() and Rotation::rotate_pitch_clamped().
  • Use the clamped pitch helper for touch, mouse, and gamepad look.
  • Add regression tests for clamping and heading preservation.

Fixes #912

Clamps camera pitch on mouse, gamepad, and touch input so the view cannot cross straight up or down. Previously only touch look clamped pitch; mouse and gamepad could flip the up vector and make the camera appear to revolve around itself. - Add `Rotation::pitch()` and `Rotation::rotate_pitch_clamped()`. - Use the clamped pitch helper for touch, mouse, and gamepad look. - Add regression tests for clamping and heading preservation. Fixes #912
fix: clamp camera pitch before vertical
Some checks failed
Lint / lint (pull_request) Successful in 1m21s
PR / test (pull_request) Failing after 3m24s
1996a69cf0

Smart test results

Result: FAIL

Failure: nextest and doctest command failed

Scope: orbital_app, orbital_ecs_bridge

Reason: directly changed crates

Elapsed: 2m 14s

Workflow run

Overall: 0 tests, 0 passed, 0 failed, 0 skipped

Nextest: build failed (no test report)
Doctests: command failed (no test report)

Nextest output tail
   Compiling built v0.8.1
   Compiling av-scenechange v0.14.1
   Compiling version_check v0.9.5
   Compiling rav1e v0.8.1
   Compiling pulp v0.22.3
   Compiling aligned v0.4.3
   Compiling orbital_file_manager v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_file_manager)
   Compiling miniz_oxide v0.9.1
   Compiling wgpu-types v30.0.1
   Compiling nom v8.0.0
   Compiling no_std_io2 v0.9.4
   Compiling arg_enum_proc_macro v0.3.4
   Compiling y4m v0.8.0
   Compiling pastey v0.1.1
   Compiling quick-error v2.0.1
   Compiling bitstream-io v4.10.0
   Compiling miniz_oxide v0.8.9
   Compiling itertools v0.14.0
   Compiling flate2 v1.1.10
   Compiling num-complex v0.4.6
   Compiling num-rational v0.4.2
   Compiling num-derive v0.4.2
   Compiling raw-cpuid v11.6.0
   Compiling simd_helpers v0.1.0
   Compiling noop_proc_macro v0.3.0
   Compiling zune-core v0.5.3
   Compiling imgref v1.12.3
   Compiling maybe-rayon v0.1.1
   Compiling pulp-wasm-simd-flag v0.1.1
   Compiling weezl v0.1.12
   Compiling new_debug_unreachable v1.0.6
   Compiling reborrow v0.5.5
   Compiling zune-jpeg v0.5.15
   Compiling avif-serialize v0.8.9
   Compiling loop9 v0.1.5
   Compiling zune-inflate v0.2.54
   Compiling fdeflate v0.3.7
   Compiling color_quant v1.1.0
   Compiling pxfm v0.1.30
   Compiling rgb v0.8.53
   Compiling fax v0.2.7
   Compiling byteorder-lite v0.1.0
   Compiling bit_field v0.10.3
   Compiling lebe v0.5.3
   Compiling png v0.18.1
   Compiling gif v0.14.2
   Compiling qoi v0.4.1
   Compiling fern v0.7.1
   Compiling image-webp v0.2.4
   Compiling humantime v2.4.0
   Compiling av1-grain v0.2.5
   Compiling pollster v1.0.1
   Compiling orbital_shader_preprocessor v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_shader_preprocessor)
   Compiling orbital_math v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_math)
   Compiling orbital_core v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_core)
   Compiling half v2.7.1
   Compiling rand_core v0.10.1
   Compiling getrandom v0.4.3
   Compiling cpufeatures v0.3.1
   Compiling rustix v1.1.5
   Compiling zmij v1.0.23
   Compiling orbital_shader_math v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_shader_math)
   Compiling thiserror v1.0.69
   Compiling chacha20 v0.10.2
   Compiling tiff v0.11.3
   Compiling linux-raw-sys v0.12.1
   Compiling serde_json v1.0.154
   Compiling rustix v0.38.44
   Compiling rand v0.10.3
   Compiling orbital_shader_engine v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_shader_engine)
   Compiling thiserror-impl v1.0.69
   Compiling itoa v1.0.18
   Compiling inflections v1.1.1
   Compiling moxcms v0.8.1
   Compiling linux-raw-sys v0.4.15
   Compiling winnow v1.0.4
   Compiling gltf-derive v1.4.1
   Compiling ulid v3.0.0
   Compiling winit v0.30.8 (https://forgejo.sakul-flee.de/SakulFlee/Orbital-Winit.git?branch=main#a9d045d6)
   Compiling xkeysym v0.2.1
   Compiling slab v0.4.12
   Compiling toml_parser v1.1.5+spec-1.1.0
   Compiling tracing-core v0.1.36
   Compiling toml_datetime v1.1.2+spec-1.1.0
   Compiling exr v1.74.2
   Compiling pin-project-lite v0.2.17
   Compiling xkbcommon-dl v0.4.2
   Compiling toml_edit v0.25.15+spec-1.1.0
   Compiling gltf-json v1.4.1
   Compiling tracing v0.1.44
   Compiling dpi v0.1.1 (https://forgejo.sakul-flee.de/SakulFlee/Orbital-Winit.git?branch=main#a9d045d6)
   Compiling byteorder v1.5.0
   Compiling urlencoding v2.1.3
   Compiling base64 v0.13.1
   Compiling cursor-icon v1.2.0
   Compiling smol_str v0.2.2
   Compiling polling v3.11.0
   Compiling lazy_static v1.5.0
   Compiling proc-macro-crate v3.5.0
   Compiling orbital_light v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_light)
   Compiling core_maths v0.1.1
   Compiling base64 v0.23.1
   Compiling ravif v0.13.0
   Compiling orbital_macros v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_macros)
   Compiling ttf-parser v0.25.1
   Compiling orbital_ecs v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/ecs)
   Compiling libloading v0.9.0
   Compiling gpu-allocator v0.28.0
   Compiling calloop v0.13.0
   Compiling fontdue v0.9.5
error: The platform you're compiling for is not supported by winit
  --> /usr/local/cargo/git/checkouts/Orbital-Winit-c3e518048d313a61/a9d045d/src/platform_impl/mod.rs:78:1
   |
78 | compile_error!("The platform you're compiling for is not supported by winit");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `winit` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: command `/usr/local/rustup/toolchains/1.99.1-x86_64-unknown-linux-gnu/bin/cargo '--color=auto' test --no-run --message-format json-render-diagnostics --package orbital_app --package orbital_ecs_bridge` exited with code 101
Doctest output tail
warning: Cargo.toml: `lints.clippy.large-enum-variant` is deprecated in favor of `lints.clippy.large_enum_variant` and will not work in a future edition
warning: Cargo.toml: `lints.clippy.map-entry` is deprecated in favor of `lints.clippy.map_entry` and will not work in a future edition
warning: Cargo.toml: `lints.clippy.match-wildcard-for-single-variants` is deprecated in favor of `lints.clippy.match_wildcard_for_single_variants` and will not work in a future edition
warning: Cargo.toml: `lints.clippy.redundant-closure-for-method-calls` is deprecated in favor of `lints.clippy.redundant_closure_for_method_calls` and will not work in a future edition
warning: Cargo.toml: `lints.clippy.trivially-copy-pass-by-ref` is deprecated in favor of `lints.clippy.trivially_copy_pass_by_ref` and will not work in a future edition
warning: Cargo.toml: `lints.clippy.type-complexity` is deprecated in favor of `lints.clippy.type_complexity` and will not work in a future edition
warning: workspace (manifest) generated 6 warnings
   Compiling wgpu-naga-bridge v30.0.1
   Compiling image v0.25.10
   Compiling winit v0.30.8 (https://forgejo.sakul-flee.de/SakulFlee/Orbital-Winit.git?branch=main#a9d045d6)
   Compiling wgpu-hal v30.0.1
error: The platform you're compiling for is not supported by winit
  --> /usr/local/cargo/git/checkouts/Orbital-Winit-c3e518048d313a61/a9d045d/src/platform_impl/mod.rs:78:1
   |
78 | compile_error!("The platform you're compiling for is not supported by winit");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `winit` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
<!-- orbital-ci-test-results --> ## Smart test results **Result:** FAIL **Failure:** nextest and doctest command failed **Scope:** orbital_app, orbital_ecs_bridge **Reason:** directly changed crates **Elapsed:** 2m 14s [Workflow run](https://forgejo.sakul-flee.de/SakulFlee/Orbital/actions/runs/569) **Overall:** 0 tests, 0 passed, 0 failed, 0 skipped **Nextest:** build failed (no test report) **Doctests:** command failed (no test report) <details> <summary>Nextest output tail</summary> <pre><code> Compiling built v0.8.1 Compiling av-scenechange v0.14.1 Compiling version_check v0.9.5 Compiling rav1e v0.8.1 Compiling pulp v0.22.3 Compiling aligned v0.4.3 Compiling orbital_file_manager v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_file_manager) Compiling miniz_oxide v0.9.1 Compiling wgpu-types v30.0.1 Compiling nom v8.0.0 Compiling no_std_io2 v0.9.4 Compiling arg_enum_proc_macro v0.3.4 Compiling y4m v0.8.0 Compiling pastey v0.1.1 Compiling quick-error v2.0.1 Compiling bitstream-io v4.10.0 Compiling miniz_oxide v0.8.9 Compiling itertools v0.14.0 Compiling flate2 v1.1.10 Compiling num-complex v0.4.6 Compiling num-rational v0.4.2 Compiling num-derive v0.4.2 Compiling raw-cpuid v11.6.0 Compiling simd_helpers v0.1.0 Compiling noop_proc_macro v0.3.0 Compiling zune-core v0.5.3 Compiling imgref v1.12.3 Compiling maybe-rayon v0.1.1 Compiling pulp-wasm-simd-flag v0.1.1 Compiling weezl v0.1.12 Compiling new_debug_unreachable v1.0.6 Compiling reborrow v0.5.5 Compiling zune-jpeg v0.5.15 Compiling avif-serialize v0.8.9 Compiling loop9 v0.1.5 Compiling zune-inflate v0.2.54 Compiling fdeflate v0.3.7 Compiling color_quant v1.1.0 Compiling pxfm v0.1.30 Compiling rgb v0.8.53 Compiling fax v0.2.7 Compiling byteorder-lite v0.1.0 Compiling bit_field v0.10.3 Compiling lebe v0.5.3 Compiling png v0.18.1 Compiling gif v0.14.2 Compiling qoi v0.4.1 Compiling fern v0.7.1 Compiling image-webp v0.2.4 Compiling humantime v2.4.0 Compiling av1-grain v0.2.5 Compiling pollster v1.0.1 Compiling orbital_shader_preprocessor v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_shader_preprocessor) Compiling orbital_math v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_math) Compiling orbital_core v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_core) Compiling half v2.7.1 Compiling rand_core v0.10.1 Compiling getrandom v0.4.3 Compiling cpufeatures v0.3.1 Compiling rustix v1.1.5 Compiling zmij v1.0.23 Compiling orbital_shader_math v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_shader_math) Compiling thiserror v1.0.69 Compiling chacha20 v0.10.2 Compiling tiff v0.11.3 Compiling linux-raw-sys v0.12.1 Compiling serde_json v1.0.154 Compiling rustix v0.38.44 Compiling rand v0.10.3 Compiling orbital_shader_engine v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_shader_engine) Compiling thiserror-impl v1.0.69 Compiling itoa v1.0.18 Compiling inflections v1.1.1 Compiling moxcms v0.8.1 Compiling linux-raw-sys v0.4.15 Compiling winnow v1.0.4 Compiling gltf-derive v1.4.1 Compiling ulid v3.0.0 Compiling winit v0.30.8 (https://forgejo.sakul-flee.de/SakulFlee/Orbital-Winit.git?branch=main#a9d045d6) Compiling xkeysym v0.2.1 Compiling slab v0.4.12 Compiling toml_parser v1.1.5+spec-1.1.0 Compiling tracing-core v0.1.36 Compiling toml_datetime v1.1.2+spec-1.1.0 Compiling exr v1.74.2 Compiling pin-project-lite v0.2.17 Compiling xkbcommon-dl v0.4.2 Compiling toml_edit v0.25.15+spec-1.1.0 Compiling gltf-json v1.4.1 Compiling tracing v0.1.44 Compiling dpi v0.1.1 (https://forgejo.sakul-flee.de/SakulFlee/Orbital-Winit.git?branch=main#a9d045d6) Compiling byteorder v1.5.0 Compiling urlencoding v2.1.3 Compiling base64 v0.13.1 Compiling cursor-icon v1.2.0 Compiling smol_str v0.2.2 Compiling polling v3.11.0 Compiling lazy_static v1.5.0 Compiling proc-macro-crate v3.5.0 Compiling orbital_light v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_light) Compiling core_maths v0.1.1 Compiling base64 v0.23.1 Compiling ravif v0.13.0 Compiling orbital_macros v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/orbital_macros) Compiling ttf-parser v0.25.1 Compiling orbital_ecs v0.1.0 (/var/lib/forgejo-runner/home/workspace/SakulFlee/Orbital/Crates/ecs) Compiling libloading v0.9.0 Compiling gpu-allocator v0.28.0 Compiling calloop v0.13.0 Compiling fontdue v0.9.5 error: The platform you&#39;re compiling for is not supported by winit --&gt; /usr/local/cargo/git/checkouts/Orbital-Winit-c3e518048d313a61/a9d045d/src/platform_impl/mod.rs:78:1 | 78 | compile_error!(&quot;The platform you&#39;re compiling for is not supported by winit&quot;); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: could not compile `winit` (lib) due to 1 previous error warning: build failed, waiting for other jobs to finish... error: command `/usr/local/rustup/toolchains/1.99.1-x86_64-unknown-linux-gnu/bin/cargo &#39;--color=auto&#39; test --no-run --message-format json-render-diagnostics --package orbital_app --package orbital_ecs_bridge` exited with code 101 </code></pre> </details> <details> <summary>Doctest output tail</summary> <pre><code>warning: Cargo.toml: `lints.clippy.large-enum-variant` is deprecated in favor of `lints.clippy.large_enum_variant` and will not work in a future edition warning: Cargo.toml: `lints.clippy.map-entry` is deprecated in favor of `lints.clippy.map_entry` and will not work in a future edition warning: Cargo.toml: `lints.clippy.match-wildcard-for-single-variants` is deprecated in favor of `lints.clippy.match_wildcard_for_single_variants` and will not work in a future edition warning: Cargo.toml: `lints.clippy.redundant-closure-for-method-calls` is deprecated in favor of `lints.clippy.redundant_closure_for_method_calls` and will not work in a future edition warning: Cargo.toml: `lints.clippy.trivially-copy-pass-by-ref` is deprecated in favor of `lints.clippy.trivially_copy_pass_by_ref` and will not work in a future edition warning: Cargo.toml: `lints.clippy.type-complexity` is deprecated in favor of `lints.clippy.type_complexity` and will not work in a future edition warning: workspace (manifest) generated 6 warnings Compiling wgpu-naga-bridge v30.0.1 Compiling image v0.25.10 Compiling winit v0.30.8 (https://forgejo.sakul-flee.de/SakulFlee/Orbital-Winit.git?branch=main#a9d045d6) Compiling wgpu-hal v30.0.1 error: The platform you&#39;re compiling for is not supported by winit --&gt; /usr/local/cargo/git/checkouts/Orbital-Winit-c3e518048d313a61/a9d045d/src/platform_impl/mod.rs:78:1 | 78 | compile_error!(&quot;The platform you&#39;re compiling for is not supported by winit&quot;); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: could not compile `winit` (lib) due to 1 previous error warning: build failed, waiting for other jobs to finish... </code></pre> </details>
Sign in to join this conversation.
No description provided.