BlackPhlox/bevy_dolly

Change all "2" functionality to From impls

Closed this issue · 1 comments

By this I mean functions like transform_2_bevy. Because the numbers 2 and 3 have significant connotations in glam (and by extent Bevy) with the dimensionality, I was confused about this function. The rust ecosystem already provides a trait for exactly this kind of conversion, namely From and the automatically implemented To, so I suggest we use this instead. If you are fine with this change, I volunteer to implement it and setup a PR :)

Hi there 👋 Thanks for creating this issue

Yes, this is a bit of an oversight on my part, I think I started trying to use From but ran into
impl From doesn't use only types from inside the current crate error
and couldn't get wrapping the type to work
(See:

bevy_dolly/src/map.rs

Lines 83 to 92 in aae4ce3

impl From<dolly::transform::Transform<RightHanded>> for DollyTransformInto {
fn from(transform: dolly::transform::Transform<RightHanded>) -> Self {
let (translation, rotation) = transform.into_position_rotation();
DollyTransformInto(Transform {
translation: bevy::math::Vec3::new(translation.x, translation.y, translation.z),
rotation: bevy::math::Quat::from_xyzw(rotation.x, rotation.y, rotation.z, rotation.w),
..default()
})
}
}
)

You are very welcome to change it and create a PR <3