bevy/crates
Matty 221d925e90
Make Transform::rotate_axis and Transform::rotate_local_axis use Dir3 (#12986)
# Objective

Related to #12981

Presently, there is a footgun where we allow non-normalized vectors to
be passed in the `axis` parameters of `Transform::rotate_axis` and
`Transform::rotate_local_axis`. These methods invoke
`Quat::from_axis_angle` which expects the vector to be normalized. This
PR aims to address this.

## Solution

Require `Dir3`-valued `axis` parameters for these functions so that the
vector's normalization can be enforced at type-level.

---

## Migration Guide

All calls to `Transform::rotate_axis` and `Transform::rotate_local_axis`
will need to be updated to use a `Dir3` for the `axis` parameter rather
than a `Vec3`. For a general input, this means calling `Dir3::new` and
handling the `Result`, but if the previous vector is already known to be
normalized, `Dir3::new_unchecked` can be called instead. Note that
literals like `Vec3::X` also have corresponding `Dir3` literals; e.g.
`Dir3::X`, `Dir3::NEG_Y` and so on.

---

## Discussion

This axis input is unambigiously a direction instead of a vector, and
that should probably be reflected and enforced by the function
signature. In previous cases where we used, e.g., `impl TryInto<Dir3>`,
the associated methods already implemented (and required!) additional
fall-back logic, since the input is conceptually more complicated than
merely specifying an axis. In this case, I think it's fairly
cut-and-dry, and I'm pretty sure these methods just predate our
direction types.
2024-04-16 13:07:03 +00:00
..
bevy_a11y Set the logo and favicon for all of Bevy's published crates (#12696) 2024-03-25 18:52:50 +00:00
bevy_animation fix find_current_keyframe panic (#12931) 2024-04-13 22:32:21 +00:00
bevy_app Optimize Event Updates (#12936) 2024-04-13 14:11:28 +00:00
bevy_asset Instrument asset loading and processing. (#12988) 2024-04-16 12:02:11 +00:00
bevy_audio updated audio_source.rs documentation (#12765) 2024-03-28 19:10:09 +00:00
bevy_color Fix crates not building individually (#12948) 2024-04-14 00:06:03 +00:00
bevy_core Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_core_pipeline Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_derive Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_dev_tools Fix crates not building individually (#12948) 2024-04-14 00:06:03 +00:00
bevy_diagnostic Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
bevy_dylib Set the logo and favicon for all of Bevy's published crates (#12696) 2024-03-25 18:52:50 +00:00
bevy_dynamic_plugin Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_ecs Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_ecs_compile_fail_tests Fix Ci failing over dead code in tests (#12623) 2024-03-21 18:08:47 +00:00
bevy_encase_derive Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_gilrs Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_gizmos Add double end arrow to gizmos (#11890) 2024-04-16 01:34:22 +00:00
bevy_gltf Fix crates not building individually (#12948) 2024-04-14 00:06:03 +00:00
bevy_hierarchy fix bevy_hierarchy crate optional feature bevy_app (#12943) 2024-04-13 04:46:00 +00:00
bevy_input Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_internal Instrument asset loading and processing. (#12988) 2024-04-16 12:02:11 +00:00
bevy_log Refactor App and SubApp internals for better separation (#9202) 2024-03-31 03:16:10 +00:00
bevy_macro_utils Clean up some low level dependencies (#12858) 2024-04-08 19:45:42 +00:00
bevy_macros_compile_fail_tests Fix Ci failing over dead code in tests (#12623) 2024-03-21 18:08:47 +00:00
bevy_math Random sampling of directions and quaternions (#12857) 2024-04-04 23:13:00 +00:00
bevy_mikktspace Enable clippy::ref_as_ptr (#12918) 2024-04-10 20:16:48 +00:00
bevy_pbr Add Cascades to the type registry, fixing lights in glTF. (#12989) 2024-04-16 05:16:45 +00:00
bevy_ptr Document the lifetime requirement of byte_offset and byte_add (#12893) 2024-04-08 17:13:35 +00:00
bevy_reflect impl Reflect for EntityHashSet (#12971) 2024-04-16 02:48:03 +00:00
bevy_reflect_compile_fail_tests Fix Ci failing over dead code in tests (#12623) 2024-03-21 18:08:47 +00:00
bevy_render Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_scene Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_sprite Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_tasks Fix beta CI (#12913) 2024-04-09 17:33:59 +00:00
bevy_text Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_time Optimize Event Updates (#12936) 2024-04-13 14:11:28 +00:00
bevy_transform Make Transform::rotate_axis and Transform::rotate_local_axis use Dir3 (#12986) 2024-04-16 13:07:03 +00:00
bevy_ui Divide the single VisibleEntities list into separate lists for 2D meshes, 3D meshes, lights, and UI elements, for performance. (#12582) 2024-04-11 20:33:20 +00:00
bevy_utils Cleanup the multithreaded executor (#12969) 2024-04-16 02:37:19 +00:00
bevy_window Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00
bevy_winit Fix beta CI (#12913) 2024-04-09 17:33:59 +00:00