mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-12 23:02:02 +02:00
Renamed Quat to Quaternion for consistency with the other engine math classes.
This commit is contained in:
parent
f423b30714
commit
730bce8587
@ -653,7 +653,7 @@ void register_global_constants() {
|
||||
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3I", Variant::VECTOR3I); //10
|
||||
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM2D", Variant::TRANSFORM2D);
|
||||
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_PLANE", Variant::PLANE);
|
||||
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT);
|
||||
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUATERNION", Variant::QUATERNION);
|
||||
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_AABB", Variant::AABB);
|
||||
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BASIS", Variant::BASIS); //15
|
||||
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM", Variant::TRANSFORM);
|
||||
|
@ -284,9 +284,9 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
|
||||
}
|
||||
|
||||
} break;
|
||||
case Variant::QUAT: {
|
||||
case Variant::QUATERNION: {
|
||||
ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
|
||||
Quat val;
|
||||
Quaternion val;
|
||||
val.x = decode_float(&buf[0]);
|
||||
val.y = decode_float(&buf[4]);
|
||||
val.z = decode_float(&buf[8]);
|
||||
@ -1113,9 +1113,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
|
||||
r_len += 4 * 4;
|
||||
|
||||
} break;
|
||||
case Variant::QUAT: {
|
||||
case Variant::QUATERNION: {
|
||||
if (buf) {
|
||||
Quat q = p_variant;
|
||||
Quaternion q = p_variant;
|
||||
encode_float(q.x, &buf[0]);
|
||||
encode_float(q.y, &buf[4]);
|
||||
encode_float(q.z, &buf[8]);
|
||||
|
@ -52,7 +52,7 @@ enum {
|
||||
VARIANT_RECT2 = 11,
|
||||
VARIANT_VECTOR3 = 12,
|
||||
VARIANT_PLANE = 13,
|
||||
VARIANT_QUAT = 14,
|
||||
VARIANT_QUATERNION = 14,
|
||||
VARIANT_AABB = 15,
|
||||
VARIANT_MATRIX3 = 16,
|
||||
VARIANT_TRANSFORM = 17,
|
||||
@ -206,8 +206,8 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
|
||||
v.d = f->get_real();
|
||||
r_v = v;
|
||||
} break;
|
||||
case VARIANT_QUAT: {
|
||||
Quat v;
|
||||
case VARIANT_QUATERNION: {
|
||||
Quaternion v;
|
||||
v.x = f->get_real();
|
||||
v.y = f->get_real();
|
||||
v.z = f->get_real();
|
||||
@ -1413,9 +1413,9 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
|
||||
f->store_real(val.d);
|
||||
|
||||
} break;
|
||||
case Variant::QUAT: {
|
||||
f->store_32(VARIANT_QUAT);
|
||||
Quat val = p_property;
|
||||
case Variant::QUATERNION: {
|
||||
f->store_32(VARIANT_QUATERNION);
|
||||
Quaternion val = p_property;
|
||||
f->store_real(val.x);
|
||||
f->store_real(val.y);
|
||||
f->store_real(val.z);
|
||||
|
@ -326,11 +326,11 @@ void Basis::rotate(const Vector3 &p_euler) {
|
||||
*this = rotated(p_euler);
|
||||
}
|
||||
|
||||
Basis Basis::rotated(const Quat &p_quat) const {
|
||||
Basis Basis::rotated(const Quaternion &p_quat) const {
|
||||
return Basis(p_quat) * (*this);
|
||||
}
|
||||
|
||||
void Basis::rotate(const Quat &p_quat) {
|
||||
void Basis::rotate(const Quaternion &p_quat) {
|
||||
*this = rotated(p_quat);
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ Vector3 Basis::get_rotation_euler() const {
|
||||
return m.get_euler();
|
||||
}
|
||||
|
||||
Quat Basis::get_rotation_quat() const {
|
||||
Quaternion Basis::get_rotation_quat() 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.
|
||||
@ -775,9 +775,9 @@ Basis::operator String() const {
|
||||
return mtx;
|
||||
}
|
||||
|
||||
Quat Basis::get_quat() const {
|
||||
Quaternion Basis::get_quat() const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_rotation(), Quat(), "Basis must be normalized in order to be casted to a Quaternion. Use get_rotation_quat() or call orthonormalized() if the Basis contains linearly independent vectors.");
|
||||
ERR_FAIL_COND_V_MSG(!is_rotation(), Quaternion(), "Basis must be normalized in order to be casted to a Quaternionernion. Use get_rotation_quat() or call orthonormalized() if the Basis contains linearly independent vectors.");
|
||||
#endif
|
||||
/* Allow getting a quaternion from an unnormalized transform */
|
||||
Basis m = *this;
|
||||
@ -808,7 +808,7 @@ Quat Basis::get_quat() const {
|
||||
temp[k] = (m.elements[k][i] + m.elements[i][k]) * s;
|
||||
}
|
||||
|
||||
return Quat(temp[0], temp[1], temp[2], temp[3]);
|
||||
return Quaternion(temp[0], temp[1], temp[2], temp[3]);
|
||||
}
|
||||
|
||||
static const Basis _ortho_bases[24] = {
|
||||
@ -949,7 +949,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
||||
r_angle = angle;
|
||||
}
|
||||
|
||||
void Basis::set_quat(const Quat &p_quat) {
|
||||
void Basis::set_quat(const Quaternion &p_quat) {
|
||||
real_t d = p_quat.length_squared();
|
||||
real_t s = 2 / d;
|
||||
real_t xs = p_quat.x * s, ys = p_quat.y * s, zs = p_quat.z * s;
|
||||
@ -1001,7 +1001,7 @@ void Basis::set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale) {
|
||||
rotate(p_euler);
|
||||
}
|
||||
|
||||
void Basis::set_quat_scale(const Quat &p_quat, const Vector3 &p_scale) {
|
||||
void Basis::set_quat_scale(const Quaternion &p_quat, const Vector3 &p_scale) {
|
||||
set_diagonal(p_scale);
|
||||
rotate(p_quat);
|
||||
}
|
||||
@ -1022,8 +1022,8 @@ void Basis::set_diagonal(const Vector3 &p_diag) {
|
||||
|
||||
Basis Basis::slerp(const Basis &p_to, const real_t &p_weight) const {
|
||||
//consider scale
|
||||
Quat from(*this);
|
||||
Quat to(p_to);
|
||||
Quaternion from(*this);
|
||||
Quaternion to(p_to);
|
||||
|
||||
Basis b(from.slerp(to, p_weight));
|
||||
b.elements[0] *= Math::lerp(elements[0].length(), p_to.elements[0].length(), p_weight);
|
||||
|
@ -30,7 +30,7 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "core/math/quat.h"
|
||||
#include "core/math/quaternion.h"
|
||||
#include "core/math/vector3.h"
|
||||
#include "core/math/vector3i.h"
|
||||
|
||||
@ -79,13 +79,13 @@ public:
|
||||
void rotate(const Vector3 &p_euler);
|
||||
Basis rotated(const Vector3 &p_euler) const;
|
||||
|
||||
void rotate(const Quat &p_quat);
|
||||
Basis rotated(const Quat &p_quat) const;
|
||||
void rotate(const Quaternion &p_quat);
|
||||
Basis rotated(const Quaternion &p_quat) const;
|
||||
|
||||
Vector3 get_rotation_euler() const;
|
||||
void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const;
|
||||
void get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) const;
|
||||
Quat get_rotation_quat() const;
|
||||
Quaternion get_rotation_quat() const;
|
||||
Vector3 get_rotation() const { return get_rotation_euler(); };
|
||||
|
||||
void rotate_to_align(Vector3 p_start_direction, Vector3 p_end_direction);
|
||||
@ -110,8 +110,8 @@ public:
|
||||
Vector3 get_euler_zyx() const;
|
||||
void set_euler_zyx(const Vector3 &p_euler);
|
||||
|
||||
Quat get_quat() const;
|
||||
void set_quat(const Quat &p_quat);
|
||||
Quaternion get_quat() const;
|
||||
void set_quat(const Quaternion &p_quat);
|
||||
|
||||
Vector3 get_euler() const { return get_euler_yxz(); }
|
||||
void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); }
|
||||
@ -131,7 +131,7 @@ public:
|
||||
|
||||
void set_axis_angle_scale(const Vector3 &p_axis, real_t p_phi, const Vector3 &p_scale);
|
||||
void set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale);
|
||||
void set_quat_scale(const Quat &p_quat, const Vector3 &p_scale);
|
||||
void set_quat_scale(const Quaternion &p_quat, const Vector3 &p_scale);
|
||||
|
||||
// transposed dot products
|
||||
_FORCE_INLINE_ real_t tdotx(const Vector3 &v) const {
|
||||
@ -265,10 +265,10 @@ public:
|
||||
// only be used in cases of single normals, or when the basis changes each time.
|
||||
Vector3 xform_normal(const Vector3 &p_vector) const { return get_normal_xform_basis().xform_normal_fast(p_vector); }
|
||||
|
||||
operator Quat() const { return get_quat(); }
|
||||
operator Quaternion() const { return get_quat(); }
|
||||
|
||||
Basis(const Quat &p_quat) { set_quat(p_quat); }
|
||||
Basis(const Quat &p_quat, const Vector3 &p_scale) { set_quat_scale(p_quat, p_scale); }
|
||||
Basis(const Quaternion &p_quat) { set_quat(p_quat); }
|
||||
Basis(const Quaternion &p_quat, const Vector3 &p_scale) { set_quat_scale(p_quat, p_scale); }
|
||||
|
||||
Basis(const Vector3 &p_euler) { set_euler(p_euler); }
|
||||
Basis(const Vector3 &p_euler, const Vector3 &p_scale) { set_euler_scale(p_euler, p_scale); }
|
||||
|
@ -93,9 +93,9 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const
|
||||
return target;
|
||||
}
|
||||
|
||||
case Variant::QUAT: {
|
||||
case Variant::QUATERNION: {
|
||||
|
||||
SETUP_TYPE(Quat)
|
||||
SETUP_TYPE(Quaternion)
|
||||
|
||||
/**/ TRY_TRANSFER_FIELD("x", x)
|
||||
else TRY_TRANSFER_FIELD("y", y)
|
||||
|
@ -28,12 +28,12 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "quat.h"
|
||||
#include "quaternion.h"
|
||||
|
||||
#include "core/math/basis.h"
|
||||
#include "core/print_string.h"
|
||||
|
||||
real_t Quat::angle_to(const Quat &p_to) const {
|
||||
real_t Quaternion::angle_to(const Quaternion &p_to) const {
|
||||
real_t d = dot(p_to);
|
||||
return Math::acos(CLAMP(d * d * 2 - 1, -1, 1));
|
||||
}
|
||||
@ -42,7 +42,7 @@ real_t Quat::angle_to(const Quat &p_to) const {
|
||||
// (ax,ay,az), where ax is the angle of rotation around x axis,
|
||||
// and similar for other axes.
|
||||
// This implementation uses XYZ convention (Z is the first rotation).
|
||||
void Quat::set_euler_xyz(const Vector3 &p_euler) {
|
||||
void Quaternion::set_euler_xyz(const Vector3 &p_euler) {
|
||||
real_t half_a1 = p_euler.x * 0.5f;
|
||||
real_t half_a2 = p_euler.y * 0.5f;
|
||||
real_t half_a3 = p_euler.z * 0.5f;
|
||||
@ -68,7 +68,7 @@ void Quat::set_euler_xyz(const Vector3 &p_euler) {
|
||||
// (ax,ay,az), where ax is the angle of rotation around x axis,
|
||||
// and similar for other axes.
|
||||
// This implementation uses XYZ convention (Z is the first rotation).
|
||||
Vector3 Quat::get_euler_xyz() const {
|
||||
Vector3 Quaternion::get_euler_xyz() const {
|
||||
Basis m(*this);
|
||||
return m.get_euler_xyz();
|
||||
}
|
||||
@ -77,7 +77,7 @@ Vector3 Quat::get_euler_xyz() const {
|
||||
// (ax,ay,az), where ax is the angle of rotation around x axis,
|
||||
// and similar for other axes.
|
||||
// This implementation uses YXZ convention (Z is the first rotation).
|
||||
void Quat::set_euler_yxz(const Vector3 &p_euler) {
|
||||
void Quaternion::set_euler_yxz(const Vector3 &p_euler) {
|
||||
real_t half_a1 = p_euler.y * 0.5f;
|
||||
real_t half_a2 = p_euler.x * 0.5f;
|
||||
real_t half_a3 = p_euler.z * 0.5f;
|
||||
@ -103,7 +103,7 @@ void Quat::set_euler_yxz(const Vector3 &p_euler) {
|
||||
// (ax,ay,az), where ax is the angle of rotation around x axis,
|
||||
// and similar for other axes.
|
||||
// This implementation uses YXZ convention (Z is the first rotation).
|
||||
Vector3 Quat::get_euler_yxz() const {
|
||||
Vector3 Quaternion::get_euler_yxz() const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Vector3(0, 0, 0), "The quaternion must be normalized.");
|
||||
#endif
|
||||
@ -111,68 +111,68 @@ Vector3 Quat::get_euler_yxz() const {
|
||||
return m.get_euler_yxz();
|
||||
}
|
||||
|
||||
void Quat::operator*=(const Quat &p_q) {
|
||||
void Quaternion::operator*=(const Quaternion &p_q) {
|
||||
set(w * p_q.x + x * p_q.w + y * p_q.z - z * p_q.y,
|
||||
w * p_q.y + y * p_q.w + z * p_q.x - x * p_q.z,
|
||||
w * p_q.z + z * p_q.w + x * p_q.y - y * p_q.x,
|
||||
w * p_q.w - x * p_q.x - y * p_q.y - z * p_q.z);
|
||||
}
|
||||
|
||||
Quat Quat::operator*(const Quat &p_q) const {
|
||||
Quat r = *this;
|
||||
Quaternion Quaternion::operator*(const Quaternion &p_q) const {
|
||||
Quaternion r = *this;
|
||||
r *= p_q;
|
||||
return r;
|
||||
}
|
||||
|
||||
bool Quat::is_equal_approx(const Quat &p_quat) const {
|
||||
bool Quaternion::is_equal_approx(const Quaternion &p_quat) const {
|
||||
return Math::is_equal_approx(x, p_quat.x) && Math::is_equal_approx(y, p_quat.y) && Math::is_equal_approx(z, p_quat.z) && Math::is_equal_approx(w, p_quat.w);
|
||||
}
|
||||
|
||||
real_t Quat::length() const {
|
||||
real_t Quaternion::length() const {
|
||||
return Math::sqrt(length_squared());
|
||||
}
|
||||
|
||||
void Quat::normalize() {
|
||||
void Quaternion::normalize() {
|
||||
*this /= length();
|
||||
}
|
||||
|
||||
Quat Quat::normalized() const {
|
||||
Quaternion Quaternion::normalized() const {
|
||||
return *this / length();
|
||||
}
|
||||
|
||||
bool Quat::is_normalized() const {
|
||||
bool Quaternion::is_normalized() const {
|
||||
return Math::is_equal_approx(length_squared(), 1, (real_t)UNIT_EPSILON); //use less epsilon
|
||||
}
|
||||
|
||||
Quat Quat::inverse() const {
|
||||
Quaternion Quaternion::inverse() const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quaternion(), "The quaternion must be normalized.");
|
||||
#endif
|
||||
return Quat(-x, -y, -z, w);
|
||||
return Quaternion(-x, -y, -z, w);
|
||||
}
|
||||
|
||||
Quat Quat::log() const {
|
||||
Quat src = *this;
|
||||
Quaternion Quaternion::log() const {
|
||||
Quaternion src = *this;
|
||||
Vector3 src_v = src.get_axis() * src.get_angle();
|
||||
return Quat(src_v.x, src_v.y, src_v.z, 0);
|
||||
return Quaternion(src_v.x, src_v.y, src_v.z, 0);
|
||||
}
|
||||
|
||||
Quat Quat::exp() const {
|
||||
Quat src = *this;
|
||||
Quaternion Quaternion::exp() const {
|
||||
Quaternion src = *this;
|
||||
Vector3 src_v = Vector3(src.x, src.y, src.z);
|
||||
float theta = src_v.length();
|
||||
if (theta < CMP_EPSILON) {
|
||||
return Quat(0, 0, 0, 1);
|
||||
return Quaternion(0, 0, 0, 1);
|
||||
}
|
||||
return Quat(src_v.normalized(), theta);
|
||||
return Quaternion(src_v.normalized(), theta);
|
||||
}
|
||||
|
||||
Quat Quat::slerp(const Quat &p_to, const real_t &p_weight) const {
|
||||
Quaternion Quaternion::slerp(const Quaternion &p_to, const real_t &p_weight) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quaternion(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quaternion(), "The end quaternion must be normalized.");
|
||||
#endif
|
||||
Quat to1;
|
||||
Quaternion to1;
|
||||
real_t omega, cosom, sinom, scale0, scale1;
|
||||
|
||||
// calc cosine
|
||||
@ -207,19 +207,19 @@ Quat Quat::slerp(const Quat &p_to, const real_t &p_weight) const {
|
||||
scale1 = p_weight;
|
||||
}
|
||||
// calculate final values
|
||||
return Quat(
|
||||
return Quaternion(
|
||||
scale0 * x + scale1 * to1.x,
|
||||
scale0 * y + scale1 * to1.y,
|
||||
scale0 * z + scale1 * to1.z,
|
||||
scale0 * w + scale1 * to1.w);
|
||||
}
|
||||
|
||||
Quat Quat::slerpni(const Quat &p_to, const real_t &p_weight) const {
|
||||
Quaternion Quaternion::slerpni(const Quaternion &p_to, const real_t &p_weight) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quaternion(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quaternion(), "The end quaternion must be normalized.");
|
||||
#endif
|
||||
const Quat &from = *this;
|
||||
const Quaternion &from = *this;
|
||||
|
||||
real_t dot = from.dot(p_to);
|
||||
|
||||
@ -232,25 +232,25 @@ Quat Quat::slerpni(const Quat &p_to, const real_t &p_weight) const {
|
||||
newFactor = Math::sin(p_weight * theta) * sinT,
|
||||
invFactor = Math::sin((1 - p_weight) * theta) * sinT;
|
||||
|
||||
return Quat(invFactor * from.x + newFactor * p_to.x,
|
||||
return Quaternion(invFactor * from.x + newFactor * p_to.x,
|
||||
invFactor * from.y + newFactor * p_to.y,
|
||||
invFactor * from.z + newFactor * p_to.z,
|
||||
invFactor * from.w + newFactor * p_to.w);
|
||||
}
|
||||
|
||||
Quat Quat::cubic_slerp(const Quat &p_b, const Quat &p_pre_a, const Quat &p_post_b, const real_t &p_weight) const {
|
||||
Quaternion Quaternion::cubic_slerp(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t &p_weight) const {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_b.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quaternion(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p_b.is_normalized(), Quaternion(), "The end quaternion must be normalized.");
|
||||
#endif
|
||||
//the only way to do slerp :|
|
||||
real_t t2 = (1 - p_weight) * p_weight * 2;
|
||||
Quat sp = this->slerp(p_b, p_weight);
|
||||
Quat sq = p_pre_a.slerpni(p_post_b, p_weight);
|
||||
Quaternion sp = this->slerp(p_b, p_weight);
|
||||
Quaternion sq = p_pre_a.slerpni(p_post_b, p_weight);
|
||||
return sp.slerpni(sq, t2);
|
||||
}
|
||||
|
||||
Vector3 Quat::get_axis() const {
|
||||
Vector3 Quaternion::get_axis() const {
|
||||
if (Math::abs(w) > 1 - CMP_EPSILON) {
|
||||
return Vector3(x, y, z);
|
||||
}
|
||||
@ -258,15 +258,15 @@ Vector3 Quat::get_axis() const {
|
||||
return Vector3(x * r, y * r, z * r);
|
||||
}
|
||||
|
||||
float Quat::get_angle() const {
|
||||
float Quaternion::get_angle() const {
|
||||
return 2 * Math::acos(w);
|
||||
}
|
||||
|
||||
Quat::operator String() const {
|
||||
Quaternion::operator String() const {
|
||||
return String::num(x) + ", " + String::num(y) + ", " + String::num(z) + ", " + String::num(w);
|
||||
}
|
||||
|
||||
void Quat::set_axis_angle(const Vector3 &axis, const real_t &angle) {
|
||||
void Quaternion::set_axis_angle(const Vector3 &axis, const real_t &angle) {
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_MSG(!axis.is_normalized(), "The axis Vector3 must be normalized.");
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
#ifndef QUAT_H
|
||||
#define QUAT_H
|
||||
#ifndef QUATERNION_H
|
||||
#define QUATERNION_H
|
||||
/*************************************************************************/
|
||||
/* quat.h */
|
||||
/*************************************************************************/
|
||||
@ -35,21 +35,21 @@
|
||||
#include "core/math/vector3.h"
|
||||
#include "core/ustring.h"
|
||||
|
||||
class _NO_DISCARD_CLASS_ Quat {
|
||||
class _NO_DISCARD_CLASS_ Quaternion {
|
||||
public:
|
||||
real_t x, y, z, w;
|
||||
|
||||
_FORCE_INLINE_ real_t length_squared() const;
|
||||
bool is_equal_approx(const Quat &p_quat) const;
|
||||
bool is_equal_approx(const Quaternion &p_quat) const;
|
||||
real_t length() const;
|
||||
void normalize();
|
||||
Quat normalized() const;
|
||||
Quaternion normalized() const;
|
||||
bool is_normalized() const;
|
||||
Quat inverse() const;
|
||||
Quat log() const;
|
||||
Quat exp() const;
|
||||
_FORCE_INLINE_ real_t dot(const Quat &p_q) const;
|
||||
real_t angle_to(const Quat &p_to) const;
|
||||
Quaternion inverse() const;
|
||||
Quaternion log() const;
|
||||
Quaternion exp() const;
|
||||
_FORCE_INLINE_ real_t dot(const Quaternion &p_q) const;
|
||||
real_t angle_to(const Quaternion &p_to) const;
|
||||
|
||||
void set_euler_xyz(const Vector3 &p_euler);
|
||||
Vector3 get_euler_xyz() const;
|
||||
@ -59,9 +59,9 @@ public:
|
||||
void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); };
|
||||
Vector3 get_euler() const { return get_euler_yxz(); };
|
||||
|
||||
Quat slerp(const Quat &p_to, const real_t &p_weight) const;
|
||||
Quat slerpni(const Quat &p_to, const real_t &p_weight) const;
|
||||
Quat cubic_slerp(const Quat &p_b, const Quat &p_pre_a, const Quat &p_post_b, const real_t &p_weight) const;
|
||||
Quaternion slerp(const Quaternion &p_to, const real_t &p_weight) const;
|
||||
Quaternion slerpni(const Quaternion &p_to, const real_t &p_weight) const;
|
||||
Quaternion cubic_slerp(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t &p_weight) const;
|
||||
|
||||
Vector3 get_axis() const;
|
||||
float get_angle() const;
|
||||
@ -75,11 +75,11 @@ public:
|
||||
r_axis.z = z * r;
|
||||
}
|
||||
|
||||
void operator*=(const Quat &p_q);
|
||||
Quat operator*(const Quat &p_q) const;
|
||||
void operator*=(const Quaternion &p_q);
|
||||
Quaternion operator*(const Quaternion &p_q) const;
|
||||
|
||||
Quat operator*(const Vector3 &v) const {
|
||||
return Quat(w * v.x + y * v.z - z * v.y,
|
||||
Quaternion operator*(const Vector3 &v) const {
|
||||
return Quaternion(w * v.x + y * v.z - z * v.y,
|
||||
w * v.y + z * v.x - x * v.z,
|
||||
w * v.z + x * v.y - y * v.x,
|
||||
-x * v.x - y * v.y - z * v.z);
|
||||
@ -94,18 +94,18 @@ public:
|
||||
return v + ((uv * w) + u.cross(uv)) * ((real_t)2);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void operator+=(const Quat &p_q);
|
||||
_FORCE_INLINE_ void operator-=(const Quat &p_q);
|
||||
_FORCE_INLINE_ void operator+=(const Quaternion &p_q);
|
||||
_FORCE_INLINE_ void operator-=(const Quaternion &p_q);
|
||||
_FORCE_INLINE_ void operator*=(const real_t &s);
|
||||
_FORCE_INLINE_ void operator/=(const real_t &s);
|
||||
_FORCE_INLINE_ Quat operator+(const Quat &q2) const;
|
||||
_FORCE_INLINE_ Quat operator-(const Quat &q2) const;
|
||||
_FORCE_INLINE_ Quat operator-() const;
|
||||
_FORCE_INLINE_ Quat operator*(const real_t &s) const;
|
||||
_FORCE_INLINE_ Quat operator/(const real_t &s) const;
|
||||
_FORCE_INLINE_ Quaternion operator+(const Quaternion &q2) const;
|
||||
_FORCE_INLINE_ Quaternion operator-(const Quaternion &q2) const;
|
||||
_FORCE_INLINE_ Quaternion operator-() const;
|
||||
_FORCE_INLINE_ Quaternion operator*(const real_t &s) const;
|
||||
_FORCE_INLINE_ Quaternion operator/(const real_t &s) const;
|
||||
|
||||
_FORCE_INLINE_ bool operator==(const Quat &p_quat) const;
|
||||
_FORCE_INLINE_ bool operator!=(const Quat &p_quat) const;
|
||||
_FORCE_INLINE_ bool operator==(const Quaternion &p_quat) const;
|
||||
_FORCE_INLINE_ bool operator!=(const Quaternion &p_quat) const;
|
||||
|
||||
operator String() const;
|
||||
|
||||
@ -115,27 +115,27 @@ public:
|
||||
z = p_z;
|
||||
w = p_w;
|
||||
}
|
||||
inline Quat(real_t p_x, real_t p_y, real_t p_z, real_t p_w) :
|
||||
inline Quaternion(real_t p_x, real_t p_y, real_t p_z, real_t p_w) :
|
||||
x(p_x),
|
||||
y(p_y),
|
||||
z(p_z),
|
||||
w(p_w) {
|
||||
}
|
||||
Quat(const Vector3 &axis, const real_t &angle) {
|
||||
Quaternion(const Vector3 &axis, const real_t &angle) {
|
||||
set_axis_angle(axis, angle);
|
||||
}
|
||||
|
||||
Quat(const Vector3 &euler) {
|
||||
Quaternion(const Vector3 &euler) {
|
||||
set_euler(euler);
|
||||
}
|
||||
Quat(const Quat &p_q) :
|
||||
Quaternion(const Quaternion &p_q) :
|
||||
x(p_q.x),
|
||||
y(p_q.y),
|
||||
z(p_q.z),
|
||||
w(p_q.w) {
|
||||
}
|
||||
|
||||
Quat &operator=(const Quat &p_q) {
|
||||
Quaternion &operator=(const Quaternion &p_q) {
|
||||
x = p_q.x;
|
||||
y = p_q.y;
|
||||
z = p_q.z;
|
||||
@ -143,7 +143,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Quat(const Vector3 &v0, const Vector3 &v1) // shortest arc
|
||||
Quaternion(const Vector3 &v0, const Vector3 &v1) // shortest arc
|
||||
{
|
||||
Vector3 c = v0.cross(v1);
|
||||
real_t d = v0.dot(v1);
|
||||
@ -164,7 +164,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
inline Quat() :
|
||||
inline Quaternion() :
|
||||
x(0),
|
||||
y(0),
|
||||
z(0),
|
||||
@ -172,67 +172,67 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
real_t Quat::dot(const Quat &p_q) const {
|
||||
real_t Quaternion::dot(const Quaternion &p_q) const {
|
||||
return x * p_q.x + y * p_q.y + z * p_q.z + w * p_q.w;
|
||||
}
|
||||
|
||||
real_t Quat::length_squared() const {
|
||||
real_t Quaternion::length_squared() const {
|
||||
return dot(*this);
|
||||
}
|
||||
|
||||
void Quat::operator+=(const Quat &p_q) {
|
||||
void Quaternion::operator+=(const Quaternion &p_q) {
|
||||
x += p_q.x;
|
||||
y += p_q.y;
|
||||
z += p_q.z;
|
||||
w += p_q.w;
|
||||
}
|
||||
|
||||
void Quat::operator-=(const Quat &p_q) {
|
||||
void Quaternion::operator-=(const Quaternion &p_q) {
|
||||
x -= p_q.x;
|
||||
y -= p_q.y;
|
||||
z -= p_q.z;
|
||||
w -= p_q.w;
|
||||
}
|
||||
|
||||
void Quat::operator*=(const real_t &s) {
|
||||
void Quaternion::operator*=(const real_t &s) {
|
||||
x *= s;
|
||||
y *= s;
|
||||
z *= s;
|
||||
w *= s;
|
||||
}
|
||||
|
||||
void Quat::operator/=(const real_t &s) {
|
||||
void Quaternion::operator/=(const real_t &s) {
|
||||
*this *= 1 / s;
|
||||
}
|
||||
|
||||
Quat Quat::operator+(const Quat &q2) const {
|
||||
const Quat &q1 = *this;
|
||||
return Quat(q1.x + q2.x, q1.y + q2.y, q1.z + q2.z, q1.w + q2.w);
|
||||
Quaternion Quaternion::operator+(const Quaternion &q2) const {
|
||||
const Quaternion &q1 = *this;
|
||||
return Quaternion(q1.x + q2.x, q1.y + q2.y, q1.z + q2.z, q1.w + q2.w);
|
||||
}
|
||||
|
||||
Quat Quat::operator-(const Quat &q2) const {
|
||||
const Quat &q1 = *this;
|
||||
return Quat(q1.x - q2.x, q1.y - q2.y, q1.z - q2.z, q1.w - q2.w);
|
||||
Quaternion Quaternion::operator-(const Quaternion &q2) const {
|
||||
const Quaternion &q1 = *this;
|
||||
return Quaternion(q1.x - q2.x, q1.y - q2.y, q1.z - q2.z, q1.w - q2.w);
|
||||
}
|
||||
|
||||
Quat Quat::operator-() const {
|
||||
const Quat &q2 = *this;
|
||||
return Quat(-q2.x, -q2.y, -q2.z, -q2.w);
|
||||
Quaternion Quaternion::operator-() const {
|
||||
const Quaternion &q2 = *this;
|
||||
return Quaternion(-q2.x, -q2.y, -q2.z, -q2.w);
|
||||
}
|
||||
|
||||
Quat Quat::operator*(const real_t &s) const {
|
||||
return Quat(x * s, y * s, z * s, w * s);
|
||||
Quaternion Quaternion::operator*(const real_t &s) const {
|
||||
return Quaternion(x * s, y * s, z * s, w * s);
|
||||
}
|
||||
|
||||
Quat Quat::operator/(const real_t &s) const {
|
||||
Quaternion Quaternion::operator/(const real_t &s) const {
|
||||
return *this * (1 / s);
|
||||
}
|
||||
|
||||
bool Quat::operator==(const Quat &p_quat) const {
|
||||
bool Quaternion::operator==(const Quaternion &p_quat) const {
|
||||
return x == p_quat.x && y == p_quat.y && z == p_quat.z && w == p_quat.w;
|
||||
}
|
||||
|
||||
bool Quat::operator!=(const Quat &p_quat) const {
|
||||
bool Quaternion::operator!=(const Quaternion &p_quat) const {
|
||||
return x != p_quat.x || y != p_quat.y || z != p_quat.z || w != p_quat.w;
|
||||
}
|
||||
|
@ -112,11 +112,11 @@ Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c)
|
||||
/* not sure if very "efficient" but good enough? */
|
||||
|
||||
Vector3 src_scale = basis.get_scale();
|
||||
Quat src_rot = basis.get_rotation_quat();
|
||||
Quaternion src_rot = basis.get_rotation_quat();
|
||||
Vector3 src_loc = origin;
|
||||
|
||||
Vector3 dst_scale = p_transform.basis.get_scale();
|
||||
Quat dst_rot = p_transform.basis.get_rotation_quat();
|
||||
Quaternion dst_rot = p_transform.basis.get_rotation_quat();
|
||||
Vector3 dst_loc = p_transform.origin;
|
||||
|
||||
Transform interp;
|
||||
|
@ -59,7 +59,7 @@ void TransformInterpolator::interpolate_basis_via_method(const Basis &p_prev, co
|
||||
}
|
||||
}
|
||||
|
||||
Quat TransformInterpolator::_basis_to_quat_unchecked(const Basis &p_basis) {
|
||||
Quaternion TransformInterpolator::_basis_to_quat_unchecked(const Basis &p_basis) {
|
||||
Basis m = p_basis;
|
||||
real_t trace = m.elements[0][0] + m.elements[1][1] + m.elements[2][2];
|
||||
real_t temp[4];
|
||||
@ -88,11 +88,11 @@ Quat TransformInterpolator::_basis_to_quat_unchecked(const Basis &p_basis) {
|
||||
temp[k] = (m.elements[k][i] + m.elements[i][k]) * s;
|
||||
}
|
||||
|
||||
return Quat(temp[0], temp[1], temp[2], temp[3]);
|
||||
return Quaternion(temp[0], temp[1], temp[2], temp[3]);
|
||||
}
|
||||
|
||||
Quat TransformInterpolator::_quat_slerp_unchecked(const Quat &p_from, const Quat &p_to, real_t p_fraction) {
|
||||
Quat to1;
|
||||
Quaternion TransformInterpolator::_quat_slerp_unchecked(const Quaternion &p_from, const Quaternion &p_to, real_t p_fraction) {
|
||||
Quaternion to1;
|
||||
real_t omega, cosom, sinom, scale0, scale1;
|
||||
|
||||
// calc cosine
|
||||
@ -130,7 +130,7 @@ Quat TransformInterpolator::_quat_slerp_unchecked(const Quat &p_from, const Quat
|
||||
scale1 = p_fraction;
|
||||
}
|
||||
// calculate final values
|
||||
return Quat(
|
||||
return Quaternion(
|
||||
scale0 * p_from.x + scale1 * to1.x,
|
||||
scale0 * p_from.y + scale1 * to1.y,
|
||||
scale0 * p_from.z + scale1 * to1.z,
|
||||
@ -138,8 +138,8 @@ Quat TransformInterpolator::_quat_slerp_unchecked(const Quat &p_from, const Quat
|
||||
}
|
||||
|
||||
Basis TransformInterpolator::_basis_slerp_unchecked(Basis p_from, Basis p_to, real_t p_fraction) {
|
||||
Quat from = _basis_to_quat_unchecked(p_from);
|
||||
Quat to = _basis_to_quat_unchecked(p_to);
|
||||
Quaternion from = _basis_to_quat_unchecked(p_from);
|
||||
Quaternion to = _basis_to_quat_unchecked(p_to);
|
||||
|
||||
Basis b(_quat_slerp_unchecked(from, to, p_fraction));
|
||||
return b;
|
||||
@ -231,7 +231,7 @@ Vector3 TransformInterpolator::_basis_orthonormalize(Basis &r_basis) {
|
||||
return lengths;
|
||||
}
|
||||
|
||||
TransformInterpolator::Method TransformInterpolator::_test_basis(Basis p_basis, bool r_needed_normalize, Quat &r_quat) {
|
||||
TransformInterpolator::Method TransformInterpolator::_test_basis(Basis p_basis, bool r_needed_normalize, Quaternion &r_quat) {
|
||||
// axis lengths
|
||||
Vector3 al = Vector3(p_basis.get_axis(0).length_squared(),
|
||||
p_basis.get_axis(1).length_squared(),
|
||||
@ -344,13 +344,13 @@ bool TransformInterpolator::_basis_is_orthogonal(const Basis &p_basis, real_t p_
|
||||
TransformInterpolator::Method TransformInterpolator::find_method(const Basis &p_a, const Basis &p_b) {
|
||||
bool needed_normalize = false;
|
||||
|
||||
Quat q0;
|
||||
Quaternion q0;
|
||||
Method method = _test_basis(p_a, needed_normalize, q0);
|
||||
if (method == INTERP_LERP) {
|
||||
return method;
|
||||
}
|
||||
|
||||
Quat q1;
|
||||
Quaternion q1;
|
||||
method = _test_basis(p_b, needed_normalize, q1);
|
||||
if (method == INTERP_LERP) {
|
||||
return method;
|
||||
|
@ -31,7 +31,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "core/math/math_defs.h"
|
||||
#include "core/math/quat.h"
|
||||
#include "core/math/quaternion.h"
|
||||
#include "core/math/transform.h"
|
||||
#include "core/math/vector3.h"
|
||||
|
||||
@ -59,10 +59,10 @@ private:
|
||||
static real_t _vec3_normalize(Vector3 &p_vec);
|
||||
static Vector3 _basis_orthonormalize(Basis &r_basis);
|
||||
static real_t vec3_sum(const Vector3 &p_pt) { return p_pt.x + p_pt.y + p_pt.z; }
|
||||
static Method _test_basis(Basis p_basis, bool r_needed_normalize, Quat &r_quat);
|
||||
static Method _test_basis(Basis p_basis, bool r_needed_normalize, Quaternion &r_quat);
|
||||
static Basis _basis_slerp_unchecked(Basis p_from, Basis p_to, real_t p_fraction);
|
||||
static Quat _quat_slerp_unchecked(const Quat &p_from, const Quat &p_to, real_t p_fraction);
|
||||
static Quat _basis_to_quat_unchecked(const Basis &p_basis);
|
||||
static Quaternion _quat_slerp_unchecked(const Quaternion &p_from, const Quaternion &p_to, real_t p_fraction);
|
||||
static Quaternion _basis_to_quat_unchecked(const Basis &p_basis);
|
||||
static bool _basis_is_orthogonal(const Basis &p_basis, real_t p_epsilon = 0.01f);
|
||||
static bool _basis_is_orthogonal_any_scale(const Basis &p_basis);
|
||||
|
||||
|
@ -122,7 +122,7 @@ MAKE_PTRARG_BY_REFERENCE(Vector3);
|
||||
MAKE_PTRARG_BY_REFERENCE(Vector3i);
|
||||
MAKE_PTRARG(Transform2D);
|
||||
MAKE_PTRARG_BY_REFERENCE(Plane);
|
||||
MAKE_PTRARG(Quat);
|
||||
MAKE_PTRARG(Quaternion);
|
||||
MAKE_PTRARG_BY_REFERENCE(AABB);
|
||||
MAKE_PTRARG_BY_REFERENCE(Basis);
|
||||
MAKE_PTRARG_BY_REFERENCE(Transform);
|
||||
|
@ -228,7 +228,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
|
||||
case Variant::VECTOR3:
|
||||
case Variant::TRANSFORM2D:
|
||||
case Variant::PLANE:
|
||||
case Variant::QUAT:
|
||||
case Variant::QUATERNION:
|
||||
case Variant::AABB:
|
||||
case Variant::BASIS:
|
||||
case Variant::TRANSFORM:
|
||||
|
@ -144,7 +144,7 @@ MAKE_TYPE_INFO(Vector3, Variant::VECTOR3)
|
||||
MAKE_TYPE_INFO(Vector3i, Variant::VECTOR3I)
|
||||
MAKE_TYPE_INFO(Transform2D, Variant::TRANSFORM2D)
|
||||
MAKE_TYPE_INFO(Plane, Variant::PLANE)
|
||||
MAKE_TYPE_INFO(Quat, Variant::QUAT)
|
||||
MAKE_TYPE_INFO(Quaternion, Variant::QUATERNION)
|
||||
MAKE_TYPE_INFO(AABB, Variant::AABB)
|
||||
MAKE_TYPE_INFO(Basis, Variant::BASIS)
|
||||
MAKE_TYPE_INFO(Transform, Variant::TRANSFORM)
|
||||
|
@ -89,15 +89,15 @@ String Variant::get_type_name(Variant::Type p_type) {
|
||||
|
||||
} break;
|
||||
/*
|
||||
case QUAT: {
|
||||
case QUATERNION: {
|
||||
|
||||
|
||||
} break;*/
|
||||
case AABB: {
|
||||
return "AABB";
|
||||
} break;
|
||||
case QUAT: {
|
||||
return "Quat";
|
||||
case QUATERNION: {
|
||||
return "Quaternion";
|
||||
|
||||
} break;
|
||||
case BASIS: {
|
||||
@ -297,7 +297,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
|
||||
|
||||
valid_types = valid;
|
||||
} break;
|
||||
case QUAT: {
|
||||
case QUATERNION: {
|
||||
static const Type valid[] = {
|
||||
BASIS,
|
||||
NIL
|
||||
@ -308,7 +308,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
|
||||
} break;
|
||||
case BASIS: {
|
||||
static const Type valid[] = {
|
||||
QUAT,
|
||||
QUATERNION,
|
||||
VECTOR3,
|
||||
NIL
|
||||
};
|
||||
@ -319,7 +319,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
|
||||
case TRANSFORM: {
|
||||
static const Type valid[] = {
|
||||
TRANSFORM2D,
|
||||
QUAT,
|
||||
QUATERNION,
|
||||
BASIS,
|
||||
NIL
|
||||
};
|
||||
@ -604,7 +604,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
|
||||
|
||||
valid_types = valid;
|
||||
} break;
|
||||
case QUAT: {
|
||||
case QUATERNION: {
|
||||
static const Type valid[] = {
|
||||
BASIS,
|
||||
NIL
|
||||
@ -615,7 +615,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
|
||||
} break;
|
||||
case BASIS: {
|
||||
static const Type valid[] = {
|
||||
QUAT,
|
||||
QUATERNION,
|
||||
VECTOR3,
|
||||
NIL
|
||||
};
|
||||
@ -626,7 +626,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
|
||||
case TRANSFORM: {
|
||||
static const Type valid[] = {
|
||||
TRANSFORM2D,
|
||||
QUAT,
|
||||
QUATERNION,
|
||||
BASIS,
|
||||
NIL
|
||||
};
|
||||
@ -900,15 +900,15 @@ bool Variant::is_zero() const {
|
||||
|
||||
} break;
|
||||
/*
|
||||
case QUAT: {
|
||||
case QUATERNION: {
|
||||
|
||||
|
||||
} break;*/
|
||||
case AABB: {
|
||||
return *_data._aabb == ::AABB();
|
||||
} break;
|
||||
case QUAT: {
|
||||
return *reinterpret_cast<const Quat *>(_data._mem) == Quat();
|
||||
case QUATERNION: {
|
||||
return *reinterpret_cast<const Quaternion *>(_data._mem) == Quaternion();
|
||||
|
||||
} break;
|
||||
case BASIS: {
|
||||
@ -1128,8 +1128,8 @@ void Variant::reference(const Variant &p_variant) {
|
||||
case AABB: {
|
||||
_data._aabb = memnew(::AABB(*p_variant._data._aabb));
|
||||
} break;
|
||||
case QUAT: {
|
||||
memnew_placement(_data._mem, Quat(*reinterpret_cast<const Quat *>(p_variant._data._mem)));
|
||||
case QUATERNION: {
|
||||
memnew_placement(_data._mem, Quaternion(*reinterpret_cast<const Quaternion *>(p_variant._data._mem)));
|
||||
|
||||
} break;
|
||||
case BASIS: {
|
||||
@ -1247,8 +1247,8 @@ void Variant::zero() {
|
||||
case PLANE:
|
||||
*reinterpret_cast<Plane *>(this->_data._mem) = Plane();
|
||||
break;
|
||||
case QUAT:
|
||||
*reinterpret_cast<Quat *>(this->_data._mem) = Quat();
|
||||
case QUATERNION:
|
||||
*reinterpret_cast<Quaternion *>(this->_data._mem) = Quaternion();
|
||||
break;
|
||||
case COLOR:
|
||||
*reinterpret_cast<Color *>(this->_data._mem) = Color();
|
||||
@ -1269,7 +1269,7 @@ void Variant::clear() {
|
||||
VECTOR3,
|
||||
VECTOR3i,
|
||||
PLANE,
|
||||
QUAT,
|
||||
QUATERNION,
|
||||
COLOR,
|
||||
VECTOR2,
|
||||
VECTOR2I,
|
||||
@ -1659,11 +1659,11 @@ String Variant::stringify(List<const void *> &stack) const {
|
||||
return "(" + operator Vector3i() + ")";
|
||||
case PLANE:
|
||||
return operator Plane();
|
||||
//case QUAT:
|
||||
//case QUATERNION:
|
||||
case AABB:
|
||||
return operator ::AABB();
|
||||
case QUAT:
|
||||
return "(" + operator Quat() + ")";
|
||||
case QUATERNION:
|
||||
return "(" + operator Quaternion() + ")";
|
||||
case BASIS: {
|
||||
Basis mat3 = operator Basis();
|
||||
|
||||
@ -1879,8 +1879,8 @@ Variant::operator ::AABB() const {
|
||||
Variant::operator Basis() const {
|
||||
if (type == BASIS) {
|
||||
return *_data._basis;
|
||||
} else if (type == QUAT) {
|
||||
return *reinterpret_cast<const Quat *>(_data._mem);
|
||||
} else if (type == QUATERNION) {
|
||||
return *reinterpret_cast<const Quaternion *>(_data._mem);
|
||||
} else if (type == VECTOR3) {
|
||||
return Basis(*reinterpret_cast<const Vector3 *>(_data._mem));
|
||||
} else if (type == TRANSFORM) { // unexposed in Variant::can_convert?
|
||||
@ -1890,15 +1890,15 @@ Variant::operator Basis() const {
|
||||
}
|
||||
}
|
||||
|
||||
Variant::operator Quat() const {
|
||||
if (type == QUAT) {
|
||||
return *reinterpret_cast<const Quat *>(_data._mem);
|
||||
Variant::operator Quaternion() const {
|
||||
if (type == QUATERNION) {
|
||||
return *reinterpret_cast<const Quaternion *>(_data._mem);
|
||||
} else if (type == BASIS) {
|
||||
return *_data._basis;
|
||||
} else if (type == TRANSFORM) {
|
||||
return _data._transform->basis;
|
||||
} else {
|
||||
return Quat();
|
||||
return Quaternion();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1907,8 +1907,8 @@ Variant::operator Transform() const {
|
||||
return *_data._transform;
|
||||
} else if (type == BASIS) {
|
||||
return Transform(*_data._basis, Vector3());
|
||||
} else if (type == QUAT) {
|
||||
return Transform(Basis(*reinterpret_cast<const Quat *>(_data._mem)), Vector3());
|
||||
} else if (type == QUATERNION) {
|
||||
return Transform(Basis(*reinterpret_cast<const Quaternion *>(_data._mem)), Vector3());
|
||||
} else if (type == TRANSFORM2D) {
|
||||
const Transform2D &t = *_data._transform2d;
|
||||
Transform m;
|
||||
@ -2503,9 +2503,9 @@ Variant::Variant(const Basis &p_matrix) {
|
||||
_data._basis = memnew(Basis(p_matrix));
|
||||
}
|
||||
|
||||
Variant::Variant(const Quat &p_quat) {
|
||||
type = QUAT;
|
||||
memnew_placement(_data._mem, Quat(p_quat));
|
||||
Variant::Variant(const Quaternion &p_quat) {
|
||||
type = QUATERNION;
|
||||
memnew_placement(_data._mem, Quaternion(p_quat));
|
||||
}
|
||||
Variant::Variant(const Transform &p_transform) {
|
||||
type = TRANSFORM;
|
||||
@ -2856,8 +2856,8 @@ void Variant::operator=(const Variant &p_variant) {
|
||||
case AABB: {
|
||||
*_data._aabb = *(p_variant._data._aabb);
|
||||
} break;
|
||||
case QUAT: {
|
||||
*reinterpret_cast<Quat *>(_data._mem) = *reinterpret_cast<const Quat *>(p_variant._data._mem);
|
||||
case QUATERNION: {
|
||||
*reinterpret_cast<Quaternion *>(_data._mem) = *reinterpret_cast<const Quaternion *>(p_variant._data._mem);
|
||||
} break;
|
||||
case BASIS: {
|
||||
*_data._basis = *(p_variant._data._basis);
|
||||
@ -3013,7 +3013,7 @@ uint32_t Variant::hash() const {
|
||||
|
||||
} break;
|
||||
/*
|
||||
case QUAT: {
|
||||
case QUATERNION: {
|
||||
|
||||
|
||||
} break;*/
|
||||
@ -3027,11 +3027,11 @@ uint32_t Variant::hash() const {
|
||||
return hash;
|
||||
|
||||
} break;
|
||||
case QUAT: {
|
||||
uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->x);
|
||||
hash = hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->y, hash);
|
||||
hash = hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->z, hash);
|
||||
return hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->w, hash);
|
||||
case QUATERNION: {
|
||||
uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Quaternion *>(_data._mem)->x);
|
||||
hash = hash_djb2_one_float(reinterpret_cast<const Quaternion *>(_data._mem)->y, hash);
|
||||
hash = hash_djb2_one_float(reinterpret_cast<const Quaternion *>(_data._mem)->z, hash);
|
||||
return hash_djb2_one_float(reinterpret_cast<const Quaternion *>(_data._mem)->w, hash);
|
||||
|
||||
} break;
|
||||
case BASIS: {
|
||||
@ -3368,9 +3368,9 @@ bool Variant::hash_compare(const Variant &p_variant) const {
|
||||
|
||||
} break;
|
||||
|
||||
case QUAT: {
|
||||
const Quat *l = reinterpret_cast<const Quat *>(_data._mem);
|
||||
const Quat *r = reinterpret_cast<const Quat *>(p_variant._data._mem);
|
||||
case QUATERNION: {
|
||||
const Quaternion *l = reinterpret_cast<const Quaternion *>(_data._mem);
|
||||
const Quaternion *r = reinterpret_cast<const Quaternion *>(p_variant._data._mem);
|
||||
|
||||
return hash_compare_quat(*l, *r);
|
||||
} break;
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "core/math/basis.h"
|
||||
#include "core/math/face3.h"
|
||||
#include "core/math/plane.h"
|
||||
#include "core/math/quat.h"
|
||||
#include "core/math/quaternion.h"
|
||||
#include "core/math/transform.h"
|
||||
#include "core/math/transform_2d.h"
|
||||
#include "core/math/vector3.h"
|
||||
@ -105,7 +105,7 @@ public:
|
||||
VECTOR3I, //10
|
||||
TRANSFORM2D,
|
||||
PLANE,
|
||||
QUAT,
|
||||
QUATERNION,
|
||||
AABB,
|
||||
BASIS, //15
|
||||
TRANSFORM,
|
||||
@ -218,7 +218,7 @@ public:
|
||||
operator Vector3i() const;
|
||||
operator Plane() const;
|
||||
operator ::AABB() const;
|
||||
operator Quat() const;
|
||||
operator Quaternion() const;
|
||||
operator Basis() const;
|
||||
operator Transform() const;
|
||||
operator Transform2D() const;
|
||||
@ -296,7 +296,7 @@ public:
|
||||
Variant(const Vector3i &p_vector3);
|
||||
Variant(const Plane &p_plane);
|
||||
Variant(const ::AABB &p_aabb);
|
||||
Variant(const Quat &p_quat);
|
||||
Variant(const Quaternion &p_quat);
|
||||
Variant(const Basis &p_matrix);
|
||||
Variant(const Transform2D &p_transform);
|
||||
Variant(const Transform &p_transform);
|
||||
|
@ -564,21 +564,21 @@ struct _VariantCall {
|
||||
}
|
||||
}
|
||||
|
||||
VCALL_LOCALMEM0R(Quat, length);
|
||||
VCALL_LOCALMEM0R(Quat, length_squared);
|
||||
VCALL_LOCALMEM0R(Quat, normalized);
|
||||
VCALL_LOCALMEM0R(Quat, is_normalized);
|
||||
VCALL_LOCALMEM1R(Quat, is_equal_approx);
|
||||
VCALL_LOCALMEM0R(Quat, inverse);
|
||||
VCALL_LOCALMEM1R(Quat, angle_to);
|
||||
VCALL_LOCALMEM1R(Quat, dot);
|
||||
VCALL_LOCALMEM1R(Quat, xform);
|
||||
VCALL_LOCALMEM2R(Quat, slerp);
|
||||
VCALL_LOCALMEM2R(Quat, slerpni);
|
||||
VCALL_LOCALMEM4R(Quat, cubic_slerp);
|
||||
VCALL_LOCALMEM0R(Quat, get_euler);
|
||||
VCALL_LOCALMEM1(Quat, set_euler);
|
||||
VCALL_LOCALMEM2(Quat, set_axis_angle);
|
||||
VCALL_LOCALMEM0R(Quaternion, length);
|
||||
VCALL_LOCALMEM0R(Quaternion, length_squared);
|
||||
VCALL_LOCALMEM0R(Quaternion, normalized);
|
||||
VCALL_LOCALMEM0R(Quaternion, is_normalized);
|
||||
VCALL_LOCALMEM1R(Quaternion, is_equal_approx);
|
||||
VCALL_LOCALMEM0R(Quaternion, inverse);
|
||||
VCALL_LOCALMEM1R(Quaternion, angle_to);
|
||||
VCALL_LOCALMEM1R(Quaternion, dot);
|
||||
VCALL_LOCALMEM1R(Quaternion, xform);
|
||||
VCALL_LOCALMEM2R(Quaternion, slerp);
|
||||
VCALL_LOCALMEM2R(Quaternion, slerpni);
|
||||
VCALL_LOCALMEM4R(Quaternion, cubic_slerp);
|
||||
VCALL_LOCALMEM0R(Quaternion, get_euler);
|
||||
VCALL_LOCALMEM1(Quaternion, set_euler);
|
||||
VCALL_LOCALMEM2(Quaternion, set_axis_angle);
|
||||
|
||||
VCALL_LOCALMEM0R(Color, to_argb32);
|
||||
VCALL_LOCALMEM0R(Color, to_abgr32);
|
||||
@ -1290,16 +1290,16 @@ struct _VariantCall {
|
||||
r_ret = Plane(p_args[0]->operator Vector3(), p_args[1]->operator Vector3());
|
||||
}
|
||||
|
||||
static void Quat_init1(Variant &r_ret, const Variant **p_args) {
|
||||
r_ret = Quat(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
|
||||
static void Quaternion_init1(Variant &r_ret, const Variant **p_args) {
|
||||
r_ret = Quaternion(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
|
||||
}
|
||||
|
||||
static void Quat_init2(Variant &r_ret, const Variant **p_args) {
|
||||
r_ret = Quat(((Vector3)(*p_args[0])), ((real_t)(*p_args[1])));
|
||||
static void Quaternion_init2(Variant &r_ret, const Variant **p_args) {
|
||||
r_ret = Quaternion(((Vector3)(*p_args[0])), ((real_t)(*p_args[1])));
|
||||
}
|
||||
|
||||
static void Quat_init3(Variant &r_ret, const Variant **p_args) {
|
||||
r_ret = Quat(((Vector3)(*p_args[0])));
|
||||
static void Quaternion_init3(Variant &r_ret, const Variant **p_args) {
|
||||
r_ret = Quaternion(((Vector3)(*p_args[0])));
|
||||
}
|
||||
|
||||
static void Color_init1(Variant &r_ret, const Variant **p_args) {
|
||||
@ -1506,8 +1506,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
|
||||
return Transform2D();
|
||||
case PLANE:
|
||||
return Plane();
|
||||
case QUAT:
|
||||
return Quat();
|
||||
case QUATERNION:
|
||||
return Quaternion();
|
||||
case AABB:
|
||||
return ::AABB(); // 10
|
||||
case BASIS:
|
||||
@ -1593,8 +1593,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
|
||||
return (Transform2D(p_args[0]->operator Transform2D()));
|
||||
case PLANE:
|
||||
return (Plane(*p_args[0]));
|
||||
case QUAT:
|
||||
return (p_args[0]->operator Quat());
|
||||
case QUATERNION:
|
||||
return (p_args[0]->operator Quaternion());
|
||||
case AABB:
|
||||
return (::AABB(*p_args[0])); // 10
|
||||
case BASIS:
|
||||
@ -2202,21 +2202,21 @@ void register_variant_methods() {
|
||||
ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_ray, VECTOR3, "from", VECTOR3, "dir", varray());
|
||||
ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_segment, VECTOR3, "begin", VECTOR3, "end", varray());
|
||||
|
||||
ADDFUNC0R(QUAT, REAL, Quat, length, varray());
|
||||
ADDFUNC0R(QUAT, REAL, Quat, length_squared, varray());
|
||||
ADDFUNC0R(QUAT, QUAT, Quat, normalized, varray());
|
||||
ADDFUNC0R(QUAT, BOOL, Quat, is_normalized, varray());
|
||||
ADDFUNC1R(QUAT, BOOL, Quat, is_equal_approx, QUAT, "quat", varray());
|
||||
ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray());
|
||||
ADDFUNC1R(QUAT, REAL, Quat, angle_to, QUAT, "to", varray());
|
||||
ADDFUNC1R(QUAT, REAL, Quat, dot, QUAT, "b", varray());
|
||||
ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray());
|
||||
ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "to", REAL, "weight", varray());
|
||||
ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "to", REAL, "weight", varray());
|
||||
ADDFUNC4R(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", REAL, "weight", varray());
|
||||
ADDFUNC0R(QUAT, VECTOR3, Quat, get_euler, varray());
|
||||
ADDFUNC1(QUAT, NIL, Quat, set_euler, VECTOR3, "euler", varray());
|
||||
ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", REAL, "angle", varray());
|
||||
ADDFUNC0R(QUATERNION, REAL, Quaternion, length, varray());
|
||||
ADDFUNC0R(QUATERNION, REAL, Quaternion, length_squared, varray());
|
||||
ADDFUNC0R(QUATERNION, QUATERNION, Quaternion, normalized, varray());
|
||||
ADDFUNC0R(QUATERNION, BOOL, Quaternion, is_normalized, varray());
|
||||
ADDFUNC1R(QUATERNION, BOOL, Quaternion, is_equal_approx, QUATERNION, "quat", varray());
|
||||
ADDFUNC0R(QUATERNION, QUATERNION, Quaternion, inverse, varray());
|
||||
ADDFUNC1R(QUATERNION, REAL, Quaternion, angle_to, QUATERNION, "to", varray());
|
||||
ADDFUNC1R(QUATERNION, REAL, Quaternion, dot, QUATERNION, "b", varray());
|
||||
ADDFUNC1R(QUATERNION, VECTOR3, Quaternion, xform, VECTOR3, "v", varray());
|
||||
ADDFUNC2R(QUATERNION, QUATERNION, Quaternion, slerp, QUATERNION, "to", REAL, "weight", varray());
|
||||
ADDFUNC2R(QUATERNION, QUATERNION, Quaternion, slerpni, QUATERNION, "to", REAL, "weight", varray());
|
||||
ADDFUNC4R(QUATERNION, QUATERNION, Quaternion, cubic_slerp, QUATERNION, "b", QUATERNION, "pre_a", QUATERNION, "post_b", REAL, "weight", varray());
|
||||
ADDFUNC0R(QUATERNION, VECTOR3, Quaternion, get_euler, varray());
|
||||
ADDFUNC1(QUATERNION, NIL, Quaternion, set_euler, VECTOR3, "euler", varray());
|
||||
ADDFUNC2(QUATERNION, NIL, Quaternion, set_axis_angle, VECTOR3, "axis", REAL, "angle", varray());
|
||||
|
||||
ADDFUNC0R(COLOR, INT, Color, to_argb32, varray());
|
||||
ADDFUNC0R(COLOR, INT, Color, to_abgr32, varray());
|
||||
@ -2533,7 +2533,7 @@ void register_variant_methods() {
|
||||
ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "to", REAL, "weight", varray());
|
||||
// For complicated reasons, the epsilon argument is always discarded. See #45062.
|
||||
ADDFUNC2R(BASIS, BOOL, Basis, is_equal_approx, BASIS, "b", REAL, "epsilon", varray(CMP_EPSILON));
|
||||
ADDFUNC0R(BASIS, QUAT, Basis, get_rotation_quat, varray());
|
||||
ADDFUNC0R(BASIS, QUATERNION, Basis, get_rotation_quat, varray());
|
||||
|
||||
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray());
|
||||
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray());
|
||||
@ -2567,9 +2567,9 @@ void register_variant_methods() {
|
||||
_VariantCall::add_constructor(_VariantCall::Plane_init2, Variant::PLANE, "v1", Variant::VECTOR3, "v2", Variant::VECTOR3, "v3", Variant::VECTOR3);
|
||||
_VariantCall::add_constructor(_VariantCall::Plane_init3, Variant::PLANE, "normal", Variant::VECTOR3, "d", Variant::REAL);
|
||||
|
||||
_VariantCall::add_constructor(_VariantCall::Quat_init1, Variant::QUAT, "x", Variant::REAL, "y", Variant::REAL, "z", Variant::REAL, "w", Variant::REAL);
|
||||
_VariantCall::add_constructor(_VariantCall::Quat_init2, Variant::QUAT, "axis", Variant::VECTOR3, "angle", Variant::REAL);
|
||||
_VariantCall::add_constructor(_VariantCall::Quat_init3, Variant::QUAT, "euler", Variant::VECTOR3);
|
||||
_VariantCall::add_constructor(_VariantCall::Quaternion_init1, Variant::QUATERNION, "x", Variant::REAL, "y", Variant::REAL, "z", Variant::REAL, "w", Variant::REAL);
|
||||
_VariantCall::add_constructor(_VariantCall::Quaternion_init2, Variant::QUATERNION, "axis", Variant::VECTOR3, "angle", Variant::REAL);
|
||||
_VariantCall::add_constructor(_VariantCall::Quaternion_init3, Variant::QUATERNION, "euler", Variant::VECTOR3);
|
||||
|
||||
_VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL, "a", Variant::REAL);
|
||||
_VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL);
|
||||
@ -2663,7 +2663,7 @@ void register_variant_methods() {
|
||||
_VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XZ", Plane(Vector3(0, 1, 0), 0));
|
||||
_VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XY", Plane(Vector3(0, 0, 1), 0));
|
||||
|
||||
_VariantCall::add_variant_constant(Variant::QUAT, "IDENTITY", Quat(0, 0, 0, 1));
|
||||
_VariantCall::add_variant_constant(Variant::QUATERNION, "IDENTITY", Quaternion(0, 0, 0, 1));
|
||||
}
|
||||
|
||||
void unregister_variant_methods() {
|
||||
|
@ -52,7 +52,7 @@
|
||||
CASE_TYPE(PREFIX, OP, VECTOR3I) \
|
||||
CASE_TYPE(PREFIX, OP, TRANSFORM2D) \
|
||||
CASE_TYPE(PREFIX, OP, PLANE) \
|
||||
CASE_TYPE(PREFIX, OP, QUAT) \
|
||||
CASE_TYPE(PREFIX, OP, QUATERNION) \
|
||||
CASE_TYPE(PREFIX, OP, AABB) \
|
||||
CASE_TYPE(PREFIX, OP, BASIS) \
|
||||
CASE_TYPE(PREFIX, OP, TRANSFORM) \
|
||||
@ -92,7 +92,7 @@
|
||||
TYPE(PREFIX, OP, VECTOR3I), \
|
||||
TYPE(PREFIX, OP, TRANSFORM2D), \
|
||||
TYPE(PREFIX, OP, PLANE), \
|
||||
TYPE(PREFIX, OP, QUAT), \
|
||||
TYPE(PREFIX, OP, QUATERNION), \
|
||||
TYPE(PREFIX, OP, AABB), \
|
||||
TYPE(PREFIX, OP, BASIS), \
|
||||
TYPE(PREFIX, OP, TRANSFORM), \
|
||||
@ -537,7 +537,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR3, ==, Vector3);
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR3I, ==, Vector3i);
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, PLANE, ==, Plane);
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, QUAT, ==, Quat);
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, QUATERNION, ==, Quaternion);
|
||||
DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, AABB, ==, _aabb);
|
||||
DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, BASIS, ==, _basis);
|
||||
DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, TRANSFORM, ==, _transform);
|
||||
@ -634,7 +634,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR3, !=, Vector3);
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR3I, !=, Vector3i);
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, PLANE, !=, Plane);
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, QUAT, !=, Quat);
|
||||
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, QUATERNION, !=, Quaternion);
|
||||
DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, AABB, !=, _aabb);
|
||||
DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, BASIS, !=, _basis);
|
||||
DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, TRANSFORM, !=, _transform);
|
||||
@ -715,7 +715,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
CASE_TYPE(math, OP_LESS, RECT2I)
|
||||
CASE_TYPE(math, OP_LESS, TRANSFORM2D)
|
||||
CASE_TYPE(math, OP_LESS, PLANE)
|
||||
CASE_TYPE(math, OP_LESS, QUAT)
|
||||
CASE_TYPE(math, OP_LESS, QUATERNION)
|
||||
CASE_TYPE(math, OP_LESS, AABB)
|
||||
CASE_TYPE(math, OP_LESS, BASIS)
|
||||
CASE_TYPE(math, OP_LESS, TRANSFORM)
|
||||
@ -748,7 +748,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
CASE_TYPE(math, OP_LESS_EQUAL, RECT2I)
|
||||
CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM2D)
|
||||
CASE_TYPE(math, OP_LESS_EQUAL, PLANE)
|
||||
CASE_TYPE(math, OP_LESS_EQUAL, QUAT)
|
||||
CASE_TYPE(math, OP_LESS_EQUAL, QUATERNION)
|
||||
CASE_TYPE(math, OP_LESS_EQUAL, AABB)
|
||||
CASE_TYPE(math, OP_LESS_EQUAL, BASIS)
|
||||
CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM)
|
||||
@ -831,7 +831,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
CASE_TYPE(math, OP_GREATER, RECT2I)
|
||||
CASE_TYPE(math, OP_GREATER, TRANSFORM2D)
|
||||
CASE_TYPE(math, OP_GREATER, PLANE)
|
||||
CASE_TYPE(math, OP_GREATER, QUAT)
|
||||
CASE_TYPE(math, OP_GREATER, QUATERNION)
|
||||
CASE_TYPE(math, OP_GREATER, AABB)
|
||||
CASE_TYPE(math, OP_GREATER, BASIS)
|
||||
CASE_TYPE(math, OP_GREATER, STRING_NAME)
|
||||
@ -864,7 +864,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
CASE_TYPE(math, OP_GREATER_EQUAL, RECT2I)
|
||||
CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM2D)
|
||||
CASE_TYPE(math, OP_GREATER_EQUAL, PLANE)
|
||||
CASE_TYPE(math, OP_GREATER_EQUAL, QUAT)
|
||||
CASE_TYPE(math, OP_GREATER_EQUAL, QUATERNION)
|
||||
CASE_TYPE(math, OP_GREATER_EQUAL, AABB)
|
||||
CASE_TYPE(math, OP_GREATER_EQUAL, BASIS)
|
||||
CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM)
|
||||
@ -912,7 +912,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR2I, +, Vector2i);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR3, +, Vector3);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR3I, +, Vector3i);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_ADD, QUAT, +, Quat);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_ADD, QUATERNION, +, Quaternion);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_ADD, COLOR, +, Color);
|
||||
|
||||
DEFAULT_OP_ARRAY_ADD(math, OP_ADD, POOL_BYTE_ARRAY, uint8_t);
|
||||
@ -949,7 +949,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR2I, -, Vector2i);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR3, -, Vector3);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR3I, -, Vector3i);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, QUAT, -, Quat);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, QUATERNION, -, Quaternion);
|
||||
DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, COLOR, -, Color);
|
||||
|
||||
CASE_TYPE(math, OP_SUBTRACT, NIL)
|
||||
@ -997,19 +997,19 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
}
|
||||
}
|
||||
|
||||
CASE_TYPE(math, OP_MULTIPLY, QUAT) {
|
||||
CASE_TYPE(math, OP_MULTIPLY, QUATERNION) {
|
||||
switch (p_b.type) {
|
||||
case VECTOR3: {
|
||||
_RETURN(reinterpret_cast<const Quat *>(p_a._data._mem)->xform(*(const Vector3 *)p_b._data._mem));
|
||||
_RETURN(reinterpret_cast<const Quaternion *>(p_a._data._mem)->xform(*(const Vector3 *)p_b._data._mem));
|
||||
}
|
||||
case VECTOR3I: {
|
||||
_RETURN(reinterpret_cast<const Quat *>(p_a._data._mem)->xform(*(const Vector3i *)p_b._data._mem));
|
||||
_RETURN(reinterpret_cast<const Quaternion *>(p_a._data._mem)->xform(*(const Vector3i *)p_b._data._mem));
|
||||
}
|
||||
case QUAT: {
|
||||
_RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * *reinterpret_cast<const Quat *>(p_b._data._mem));
|
||||
case QUATERNION: {
|
||||
_RETURN(*reinterpret_cast<const Quaternion *>(p_a._data._mem) * *reinterpret_cast<const Quaternion *>(p_b._data._mem));
|
||||
}
|
||||
case REAL: {
|
||||
_RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * p_b._data._real);
|
||||
_RETURN(*reinterpret_cast<const Quaternion *>(p_a._data._mem) * p_b._data._real);
|
||||
}
|
||||
default:
|
||||
_RETURN_FAIL;
|
||||
@ -1082,7 +1082,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
}
|
||||
|
||||
SWITCH_OP(math, OP_DIVIDE, p_a.type) {
|
||||
CASE_TYPE(math, OP_DIVIDE, QUAT) {
|
||||
CASE_TYPE(math, OP_DIVIDE, QUATERNION) {
|
||||
if (p_b.type != REAL)
|
||||
_RETURN_FAIL;
|
||||
#ifdef DEBUG_ENABLED
|
||||
@ -1091,7 +1091,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
_RETURN("Division By Zero");
|
||||
}
|
||||
#endif
|
||||
_RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) / p_b._data._real);
|
||||
_RETURN(*reinterpret_cast<const Quaternion *>(p_a._data._mem) / p_b._data._real);
|
||||
}
|
||||
|
||||
DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, INT, _int);
|
||||
@ -1136,7 +1136,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR3, Vector3);
|
||||
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR3I, Vector3i);
|
||||
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, PLANE, Plane);
|
||||
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, QUAT, Quat);
|
||||
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, QUATERNION, Quaternion);
|
||||
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR2, Vector2);
|
||||
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR2I, Vector2i);
|
||||
|
||||
@ -1177,7 +1177,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR3, Vector3);
|
||||
DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR3I, Vector3i);
|
||||
DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, PLANE, Plane);
|
||||
DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, QUAT, Quat);
|
||||
DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, QUATERNION, Quaternion);
|
||||
DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, COLOR, Color);
|
||||
|
||||
CASE_TYPE(math, OP_NEGATE, NIL)
|
||||
@ -1250,7 +1250,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||
CASE_TYPE(math, OP_MODULE, VECTOR3I)
|
||||
CASE_TYPE(math, OP_MODULE, TRANSFORM2D)
|
||||
CASE_TYPE(math, OP_MODULE, PLANE)
|
||||
CASE_TYPE(math, OP_MODULE, QUAT)
|
||||
CASE_TYPE(math, OP_MODULE, QUATERNION)
|
||||
CASE_TYPE(math, OP_MODULE, AABB)
|
||||
CASE_TYPE(math, OP_MODULE, BASIS)
|
||||
CASE_TYPE(math, OP_MODULE, TRANSFORM)
|
||||
@ -1618,9 +1618,9 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
|
||||
}
|
||||
|
||||
} break;
|
||||
case QUAT: {
|
||||
case QUATERNION: {
|
||||
if (p_value.type == Variant::INT) {
|
||||
Quat *v = reinterpret_cast<Quat *>(_data._mem);
|
||||
Quaternion *v = reinterpret_cast<Quaternion *>(_data._mem);
|
||||
if (p_index == CoreStringNames::singleton->x) {
|
||||
v->x = p_value._data._int;
|
||||
valid = true;
|
||||
@ -1635,7 +1635,7 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
|
||||
valid = true;
|
||||
}
|
||||
} else if (p_value.type == Variant::REAL) {
|
||||
Quat *v = reinterpret_cast<Quat *>(_data._mem);
|
||||
Quaternion *v = reinterpret_cast<Quaternion *>(_data._mem);
|
||||
if (p_index == CoreStringNames::singleton->x) {
|
||||
v->x = p_value._data._real;
|
||||
valid = true;
|
||||
@ -1914,8 +1914,8 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
|
||||
}
|
||||
|
||||
} break;
|
||||
case QUAT: {
|
||||
const Quat *v = reinterpret_cast<const Quat *>(_data._mem);
|
||||
case QUATERNION: {
|
||||
const Quaternion *v = reinterpret_cast<const Quaternion *>(_data._mem);
|
||||
if (p_index == CoreStringNames::singleton->x) {
|
||||
return v->x;
|
||||
} else if (p_index == CoreStringNames::singleton->y) {
|
||||
@ -2533,14 +2533,14 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
|
||||
}
|
||||
|
||||
} break;
|
||||
case QUAT: {
|
||||
case QUATERNION: {
|
||||
if (p_value.type != Variant::INT && p_value.type != Variant::REAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_index.get_type() == Variant::STRING) {
|
||||
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
|
||||
Quat *v = reinterpret_cast<Quat *>(_data._mem);
|
||||
Quaternion *v = reinterpret_cast<Quaternion *>(_data._mem);
|
||||
if (*str == "x") {
|
||||
valid = true;
|
||||
v->x = p_value;
|
||||
@ -2559,7 +2559,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
|
||||
return;
|
||||
}
|
||||
} else if (p_index.get_type() == Variant::STRING_NAME) {
|
||||
Quat *v = reinterpret_cast<Quat *>(_data._mem);
|
||||
Quaternion *v = reinterpret_cast<Quaternion *>(_data._mem);
|
||||
if (p_index == CoreStringNames::singleton->x) {
|
||||
valid = true;
|
||||
v->x = p_value;
|
||||
@ -3247,10 +3247,10 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
|
||||
}
|
||||
|
||||
} break;
|
||||
case QUAT: {
|
||||
case QUATERNION: {
|
||||
if (p_index.get_type() == Variant::STRING) {
|
||||
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
|
||||
const Quat *v = reinterpret_cast<const Quat *>(_data._mem);
|
||||
const Quaternion *v = reinterpret_cast<const Quaternion *>(_data._mem);
|
||||
if (*str == "x") {
|
||||
valid = true;
|
||||
return v->x;
|
||||
@ -3265,7 +3265,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
|
||||
return v->w;
|
||||
}
|
||||
} else if (p_index.get_type() == Variant::STRING_NAME) {
|
||||
const Quat *v = reinterpret_cast<const Quat *>(_data._mem);
|
||||
const Quaternion *v = reinterpret_cast<const Quaternion *>(_data._mem);
|
||||
if (p_index == CoreStringNames::singleton->x) {
|
||||
valid = true;
|
||||
return v->x;
|
||||
@ -3813,7 +3813,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "d"));
|
||||
|
||||
} break;
|
||||
case QUAT: {
|
||||
case QUATERNION: {
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "x"));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "y"));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "z"));
|
||||
@ -4606,10 +4606,10 @@ void Variant::sub(const Variant &a, const Variant &b, Variant &r_dst) {
|
||||
r_dst = ::AABB(ra->position - rb->position, ra->size - rb->size);
|
||||
}
|
||||
return;
|
||||
case QUAT: {
|
||||
Quat empty_rot;
|
||||
const Quat *qa = reinterpret_cast<const Quat *>(a._data._mem);
|
||||
const Quat *qb = reinterpret_cast<const Quat *>(b._data._mem);
|
||||
case QUATERNION: {
|
||||
Quaternion empty_rot;
|
||||
const Quaternion *qa = reinterpret_cast<const Quaternion *>(a._data._mem);
|
||||
const Quaternion *qb = reinterpret_cast<const Quaternion *>(b._data._mem);
|
||||
r_dst = (*qb).inverse() * *qa;
|
||||
}
|
||||
return;
|
||||
@ -4697,10 +4697,10 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst)
|
||||
r_dst = ::AABB(ra->position + rb->position * c, ra->size + rb->size * c);
|
||||
}
|
||||
return;
|
||||
case QUAT: {
|
||||
Quat empty_rot;
|
||||
const Quat *qa = reinterpret_cast<const Quat *>(a._data._mem);
|
||||
const Quat *qb = reinterpret_cast<const Quat *>(b._data._mem);
|
||||
case QUATERNION: {
|
||||
Quaternion empty_rot;
|
||||
const Quaternion *qa = reinterpret_cast<const Quaternion *>(a._data._mem);
|
||||
const Quaternion *qb = reinterpret_cast<const Quaternion *>(b._data._mem);
|
||||
r_dst = *qa * empty_rot.slerp(*qb, c);
|
||||
}
|
||||
return;
|
||||
@ -4832,8 +4832,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
|
||||
r_dst = a;
|
||||
}
|
||||
return;
|
||||
case QUAT: {
|
||||
r_dst = reinterpret_cast<const Quat *>(a._data._mem)->slerp(*reinterpret_cast<const Quat *>(b._data._mem), c);
|
||||
case QUATERNION: {
|
||||
r_dst = reinterpret_cast<const Quaternion *>(a._data._mem)->slerp(*reinterpret_cast<const Quaternion *>(b._data._mem), c);
|
||||
}
|
||||
return;
|
||||
case AABB: {
|
||||
|
@ -646,7 +646,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
}
|
||||
|
||||
value = Plane(args[0], args[1], args[2], args[3]);
|
||||
} else if (id == "Quat") {
|
||||
} else if (id == "Quaternion") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err) {
|
||||
@ -658,7 +658,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
value = Quat(args[0], args[1], args[2], args[3]);
|
||||
value = Quaternion(args[0], args[1], args[2], args[3]);
|
||||
} else if (id == "AABB" || id == "Rect3") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
@ -1702,9 +1702,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
p_store_string_func(p_store_string_ud, "AABB( " + rtos_fix(aabb.position.x) + ", " + rtos_fix(aabb.position.y) + ", " + rtos_fix(aabb.position.z) + ", " + rtos_fix(aabb.size.x) + ", " + rtos_fix(aabb.size.y) + ", " + rtos_fix(aabb.size.z) + " )");
|
||||
|
||||
} break;
|
||||
case Variant::QUAT: {
|
||||
Quat quat = p_variant;
|
||||
p_store_string_func(p_store_string_ud, "Quat( " + rtos_fix(quat.x) + ", " + rtos_fix(quat.y) + ", " + rtos_fix(quat.z) + ", " + rtos_fix(quat.w) + " )");
|
||||
case Variant::QUATERNION: {
|
||||
Quaternion quat = p_variant;
|
||||
p_store_string_func(p_store_string_ud, "Quaternion( " + rtos_fix(quat.x) + ", " + rtos_fix(quat.y) + ", " + rtos_fix(quat.z) + ", " + rtos_fix(quat.w) + " )");
|
||||
|
||||
} break;
|
||||
case Variant::TRANSFORM2D: {
|
||||
|
@ -1602,8 +1602,8 @@
|
||||
<constant name="TYPE_PLANE" value="12" enum="Variant.Type">
|
||||
Variable is of type [Plane].
|
||||
</constant>
|
||||
<constant name="TYPE_QUAT" value="13" enum="Variant.Type">
|
||||
Variable is of type [Quat].
|
||||
<constant name="TYPE_QUATERNION" value="13" enum="Variant.Type">
|
||||
Variable is of type [Quaternion].
|
||||
</constant>
|
||||
<constant name="TYPE_AABB" value="14" enum="Variant.Type">
|
||||
Variable is of type [AABB].
|
||||
|
@ -260,7 +260,7 @@
|
||||
<return type="int" />
|
||||
<argument index="0" name="track_idx" type="int" />
|
||||
<argument index="1" name="time" type="float" />
|
||||
<argument index="2" name="rotation" type="Quaternion" />
|
||||
<argument index="2" name="rotation" type="Quaternionernion" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<methods>
|
||||
<method name="Basis">
|
||||
<return type="Basis" />
|
||||
<argument index="0" name="from" type="Quat" />
|
||||
<argument index="0" name="from" type="Quaternion" />
|
||||
<description>
|
||||
Constructs a pure rotation basis matrix from the given quaternion.
|
||||
</description>
|
||||
@ -31,7 +31,7 @@
|
||||
<argument index="0" name="from" type="Vector3" />
|
||||
<description>
|
||||
Constructs a pure rotation basis matrix from the given Euler angles (in the YXZ convention: when *composing*, first Y, then X, and Z last), given in the vector format as (X angle, Y angle, Z angle).
|
||||
Consider using the [Quat] constructor instead, which uses a quaternion instead of Euler angles.
|
||||
Consider using the [Quaternion] constructor instead, which uses a quaternion instead of Euler angles.
|
||||
</description>
|
||||
</method>
|
||||
<method name="Basis">
|
||||
@ -62,7 +62,7 @@
|
||||
<return type="Vector3" />
|
||||
<description>
|
||||
Returns the basis's rotation in the form of Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last). The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).
|
||||
Consider using the [method get_rotation_quat] method instead, which returns a [Quat] quaternion instead of Euler angles.
|
||||
Consider using the [method get_rotation_quat] method instead, which returns a [Quaternion] quaternion instead of Euler angles.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_orthogonal_index">
|
||||
@ -72,7 +72,7 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_rotation_quat">
|
||||
<return type="Quat" />
|
||||
<return type="Quaternion" />
|
||||
<description>
|
||||
Returns the basis's rotation in the form of a quaternion. See [method get_euler] if you need Euler angles, but keep in mind quaternions should generally be preferred to Euler angles.
|
||||
</description>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="Quat" version="3.5">
|
||||
<class name="Quaternion" version="3.5">
|
||||
<brief_description>
|
||||
Quaternion.
|
||||
Quaternionernion.
|
||||
</brief_description>
|
||||
<description>
|
||||
A unit quaternion used for representing 3D rotations. Quaternions need to be normalized to be used for rotation.
|
||||
It is similar to Basis, which implements matrix representation of rotations, and can be parametrized using both an axis-angle pair or Euler angles. Basis stores rotation, scale, and shearing, while Quat only stores rotation.
|
||||
A unit quaternion used for representing 3D rotations. Quaternionernions need to be normalized to be used for rotation.
|
||||
It is similar to Basis, which implements matrix representation of rotations, and can be parametrized using both an axis-angle pair or Euler angles. Basis stores rotation, scale, and shearing, while Quaternion only stores rotation.
|
||||
Due to its compactness and the way it is stored in memory, certain operations (obtaining axis-angle and performing SLERP, in particular) are more efficient and robust against floating-point errors.
|
||||
</description>
|
||||
<tutorials>
|
||||
@ -13,30 +13,30 @@
|
||||
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="Quat">
|
||||
<return type="Quat" />
|
||||
<method name="Quaternion">
|
||||
<return type="Quaternion" />
|
||||
<argument index="0" name="from" type="Basis" />
|
||||
<description>
|
||||
Constructs a quaternion from the given [Basis].
|
||||
</description>
|
||||
</method>
|
||||
<method name="Quat">
|
||||
<return type="Quat" />
|
||||
<method name="Quaternion">
|
||||
<return type="Quaternion" />
|
||||
<argument index="0" name="euler" type="Vector3" />
|
||||
<description>
|
||||
Constructs a quaternion that will perform a rotation specified by Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle).
|
||||
</description>
|
||||
</method>
|
||||
<method name="Quat">
|
||||
<return type="Quat" />
|
||||
<method name="Quaternion">
|
||||
<return type="Quaternion" />
|
||||
<argument index="0" name="axis" type="Vector3" />
|
||||
<argument index="1" name="angle" type="float" />
|
||||
<description>
|
||||
Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
|
||||
</description>
|
||||
</method>
|
||||
<method name="Quat">
|
||||
<return type="Quat" />
|
||||
<method name="Quaternion">
|
||||
<return type="Quaternion" />
|
||||
<argument index="0" name="x" type="float" />
|
||||
<argument index="1" name="y" type="float" />
|
||||
<argument index="2" name="z" type="float" />
|
||||
@ -47,17 +47,17 @@
|
||||
</method>
|
||||
<method name="angle_to">
|
||||
<return type="float" />
|
||||
<argument index="0" name="to" type="Quat" />
|
||||
<argument index="0" name="to" type="Quaternion" />
|
||||
<description>
|
||||
Returns the angle between this quaternion and [code]to[/code]. This is the magnitude of the angle you would need to rotate by to get from one to the other.
|
||||
[b]Note:[/b] This method has an abnormally high amount of floating-point error, so methods such as [method @GDScript.is_zero_approx] will not work reliably.
|
||||
</description>
|
||||
</method>
|
||||
<method name="cubic_slerp">
|
||||
<return type="Quat" />
|
||||
<argument index="0" name="b" type="Quat" />
|
||||
<argument index="1" name="pre_a" type="Quat" />
|
||||
<argument index="2" name="post_b" type="Quat" />
|
||||
<return type="Quaternion" />
|
||||
<argument index="0" name="b" type="Quaternion" />
|
||||
<argument index="1" name="pre_a" type="Quaternion" />
|
||||
<argument index="2" name="post_b" type="Quaternion" />
|
||||
<argument index="3" name="weight" type="float" />
|
||||
<description>
|
||||
Performs a cubic spherical interpolation between quaternions [code]pre_a[/code], this vector, [code]b[/code], and [code]post_b[/code], by the given amount [code]weight[/code].
|
||||
@ -65,13 +65,13 @@
|
||||
</method>
|
||||
<method name="dot">
|
||||
<return type="float" />
|
||||
<argument index="0" name="b" type="Quat" />
|
||||
<argument index="0" name="b" type="Quaternion" />
|
||||
<description>
|
||||
Returns the dot product of two quaternions.
|
||||
</description>
|
||||
</method>
|
||||
<method name="exp" qualifiers="const">
|
||||
<return type="Quaternion" />
|
||||
<return type="Quaternionernion" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
@ -82,14 +82,14 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="inverse">
|
||||
<return type="Quat" />
|
||||
<return type="Quaternion" />
|
||||
<description>
|
||||
Returns the inverse of the quaternion.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_equal_approx">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="quat" type="Quat" />
|
||||
<argument index="0" name="quat" type="Quaternion" />
|
||||
<description>
|
||||
Returns [code]true[/code] if this quaternion and [code]quat[/code] are approximately equal, by running [method @GDScript.is_equal_approx] on each component.
|
||||
</description>
|
||||
@ -113,12 +113,12 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="log" qualifiers="const">
|
||||
<return type="Quaternion" />
|
||||
<return type="Quaternionernion" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="normalized">
|
||||
<return type="Quat" />
|
||||
<return type="Quaternion" />
|
||||
<description>
|
||||
Returns a copy of the quaternion, normalized to unit length.
|
||||
</description>
|
||||
@ -137,8 +137,8 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="slerp">
|
||||
<return type="Quat" />
|
||||
<argument index="0" name="to" type="Quat" />
|
||||
<return type="Quaternion" />
|
||||
<argument index="0" name="to" type="Quaternion" />
|
||||
<argument index="1" name="weight" type="float" />
|
||||
<description>
|
||||
Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code].
|
||||
@ -146,8 +146,8 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="slerpni">
|
||||
<return type="Quat" />
|
||||
<argument index="0" name="to" type="Quat" />
|
||||
<return type="Quaternion" />
|
||||
<argument index="0" name="to" type="Quaternion" />
|
||||
<argument index="1" name="weight" type="float" />
|
||||
<description>
|
||||
Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code], but without checking if the rotation path is not bigger than 90 degrees.
|
||||
@ -164,23 +164,23 @@
|
||||
<members>
|
||||
<member name="w" type="float" setter="" getter="" default="1.0">
|
||||
W component of the quaternion (real part).
|
||||
Quaternion components should usually not be manipulated directly.
|
||||
Quaternionernion components should usually not be manipulated directly.
|
||||
</member>
|
||||
<member name="x" type="float" setter="" getter="" default="0.0">
|
||||
X component of the quaternion (imaginary [code]i[/code] axis part).
|
||||
Quaternion components should usually not be manipulated directly.
|
||||
Quaternionernion components should usually not be manipulated directly.
|
||||
</member>
|
||||
<member name="y" type="float" setter="" getter="" default="0.0">
|
||||
Y component of the quaternion (imaginary [code]j[/code] axis part).
|
||||
Quaternion components should usually not be manipulated directly.
|
||||
Quaternionernion components should usually not be manipulated directly.
|
||||
</member>
|
||||
<member name="z" type="float" setter="" getter="" default="0.0">
|
||||
Z component of the quaternion (imaginary [code]k[/code] axis part).
|
||||
Quaternion components should usually not be manipulated directly.
|
||||
Quaternionernion components should usually not be manipulated directly.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="IDENTITY" value="Quat( 0, 0, 0, 1 )">
|
||||
<constant name="IDENTITY" value="Quaternion( 0, 0, 0, 1 )">
|
||||
The identity quaternion, representing no rotation. Equivalent to an identity [Basis] matrix. If a vector is transformed by an identity quaternion, it will not change.
|
||||
</constant>
|
||||
</constants>
|
@ -160,7 +160,7 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_bone_pose_rotation" qualifiers="const">
|
||||
<return type="Quaternion" />
|
||||
<return type="Quaternionernion" />
|
||||
<argument index="0" name="bone_idx" type="int" />
|
||||
<description>
|
||||
</description>
|
||||
@ -365,7 +365,7 @@
|
||||
<method name="set_bone_pose_rotation">
|
||||
<return type="void" />
|
||||
<argument index="0" name="bone_idx" type="int" />
|
||||
<argument index="1" name="rotation" type="Quaternion" />
|
||||
<argument index="1" name="rotation" type="Quaternionernion" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
|
@ -86,9 +86,9 @@
|
||||
</method>
|
||||
<method name="String">
|
||||
<return type="String" />
|
||||
<argument index="0" name="from" type="Quat" />
|
||||
<argument index="0" name="from" type="Quaternion" />
|
||||
<description>
|
||||
Constructs a new String from the given [Quat].
|
||||
Constructs a new String from the given [Quaternion].
|
||||
</description>
|
||||
</method>
|
||||
<method name="String">
|
||||
|
@ -43,9 +43,9 @@
|
||||
</method>
|
||||
<method name="Transform">
|
||||
<return type="Transform" />
|
||||
<argument index="0" name="from" type="Quat" />
|
||||
<argument index="0" name="from" type="Quaternion" />
|
||||
<description>
|
||||
Constructs a Transform from a [Quat]. The origin will be [code]Vector3(0, 0, 0)[/code].
|
||||
Constructs a Transform from a [Quaternion]. The origin will be [code]Vector3(0, 0, 0)[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="Transform">
|
||||
|
@ -3560,7 +3560,7 @@ msgid "Variable is of type [Plane]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/@GlobalScope.xml
|
||||
msgid "Variable is of type [Quat]."
|
||||
msgid "Variable is of type [Quaternion]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/@GlobalScope.xml
|
||||
@ -4637,7 +4637,7 @@ msgstr ""
|
||||
msgid ""
|
||||
"Returns the interpolated value of a transform track at a given time (in "
|
||||
"seconds). An array consisting of 3 elements: position ([Vector3]), rotation "
|
||||
"([Quat]) and scale ([Vector3])."
|
||||
"([Quaternion]) and scale ([Vector3])."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Animation.xml
|
||||
@ -4959,7 +4959,7 @@ msgstr ""
|
||||
#: doc/classes/GIProbe.xml doc/classes/GIProbeData.xml
|
||||
#: doc/classes/KinematicBody.xml doc/classes/Light.xml doc/classes/Material.xml
|
||||
#: doc/classes/Mesh.xml doc/classes/MeshInstance.xml doc/classes/Particles.xml
|
||||
#: doc/classes/Quat.xml doc/classes/Skeleton.xml doc/classes/SpotLight.xml
|
||||
#: doc/classes/Quaternion.xml doc/classes/Skeleton.xml doc/classes/SpotLight.xml
|
||||
#: doc/classes/StaticBody.xml doc/classes/WorldEnvironment.xml
|
||||
msgid "Third Person Shooter Demo"
|
||||
msgstr ""
|
||||
@ -10772,7 +10772,7 @@ msgstr ""
|
||||
msgid "Matrices and transforms"
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Basis.xml doc/classes/Quat.xml doc/classes/Transform.xml
|
||||
#: doc/classes/Basis.xml doc/classes/Quaternion.xml doc/classes/Transform.xml
|
||||
msgid "Using 3D transforms"
|
||||
msgstr ""
|
||||
|
||||
@ -10807,7 +10807,7 @@ msgid ""
|
||||
"Constructs a pure rotation basis matrix from the given Euler angles (in the "
|
||||
"YXZ convention: when *composing*, first Y, then X, and Z last), given in the "
|
||||
"vector format as (X angle, Y angle, Z angle).\n"
|
||||
"Consider using the [Quat] constructor instead, which uses a quaternion "
|
||||
"Consider using the [Quaternion] constructor instead, which uses a quaternion "
|
||||
"instead of Euler angles."
|
||||
msgstr ""
|
||||
|
||||
@ -10838,7 +10838,7 @@ msgid ""
|
||||
"vector contains the rotation angles in the format (X angle, Y angle, Z "
|
||||
"angle).\n"
|
||||
"Consider using the [method get_rotation_quat] method instead, which returns "
|
||||
"a [Quat] quaternion instead of Euler angles."
|
||||
"a [Quaternion] quaternion instead of Euler angles."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Basis.xml
|
||||
@ -47787,44 +47787,44 @@ msgstr ""
|
||||
msgid "Size on the X and Y axes."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
msgid "Quaternion."
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Quaternionernion."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"A unit quaternion used for representing 3D rotations. Quaternions need to be "
|
||||
"A unit quaternion used for representing 3D rotations. Quaternionernions need to be "
|
||||
"normalized to be used for rotation.\n"
|
||||
"It is similar to Basis, which implements matrix representation of rotations, "
|
||||
"and can be parametrized using both an axis-angle pair or Euler angles. Basis "
|
||||
"stores rotation, scale, and shearing, while Quat only stores rotation.\n"
|
||||
"stores rotation, scale, and shearing, while Quaternion only stores rotation.\n"
|
||||
"Due to its compactness and the way it is stored in memory, certain "
|
||||
"operations (obtaining axis-angle and performing SLERP, in particular) are "
|
||||
"more efficient and robust against floating-point errors."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Constructs a quaternion from the given [Basis]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Constructs a quaternion that will perform a rotation specified by Euler "
|
||||
"angles (in the YXZ convention: when decomposing, first Z, then X, and Y "
|
||||
"last), given in the vector format as (X angle, Y angle, Z angle)."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Constructs a quaternion that will rotate around the given axis by the "
|
||||
"specified angle. The axis must be a normalized vector."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Constructs a quaternion defined by the given values."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns the angle between this quaternion and [code]to[/code]. This is the "
|
||||
"magnitude of the angle you would need to rotate by to get from one to the "
|
||||
@ -47834,18 +47834,18 @@ msgid ""
|
||||
"reliably."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Performs a cubic spherical interpolation between quaternions [code]pre_a[/"
|
||||
"code], this vector, [code]b[/code], and [code]post_b[/code], by the given "
|
||||
"amount [code]weight[/code]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns the dot product of two quaternions."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns Euler angles (in the YXZ convention: when decomposing, first Z, then "
|
||||
"X, and Y last) corresponding to the rotation represented by the unit "
|
||||
@ -47853,89 +47853,89 @@ msgid ""
|
||||
"angle, Y angle, Z angle)."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns the inverse of the quaternion."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns [code]true[/code] if this quaternion and [code]quat[/code] are "
|
||||
"approximately equal, by running [method @GDScript.is_equal_approx] on each "
|
||||
"component."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns whether the quaternion is normalized or not."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns the length of the quaternion."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns the length of the quaternion, squared."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns a copy of the quaternion, normalized to unit length."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Sets the quaternion to a rotation which rotates around axis by the specified "
|
||||
"angle, in radians. The axis must be a normalized vector."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Sets the quaternion to a rotation specified by Euler angles (in the YXZ "
|
||||
"convention: when decomposing, first Z, then X, and Y last), given in the "
|
||||
"vector format as (X angle, Y angle, Z angle)."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns the result of the spherical linear interpolation between this "
|
||||
"quaternion and [code]to[/code] by amount [code]weight[/code].\n"
|
||||
"[b]Note:[/b] Both quaternions must be normalized."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns the result of the spherical linear interpolation between this "
|
||||
"quaternion and [code]to[/code] by amount [code]weight[/code], but without "
|
||||
"checking if the rotation path is not bigger than 90 degrees."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns a vector transformed (multiplied) by this quaternion."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"W component of the quaternion (real part).\n"
|
||||
"Quaternion components should usually not be manipulated directly."
|
||||
"Quaternionernion components should usually not be manipulated directly."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"X component of the quaternion (imaginary [code]i[/code] axis part).\n"
|
||||
"Quaternion components should usually not be manipulated directly."
|
||||
"Quaternionernion components should usually not be manipulated directly."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Y component of the quaternion (imaginary [code]j[/code] axis part).\n"
|
||||
"Quaternion components should usually not be manipulated directly."
|
||||
"Quaternionernion components should usually not be manipulated directly."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Z component of the quaternion (imaginary [code]k[/code] axis part).\n"
|
||||
"Quaternion components should usually not be manipulated directly."
|
||||
"Quaternionernion components should usually not be manipulated directly."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"The identity quaternion, representing no rotation. Equivalent to an identity "
|
||||
"[Basis] matrix. If a vector is transformed by an identity quaternion, it "
|
||||
@ -55092,7 +55092,7 @@ msgid "Constructs a new String from the given [Plane]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/String.xml
|
||||
msgid "Constructs a new String from the given [Quat]."
|
||||
msgid "Constructs a new String from the given [Quaternion]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/String.xml
|
||||
@ -59895,7 +59895,7 @@ msgstr ""
|
||||
|
||||
#: doc/classes/Transform.xml
|
||||
msgid ""
|
||||
"Constructs a Transform from a [Quat]. The origin will be [code]Vector3(0, 0, "
|
||||
"Constructs a Transform from a [Quaternion]. The origin will be [code]Vector3(0, 0, "
|
||||
"0)[/code]."
|
||||
msgstr ""
|
||||
|
||||
|
@ -3585,7 +3585,7 @@ msgid "Variable is of type [Plane]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/@GlobalScope.xml
|
||||
msgid "Variable is of type [Quat]."
|
||||
msgid "Variable is of type [Quaternion]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/@GlobalScope.xml
|
||||
@ -4662,7 +4662,7 @@ msgstr ""
|
||||
msgid ""
|
||||
"Returns the interpolated value of a transform track at a given time (in "
|
||||
"seconds). An array consisting of 3 elements: position ([Vector3]), rotation "
|
||||
"([Quat]) and scale ([Vector3])."
|
||||
"([Quaternion]) and scale ([Vector3])."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Animation.xml
|
||||
@ -4984,7 +4984,7 @@ msgstr ""
|
||||
#: doc/classes/GIProbe.xml doc/classes/GIProbeData.xml
|
||||
#: doc/classes/KinematicBody.xml doc/classes/Light.xml doc/classes/Material.xml
|
||||
#: doc/classes/Mesh.xml doc/classes/MeshInstance.xml doc/classes/Particles.xml
|
||||
#: doc/classes/Quat.xml doc/classes/Skeleton.xml doc/classes/SpotLight.xml
|
||||
#: doc/classes/Quaternion.xml doc/classes/Skeleton.xml doc/classes/SpotLight.xml
|
||||
#: doc/classes/StaticBody.xml doc/classes/WorldEnvironment.xml
|
||||
msgid "Third Person Shooter Demo"
|
||||
msgstr ""
|
||||
@ -10797,7 +10797,7 @@ msgstr ""
|
||||
msgid "Matrices and transforms"
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Basis.xml doc/classes/Quat.xml doc/classes/Transform.xml
|
||||
#: doc/classes/Basis.xml doc/classes/Quaternion.xml doc/classes/Transform.xml
|
||||
msgid "Using 3D transforms"
|
||||
msgstr ""
|
||||
|
||||
@ -10832,7 +10832,7 @@ msgid ""
|
||||
"Constructs a pure rotation basis matrix from the given Euler angles (in the "
|
||||
"YXZ convention: when *composing*, first Y, then X, and Z last), given in the "
|
||||
"vector format as (X angle, Y angle, Z angle).\n"
|
||||
"Consider using the [Quat] constructor instead, which uses a quaternion "
|
||||
"Consider using the [Quaternion] constructor instead, which uses a quaternion "
|
||||
"instead of Euler angles."
|
||||
msgstr ""
|
||||
|
||||
@ -10863,7 +10863,7 @@ msgid ""
|
||||
"vector contains the rotation angles in the format (X angle, Y angle, Z "
|
||||
"angle).\n"
|
||||
"Consider using the [method get_rotation_quat] method instead, which returns "
|
||||
"a [Quat] quaternion instead of Euler angles."
|
||||
"a [Quaternion] quaternion instead of Euler angles."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Basis.xml
|
||||
@ -47872,44 +47872,44 @@ msgstr ""
|
||||
msgid "Size on the X and Y axes."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
msgid "Quaternion."
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Quaternionernion."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"A unit quaternion used for representing 3D rotations. Quaternions need to be "
|
||||
"A unit quaternion used for representing 3D rotations. Quaternionernions need to be "
|
||||
"normalized to be used for rotation.\n"
|
||||
"It is similar to Basis, which implements matrix representation of rotations, "
|
||||
"and can be parametrized using both an axis-angle pair or Euler angles. Basis "
|
||||
"stores rotation, scale, and shearing, while Quat only stores rotation.\n"
|
||||
"stores rotation, scale, and shearing, while Quaternion only stores rotation.\n"
|
||||
"Due to its compactness and the way it is stored in memory, certain "
|
||||
"operations (obtaining axis-angle and performing SLERP, in particular) are "
|
||||
"more efficient and robust against floating-point errors."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Constructs a quaternion from the given [Basis]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Constructs a quaternion that will perform a rotation specified by Euler "
|
||||
"angles (in the YXZ convention: when decomposing, first Z, then X, and Y "
|
||||
"last), given in the vector format as (X angle, Y angle, Z angle)."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Constructs a quaternion that will rotate around the given axis by the "
|
||||
"specified angle. The axis must be a normalized vector."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Constructs a quaternion defined by the given values."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns the angle between this quaternion and [code]to[/code]. This is the "
|
||||
"magnitude of the angle you would need to rotate by to get from one to the "
|
||||
@ -47919,18 +47919,18 @@ msgid ""
|
||||
"reliably."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Performs a cubic spherical interpolation between quaternions [code]pre_a[/"
|
||||
"code], this vector, [code]b[/code], and [code]post_b[/code], by the given "
|
||||
"amount [code]weight[/code]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns the dot product of two quaternions."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns Euler angles (in the YXZ convention: when decomposing, first Z, then "
|
||||
"X, and Y last) corresponding to the rotation represented by the unit "
|
||||
@ -47938,89 +47938,89 @@ msgid ""
|
||||
"angle, Y angle, Z angle)."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns the inverse of the quaternion."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns [code]true[/code] if this quaternion and [code]quat[/code] are "
|
||||
"approximately equal, by running [method @GDScript.is_equal_approx] on each "
|
||||
"component."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns whether the quaternion is normalized or not."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns the length of the quaternion."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns the length of the quaternion, squared."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns a copy of the quaternion, normalized to unit length."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Sets the quaternion to a rotation which rotates around axis by the specified "
|
||||
"angle, in radians. The axis must be a normalized vector."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Sets the quaternion to a rotation specified by Euler angles (in the YXZ "
|
||||
"convention: when decomposing, first Z, then X, and Y last), given in the "
|
||||
"vector format as (X angle, Y angle, Z angle)."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns the result of the spherical linear interpolation between this "
|
||||
"quaternion and [code]to[/code] by amount [code]weight[/code].\n"
|
||||
"[b]Note:[/b] Both quaternions must be normalized."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Returns the result of the spherical linear interpolation between this "
|
||||
"quaternion and [code]to[/code] by amount [code]weight[/code], but without "
|
||||
"checking if the rotation path is not bigger than 90 degrees."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid "Returns a vector transformed (multiplied) by this quaternion."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"W component of the quaternion (real part).\n"
|
||||
"Quaternion components should usually not be manipulated directly."
|
||||
"Quaternionernion components should usually not be manipulated directly."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"X component of the quaternion (imaginary [code]i[/code] axis part).\n"
|
||||
"Quaternion components should usually not be manipulated directly."
|
||||
"Quaternionernion components should usually not be manipulated directly."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Y component of the quaternion (imaginary [code]j[/code] axis part).\n"
|
||||
"Quaternion components should usually not be manipulated directly."
|
||||
"Quaternionernion components should usually not be manipulated directly."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"Z component of the quaternion (imaginary [code]k[/code] axis part).\n"
|
||||
"Quaternion components should usually not be manipulated directly."
|
||||
"Quaternionernion components should usually not be manipulated directly."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/Quat.xml
|
||||
#: doc/classes/Quaternion.xml
|
||||
msgid ""
|
||||
"The identity quaternion, representing no rotation. Equivalent to an identity "
|
||||
"[Basis] matrix. If a vector is transformed by an identity quaternion, it "
|
||||
@ -55177,7 +55177,7 @@ msgid "Constructs a new String from the given [Plane]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/String.xml
|
||||
msgid "Constructs a new String from the given [Quat]."
|
||||
msgid "Constructs a new String from the given [Quaternion]."
|
||||
msgstr ""
|
||||
|
||||
#: doc/classes/String.xml
|
||||
@ -59980,7 +59980,7 @@ msgstr ""
|
||||
|
||||
#: doc/classes/Transform.xml
|
||||
msgid ""
|
||||
"Constructs a Transform from a [Quat]. The origin will be [code]Vector3(0, 0, "
|
||||
"Constructs a Transform from a [Quaternion]. The origin will be [code]Vector3(0, 0, "
|
||||
"0)[/code]."
|
||||
msgstr ""
|
||||
|
||||
|
@ -771,8 +771,8 @@ void ShaderGLES2::use_material(void *p_material) {
|
||||
if (V->get().get_type() == Variant::COLOR) {
|
||||
Color value = V->get();
|
||||
glUniform4f(location, value.r, value.g, value.b, value.a);
|
||||
} else if (V->get().get_type() == Variant::QUAT) {
|
||||
Quat value = V->get();
|
||||
} else if (V->get().get_type() == Variant::QUATERNION) {
|
||||
Quaternion value = V->get();
|
||||
glUniform4f(location, value.x, value.y, value.z, value.w);
|
||||
} else {
|
||||
Plane value = V->get();
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "core/error_macros.h"
|
||||
#include "core/math/basis.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/math/quat.h"
|
||||
#include "core/math/quaternion.h"
|
||||
#include "core/math/transform.h"
|
||||
#include "core/math/transform_2d.h"
|
||||
#include "core/math/vector3.h"
|
||||
@ -1266,7 +1266,7 @@ public:
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR3, "position"));
|
||||
} break;
|
||||
case Animation::TYPE_ROTATION_3D: {
|
||||
p_list->push_back(PropertyInfo(Variant::QUAT, "scale"));
|
||||
p_list->push_back(PropertyInfo(Variant::QUATERNION, "scale"));
|
||||
} break;
|
||||
case Animation::TYPE_SCALE_3D: {
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale"));
|
||||
@ -2607,7 +2607,7 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
|
||||
text += TTR("Position:") + " " + String(t) + "\n";
|
||||
} break;
|
||||
case Animation::TYPE_ROTATION_3D: {
|
||||
Quat t = animation->track_get_key_value(track, key_idx);
|
||||
Quaternion t = animation->track_get_key_value(track, key_idx);
|
||||
text += TTR("Rotation:") + " " + String(t) + "\n";
|
||||
} break;
|
||||
case Animation::TYPE_SCALE_3D: {
|
||||
@ -3540,7 +3540,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) {
|
||||
case Variant::REAL:
|
||||
case Variant::VECTOR2:
|
||||
case Variant::VECTOR3:
|
||||
case Variant::QUAT:
|
||||
case Variant::QUATERNION:
|
||||
case Variant::PLANE:
|
||||
case Variant::COLOR: {
|
||||
// Valid.
|
||||
@ -4038,7 +4038,7 @@ static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool
|
||||
subindices.push_back(":y");
|
||||
subindices.push_back(":z");
|
||||
} break;
|
||||
case Variant::QUAT: {
|
||||
case Variant::QUATERNION: {
|
||||
subindices.push_back(":x");
|
||||
subindices.push_back(":y");
|
||||
subindices.push_back(":z");
|
||||
@ -4104,7 +4104,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
|
||||
h.type == Variant::RECT2 ||
|
||||
h.type == Variant::VECTOR3 ||
|
||||
h.type == Variant::AABB ||
|
||||
h.type == Variant::QUAT ||
|
||||
h.type == Variant::QUATERNION ||
|
||||
h.type == Variant::COLOR ||
|
||||
h.type == Variant::PLANE ||
|
||||
h.type == Variant::TRANSFORM2D ||
|
||||
@ -4588,7 +4588,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
|
||||
filter.push_back(Variant::REAL);
|
||||
filter.push_back(Variant::VECTOR2);
|
||||
filter.push_back(Variant::VECTOR3);
|
||||
filter.push_back(Variant::QUAT);
|
||||
filter.push_back(Variant::QUATERNION);
|
||||
filter.push_back(Variant::PLANE);
|
||||
filter.push_back(Variant::COLOR);
|
||||
|
||||
@ -4659,7 +4659,7 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) {
|
||||
h.type == Variant::RECT2 ||
|
||||
h.type == Variant::VECTOR3 ||
|
||||
h.type == Variant::AABB ||
|
||||
h.type == Variant::QUAT ||
|
||||
h.type == Variant::QUATERNION ||
|
||||
h.type == Variant::COLOR ||
|
||||
h.type == Variant::PLANE ||
|
||||
h.type == Variant::TRANSFORM2D ||
|
||||
@ -4775,7 +4775,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
|
||||
return;
|
||||
}
|
||||
|
||||
Quat rot = base->get_transform().basis.operator Quat();
|
||||
Quaternion rot = base->get_transform().basis.operator Quaternion();
|
||||
|
||||
undo_redo->create_action(TTR("Add Rotation Key"));
|
||||
undo_redo->add_do_method(animation.ptr(), "rotation_track_insert_key", p_track, p_ofs, rot);
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "core/math/aabb.h"
|
||||
#include "core/math/basis.h"
|
||||
#include "core/math/plane.h"
|
||||
#include "core/math/quat.h"
|
||||
#include "core/math/quaternion.h"
|
||||
#include "core/math/rect2.h"
|
||||
#include "core/math/transform.h"
|
||||
#include "core/math/vector2.h"
|
||||
@ -229,8 +229,8 @@ void ConnectDialog::_add_bind() {
|
||||
case Variant::PLANE:
|
||||
value = Plane();
|
||||
break;
|
||||
case Variant::QUAT:
|
||||
value = Quat();
|
||||
case Variant::QUATERNION:
|
||||
value = Quaternion();
|
||||
break;
|
||||
case Variant::AABB:
|
||||
value = AABB();
|
||||
@ -473,7 +473,7 @@ ConnectDialog::ConnectDialog() {
|
||||
type_list->add_item("Rect2", Variant::RECT2);
|
||||
type_list->add_item("Vector3", Variant::VECTOR3);
|
||||
type_list->add_item("Plane", Variant::PLANE);
|
||||
type_list->add_item("Quat", Variant::QUAT);
|
||||
type_list->add_item("Quaternion", Variant::QUATERNION);
|
||||
type_list->add_item("AABB", Variant::AABB);
|
||||
type_list->add_item("Basis", Variant::BASIS);
|
||||
type_list->add_item("Transform", Variant::TRANSFORM);
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "core/math/math_defs.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/math/plane.h"
|
||||
#include "core/math/quat.h"
|
||||
#include "core/math/quaternion.h"
|
||||
#include "core/math/rect2.h"
|
||||
#include "core/math/transform.h"
|
||||
#include "core/math/transform_2d.h"
|
||||
@ -2117,14 +2117,14 @@ EditorPropertyPlane::EditorPropertyPlane() {
|
||||
setting = false;
|
||||
}
|
||||
|
||||
///////////////////// QUAT /////////////////////////
|
||||
///////////////////// QUATERNION /////////////////////////
|
||||
|
||||
void EditorPropertyQuat::_value_changed(double val, const String &p_name) {
|
||||
void EditorPropertyQuaternion::_value_changed(double val, const String &p_name) {
|
||||
if (setting) {
|
||||
return;
|
||||
}
|
||||
|
||||
Quat p;
|
||||
Quaternion p;
|
||||
p.x = spin[0]->get_value();
|
||||
p.y = spin[1]->get_value();
|
||||
p.z = spin[2]->get_value();
|
||||
@ -2132,8 +2132,8 @@ void EditorPropertyQuat::_value_changed(double val, const String &p_name) {
|
||||
emit_changed(get_edited_property(), p, p_name);
|
||||
}
|
||||
|
||||
void EditorPropertyQuat::update_property() {
|
||||
Quat val = get_edited_object()->get(get_edited_property());
|
||||
void EditorPropertyQuaternion::update_property() {
|
||||
Quaternion val = get_edited_object()->get(get_edited_property());
|
||||
setting = true;
|
||||
spin[0]->set_value(val.x);
|
||||
spin[1]->set_value(val.y);
|
||||
@ -2141,7 +2141,7 @@ void EditorPropertyQuat::update_property() {
|
||||
spin[3]->set_value(val.w);
|
||||
setting = false;
|
||||
}
|
||||
void EditorPropertyQuat::_notification(int p_what) {
|
||||
void EditorPropertyQuaternion::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
|
||||
Color base = get_color("accent_color", "Editor");
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@ -2151,11 +2151,11 @@ void EditorPropertyQuat::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
}
|
||||
void EditorPropertyQuat::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_value_changed"), &EditorPropertyQuat::_value_changed);
|
||||
void EditorPropertyQuaternion::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_value_changed"), &EditorPropertyQuaternion::_value_changed);
|
||||
}
|
||||
|
||||
void EditorPropertyQuat::setup(double p_min, double p_max, double p_step, bool p_no_slider) {
|
||||
void EditorPropertyQuaternion::setup(double p_min, double p_max, double p_step, bool p_no_slider) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
spin[i]->set_min(p_min);
|
||||
spin[i]->set_max(p_max);
|
||||
@ -2166,7 +2166,7 @@ void EditorPropertyQuat::setup(double p_min, double p_max, double p_step, bool p
|
||||
}
|
||||
}
|
||||
|
||||
EditorPropertyQuat::EditorPropertyQuat() {
|
||||
EditorPropertyQuaternion::EditorPropertyQuaternion() {
|
||||
bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing");
|
||||
|
||||
BoxContainer *bc;
|
||||
@ -3463,8 +3463,8 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
||||
editor->setup(min, max, step, hide_slider);
|
||||
add_property_editor(p_path, editor);
|
||||
} break;
|
||||
case Variant::QUAT: {
|
||||
EditorPropertyQuat *editor = memnew(EditorPropertyQuat);
|
||||
case Variant::QUATERNION: {
|
||||
EditorPropertyQuaternion *editor = memnew(EditorPropertyQuaternion);
|
||||
double min = -65535, max = 65535, step = default_float_step;
|
||||
bool hide_slider = true;
|
||||
|
||||
|
@ -532,8 +532,8 @@ public:
|
||||
EditorPropertyPlane();
|
||||
};
|
||||
|
||||
class EditorPropertyQuat : public EditorProperty {
|
||||
GDCLASS(EditorPropertyQuat, EditorProperty);
|
||||
class EditorPropertyQuaternion : public EditorProperty {
|
||||
GDCLASS(EditorPropertyQuaternion, EditorProperty);
|
||||
EditorSpinSlider *spin[4];
|
||||
bool setting;
|
||||
void _value_changed(double p_val, const String &p_name);
|
||||
@ -545,7 +545,7 @@ protected:
|
||||
public:
|
||||
virtual void update_property();
|
||||
void setup(double p_min, double p_max, double p_step, bool p_no_slider);
|
||||
EditorPropertyQuat();
|
||||
EditorPropertyQuaternion();
|
||||
};
|
||||
|
||||
class EditorPropertyAABB : public EditorProperty {
|
||||
|
@ -1008,8 +1008,8 @@ void EditorPropertyDictionary::update_property() {
|
||||
prop = editor;
|
||||
|
||||
} break;
|
||||
case Variant::QUAT: {
|
||||
EditorPropertyQuat *editor = memnew(EditorPropertyQuat);
|
||||
case Variant::QUATERNION: {
|
||||
EditorPropertyQuaternion *editor = memnew(EditorPropertyQuaternion);
|
||||
editor->setup(-100000, 100000, 0.001, true);
|
||||
prop = editor;
|
||||
|
||||
|
@ -679,7 +679,7 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo
|
||||
default_anim->position_track_interpolate(j, from, &p);
|
||||
new_anim->position_track_insert_key(dtrack, 0, p);
|
||||
} else if (default_anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
|
||||
Quat r;
|
||||
Quaternion r;
|
||||
default_anim->rotation_track_interpolate(j, from, &r);
|
||||
new_anim->rotation_track_insert_key(dtrack, 0, r);
|
||||
} else if (default_anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
|
||||
@ -698,7 +698,7 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo
|
||||
default_anim->position_track_get_key(j, k, &p);
|
||||
new_anim->position_track_insert_key(dtrack, kt - from, p);
|
||||
} else if (default_anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
|
||||
Quat r;
|
||||
Quaternion r;
|
||||
default_anim->rotation_track_get_key(j, k, &r);
|
||||
new_anim->rotation_track_insert_key(dtrack, kt - from, r);
|
||||
} else if (default_anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
|
||||
@ -717,7 +717,7 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo
|
||||
default_anim->position_track_interpolate(j, to, &p);
|
||||
new_anim->position_track_insert_key(dtrack, to - from, p);
|
||||
} else if (default_anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
|
||||
Quat r;
|
||||
Quaternion r;
|
||||
default_anim->rotation_track_interpolate(j, to, &r);
|
||||
new_anim->rotation_track_insert_key(dtrack, to - from, r);
|
||||
} else if (default_anim->track_get_type(j) == Animation::TYPE_SCALE_3D) {
|
||||
@ -742,7 +742,7 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo
|
||||
default_anim->position_track_interpolate(j, to, &p);
|
||||
new_anim->position_track_insert_key(dtrack, to - from, p);
|
||||
} else if (default_anim->track_get_type(j) == Animation::TYPE_ROTATION_3D) {
|
||||
Quat r;
|
||||
Quaternion r;
|
||||
default_anim->rotation_track_interpolate(j, from, &r);
|
||||
new_anim->rotation_track_insert_key(dtrack, 0, r);
|
||||
default_anim->rotation_track_interpolate(j, to, &r);
|
||||
|
@ -348,7 +348,7 @@ void ScriptTextEditor::_set_theme_for_script() {
|
||||
text_edit->add_keyword_color("Basis", basetype_color);
|
||||
text_edit->add_keyword_color("Plane", basetype_color);
|
||||
text_edit->add_keyword_color("Transform", basetype_color);
|
||||
text_edit->add_keyword_color("Quat", basetype_color);
|
||||
text_edit->add_keyword_color("Quaternion", basetype_color);
|
||||
text_edit->add_keyword_color("Color", basetype_color);
|
||||
text_edit->add_keyword_color("Object", basetype_color);
|
||||
text_edit->add_keyword_color("NodePath", basetype_color);
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "core/math/expression.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/math/plane.h"
|
||||
#include "core/math/quat.h"
|
||||
#include "core/math/quaternion.h"
|
||||
#include "core/math/rect2.h"
|
||||
#include "core/math/transform.h"
|
||||
#include "core/math/transform_2d.h"
|
||||
@ -765,13 +765,13 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
|
||||
value_editor[3]->set_text(String::num(plane.d));
|
||||
|
||||
} break;
|
||||
case Variant::QUAT: {
|
||||
case Variant::QUATERNION: {
|
||||
field_names.push_back("x");
|
||||
field_names.push_back("y");
|
||||
field_names.push_back("z");
|
||||
field_names.push_back("w");
|
||||
config_value_editors(4, 4, 10, field_names);
|
||||
Quat q = v;
|
||||
Quaternion q = v;
|
||||
value_editor[0]->set_text(String::num(q.x));
|
||||
value_editor[1]->set_text(String::num(q.y));
|
||||
value_editor[2]->set_text(String::num(q.z));
|
||||
@ -1554,8 +1554,8 @@ void CustomPropertyEditor::_modified(String p_string) {
|
||||
_emit_changed_whole_or_field();
|
||||
|
||||
} break;
|
||||
case Variant::QUAT: {
|
||||
Quat q;
|
||||
case Variant::QUATERNION: {
|
||||
Quaternion q;
|
||||
q.x = _parse_real_expression(value_editor[0]->get_text());
|
||||
q.y = _parse_real_expression(value_editor[1]->get_text());
|
||||
q.z = _parse_real_expression(value_editor[2]->get_text());
|
||||
@ -1676,7 +1676,7 @@ void CustomPropertyEditor::_focus_enter() {
|
||||
case Variant::RECT2:
|
||||
case Variant::VECTOR3:
|
||||
case Variant::PLANE:
|
||||
case Variant::QUAT:
|
||||
case Variant::QUATERNION:
|
||||
case Variant::AABB:
|
||||
case Variant::TRANSFORM2D:
|
||||
case Variant::BASIS:
|
||||
@ -1702,7 +1702,7 @@ void CustomPropertyEditor::_focus_exit() {
|
||||
case Variant::RECT2:
|
||||
case Variant::VECTOR3:
|
||||
case Variant::PLANE:
|
||||
case Variant::QUAT:
|
||||
case Variant::QUATERNION:
|
||||
case Variant::AABB:
|
||||
case Variant::TRANSFORM2D:
|
||||
case Variant::BASIS:
|
||||
|
@ -148,7 +148,7 @@ void PropertySelector::_update_search() {
|
||||
Control::get_icon("Vector3", "EditorIcons"),
|
||||
Control::get_icon("Transform2D", "EditorIcons"),
|
||||
Control::get_icon("Plane", "EditorIcons"),
|
||||
Control::get_icon("Quat", "EditorIcons"),
|
||||
Control::get_icon("Quaternion", "EditorIcons"),
|
||||
Control::get_icon("AABB", "EditorIcons"),
|
||||
Control::get_icon("Basis", "EditorIcons"),
|
||||
Control::get_icon("Transform", "EditorIcons"),
|
||||
|
@ -204,7 +204,7 @@ bool test_rotation(Vector3 deg_original_euler, RotOrder rot_order) {
|
||||
OS *os = OS::get_singleton();
|
||||
os->print("Rotation order: %ls\n.", get_rot_order_name(rot_order).c_str());
|
||||
os->print("Original Rotation: %ls\n", String(deg_original_euler).c_str());
|
||||
os->print("Quaternion to rotation order: %ls\n", String(rad2deg(euler_from_rotation)).c_str());
|
||||
os->print("Quaternionernion to rotation order: %ls\n", String(rad2deg(euler_from_rotation)).c_str());
|
||||
}
|
||||
|
||||
return pass;
|
||||
|
@ -557,13 +557,13 @@ MainLoop *test() {
|
||||
|
||||
Basis m2(v2, a2);
|
||||
|
||||
Quat q = m;
|
||||
Quat q2 = m2;
|
||||
Quaternion q = m;
|
||||
Quaternion q2 = m2;
|
||||
|
||||
Basis m3 = m.inverse() * m2;
|
||||
Quat q3 = (q.inverse() * q2); //.normalized();
|
||||
Quaternion q3 = (q.inverse() * q2); //.normalized();
|
||||
|
||||
print_line(Quat(m3));
|
||||
print_line(Quaternion(m3));
|
||||
print_line(q3);
|
||||
|
||||
print_line("before v: " + v + " a: " + rtos(a));
|
||||
|
@ -2174,7 +2174,7 @@ static void _find_identifiers(const CScriptCompletionContext &p_context, bool p_
|
||||
|
||||
static const char *_type_names[Variant::VARIANT_MAX] = {
|
||||
"null", "bool", "int", "float", "String", "Vector2", "Vector2i", "Rect2", "Rect2i", "Vector3", "Vector3i", "Transform2D", "Plane",
|
||||
"Quat", "AABB", "Basis", "Transform", "Color", "NodePath", "RID", "Object", "Dictionary", "Array",
|
||||
"Quaternion", "AABB", "Basis", "Transform", "Color", "NodePath", "RID", "Object", "Dictionary", "Array",
|
||||
"PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray",
|
||||
"PoolVector2Array", "PoolVector2iArray", "PoolVector3Array", "PoolVector3iArray", "PoolColorArray"
|
||||
};
|
||||
|
@ -6551,7 +6551,7 @@ CScriptParser::DataType CScriptParser::_reduce_node_type(Node *p_node) {
|
||||
case Variant::RECT2:
|
||||
case Variant::RECT2I:
|
||||
case Variant::PLANE:
|
||||
case Variant::QUAT:
|
||||
case Variant::QUATERNION:
|
||||
case Variant::AABB:
|
||||
case Variant::OBJECT: {
|
||||
error = index_type.builtin_type != Variant::STRING;
|
||||
@ -6649,7 +6649,7 @@ CScriptParser::DataType CScriptParser::_reduce_node_type(Node *p_node) {
|
||||
case Variant::POOL_REAL_ARRAY:
|
||||
case Variant::VECTOR2:
|
||||
case Variant::VECTOR3:
|
||||
case Variant::QUAT: {
|
||||
case Variant::QUATERNION: {
|
||||
result.builtin_type = Variant::REAL;
|
||||
} break;
|
||||
// Return color
|
||||
|
@ -150,7 +150,7 @@ static const _bit _type_list[] = {
|
||||
{ Variant::VECTOR3I, "Vector3i" },
|
||||
{ Variant::AABB, "AABB" },
|
||||
{ Variant::PLANE, "Plane" },
|
||||
{ Variant::QUAT, "Quat" },
|
||||
{ Variant::QUATERNION, "Quaternion" },
|
||||
{ Variant::BASIS, "Basis" },
|
||||
{ Variant::TRANSFORM, "Transform" },
|
||||
{ Variant::COLOR, "Color" },
|
||||
|
@ -2184,7 +2184,7 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p
|
||||
|
||||
static const char *_type_names[Variant::VARIANT_MAX] = {
|
||||
"null", "bool", "int", "float", "String", "Vector2", "Vector2i", "Rect2", "Rect2i", "Vector3", "Vector3i", "Transform2D", "Plane",
|
||||
"Quat", "AABB", "Basis", "Transform", "Color", "NodePath", "RID", "Object", "Dictionary", "Array",
|
||||
"Quaternion", "AABB", "Basis", "Transform", "Color", "NodePath", "RID", "Object", "Dictionary", "Array",
|
||||
"PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray",
|
||||
"PoolVector2Array", "PoolVector2iArray", "PoolVector3Array", "PoolVector3iArray", "PoolColorArray"
|
||||
};
|
||||
|
@ -6757,7 +6757,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
|
||||
case Variant::RECT2:
|
||||
case Variant::RECT2I:
|
||||
case Variant::PLANE:
|
||||
case Variant::QUAT:
|
||||
case Variant::QUATERNION:
|
||||
case Variant::AABB:
|
||||
case Variant::OBJECT: {
|
||||
error = index_type.builtin_type != Variant::STRING;
|
||||
@ -6855,7 +6855,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
|
||||
case Variant::POOL_REAL_ARRAY:
|
||||
case Variant::VECTOR2:
|
||||
case Variant::VECTOR3:
|
||||
case Variant::QUAT: {
|
||||
case Variant::QUATERNION: {
|
||||
result.builtin_type = Variant::REAL;
|
||||
} break;
|
||||
// Return color
|
||||
|
@ -159,7 +159,7 @@ static const _bit _type_list[] = {
|
||||
{ Variant::VECTOR3I, "Vector3i" },
|
||||
{ Variant::AABB, "AABB" },
|
||||
{ Variant::PLANE, "Plane" },
|
||||
{ Variant::QUAT, "Quat" },
|
||||
{ Variant::QUATERNION, "Quaternion" },
|
||||
{ Variant::BASIS, "Basis" },
|
||||
{ Variant::TRANSFORM, "Transform" },
|
||||
{ Variant::COLOR, "Color" },
|
||||
|
@ -24,7 +24,7 @@
|
||||
</member>
|
||||
<member name="parent" type="int" setter="set_parent" getter="get_parent" default="-1">
|
||||
</member>
|
||||
<member name="rotation" type="Quat" setter="set_rotation" getter="get_rotation" default="Quat( 0, 0, 0, 1 )">
|
||||
<member name="rotation" type="Quaternion" setter="set_rotation" getter="get_rotation" default="Quaternion( 0, 0, 0, 1 )">
|
||||
</member>
|
||||
<member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )">
|
||||
</member>
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
struct Track {
|
||||
Channel<Vector3> translation_track;
|
||||
Channel<Quat> rotation_track;
|
||||
Channel<Quaternion> rotation_track;
|
||||
Channel<Vector3> scale_track;
|
||||
Vector<Channel<float>> weight_tracks;
|
||||
};
|
||||
|
@ -332,7 +332,7 @@ static Vector3 _arr_to_vec3(const Array &p_array) {
|
||||
return Vector3(p_array[0], p_array[1], p_array[2]);
|
||||
}
|
||||
|
||||
static Array _quat_to_array(const Quat &p_quat) {
|
||||
static Array _quat_to_array(const Quaternion &p_quat) {
|
||||
Array array;
|
||||
array.resize(4);
|
||||
array[0] = p_quat.x;
|
||||
@ -342,9 +342,9 @@ static Array _quat_to_array(const Quat &p_quat) {
|
||||
return array;
|
||||
}
|
||||
|
||||
static Quat _arr_to_quat(const Array &p_array) {
|
||||
ERR_FAIL_COND_V(p_array.size() != 4, Quat());
|
||||
return Quat(p_array[0], p_array[1], p_array[2], p_array[3]);
|
||||
static Quaternion _arr_to_quat(const Array &p_array) {
|
||||
ERR_FAIL_COND_V(p_array.size() != 4, Quaternion());
|
||||
return Quaternion(p_array[0], p_array[1], p_array[2], p_array[3]);
|
||||
}
|
||||
|
||||
static Transform _arr_to_xform(const Array &p_array) {
|
||||
@ -415,7 +415,7 @@ Error GLTFDocument::_serialize_nodes(Ref<GLTFState> state) {
|
||||
node["matrix"] = _xform_to_array(n->xform);
|
||||
}
|
||||
|
||||
if (!n->rotation.is_equal_approx(Quat())) {
|
||||
if (!n->rotation.is_equal_approx(Quaternion())) {
|
||||
node["rotation"] = _quat_to_array(n->rotation);
|
||||
}
|
||||
|
||||
@ -1905,7 +1905,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_joints(Ref<GLTFState> state,
|
||||
return state->accessors.size() - 1;
|
||||
}
|
||||
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_quats(Ref<GLTFState> state, const Vector<Quat> p_attribs, const bool p_for_vertex) {
|
||||
GLTFAccessorIndex GLTFDocument::_encode_accessor_as_quats(Ref<GLTFState> state, const Vector<Quaternion> p_attribs, const bool p_for_vertex) {
|
||||
if (p_attribs.size() == 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -1920,7 +1920,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_quats(Ref<GLTFState> state,
|
||||
Vector<double> type_min;
|
||||
type_min.resize(element_count);
|
||||
for (int i = 0; i < p_attribs.size(); i++) {
|
||||
Quat quat = p_attribs[i];
|
||||
Quaternion quat = p_attribs[i];
|
||||
attribs.write[(i * element_count) + 0] = Math::stepify(quat.x, CMP_NORMALIZE_TOLERANCE);
|
||||
attribs.write[(i * element_count) + 1] = Math::stepify(quat.y, CMP_NORMALIZE_TOLERANCE);
|
||||
attribs.write[(i * element_count) + 2] = Math::stepify(quat.z, CMP_NORMALIZE_TOLERANCE);
|
||||
@ -2227,9 +2227,9 @@ Vector<Color> GLTFDocument::_decode_accessor_as_color(Ref<GLTFState> state, cons
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
Vector<Quat> GLTFDocument::_decode_accessor_as_quat(Ref<GLTFState> state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
|
||||
Vector<Quaternion> GLTFDocument::_decode_accessor_as_quat(Ref<GLTFState> state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
|
||||
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
|
||||
Vector<Quat> ret;
|
||||
Vector<Quaternion> ret;
|
||||
|
||||
if (attribs.size() == 0) {
|
||||
return ret;
|
||||
@ -2241,7 +2241,7 @@ Vector<Quat> GLTFDocument::_decode_accessor_as_quat(Ref<GLTFState> state, const
|
||||
ret.resize(ret_size);
|
||||
{
|
||||
for (int i = 0; i < ret_size; i++) {
|
||||
ret.write[i] = Quat(attribs_ptr[i * 4 + 0], attribs_ptr[i * 4 + 1], attribs_ptr[i * 4 + 2], attribs_ptr[i * 4 + 3]).normalized();
|
||||
ret.write[i] = Quaternion(attribs_ptr[i * 4 + 0], attribs_ptr[i * 4 + 1], attribs_ptr[i * 4 + 2], attribs_ptr[i * 4 + 3]).normalized();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -4762,7 +4762,7 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> state) {
|
||||
s["interpolation"] = interpolation_to_string(track.rotation_track.interpolation);
|
||||
Vector<real_t> times = Variant(track.rotation_track.times);
|
||||
s["input"] = _encode_accessor_as_floats(state, times, false);
|
||||
Vector<Quat> values = track.rotation_track.values;
|
||||
Vector<Quaternion> values = track.rotation_track.values;
|
||||
s["output"] = _encode_accessor_as_quats(state, values, false);
|
||||
|
||||
samplers.push_back(s);
|
||||
@ -4983,7 +4983,7 @@ Error GLTFDocument::_parse_animations(Ref<GLTFState> state) {
|
||||
track->translation_track.times = Variant(times); //convert via variant
|
||||
track->translation_track.values = Variant(translations); //convert via variant
|
||||
} else if (path == "rotation") {
|
||||
const Vector<Quat> rotations = _decode_accessor_as_quat(state, output, false);
|
||||
const Vector<Quaternion> rotations = _decode_accessor_as_quat(state, output, false);
|
||||
track->rotation_track.interpolation = interp;
|
||||
track->rotation_track.times = Variant(times); //convert via variant
|
||||
track->rotation_track.values = rotations;
|
||||
@ -5400,7 +5400,7 @@ void GLTFDocument::_convert_mult_mesh_instance_to_gltf(MultiMeshInstance *p_mult
|
||||
transform.origin =
|
||||
Vector3(xform_2d.get_origin().x, 0, xform_2d.get_origin().y);
|
||||
real_t rotation = xform_2d.get_rotation();
|
||||
Quat quat(Vector3(0, 1, 0), rotation);
|
||||
Quaternion quat(Vector3(0, 1, 0), rotation);
|
||||
Size2 scale = xform_2d.get_scale();
|
||||
transform.basis.set_quat_scale(quat,
|
||||
Vector3(scale.x, 0, scale.y));
|
||||
@ -5692,24 +5692,24 @@ struct EditorSceneImporterGLTFInterpolate {
|
||||
|
||||
// thank you for existing, partial specialization
|
||||
template <>
|
||||
struct EditorSceneImporterGLTFInterpolate<Quat> {
|
||||
Quat lerp(const Quat &a, const Quat &b, const float c) const {
|
||||
ERR_FAIL_COND_V_MSG(!a.is_normalized(), Quat(), "The quaternion \"a\" must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!b.is_normalized(), Quat(), "The quaternion \"b\" must be normalized.");
|
||||
struct EditorSceneImporterGLTFInterpolate<Quaternion> {
|
||||
Quaternion lerp(const Quaternion &a, const Quaternion &b, const float c) const {
|
||||
ERR_FAIL_COND_V_MSG(!a.is_normalized(), Quaternion(), "The quaternion \"a\" must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!b.is_normalized(), Quaternion(), "The quaternion \"b\" must be normalized.");
|
||||
|
||||
return a.slerp(b, c).normalized();
|
||||
}
|
||||
|
||||
Quat catmull_rom(const Quat &p0, const Quat &p1, const Quat &p2, const Quat &p3, const float c) {
|
||||
ERR_FAIL_COND_V_MSG(!p1.is_normalized(), Quat(), "The quaternion \"p1\" must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p2.is_normalized(), Quat(), "The quaternion \"p2\" must be normalized.");
|
||||
Quaternion catmull_rom(const Quaternion &p0, const Quaternion &p1, const Quaternion &p2, const Quaternion &p3, const float c) {
|
||||
ERR_FAIL_COND_V_MSG(!p1.is_normalized(), Quaternion(), "The quaternion \"p1\" must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!p2.is_normalized(), Quaternion(), "The quaternion \"p2\" must be normalized.");
|
||||
|
||||
return p1.slerp(p2, c).normalized();
|
||||
}
|
||||
|
||||
Quat bezier(const Quat start, const Quat control_1, const Quat control_2, const Quat end, const float t) {
|
||||
ERR_FAIL_COND_V_MSG(!start.is_normalized(), Quat(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!end.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
||||
Quaternion bezier(const Quaternion start, const Quaternion control_1, const Quaternion control_2, const Quaternion end, const float t) {
|
||||
ERR_FAIL_COND_V_MSG(!start.is_normalized(), Quaternion(), "The start quaternion must be normalized.");
|
||||
ERR_FAIL_COND_V_MSG(!end.is_normalized(), Quaternion(), "The end quaternion must be normalized.");
|
||||
|
||||
return start.slerp(end, t).normalized();
|
||||
}
|
||||
@ -5878,10 +5878,10 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
|
||||
}
|
||||
}
|
||||
if (track.rotation_track.values.size()) {
|
||||
Quat base_rot = state->nodes[track_i->key()]->rotation.normalized();
|
||||
Quaternion base_rot = state->nodes[track_i->key()]->rotation.normalized();
|
||||
bool not_default = false; //discard the track if all it contains is default values
|
||||
for (int i = 0; i < track.rotation_track.times.size(); i++) {
|
||||
Quat value = track.rotation_track.values[track.rotation_track.interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE ? (1 + i * 3) : i].normalized();
|
||||
Quaternion value = track.rotation_track.values[track.rotation_track.interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE ? (1 + i * 3) : i].normalized();
|
||||
if (!value.is_equal_approx(base_rot)) {
|
||||
not_default = true;
|
||||
break;
|
||||
@ -5920,7 +5920,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
|
||||
double time = 0.0;
|
||||
|
||||
Vector3 base_pos;
|
||||
Quat base_rot;
|
||||
Quaternion base_rot;
|
||||
Vector3 base_scale = Vector3(1, 1, 1);
|
||||
|
||||
if (rotation_idx == -1) {
|
||||
@ -5938,7 +5938,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
|
||||
bool last = false;
|
||||
while (true) {
|
||||
Vector3 pos = base_pos;
|
||||
Quat rot = base_rot;
|
||||
Quaternion rot = base_rot;
|
||||
Vector3 scale = base_scale;
|
||||
|
||||
if (position_idx >= 0) {
|
||||
@ -5947,7 +5947,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
|
||||
}
|
||||
|
||||
if (rotation_idx >= 0) {
|
||||
rot = _interpolate_track<Quat>(track.rotation_track.times, track.rotation_track.values, time, track.rotation_track.interpolation);
|
||||
rot = _interpolate_track<Quaternion>(track.rotation_track.times, track.rotation_track.values, time, track.rotation_track.interpolation);
|
||||
animation->rotation_track_insert_key(rotation_idx, time, rot);
|
||||
}
|
||||
|
||||
@ -6223,7 +6223,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state
|
||||
p_track.rotation_track.interpolation = gltf_interpolation;
|
||||
p_track.rotation_track.values.resize(key_count);
|
||||
for (int32_t key_i = 0; key_i < key_count; key_i++) {
|
||||
Quat rotation;
|
||||
Quaternion rotation;
|
||||
Error err = p_animation->rotation_track_get_key(p_track_i, key_i, &rotation);
|
||||
ERR_CONTINUE(err != OK);
|
||||
p_track.rotation_track.values.write[key_i] = rotation;
|
||||
@ -6237,7 +6237,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state
|
||||
p_track.rotation_track.interpolation = gltf_interpolation;
|
||||
|
||||
for (int32_t key_i = 0; key_i < key_count; key_i++) {
|
||||
Quat rotation_track = p_animation->track_get_key_value(p_track_i, key_i);
|
||||
Quaternion rotation_track = p_animation->track_get_key_value(p_track_i, key_i);
|
||||
p_track.rotation_track.values.write[key_i] = rotation_track;
|
||||
}
|
||||
} else if (path.find(":translation") != -1) {
|
||||
@ -6264,7 +6264,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state
|
||||
rotation_radian.x = Math::deg2rad(rotation_degrees.x);
|
||||
rotation_radian.y = Math::deg2rad(rotation_degrees.y);
|
||||
rotation_radian.z = Math::deg2rad(rotation_degrees.z);
|
||||
p_track.rotation_track.values.write[key_i] = Quat(rotation_radian);
|
||||
p_track.rotation_track.values.write[key_i] = Quaternion(rotation_radian);
|
||||
}
|
||||
} else if (path.find(":scale") != -1) {
|
||||
p_track.scale_track.times = times;
|
||||
|
@ -208,7 +208,7 @@ private:
|
||||
Vector<Color> _decode_accessor_as_color(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<Quat> _decode_accessor_as_quat(Ref<GLTFState> state,
|
||||
Vector<Quaternion> _decode_accessor_as_quat(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<Transform2D> _decode_accessor_as_xform2d(Ref<GLTFState> state,
|
||||
@ -275,7 +275,7 @@ private:
|
||||
const float p_time,
|
||||
const GLTFAnimation::Interpolation p_interp);
|
||||
GLTFAccessorIndex _encode_accessor_as_quats(Ref<GLTFState> state,
|
||||
const Vector<Quat> p_attribs,
|
||||
const Vector<Quaternion> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
GLTFAccessorIndex _encode_accessor_as_weights(Ref<GLTFState> state,
|
||||
const Vector<Color> p_attribs,
|
||||
|
@ -67,7 +67,7 @@ void GLTFNode::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "skeleton"), "set_skeleton", "get_skeleton"); // GLTFSkeletonIndex
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "joint"), "set_joint", "get_joint"); // bool
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation"), "set_translation", "get_translation"); // Vector3
|
||||
ADD_PROPERTY(PropertyInfo(Variant::QUAT, "rotation"), "set_rotation", "get_rotation"); // Quat
|
||||
ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "rotation"), "set_rotation", "get_rotation"); // Quaternion
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale"); // Vector3
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "children"), "set_children", "get_children"); // Vector<int>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "light"), "set_light", "get_light"); // GLTFLightIndex
|
||||
@ -145,11 +145,11 @@ void GLTFNode::set_translation(Vector3 p_translation) {
|
||||
translation = p_translation;
|
||||
}
|
||||
|
||||
Quat GLTFNode::get_rotation() {
|
||||
Quaternion GLTFNode::get_rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
void GLTFNode::set_rotation(Quat p_rotation) {
|
||||
void GLTFNode::set_rotation(Quaternion p_rotation) {
|
||||
rotation = p_rotation;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ private:
|
||||
GLTFSkeletonIndex skeleton = -1;
|
||||
bool joint = false;
|
||||
Vector3 translation;
|
||||
Quat rotation;
|
||||
Quaternion rotation;
|
||||
Vector3 scale = Vector3(1, 1, 1);
|
||||
Vector<int> children;
|
||||
GLTFLightIndex light = -1;
|
||||
@ -86,8 +86,8 @@ public:
|
||||
Vector3 get_translation();
|
||||
void set_translation(Vector3 p_translation);
|
||||
|
||||
Quat get_rotation();
|
||||
void set_rotation(Quat p_rotation);
|
||||
Quaternion get_rotation();
|
||||
void set_rotation(Quaternion p_rotation);
|
||||
|
||||
Vector3 get_scale();
|
||||
void set_scale(Vector3 p_scale);
|
||||
|
@ -60,7 +60,7 @@ void MDIGizmo::set_handle(int index, bool secondary, Camera *camera, const Point
|
||||
_drag_op_accumulator = Vector3();
|
||||
}
|
||||
|
||||
_drag_op_accumulator_quat = Quat();
|
||||
_drag_op_accumulator_quat = Quaternion();
|
||||
|
||||
_drag_op_orig_verices = copy_mdr_verts_array();
|
||||
setup_op_drag_indices();
|
||||
@ -127,8 +127,8 @@ void MDIGizmo::set_handle(int index, bool secondary, Camera *camera, const Point
|
||||
apply();
|
||||
redraw();
|
||||
} else if (edit_mode == EditMode::EDIT_MODE_ROTATE) {
|
||||
Quat yrot = Quat(Vector3(0, 1, 0), relative.x * 0.01);
|
||||
Quat xrot = Quat(camera->get_global_transform().basis.get_axis(0), relative.y * 0.01);
|
||||
Quaternion yrot = Quaternion(Vector3(0, 1, 0), relative.x * 0.01);
|
||||
Quaternion xrot = Quaternion(camera->get_global_transform().basis.get_axis(0), relative.y * 0.01);
|
||||
|
||||
_drag_op_accumulator_quat *= yrot;
|
||||
_drag_op_accumulator_quat *= xrot;
|
||||
|
@ -228,7 +228,7 @@ public:
|
||||
PoolVector3Array _drag_op_orig_verices;
|
||||
PoolIntArray _drag_op_indices;
|
||||
Vector3 _drag_op_accumulator;
|
||||
Quat _drag_op_accumulator_quat;
|
||||
Quaternion _drag_op_accumulator_quat;
|
||||
Vector3 _drag_op_pivot;
|
||||
|
||||
EditorPlugin *_editor_plugin;
|
||||
|
@ -403,8 +403,8 @@ Variant Interpolator::interpolate(const Variant &p_v1, const Variant &p_v2, real
|
||||
int(Math::round(Math::lerp(p_v1.operator Vector3i()[0], p_v2.operator Vector3i()[0], p_delta))),
|
||||
int(Math::round(Math::lerp(p_v1.operator Vector3i()[1], p_v2.operator Vector3i()[1], p_delta))),
|
||||
int(Math::round(Math::lerp(p_v1.operator Vector3i()[2], p_v2.operator Vector3i()[2], p_delta))));
|
||||
case Variant::Type::QUAT:
|
||||
return p_v1.operator Quat().slerp(p_v2.operator Quat(), p_delta);
|
||||
case Variant::Type::QUATERNION:
|
||||
return p_v1.operator Quaternion().slerp(p_v2.operator Quaternion(), p_delta);
|
||||
case Variant::Type::BASIS:
|
||||
return p_v1.operator Basis().slerp(p_v2.operator Basis(), p_delta);
|
||||
case Variant::Type::TRANSFORM:
|
||||
|
@ -1340,10 +1340,10 @@ bool SceneSynchronizer::compare(const Variant &p_first, const Variant &p_second,
|
||||
case Variant::VECTOR3: {
|
||||
return compare(Vector3(p_first), Vector3(p_second), p_tolerance);
|
||||
}
|
||||
case Variant::QUAT: {
|
||||
const Quat a = p_first;
|
||||
const Quat b = p_second;
|
||||
const Quat r(a - b); // Element wise subtraction.
|
||||
case Variant::QUATERNION: {
|
||||
const Quaternion a = p_first;
|
||||
const Quaternion b = p_second;
|
||||
const Quaternion r(a - b); // Element wise subtraction.
|
||||
return (r.x * r.x + r.y * r.y + r.z * r.z + r.w * r.w) <= (p_tolerance * p_tolerance);
|
||||
}
|
||||
case Variant::PLANE: {
|
||||
|
@ -109,7 +109,7 @@ void BoneTransformEditor::create_editors() {
|
||||
section->get_vbox()->add_child(position_property);
|
||||
|
||||
// Rotation property
|
||||
rotation_property = memnew(EditorPropertyQuat());
|
||||
rotation_property = memnew(EditorPropertyQuaternion());
|
||||
rotation_property->setup(-10000, 10000, 0.001f, true);
|
||||
rotation_property->set_label("Rotation");
|
||||
rotation_property->set_selectable(false);
|
||||
|
@ -57,7 +57,7 @@ class VSeparator;
|
||||
class EditorPropertyTransform;
|
||||
class EditorPropertyVector3;
|
||||
class EditorPropertyCheck;
|
||||
class EditorPropertyQuat;
|
||||
class EditorPropertyQuaternion;
|
||||
|
||||
class BoneTransformEditor : public VBoxContainer {
|
||||
GDCLASS(BoneTransformEditor, VBoxContainer);
|
||||
@ -66,7 +66,7 @@ class BoneTransformEditor : public VBoxContainer {
|
||||
|
||||
EditorPropertyCheck *enabled_checkbox = nullptr;
|
||||
EditorPropertyVector3 *position_property = nullptr;
|
||||
EditorPropertyQuat *rotation_property = nullptr;
|
||||
EditorPropertyQuaternion *rotation_property = nullptr;
|
||||
EditorPropertyVector3 *scale_property;
|
||||
|
||||
EditorInspectorSection *rest_section = nullptr;
|
||||
@ -191,7 +191,7 @@ class SkeletonEditor : public VBoxContainer {
|
||||
Ref<Shader> handle_shader;
|
||||
|
||||
Vector3 bone_original_position;
|
||||
Quat bone_original_rotation;
|
||||
Quaternion bone_original_rotation;
|
||||
Vector3 bone_original_scale;
|
||||
|
||||
void _update_gizmo_visible();
|
||||
@ -230,7 +230,7 @@ public:
|
||||
|
||||
void update_bone_original();
|
||||
Vector3 get_bone_original_position() const { return bone_original_position; };
|
||||
Quat get_bone_original_rotation() const { return bone_original_rotation; };
|
||||
Quaternion get_bone_original_rotation() const { return bone_original_rotation; };
|
||||
Vector3 get_bone_original_scale() const { return bone_original_scale; };
|
||||
|
||||
SkeletonEditor(EditorInspectorPluginSkeleton *e_plugin, EditorNode *p_editor, Skeleton *skeleton);
|
||||
|
@ -56,7 +56,7 @@
|
||||
<DisplayString Condition="type == Variant::RECT2">{*(Rect2 *)_data._mem}</DisplayString>
|
||||
<DisplayString Condition="type == Variant::VECTOR3">{*(Vector3 *)_data._mem}</DisplayString>
|
||||
<DisplayString Condition="type == Variant::PLANE">{*(Plane *)_data._mem}</DisplayString>
|
||||
<DisplayString Condition="type == Variant::QUAT">{*(Quat *)_data._mem}</DisplayString>
|
||||
<DisplayString Condition="type == Variant::QUATERNION">{*(Quaternion *)_data._mem}</DisplayString>
|
||||
<DisplayString Condition="type == Variant::COLOR">{*(Color *)_data._mem}</DisplayString>
|
||||
<DisplayString Condition="type == Variant::NODE_PATH">{*(NodePath *)_data._mem}</DisplayString>
|
||||
<DisplayString Condition="type == Variant::_RID">{*(RID *)_data._mem}</DisplayString>
|
||||
@ -86,7 +86,7 @@
|
||||
<Item Name="[value]" Condition="type == Variant::RECT2">*(Rect2 *)_data._mem</Item>
|
||||
<Item Name="[value]" Condition="type == Variant::VECTOR3">*(Vector3 *)_data._mem</Item>
|
||||
<Item Name="[value]" Condition="type == Variant::PLANE">*(Plane *)_data._mem</Item>
|
||||
<Item Name="[value]" Condition="type == Variant::QUAT">*(Quat *)_data._mem</Item>
|
||||
<Item Name="[value]" Condition="type == Variant::QUATERNION">*(Quaternion *)_data._mem</Item>
|
||||
<Item Name="[value]" Condition="type == Variant::COLOR">*(Color *)_data._mem</Item>
|
||||
<Item Name="[value]" Condition="type == Variant::NODE_PATH">*(NodePath *)_data._mem</Item>
|
||||
<Item Name="[value]" Condition="type == Variant::_RID">*(RID *)_data._mem</Item>
|
||||
@ -134,8 +134,8 @@
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="Quat">
|
||||
<DisplayString>Quat {{{x},{y},{z},{w}}}</DisplayString>
|
||||
<Type Name="Quaternion">
|
||||
<DisplayString>Quaternion {{{x},{y},{z},{w}}}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="x">x</Item>
|
||||
<Item Name="y">y</Item>
|
||||
|
@ -169,7 +169,7 @@ void Skeleton::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "rest"));
|
||||
p_list->push_back(PropertyInfo(Variant::BOOL, prep + "enabled"));
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR3, prep + "position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
|
||||
p_list->push_back(PropertyInfo(Variant::QUAT, prep + "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
|
||||
p_list->push_back(PropertyInfo(Variant::QUATERNION, prep + "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR3, prep + "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
|
||||
}
|
||||
|
||||
@ -754,7 +754,7 @@ void Skeleton::set_bone_pose_position(int p_bone, const Vector3 &p_position) {
|
||||
_make_dirty();
|
||||
}
|
||||
}
|
||||
void Skeleton::set_bone_pose_rotation(int p_bone, const Quat &p_rotation) {
|
||||
void Skeleton::set_bone_pose_rotation(int p_bone, const Quaternion &p_rotation) {
|
||||
const int bone_size = bones.size();
|
||||
ERR_FAIL_INDEX(p_bone, bone_size);
|
||||
|
||||
@ -790,9 +790,9 @@ Vector3 Skeleton::get_bone_pose_position(int p_bone) const {
|
||||
return bones[p_bone].pose_position;
|
||||
}
|
||||
|
||||
Quat Skeleton::get_bone_pose_rotation(int p_bone) const {
|
||||
Quaternion Skeleton::get_bone_pose_rotation(int p_bone) const {
|
||||
const int bone_size = bones.size();
|
||||
ERR_FAIL_INDEX_V(p_bone, bone_size, Quat());
|
||||
ERR_FAIL_INDEX_V(p_bone, bone_size, Quaternion());
|
||||
return bones[p_bone].pose_rotation;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ private:
|
||||
bool pose_cache_dirty;
|
||||
Transform pose_cache;
|
||||
Vector3 pose_position;
|
||||
Quat pose_rotation;
|
||||
Quaternion pose_rotation;
|
||||
Vector3 pose_scale;
|
||||
|
||||
Transform pose_global;
|
||||
@ -226,12 +226,12 @@ public:
|
||||
// posing api
|
||||
void set_bone_pose(int p_bone, const Transform &p_pose);
|
||||
void set_bone_pose_position(int p_bone, const Vector3 &p_position);
|
||||
void set_bone_pose_rotation(int p_bone, const Quat &p_rotation);
|
||||
void set_bone_pose_rotation(int p_bone, const Quaternion &p_rotation);
|
||||
void set_bone_pose_scale(int p_bone, const Vector3 &p_scale);
|
||||
|
||||
Transform get_bone_pose(int p_bone) const;
|
||||
Vector3 get_bone_pose_position(int p_bone) const;
|
||||
Quat get_bone_pose_rotation(int p_bone) const;
|
||||
Quaternion get_bone_pose_rotation(int p_bone) const;
|
||||
Vector3 get_bone_pose_scale(int p_bone) const;
|
||||
|
||||
void clear_bones_global_pose_override();
|
||||
|
@ -447,7 +447,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
|
||||
continue;
|
||||
}
|
||||
|
||||
Quat rot;
|
||||
Quaternion rot;
|
||||
|
||||
Error err = a->rotation_track_interpolate(i, p_time, &rot);
|
||||
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
|
||||
|
@ -110,11 +110,11 @@ private:
|
||||
bool rot_used;
|
||||
bool scale_used;
|
||||
Vector3 init_loc;
|
||||
Quat init_rot;
|
||||
Quaternion init_rot;
|
||||
Vector3 init_scale;
|
||||
|
||||
Vector3 loc_accum;
|
||||
Quat rot_accum;
|
||||
Quaternion rot_accum;
|
||||
Vector3 scale_accum;
|
||||
uint64_t accum_pass;
|
||||
|
||||
@ -178,7 +178,7 @@ private:
|
||||
scale_used = false;
|
||||
last_setup_pass = 0;
|
||||
init_loc = Vector3(0, 0, 0);
|
||||
init_rot = Quat(0, 0, 0, 1);
|
||||
init_rot = Quaternion(0, 0, 0, 1);
|
||||
init_scale = Vector3(1, 1, 1);
|
||||
}
|
||||
};
|
||||
|
@ -1038,7 +1038,7 @@ void AnimationTree::_process_graph(float p_delta) {
|
||||
}
|
||||
}
|
||||
|
||||
Quat rot[2];
|
||||
Quaternion rot[2];
|
||||
|
||||
if (prev_time > time) {
|
||||
Error err = a->rotation_track_interpolate(i, prev_time, &rot[0]);
|
||||
@ -1067,7 +1067,7 @@ void AnimationTree::_process_graph(float p_delta) {
|
||||
prev_time = 0;
|
||||
|
||||
} else {
|
||||
Quat rot;
|
||||
Quaternion rot;
|
||||
|
||||
Error err = a->rotation_track_interpolate(i, time, &rot);
|
||||
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
|
||||
|
@ -192,11 +192,11 @@ private:
|
||||
bool rot_used;
|
||||
bool scale_used;
|
||||
Vector3 init_loc;
|
||||
Quat ref_rot;
|
||||
Quat init_rot;
|
||||
Quaternion ref_rot;
|
||||
Quaternion init_rot;
|
||||
Vector3 init_scale;
|
||||
Vector3 loc;
|
||||
Quat rot;
|
||||
Quaternion rot;
|
||||
Vector3 scale;
|
||||
|
||||
TrackCacheTransform() {
|
||||
@ -208,8 +208,8 @@ private:
|
||||
rot_used = false;
|
||||
scale_used = false;
|
||||
init_loc = Vector3(0, 0, 0);
|
||||
ref_rot = Quat(0, 0, 0, 1);
|
||||
init_rot = Quat(0, 0, 0, 0);
|
||||
ref_rot = Quaternion(0, 0, 0, 1);
|
||||
init_rot = Quaternion(0, 0, 0, 0);
|
||||
init_scale = Vector3(1, 1, 1);
|
||||
}
|
||||
};
|
||||
|
@ -419,10 +419,10 @@ Variant SceneTreeTween::interpolate_variant(Variant p_initial_val, Variant p_del
|
||||
return r;
|
||||
}
|
||||
|
||||
case Variant::QUAT: {
|
||||
Quat i = p_initial_val;
|
||||
Quat d = p_delta_val;
|
||||
Quat r;
|
||||
case Variant::QUATERNION: {
|
||||
Quaternion i = p_initial_val;
|
||||
Quaternion d = p_delta_val;
|
||||
Quaternion r;
|
||||
|
||||
APPLY_EQUATION(x);
|
||||
APPLY_EQUATION(y);
|
||||
|
@ -547,11 +547,11 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
|
||||
result = r;
|
||||
} break;
|
||||
|
||||
case Variant::QUAT: {
|
||||
case Variant::QUATERNION: {
|
||||
// Get the quaternian for the initial and delta values
|
||||
Quat i = initial_val;
|
||||
Quat d = delta_val;
|
||||
Quat r;
|
||||
Quaternion i = initial_val;
|
||||
Quaternion d = delta_val;
|
||||
Quaternion r;
|
||||
|
||||
// Execute the equation on the quaternian values and mutate the r quaternian
|
||||
// This uses the custom APPLY_EQUATION macro defined above
|
||||
@ -1258,9 +1258,9 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
|
||||
delta_val = d;
|
||||
} break;
|
||||
|
||||
case Variant::QUAT:
|
||||
case Variant::QUATERNION:
|
||||
// Convert to quaternianls and find the delta
|
||||
delta_val = final_val.operator Quat() - initial_val.operator Quat();
|
||||
delta_val = final_val.operator Quaternion() - initial_val.operator Quaternion();
|
||||
break;
|
||||
|
||||
case Variant::AABB: {
|
||||
@ -1322,7 +1322,7 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
|
||||
Variant::RECT2,
|
||||
Variant::VECTOR3,
|
||||
Variant::TRANSFORM2D,
|
||||
Variant::QUAT,
|
||||
Variant::QUATERNION,
|
||||
Variant::AABB,
|
||||
Variant::BASIS,
|
||||
Variant::TRANSFORM,
|
||||
|
@ -112,9 +112,9 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
|
||||
int64_t count = vcount / 6;
|
||||
rt->rotations.resize(count);
|
||||
|
||||
TKey<Quat> *rw = rt->rotations.ptrw();
|
||||
TKey<Quaternion> *rw = rt->rotations.ptrw();
|
||||
for (int i = 0; i < count; i++) {
|
||||
TKey<Quat> &rk = rw[i];
|
||||
TKey<Quaternion> &rk = rw[i];
|
||||
const real_t *ofs = &r[i * 6];
|
||||
rk.time = ofs[0];
|
||||
rk.transition = ofs[1];
|
||||
@ -429,7 +429,7 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
|
||||
int idx = 0;
|
||||
for (int i = 0; i < track_get_key_count(track); i++) {
|
||||
Quat rot;
|
||||
Quaternion rot;
|
||||
rotation_track_get_key(track, i, &rot);
|
||||
|
||||
w[idx++] = track_get_key_time(track, i);
|
||||
@ -936,7 +936,7 @@ Error Animation::position_track_interpolate(int p_track, double p_time, Vector3
|
||||
|
||||
////
|
||||
|
||||
int Animation::rotation_track_insert_key(int p_track, double p_time, const Quat &p_rotation) {
|
||||
int Animation::rotation_track_insert_key(int p_track, double p_time, const Quaternion &p_rotation) {
|
||||
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
|
||||
Track *t = tracks[p_track];
|
||||
ERR_FAIL_COND_V(t->type != TYPE_ROTATION_3D, -1);
|
||||
@ -945,7 +945,7 @@ int Animation::rotation_track_insert_key(int p_track, double p_time, const Quat
|
||||
|
||||
//ERR_FAIL_COND_V(rt->compressed_track >= 0, -1);
|
||||
|
||||
TKey<Quat> tkey;
|
||||
TKey<Quaternion> tkey;
|
||||
tkey.time = p_time;
|
||||
tkey.value = p_rotation;
|
||||
|
||||
@ -954,7 +954,7 @@ int Animation::rotation_track_insert_key(int p_track, double p_time, const Quat
|
||||
return ret;
|
||||
}
|
||||
|
||||
Error Animation::rotation_track_get_key(int p_track, int p_key, Quat *r_rotation) const {
|
||||
Error Animation::rotation_track_get_key(int p_track, int p_key, Quaternion *r_rotation) const {
|
||||
ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
|
||||
Track *t = tracks[p_track];
|
||||
|
||||
@ -982,7 +982,7 @@ Error Animation::rotation_track_get_key(int p_track, int p_key, Quat *r_rotation
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error Animation::rotation_track_interpolate(int p_track, double p_time, Quat *r_interpolation) const {
|
||||
Error Animation::rotation_track_interpolate(int p_track, double p_time, Quaternion *r_interpolation) const {
|
||||
ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
|
||||
Track *t = tracks[p_track];
|
||||
ERR_FAIL_COND_V(t->type != TYPE_ROTATION_3D, ERR_INVALID_PARAMETER);
|
||||
@ -1001,7 +1001,7 @@ Error Animation::rotation_track_interpolate(int p_track, double p_time, Quat *r_
|
||||
|
||||
bool ok = false;
|
||||
|
||||
Quat tk = _interpolate(rt->rotations, p_time, rt->interpolation, rt->loop_wrap, &ok);
|
||||
Quaternion tk = _interpolate(rt->rotations, p_time, rt->interpolation, rt->loop_wrap, &ok);
|
||||
|
||||
if (!ok) {
|
||||
return ERR_UNAVAILABLE;
|
||||
@ -1328,7 +1328,7 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key
|
||||
|
||||
} break;
|
||||
case TYPE_ROTATION_3D: {
|
||||
ERR_FAIL_COND((p_key.get_type() != Variant::QUAT) && (p_key.get_type() != Variant::BASIS));
|
||||
ERR_FAIL_COND((p_key.get_type() != Variant::QUATERNION) && (p_key.get_type() != Variant::BASIS));
|
||||
int idx = rotation_track_insert_key(p_track, p_time, p_key);
|
||||
track_set_key_transition(p_track, idx, p_transition);
|
||||
|
||||
@ -1478,7 +1478,7 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
|
||||
return value;
|
||||
} break;
|
||||
case TYPE_ROTATION_3D: {
|
||||
Quat value;
|
||||
Quaternion value;
|
||||
rotation_track_get_key(p_track, p_key_idx, &value);
|
||||
return value;
|
||||
} break;
|
||||
@ -1646,7 +1646,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, float p_time) {
|
||||
RotationTrack *tt = static_cast<RotationTrack *>(t);
|
||||
//ERR_FAIL_COND(tt->compressed_track >= 0);
|
||||
ERR_FAIL_INDEX(p_key_idx, tt->rotations.size());
|
||||
TKey<Quat> key = tt->rotations[p_key_idx];
|
||||
TKey<Quaternion> key = tt->rotations[p_key_idx];
|
||||
key.time = p_time;
|
||||
tt->rotations.remove(p_key_idx);
|
||||
_insert(p_time, tt->rotations, key);
|
||||
@ -1794,7 +1794,7 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p
|
||||
|
||||
} break;
|
||||
case TYPE_ROTATION_3D: {
|
||||
ERR_FAIL_COND((p_value.get_type() != Variant::QUAT) && (p_value.get_type() != Variant::BASIS));
|
||||
ERR_FAIL_COND((p_value.get_type() != Variant::QUATERNION) && (p_value.get_type() != Variant::BASIS));
|
||||
RotationTrack *rt = static_cast<RotationTrack *>(t);
|
||||
//ERR_FAIL_COND(rt->compressed_track >= 0);
|
||||
ERR_FAIL_INDEX(p_key_idx, rt->rotations.size());
|
||||
@ -1957,7 +1957,7 @@ int Animation::_find(const Vector<K> &p_keys, float p_time) const {
|
||||
Vector3 Animation::_interpolate(const Vector3 &p_a, const Vector3 &p_b, float p_c) const {
|
||||
return p_a.linear_interpolate(p_b, p_c);
|
||||
}
|
||||
Quat Animation::_interpolate(const Quat &p_a, const Quat &p_b, float p_c) const {
|
||||
Quaternion Animation::_interpolate(const Quaternion &p_a, const Quaternion &p_b, float p_c) const {
|
||||
return p_a.slerp(p_b, p_c);
|
||||
}
|
||||
Variant Animation::_interpolate(const Variant &p_a, const Variant &p_b, float p_c) const {
|
||||
@ -1973,7 +1973,7 @@ float Animation::_interpolate(const float &p_a, const float &p_b, float p_c) con
|
||||
Vector3 Animation::_cubic_interpolate(const Vector3 &p_pre_a, const Vector3 &p_a, const Vector3 &p_b, const Vector3 &p_post_b, float p_c) const {
|
||||
return p_a.cubic_interpolate(p_b, p_pre_a, p_post_b, p_c);
|
||||
}
|
||||
Quat Animation::_cubic_interpolate(const Quat &p_pre_a, const Quat &p_a, const Quat &p_b, const Quat &p_post_b, float p_c) const {
|
||||
Quaternion Animation::_cubic_interpolate(const Quaternion &p_pre_a, const Quaternion &p_a, const Quaternion &p_b, const Quaternion &p_post_b, float p_c) const {
|
||||
return p_a.cubic_slerp(p_b, p_pre_a, p_post_b, p_c);
|
||||
}
|
||||
Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, float p_c) const {
|
||||
@ -2038,11 +2038,11 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
|
||||
|
||||
return a.cubic_interpolate(b, pa, pb, p_c);
|
||||
}
|
||||
case Variant::QUAT: {
|
||||
Quat a = p_a;
|
||||
Quat b = p_b;
|
||||
Quat pa = p_pre_a;
|
||||
Quat pb = p_post_b;
|
||||
case Variant::QUATERNION: {
|
||||
Quaternion a = p_a;
|
||||
Quaternion b = p_b;
|
||||
Quaternion pa = p_pre_a;
|
||||
Quaternion pb = p_post_b;
|
||||
|
||||
return a.cubic_slerp(b, pa, pb, p_c);
|
||||
}
|
||||
@ -3230,10 +3230,10 @@ bool Animation::_position_track_optimize_key(const TKey<Vector3> &t0, const TKey
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Animation::_rotation_track_optimize_key(const TKey<Quat> &t0, const TKey<Quat> &t1, const TKey<Quat> &t2, real_t p_allowed_angular_error, float p_max_optimizable_angle) {
|
||||
const Quat &q0 = t0.value;
|
||||
const Quat &q1 = t1.value;
|
||||
const Quat &q2 = t2.value;
|
||||
bool Animation::_rotation_track_optimize_key(const TKey<Quaternion> &t0, const TKey<Quaternion> &t1, const TKey<Quaternion> &t2, real_t p_allowed_angular_error, float p_max_optimizable_angle) {
|
||||
const Quaternion &q0 = t0.value;
|
||||
const Quaternion &q1 = t1.value;
|
||||
const Quaternion &q2 = t2.value;
|
||||
|
||||
//localize both to rotation from q0
|
||||
|
||||
@ -3243,8 +3243,8 @@ bool Animation::_rotation_track_optimize_key(const TKey<Quat> &t0, const TKey<Qu
|
||||
}
|
||||
|
||||
} else {
|
||||
Quat r02 = (q0.inverse() * q2).normalized();
|
||||
Quat r01 = (q0.inverse() * q1).normalized();
|
||||
Quaternion r02 = (q0.inverse() * q2).normalized();
|
||||
Quaternion r01 = (q0.inverse() * q1).normalized();
|
||||
|
||||
Vector3 v02, v01;
|
||||
real_t a02, a01;
|
||||
@ -3359,12 +3359,12 @@ void Animation::_rotation_track_optimize(int p_idx, real_t p_allowed_angular_err
|
||||
ERR_FAIL_COND(tracks[p_idx]->type != TYPE_ROTATION_3D);
|
||||
RotationTrack *tt = static_cast<RotationTrack *>(tracks[p_idx]);
|
||||
bool prev_erased = false;
|
||||
TKey<Quat> first_erased;
|
||||
TKey<Quaternion> first_erased;
|
||||
|
||||
for (int i = 1; i < tt->rotations.size() - 1; i++) {
|
||||
TKey<Quat> &t0 = tt->rotations.write[i - 1];
|
||||
TKey<Quat> &t1 = tt->rotations.write[i];
|
||||
TKey<Quat> &t2 = tt->rotations.write[i + 1];
|
||||
TKey<Quaternion> &t0 = tt->rotations.write[i - 1];
|
||||
TKey<Quaternion> &t1 = tt->rotations.write[i];
|
||||
TKey<Quaternion> &t2 = tt->rotations.write[i + 1];
|
||||
|
||||
bool erase = _rotation_track_optimize_key(t0, t1, t2, p_allowed_angular_err, p_max_optimizable_angle);
|
||||
|
||||
|
@ -87,7 +87,7 @@ private:
|
||||
Key() { transition = 1; }
|
||||
};
|
||||
|
||||
// transform key holds either Vector3 or Quaternion
|
||||
// transform key holds either Vector3 or Quaternionernion
|
||||
template <class T>
|
||||
struct TKey : public Key {
|
||||
T value;
|
||||
@ -95,7 +95,7 @@ private:
|
||||
|
||||
struct TransformKey {
|
||||
Vector3 loc;
|
||||
Quat rot;
|
||||
Quaternion rot;
|
||||
Vector3 scale;
|
||||
};
|
||||
|
||||
@ -110,7 +110,7 @@ private:
|
||||
/* ROTATION TRACK */
|
||||
|
||||
struct RotationTrack : public Track {
|
||||
Vector<TKey<Quat>> rotations;
|
||||
Vector<TKey<Quaternion>> rotations;
|
||||
//int32_t compressed_track = -1;
|
||||
RotationTrack() { type = TYPE_ROTATION_3D; }
|
||||
};
|
||||
@ -210,12 +210,12 @@ private:
|
||||
inline int _find(const Vector<K> &p_keys, float p_time) const;
|
||||
|
||||
_FORCE_INLINE_ Vector3 _interpolate(const Vector3 &p_a, const Vector3 &p_b, float p_c) const;
|
||||
_FORCE_INLINE_ Quat _interpolate(const Quat &p_a, const Quat &p_b, float p_c) const;
|
||||
_FORCE_INLINE_ Quaternion _interpolate(const Quaternion &p_a, const Quaternion &p_b, float p_c) const;
|
||||
_FORCE_INLINE_ Variant _interpolate(const Variant &p_a, const Variant &p_b, float p_c) const;
|
||||
_FORCE_INLINE_ float _interpolate(const float &p_a, const float &p_b, float p_c) const;
|
||||
|
||||
_FORCE_INLINE_ Vector3 _cubic_interpolate(const Vector3 &p_pre_a, const Vector3 &p_a, const Vector3 &p_b, const Vector3 &p_post_b, float p_c) const;
|
||||
_FORCE_INLINE_ Quat _cubic_interpolate(const Quat &p_pre_a, const Quat &p_a, const Quat &p_b, const Quat &p_post_b, float p_c) const;
|
||||
_FORCE_INLINE_ Quaternion _cubic_interpolate(const Quaternion &p_pre_a, const Quaternion &p_a, const Quaternion &p_b, const Quaternion &p_post_b, float p_c) const;
|
||||
_FORCE_INLINE_ Variant _cubic_interpolate(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, float p_c) const;
|
||||
_FORCE_INLINE_ float _cubic_interpolate(const float &p_pre_a, const float &p_a, const float &p_b, const float &p_post_b, float p_c) const;
|
||||
|
||||
@ -257,7 +257,7 @@ private:
|
||||
}
|
||||
|
||||
bool _position_track_optimize_key(const TKey<Vector3> &t0, const TKey<Vector3> &t1, const TKey<Vector3> &t2, real_t p_alowed_linear_err, real_t p_allowed_angular_error, const Vector3 &p_norm);
|
||||
bool _rotation_track_optimize_key(const TKey<Quat> &t0, const TKey<Quat> &t1, const TKey<Quat> &t2, real_t p_allowed_angular_error, float p_max_optimizable_angle);
|
||||
bool _rotation_track_optimize_key(const TKey<Quaternion> &t0, const TKey<Quaternion> &t1, const TKey<Quaternion> &t2, real_t p_allowed_angular_error, float p_max_optimizable_angle);
|
||||
bool _scale_track_optimize_key(const TKey<Vector3> &t0, const TKey<Vector3> &t1, const TKey<Vector3> &t2, real_t p_allowed_linear_error);
|
||||
|
||||
void _position_track_optimize(int p_idx, real_t p_allowed_linear_err, real_t p_allowed_angular_err);
|
||||
@ -309,9 +309,9 @@ public:
|
||||
Error position_track_get_key(int p_track, int p_key, Vector3 *r_position) const;
|
||||
Error position_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const;
|
||||
|
||||
int rotation_track_insert_key(int p_track, double p_time, const Quat &p_rotation);
|
||||
Error rotation_track_get_key(int p_track, int p_key, Quat *r_rotation) const;
|
||||
Error rotation_track_interpolate(int p_track, double p_time, Quat *r_interpolation) const;
|
||||
int rotation_track_insert_key(int p_track, double p_time, const Quaternion &p_rotation);
|
||||
Error rotation_track_get_key(int p_track, int p_key, Quaternion *r_rotation) const;
|
||||
Error rotation_track_interpolate(int p_track, double p_time, Quaternion *r_interpolation) const;
|
||||
|
||||
int scale_track_insert_key(int p_track, double p_time, const Vector3 &p_scale);
|
||||
Error scale_track_get_key(int p_track, int p_key, Vector3 *r_scale) const;
|
||||
|
@ -258,9 +258,9 @@ void SkeletonModification3DTwoBoneIK::_execute(real_t p_delta) {
|
||||
Vector3 axis_1 = bone_one_trans.origin.direction_to(bone_two_tip_trans.origin).cross(bone_one_trans.origin.direction_to(target_trans.origin));
|
||||
|
||||
// Make a quaternion with the delta rotation needed to rotate the first joint into alignment and apply it to the transform.
|
||||
Quaternion bone_one_quat = bone_one_trans.basis.get_rotation_quaternion();
|
||||
Quaternion rot_0 = Quaternion(bone_one_quat.inverse().xform(axis_0).normalized(), (ac_ab_1 - ac_ab_0));
|
||||
Quaternion rot_2 = Quaternion(bone_one_quat.inverse().xform(axis_1).normalized(), ac_at_0);
|
||||
Quaternionernion bone_one_quat = bone_one_trans.basis.get_rotation_quaternion();
|
||||
Quaternionernion rot_0 = Quaternionernion(bone_one_quat.inverse().xform(axis_0).normalized(), (ac_ab_1 - ac_ab_0));
|
||||
Quaternionernion rot_2 = Quaternionernion(bone_one_quat.inverse().xform(axis_1).normalized(), ac_at_0);
|
||||
bone_one_trans.basis.set_quaternion(bone_one_quat * (rot_0 * rot_2));
|
||||
|
||||
stack->skeleton->update_bone_rest_forward_vector(joint_one_bone_idx);
|
||||
@ -290,8 +290,8 @@ void SkeletonModification3DTwoBoneIK::_execute(real_t p_delta) {
|
||||
// alignment, and then apply it to the second joint.
|
||||
real_t ba_bc_0 = Math::acos(CLAMP(bone_two_trans.origin.direction_to(bone_one_trans.origin).dot(bone_two_trans.origin.direction_to(bone_two_tip_trans.origin)), -1, 1));
|
||||
real_t ba_bc_1 = Math::acos(CLAMP((sqr_three_length - sqr_one_length - sqr_two_length) / (-2.0 * joint_one_length * joint_two_length), -1, 1));
|
||||
Quaternion bone_two_quat = bone_two_trans.basis.get_rotation_quaternion();
|
||||
Quaternion rot_1 = Quaternion(bone_two_quat.inverse().xform(axis_0).normalized(), (ba_bc_1 - ba_bc_0));
|
||||
Quaternionernion bone_two_quat = bone_two_trans.basis.get_rotation_quaternion();
|
||||
Quaternionernion rot_1 = Quaternionernion(bone_two_quat.inverse().xform(axis_0).normalized(), (ba_bc_1 - ba_bc_0));
|
||||
bone_two_trans.basis.set_quaternion(bone_two_quat * rot_1);
|
||||
|
||||
stack->skeleton->update_bone_rest_forward_vector(joint_two_bone_idx);
|
||||
|
@ -209,7 +209,7 @@ bool ConeTwistJointSW::setup(real_t p_timestep) {
|
||||
// Twist limits
|
||||
if (m_twistSpan >= real_t(0.)) {
|
||||
Vector3 b2Axis22 = B->get_transform().basis.xform(this->m_rbBFrame.basis.get_axis(1));
|
||||
Quat rotationArc = Quat(b2Axis1, b1Axis1);
|
||||
Quaternion rotationArc = Quaternion(b2Axis1, b1Axis1);
|
||||
Vector3 TwistRef = rotationArc.xform(b2Axis22);
|
||||
real_t twist = atan2fast(TwistRef.dot(b1Axis3), TwistRef.dot(b1Axis2));
|
||||
|
||||
|
@ -126,7 +126,7 @@ HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Vector3 &pivotInA, co
|
||||
rbAxisA1.y, rbAxisA2.y, axisInA.y,
|
||||
rbAxisA1.z, rbAxisA2.z, axisInA.z);
|
||||
|
||||
Quat rotationArc = Quat(axisInA, axisInB);
|
||||
Quaternion rotationArc = Quaternion(axisInA, axisInB);
|
||||
Vector3 rbAxisB1 = rotationArc.xform(rbAxisA1);
|
||||
Vector3 rbAxisB2 = axisInB.cross(rbAxisB1);
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "core/local_vector.h"
|
||||
#include "core/math/aabb.h"
|
||||
#include "core/math/plane.h"
|
||||
#include "core/math/quat.h"
|
||||
#include "core/math/quaternion.h"
|
||||
#include "core/math/transform.h"
|
||||
#include "core/math/vector3.h"
|
||||
#include "core/object_id.h"
|
||||
|
Loading…
Reference in New Issue
Block a user