From 4fe747c6dda4b4b0ea946e5d1b7a5c028bbbe987 Mon Sep 17 00:00:00 2001 From: Joona Aalto Date: Tue, 2 Jan 2024 18:30:00 +0200 Subject: [PATCH] Implement `Neg` for `Direction2d` and `Direction3d` --- crates/bevy_math/src/primitives/dim2.rs | 7 +++++++ crates/bevy_math/src/primitives/dim3.rs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/crates/bevy_math/src/primitives/dim2.rs b/crates/bevy_math/src/primitives/dim2.rs index fbb7811cfbb2e..8b34a100ebde3 100644 --- a/crates/bevy_math/src/primitives/dim2.rs +++ b/crates/bevy_math/src/primitives/dim2.rs @@ -58,6 +58,13 @@ impl std::ops::Deref for Direction2d { } } +impl std::ops::Neg for Direction2d { + type Output = Self; + fn neg(self) -> Self::Output { + Self(-self.0) + } +} + /// A circle primitive #[derive(Clone, Copy, Debug)] pub struct Circle { diff --git a/crates/bevy_math/src/primitives/dim3.rs b/crates/bevy_math/src/primitives/dim3.rs index 0177d03fc3620..93b92fbc6c746 100644 --- a/crates/bevy_math/src/primitives/dim3.rs +++ b/crates/bevy_math/src/primitives/dim3.rs @@ -58,6 +58,13 @@ impl std::ops::Deref for Direction3d { } } +impl std::ops::Neg for Direction3d { + type Output = Self; + fn neg(self) -> Self::Output { + Self(-self.0) + } +} + /// A sphere primitive #[derive(Clone, Copy, Debug)] pub struct Sphere {