From ed44eb3913b1180604d468f1ae88fcd2dd3f68a5 Mon Sep 17 00:00:00 2001 From: Brezak Date: Wed, 20 Mar 2024 15:21:50 +0100 Subject: [PATCH] Add a from Dir2 impl for Vec2 (#12594) # Objective Allow converting from `Dir2` to `Vec2` in generic code. Fixes #12529. ## Solution Added a `From` impl for `Vec2`. --- crates/bevy_math/src/direction.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/bevy_math/src/direction.rs b/crates/bevy_math/src/direction.rs index a88d44b6024a4..150a9105b86e1 100644 --- a/crates/bevy_math/src/direction.rs +++ b/crates/bevy_math/src/direction.rs @@ -151,6 +151,12 @@ impl TryFrom for Dir2 { } } +impl From for Vec2 { + fn from(value: Dir2) -> Self { + value.as_vec2() + } +} + impl std::ops::Deref for Dir2 { type Target = Vec2; fn deref(&self) -> &Self::Target {