mirror of
https://github.com/bevyengine/bevy
synced 2024-09-20 14:32:06 +00:00
Implement Neg
for Direction2d
and Direction3d
(#11179)
# Objective I frequently encounter cases where I need to get the opposite direction. This currently requires something like `Direction2d::from_normalized(-*direction)`, which is very inconvenient. ## Solution Implement `Neg` for `Direction2d` and `Direction3d`.
This commit is contained in:
parent
4034740396
commit
6086d4193e
2 changed files with 14 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue