From 3075a9be50572a1ac7c36309b0ab5da39822d61c Mon Sep 17 00:00:00 2001 From: Alex <58638691+Alex-Velez@users.noreply.github.com> Date: Fri, 28 Jan 2022 14:33:38 -0600 Subject: [PATCH] Vector2 Constants - `zero()` and `one()` functions changed to const/inline functions --- raylib/src/core/math.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/raylib/src/core/math.rs b/raylib/src/core/math.rs index cfa723e0..f842d866 100644 --- a/raylib/src/core/math.rs +++ b/raylib/src/core/math.rs @@ -165,6 +165,18 @@ impl Vector2 { Vector2 { x, y } } + /// Returns a new `Vector2` with both components set to zero. + #[inline] + pub const fn zero() -> Vector2 { + Vector2 { x: 0.0, y: 0.0 } + } + + /// Returns a new `Vector2` with both components set to one. + #[inline] + pub const fn one() -> Vector2 { + Vector2 { x: 1.0, y: 1.0 } + } + /// Calculates the vector length. pub fn length(&self) -> f32 { ((self.x * self.x) + (self.y * self.y)).sqrt()