summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/image.cpp2
-rw-r--r--core/math/math_2d.cpp9
-rw-r--r--core/math/math_defs.h4
-rw-r--r--core/math/math_funcs.h2
-rw-r--r--core/math/matrix3.cpp126
-rw-r--r--core/math/matrix3.h20
-rw-r--r--core/math/quat.cpp4
-rw-r--r--core/math/quat.h3
-rw-r--r--core/math/vector3.h7
-rw-r--r--core/script_language.h1
-rw-r--r--core/ustring.cpp4
-rw-r--r--core/variant_call.cpp18
12 files changed, 156 insertions, 44 deletions
diff --git a/core/image.cpp b/core/image.cpp
index 5fb7cfa812..8a09dc1a8c 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -94,7 +94,7 @@ void Image::_get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p
uint32_t ofs = (p_y * width + p_x) * p_pixelsize;
for (uint32_t i = 0; i < p_pixelsize; i++) {
- p_dst[ofs] = p_src[ofs + i];
+ p_dst[i] = p_src[ofs + i];
}
}
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp
index 20b916ee3b..962a42acb9 100644
--- a/core/math/math_2d.cpp
+++ b/core/math/math_2d.cpp
@@ -63,7 +63,8 @@ Vector2 Vector2::normalized() const {
}
bool Vector2::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);
}
real_t Vector2::distance_to(const Vector2 &p_vector2) const {
@@ -281,7 +282,7 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c
// slide returns the component of the vector along the given plane, specified by its normal vector.
Vector2 Vector2::slide(const Vector2 &p_n) const {
-#ifdef DEBUG_ENABLED
+#ifdef MATH_CHECKS
ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector2());
#endif
return *this - p_n * this->dot(p_n);
@@ -292,7 +293,7 @@ Vector2 Vector2::bounce(const Vector2 &p_n) const {
}
Vector2 Vector2::reflect(const Vector2 &p_n) const {
-#ifdef DEBUG_ENABLED
+#ifdef MATH_CHECKS
ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector2());
#endif
return 2.0 * p_n * this->dot(p_n) - *this;
@@ -439,7 +440,9 @@ Transform2D Transform2D::inverse() const {
void Transform2D::affine_invert() {
real_t det = basis_determinant();
+#ifdef MATH_CHECKS
ERR_FAIL_COND(det == 0);
+#endif
real_t idet = 1.0 / det;
SWAP(elements[0][0], elements[1][1]);
diff --git a/core/math/math_defs.h b/core/math/math_defs.h
index 1a5768e515..3d9eb63e11 100644
--- a/core/math/math_defs.h
+++ b/core/math/math_defs.h
@@ -35,6 +35,10 @@
#define CMP_NORMALIZE_TOLERANCE 0.000001
#define CMP_POINT_IN_PLANE_EPSILON 0.00001
+#ifdef DEBUG_ENABLED
+#define MATH_CHECKS
+#endif
+
#define USEC_TO_SEC(m_usec) ((m_usec) / 1000000.0)
/**
* "Real" is a type that will be translated to either floats or fixed depending
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index d71d9bd792..5bfbc1005f 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -168,7 +168,7 @@ public:
static float random(float from, float to);
static real_t random(int from, int to) { return (real_t)random((real_t)from, (real_t)to); }
- static _ALWAYS_INLINE_ bool isequal_approx(real_t a, real_t b) {
+ static _ALWAYS_INLINE_ bool is_equal_approx(real_t a, real_t b) {
// TODO: Comparing floats for approximate-equality is non-trivial.
// Using epsilon should cover the typical cases in Godot (where a == b is used to compare two reals), such as matrix and vector comparison operators.
// A proper implementation in terms of ULPs should eventually replace the contents of this function.
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index ef368009d1..c733251c3c 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -62,8 +62,9 @@ void Basis::invert() {
real_t det = elements[0][0] * co[0] +
elements[0][1] * co[1] +
elements[0][2] * co[2];
-
+#ifdef MATH_CHECKS
ERR_FAIL_COND(det == 0);
+#endif
real_t s = 1.0 / det;
set(co[0] * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s,
@@ -72,8 +73,9 @@ void Basis::invert() {
}
void Basis::orthonormalize() {
+#ifdef MATH_CHECKS
ERR_FAIL_COND(determinant() == 0);
-
+#endif
// Gram-Schmidt Process
Vector3 x = get_axis(0);
@@ -102,20 +104,20 @@ bool Basis::is_orthogonal() const {
Basis id;
Basis m = (*this) * transposed();
- return isequal_approx(id, m);
+ return is_equal_approx(id, m);
}
bool Basis::is_rotation() const {
- return Math::isequal_approx(determinant(), 1) && is_orthogonal();
+ return Math::is_equal_approx(determinant(), 1) && is_orthogonal();
}
bool Basis::is_symmetric() const {
- if (Math::abs(elements[0][1] - elements[1][0]) > CMP_EPSILON)
+ if (!Math::is_equal_approx(elements[0][1], elements[1][0]))
return false;
- if (Math::abs(elements[0][2] - elements[2][0]) > CMP_EPSILON)
+ if (!Math::is_equal_approx(elements[0][2], elements[2][0]))
return false;
- if (Math::abs(elements[1][2] - elements[2][1]) > CMP_EPSILON)
+ if (!Math::is_equal_approx(elements[1][2], elements[2][1]))
return false;
return true;
@@ -123,11 +125,11 @@ bool Basis::is_symmetric() const {
Basis Basis::diagonalize() {
- //NOTE: only implemented for symmetric matrices
- //with the Jacobi iterative method method
-
+//NOTE: only implemented for symmetric matrices
+//with the Jacobi iterative method method
+#ifdef MATH_CHECKS
ERR_FAIL_COND_V(!is_symmetric(), Basis());
-
+#endif
const int ite_max = 1024;
real_t off_matrix_norm_2 = elements[0][1] * elements[0][1] + elements[0][2] * elements[0][2] + elements[1][2] * elements[1][2];
@@ -160,7 +162,7 @@ Basis Basis::diagonalize() {
// Compute the rotation angle
real_t angle;
- if (Math::abs(elements[j][j] - elements[i][i]) < CMP_EPSILON) {
+ if (Math::is_equal_approx(elements[j][j], elements[i][i])) {
angle = Math_PI / 4;
} else {
angle = 0.5 * Math::atan(2 * elements[i][j] / (elements[j][j] - elements[i][i]));
@@ -226,11 +228,25 @@ Basis Basis::scaled(const Vector3 &p_scale) const {
}
Vector3 Basis::get_scale() const {
- // We are assuming M = R.S, and performing a polar decomposition to extract R and S.
- // FIXME: We eventually need a proper polar decomposition.
- // As a cheap workaround until then, to ensure that R is a proper rotation matrix with determinant +1
- // (such that it can be represented by a Quat or Euler angles), we absorb the sign flip into the scaling matrix.
- // As such, it works in conjunction with get_rotation().
+ // FIXME: We are assuming M = R.S (R is rotation and S is scaling), and use polar decomposition to extract R and S.
+ // A polar decomposition is M = O.P, where O is an orthogonal matrix (meaning rotation and reflection) and
+ // P is a positive semi-definite matrix (meaning it contains absolute values of scaling along its diagonal).
+ //
+ // Despite being different from what we want to achieve, we can nevertheless make use of polar decomposition
+ // here as follows. We can split O into a rotation and a reflection as O = R.Q, and obtain M = R.S where
+ // we defined S = Q.P. Now, R is a proper rotation matrix and S is a (signed) scaling matrix,
+ // which can involve negative scalings. However, there is a catch: unlike the polar decomposition of M = O.P,
+ // the decomposition of O into a rotation and reflection matrix as O = R.Q is not unique.
+ // Therefore, we are going to do this decomposition by sticking to a particular convention.
+ // This may lead to confusion for some users though.
+ //
+ // The convention we use here is to absorb the sign flip into the scaling matrix.
+ // The same convention is also used in other similar functions such as set_scale,
+ // get_rotation_axis_angle, get_rotation, set_rotation_axis_angle, set_rotation_euler, ...
+ //
+ // A proper way to get rid of this issue would be to store the scaling values (or at least their signs)
+ // as a part of Basis. However, if we go that path, we need to disable direct (write) access to the
+ // matrix elements.
real_t det_sign = determinant() > 0 ? 1 : -1;
return det_sign * Vector3(
Vector3(elements[0][0], elements[1][0], elements[2][0]).length(),
@@ -238,6 +254,17 @@ Vector3 Basis::get_scale() const {
Vector3(elements[0][2], elements[1][2], elements[2][2]).length());
}
+// Sets scaling while preserving rotation.
+// This requires some care when working with matrices with negative determinant,
+// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation.
+// For details, see the explanation in get_scale.
+void Basis::set_scale(const Vector3 &p_scale) {
+ Vector3 e = get_euler();
+ Basis(); // reset to identity
+ scale(p_scale);
+ rotate(e);
+}
+
// Multiplies the matrix from left by the rotation matrix: M -> R.M
// Note that this does *not* rotate the matrix itself.
//
@@ -260,6 +287,7 @@ void Basis::rotate(const Vector3 &p_euler) {
*this = rotated(p_euler);
}
+// TODO: rename this to get_rotation_euler
Vector3 Basis::get_rotation() const {
// Assumes that the matrix can be decomposed into a proper rotation and scaling matrix as M = R.S,
// and returns the Euler angles corresponding to the rotation part, complementing get_scale().
@@ -274,6 +302,42 @@ Vector3 Basis::get_rotation() const {
return m.get_euler();
}
+void Basis::get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const {
+ // Assumes that the matrix can be decomposed into a proper rotation and scaling matrix as M = R.S,
+ // and returns the Euler angles corresponding to the rotation part, complementing get_scale().
+ // See the comment in get_scale() for further information.
+ Basis m = orthonormalized();
+ real_t det = m.determinant();
+ if (det < 0) {
+ // Ensure that the determinant is 1, such that result is a proper rotation matrix which can be represented by Euler angles.
+ m.scale(Vector3(-1, -1, -1));
+ }
+
+ m.get_axis_angle(p_axis, p_angle);
+}
+
+// Sets rotation while preserving scaling.
+// This requires some care when working with matrices with negative determinant,
+// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation.
+// For details, see the explanation in get_scale.
+void Basis::set_rotation_euler(const Vector3 &p_euler) {
+ Vector3 s = get_scale();
+ Basis(); // reset to identity
+ scale(s);
+ rotate(p_euler);
+}
+
+// Sets rotation while preserving scaling.
+// This requires some care when working with matrices with negative determinant,
+// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation.
+// For details, see the explanation in get_scale.
+void Basis::set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle) {
+ Vector3 s = get_scale();
+ Basis(); // reset to identity
+ scale(s);
+ rotate(p_axis, p_angle);
+}
+
// get_euler returns a vector containing the Euler angles in the format
// (a1,a2,a3), where a3 is the angle of the first rotation, and a1 is the last
// (following the convention they are commonly defined in the literature).
@@ -294,9 +358,9 @@ Vector3 Basis::get_euler() const {
// -cx*cz*sy+sx*sz cz*sx+cx*sy*sz cx*cy
Vector3 euler;
-
+#ifdef MATH_CHECKS
ERR_FAIL_COND_V(is_rotation() == false, euler);
-
+#endif
euler.y = Math::asin(elements[0][2]);
if (euler.y < Math_PI * 0.5) {
if (euler.y > -Math_PI * 0.5) {
@@ -340,11 +404,11 @@ void Basis::set_euler(const Vector3 &p_euler) {
*this = xmat * (ymat * zmat);
}
-bool Basis::isequal_approx(const Basis &a, const Basis &b) const {
+bool Basis::is_equal_approx(const Basis &a, const Basis &b) const {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
- if (Math::isequal_approx(a.elements[i][j], b.elements[i][j]) == false)
+ if (Math::is_equal_approx(a.elements[i][j], b.elements[i][j]) == false)
return false;
}
}
@@ -387,8 +451,9 @@ Basis::operator String() const {
}
Basis::operator Quat() const {
+#ifdef MATH_CHECKS
ERR_FAIL_COND_V(is_rotation() == false, Quat());
-
+#endif
real_t trace = elements[0][0] + elements[1][1] + elements[2][2];
real_t temp[4];
@@ -482,9 +547,10 @@ void Basis::set_orthogonal_index(int p_index) {
*this = _ortho_bases[p_index];
}
-void Basis::get_axis_and_angle(Vector3 &r_axis, real_t &r_angle) const {
+void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
+#ifdef MATH_CHECKS
ERR_FAIL_COND(is_rotation() == false);
-
+#endif
real_t angle, x, y, z; // variables for result
real_t epsilon = 0.01; // margin to allow for rounding errors
real_t epsilon2 = 0.1; // margin to distinguish between 0 and 180 degrees
@@ -573,11 +639,11 @@ Basis::Basis(const Quat &p_quat) {
xz - wy, yz + wx, 1.0 - (xx + yy));
}
-Basis::Basis(const Vector3 &p_axis, real_t p_phi) {
- // Rotation matrix from axis and angle, see https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle
-
+void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) {
+// Rotation matrix from axis and angle, see https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_angle
+#ifdef MATH_CHECKS
ERR_FAIL_COND(p_axis.is_normalized() == false);
-
+#endif
Vector3 axis_sq(p_axis.x * p_axis.x, p_axis.y * p_axis.y, p_axis.z * p_axis.z);
real_t cosine = Math::cos(p_phi);
@@ -595,3 +661,7 @@ Basis::Basis(const Vector3 &p_axis, real_t p_phi) {
elements[2][1] = p_axis.y * p_axis.z * (1.0 - cosine) + p_axis.x * sine;
elements[2][2] = axis_sq.z + cosine * (1.0 - axis_sq.z);
}
+
+Basis::Basis(const Vector3 &p_axis, real_t p_phi) {
+ set_axis_angle(p_axis, p_phi);
+}
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index 08e963f56e..c3eeb1f705 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -77,15 +77,25 @@ public:
void rotate(const Vector3 &p_euler);
Basis rotated(const Vector3 &p_euler) const;
+
Vector3 get_rotation() const;
+ void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const;
- void scale(const Vector3 &p_scale);
- Basis scaled(const Vector3 &p_scale) const;
- Vector3 get_scale() const;
+ void set_rotation_euler(const Vector3 &p_euler);
+ void set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle);
Vector3 get_euler() const;
void set_euler(const Vector3 &p_euler);
+ void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const;
+ void set_axis_angle(const Vector3 &p_axis, real_t p_phi);
+
+ void scale(const Vector3 &p_scale);
+ Basis scaled(const Vector3 &p_scale) const;
+
+ Vector3 get_scale() const;
+ void set_scale(const Vector3 &p_scale);
+
// transposed dot products
_FORCE_INLINE_ real_t tdotx(const Vector3 &v) const {
return elements[0][0] * v[0] + elements[1][0] * v[1] + elements[2][0] * v[2];
@@ -97,7 +107,7 @@ public:
return elements[0][2] * v[0] + elements[1][2] * v[1] + elements[2][2] * v[2];
}
- bool isequal_approx(const Basis &a, const Basis &b) const;
+ bool is_equal_approx(const Basis &a, const Basis &b) const;
bool operator==(const Basis &p_matrix) const;
bool operator!=(const Basis &p_matrix) const;
@@ -121,8 +131,6 @@ public:
operator String() const;
- void get_axis_and_angle(Vector3 &r_axis, real_t &r_angle) const;
-
/* create / set */
_FORCE_INLINE_ void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index 9662542224..0bea97c2e8 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -92,6 +92,10 @@ Quat Quat::normalized() const {
return *this / length();
}
+bool Quat::is_normalized() const {
+ return Math::is_equal_approx(length(), 1.0);
+}
+
Quat Quat::inverse() const {
return Quat(-x, -y, -z, w);
}
diff --git a/core/math/quat.h b/core/math/quat.h
index 76b3cde2a3..f22275b457 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -48,6 +48,7 @@ public:
real_t length() const;
void normalize();
Quat normalized() const;
+ bool is_normalized() const;
Quat inverse() const;
_FORCE_INLINE_ real_t dot(const Quat &q) const;
void set_euler(const Vector3 &p_euler);
@@ -56,7 +57,7 @@ public:
Quat slerpni(const Quat &q, const real_t &t) const;
Quat cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const;
- _FORCE_INLINE_ void get_axis_and_angle(Vector3 &r_axis, real_t &r_angle) const {
+ _FORCE_INLINE_ void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
r_angle = 2 * Math::acos(w);
r_axis.x = x / Math::sqrt(1 - w * w);
r_axis.y = y / Math::sqrt(1 - w * w);
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;
diff --git a/core/script_language.h b/core/script_language.h
index 1ec02f5845..115ab59dca 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -199,6 +199,7 @@ public:
virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL) const = 0;
virtual Script *create_script() const = 0;
virtual bool has_named_classes() const = 0;
+ virtual bool can_inherit_from_file() { return false; }
virtual int find_function(const String &p_function, const String &p_code) const = 0;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const = 0;
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
diff --git a/core/ustring.cpp b/core/ustring.cpp
index d2d4b6507f..b01f680dd6 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -513,14 +513,16 @@ String String::camelcase_to_underscore(bool lowercase) const {
for (size_t i = 1; i < this->size(); i++) {
bool is_upper = cstr[i] >= A && cstr[i] <= Z;
+ bool is_number = cstr[i] >= '0' && cstr[i] <= '9';
bool are_next_2_lower = false;
bool was_precedent_upper = cstr[i - 1] >= A && cstr[i - 1] <= Z;
+ bool was_precedent_number = cstr[i - 1] >= '0' && cstr[i - 1] <= '9';
if (i + 2 < this->size()) {
are_next_2_lower = cstr[i + 1] >= a && cstr[i + 1] <= z && cstr[i + 2] >= a && cstr[i + 2] <= z;
}
- bool should_split = ((is_upper && !was_precedent_upper) || (was_precedent_upper && is_upper && are_next_2_lower));
+ bool should_split = ((is_upper && !was_precedent_upper && !was_precedent_number) || (was_precedent_upper && is_upper && are_next_2_lower) || (is_number && !was_precedent_number));
if (should_split) {
new_string += this->substr(start_index, i - start_index) + "_";
start_index = i;
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index e87dfd2768..beaee188eb 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -328,6 +328,7 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Vector2, normalized);
VCALL_LOCALMEM0R(Vector2, length);
VCALL_LOCALMEM0R(Vector2, length_squared);
+ VCALL_LOCALMEM0R(Vector2, is_normalized);
VCALL_LOCALMEM1R(Vector2, distance_to);
VCALL_LOCALMEM1R(Vector2, distance_squared_to);
VCALL_LOCALMEM1R(Vector2, angle_to);
@@ -362,6 +363,7 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Vector3, max_axis);
VCALL_LOCALMEM0R(Vector3, length);
VCALL_LOCALMEM0R(Vector3, length_squared);
+ VCALL_LOCALMEM0R(Vector3, is_normalized);
VCALL_LOCALMEM0R(Vector3, normalized);
VCALL_LOCALMEM0R(Vector3, inverse);
VCALL_LOCALMEM1R(Vector3, snapped);
@@ -418,6 +420,7 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Quat, length);
VCALL_LOCALMEM0R(Quat, length_squared);
VCALL_LOCALMEM0R(Quat, normalized);
+ VCALL_LOCALMEM0R(Quat, is_normalized);
VCALL_LOCALMEM0R(Quat, inverse);
VCALL_LOCALMEM1R(Quat, dot);
VCALL_LOCALMEM1R(Quat, xform);
@@ -704,6 +707,9 @@ struct _VariantCall {
VCALL_PTR1R(Basis, scaled);
VCALL_PTR0R(Basis, get_scale);
VCALL_PTR0R(Basis, get_euler);
+ VCALL_PTR1(Basis, set_scale);
+ VCALL_PTR1(Basis, set_rotation_euler);
+ VCALL_PTR2(Basis, set_rotation_axis_angle);
VCALL_PTR1R(Basis, tdotx);
VCALL_PTR1R(Basis, tdoty);
VCALL_PTR1R(Basis, tdotz);
@@ -875,6 +881,11 @@ struct _VariantCall {
r_ret = Basis(p_args[0]->operator Vector3(), p_args[1]->operator real_t());
}
+ static void Basis_init3(Variant &r_ret, const Variant **p_args) {
+
+ r_ret = Basis(p_args[0]->operator Vector3());
+ }
+
static void Transform_init1(Variant &r_ret, const Variant **p_args) {
Transform t;
@@ -1429,6 +1440,7 @@ void register_variant_methods() {
ADDFUNC0(VECTOR2, REAL, Vector2, length, varray());
ADDFUNC0(VECTOR2, REAL, Vector2, angle, varray());
ADDFUNC0(VECTOR2, REAL, Vector2, length_squared, varray());
+ ADDFUNC0(VECTOR2, BOOL, Vector2, is_normalized, varray());
ADDFUNC1(VECTOR2, REAL, Vector2, distance_to, VECTOR2, "to", varray());
ADDFUNC1(VECTOR2, REAL, Vector2, distance_squared_to, VECTOR2, "to", varray());
ADDFUNC1(VECTOR2, REAL, Vector2, angle_to, VECTOR2, "to", varray());
@@ -1462,6 +1474,7 @@ void register_variant_methods() {
ADDFUNC0(VECTOR3, INT, Vector3, max_axis, varray());
ADDFUNC0(VECTOR3, REAL, Vector3, length, varray());
ADDFUNC0(VECTOR3, REAL, Vector3, length_squared, varray());
+ ADDFUNC0(VECTOR3, BOOL, Vector3, is_normalized, varray());
ADDFUNC0(VECTOR3, VECTOR3, Vector3, normalized, varray());
ADDFUNC0(VECTOR3, VECTOR3, Vector3, inverse, varray());
ADDFUNC1(VECTOR3, VECTOR3, Vector3, snapped, REAL, "by", varray());
@@ -1497,6 +1510,7 @@ void register_variant_methods() {
ADDFUNC0(QUAT, REAL, Quat, length, varray());
ADDFUNC0(QUAT, REAL, Quat, length_squared, varray());
ADDFUNC0(QUAT, QUAT, Quat, normalized, varray());
+ ADDFUNC0(QUAT, BOOL, Quat, is_normalized, varray());
ADDFUNC0(QUAT, QUAT, Quat, inverse, varray());
ADDFUNC1(QUAT, REAL, Quat, dot, QUAT, "b", varray());
ADDFUNC1(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray());
@@ -1692,6 +1706,9 @@ void register_variant_methods() {
ADDFUNC0(BASIS, REAL, Basis, determinant, varray());
ADDFUNC2(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray());
ADDFUNC1(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray());
+ ADDFUNC1(BASIS, NIL, Basis, set_scale, VECTOR3, "scale", varray());
+ ADDFUNC1(BASIS, NIL, Basis, set_rotation_euler, VECTOR3, "euler", varray());
+ ADDFUNC2(BASIS, NIL, Basis, set_rotation_axis_angle, VECTOR3, "axis", REAL, "angle", varray());
ADDFUNC0(BASIS, VECTOR3, Basis, get_scale, varray());
ADDFUNC0(BASIS, VECTOR3, Basis, get_euler, varray());
ADDFUNC1(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray());
@@ -1749,6 +1766,7 @@ void register_variant_methods() {
_VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Basis_init3, Variant::BASIS, "euler", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Transform_init1, Variant::TRANSFORM, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3, "origin", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Transform_init2, Variant::TRANSFORM, "basis", Variant::BASIS, "origin", Variant::VECTOR3);