rename and unify notation for spherical interpolation
This commit is contained in:
parent
cc5135959b
commit
4211e68d80
8 changed files with 19 additions and 19 deletions
|
@ -183,7 +183,7 @@ Quaternion Quaternion::slerpni(const Quaternion &p_to, const real_t &p_weight) c
|
||||||
invFactor * from.w + newFactor * p_to.w);
|
invFactor * from.w + newFactor * p_to.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion Quaternion::cubic_slerp(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t &p_weight) const {
|
Quaternion Quaternion::spherical_cubic_interpolate(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t &p_weight) const {
|
||||||
#ifdef MATH_CHECKS
|
#ifdef MATH_CHECKS
|
||||||
ERR_FAIL_COND_V_MSG(!is_normalized(), Quaternion(), "The start 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.");
|
ERR_FAIL_COND_V_MSG(!p_b.is_normalized(), Quaternion(), "The end quaternion must be normalized.");
|
||||||
|
|
|
@ -71,7 +71,7 @@ struct _NO_DISCARD_ Quaternion {
|
||||||
|
|
||||||
Quaternion slerp(const Quaternion &p_to, 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 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;
|
Quaternion spherical_cubic_interpolate(const Quaternion &p_b, const Quaternion &p_pre_a, const Quaternion &p_post_b, const real_t &p_weight) const;
|
||||||
|
|
||||||
Vector3 get_axis() const;
|
Vector3 get_axis() const;
|
||||||
real_t get_angle() const;
|
real_t get_angle() const;
|
||||||
|
|
|
@ -80,7 +80,7 @@ void Transform3D::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, con
|
||||||
origin = p_eye;
|
origin = p_eye;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform3D Transform3D::sphere_interpolate_with(const Transform3D &p_transform, real_t p_c) const {
|
Transform3D Transform3D::spherical_interpolate_with(const Transform3D &p_transform, real_t p_c) const {
|
||||||
/* not sure if very "efficient" but good enough? */
|
/* not sure if very "efficient" but good enough? */
|
||||||
|
|
||||||
Transform3D interp;
|
Transform3D interp;
|
||||||
|
|
|
@ -100,7 +100,7 @@ struct _NO_DISCARD_ Transform3D {
|
||||||
void operator*=(const real_t p_val);
|
void operator*=(const real_t p_val);
|
||||||
Transform3D operator*(const real_t p_val) const;
|
Transform3D operator*(const real_t p_val) const;
|
||||||
|
|
||||||
Transform3D sphere_interpolate_with(const Transform3D &p_transform, real_t p_c) const;
|
Transform3D spherical_interpolate_with(const Transform3D &p_transform, real_t p_c) const;
|
||||||
Transform3D interpolate_with(const Transform3D &p_transform, real_t p_c) const;
|
Transform3D interpolate_with(const Transform3D &p_transform, real_t p_c) const;
|
||||||
|
|
||||||
_FORCE_INLINE_ Transform3D inverse_xform(const Transform3D &t) const {
|
_FORCE_INLINE_ Transform3D inverse_xform(const Transform3D &t) const {
|
||||||
|
|
|
@ -1781,7 +1781,7 @@ static void _register_variant_builtin_methods() {
|
||||||
bind_method(Quaternion, dot, sarray("with"), varray());
|
bind_method(Quaternion, dot, sarray("with"), varray());
|
||||||
bind_method(Quaternion, slerp, sarray("to", "weight"), varray());
|
bind_method(Quaternion, slerp, sarray("to", "weight"), varray());
|
||||||
bind_method(Quaternion, slerpni, sarray("to", "weight"), varray());
|
bind_method(Quaternion, slerpni, sarray("to", "weight"), varray());
|
||||||
bind_method(Quaternion, cubic_slerp, sarray("b", "pre_a", "post_b", "weight"), varray());
|
bind_method(Quaternion, spherical_cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray());
|
||||||
bind_method(Quaternion, get_euler, sarray(), varray());
|
bind_method(Quaternion, get_euler, sarray(), varray());
|
||||||
bind_method(Quaternion, get_axis, sarray(), varray());
|
bind_method(Quaternion, get_axis, sarray(), varray());
|
||||||
bind_method(Quaternion, get_angle, sarray(), varray());
|
bind_method(Quaternion, get_angle, sarray(), varray());
|
||||||
|
@ -1950,7 +1950,7 @@ static void _register_variant_builtin_methods() {
|
||||||
bind_method(Transform3D, scaled, sarray("scale"), varray());
|
bind_method(Transform3D, scaled, sarray("scale"), varray());
|
||||||
bind_method(Transform3D, translated, sarray("offset"), varray());
|
bind_method(Transform3D, translated, sarray("offset"), varray());
|
||||||
bind_method(Transform3D, looking_at, sarray("target", "up"), varray(Vector3(0, 1, 0)));
|
bind_method(Transform3D, looking_at, sarray("target", "up"), varray(Vector3(0, 1, 0)));
|
||||||
bind_method(Transform3D, sphere_interpolate_with, sarray("xform", "weight"), varray());
|
bind_method(Transform3D, spherical_interpolate_with, sarray("xform", "weight"), varray());
|
||||||
bind_method(Transform3D, interpolate_with, sarray("xform", "weight"), varray());
|
bind_method(Transform3D, interpolate_with, sarray("xform", "weight"), varray());
|
||||||
bind_method(Transform3D, is_equal_approx, sarray("xform"), varray());
|
bind_method(Transform3D, is_equal_approx, sarray("xform"), varray());
|
||||||
|
|
||||||
|
|
|
@ -74,16 +74,6 @@
|
||||||
[b]Note:[/b] This method has an abnormally high amount of floating-point error, so methods such as [code]is_zero_approx[/code] will not work reliably.
|
[b]Note:[/b] This method has an abnormally high amount of floating-point error, so methods such as [code]is_zero_approx[/code] will not work reliably.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="cubic_slerp" qualifiers="const">
|
|
||||||
<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].
|
|
||||||
</description>
|
|
||||||
</method>
|
|
||||||
<method name="dot" qualifiers="const">
|
<method name="dot" qualifiers="const">
|
||||||
<return type="float" />
|
<return type="float" />
|
||||||
<argument index="0" name="with" type="Quaternion" />
|
<argument index="0" name="with" type="Quaternion" />
|
||||||
|
@ -171,6 +161,16 @@
|
||||||
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.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="spherical_cubic_interpolate" qualifiers="const">
|
||||||
|
<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 spherical cubic 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>
|
||||||
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="w" type="float" setter="" getter="" default="1.0">
|
<member name="w" type="float" setter="" getter="" default="1.0">
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
Returns a copy of the transform with its basis and origin scaled by the given [code]scale[/code] factor, using matrix multiplication.
|
Returns a copy of the transform with its basis and origin scaled by the given [code]scale[/code] factor, using matrix multiplication.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="sphere_interpolate_with" qualifiers="const">
|
<method name="spherical_interpolate_with" qualifiers="const">
|
||||||
<return type="Transform3D" />
|
<return type="Transform3D" />
|
||||||
<argument index="0" name="xform" type="Transform3D" />
|
<argument index="0" name="xform" type="Transform3D" />
|
||||||
<argument index="1" name="weight" type="float" />
|
<argument index="1" name="weight" type="float" />
|
||||||
|
|
|
@ -2302,7 +2302,7 @@ Vector3 Animation::_cubic_interpolate(const Vector3 &p_pre_a, const Vector3 &p_a
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion Animation::_cubic_interpolate(const Quaternion &p_pre_a, const Quaternion &p_a, const Quaternion &p_b, const Quaternion &p_post_b, real_t 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, real_t p_c) const {
|
||||||
return p_a.cubic_slerp(p_b, p_pre_a, p_post_b, p_c);
|
return p_a.spherical_cubic_interpolate(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, real_t p_c) const {
|
Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, real_t p_c) const {
|
||||||
|
@ -2363,7 +2363,7 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
|
||||||
Quaternion pa = p_pre_a;
|
Quaternion pa = p_pre_a;
|
||||||
Quaternion pb = p_post_b;
|
Quaternion pb = p_post_b;
|
||||||
|
|
||||||
return a.cubic_slerp(b, pa, pb, p_c);
|
return a.spherical_cubic_interpolate(b, pa, pb, p_c);
|
||||||
}
|
}
|
||||||
case Variant::AABB: {
|
case Variant::AABB: {
|
||||||
AABB a = p_a;
|
AABB a = p_a;
|
||||||
|
|
Loading…
Reference in a new issue