Improve some argument names for core types
(cherry picked from commit 4d7f642fb3
)
This commit is contained in:
parent
bceaef6500
commit
9201ffa9a2
10
core/color.h
10
core/color.h
|
@ -93,14 +93,14 @@ struct Color {
|
||||||
Color inverted() const;
|
Color inverted() const;
|
||||||
Color contrasted() const;
|
Color contrasted() const;
|
||||||
|
|
||||||
_FORCE_INLINE_ Color linear_interpolate(const Color &p_b, float p_t) const {
|
_FORCE_INLINE_ Color linear_interpolate(const Color &p_to, float p_weight) const {
|
||||||
|
|
||||||
Color res = *this;
|
Color res = *this;
|
||||||
|
|
||||||
res.r += (p_t * (p_b.r - r));
|
res.r += (p_weight * (p_to.r - r));
|
||||||
res.g += (p_t * (p_b.g - g));
|
res.g += (p_weight * (p_to.g - g));
|
||||||
res.b += (p_t * (p_b.b - b));
|
res.b += (p_weight * (p_to.b - b));
|
||||||
res.a += (p_t * (p_b.a - a));
|
res.a += (p_weight * (p_to.a - a));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1033,16 +1033,16 @@ void Basis::set_diagonal(const Vector3 &p_diag) {
|
||||||
elements[2][2] = p_diag.z;
|
elements[2][2] = p_diag.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
Basis Basis::slerp(const Basis &target, const real_t &t) const {
|
Basis Basis::slerp(const Basis &p_to, const real_t &p_weight) const {
|
||||||
|
|
||||||
//consider scale
|
//consider scale
|
||||||
Quat from(*this);
|
Quat from(*this);
|
||||||
Quat to(target);
|
Quat to(p_to);
|
||||||
|
|
||||||
Basis b(from.slerp(to, t));
|
Basis b(from.slerp(to, p_weight));
|
||||||
b.elements[0] *= Math::lerp(elements[0].length(), target.elements[0].length(), t);
|
b.elements[0] *= Math::lerp(elements[0].length(), p_to.elements[0].length(), p_weight);
|
||||||
b.elements[1] *= Math::lerp(elements[1].length(), target.elements[1].length(), t);
|
b.elements[1] *= Math::lerp(elements[1].length(), p_to.elements[1].length(), p_weight);
|
||||||
b.elements[2] *= Math::lerp(elements[2].length(), target.elements[2].length(), t);
|
b.elements[2] *= Math::lerp(elements[2].length(), p_to.elements[2].length(), p_weight);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ public:
|
||||||
bool is_diagonal() const;
|
bool is_diagonal() const;
|
||||||
bool is_rotation() const;
|
bool is_rotation() const;
|
||||||
|
|
||||||
Basis slerp(const Basis &target, const real_t &t) const;
|
Basis slerp(const Basis &p_to, const real_t &p_weight) const;
|
||||||
|
|
||||||
operator String() const;
|
operator String() const;
|
||||||
|
|
||||||
|
|
|
@ -106,18 +106,18 @@ Vector3 Quat::get_euler_yxz() const {
|
||||||
return m.get_euler_yxz();
|
return m.get_euler_yxz();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quat::operator*=(const Quat &q) {
|
void Quat::operator*=(const Quat &p_q) {
|
||||||
|
|
||||||
set(w * q.x + x * q.w + y * q.z - z * q.y,
|
set(w * p_q.x + x * p_q.w + y * p_q.z - z * p_q.y,
|
||||||
w * q.y + y * q.w + z * q.x - x * q.z,
|
w * p_q.y + y * p_q.w + z * p_q.x - x * p_q.z,
|
||||||
w * q.z + z * q.w + x * q.y - y * q.x,
|
w * p_q.z + z * p_q.w + x * p_q.y - y * p_q.x,
|
||||||
w * q.w - x * q.x - y * q.y - z * q.z);
|
w * p_q.w - x * p_q.x - y * p_q.y - z * p_q.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quat Quat::operator*(const Quat &q) const {
|
Quat Quat::operator*(const Quat &p_q) const {
|
||||||
|
|
||||||
Quat r = *this;
|
Quat r = *this;
|
||||||
r *= q;
|
r *= p_q;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,29 +150,29 @@ Quat Quat::inverse() const {
|
||||||
return Quat(-x, -y, -z, w);
|
return Quat(-x, -y, -z, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quat Quat::slerp(const Quat &q, const real_t &t) const {
|
Quat Quat::slerp(const Quat &p_to, const real_t &p_weight) const {
|
||||||
#ifdef MATH_CHECKS
|
#ifdef MATH_CHECKS
|
||||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
|
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
|
||||||
ERR_FAIL_COND_V_MSG(!q.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
||||||
#endif
|
#endif
|
||||||
Quat to1;
|
Quat to1;
|
||||||
real_t omega, cosom, sinom, scale0, scale1;
|
real_t omega, cosom, sinom, scale0, scale1;
|
||||||
|
|
||||||
// calc cosine
|
// calc cosine
|
||||||
cosom = dot(q);
|
cosom = dot(p_to);
|
||||||
|
|
||||||
// adjust signs (if necessary)
|
// adjust signs (if necessary)
|
||||||
if (cosom < 0.0) {
|
if (cosom < 0.0) {
|
||||||
cosom = -cosom;
|
cosom = -cosom;
|
||||||
to1.x = -q.x;
|
to1.x = -p_to.x;
|
||||||
to1.y = -q.y;
|
to1.y = -p_to.y;
|
||||||
to1.z = -q.z;
|
to1.z = -p_to.z;
|
||||||
to1.w = -q.w;
|
to1.w = -p_to.w;
|
||||||
} else {
|
} else {
|
||||||
to1.x = q.x;
|
to1.x = p_to.x;
|
||||||
to1.y = q.y;
|
to1.y = p_to.y;
|
||||||
to1.z = q.z;
|
to1.z = p_to.z;
|
||||||
to1.w = q.w;
|
to1.w = p_to.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate coefficients
|
// calculate coefficients
|
||||||
|
@ -181,13 +181,13 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const {
|
||||||
// standard case (slerp)
|
// standard case (slerp)
|
||||||
omega = Math::acos(cosom);
|
omega = Math::acos(cosom);
|
||||||
sinom = Math::sin(omega);
|
sinom = Math::sin(omega);
|
||||||
scale0 = Math::sin((1.0 - t) * omega) / sinom;
|
scale0 = Math::sin((1.0 - p_weight) * omega) / sinom;
|
||||||
scale1 = Math::sin(t * omega) / sinom;
|
scale1 = Math::sin(p_weight * omega) / sinom;
|
||||||
} else {
|
} else {
|
||||||
// "from" and "to" quaternions are very close
|
// "from" and "to" quaternions are very close
|
||||||
// ... so we can do a linear interpolation
|
// ... so we can do a linear interpolation
|
||||||
scale0 = 1.0 - t;
|
scale0 = 1.0 - p_weight;
|
||||||
scale1 = t;
|
scale1 = p_weight;
|
||||||
}
|
}
|
||||||
// calculate final values
|
// calculate final values
|
||||||
return Quat(
|
return Quat(
|
||||||
|
@ -197,37 +197,37 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const {
|
||||||
scale0 * w + scale1 * to1.w);
|
scale0 * w + scale1 * to1.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quat Quat::slerpni(const Quat &q, const real_t &t) const {
|
Quat Quat::slerpni(const Quat &p_to, const real_t &p_weight) const {
|
||||||
#ifdef MATH_CHECKS
|
#ifdef MATH_CHECKS
|
||||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
|
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
|
||||||
ERR_FAIL_COND_V_MSG(!q.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
||||||
#endif
|
#endif
|
||||||
const Quat &from = *this;
|
const Quat &from = *this;
|
||||||
|
|
||||||
real_t dot = from.dot(q);
|
real_t dot = from.dot(p_to);
|
||||||
|
|
||||||
if (Math::absf(dot) > 0.9999) return from;
|
if (Math::absf(dot) > 0.9999) return from;
|
||||||
|
|
||||||
real_t theta = Math::acos(dot),
|
real_t theta = Math::acos(dot),
|
||||||
sinT = 1.0 / Math::sin(theta),
|
sinT = 1.0 / Math::sin(theta),
|
||||||
newFactor = Math::sin(t * theta) * sinT,
|
newFactor = Math::sin(p_weight * theta) * sinT,
|
||||||
invFactor = Math::sin((1.0 - t) * theta) * sinT;
|
invFactor = Math::sin((1.0 - p_weight) * theta) * sinT;
|
||||||
|
|
||||||
return Quat(invFactor * from.x + newFactor * q.x,
|
return Quat(invFactor * from.x + newFactor * p_to.x,
|
||||||
invFactor * from.y + newFactor * q.y,
|
invFactor * from.y + newFactor * p_to.y,
|
||||||
invFactor * from.z + newFactor * q.z,
|
invFactor * from.z + newFactor * p_to.z,
|
||||||
invFactor * from.w + newFactor * q.w);
|
invFactor * from.w + newFactor * p_to.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quat Quat::cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const {
|
Quat Quat::cubic_slerp(const Quat &p_b, const Quat &p_pre_a, const Quat &p_post_b, const real_t &p_weight) const {
|
||||||
#ifdef MATH_CHECKS
|
#ifdef MATH_CHECKS
|
||||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
|
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
|
||||||
ERR_FAIL_COND_V_MSG(!q.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
ERR_FAIL_COND_V_MSG(!p_b.is_normalized(), Quat(), "The end quaternion must be normalized.");
|
||||||
#endif
|
#endif
|
||||||
//the only way to do slerp :|
|
//the only way to do slerp :|
|
||||||
real_t t2 = (1.0 - t) * t * 2;
|
real_t t2 = (1.0 - p_weight) * p_weight * 2;
|
||||||
Quat sp = this->slerp(q, t);
|
Quat sp = this->slerp(p_b, p_weight);
|
||||||
Quat sq = prep.slerpni(postq, t);
|
Quat sq = p_pre_a.slerpni(p_post_b, p_weight);
|
||||||
return sp.slerpni(sq, t2);
|
return sp.slerpni(sq, t2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
Quat normalized() const;
|
Quat normalized() const;
|
||||||
bool is_normalized() const;
|
bool is_normalized() const;
|
||||||
Quat inverse() const;
|
Quat inverse() const;
|
||||||
_FORCE_INLINE_ real_t dot(const Quat &q) const;
|
_FORCE_INLINE_ real_t dot(const Quat &p_q) const;
|
||||||
|
|
||||||
void set_euler_xyz(const Vector3 &p_euler);
|
void set_euler_xyz(const Vector3 &p_euler);
|
||||||
Vector3 get_euler_xyz() const;
|
Vector3 get_euler_xyz() const;
|
||||||
|
@ -59,9 +59,9 @@ public:
|
||||||
void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); };
|
void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); };
|
||||||
Vector3 get_euler() const { return get_euler_yxz(); };
|
Vector3 get_euler() const { return get_euler_yxz(); };
|
||||||
|
|
||||||
Quat slerp(const Quat &q, const real_t &t) const;
|
Quat slerp(const Quat &p_to, const real_t &p_weight) const;
|
||||||
Quat slerpni(const Quat &q, const real_t &t) const;
|
Quat slerpni(const Quat &p_to, const real_t &p_weight) const;
|
||||||
Quat cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const;
|
Quat cubic_slerp(const Quat &p_b, const Quat &p_pre_a, const Quat &p_post_b, const real_t &p_weight) const;
|
||||||
|
|
||||||
void set_axis_angle(const Vector3 &axis, const real_t &angle);
|
void set_axis_angle(const Vector3 &axis, const real_t &angle);
|
||||||
_FORCE_INLINE_ void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
_FORCE_INLINE_ void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
|
||||||
|
@ -72,8 +72,8 @@ public:
|
||||||
r_axis.z = z * r;
|
r_axis.z = z * r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator*=(const Quat &q);
|
void operator*=(const Quat &p_q);
|
||||||
Quat operator*(const Quat &q) const;
|
Quat operator*(const Quat &p_q) const;
|
||||||
|
|
||||||
Quat operator*(const Vector3 &v) const {
|
Quat operator*(const Vector3 &v) const {
|
||||||
return Quat(w * v.x + y * v.z - z * v.y,
|
return Quat(w * v.x + y * v.z - z * v.y,
|
||||||
|
@ -91,8 +91,8 @@ public:
|
||||||
return v + ((uv * w) + u.cross(uv)) * ((real_t)2);
|
return v + ((uv * w) + u.cross(uv)) * ((real_t)2);
|
||||||
}
|
}
|
||||||
|
|
||||||
_FORCE_INLINE_ void operator+=(const Quat &q);
|
_FORCE_INLINE_ void operator+=(const Quat &p_q);
|
||||||
_FORCE_INLINE_ void operator-=(const Quat &q);
|
_FORCE_INLINE_ void operator-=(const Quat &p_q);
|
||||||
_FORCE_INLINE_ void operator*=(const real_t &s);
|
_FORCE_INLINE_ void operator*=(const real_t &s);
|
||||||
_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;
|
||||||
|
@ -121,18 +121,18 @@ public:
|
||||||
Quat(const Vector3 &axis, const real_t &angle) { set_axis_angle(axis, angle); }
|
Quat(const Vector3 &axis, const real_t &angle) { set_axis_angle(axis, angle); }
|
||||||
|
|
||||||
Quat(const Vector3 &euler) { set_euler(euler); }
|
Quat(const Vector3 &euler) { set_euler(euler); }
|
||||||
Quat(const Quat &q) :
|
Quat(const Quat &p_q) :
|
||||||
x(q.x),
|
x(p_q.x),
|
||||||
y(q.y),
|
y(p_q.y),
|
||||||
z(q.z),
|
z(p_q.z),
|
||||||
w(q.w) {
|
w(p_q.w) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Quat operator=(const Quat &q) {
|
Quat operator=(const Quat &p_q) {
|
||||||
x = q.x;
|
x = p_q.x;
|
||||||
y = q.y;
|
y = p_q.y;
|
||||||
z = q.z;
|
z = p_q.z;
|
||||||
w = q.w;
|
w = p_q.w;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,26 +166,26 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
real_t Quat::dot(const Quat &q) const {
|
real_t Quat::dot(const Quat &p_q) const {
|
||||||
return x * q.x + y * q.y + z * q.z + w * q.w;
|
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 Quat::length_squared() const {
|
||||||
return dot(*this);
|
return dot(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quat::operator+=(const Quat &q) {
|
void Quat::operator+=(const Quat &p_q) {
|
||||||
x += q.x;
|
x += p_q.x;
|
||||||
y += q.y;
|
y += p_q.y;
|
||||||
z += q.z;
|
z += p_q.z;
|
||||||
w += q.w;
|
w += p_q.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quat::operator-=(const Quat &q) {
|
void Quat::operator-=(const Quat &p_q) {
|
||||||
x -= q.x;
|
x -= p_q.x;
|
||||||
y -= q.y;
|
y -= p_q.y;
|
||||||
z -= q.z;
|
z -= p_q.z;
|
||||||
w -= q.w;
|
w -= p_q.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quat::operator*=(const real_t &s) {
|
void Quat::operator*=(const real_t &s) {
|
||||||
|
|
|
@ -134,8 +134,8 @@ Vector2 Vector2::posmodv(const Vector2 &p_modv) const {
|
||||||
return Vector2(Math::fposmod(x, p_modv.x), Math::fposmod(y, p_modv.y));
|
return Vector2(Math::fposmod(x, p_modv.x), Math::fposmod(y, p_modv.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::project(const Vector2 &p_b) const {
|
Vector2 Vector2::project(const Vector2 &p_to) const {
|
||||||
return p_b * (dot(p_b) / p_b.length_squared());
|
return p_to * (dot(p_to) / p_to.length_squared());
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::snapped(const Vector2 &p_by) const {
|
Vector2 Vector2::snapped(const Vector2 &p_by) const {
|
||||||
|
@ -158,14 +158,14 @@ Vector2 Vector2::clamped(real_t p_len) const {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const {
|
Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_weight) const {
|
||||||
|
|
||||||
Vector2 p0 = p_pre_a;
|
Vector2 p0 = p_pre_a;
|
||||||
Vector2 p1 = *this;
|
Vector2 p1 = *this;
|
||||||
Vector2 p2 = p_b;
|
Vector2 p2 = p_b;
|
||||||
Vector2 p3 = p_post_b;
|
Vector2 p3 = p_post_b;
|
||||||
|
|
||||||
real_t t = p_t;
|
real_t t = p_weight;
|
||||||
real_t t2 = t * t;
|
real_t t2 = t * t;
|
||||||
real_t t3 = t2 * t;
|
real_t t3 = t2 * t;
|
||||||
|
|
||||||
|
|
|
@ -70,22 +70,22 @@ struct Vector2 {
|
||||||
real_t distance_squared_to(const Vector2 &p_vector2) const;
|
real_t distance_squared_to(const Vector2 &p_vector2) const;
|
||||||
real_t angle_to(const Vector2 &p_vector2) const;
|
real_t angle_to(const Vector2 &p_vector2) const;
|
||||||
real_t angle_to_point(const Vector2 &p_vector2) const;
|
real_t angle_to_point(const Vector2 &p_vector2) const;
|
||||||
_FORCE_INLINE_ Vector2 direction_to(const Vector2 &p_b) const;
|
_FORCE_INLINE_ Vector2 direction_to(const Vector2 &p_to) const;
|
||||||
|
|
||||||
real_t dot(const Vector2 &p_other) const;
|
real_t dot(const Vector2 &p_other) const;
|
||||||
real_t cross(const Vector2 &p_other) const;
|
real_t cross(const Vector2 &p_other) const;
|
||||||
Vector2 posmod(const real_t p_mod) const;
|
Vector2 posmod(const real_t p_mod) const;
|
||||||
Vector2 posmodv(const Vector2 &p_modv) const;
|
Vector2 posmodv(const Vector2 &p_modv) const;
|
||||||
Vector2 project(const Vector2 &p_b) const;
|
Vector2 project(const Vector2 &p_to) const;
|
||||||
|
|
||||||
Vector2 plane_project(real_t p_d, const Vector2 &p_vec) const;
|
Vector2 plane_project(real_t p_d, const Vector2 &p_vec) const;
|
||||||
|
|
||||||
Vector2 clamped(real_t p_len) const;
|
Vector2 clamped(real_t p_len) const;
|
||||||
|
|
||||||
_FORCE_INLINE_ static Vector2 linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t);
|
_FORCE_INLINE_ static Vector2 linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_weight);
|
||||||
_FORCE_INLINE_ Vector2 linear_interpolate(const Vector2 &p_b, real_t p_t) const;
|
_FORCE_INLINE_ Vector2 linear_interpolate(const Vector2 &p_to, real_t p_weight) const;
|
||||||
_FORCE_INLINE_ Vector2 slerp(const Vector2 &p_b, real_t p_t) const;
|
_FORCE_INLINE_ Vector2 slerp(const Vector2 &p_to, real_t p_weight) const;
|
||||||
Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const;
|
Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_weight) const;
|
||||||
Vector2 move_toward(const Vector2 &p_to, const real_t p_delta) const;
|
Vector2 move_toward(const Vector2 &p_to, const real_t p_delta) const;
|
||||||
|
|
||||||
Vector2 slide(const Vector2 &p_normal) const;
|
Vector2 slide(const Vector2 &p_normal) const;
|
||||||
|
@ -230,36 +230,36 @@ _FORCE_INLINE_ bool Vector2::operator!=(const Vector2 &p_vec2) const {
|
||||||
return x != p_vec2.x || y != p_vec2.y;
|
return x != p_vec2.x || y != p_vec2.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::linear_interpolate(const Vector2 &p_b, real_t p_t) const {
|
Vector2 Vector2::linear_interpolate(const Vector2 &p_to, real_t p_weight) const {
|
||||||
|
|
||||||
Vector2 res = *this;
|
Vector2 res = *this;
|
||||||
|
|
||||||
res.x += (p_t * (p_b.x - x));
|
res.x += (p_weight * (p_to.x - x));
|
||||||
res.y += (p_t * (p_b.y - y));
|
res.y += (p_weight * (p_to.y - y));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::slerp(const Vector2 &p_b, real_t p_t) const {
|
Vector2 Vector2::slerp(const Vector2 &p_to, real_t p_weight) const {
|
||||||
#ifdef MATH_CHECKS
|
#ifdef MATH_CHECKS
|
||||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Vector2(), "The start Vector2 must be normalized.");
|
ERR_FAIL_COND_V_MSG(!is_normalized(), Vector2(), "The start Vector2 must be normalized.");
|
||||||
#endif
|
#endif
|
||||||
real_t theta = angle_to(p_b);
|
real_t theta = angle_to(p_to);
|
||||||
return rotated(theta * p_t);
|
return rotated(theta * p_weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::direction_to(const Vector2 &p_b) const {
|
Vector2 Vector2::direction_to(const Vector2 &p_to) const {
|
||||||
Vector2 ret(p_b.x - x, p_b.y - y);
|
Vector2 ret(p_to.x - x, p_to.y - y);
|
||||||
ret.normalize();
|
ret.normalize();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t) {
|
Vector2 Vector2::linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_weight) {
|
||||||
|
|
||||||
Vector2 res = p_a;
|
Vector2 res = p_a;
|
||||||
|
|
||||||
res.x += (p_t * (p_b.x - p_a.x));
|
res.x += (p_weight * (p_b.x - p_a.x));
|
||||||
res.y += (p_t * (p_b.y - p_a.y));
|
res.y += (p_weight * (p_b.y - p_a.y));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ Vector3 Vector3::snapped(Vector3 p_val) const {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const {
|
Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const {
|
||||||
|
|
||||||
Vector3 p0 = p_pre_a;
|
Vector3 p0 = p_pre_a;
|
||||||
Vector3 p1 = *this;
|
Vector3 p1 = *this;
|
||||||
|
@ -96,7 +96,7 @@ Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a,
|
||||||
p3 = p2 + (p3 - p2) * (bc / cd);
|
p3 = p2 + (p3 - p2) * (bc / cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t t = p_t;
|
real_t t = p_weight;
|
||||||
real_t t2 = t * t;
|
real_t t2 = t * t;
|
||||||
real_t t3 = t2 * t;
|
real_t t3 = t2 * t;
|
||||||
|
|
||||||
|
@ -108,14 +108,14 @@ Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a,
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const {
|
Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const {
|
||||||
|
|
||||||
Vector3 p0 = p_pre_a;
|
Vector3 p0 = p_pre_a;
|
||||||
Vector3 p1 = *this;
|
Vector3 p1 = *this;
|
||||||
Vector3 p2 = p_b;
|
Vector3 p2 = p_b;
|
||||||
Vector3 p3 = p_post_b;
|
Vector3 p3 = p_post_b;
|
||||||
|
|
||||||
real_t t = p_t;
|
real_t t = p_weight;
|
||||||
real_t t2 = t * t;
|
real_t t2 = t * t;
|
||||||
real_t t3 = t2 * t;
|
real_t t3 = t2 * t;
|
||||||
|
|
||||||
|
|
|
@ -88,10 +88,10 @@ struct Vector3 {
|
||||||
|
|
||||||
/* Static Methods between 2 vector3s */
|
/* Static Methods between 2 vector3s */
|
||||||
|
|
||||||
_FORCE_INLINE_ Vector3 linear_interpolate(const Vector3 &p_b, real_t p_t) const;
|
_FORCE_INLINE_ Vector3 linear_interpolate(const Vector3 &p_to, real_t p_weight) const;
|
||||||
_FORCE_INLINE_ Vector3 slerp(const Vector3 &p_b, real_t p_t) const;
|
_FORCE_INLINE_ Vector3 slerp(const Vector3 &p_to, real_t p_weight) const;
|
||||||
Vector3 cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const;
|
Vector3 cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const;
|
||||||
Vector3 cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const;
|
Vector3 cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const;
|
||||||
Vector3 move_toward(const Vector3 &p_to, const real_t p_delta) const;
|
Vector3 move_toward(const Vector3 &p_to, const real_t p_delta) const;
|
||||||
|
|
||||||
_FORCE_INLINE_ Vector3 cross(const Vector3 &p_b) const;
|
_FORCE_INLINE_ Vector3 cross(const Vector3 &p_b) const;
|
||||||
|
@ -105,15 +105,15 @@ struct Vector3 {
|
||||||
_FORCE_INLINE_ Vector3 ceil() const;
|
_FORCE_INLINE_ Vector3 ceil() const;
|
||||||
_FORCE_INLINE_ Vector3 round() const;
|
_FORCE_INLINE_ Vector3 round() const;
|
||||||
|
|
||||||
_FORCE_INLINE_ real_t distance_to(const Vector3 &p_b) const;
|
_FORCE_INLINE_ real_t distance_to(const Vector3 &p_to) const;
|
||||||
_FORCE_INLINE_ real_t distance_squared_to(const Vector3 &p_b) const;
|
_FORCE_INLINE_ real_t distance_squared_to(const Vector3 &p_to) const;
|
||||||
|
|
||||||
_FORCE_INLINE_ Vector3 posmod(const real_t p_mod) const;
|
_FORCE_INLINE_ Vector3 posmod(const real_t p_mod) const;
|
||||||
_FORCE_INLINE_ Vector3 posmodv(const Vector3 &p_modv) const;
|
_FORCE_INLINE_ Vector3 posmodv(const Vector3 &p_modv) const;
|
||||||
_FORCE_INLINE_ Vector3 project(const Vector3 &p_b) const;
|
_FORCE_INLINE_ Vector3 project(const Vector3 &p_to) const;
|
||||||
|
|
||||||
_FORCE_INLINE_ real_t angle_to(const Vector3 &p_b) const;
|
_FORCE_INLINE_ real_t angle_to(const Vector3 &p_to) const;
|
||||||
_FORCE_INLINE_ Vector3 direction_to(const Vector3 &p_b) const;
|
_FORCE_INLINE_ Vector3 direction_to(const Vector3 &p_to) const;
|
||||||
|
|
||||||
_FORCE_INLINE_ Vector3 slide(const Vector3 &p_normal) const;
|
_FORCE_INLINE_ Vector3 slide(const Vector3 &p_normal) const;
|
||||||
_FORCE_INLINE_ Vector3 bounce(const Vector3 &p_normal) const;
|
_FORCE_INLINE_ Vector3 bounce(const Vector3 &p_normal) const;
|
||||||
|
@ -196,27 +196,27 @@ Vector3 Vector3::round() const {
|
||||||
return Vector3(Math::round(x), Math::round(y), Math::round(z));
|
return Vector3(Math::round(x), Math::round(y), Math::round(z));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::linear_interpolate(const Vector3 &p_b, real_t p_t) const {
|
Vector3 Vector3::linear_interpolate(const Vector3 &p_to, real_t p_weight) const {
|
||||||
|
|
||||||
return Vector3(
|
return Vector3(
|
||||||
x + (p_t * (p_b.x - x)),
|
x + (p_weight * (p_to.x - x)),
|
||||||
y + (p_t * (p_b.y - y)),
|
y + (p_weight * (p_to.y - y)),
|
||||||
z + (p_t * (p_b.z - z)));
|
z + (p_weight * (p_to.z - z)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::slerp(const Vector3 &p_b, real_t p_t) const {
|
Vector3 Vector3::slerp(const Vector3 &p_to, real_t p_weight) const {
|
||||||
real_t theta = angle_to(p_b);
|
real_t theta = angle_to(p_to);
|
||||||
return rotated(cross(p_b).normalized(), theta * p_t);
|
return rotated(cross(p_to).normalized(), theta * p_weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Vector3::distance_to(const Vector3 &p_b) const {
|
real_t Vector3::distance_to(const Vector3 &p_to) const {
|
||||||
|
|
||||||
return (p_b - *this).length();
|
return (p_to - *this).length();
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Vector3::distance_squared_to(const Vector3 &p_b) const {
|
real_t Vector3::distance_squared_to(const Vector3 &p_to) const {
|
||||||
|
|
||||||
return (p_b - *this).length_squared();
|
return (p_to - *this).length_squared();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::posmod(const real_t p_mod) const {
|
Vector3 Vector3::posmod(const real_t p_mod) const {
|
||||||
|
@ -227,17 +227,17 @@ Vector3 Vector3::posmodv(const Vector3 &p_modv) const {
|
||||||
return Vector3(Math::fposmod(x, p_modv.x), Math::fposmod(y, p_modv.y), Math::fposmod(z, p_modv.z));
|
return Vector3(Math::fposmod(x, p_modv.x), Math::fposmod(y, p_modv.y), Math::fposmod(z, p_modv.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::project(const Vector3 &p_b) const {
|
Vector3 Vector3::project(const Vector3 &p_to) const {
|
||||||
return p_b * (dot(p_b) / p_b.length_squared());
|
return p_to * (dot(p_to) / p_to.length_squared());
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Vector3::angle_to(const Vector3 &p_b) const {
|
real_t Vector3::angle_to(const Vector3 &p_to) const {
|
||||||
|
|
||||||
return Math::atan2(cross(p_b).length(), dot(p_b));
|
return Math::atan2(cross(p_to).length(), dot(p_to));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::direction_to(const Vector3 &p_b) const {
|
Vector3 Vector3::direction_to(const Vector3 &p_to) const {
|
||||||
Vector3 ret(p_b.x - x, p_b.y - y, p_b.z - z);
|
Vector3 ret(p_to.x - x, p_to.y - y, p_to.z - z);
|
||||||
ret.normalize();
|
ret.normalize();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1681,9 +1681,9 @@ void register_variant_methods() {
|
||||||
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, REAL, "mod", varray());
|
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, REAL, "mod", varray());
|
||||||
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmodv, VECTOR2, "modv", varray());
|
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmodv, VECTOR2, "modv", varray());
|
||||||
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", varray());
|
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", varray());
|
||||||
ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", REAL, "t", varray());
|
ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "to", REAL, "weight", varray());
|
||||||
ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", REAL, "t", varray());
|
ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "to", REAL, "weight", varray());
|
||||||
ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "t", varray());
|
ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "weight", varray());
|
||||||
ADDFUNC2R(VECTOR2, VECTOR2, Vector2, move_toward, VECTOR2, "to", REAL, "delta", varray());
|
ADDFUNC2R(VECTOR2, VECTOR2, Vector2, move_toward, VECTOR2, "to", REAL, "delta", varray());
|
||||||
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, REAL, "phi", varray());
|
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, REAL, "phi", varray());
|
||||||
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, tangent, varray());
|
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, tangent, varray());
|
||||||
|
@ -1729,9 +1729,9 @@ void register_variant_methods() {
|
||||||
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray());
|
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray());
|
||||||
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray());
|
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray());
|
||||||
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray());
|
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray());
|
||||||
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", REAL, "t", varray());
|
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "to", REAL, "weight", varray());
|
||||||
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", REAL, "t", varray());
|
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "to", REAL, "weight", varray());
|
||||||
ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "t", varray());
|
ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "weight", varray());
|
||||||
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", REAL, "delta", varray());
|
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", REAL, "delta", varray());
|
||||||
ADDFUNC1R(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray());
|
ADDFUNC1R(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray());
|
||||||
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray());
|
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray());
|
||||||
|
@ -1769,9 +1769,9 @@ void register_variant_methods() {
|
||||||
ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray());
|
ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray());
|
||||||
ADDFUNC1R(QUAT, REAL, Quat, dot, QUAT, "b", varray());
|
ADDFUNC1R(QUAT, REAL, Quat, dot, QUAT, "b", varray());
|
||||||
ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray());
|
ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray());
|
||||||
ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "b", REAL, "t", varray());
|
ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "to", REAL, "weight", varray());
|
||||||
ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "b", REAL, "t", 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, "t", 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());
|
ADDFUNC0R(QUAT, VECTOR3, Quat, get_euler, varray());
|
||||||
ADDFUNC1(QUAT, NIL, Quat, set_euler, VECTOR3, "euler", varray());
|
ADDFUNC1(QUAT, NIL, Quat, set_euler, VECTOR3, "euler", varray());
|
||||||
ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", REAL, "angle", varray());
|
ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", REAL, "angle", varray());
|
||||||
|
@ -1785,7 +1785,7 @@ void register_variant_methods() {
|
||||||
ADDFUNC0R(COLOR, REAL, Color, gray, varray());
|
ADDFUNC0R(COLOR, REAL, Color, gray, varray());
|
||||||
ADDFUNC0R(COLOR, COLOR, Color, inverted, varray());
|
ADDFUNC0R(COLOR, COLOR, Color, inverted, varray());
|
||||||
ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray());
|
ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray());
|
||||||
ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", REAL, "t", varray());
|
ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "to", REAL, "weight", varray());
|
||||||
ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray());
|
ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray());
|
||||||
ADDFUNC1R(COLOR, COLOR, Color, lightened, REAL, "amount", varray());
|
ADDFUNC1R(COLOR, COLOR, Color, lightened, REAL, "amount", varray());
|
||||||
ADDFUNC1R(COLOR, COLOR, Color, darkened, REAL, "amount", varray());
|
ADDFUNC1R(COLOR, COLOR, Color, darkened, REAL, "amount", varray());
|
||||||
|
@ -1988,7 +1988,7 @@ void register_variant_methods() {
|
||||||
ADDFUNC1R(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray());
|
ADDFUNC1R(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray());
|
||||||
ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray());
|
ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray());
|
||||||
ADDFUNC0R(BASIS, INT, Basis, get_orthogonal_index, varray());
|
ADDFUNC0R(BASIS, INT, Basis, get_orthogonal_index, varray());
|
||||||
ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "b", REAL, "t", varray());
|
ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "to", REAL, "weight", varray());
|
||||||
// For complicated reasons, the epsilon argument is always discarded. See #45062.
|
// 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));
|
ADDFUNC2R(BASIS, BOOL, Basis, is_equal_approx, BASIS, "b", REAL, "epsilon", varray(CMP_EPSILON));
|
||||||
ADDFUNC0R(BASIS, QUAT, Basis, get_rotation_quat, varray());
|
ADDFUNC0R(BASIS, QUAT, Basis, get_rotation_quat, varray());
|
||||||
|
|
|
@ -148,9 +148,9 @@
|
||||||
<method name="slerp">
|
<method name="slerp">
|
||||||
<return type="Basis">
|
<return type="Basis">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="b" type="Basis">
|
<argument index="0" name="to" type="Basis">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="t" type="float">
|
<argument index="1" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Assuming that the matrix is a proper rotation matrix, slerp performs a spherical-linear interpolation with another rotation matrix.
|
Assuming that the matrix is a proper rotation matrix, slerp performs a spherical-linear interpolation with another rotation matrix.
|
||||||
|
|
|
@ -182,12 +182,12 @@
|
||||||
<method name="linear_interpolate">
|
<method name="linear_interpolate">
|
||||||
<return type="Color">
|
<return type="Color">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="b" type="Color">
|
<argument index="0" name="to" type="Color">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="t" type="float">
|
<argument index="1" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns the linear interpolation with another color. The interpolation factor [code]t[/code] is between 0 and 1.
|
Returns the linear interpolation with another color. The interpolation factor [code]weight[/code] is between 0 and 1.
|
||||||
[codeblock]
|
[codeblock]
|
||||||
var c1 = Color(1.0, 0.0, 0.0)
|
var c1 = Color(1.0, 0.0, 0.0)
|
||||||
var c2 = Color(0.0, 1.0, 0.0)
|
var c2 = Color(0.0, 1.0, 0.0)
|
||||||
|
|
|
@ -66,10 +66,10 @@
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="2" name="post_b" type="Quat">
|
<argument index="2" name="post_b" type="Quat">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="3" name="t" type="float">
|
<argument index="3" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Performs a cubic spherical interpolation between quaternions [code]preA[/code], this vector, [code]b[/code], and [code]postB[/code], by the given amount [code]t[/code].
|
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].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="dot">
|
<method name="dot">
|
||||||
|
@ -151,9 +151,9 @@
|
||||||
<method name="slerp">
|
<method name="slerp">
|
||||||
<return type="Quat">
|
<return type="Quat">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="b" type="Quat">
|
<argument index="0" name="to" type="Quat">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="t" type="float">
|
<argument index="1" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code].
|
Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code].
|
||||||
|
@ -163,9 +163,9 @@
|
||||||
<method name="slerpni">
|
<method name="slerpni">
|
||||||
<return type="Quat">
|
<return type="Quat">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="b" type="Quat">
|
<argument index="0" name="to" type="Quat">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="t" type="float">
|
<argument index="1" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<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.
|
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.
|
||||||
|
|
|
@ -103,7 +103,7 @@
|
||||||
<argument index="1" name="weight" type="float">
|
<argument index="1" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns a transform interpolated between this transform and another by a given weight (on the range of 0.0 to 1.0).
|
Returns a transform interpolated between this transform and another by a given [code]weight[/code] (on the range of 0.0 to 1.0).
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="inverse">
|
<method name="inverse">
|
||||||
|
|
|
@ -111,10 +111,10 @@
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="2" name="post_b" type="Vector2">
|
<argument index="2" name="post_b" type="Vector2">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="3" name="t" type="float">
|
<argument index="3" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Cubically interpolates between this vector and [code]b[/code] using [code]pre_a[/code] and [code]post_b[/code] as handles, and returns the result at position [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
Cubically interpolates between this vector and [code]b[/code] using [code]pre_a[/code] and [code]post_b[/code] as handles, and returns the result at position [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="direction_to">
|
<method name="direction_to">
|
||||||
|
@ -198,12 +198,12 @@
|
||||||
<method name="linear_interpolate">
|
<method name="linear_interpolate">
|
||||||
<return type="Vector2">
|
<return type="Vector2">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="b" type="Vector2">
|
<argument index="0" name="to" type="Vector2">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="t" type="float">
|
<argument index="1" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns the result of the linear interpolation between this vector and [code]b[/code] by amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
Returns the result of the linear interpolation between this vector and [code]to[/code] by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="move_toward">
|
<method name="move_toward">
|
||||||
|
@ -286,12 +286,12 @@
|
||||||
<method name="slerp">
|
<method name="slerp">
|
||||||
<return type="Vector2">
|
<return type="Vector2">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="b" type="Vector2">
|
<argument index="0" name="to" type="Vector2">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="t" type="float">
|
<argument index="1" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns the result of spherical linear interpolation between this vector and [code]b[/code], by amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
Returns the result of spherical linear interpolation between this vector and [code]to[/code], by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
||||||
[b]Note:[/b] Both vectors must be normalized.
|
[b]Note:[/b] Both vectors must be normalized.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
|
|
@ -79,10 +79,10 @@
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="2" name="post_b" type="Vector3">
|
<argument index="2" name="post_b" type="Vector3">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="3" name="t" type="float">
|
<argument index="3" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Performs a cubic interpolation between vectors [code]pre_a[/code], [code]a[/code], [code]b[/code], [code]post_b[/code] ([code]a[/code] is current), by the given amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
Performs a cubic interpolation between vectors [code]pre_a[/code], [code]a[/code], [code]b[/code], [code]post_b[/code] ([code]a[/code] is current), by the given amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="direction_to">
|
<method name="direction_to">
|
||||||
|
@ -173,12 +173,12 @@
|
||||||
<method name="linear_interpolate">
|
<method name="linear_interpolate">
|
||||||
<return type="Vector3">
|
<return type="Vector3">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="b" type="Vector3">
|
<argument index="0" name="to" type="Vector3">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="t" type="float">
|
<argument index="1" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns the result of the linear interpolation between this vector and [code]b[/code] by amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
Returns the result of the linear interpolation between this vector and [code]to[/code] by amount [code]t[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="max_axis">
|
<method name="max_axis">
|
||||||
|
@ -286,12 +286,12 @@
|
||||||
<method name="slerp">
|
<method name="slerp">
|
||||||
<return type="Vector3">
|
<return type="Vector3">
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="b" type="Vector3">
|
<argument index="0" name="to" type="Vector3">
|
||||||
</argument>
|
</argument>
|
||||||
<argument index="1" name="t" type="float">
|
<argument index="1" name="weight" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Returns the result of spherical linear interpolation between this vector and [code]b[/code], by amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
Returns the result of spherical linear interpolation between this vector and [code]to[/code], by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
||||||
[b]Note:[/b] Both vectors must be normalized.
|
[b]Note:[/b] Both vectors must be normalized.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
|
|
@ -120,10 +120,11 @@ namespace Godot
|
||||||
/// <param name="b">The destination quaternion.</param>
|
/// <param name="b">The destination quaternion.</param>
|
||||||
/// <param name="preA">A quaternion before this quaternion.</param>
|
/// <param name="preA">A quaternion before this quaternion.</param>
|
||||||
/// <param name="postB">A quaternion after `b`.</param>
|
/// <param name="postB">A quaternion after `b`.</param>
|
||||||
/// <param name="t">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
|
/// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
|
||||||
/// <returns>The interpolated quaternion.</returns>
|
/// <returns>The interpolated quaternion.</returns>
|
||||||
public Quat CubicSlerp(Quat b, Quat preA, Quat postB, real_t t)
|
public Quat CubicSlerp(Quat b, Quat preA, Quat postB, real_t weight)
|
||||||
{
|
{
|
||||||
|
real_t t = weight;
|
||||||
real_t t2 = (1.0f - t) * t * 2f;
|
real_t t2 = (1.0f - t) * t * 2f;
|
||||||
Quat sp = Slerp(b, t);
|
Quat sp = Slerp(b, t);
|
||||||
Quat sq = preA.Slerpni(postB, t);
|
Quat sq = preA.Slerpni(postB, t);
|
||||||
|
|
|
@ -194,15 +194,16 @@ namespace Godot
|
||||||
/// <param name="b">The destination vector.</param>
|
/// <param name="b">The destination vector.</param>
|
||||||
/// <param name="preA">A vector before this vector.</param>
|
/// <param name="preA">A vector before this vector.</param>
|
||||||
/// <param name="postB">A vector after `b`.</param>
|
/// <param name="postB">A vector after `b`.</param>
|
||||||
/// <param name="t">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
|
/// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
|
||||||
/// <returns>The interpolated vector.</returns>
|
/// <returns>The interpolated vector.</returns>
|
||||||
public Vector2 CubicInterpolate(Vector2 b, Vector2 preA, Vector2 postB, real_t t)
|
public Vector2 CubicInterpolate(Vector2 b, Vector2 preA, Vector2 postB, real_t weight)
|
||||||
{
|
{
|
||||||
Vector2 p0 = preA;
|
Vector2 p0 = preA;
|
||||||
Vector2 p1 = this;
|
Vector2 p1 = this;
|
||||||
Vector2 p2 = b;
|
Vector2 p2 = b;
|
||||||
Vector2 p3 = postB;
|
Vector2 p3 = postB;
|
||||||
|
|
||||||
|
real_t t = weight;
|
||||||
real_t t2 = t * t;
|
real_t t2 = t * t;
|
||||||
real_t t3 = t2 * t;
|
real_t t3 = t2 * t;
|
||||||
|
|
||||||
|
|
|
@ -161,15 +161,16 @@ namespace Godot
|
||||||
/// <param name="b">The destination vector.</param>
|
/// <param name="b">The destination vector.</param>
|
||||||
/// <param name="preA">A vector before this vector.</param>
|
/// <param name="preA">A vector before this vector.</param>
|
||||||
/// <param name="postB">A vector after `b`.</param>
|
/// <param name="postB">A vector after `b`.</param>
|
||||||
/// <param name="t">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
|
/// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
|
||||||
/// <returns>The interpolated vector.</returns>
|
/// <returns>The interpolated vector.</returns>
|
||||||
public Vector3 CubicInterpolate(Vector3 b, Vector3 preA, Vector3 postB, real_t t)
|
public Vector3 CubicInterpolate(Vector3 b, Vector3 preA, Vector3 postB, real_t weight)
|
||||||
{
|
{
|
||||||
Vector3 p0 = preA;
|
Vector3 p0 = preA;
|
||||||
Vector3 p1 = this;
|
Vector3 p1 = this;
|
||||||
Vector3 p2 = b;
|
Vector3 p2 = b;
|
||||||
Vector3 p3 = postB;
|
Vector3 p3 = postB;
|
||||||
|
|
||||||
|
real_t t = weight;
|
||||||
real_t t2 = t * t;
|
real_t t2 = t * t;
|
||||||
real_t t3 = t2 * t;
|
real_t t3 = t2 * t;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue