mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
e6261b0f5f
# Objective Bevy's direction types have `new` and `new_unchecked` constructors, but no unchecked variant for the `Dir2::from_xy` and `Dir3::from_xyz` methods. For me, this has several times lead to constructing directions like this, in cases where the components of the direction are already known to be normalized: ```rust let normal = Dir2::new_unchecked(Vec2::new(-ray.direction.x.signum(), 0.0)); ``` ```rust segment.direction = Dir2::new_unchecked(Vec2::new(-segment.direction.x, segment.direction.y)); ``` For consistency and ergonomics, it would be nice to have unchecked variants of `Dir2::from_xy` and `Dir3::from_xyz`: ```rust let normal = Dir2::from_xy_unchecked(-ray.direction.x.signum(), 0.0); ``` ```rust segment.direction = Dir2::from_xy_unchecked(-segment.direction.x, segment.direction.y); ``` ## Solution Add `Dir2::from_xy_unchecked` and `Dir3::from_xyz_unchecked`. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |