From 2b24871814a528b4b510fb45072f5a9a1457c81f Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 27 May 2023 11:12:31 +0200 Subject: [PATCH] Made the parameter of snap and snapped in Vector3 const reference. --- core/math/vector3.cpp | 4 ++-- core/math/vector3.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index 83eea368f..d4ca77f4c 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -51,12 +51,12 @@ real_t Vector3::get_axis(int p_axis) const { return operator[](p_axis); } -void Vector3::snap(Vector3 p_val) { +void Vector3::snap(const Vector3 &p_val) { x = Math::stepify(x, p_val.x); y = Math::stepify(y, p_val.y); z = Math::stepify(z, p_val.z); } -Vector3 Vector3::snapped(Vector3 p_val) const { +Vector3 Vector3::snapped(const Vector3 &p_val) const { Vector3 v = *this; v.snap(p_val); return v; diff --git a/core/math/vector3.h b/core/math/vector3.h index fed062843..2c560c3ad 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -90,8 +90,8 @@ struct _NO_DISCARD_CLASS_ Vector3 { _FORCE_INLINE_ void zero(); - void snap(Vector3 p_val); - Vector3 snapped(Vector3 p_val) const; + void snap(const Vector3 &p_val); + Vector3 snapped(const Vector3 &p_val) const; void rotate(const Vector3 &p_axis, real_t p_phi); Vector3 rotated(const Vector3 &p_axis, real_t p_phi) const;