summaryrefslogtreecommitdiffstats
path: root/core/math/vector3.h
diff options
context:
space:
mode:
authorFerenc Arn <tagcup@yahoo.com>2017-04-05 17:47:13 -0500
committerFerenc Arn <tagcup@yahoo.com>2017-04-06 13:03:56 -0500
commit9a37ff1e34fe445a9168a7d91ae1df7d9928eb25 (patch)
treef524cd3d1fd4c31e7e1fe868eea45d3d3086c2f6 /core/math/vector3.h
parent454f53c77659721a529c48fd4be6bf80d33c0082 (diff)
downloadredot-engine-9a37ff1e34fe445a9168a7d91ae1df7d9928eb25.tar.gz
Added various functions basic math classes. Also enabled math checks only for debug builds.
Added set_scale, set_rotation_euler, set_rotation_axis_angle. Addresses #2565 directly. Added an euler angle constructor for Basis in GDScript and also exposed is_normalized for vectors and quaternions. Various other changes mostly cosmetic in nature.
Diffstat (limited to 'core/math/vector3.h')
-rw-r--r--core/math/vector3.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 8550ae7009..22d45400b1 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -388,7 +388,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 {
@@ -403,7 +404,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);
@@ -414,7 +415,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;