diff options
95 files changed, 578 insertions, 343 deletions
diff --git a/core/color.h b/core/color.h index 16dc721072..d95e80f5da 100644 --- a/core/color.h +++ b/core/color.h @@ -97,7 +97,7 @@ struct Color { Color inverted() const; Color contrasted() const; - _FORCE_INLINE_ Color linear_interpolate(const Color &p_b, float p_t) const { + _FORCE_INLINE_ Color lerp(const Color &p_b, float p_t) const { Color res = *this; diff --git a/core/input/input.cpp b/core/input/input.cpp index 5301f5f4ee..357e4c06c1 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -175,7 +175,7 @@ void Input::SpeedTrack::update(const Vector2 &p_delta_p) { accum = accum - slice; accum_t -= min_ref_frame; - speed = (slice / min_ref_frame).linear_interpolate(speed, min_ref_frame / max_ref_frame); + speed = (slice / min_ref_frame).lerp(speed, min_ref_frame / max_ref_frame); } } diff --git a/core/input/input.h b/core/input/input.h index 477de1e879..2e136dbf02 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -127,15 +127,6 @@ private: int mouse_from_touch_index; - struct VibrationInfo { - float weak_magnitude; - float strong_magnitude; - float duration; // Duration in seconds - uint64_t timestamp; - }; - - Map<int, VibrationInfo> joy_vibration; - struct SpeedTrack { uint64_t last_tick; @@ -232,6 +223,15 @@ private: EventDispatchFunc event_dispatch_function; protected: + struct VibrationInfo { + float weak_magnitude; + float strong_magnitude; + float duration; // Duration in seconds + uint64_t timestamp; + }; + + Map<int, VibrationInfo> joy_vibration; + static void _bind_methods(); public: diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h index e1dbb385e4..4665311059 100644 --- a/core/math/audio_frame.h +++ b/core/math/audio_frame.h @@ -104,7 +104,7 @@ struct AudioFrame { r = ::undenormalise(r); } - _FORCE_INLINE_ AudioFrame linear_interpolate(const AudioFrame &p_b, float p_t) const { + _FORCE_INLINE_ AudioFrame lerp(const AudioFrame &p_b, float p_t) const { AudioFrame res = *this; diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 3e07e9253e..4733c27cbc 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -911,7 +911,7 @@ Vector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int p_l for (int j = 1; j <= p_lats; j++) { // FIXME: This is stupid. - Vector3 angle = normal.linear_interpolate(axis, j / (real_t)p_lats).normalized(); + Vector3 angle = normal.lerp(axis, j / (real_t)p_lats).normalized(); Vector3 pos = angle * p_radius; planes.push_back(Plane(pos, angle)); planes.push_back(Plane(pos * axis_neg, angle * axis_neg)); @@ -943,7 +943,7 @@ Vector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, i for (int j = 1; j <= p_lats; j++) { - Vector3 angle = normal.linear_interpolate(axis, j / (real_t)p_lats).normalized(); + Vector3 angle = normal.lerp(axis, j / (real_t)p_lats).normalized(); Vector3 pos = axis * p_height * 0.5 + angle * p_radius; planes.push_back(Plane(pos, angle)); planes.push_back(Plane(pos * axis_neg, angle * axis_neg)); diff --git a/core/math/geometry.h b/core/math/geometry.h index e47d18b056..a86db6e395 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -117,8 +117,8 @@ public: if (mub < 0) mub = 0; if (mua > 1) mua = 1; if (mub > 1) mub = 1; - c1 = p1.linear_interpolate(p2, mua); - c2 = q1.linear_interpolate(q2, mub); + c1 = p1.lerp(p2, mua); + c2 = q1.lerp(q2, mub); } static real_t get_closest_distance_between_segments(const Vector3 &p_from_a, const Vector3 &p_to_a, const Vector3 &p_from_b, const Vector3 &p_to_b) { diff --git a/core/math/transform.cpp b/core/math/transform.cpp index 9dad3262d2..82e4005d3e 100644 --- a/core/math/transform.cpp +++ b/core/math/transform.cpp @@ -129,8 +129,8 @@ Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c) Vector3 dst_loc = p_transform.origin; Transform interp; - interp.basis.set_quat_scale(src_rot.slerp(dst_rot, p_c).normalized(), src_scale.linear_interpolate(dst_scale, p_c)); - interp.origin = src_loc.linear_interpolate(dst_loc, p_c); + interp.basis.set_quat_scale(src_rot.slerp(dst_rot, p_c).normalized(), src_scale.lerp(dst_scale, p_c)); + interp.origin = src_loc.lerp(dst_loc, p_c); return interp; } diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp index f28b664e46..97a9216a5a 100644 --- a/core/math/transform_2d.cpp +++ b/core/math/transform_2d.cpp @@ -267,7 +267,7 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t Vector2 v; if (dot > 0.9995) { - v = Vector2::linear_interpolate(v1, v2, p_c).normalized(); //linearly interpolate to avoid numerical precision issues + v = v1.lerp(v2, p_c).normalized(); //linearly interpolate to avoid numerical precision issues } else { real_t angle = p_c * Math::acos(dot); Vector2 v3 = (v2 - v1 * dot).normalized(); @@ -275,8 +275,8 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t } //construct matrix - Transform2D res(Math::atan2(v.y, v.x), Vector2::linear_interpolate(p1, p2, p_c)); - res.scale_basis(Vector2::linear_interpolate(s1, s2, p_c)); + Transform2D res(Math::atan2(v.y, v.x), p1.lerp(p2, p_c)); + res.scale_basis(s1.lerp(s2, p_c)); return res; } diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp index f4259e388b..f46badd19e 100644 --- a/core/math/vector2.cpp +++ b/core/math/vector2.cpp @@ -119,11 +119,11 @@ Vector2 Vector2::round() const { } Vector2 Vector2::rotated(real_t p_by) const { - - Vector2 v; - v.set_rotation(angle() + p_by); - v *= length(); - return v; + real_t sine = Math::sin(p_by); + real_t cosi = Math::cos(p_by); + return Vector2( + x * cosi - y * sine, + x * sine + y * cosi); } Vector2 Vector2::posmod(const real_t p_mod) const { diff --git a/core/math/vector2.h b/core/math/vector2.h index ba5558102f..c0057f2543 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -82,8 +82,7 @@ struct Vector2 { 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_ Vector2 linear_interpolate(const Vector2 &p_b, real_t p_t) const; + _FORCE_INLINE_ Vector2 lerp(const Vector2 &p_b, real_t p_t) const; _FORCE_INLINE_ Vector2 slerp(const Vector2 &p_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_t) const; Vector2 move_toward(const Vector2 &p_to, const real_t p_delta) const; @@ -123,12 +122,6 @@ struct Vector2 { real_t angle() const; - void set_rotation(real_t p_radians) { - - x = Math::cos(p_radians); - y = Math::sin(p_radians); - } - _FORCE_INLINE_ Vector2 abs() const { return Vector2(Math::abs(x), Math::abs(y)); @@ -230,7 +223,7 @@ _FORCE_INLINE_ bool Vector2::operator!=(const Vector2 &p_vec2) const { return x != p_vec2.x || y != p_vec2.y; } -Vector2 Vector2::linear_interpolate(const Vector2 &p_b, real_t p_t) const { +Vector2 Vector2::lerp(const Vector2 &p_b, real_t p_t) const { Vector2 res = *this; @@ -254,16 +247,6 @@ Vector2 Vector2::direction_to(const Vector2 &p_b) const { return ret; } -Vector2 Vector2::linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t) { - - Vector2 res = p_a; - - res.x += (p_t * (p_b.x - p_a.x)); - res.y += (p_t * (p_b.y - p_a.y)); - - return res; -} - typedef Vector2 Size2; typedef Vector2 Point2; diff --git a/core/math/vector3.h b/core/math/vector3.h index 3bf8644af9..a5e9d09208 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -89,7 +89,7 @@ struct Vector3 { /* Static Methods between 2 vector3s */ - _FORCE_INLINE_ Vector3 linear_interpolate(const Vector3 &p_b, real_t p_t) const; + _FORCE_INLINE_ Vector3 lerp(const Vector3 &p_b, real_t p_t) const; _FORCE_INLINE_ Vector3 slerp(const Vector3 &p_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_t) const; Vector3 cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const; @@ -206,7 +206,7 @@ Vector3 Vector3::round() const { 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::lerp(const Vector3 &p_b, real_t p_t) const { return Vector3( x + (p_t * (p_b.x - x)), diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 391c293810..39bfd04a0b 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -362,7 +362,7 @@ struct _VariantCall { VCALL_LOCALMEM1R(Vector2, angle_to); VCALL_LOCALMEM1R(Vector2, angle_to_point); VCALL_LOCALMEM1R(Vector2, direction_to); - VCALL_LOCALMEM2R(Vector2, linear_interpolate); + VCALL_LOCALMEM2R(Vector2, lerp); VCALL_LOCALMEM2R(Vector2, slerp); VCALL_LOCALMEM4R(Vector2, cubic_interpolate); VCALL_LOCALMEM2R(Vector2, move_toward); @@ -426,7 +426,7 @@ struct _VariantCall { VCALL_LOCALMEM0R(Vector3, inverse); VCALL_LOCALMEM1R(Vector3, snapped); VCALL_LOCALMEM2R(Vector3, rotated); - VCALL_LOCALMEM2R(Vector3, linear_interpolate); + VCALL_LOCALMEM2R(Vector3, lerp); VCALL_LOCALMEM2R(Vector3, slerp); VCALL_LOCALMEM4R(Vector3, cubic_interpolate); VCALL_LOCALMEM2R(Vector3, move_toward); @@ -509,7 +509,7 @@ struct _VariantCall { VCALL_LOCALMEM0R(Color, to_rgba64); VCALL_LOCALMEM0R(Color, inverted); VCALL_LOCALMEM0R(Color, contrasted); - VCALL_LOCALMEM2R(Color, linear_interpolate); + VCALL_LOCALMEM2R(Color, lerp); VCALL_LOCALMEM1R(Color, blend); VCALL_LOCALMEM1R(Color, lightened); VCALL_LOCALMEM1R(Color, darkened); @@ -860,42 +860,42 @@ struct _VariantCall { VCALL_PTR1R(Transform2D, is_equal_approx); static void _call_Transform2D_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator Vector2()); return; case Variant::RECT2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator Rect2()); return; case Variant::PACKED_VECTOR2_ARRAY: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator PackedVector2Array()); return; - default: r_ret = Variant(); + default: + r_ret = Variant(); + ERR_PRINT("Invalid type in function 'xform' in base 'Transform2D'. Valid types are Vector2, Rect2, and PackedVector2Array."); } } static void _call_Transform2D_xform_inv(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector2()); return; case Variant::RECT2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Rect2()); return; case Variant::PACKED_VECTOR2_ARRAY: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator PackedVector2Array()); return; - default: r_ret = Variant(); + default: + r_ret = Variant(); + ERR_PRINT("Invalid type in function 'xform_inv' in base 'Transform2D'. Valid types are Vector2, Rect2, and PackedVector2Array."); } } static void _call_Transform2D_basis_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->basis_xform(p_args[0]->operator Vector2()); return; - default: r_ret = Variant(); + default: + r_ret = Variant(); + ERR_PRINT("Invalid type in function 'basis_xform' in base 'Transform2D'. Only Vector2 is valid."); } } static void _call_Transform2D_basis_xform_inv(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->basis_xform_inv(p_args[0]->operator Vector2()); return; - default: r_ret = Variant(); + default: + r_ret = Variant(); + ERR_PRINT("Invalid type in function 'basis_xform_inv' in base 'Transform2D'. Only Vector2 is valid."); } } @@ -928,37 +928,29 @@ struct _VariantCall { VCALL_PTR1R(Transform, is_equal_approx); static void _call_Transform_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Vector3()); return; case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Plane()); return; case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::AABB()); return; case Variant::PACKED_VECTOR3_ARRAY: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::PackedVector3Array()); return; - default: r_ret = Variant(); + default: + r_ret = Variant(); + ERR_PRINT("Invalid type in function 'xform' in base 'Transform'. Valid types are Vector3, Plane, AABB, and PackedVector3Array."); } } static void _call_Transform_xform_inv(Variant &r_ret, Variant &p_self, const Variant **p_args) { - switch (p_args[0]->type) { - case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector3()); return; case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Plane()); return; case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::AABB()); return; case Variant::PACKED_VECTOR3_ARRAY: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::PackedVector3Array()); return; - default: r_ret = Variant(); + default: + r_ret = Variant(); + ERR_PRINT("Invalid type in function 'xform_inv' in base 'Transform'. Valid types are Vector3, Plane, AABB, and PackedVector3Array."); } } - /* - VCALL_PTR0( Transform, invert ); - VCALL_PTR0( Transform, affine_invert ); - VCALL_PTR2( Transform, rotate ); - VCALL_PTR1( Transform, scale ); - VCALL_PTR1( Transform, translate ); - VCALL_PTR0( Transform, orthonormalize ); */ - struct ConstructData { int arg_count; @@ -1809,7 +1801,7 @@ void register_variant_methods() { ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, FLOAT, "mod", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmodv, VECTOR2, "modv", varray()); ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", varray()); - ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", FLOAT, "t", varray()); + ADDFUNC2R(VECTOR2, VECTOR2, Vector2, lerp, VECTOR2, "b", FLOAT, "t", varray()); ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", FLOAT, "t", varray()); ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", FLOAT, "t", varray()); ADDFUNC2R(VECTOR2, VECTOR2, Vector2, move_toward, VECTOR2, "to", FLOAT, "delta", varray()); @@ -1874,7 +1866,7 @@ void register_variant_methods() { ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray()); ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray()); ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", FLOAT, "phi", varray()); - ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", FLOAT, "t", varray()); + ADDFUNC2R(VECTOR3, VECTOR3, Vector3, lerp, VECTOR3, "b", FLOAT, "t", varray()); ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", FLOAT, "t", varray()); ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", FLOAT, "t", varray()); ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", FLOAT, "delta", varray()); @@ -1933,7 +1925,7 @@ void register_variant_methods() { ADDFUNC0R(COLOR, INT, Color, to_rgba64, varray()); ADDFUNC0R(COLOR, COLOR, Color, inverted, varray()); ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray()); - ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", FLOAT, "t", varray()); + ADDFUNC2R(COLOR, COLOR, Color, lerp, COLOR, "b", FLOAT, "t", varray()); ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray()); ADDFUNC1R(COLOR, COLOR, Color, lightened, FLOAT, "amount", varray()); ADDFUNC1R(COLOR, COLOR, Color, darkened, FLOAT, "amount", varray()); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index f173c88054..27624b81ee 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -4220,7 +4220,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } return; case VECTOR2: { - r_dst = reinterpret_cast<const Vector2 *>(a._data._mem)->linear_interpolate(*reinterpret_cast<const Vector2 *>(b._data._mem), c); + r_dst = reinterpret_cast<const Vector2 *>(a._data._mem)->lerp(*reinterpret_cast<const Vector2 *>(b._data._mem), c); } return; case VECTOR2I: { @@ -4233,7 +4233,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & return; case RECT2: { - r_dst = Rect2(reinterpret_cast<const Rect2 *>(a._data._mem)->position.linear_interpolate(reinterpret_cast<const Rect2 *>(b._data._mem)->position, c), reinterpret_cast<const Rect2 *>(a._data._mem)->size.linear_interpolate(reinterpret_cast<const Rect2 *>(b._data._mem)->size, c)); + r_dst = Rect2(reinterpret_cast<const Rect2 *>(a._data._mem)->position.lerp(reinterpret_cast<const Rect2 *>(b._data._mem)->position, c), reinterpret_cast<const Rect2 *>(a._data._mem)->size.lerp(reinterpret_cast<const Rect2 *>(b._data._mem)->size, c)); } return; case RECT2I: { @@ -4254,7 +4254,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & return; case VECTOR3: { - r_dst = reinterpret_cast<const Vector3 *>(a._data._mem)->linear_interpolate(*reinterpret_cast<const Vector3 *>(b._data._mem), c); + r_dst = reinterpret_cast<const Vector3 *>(a._data._mem)->lerp(*reinterpret_cast<const Vector3 *>(b._data._mem), c); } return; case VECTOR3I: { @@ -4281,7 +4281,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } return; case AABB: { - r_dst = ::AABB(a._data._aabb->position.linear_interpolate(b._data._aabb->position, c), a._data._aabb->size.linear_interpolate(b._data._aabb->size, c)); + r_dst = ::AABB(a._data._aabb->position.lerp(b._data._aabb->position, c), a._data._aabb->size.lerp(b._data._aabb->size, c)); } return; case BASIS: { @@ -4293,7 +4293,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & } return; case COLOR: { - r_dst = reinterpret_cast<const Color *>(a._data._mem)->linear_interpolate(*reinterpret_cast<const Color *>(b._data._mem), c); + r_dst = reinterpret_cast<const Color *>(a._data._mem)->lerp(*reinterpret_cast<const Color *>(b._data._mem), c); } return; case STRING_NAME: { @@ -4448,7 +4448,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector2 *br = arr_b->ptr(); for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); + vw[i] = ar[i].lerp(br[i], c); } } r_dst = v; @@ -4473,7 +4473,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Vector3 *br = arr_b->ptr(); for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); + vw[i] = ar[i].lerp(br[i], c); } } r_dst = v; @@ -4497,7 +4497,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & const Color *br = arr_b->ptr(); for (int i = 0; i < sz; i++) { - vw[i] = ar[i].linear_interpolate(br[i], c); + vw[i] = ar[i].lerp(br[i], c); } } r_dst = v; diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 47b9c80f3f..b3cd1c1af7 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -155,7 +155,7 @@ Tab key. </constant> <constant name="KEY_BACKTAB" value="16777219" enum="KeyList"> - Shift+Tab key. + Shift + Tab key. </constant> <constant name="KEY_BACKSPACE" value="16777220" enum="KeyList"> Backspace key. diff --git a/doc/classes/AnimatedTexture.xml b/doc/classes/AnimatedTexture.xml index 80b910aaa7..ddd51cc6b3 100644 --- a/doc/classes/AnimatedTexture.xml +++ b/doc/classes/AnimatedTexture.xml @@ -61,6 +61,9 @@ </method> </methods> <members> + <member name="current_frame" type="int" setter="set_current_frame" getter="get_current_frame"> + Sets the currently visible frame of the texture. + </member> <member name="fps" type="float" setter="set_fps" getter="get_fps" default="4.0"> Animation speed in frames per second. This value defines the default time interval between two frames of the animation, and thus the overall duration of the animation loop based on the [member frames] property. A value of 0 means no predefined number of frames per second, the animation will play according to each frame's frame delay (see [method set_frame_delay]). For example, an animation with 8 frames, no frame delay and a [code]fps[/code] value of 2 will run for 4 seconds, with each frame lasting 0.5 seconds. @@ -68,6 +71,12 @@ <member name="frames" type="int" setter="set_frames" getter="get_frames" default="1"> Number of frames to use in the animation. While you can create the frames independently with [method set_frame_texture], you need to set this value for the animation to take new frames into account. The maximum number of frames is [constant MAX_FRAMES]. </member> + <member name="oneshot" type="bool" setter="set_oneshot" getter="get_oneshot" default="false"> + If [code]true[/code], the animation will only play once and will not loop back to the first frame after reaching the end. Note that reaching the end will not set [member pause] to [code]true[/code]. + </member> + <member name="pause" type="bool" setter="set_pause" getter="get_pause" default="false"> + If [code]true[/code], the animation will pause where it currently is (i.e. at [member current_frame]). The animation will continue from where it was paused when changing this property to [code]false[/code]. + </member> </members> <constants> <constant name="MAX_FRAMES" value="256"> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index d495be2ffd..1af5c87532 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -149,32 +149,32 @@ Returns [code]true[/code] if this color and [code]color[/code] are approximately equal, by running [method @GDScript.is_equal_approx] on each component. </description> </method> - <method name="lightened"> + <method name="lerp"> <return type="Color"> </return> - <argument index="0" name="amount" type="float"> + <argument index="0" name="b" type="Color"> + </argument> + <argument index="1" name="t" type="float"> </argument> <description> - Returns a new color resulting from making this color lighter by the specified percentage (ratio from 0 to 1). + Returns the linear interpolation with another color. The interpolation factor [code]t[/code] is between 0 and 1. [codeblock] - var green = Color(0.0, 1.0, 0.0) - var lightgreen = green.lightened(0.2) # 20% lighter than regular green + var c1 = Color(1.0, 0.0, 0.0) + var c2 = Color(0.0, 1.0, 0.0) + var li_c = c1.lerp(c2, 0.5) # A color of an RGBA(128, 128, 0, 255) [/codeblock] </description> </method> - <method name="linear_interpolate"> + <method name="lightened"> <return type="Color"> </return> - <argument index="0" name="b" type="Color"> - </argument> - <argument index="1" name="t" type="float"> + <argument index="0" name="amount" type="float"> </argument> <description> - Returns the linear interpolation with another color. The interpolation factor [code]t[/code] is between 0 and 1. + Returns a new color resulting from making this color lighter by the specified percentage (ratio from 0 to 1). [codeblock] - var c1 = Color(1.0, 0.0, 0.0) - var c2 = Color(0.0, 1.0, 0.0) - var li_c = c1.linear_interpolate(c2, 0.5) # A color of an RGBA(128, 128, 0, 255) + var green = Color(0.0, 1.0, 0.0) + var lightgreen = green.lightened(0.2) # 20% lighter than regular green [/codeblock] </description> </method> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 0c8d42021a..9dbb843902 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -798,11 +798,11 @@ Tells Godot which node it should give keyboard focus to if the user presses the top arrow on the keyboard or top on a gamepad by default. You can change the key by editing the [code]ui_top[/code] input action. The node must be a [Control]. If this property is not set, Godot will give focus to the closest [Control] to the bottom of this one. </member> <member name="focus_next" type="NodePath" setter="set_focus_next" getter="get_focus_next" default="NodePath("")"> - Tells Godot which node it should give keyboard focus to if the user presses Tab on a keyboard by default. You can change the key by editing the [code]ui_focus_next[/code] input action. + Tells Godot which node it should give keyboard focus to if the user presses [kbd]Tab[/kbd] on a keyboard by default. You can change the key by editing the [code]ui_focus_next[/code] input action. If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree. </member> <member name="focus_previous" type="NodePath" setter="set_focus_previous" getter="get_focus_previous" default="NodePath("")"> - Tells Godot which node it should give keyboard focus to if the user presses Shift+Tab on a keyboard by default. You can change the key by editing the [code]ui_focus_prev[/code] input action. + Tells Godot which node it should give keyboard focus to if the user presses [kbd]Shift + Tab[/kbd] on a keyboard by default. You can change the key by editing the [code]ui_focus_prev[/code] input action. If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree. </member> <member name="grow_horizontal" type="int" setter="set_h_grow_direction" getter="get_h_grow_direction" enum="Control.GrowDirection" default="1"> diff --git a/doc/classes/EditorScript.xml b/doc/classes/EditorScript.xml index 410301351f..e96044bf48 100644 --- a/doc/classes/EditorScript.xml +++ b/doc/classes/EditorScript.xml @@ -4,7 +4,7 @@ Base script that can be used to add extension functions to the editor. </brief_description> <description> - Scripts extending this class and implementing its [method _run] method can be executed from the Script Editor's [b]File > Run[/b] menu option (or by pressing [code]Ctrl+Shift+X[/code]) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider using [EditorPlugin]s instead. + Scripts extending this class and implementing its [method _run] method can be executed from the Script Editor's [b]File > Run[/b] menu option (or by pressing [kbd]Ctrl + Shift + X[/kbd]) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider using [EditorPlugin]s instead. [b]Note:[/b] Extending scripts need to have [code]tool[/code] mode enabled. [b]Example script:[/b] [codeblock] diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index 750ac8085c..9d00ffe233 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -240,7 +240,7 @@ </signal> <signal name="copy_nodes_request"> <description> - Emitted when the user presses [code]Ctrl + C[/code]. + Emitted when the user presses [kbd]Ctrl + C[/kbd]. </description> </signal> <signal name="delete_nodes_request"> @@ -281,7 +281,7 @@ </signal> <signal name="paste_nodes_request"> <description> - Emitted when the user presses [code]Ctrl + V[/code]. + Emitted when the user presses [kbd]Ctrl + V[/kbd]. </description> </signal> <signal name="popup_request"> diff --git a/doc/classes/InputEventKey.xml b/doc/classes/InputEventKey.xml index 34afa90553..767e67c615 100644 --- a/doc/classes/InputEventKey.xml +++ b/doc/classes/InputEventKey.xml @@ -14,7 +14,7 @@ <return type="int"> </return> <description> - Returns the keycode combined with modifier keys such as [code]Shift[/code] or [code]Alt[/code]. See also [InputEventWithModifiers]. + Returns the keycode combined with modifier keys such as [kbd]Shift[/kbd] or [kbd]Alt[/kbd]. See also [InputEventWithModifiers]. To get a human-readable representation of the [InputEventKey] with modifiers, use [code]OS.get_keycode_string(event.get_keycode_with_modifiers())[/code] where [code]event[/code] is the [InputEventKey]. </description> </method> @@ -22,7 +22,7 @@ <return type="int"> </return> <description> - Returns the physical keycode combined with modifier keys such as [code]Shift[/code] or [code]Alt[/code]. See also [InputEventWithModifiers]. + Returns the physical keycode combined with modifier keys such as [kbd]Shift[/kbd] or [kbd]Alt[/kbd]. See also [InputEventWithModifiers]. To get a human-readable representation of the [InputEventKey] with modifiers, use [code]OS.get_keycode_string(event.get_physical_keycode_with_modifiers())[/code] where [code]event[/code] is the [InputEventKey]. </description> </method> diff --git a/doc/classes/InputEventWithModifiers.xml b/doc/classes/InputEventWithModifiers.xml index 34faf18e24..cc7de2ca32 100644 --- a/doc/classes/InputEventWithModifiers.xml +++ b/doc/classes/InputEventWithModifiers.xml @@ -4,7 +4,7 @@ Base class for keys events with modifiers. </brief_description> <description> - Contains keys events information with modifiers support like [code]Shift[/code] or [code]Alt[/code]. See [method Node._input]. + Contains keys events information with modifiers support like [kbd]Shift[/kbd] or [kbd]Alt[/kbd]. See [method Node._input]. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/inputs/inputevent.html</link> @@ -13,19 +13,19 @@ </methods> <members> <member name="alt" type="bool" setter="set_alt" getter="get_alt" default="false"> - State of the [code]Alt[/code] modifier. + State of the [kbd]Alt[/kbd] modifier. </member> <member name="command" type="bool" setter="set_command" getter="get_command" default="false"> - State of the [code]Command[/code] modifier. + State of the [kbd]Cmd[/kbd] modifier. </member> <member name="control" type="bool" setter="set_control" getter="get_control" default="false"> - State of the [code]Ctrl[/code] modifier. + State of the [kbd]Ctrl[/kbd] modifier. </member> <member name="meta" type="bool" setter="set_metakey" getter="get_metakey" default="false"> - State of the [code]Meta[/code] modifier. + State of the [kbd]Meta[/kbd] modifier. </member> <member name="shift" type="bool" setter="set_shift" getter="get_shift" default="false"> - State of the [code]Shift[/code] modifier. + State of the [kbd]Shift[/kbd] modifier. </member> </members> <constants> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index c6ed1e22ed..25420bd77b 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -5,7 +5,7 @@ </brief_description> <description> This control provides a selectable list of items that may be in a single (or multiple columns) with option of text, icons, or both text and icon. Tooltips are supported and may be different for every item in the list. - Selectable items in the list may be selected or deselected and multiple selection may be enabled. Selection with right mouse button may also be enabled to allow use of popup context menus. Items may also be "activated" by double-clicking them or by pressing Enter. + Selectable items in the list may be selected or deselected and multiple selection may be enabled. Selection with right mouse button may also be enabled to allow use of popup context menus. Items may also be "activated" by double-clicking them or by pressing [kbd]Enter[/kbd]. Item text only supports single-line strings, newline characters (e.g. [code]\n[/code]) in the string won't produce a newline. Text wrapping is enabled in [constant ICON_MODE_TOP] mode, but column's width is adjusted to fully fit its content by default. You need to set [member fixed_column_width] greater than zero to wrap the text. </description> <tutorials> @@ -278,7 +278,7 @@ </argument> <description> Disables (or enables) the item at the specified index. - Disabled items cannot be selected and do not trigger activation signals (when double-clicking or pressing Enter). + Disabled items cannot be selected and do not trigger activation signals (when double-clicking or pressing [kbd]Enter[/kbd]). </description> </method> <method name="set_item_icon"> @@ -452,7 +452,7 @@ <argument index="0" name="index" type="int"> </argument> <description> - Triggered when specified list item is activated via double-clicking or by pressing Enter. + Triggered when specified list item is activated via double-clicking or by pressing [kbd]Enter[/kbd]. </description> </signal> <signal name="item_rmb_selected"> @@ -508,7 +508,7 @@ Only allow selecting a single item. </constant> <constant name="SELECT_MULTI" value="1" enum="SelectMode"> - Allows selecting multiple items by holding Ctrl or Shift. + Allows selecting multiple items by holding [kbd]Ctrl[/kbd] or [kbd]Shift[/kbd]. </constant> </constants> <theme_items> diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index 447446ba10..3eeb892719 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -5,27 +5,27 @@ </brief_description> <description> LineEdit provides a single-line string editor, used for text fields. - It features many built-in shortcuts which will always be available ([code]Ctrl[/code] here maps to [code]Command[/code] on macOS): - - Ctrl + C: Copy - - Ctrl + X: Cut - - Ctrl + V or Ctrl + Y: Paste/"yank" - - Ctrl + Z: Undo - - Ctrl + Shift + Z: Redo - - Ctrl + U: Delete text from the cursor position to the beginning of the line - - Ctrl + K: Delete text from the cursor position to the end of the line - - Ctrl + A: Select all text - - Up/Down arrow: Move the cursor to the beginning/end of the line + It features many built-in shortcuts which will always be available ([kbd]Ctrl[/kbd] here maps to [kbd]Cmd[/kbd] on macOS): + - [kbd]Ctrl + C[/kbd]: Copy + - [kbd]Ctrl + X[/kbd]: Cut + - [kbd]Ctrl + V[/kbd] or [kbd]Ctrl + Y[/kbd]: Paste/"yank" + - [kbd]Ctrl + Z[/kbd]: Undo + - [kbd]Ctrl + Shift + Z[/kbd]: Redo + - [kbd]Ctrl + U[/kbd]: Delete text from the cursor position to the beginning of the line + - [kbd]Ctrl + K[/kbd]: Delete text from the cursor position to the end of the line + - [kbd]Ctrl + A[/kbd]: Select all text + - [kbd]Up Arrow[/kbd]/[kbd]Down Arrow[/kbd]: Move the cursor to the beginning/end of the line On macOS, some extra keyboard shortcuts are available: - - Ctrl + F: Like the right arrow key, move the cursor one character right - - Ctrl + B: Like the left arrow key, move the cursor one character left - - Ctrl + P: Like the up arrow key, move the cursor to the previous line - - Ctrl + N: Like the down arrow key, move the cursor to the next line - - Ctrl + D: Like the Delete key, delete the character on the right side of cursor - - Ctrl + H: Like the Backspace key, delete the character on the left side of the cursor - - Ctrl + A: Like the Home key, move the cursor to the beginning of the line - - Ctrl + E: Like the End key, move the cursor to the end of the line - - Command + Left arrow: Like the Home key, move the cursor to the beginning of the line - - Command + Right arrow: Like the End key, move the cursor to the end of the line + - [kbd]Ctrl + F[/kbd]: Same as [kbd]Right Arrow[/kbd], move the cursor one character right + - [kbd]Ctrl + B[/kbd]: Same as [kbd]Left Arrow[/kbd], move the cursor one character left + - [kbd]Ctrl + P[/kbd]: Same as [kbd]Up Arrow[/kbd], move the cursor to the previous line + - [kbd]Ctrl + N[/kbd]: Same as [kbd]Down Arrow[/kbd], move the cursor to the next line + - [kbd]Ctrl + D[/kbd]: Same as [kbd]Delete[/kbd], delete the character on the right side of cursor + - [kbd]Ctrl + H[/kbd]: Same as [kbd]Backspace[/kbd], delete the character on the left side of the cursor + - [kbd]Ctrl + A[/kbd]: Same as [kbd]Home[/kbd], move the cursor to the beginning of the line + - [kbd]Ctrl + E[/kbd]: Same as [kbd]End[/kbd], move the cursor to the end of the line + - [kbd]Cmd + Left Arrow[/kbd]: Same as [kbd]Home[/kbd], move the cursor to the beginning of the line + - [kbd]Cmd + Right Arrow[/kbd]: Same as [kbd]End[/kbd], move the cursor to the end of the line </description> <tutorials> </tutorials> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 1c745de7f0..5ba3c6c56a 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -932,7 +932,7 @@ Implemented on all platforms. </constant> <constant name="NOTIFICATION_WM_CLOSE_REQUEST" value="1006"> - Notification received from the OS when a close request is sent (e.g. closing the window with a "Close" button or Alt+F4). + Notification received from the OS when a close request is sent (e.g. closing the window with a "Close" button or [kbd]Alt + F4[/kbd]). Implemented on desktop platforms. </constant> <constant name="NOTIFICATION_WM_GO_BACK_REQUEST" value="1007"> diff --git a/doc/classes/Node2D.xml b/doc/classes/Node2D.xml index 9f017e9aed..d4517f0588 100644 --- a/doc/classes/Node2D.xml +++ b/doc/classes/Node2D.xml @@ -92,7 +92,7 @@ <argument index="0" name="local_point" type="Vector2"> </argument> <description> - Converts a local point's coordinates to global coordinates. + Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the [Node2D] it is called on. e.g. Applying this method to the positions of child nodes will correctly transform their positions into the global coordinate space, but applying it to a node's own position will give an incorrect result, as it will incorporate the node's own transformation into its global position. </description> </method> <method name="to_local" qualifiers="const"> @@ -101,7 +101,7 @@ <argument index="0" name="global_point" type="Vector2"> </argument> <description> - Converts a global point's coordinates to local coordinates. + Transforms the provided global position into a position in local coordinate space. The output will be local relative to the [Node2D] it is called on. e.g. It is appropriate for determining the positions of child nodes, but it is not appropriate for determining its own position relative to its parent. </description> </method> <method name="translate"> diff --git a/doc/classes/Transform.xml b/doc/classes/Transform.xml index e4d367c344..4175f01eb4 100644 --- a/doc/classes/Transform.xml +++ b/doc/classes/Transform.xml @@ -135,7 +135,7 @@ <argument index="0" name="scale" type="Vector3"> </argument> <description> - Scales the transform by the given scale factor, using matrix multiplication. + Scales basis and origin of the transform by the given scale factor, using matrix multiplication. </description> </method> <method name="translated"> diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index b01ba3850f..0b2fb80480 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -16,7 +16,7 @@ var subchild1 = tree.create_item(child1) subchild1.set_text(0, "Subchild1") [/codeblock] - To iterate over all the [TreeItem] objects in a [Tree] object, use [method TreeItem.get_next] and [method TreeItem.get_children] after getting the root through [method get_root]. + To iterate over all the [TreeItem] objects in a [Tree] object, use [method TreeItem.get_next] and [method TreeItem.get_children] after getting the root through [method get_root]. You can use [method Object.free] on a [TreeItem] to remove it from the [Tree]. </description> <tutorials> </tutorials> diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index 84aa3a3686..a8a17370c2 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -5,6 +5,7 @@ </brief_description> <description> Control for a single item inside a [Tree]. May have child [TreeItem]s and be styled as well as contain buttons. + You can remove a [TreeItem] by using [method Object.free]. </description> <tutorials> </tutorials> @@ -350,7 +351,7 @@ <argument index="0" name="child" type="Object"> </argument> <description> - Removes the given child TreeItem. + Removes the given child [TreeItem] and all its children from the [Tree]. Note that it doesn't free the item from memory, so it can be reused later. To completely remove a [TreeItem] use [method Object.free]. </description> </method> <method name="select"> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 7b02a1a4c9..64ebc1fa09 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -193,7 +193,7 @@ Returns the vector's length squared. Prefer this method over [method length] if you need to sort vectors or need the squared length for some formula. </description> </method> - <method name="linear_interpolate"> + <method name="lerp"> <return type="Vector2"> </return> <argument index="0" name="b" type="Vector2"> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index 600c03ba7d..8c18ca8cc9 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -169,7 +169,7 @@ Returns the vector's length squared. Prefer this function over [method length] if you need to sort vectors or need the squared length for some formula. </description> </method> - <method name="linear_interpolate"> + <method name="lerp"> <return type="Vector3"> </return> <argument index="0" name="b" type="Vector3"> diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index 5ceab52523..a14ef7c665 100755 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -901,6 +901,12 @@ def rstize_text(text, state): # type: (str, State) -> str tag_text = "``" tag_depth += 1 inside_code = True + elif cmd == "kbd": + tag_text = ":kbd:`" + tag_depth += 1 + elif cmd == "/kbd": + tag_text = "`" + tag_depth -= 1 elif cmd.startswith("enum "): tag_text = make_enum(cmd[5:], state) escape_post = True diff --git a/doc/translations/classes.pot b/doc/translations/classes.pot index 641d80c5ca..d5351403dd 100644 --- a/doc/translations/classes.pot +++ b/doc/translations/classes.pot @@ -480,7 +480,7 @@ msgid "" "[float], the return value is a [float].\n" "If both are of the same vector type ([Vector2], [Vector3] or [Color]), the " "return value will be of the same type ([code]lerp[/code] then calls the " -"vector type's [code]linear_interpolate[/code] method).\n" +"vector type's [code]lerp[/code] method).\n" "[codeblock]\n" "lerp(0, 4, 0.75) # Returns 3.0\n" "lerp(Vector2(1, 5), Vector2(3, 2), 0.5) # Returns Vector2(2, 3.5)\n" @@ -12703,7 +12703,7 @@ msgid "" "[codeblock]\n" "var c1 = Color(1.0, 0.0, 0.0)\n" "var c2 = Color(0.0, 1.0, 0.0)\n" -"var li_c = c1.linear_interpolate(c2, 0.5) # A color of an RGBA(128, 128, 0, " +"var li_c = c1.lerp(c2, 0.5) # A color of an RGBA(128, 128, 0, " "255)\n" "[/codeblock]" msgstr "" diff --git a/doc/translations/fr.po b/doc/translations/fr.po index 6926376c05..51313f873b 100644 --- a/doc/translations/fr.po +++ b/doc/translations/fr.po @@ -490,7 +490,7 @@ msgid "" "[float], the return value is a [float].\n" "If both are of the same vector type ([Vector2], [Vector3] or [Color]), the " "return value will be of the same type ([code]lerp[/code] then calls the " -"vector type's [code]linear_interpolate[/code] method).\n" +"vector type's [code]lerp[/code] method).\n" "[codeblock]\n" "lerp(0, 4, 0.75) # Returns 3.0\n" "lerp(Vector2(1, 5), Vector2(3, 2), 0.5) # Returns Vector2(2, 3.5)\n" @@ -12713,7 +12713,7 @@ msgid "" "[codeblock]\n" "var c1 = Color(1.0, 0.0, 0.0)\n" "var c2 = Color(0.0, 1.0, 0.0)\n" -"var li_c = c1.linear_interpolate(c2, 0.5) # A color of an RGBA(128, 128, 0, " +"var li_c = c1.lerp(c2, 0.5) # A color of an RGBA(128, 128, 0, " "255)\n" "[/codeblock]" msgstr "" diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 699d6e1484..92c1ada850 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -404,18 +404,19 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener // constants - for (Map<StringName, SL::ShaderNode::Constant>::Element *E = snode->constants.front(); E; E = E->next()) { + for (int i = 0; i < snode->vconstants.size(); i++) { + const SL::ShaderNode::Constant &cnode = snode->vconstants[i]; String gcode; gcode += "const "; - gcode += _prestr(E->get().precision); - if (E->get().type == SL::TYPE_STRUCT) { - gcode += _mkid(E->get().type_str); + gcode += _prestr(cnode.precision); + if (cnode.type == SL::TYPE_STRUCT) { + gcode += _mkid(cnode.type_str); } else { - gcode += _typestr(E->get().type); + gcode += _typestr(cnode.type); } - gcode += " " + _mkid(E->key()); + gcode += " " + _mkid(String(cnode.name)); gcode += "="; - gcode += _dump_node_code(E->get().initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); + gcode += _dump_node_code(cnode.initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); gcode += ";\n"; vertex_global += gcode; fragment_global += gcode; diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index e6a020bf41..57c63dd40d 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -162,7 +162,7 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { float c = (t - low_pos.x) / (high_pos.x - low_pos.x); - h = low_pos.linear_interpolate(high_pos, c).y; + h = low_pos.lerp(high_pos, c).y; } h = _bezier_h_to_pixel(h); @@ -201,12 +201,12 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V if (to.x > p_clip_right) { float c = (p_clip_right - from.x) / (to.x - from.x); - to = from.linear_interpolate(to, c); + to = from.lerp(to, c); } if (from.x < p_clip_left) { float c = (p_clip_left - from.x) / (to.x - from.x); - from = from.linear_interpolate(to, c); + from = from.lerp(to, c); } draw_line(from, to, p_color); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 695c294ad2..0ce3ab292e 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -112,13 +112,13 @@ void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int if (x_from < p_clip_left) { float c = float(p_clip_left - x_from) / (x_to - x_from); - color = color.linear_interpolate(color_next, c); + color = color.lerp(color_next, c); x_from = p_clip_left; } if (x_to > p_clip_right) { float c = float(p_clip_right - x_from) / (x_to - x_from); - color_next = color.linear_interpolate(color_next, c); + color_next = color.lerp(color_next, c); x_to = p_clip_right; } diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 1577e24ac0..c7d4e9128a 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -136,7 +136,7 @@ Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) c double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.linear_interpolate(get_theme_color("base_color", "Editor"), 0.07); + return c.lerp(get_theme_color("base_color", "Editor"), 0.07); } void EditorProfiler::_item_edited() { diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index d2edba5970..7d2822b1c9 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -132,7 +132,7 @@ Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signat double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.linear_interpolate(get_theme_color("base_color", "Editor"), 0.07); + return c.lerp(get_theme_color("base_color", "Editor"), 0.07); } void EditorVisualProfiler::_item_selected() { diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 8aadf02ea6..cf00c536a7 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -247,10 +247,12 @@ void editor_register_fonts(Ref<Theme> p_theme) { MAKE_BOLD_FONT(df_doc_bold, int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); MAKE_BOLD_FONT(df_doc_title, int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE); MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); + MAKE_SOURCE_FONT(df_doc_kbd, (int(EDITOR_GET("text_editor/help/help_source_font_size")) - 1) * EDSCALE); p_theme->set_font("doc", "EditorFonts", df_doc); p_theme->set_font("doc_bold", "EditorFonts", df_doc_bold); p_theme->set_font("doc_title", "EditorFonts", df_doc_title); p_theme->set_font("doc_source", "EditorFonts", df_doc_code); + p_theme->set_font("doc_keyboard", "EditorFonts", df_doc_kbd); // Ruler font MAKE_DEFAULT_FONT(df_rulers, 8 * EDSCALE); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 050b0a5f33..8089d463bd 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -47,12 +47,12 @@ void EditorHelp::_init_colors() { title_color = get_theme_color("accent_color", "Editor"); text_color = get_theme_color("default_color", "RichTextLabel"); headline_color = get_theme_color("headline_color", "EditorHelp"); - base_type_color = title_color.linear_interpolate(text_color, 0.5); + base_type_color = title_color.lerp(text_color, 0.5); comment_color = text_color * Color(1, 1, 1, 0.6); symbol_color = comment_color; value_color = text_color * Color(1, 1, 1, 0.6); qualifier_color = text_color * Color(1, 1, 1, 0.8); - type_color = get_theme_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); + type_color = get_theme_color("accent_color", "Editor").lerp(text_color, 0.5); class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); class_desc->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE)); } @@ -196,7 +196,7 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { } } const Color text_color = get_theme_color("default_color", "RichTextLabel"); - const Color type_color = get_theme_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); + const Color type_color = get_theme_color("accent_color", "Editor").lerp(text_color, 0.5); class_desc->push_color(type_color); bool add_array = false; if (can_ref) { @@ -1222,11 +1222,14 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { Ref<Font> doc_font = p_rt->get_theme_font("doc", "EditorFonts"); Ref<Font> doc_bold_font = p_rt->get_theme_font("doc_bold", "EditorFonts"); Ref<Font> doc_code_font = p_rt->get_theme_font("doc_source", "EditorFonts"); + Ref<Font> doc_kbd_font = p_rt->get_theme_font("doc_keyboard", "EditorFonts"); Color font_color_hl = p_rt->get_theme_color("headline_color", "EditorHelp"); Color accent_color = p_rt->get_theme_color("accent_color", "Editor"); - Color link_color = accent_color.linear_interpolate(font_color_hl, 0.8); - Color code_color = accent_color.linear_interpolate(font_color_hl, 0.6); + Color property_color = p_rt->get_theme_color("property_color", "Editor"); + Color link_color = accent_color.lerp(font_color_hl, 0.8); + Color code_color = accent_color.lerp(font_color_hl, 0.6); + Color kbd_color = accent_color.lerp(property_color, 0.6); String bbcode = p_bbcode.dedent().replace("\t", "").replace("\r", "").strip_edges(); @@ -1337,6 +1340,14 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { code_tag = true; pos = brk_end + 1; tag_stack.push_front(tag); + } else if (tag == "kbd") { + + //use keyboard font with custom color + p_rt->push_font(doc_kbd_font); + p_rt->push_color(kbd_color); + code_tag = true; // though not strictly a code tag, logic is similar + pos = brk_end + 1; + tag_stack.push_front(tag); } else if (tag == "center") { //align to center diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index c4584e3dfb..ea2009ab58 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1195,8 +1195,6 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { } img->convert(Image::FORMAT_RGB8); - img->flip_y(); - //save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5 String temp_path = EditorSettings::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_file).md5_text(); diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index fdd5bd8db6..49cffb015f 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -412,8 +412,104 @@ void EditorPropertyArray::_remove_pressed(int p_index) { update_property(); } +void EditorPropertyArray::_button_draw() { + if (dropping) { + Color color = get_theme_color("accent_color", "Editor"); + edit->draw_rect(Rect2(Point2(), edit->get_size()), color, false); + } +} + +bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const { + String allowed_type = Variant::get_type_name(subtype); + + Dictionary drag_data = p_drag_data; + + if (drag_data.has("type") && String(drag_data["type"]) == "files") { + + Vector<String> files = drag_data["files"]; + + for (int i = 0; i < files.size(); i++) { + String file = files[i]; + String ftype = EditorFileSystem::get_singleton()->get_file_type(file); + + for (int j = 0; j < allowed_type.get_slice_count(","); j++) { + String at = allowed_type.get_slice(",", j).strip_edges(); + // Fail if one of the files is not of allowed type + if (!ClassDB::is_parent_class(ftype, at)) { + return false; + } + } + } + + // If no files fail, drop is valid + return true; + } + + return false; +} + +bool EditorPropertyArray::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { + + return _is_drop_valid(p_data); +} + +void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { + ERR_FAIL_COND(!_is_drop_valid(p_data)); + + Dictionary drag_data = p_data; + + if (drag_data.has("type") && String(drag_data["type"]) == "files") { + + Vector<String> files = drag_data["files"]; + + Variant array = object->get_array(); + + // Handle the case where array is not initialised yet + if (!array.is_array()) { + Callable::CallError ce; + array = Variant::construct(array_type, nullptr, 0, ce); + } + + // Loop the file array and add to existing array + for (int i = 0; i < files.size(); i++) { + String file = files[i]; + + RES res = ResourceLoader::load(file); + if (res.is_valid()) { + array.call("push_back", res); + } + } + + if (array.get_type() == Variant::ARRAY) { + array = array.call("duplicate"); + } + + emit_changed(get_edited_property(), array, "", false); + object->set_array(array); + + update_property(); + } +} + void EditorPropertyArray::_notification(int p_what) { + if (p_what == NOTIFICATION_DRAG_BEGIN) { + + if (is_visible_in_tree()) { + if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { + dropping = true; + edit->update(); + } + } + } + + if (p_what == NOTIFICATION_DRAG_END) { + if (dropping) { + dropping = false; + edit->update(); + } + } } + void EditorPropertyArray::_edit_pressed() { Variant array = get_edited_object()->get(get_edited_property()); @@ -490,6 +586,8 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint } void EditorPropertyArray::_bind_methods() { + ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &EditorPropertyArray::can_drop_data_fw); + ClassDB::bind_method(D_METHOD("drop_data_fw"), &EditorPropertyArray::drop_data_fw); } EditorPropertyArray::EditorPropertyArray() { @@ -503,6 +601,8 @@ EditorPropertyArray::EditorPropertyArray() { edit->set_clip_text(true); edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_edit_pressed)); edit->set_toggle_mode(true); + edit->set_drag_forwarding(this); + edit->connect("draw", callable_mp(this, &EditorPropertyArray::_button_draw)); add_child(edit); add_focusable(edit); vbox = nullptr; @@ -524,6 +624,8 @@ EditorPropertyArray::EditorPropertyArray() { subtype = Variant::NIL; subtype_hint = PROPERTY_HINT_NONE; subtype_hint_string = ""; + + dropping = false; } ///////////////////// DICTIONARY /////////////////////////// diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index 51a4be1b3a..d6f3c976f9 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -33,6 +33,7 @@ #include "editor/editor_inspector.h" #include "editor/editor_spin_slider.h" +#include "editor/filesystem_dock.h" #include "scene/gui/button.h" class EditorPropertyArrayObject : public Reference { @@ -82,6 +83,7 @@ class EditorPropertyArray : public EditorProperty { PopupMenu *change_type; bool updating; + bool dropping; Ref<EditorPropertyArrayObject> object; int page_len; @@ -107,6 +109,11 @@ class EditorPropertyArray : public EditorProperty { void _object_id_selected(const StringName &p_property, ObjectID p_id); void _remove_pressed(int p_index); + void _button_draw(); + bool _is_drop_valid(const Dictionary &p_drag_data) const; + bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; + void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + protected: static void _bind_methods(); void _notification(int p_what); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 9b58c18f51..5e34913cf0 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -561,6 +561,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // 3D: Freelook _initial_set("editors/3d/freelook/freelook_navigation_scheme", false); hints["editors/3d/freelook/freelook_navigation_scheme"] = PropertyInfo(Variant::INT, "editors/3d/freelook/freelook_navigation_scheme", PROPERTY_HINT_ENUM, "Default,Partially Axis-Locked (id Tech),Fully Axis-Locked (Minecraft)"); + _initial_set("editors/3d/freelook/freelook_sensitivity", 0.4); + hints["editors/3d/freelook/freelook_sensitivity"] = PropertyInfo(Variant::FLOAT, "editors/3d/freelook/freelook_sensitivity", PROPERTY_HINT_RANGE, "0.0, 2, 0.01"); _initial_set("editors/3d/freelook/freelook_inertia", 0.1); hints["editors/3d/freelook/freelook_inertia"] = PropertyInfo(Variant::FLOAT, "editors/3d/freelook/freelook_inertia", PROPERTY_HINT_RANGE, "0.0, 1, 0.01"); _initial_set("editors/3d/freelook/freelook_base_speed", 5.0); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 576ee436de..0ef173f074 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -337,24 +337,24 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { //Colors bool dark_theme = EditorSettings::get_singleton()->is_dark_theme(); - const Color dark_color_1 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast); - const Color dark_color_2 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 1.5); - const Color dark_color_3 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 2); + const Color dark_color_1 = base_color.lerp(Color(0, 0, 0, 1), contrast); + const Color dark_color_2 = base_color.lerp(Color(0, 0, 0, 1), contrast * 1.5); + const Color dark_color_3 = base_color.lerp(Color(0, 0, 0, 1), contrast * 2); const Color background_color = dark_color_2; // white (dark theme) or black (light theme), will be used to generate the rest of the colors const Color mono_color = dark_theme ? Color(1, 1, 1) : Color(0, 0, 0); - const Color contrast_color_1 = base_color.linear_interpolate(mono_color, MAX(contrast, default_contrast)); - const Color contrast_color_2 = base_color.linear_interpolate(mono_color, MAX(contrast * 1.5, default_contrast * 1.5)); + const Color contrast_color_1 = base_color.lerp(mono_color, MAX(contrast, default_contrast)); + const Color contrast_color_2 = base_color.lerp(mono_color, MAX(contrast * 1.5, default_contrast * 1.5)); - const Color font_color = mono_color.linear_interpolate(base_color, 0.25); - const Color font_color_hl = mono_color.linear_interpolate(base_color, 0.15); + const Color font_color = mono_color.lerp(base_color, 0.25); + const Color font_color_hl = mono_color.lerp(base_color, 0.15); const Color font_color_disabled = Color(mono_color.r, mono_color.g, mono_color.b, 0.3); const Color font_color_selection = accent_color * Color(1, 1, 1, 0.4); - const Color color_disabled = mono_color.inverted().linear_interpolate(base_color, 0.7); - const Color color_disabled_bg = mono_color.inverted().linear_interpolate(base_color, 0.9); + const Color color_disabled = mono_color.inverted().lerp(base_color, 0.7); + const Color color_disabled_bg = mono_color.inverted().lerp(base_color, 0.9); Color icon_color_hover = Color(1, 1, 1) * (dark_theme ? 1.15 : 1.45); icon_color_hover.a = 1.0; @@ -391,13 +391,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Color success_color = Color(0.45, 0.95, 0.5); Color warning_color = Color(1, 0.87, 0.4); Color error_color = Color(1, 0.47, 0.42); - Color property_color = font_color.linear_interpolate(Color(0.5, 0.5, 0.5), 0.5); + Color property_color = font_color.lerp(Color(0.5, 0.5, 0.5), 0.5); if (!dark_theme) { // Darken some colors to be readable on a light background - success_color = success_color.linear_interpolate(mono_color, 0.35); - warning_color = warning_color.linear_interpolate(mono_color, 0.35); - error_color = error_color.linear_interpolate(mono_color, 0.25); + success_color = success_color.lerp(mono_color, 0.35); + warning_color = warning_color.lerp(mono_color, 0.35); + error_color = error_color.lerp(mono_color, 0.25); } theme->set_color("success_color", "Editor", success_color); @@ -434,7 +434,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { editor_register_fonts(theme); // Highlighted tabs and border width - Color tab_color = highlight_tabs ? base_color.linear_interpolate(font_color, contrast) : base_color; + Color tab_color = highlight_tabs ? base_color.lerp(font_color, contrast) : base_color; const int border_width = CLAMP(border_size, 0, 3) * EDSCALE; const int default_margin_size = 4; @@ -686,7 +686,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons")); theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE); - Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1.linear_interpolate(accent_color, 0.08), 2, 0, 2, 2); + Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1.lerp(accent_color, 0.08), 2, 0, 2, 2); sub_inspector_bg->set_border_width(MARGIN_LEFT, 2); sub_inspector_bg->set_border_width(MARGIN_RIGHT, 2); sub_inspector_bg->set_border_width(MARGIN_BOTTOM, 2); @@ -763,9 +763,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("title_button_hover", "Tree", style_tree_title); theme->set_stylebox("title_button_pressed", "Tree", style_tree_title); - Color prop_category_color = dark_color_1.linear_interpolate(mono_color, 0.12); - Color prop_section_color = dark_color_1.linear_interpolate(mono_color, 0.09); - Color prop_subsection_color = dark_color_1.linear_interpolate(mono_color, 0.06); + Color prop_category_color = dark_color_1.lerp(mono_color, 0.12); + Color prop_section_color = dark_color_1.lerp(mono_color, 0.09); + Color prop_subsection_color = dark_color_1.lerp(mono_color, 0.06); theme->set_color("prop_category", "Editor", prop_category_color); theme->set_color("prop_section", "Editor", prop_section_color); theme->set_color("prop_subsection", "Editor", prop_subsection_color); @@ -1124,7 +1124,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("toggle_hidden", "FileDialog", theme->get_icon("GuiVisibilityVisible", "EditorIcons")); // Use a different color for folder icons to make them easier to distinguish from files. // On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color. - theme->set_color("folder_icon_modulate", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).linear_interpolate(accent_color, 0.7)); + theme->set_color("folder_icon_modulate", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(accent_color, 0.7)); theme->set_color("files_disabled", "FileDialog", font_color_disabled); // color picker @@ -1158,13 +1158,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // editor main color const Color main_color = dark_theme ? Color(0.34, 0.7, 1.0) : Color(0.02, 0.5, 1.0); - const Color symbol_color = Color(0.34, 0.57, 1.0).linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); + const Color symbol_color = Color(0.34, 0.57, 1.0).lerp(mono_color, dark_theme ? 0.5 : 0.3); const Color keyword_color = Color(1.0, 0.44, 0.52); const Color basetype_color = dark_theme ? Color(0.26, 1.0, 0.76) : Color(0.0, 0.76, 0.38); - const Color type_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.4 : 0.3); - const Color usertype_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.7 : 0.5); + const Color type_color = basetype_color.lerp(mono_color, dark_theme ? 0.4 : 0.3); + const Color usertype_color = basetype_color.lerp(mono_color, dark_theme ? 0.7 : 0.5); const Color comment_color = dim_color; - const Color string_color = (dark_theme ? Color(1.0, 0.85, 0.26) : Color(1.0, 0.82, 0.09)).linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); + const Color string_color = (dark_theme ? Color(1.0, 0.85, 0.26) : Color(1.0, 0.82, 0.09)).lerp(mono_color, dark_theme ? 0.5 : 0.3); const Color te_background_color = dark_theme ? background_color : base_color; const Color completion_background_color = dark_theme ? base_color : background_color; @@ -1183,9 +1183,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color current_line_color = alpha1; const Color line_length_guideline_color = dark_theme ? base_color : background_color; const Color word_highlighted_color = alpha1; - const Color number_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); + const Color number_color = basetype_color.lerp(mono_color, dark_theme ? 0.5 : 0.3); const Color function_color = main_color; - const Color member_variable_color = main_color.linear_interpolate(mono_color, 0.6); + const Color member_variable_color = main_color.lerp(mono_color, 0.6); const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3); const Color bookmark_color = Color(0.08, 0.49, 0.98); const Color breakpoint_color = error_color; diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 6ad2aa4142..45e376a2aa 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1075,24 +1075,15 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { array[Mesh::ARRAY_INDEX] = indices; } - bool generated_tangents = false; - Variant erased_indices; + bool generate_tangents = (primitive == Mesh::PRIMITIVE_TRIANGLES && !a.has("TANGENT") && a.has("TEXCOORD_0") && a.has("NORMAL")); - if (primitive == Mesh::PRIMITIVE_TRIANGLES && !a.has("TANGENT") && a.has("TEXCOORD_0") && a.has("NORMAL")) { + if (generate_tangents) { //must generate mikktspace tangents.. ergh.. Ref<SurfaceTool> st; st.instance(); st->create_from_triangle_arrays(array); - if (!p.has("targets")) { - //morph targets should not be reindexed, as array size might differ - //removing indices is the best bet here - st->deindex(); - erased_indices = a[Mesh::ARRAY_INDEX]; - a[Mesh::ARRAY_INDEX] = Variant(); - } st->generate_tangents(); array = st->commit_to_arrays(); - generated_tangents = true; } Array morphs; @@ -1207,10 +1198,9 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { array_copy[Mesh::ARRAY_TANGENT] = tangents_v4; } - if (generated_tangents) { + if (generate_tangents) { Ref<SurfaceTool> st; st.instance(); - array_copy[Mesh::ARRAY_INDEX] = erased_indices; //needed for tangent generation, erased by deindex st->create_from_triangle_arrays(array_copy); st->deindex(); st->generate_tangents(); diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index 31a8320209..9a5df3e58f 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -2827,10 +2827,10 @@ void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { lines.push_back(a); lines.push_back(b); } else { - Vector3 ah = a.linear_interpolate(b, 0.2); + Vector3 ah = a.lerp(b, 0.2); lines.push_back(a); lines.push_back(ah); - Vector3 bh = b.linear_interpolate(a, 0.2); + Vector3 bh = b.lerp(a, 0.2); lines.push_back(b); lines.push_back(bh); } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index db51c5c6ba..0a252cc0a3 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -433,7 +433,9 @@ void AnimationPlayerEditor::_animation_remove() { if (animation->get_item_count() == 0) return; - delete_dialog->set_text(TTR("Delete Animation?")); + String current = animation->get_item_text(animation->get_selected()); + + delete_dialog->set_text(TTR("Delete Animation '" + current + "'?")); delete_dialog->popup_centered(); } @@ -1135,7 +1137,9 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { case TOOL_DUPLICATE_ANIM: { _animation_duplicate(); - } break; + + [[fallthrough]]; // Allow immediate rename after animation is duplicated + } case TOOL_RENAME_ANIM: { _animation_rename(); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index c28f533958..ed51a2d2cf 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -885,7 +885,7 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { state_machine_play_pos->draw_line(from, to, bg, 2); - to = from.linear_interpolate(to, c); + to = from.lerp(to, c); state_machine_play_pos->draw_line(from, to, fg, 2); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 79111762b2..e882b3a8d7 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1437,13 +1437,13 @@ void CanvasItemEditor::_solve_IK(Node2D *leaf_node, Point2 target_position) { Vector2 direction = (joints_pos[node_id + 1] - joints_pos[node_id]).normalized(); int len = E->get(); if (E == se->pre_drag_bones_length.front()) { - joints_pos[1] = joints_pos[1].linear_interpolate(joints_pos[0] + len * direction, solver_k); + joints_pos[1] = joints_pos[1].lerp(joints_pos[0] + len * direction, solver_k); } else if (E == se->pre_drag_bones_length.back()) { - joints_pos[node_id] = joints_pos[node_id].linear_interpolate(joints_pos[node_id + 1] - len * direction, solver_k); + joints_pos[node_id] = joints_pos[node_id].lerp(joints_pos[node_id + 1] - len * direction, solver_k); } else { Vector2 center = (joints_pos[node_id + 1] + joints_pos[node_id]) / 2.0; - joints_pos[node_id] = joints_pos[node_id].linear_interpolate(center - (direction * len) / 2.0, solver_k); - joints_pos[node_id + 1] = joints_pos[node_id + 1].linear_interpolate(center + (direction * len) / 2.0, solver_k); + joints_pos[node_id] = joints_pos[node_id].lerp(center - (direction * len) / 2.0, solver_k); + joints_pos[node_id + 1] = joints_pos[node_id + 1].lerp(center + (direction * len) / 2.0, solver_k); } node_id++; } @@ -2698,7 +2698,7 @@ void CanvasItemEditor::_draw_smart_snapping() { void CanvasItemEditor::_draw_rulers() { Color bg_color = get_theme_color("dark_color_2", "Editor"); - Color graduation_color = get_theme_color("font_color", "Editor").linear_interpolate(bg_color, 0.5); + Color graduation_color = get_theme_color("font_color", "Editor").lerp(bg_color, 0.5); Color font_color = get_theme_color("font_color", "Editor"); font_color.a = 0.8; Ref<Font> font = get_theme_font("rulers", "EditorFonts"); @@ -3072,8 +3072,8 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { Vector2 line_ends[4]; for (int i = 0; i < 4; i++) { float anchor_val = (i >= 2) ? ANCHOR_END - anchors_values[i] : anchors_values[i]; - line_starts[i] = Vector2::linear_interpolate(corners_pos[i], corners_pos[(i + 1) % 4], anchor_val); - line_ends[i] = Vector2::linear_interpolate(corners_pos[(i + 3) % 4], corners_pos[(i + 2) % 4], anchor_val); + line_starts[i] = corners_pos[i].lerp(corners_pos[(i + 1) % 4], anchor_val); + line_ends[i] = corners_pos[(i + 3) % 4].lerp(corners_pos[(i + 2) % 4], anchor_val); anchor_snapped = anchors_values[i] == 0.0 || anchors_values[i] == 0.5 || anchors_values[i] == 1.0; viewport->draw_line(line_starts[i], line_ends[i], anchor_snapped ? color_snapped : color_base, (i == dragged_anchor || (i + 3) % 4 == dragged_anchor) ? 2 : 1); } diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index af34dd5cab..17eaa06d57 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -268,7 +268,7 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) { real_t factor = (1.0 / inertia) * p_interp_delta; // We interpolate a different point here, because in freelook mode the focus point (cursor.pos) orbits around eye_pos - camera_cursor.eye_pos = old_camera_cursor.eye_pos.linear_interpolate(cursor.eye_pos, CLAMP(factor, 0, 1)); + camera_cursor.eye_pos = old_camera_cursor.eye_pos.lerp(cursor.eye_pos, CLAMP(factor, 0, 1)); float orbit_inertia = EDITOR_GET("editors/3d/navigation_feel/orbit_inertia"); orbit_inertia = MAX(0.0001, orbit_inertia); @@ -318,7 +318,7 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) { camera_cursor.y_rot = cursor.y_rot; } - camera_cursor.pos = old_camera_cursor.pos.linear_interpolate(cursor.pos, MIN(1.f, p_interp_delta * (1 / translation_inertia))); + camera_cursor.pos = old_camera_cursor.pos.lerp(cursor.pos, MIN(1.f, p_interp_delta * (1 / translation_inertia))); camera_cursor.distance = Math::lerp(old_camera_cursor.distance, cursor.distance, MIN(1.f, p_interp_delta * (1 / zoom_inertia))); } } @@ -2166,7 +2166,7 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const _menu_option(VIEW_PERSPECTIVE); } - real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/navigation_feel/orbit_sensitivity"); + real_t degrees_per_pixel = EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_sensitivity"); real_t radians_per_pixel = Math::deg2rad(degrees_per_pixel); bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis"); @@ -4570,10 +4570,10 @@ void Node3DEditor::_generate_selection_box() { st->add_color(Color(1.0, 1.0, 0.8, 0.8)); st->add_vertex(a); st->add_color(Color(1.0, 1.0, 0.8, 0.4)); - st->add_vertex(a.linear_interpolate(b, 0.2)); + st->add_vertex(a.lerp(b, 0.2)); st->add_color(Color(1.0, 1.0, 0.8, 0.4)); - st->add_vertex(a.linear_interpolate(b, 0.8)); + st->add_vertex(a.lerp(b, 0.8)); st->add_color(Color(1.0, 1.0, 0.8, 0.8)); st->add_vertex(b); } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 7af98cf346..35a08f2d1c 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1742,7 +1742,7 @@ void ScriptEditor::_update_script_colors() { int non_zero_hist_size = (hist_size == 0) ? 1 : hist_size; float v = Math::ease((edit_pass - pass) / float(non_zero_hist_size), 0.4); - script_list->set_item_custom_fg_color(i, hot_color.linear_interpolate(cold_color, v)); + script_list->set_item_custom_fg_color(i, hot_color.lerp(cold_color, v)); } } } @@ -1866,6 +1866,10 @@ void ScriptEditor::_update_script_names() { if (new_cur_tab == -1 && sedata[i].index == cur_tab) { new_cur_tab = i; } + // Update index of sd entries for sorted order + _ScriptEditorItemData sd = sedata[i]; + sd.index = i; + sedata.set(i, sd); } tab_container->set_current_tab(new_prev_tab); tab_container->set_current_tab(new_cur_tab); diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 1b4439f0a8..b872bc3dd4 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -113,12 +113,18 @@ void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) { float EditorQuickOpen::_path_cmp(String search, String path) const { + // Exact match. if (search == path) { return 1.2f; } - if (path.findn(search) != -1) { - return 1.1f; + + // Substring match, with positive bias for matches close to the end of the path. + int pos = path.rfindn(search); + if (pos != -1) { + return 1.1f + 0.09 / (path.length() - pos + 1); } + + // Similarity. return path.to_lower().similarity(search.to_lower()); } diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 0266ef6a2b..8ae8d0991d 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -403,7 +403,7 @@ void RenameDialog::_update_preview(String new_text) { // New name is identical to the old one. Don't color it as much to avoid distracting the user. const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor"); const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("default_color", "RichTextLabel"); - lbl_preview->add_theme_color_override("font_color", accent_color.linear_interpolate(text_color, 0.5)); + lbl_preview->add_theme_color_override("font_color", accent_color.lerp(text_color, 0.5)); } else { lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); } diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub index 6f64edce3d..b853ebfc63 100644 --- a/modules/bullet/SCsub +++ b/modules/bullet/SCsub @@ -204,6 +204,8 @@ if env["builtin_bullet"]: # if env['target'] == "debug" or env['target'] == "release_debug": # env_bullet.Append(CPPDEFINES=['BT_DEBUG']) + env_bullet.Append(CPPDEFINES=["BT_USE_OLD_DAMPING_METHOD"]) + env_thirdparty = env_bullet.Clone() env_thirdparty.disable_warnings() env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources) diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index a4f9affa95..e393396713 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -503,15 +503,18 @@ void RigidBodyBullet::set_param(PhysicsServer3D::BodyParameter p_param, real_t p } case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: linearDamp = p_value; - btBody->setDamping(linearDamp, angularDamp); + // Mark for updating total linear damping. + scratch_space_override_modificator(); break; case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: angularDamp = p_value; - btBody->setDamping(linearDamp, angularDamp); + // Mark for updating total angular damping. + scratch_space_override_modificator(); break; case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: gravity_scale = p_value; - /// The Bullet gravity will be is set by reload_space_override_modificator + // The Bullet gravity will be is set by reload_space_override_modificator. + // Mark for updating total gravity scale. scratch_space_override_modificator(); break; default: @@ -902,21 +905,20 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) { } void RigidBodyBullet::reload_space_override_modificator() { - // Make sure that kinematic bodies have their total gravity calculated if (!is_active() && PhysicsServer3D::BODY_MODE_KINEMATIC != mode) return; - Vector3 newGravity(space->get_gravity_direction() * space->get_gravity_magnitude()); - real_t newLinearDamp(linearDamp); - real_t newAngularDamp(angularDamp); + Vector3 newGravity(0.0, 0.0, 0.0); + real_t newLinearDamp = MAX(0.0, linearDamp); + real_t newAngularDamp = MAX(0.0, angularDamp); AreaBullet *currentArea; // Variable used to calculate new gravity for gravity point areas, it is pointed by currentGravity pointer Vector3 support_gravity(0, 0, 0); - int countCombined(0); - for (int i = areaWhereIamCount - 1; 0 <= i; --i) { + bool stopped = false; + for (int i = areaWhereIamCount - 1; (0 <= i) && !stopped; --i) { currentArea = areasWhereIam[i]; @@ -965,7 +967,6 @@ void RigidBodyBullet::reload_space_override_modificator() { newGravity += support_gravity; newLinearDamp += currentArea->get_spOv_linearDamp(); newAngularDamp += currentArea->get_spOv_angularDamp(); - ++countCombined; break; case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: /// This area adds its gravity/damp values to whatever has been calculated @@ -974,32 +975,31 @@ void RigidBodyBullet::reload_space_override_modificator() { newGravity += support_gravity; newLinearDamp += currentArea->get_spOv_linearDamp(); newAngularDamp += currentArea->get_spOv_angularDamp(); - ++countCombined; - goto endAreasCycle; + stopped = true; + break; case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE: /// This area replaces any gravity/damp, even the default one, and /// stops taking into account the rest of the areas. newGravity = support_gravity; newLinearDamp = currentArea->get_spOv_linearDamp(); newAngularDamp = currentArea->get_spOv_angularDamp(); - countCombined = 1; - goto endAreasCycle; + stopped = true; + break; case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: /// This area replaces any gravity/damp calculated so far, but keeps /// calculating the rest of the areas, down to the default one. newGravity = support_gravity; newLinearDamp = currentArea->get_spOv_linearDamp(); newAngularDamp = currentArea->get_spOv_angularDamp(); - countCombined = 1; break; } } -endAreasCycle: - if (1 < countCombined) { - newGravity /= countCombined; - newLinearDamp /= countCombined; - newAngularDamp /= countCombined; + // Add default gravity and damping from space. + if (!stopped) { + newGravity += space->get_gravity_direction() * space->get_gravity_magnitude(); + newLinearDamp += space->get_linear_damp(); + newAngularDamp += space->get_angular_damp(); } btVector3 newBtGravity; diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 1659664ff9..d49e635fd5 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -342,6 +342,8 @@ SpaceBullet::SpaceBullet() : godotFilterCallback(nullptr), gravityDirection(0, -1, 0), gravityMagnitude(10), + linear_damp(0.0), + angular_damp(0.0), contactDebugCount(0), delta_time(0.) { @@ -379,8 +381,11 @@ void SpaceBullet::set_param(PhysicsServer3D::AreaParameter p_param, const Varian update_gravity(); break; case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: + linear_damp = p_value; + break; case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: - break; // No damp + angular_damp = p_value; + break; case PhysicsServer3D::AREA_PARAM_PRIORITY: // Priority is always 0, the lower break; @@ -401,8 +406,9 @@ Variant SpaceBullet::get_param(PhysicsServer3D::AreaParameter p_param) { case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: return gravityDirection; case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: + return linear_damp; case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: - return 0; // No damp + return angular_damp; case PhysicsServer3D::AREA_PARAM_PRIORITY: return 0; // Priority is always 0, the lower case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index f9a8c063fd..3d4a2aeceb 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -108,6 +108,9 @@ class SpaceBullet : public RIDBullet { Vector3 gravityDirection; real_t gravityMagnitude; + real_t linear_damp; + real_t angular_damp; + Vector<AreaBullet *> areas; Vector<Vector3> contactDebug; @@ -177,6 +180,9 @@ public: void update_gravity(); + real_t get_linear_damp() const { return linear_damp; } + real_t get_angular_damp() const { return angular_damp; } + bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes); int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin); diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 3f61e2852f..6714db76bb 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -50,7 +50,7 @@ inline static Vector2 interpolate_segment_uv(const Vector2 p_segement_points[2], float distance = (p_interpolation_point - p_segement_points[0]).length(); float fraction = distance / segment_length; - return p_uvs[0].linear_interpolate(p_uvs[1], fraction); + return p_uvs[0].lerp(p_uvs[1], fraction); } inline static Vector2 interpolate_triangle_uv(const Vector2 p_vertices[3], const Vector2 p_uvs[3], const Vector2 &p_interpolation_point) { diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp index 914d5b03f4..68c83e05a6 100644 --- a/modules/gdnative/gdnative/color.cpp +++ b/modules/gdnative/gdnative/color.cpp @@ -155,11 +155,11 @@ godot_color GDAPI godot_color_contrasted(const godot_color *p_self) { return dest; } -godot_color GDAPI godot_color_linear_interpolate(const godot_color *p_self, const godot_color *p_b, const godot_real p_t) { +godot_color GDAPI godot_color_lerp(const godot_color *p_self, const godot_color *p_b, const godot_real p_t) { godot_color dest; const Color *self = (const Color *)p_self; const Color *b = (const Color *)p_b; - *((Color *)&dest) = self->linear_interpolate(*b, p_t); + *((Color *)&dest) = self->lerp(*b, p_t); return dest; } diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp index e9e2a8edf8..dc273e7951 100644 --- a/modules/gdnative/gdnative/vector2.cpp +++ b/modules/gdnative/gdnative/vector2.cpp @@ -109,11 +109,11 @@ godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_self, const return self->angle_to_point(*to); } -godot_vector2 GDAPI godot_vector2_linear_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t) { +godot_vector2 GDAPI godot_vector2_lerp(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t) { godot_vector2 dest; const Vector2 *self = (const Vector2 *)p_self; const Vector2 *b = (const Vector2 *)p_b; - *((Vector2 *)&dest) = self->linear_interpolate(*b, p_t); + *((Vector2 *)&dest) = self->lerp(*b, p_t); return dest; } diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp index e34a9370a5..bb27ad5a00 100644 --- a/modules/gdnative/gdnative/vector3.cpp +++ b/modules/gdnative/gdnative/vector3.cpp @@ -106,11 +106,11 @@ godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_self, const god return dest; } -godot_vector3 GDAPI godot_vector3_linear_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t) { +godot_vector3 GDAPI godot_vector3_lerp(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t) { godot_vector3 dest; const Vector3 *self = (const Vector3 *)p_self; const Vector3 *b = (const Vector3 *)p_b; - *((Vector3 *)&dest) = self->linear_interpolate(*b, p_t); + *((Vector3 *)&dest) = self->lerp(*b, p_t); return dest; } diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 9473a3d419..d5ab62dc61 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -586,7 +586,7 @@ ] }, { - "name": "godot_color_linear_interpolate", + "name": "godot_color_lerp", "return_type": "godot_color", "arguments": [ ["const godot_color *", "p_self"], @@ -710,7 +710,7 @@ ] }, { - "name": "godot_vector2_linear_interpolate", + "name": "godot_vector2_lerp", "return_type": "godot_vector2", "arguments": [ ["const godot_vector2 *", "p_self"], @@ -1449,7 +1449,7 @@ ] }, { - "name": "godot_vector3_linear_interpolate", + "name": "godot_vector3_lerp", "return_type": "godot_vector3", "arguments": [ ["const godot_vector3 *", "p_self"], diff --git a/modules/gdnative/include/gdnative/color.h b/modules/gdnative/include/gdnative/color.h index 47c01dbb20..e7737bf8e1 100644 --- a/modules/gdnative/include/gdnative/color.h +++ b/modules/gdnative/include/gdnative/color.h @@ -95,7 +95,7 @@ godot_color GDAPI godot_color_inverted(const godot_color *p_self); godot_color GDAPI godot_color_contrasted(const godot_color *p_self); -godot_color GDAPI godot_color_linear_interpolate(const godot_color *p_self, const godot_color *p_b, const godot_real p_t); +godot_color GDAPI godot_color_lerp(const godot_color *p_self, const godot_color *p_b, const godot_real p_t); godot_color GDAPI godot_color_blend(const godot_color *p_self, const godot_color *p_over); diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h index 15a1a6063b..c11e23a586 100644 --- a/modules/gdnative/include/gdnative/vector2.h +++ b/modules/gdnative/include/gdnative/vector2.h @@ -81,7 +81,7 @@ godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_self, const godot godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_self, const godot_vector2 *p_to); -godot_vector2 GDAPI godot_vector2_linear_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t); +godot_vector2 GDAPI godot_vector2_lerp(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t); godot_vector2 GDAPI godot_vector2_cubic_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_vector2 *p_pre_a, const godot_vector2 *p_post_b, const godot_real p_t); diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h index 1b344590ea..8ebf15b724 100644 --- a/modules/gdnative/include/gdnative/vector3.h +++ b/modules/gdnative/include/gdnative/vector3.h @@ -86,7 +86,7 @@ godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const god godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_self, const godot_vector3 *p_axis, const godot_real p_phi); -godot_vector3 GDAPI godot_vector3_linear_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t); +godot_vector3 GDAPI godot_vector3_lerp(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t); godot_vector3 GDAPI godot_vector3_cubic_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_vector3 *p_pre_a, const godot_vector3 *p_post_b, const godot_real p_t); diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 9324691df5..be159b6407 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -568,7 +568,7 @@ <description> Linearly interpolates between two values by a normalized value. This is the opposite of [method inverse_lerp]. If the [code]from[/code] and [code]to[/code] arguments are of type [int] or [float], the return value is a [float]. - If both are of the same vector type ([Vector2], [Vector3] or [Color]), the return value will be of the same type ([code]lerp[/code] then calls the vector type's [code]linear_interpolate[/code] method). + If both are of the same vector type ([Vector2], [Vector3] or [Color]), the return value will be of the same type ([code]lerp[/code] then calls the vector type's [code]lerp[/code] method). [codeblock] lerp(0, 4, 0.75) # Returns 3.0 lerp(Vector2(1, 5), Vector2(3, 2), 0.5) # Returns Vector2(2, 3.5) diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index 9154d6eb89..58161d6f53 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -362,13 +362,13 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ const double t = (double)*p_args[2]; switch (p_args[0]->get_type() == p_args[1]->get_type() ? p_args[0]->get_type() : Variant::FLOAT) { case Variant::VECTOR2: { - r_ret = ((Vector2)*p_args[0]).linear_interpolate((Vector2)*p_args[1], t); + r_ret = ((Vector2)*p_args[0]).lerp((Vector2)*p_args[1], t); } break; case Variant::VECTOR3: { - r_ret = (p_args[0]->operator Vector3()).linear_interpolate(p_args[1]->operator Vector3(), t); + r_ret = (p_args[0]->operator Vector3()).lerp(p_args[1]->operator Vector3(), t); } break; case Variant::COLOR: { - r_ret = ((Color)*p_args[0]).linear_interpolate((Color)*p_args[1], t); + r_ret = ((Color)*p_args[0]).lerp((Color)*p_args[1], t); } break; default: { VALIDATE_ARG_NUM(0); diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index ee92a6234a..bdf9cf965f 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -566,8 +566,12 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf code_tag = true; pos = brk_end + 1; tag_stack.push_front(tag); + } else if (tag == "kbd") { + // keyboard combinations are not supported in xml comments + pos = brk_end + 1; + tag_stack.push_front(tag); } else if (tag == "center") { - // center is alignment not supported in xml comments + // center alignment is not supported in xml comments pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "br") { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs index 1d1a49945f..facaf74606 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs @@ -306,16 +306,26 @@ namespace Godot return res; } - public Color LinearInterpolate(Color c, float t) - { - var res = this; - - res.r += t * (c.r - r); - res.g += t * (c.g - g); - res.b += t * (c.b - b); - res.a += t * (c.a - a); + public Color Lerp(Color to, float weight) + { + return new Color + ( + Mathf.Lerp(r, to.r, weight), + Mathf.Lerp(g, to.g, weight), + Mathf.Lerp(b, to.b, weight), + Mathf.Lerp(a, to.a, weight) + ); + } - return res; + public Color Lerp(Color to, Color weight) + { + return new Color + ( + Mathf.Lerp(r, to.r, weight.r), + Mathf.Lerp(g, to.g, weight.g), + Mathf.Lerp(b, to.b, weight.b), + Mathf.Lerp(a, to.a, weight.a) + ); } public uint ToAbgr32() diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs index aa8815d1aa..6a58b90561 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs @@ -104,8 +104,8 @@ namespace Godot Vector3 destinationLocation = transform.origin; var interpolated = new Transform(); - interpolated.basis.SetQuatScale(sourceRotation.Slerp(destinationRotation, c).Normalized(), sourceScale.LinearInterpolate(destinationScale, c)); - interpolated.origin = sourceLocation.LinearInterpolate(destinationLocation, c); + interpolated.basis.SetQuatScale(sourceRotation.Slerp(destinationRotation, c).Normalized(), sourceScale.Lerp(destinationScale, c)); + interpolated.origin = sourceLocation.Lerp(destinationLocation, c); return interpolated; } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs index e72a44809a..3ae96d4922 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs @@ -172,7 +172,7 @@ namespace Godot if (dot > 0.9995f) { // Linearly interpolate to avoid numerical precision issues - v = v1.LinearInterpolate(v2, c).Normalized(); + v = v1.Lerp(v2, c).Normalized(); } else { @@ -186,8 +186,8 @@ namespace Godot Vector2 p2 = m.origin; // Construct matrix - var res = new Transform2D(Mathf.Atan2(v.y, v.x), p1.LinearInterpolate(p2, c)); - Vector2 scale = s1.LinearInterpolate(s2, c); + var res = new Transform2D(Mathf.Atan2(v.y, v.x), p1.Lerp(p2, c)); + Vector2 scale = s1.Lerp(s2, c); res.x *= scale; res.y *= scale; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index f7b13198f8..7e4804f9fd 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -186,14 +186,22 @@ namespace Godot return x * x + y * y; } - public Vector2 LinearInterpolate(Vector2 b, real_t t) + public Vector2 Lerp(Vector2 to, real_t weight) { - var res = this; - - res.x += t * (b.x - x); - res.y += t * (b.y - y); + return new Vector2 + ( + Mathf.Lerp(x, to.x, weight), + Mathf.Lerp(y, to.y, weight) + ); + } - return res; + public Vector2 Lerp(Vector2 to, Vector2 weight) + { + return new Vector2 + ( + Mathf.Lerp(x, to.x, weight.x), + Mathf.Lerp(y, to.y, weight.y) + ); } public Vector2 MoveToward(Vector2 to, real_t delta) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index a43836e985..b26e17ecba 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -184,13 +184,23 @@ namespace Godot return x2 + y2 + z2; } - public Vector3 LinearInterpolate(Vector3 b, real_t t) + public Vector3 Lerp(Vector3 to, real_t weight) { return new Vector3 ( - x + t * (b.x - x), - y + t * (b.y - y), - z + t * (b.z - z) + Mathf.Lerp(x, to.x, weight), + Mathf.Lerp(y, to.y, weight), + Mathf.Lerp(z, to.z, weight) + ); + } + + public Vector3 Lerp(Vector3 to, Vector3 weight) + { + return new Vector3 + ( + Mathf.Lerp(x, to.x, weight.x), + Mathf.Lerp(y, to.y, weight.y), + Mathf.Lerp(z, to.z, weight.z) ); } diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 22790a3fe5..e38b0c13d0 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -3606,8 +3606,10 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode } } #endif - - WindowID main_window = _create_window(p_mode, p_flags, Rect2i(Point2(), p_resolution)); + Point2i window_position( + (screen_get_size(0).width - p_resolution.width) / 2, + (screen_get_size(0).height - p_resolution.height) / 2); + WindowID main_window = _create_window(p_mode, p_flags, Rect2i(window_position, p_resolution)); for (int i = 0; i < WINDOW_FLAG_MAX; i++) { if (p_flags & (1 << i)) { window_set_flag(WindowFlags(i), true, main_window); diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index a44bfef94c..9d92992332 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -3528,7 +3528,10 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode } #endif - WindowID main_window = _create_window(p_mode, Rect2i(Point2i(), p_resolution)); + Point2i window_position( + (screen_get_size(0).width - p_resolution.width) / 2, + (screen_get_size(0).height - p_resolution.height) / 2); + WindowID main_window = _create_window(p_mode, Rect2i(window_position, p_resolution)); for (int i = 0; i < WINDOW_FLAG_MAX; i++) { if (p_flags & (1 << i)) { window_set_flag(WindowFlags(i), true, main_window); diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 4d4273a073..e4fe7f04d0 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -2897,7 +2897,10 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } } #endif - WindowID main_window = _create_window(p_mode, 0, Rect2i(Point2i(), p_resolution)); + Point2i window_position( + (screen_get_size(0).width - p_resolution.width) / 2, + (screen_get_size(0).height - p_resolution.height) / 2); + WindowID main_window = _create_window(p_mode, 0, Rect2i(window_position, p_resolution)); for (int i = 0; i < WINDOW_FLAG_MAX; i++) { if (p_flags & (1 << i)) { window_set_flag(WindowFlags(i), true, main_window); diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 097368853e..28a8b01437 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -556,7 +556,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { for (int i = 0; i < vol_index_max; i++) { - output.reverb_vol[i] = output.reverb_vol[i].linear_interpolate(center_frame, attenuation); + output.reverb_vol[i] = output.reverb_vol[i].lerp(center_frame, attenuation); } } else { for (int i = 0; i < vol_index_max; i++) { @@ -567,7 +567,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { for (int i = 0; i < vol_index_max; i++) { - output.reverb_vol[i] = output.vol[i].linear_interpolate(output.reverb_vol[i] * attenuation, uniformity); + output.reverb_vol[i] = output.vol[i].lerp(output.reverb_vol[i] * attenuation, uniformity); output.reverb_vol[i] *= area_send; } diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp index 7366290ed3..e8a9d5bf57 100644 --- a/scene/3d/skeleton_ik_3d.cpp +++ b/scene/3d/skeleton_ik_3d.cpp @@ -294,7 +294,7 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove update_chain(p_task->skeleton, &p_task->chain.chain_root); if (p_use_magnet && p_task->chain.middle_chain_item) { - p_task->chain.magnet_position = p_task->chain.middle_chain_item->initial_transform.origin.linear_interpolate(p_magnet_position, blending_delta); + p_task->chain.magnet_position = p_task->chain.middle_chain_item->initial_transform.origin.lerp(p_magnet_position, blending_delta); solve_simple(p_task, true); } solve_simple(p_task, false); diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 946f759610..9ef6b9864a 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -395,9 +395,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } else { - nc->loc_accum = nc->loc_accum.linear_interpolate(loc, p_interp); + nc->loc_accum = nc->loc_accum.lerp(loc, p_interp); nc->rot_accum = nc->rot_accum.slerp(rot, p_interp); - nc->scale_accum = nc->scale_accum.linear_interpolate(scale, p_interp); + nc->scale_accum = nc->scale_accum.lerp(scale, p_interp); } } break; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index f8b3ca291b..56e224819f 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -958,7 +958,7 @@ void AnimationTree::_process_graph(float p_delta) { if (err != OK) continue; - t->loc = t->loc.linear_interpolate(loc, blend); + t->loc = t->loc.lerp(loc, blend); if (t->rot_blend_accum == 0) { t->rot = rot; t->rot_blend_accum = blend; @@ -967,7 +967,7 @@ void AnimationTree::_process_graph(float p_delta) { t->rot = rot.slerp(t->rot, t->rot_blend_accum / rot_total).normalized(); t->rot_blend_accum = rot_total; } - t->scale = t->scale.linear_interpolate(scale, blend); + t->scale = t->scale.lerp(scale, blend); } } break; diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 88107f754c..a6ed3d8de9 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -207,7 +207,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { prev = points[pos]; } - newPoint.color = prev.color.linear_interpolate(next.color, (newPoint.offset - prev.offset) / (next.offset - prev.offset)); + newPoint.color = prev.color.lerp(next.color, (newPoint.offset - prev.offset) / (next.offset - prev.offset)); points.push_back(newPoint); points.sort(); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 3af730de23..0bf67df9b4 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -653,7 +653,7 @@ void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors, if (p_depth >= p_min_depth && (dp < p_tol || p_depth >= p_max_depth)) { points.push_back((beg + end) * 0.5); - colors.push_back(p_color.linear_interpolate(p_to_color, mp)); + colors.push_back(p_color.lerp(p_to_color, mp)); lines++; } else { _bake_segment2d(points, colors, p_begin, mp, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines); @@ -737,8 +737,8 @@ void GraphEdit::_connections_layer_draw() { Color tocolor = gto->get_connection_input_color(E->get().to_port); if (E->get().activity > 0) { - color = color.linear_interpolate(activity_color, E->get().activity); - tocolor = tocolor.linear_interpolate(activity_color, E->get().activity); + color = color.lerp(activity_color, E->get().activity); + tocolor = tocolor.lerp(activity_color, E->get().activity); } _draw_cos_line(connections_layer, frompos, topos, color, tocolor); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index c83ca6f73d..9ee7456d26 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1064,11 +1064,6 @@ void TextEdit::_notification(int p_what) { break; } - // re-adjust if we went backwards. - if (color != previous_color && !is_whitespace) { - characters++; - } - if (str[j] == '\t') { tabs += minimap_tab_size; } @@ -6220,6 +6215,10 @@ void TextEdit::_push_current_op() { current_op.type = TextOperation::TYPE_NONE; current_op.text = ""; current_op.chain_forward = false; + + if (undo_stack.size() > undo_stack_max_size) { + undo_stack.pop_front(); + } } void TextEdit::set_indent_using_spaces(const bool p_use_spaces) { @@ -7244,6 +7243,8 @@ void TextEdit::_bind_methods() { GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec", 3); ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/text_edit_idle_detect_sec", PropertyInfo(Variant::FLOAT, "gui/timers/text_edit_idle_detect_sec", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater")); // No negative numbers. + GLOBAL_DEF("gui/common/text_edit_undo_stack_max_size", 1024); + ProjectSettings::get_singleton()->set_custom_property_info("gui/common/text_edit_undo_stack_max_size", PropertyInfo(Variant::INT, "gui/common/text_edit_undo_stack_max_size", PROPERTY_HINT_RANGE, "0,10000,1,or_greater")); // No negative numbers. } TextEdit::TextEdit() { @@ -7323,6 +7324,7 @@ TextEdit::TextEdit() { current_op.type = TextOperation::TYPE_NONE; undo_enabled = true; + undo_stack_max_size = GLOBAL_GET("gui/common/text_edit_undo_stack_max_size"); undo_stack_pos = nullptr; setting_text = false; last_dblclk = 0; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index ef8c39d32f..ac8eb5da1d 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -306,6 +306,7 @@ private: List<TextOperation> undo_stack; List<TextOperation>::Element *undo_stack_pos; + int undo_stack_max_size; void _clear_redo(); void _do_text_op(const TextOperation &p_op, bool p_reverse); diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index aa4c9bf225..ea4338519e 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1570,7 +1570,7 @@ Animation::TransformKey Animation::_interpolate(const Animation::TransformKey &p Vector3 Animation::_interpolate(const Vector3 &p_a, const Vector3 &p_b, float p_c) const { - return p_a.linear_interpolate(p_b, p_c); + return p_a.lerp(p_b, p_c); } Quat Animation::_interpolate(const Quat &p_a, const Quat &p_b, float p_c) const { @@ -2432,7 +2432,7 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const { Vector2 high_pos = _bezier_interp(high, start, start_out, end_in, end); float c = (t - low_pos.x) / (high_pos.x - low_pos.x); - return low_pos.linear_interpolate(high_pos, c).y; + return low_pos.lerp(high_pos, c).y; } int Animation::audio_track_insert_key(int p_track, float p_time, const RES &p_stream, float p_start_offset, float p_end_offset) { diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index d19eae0d4f..ae705a47e8 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -796,7 +796,7 @@ Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const { Vector2 post = (idx < (bpc - 2)) ? r[idx + 2] : r[idx + 1]; return r[idx].cubic_interpolate(r[idx + 1], pre, post, frac); } else { - return r[idx].linear_interpolate(r[idx + 1], frac); + return r[idx].lerp(r[idx + 1], frac); } } @@ -1354,7 +1354,7 @@ Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const { Vector3 post = (idx < (bpc - 2)) ? r[idx + 2] : r[idx + 1]; return r[idx].cubic_interpolate(r[idx + 1], pre, post, frac); } else { - return r[idx].linear_interpolate(r[idx + 1], frac); + return r[idx].lerp(r[idx + 1], frac); } } diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h index 2d98f799e2..573749ea7e 100644 --- a/scene/resources/gradient.h +++ b/scene/resources/gradient.h @@ -120,7 +120,7 @@ public: return points[0].color; const Point &pointFirst = points[first]; const Point &pointSecond = points[second]; - return pointFirst.color.linear_interpolate(pointSecond.color, (p_offset - pointFirst.offset) / (pointSecond.offset - pointFirst.offset)); + return pointFirst.color.lerp(pointSecond.color, (p_offset - pointFirst.offset) / (pointSecond.offset - pointFirst.offset)); } int get_points_count() const; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index f431a2ad48..d57af29599 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -1692,15 +1692,20 @@ void AnimatedTexture::_update_proxy() { } int iter_max = frame_count; - while (iter_max) { + while (iter_max && !pause) { float frame_limit = limit + frames[current_frame].delay_sec; if (time > frame_limit) { current_frame++; if (current_frame >= frame_count) { - current_frame = 0; + if (oneshot) { + current_frame = frame_count - 1; + } else { + current_frame = 0; + } } time -= frame_limit; + _change_notify("current_frame"); } else { break; } @@ -1723,6 +1728,33 @@ int AnimatedTexture::get_frames() const { return frame_count; } +void AnimatedTexture::set_current_frame(int p_frame) { + ERR_FAIL_COND(p_frame < 0 || p_frame >= frame_count); + + RWLockWrite r(rw_lock); + + current_frame = p_frame; +} +int AnimatedTexture::get_current_frame() const { + return current_frame; +} + +void AnimatedTexture::set_pause(bool p_pause) { + RWLockWrite r(rw_lock); + pause = p_pause; +} +bool AnimatedTexture::get_pause() const { + return pause; +} + +void AnimatedTexture::set_oneshot(bool p_oneshot) { + RWLockWrite r(rw_lock); + oneshot = p_oneshot; +} +bool AnimatedTexture::get_oneshot() const { + return oneshot; +} + void AnimatedTexture::set_frame_texture(int p_frame, const Ref<Texture2D> &p_texture) { ERR_FAIL_COND(p_texture == this); @@ -1833,6 +1865,15 @@ void AnimatedTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_frames", "frames"), &AnimatedTexture::set_frames); ClassDB::bind_method(D_METHOD("get_frames"), &AnimatedTexture::get_frames); + ClassDB::bind_method(D_METHOD("set_current_frame", "frame"), &AnimatedTexture::set_current_frame); + ClassDB::bind_method(D_METHOD("get_current_frame"), &AnimatedTexture::get_current_frame); + + ClassDB::bind_method(D_METHOD("set_pause", "pause"), &AnimatedTexture::set_pause); + ClassDB::bind_method(D_METHOD("get_pause"), &AnimatedTexture::get_pause); + + ClassDB::bind_method(D_METHOD("set_oneshot", "oneshot"), &AnimatedTexture::set_oneshot); + ClassDB::bind_method(D_METHOD("get_oneshot"), &AnimatedTexture::get_oneshot); + ClassDB::bind_method(D_METHOD("set_fps", "fps"), &AnimatedTexture::set_fps); ClassDB::bind_method(D_METHOD("get_fps"), &AnimatedTexture::get_fps); @@ -1843,6 +1884,9 @@ void AnimatedTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("get_frame_delay", "frame"), &AnimatedTexture::get_frame_delay); ADD_PROPERTY(PropertyInfo(Variant::INT, "frames", PROPERTY_HINT_RANGE, "1," + itos(MAX_FRAMES), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_frames", "get_frames"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "current_frame", PROPERTY_HINT_NONE, "", 0), "set_current_frame", "get_current_frame"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pause"), "set_pause", "get_pause"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "oneshot"), "set_oneshot", "get_oneshot"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fps", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_fps", "get_fps"); for (int i = 0; i < MAX_FRAMES; i++) { @@ -1864,6 +1908,8 @@ AnimatedTexture::AnimatedTexture() { fps = 4; prev_ticks = 0; current_frame = 0; + pause = false; + oneshot = false; RenderingServer::get_singleton()->connect("frame_pre_draw", callable_mp(this, &AnimatedTexture::_update_proxy)); #ifndef NO_THREADS diff --git a/scene/resources/texture.h b/scene/resources/texture.h index f4f00c2ca0..5d5f438eba 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -567,7 +567,8 @@ private: Frame frames[MAX_FRAMES]; int frame_count; int current_frame; - + bool pause; + bool oneshot; float fps; float time; @@ -584,6 +585,15 @@ public: void set_frames(int p_frames); int get_frames() const; + void set_current_frame(int p_frame); + int get_current_frame() const; + + void set_pause(bool p_pause); + bool get_pause() const; + + void set_oneshot(bool p_oneshot); + bool get_oneshot() const; + void set_frame_texture(int p_frame, const Ref<Texture2D> &p_texture); Ref<Texture2D> get_frame_texture(int p_frame) const; diff --git a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp index 0689429014..c2bd41a746 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp @@ -131,7 +131,6 @@ Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_ima image->convert(Image::FORMAT_RGBAF); } - r_format.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R; r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G; r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B; @@ -171,7 +170,6 @@ Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_ima image->convert(Image::FORMAT_RGBAH); } - r_format.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R; r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G; r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B; @@ -5063,10 +5061,10 @@ void RasterizerStorageRD::_global_variable_store_in_buffer(int32_t p_index, RS:: bv[2].z = v.basis.elements[2][2]; bv[2].w = 0; - bv[2].x = v.origin.x; - bv[2].y = v.origin.y; - bv[2].z = v.origin.z; - bv[2].w = 1; + bv[3].x = v.origin.x; + bv[3].y = v.origin.y; + bv[3].z = v.origin.z; + bv[3].w = 1; } break; default: { diff --git a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp index 9cbff2571a..d4e6576125 100644 --- a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp +++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp @@ -650,18 +650,19 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge index++; } - for (Map<StringName, SL::ShaderNode::Constant>::Element *E = pnode->constants.front(); E; E = E->next()) { + for (int i = 0; i < pnode->vconstants.size(); i++) { + const SL::ShaderNode::Constant &cnode = pnode->vconstants[i]; String gcode; gcode += "const "; - gcode += _prestr(E->get().precision); - if (E->get().type == SL::TYPE_STRUCT) { - gcode += _mkid(E->get().type_str); + gcode += _prestr(cnode.precision); + if (cnode.type == SL::TYPE_STRUCT) { + gcode += _mkid(cnode.type_str); } else { - gcode += _typestr(E->get().type); + gcode += _typestr(cnode.type); } - gcode += " " + _mkid(E->key()); + gcode += " " + _mkid(String(cnode.name)); gcode += "="; - gcode += _dump_node_code(E->get().initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); + gcode += _dump_node_code(cnode.initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); gcode += ";\n"; r_gen_code.vertex_global += gcode; r_gen_code.fragment_global += gcode; diff --git a/servers/rendering/rendering_server_scene.cpp b/servers/rendering/rendering_server_scene.cpp index 9d141ea570..337eb5995f 100644 --- a/servers/rendering/rendering_server_scene.cpp +++ b/servers/rendering/rendering_server_scene.cpp @@ -1348,15 +1348,15 @@ _FORCE_INLINE_ static void _light_capture_sample_octree(const RasterizerStorage: for (int i = 0; i < 2; i++) { - Vector3 color_x00 = color[i][0].linear_interpolate(color[i][1], pos_fract[i].x); - Vector3 color_xy0 = color[i][2].linear_interpolate(color[i][3], pos_fract[i].x); - Vector3 blend_z0 = color_x00.linear_interpolate(color_xy0, pos_fract[i].y); + Vector3 color_x00 = color[i][0].lerp(color[i][1], pos_fract[i].x); + Vector3 color_xy0 = color[i][2].lerp(color[i][3], pos_fract[i].x); + Vector3 blend_z0 = color_x00.lerp(color_xy0, pos_fract[i].y); - Vector3 color_x0z = color[i][4].linear_interpolate(color[i][5], pos_fract[i].x); - Vector3 color_xyz = color[i][6].linear_interpolate(color[i][7], pos_fract[i].x); - Vector3 blend_z1 = color_x0z.linear_interpolate(color_xyz, pos_fract[i].y); + Vector3 color_x0z = color[i][4].lerp(color[i][5], pos_fract[i].x); + Vector3 color_xyz = color[i][6].lerp(color[i][7], pos_fract[i].x); + Vector3 blend_z1 = color_x0z.lerp(color_xyz, pos_fract[i].y); - color_interp[i] = blend_z0.linear_interpolate(blend_z1, pos_fract[i].z); + color_interp[i] = blend_z0.lerp(blend_z1, pos_fract[i].z); float alpha_x00 = Math::lerp(alpha[i][0], alpha[i][1], pos_fract[i].x); float alpha_xy0 = Math::lerp(alpha[i][2], alpha[i][3], pos_fract[i].x); @@ -1369,7 +1369,7 @@ _FORCE_INLINE_ static void _light_capture_sample_octree(const RasterizerStorage: alpha_interp[i] = Math::lerp(alpha_z0, alpha_z1, pos_fract[i].z); } - r_color = color_interp[0].linear_interpolate(color_interp[1], level_filter); + r_color = color_interp[0].lerp(color_interp[1], level_filter); r_alpha = Math::lerp(alpha_interp[0], alpha_interp[1], level_filter); //print_line("pos: " + p_posf + " level " + rtos(p_level) + " down to " + itos(target_level) + "." + rtos(level_filter) + " color " + r_color + " alpha " + rtos(r_alpha)); diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index bec0958f71..93593effd4 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -6334,6 +6334,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct while (true) { ShaderNode::Constant constant; + constant.name = name; constant.type = is_struct ? TYPE_STRUCT : type; constant.type_str = struct_name; constant.precision = precision; @@ -6373,6 +6374,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } shader->constants[name] = constant; + shader->vconstants.push_back(constant); + if (tk.type == TK_COMMA) { tk = _get_token(); if (tk.type != TK_IDENTIFIER) { diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 48f1d1440f..973e1c4937 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -607,6 +607,7 @@ public: struct ShaderNode : public Node { struct Constant { + StringName name; DataType type; StringName type_str; DataPrecision precision; @@ -698,6 +699,7 @@ public: Vector<StringName> render_modes; Vector<Function> functions; + Vector<Constant> vconstants; Vector<Struct> vstructs; ShaderNode() : |