diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-04-24 11:16:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-24 11:16:20 +0200 |
commit | 5ae1e172da08a63b14635f5d06e32385901525e2 (patch) | |
tree | 9a9bd7f4dd90eada323f504b551e7630802fa494 /core/math/vector3.h | |
parent | 90ef1fd03d43d51f09b730dee107c0e407cf0703 (diff) | |
parent | 9a37ff1e34fe445a9168a7d91ae1df7d9928eb25 (diff) | |
download | redot-engine-5ae1e172da08a63b14635f5d06e32385901525e2.tar.gz |
Merge pull request #8277 from tagcup/math_checks
Added various functions basic math classes. Also enabled math checks …
Diffstat (limited to 'core/math/vector3.h')
-rw-r--r-- | core/math/vector3.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h index a6bc20ccb2..5f4390fbd1 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -389,7 +389,8 @@ Vector3 Vector3::normalized() const { } bool Vector3::is_normalized() const { - return Math::isequal_approx(length(), (real_t)1.0); + // use length_squared() instead of length() to avoid sqrt(), makes it more stringent. + return Math::is_equal_approx(length_squared(), 1.0); } Vector3 Vector3::inverse() const { @@ -404,7 +405,7 @@ void Vector3::zero() { // slide returns the component of the vector along the given plane, specified by its normal vector. Vector3 Vector3::slide(const Vector3 &p_n) const { -#ifdef DEBUG_ENABLED +#ifdef MATH_CHECKS ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector3()); #endif return *this - p_n * this->dot(p_n); @@ -415,7 +416,7 @@ Vector3 Vector3::bounce(const Vector3 &p_n) const { } Vector3 Vector3::reflect(const Vector3 &p_n) const { -#ifdef DEBUG_ENABLED +#ifdef MATH_CHECKS ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector3()); #endif return 2.0 * p_n * this->dot(p_n) - *this; |