summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/math/math_funcs.h15
-rw-r--r--core/math/vector2.cpp20
-rw-r--r--core/math/vector3.cpp21
-rw-r--r--core/variant/variant_utility.cpp5
-rw-r--r--doc/classes/@GlobalScope.xml11
-rw-r--r--editor/animation_track_editor.cpp18
-rw-r--r--editor/project_manager.cpp34
-rw-r--r--editor/project_manager.h8
-rw-r--r--main/main.cpp5
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs18
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs18
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs18
-rw-r--r--modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml84
-rw-r--r--modules/visual_script/editor/visual_script_editor.cpp10
-rw-r--r--modules/visual_script/editor/visual_script_editor.h1
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp26
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h1
-rw-r--r--platform/osx/godot_content_view.mm4
-rw-r--r--scene/gui/control.cpp23
-rw-r--r--scene/resources/animation.cpp20
20 files changed, 218 insertions, 142 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 6b5eb655d3..47e5ab2709 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -235,6 +235,21 @@ public:
static _ALWAYS_INLINE_ double lerp(double p_from, double p_to, double p_weight) { return p_from + (p_to - p_from) * p_weight; }
static _ALWAYS_INLINE_ float lerp(float p_from, float p_to, float p_weight) { return p_from + (p_to - p_from) * p_weight; }
+ static _ALWAYS_INLINE_ double cubic_interpolate(double p_from, double p_to, double p_pre, double p_post, double p_weight) {
+ return 0.5 *
+ ((p_from * 2.0) +
+ (-p_pre + p_to) * p_weight +
+ (2.0 * p_pre - 5.0 * p_from + 4.0 * p_to - p_post) * (p_weight * p_weight) +
+ (-p_pre + 3.0 * p_from - 3.0 * p_to + p_post) * (p_weight * p_weight * p_weight));
+ }
+ static _ALWAYS_INLINE_ float cubic_interpolate(float p_from, float p_to, float p_pre, float p_post, float p_weight) {
+ return 0.5f *
+ ((p_from * 2.0f) +
+ (-p_pre + p_to) * p_weight +
+ (2.0f * p_pre - 5.0f * p_from + 4.0f * p_to - p_post) * (p_weight * p_weight) +
+ (-p_pre + 3.0f * p_from - 3.0f * p_to + p_post) * (p_weight * p_weight * p_weight));
+ }
+
static _ALWAYS_INLINE_ double lerp_angle(double p_from, double p_to, double p_weight) {
double difference = fmod(p_to - p_from, Math_TAU);
double distance = fmod(2.0 * difference, Math_TAU) - difference;
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index 120b66e432..ed4266b115 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -153,22 +153,10 @@ Vector2 Vector2::limit_length(const real_t p_len) const {
}
Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, const real_t p_weight) const {
- Vector2 p0 = p_pre_a;
- Vector2 p1 = *this;
- Vector2 p2 = p_b;
- Vector2 p3 = p_post_b;
-
- real_t t = p_weight;
- real_t t2 = t * t;
- real_t t3 = t2 * t;
-
- Vector2 out;
- out = 0.5f *
- ((p1 * 2.0f) +
- (-p0 + p2) * t +
- (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 +
- (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
- return out;
+ Vector2 res = *this;
+ res.x = Math::cubic_interpolate(res.x, p_b.x, p_pre_a.x, p_post_b.x, p_weight);
+ res.y = Math::cubic_interpolate(res.y, p_b.y, p_pre_a.y, p_post_b.y, p_weight);
+ return res;
}
Vector2 Vector2::move_toward(const Vector2 &p_to, const real_t p_delta) const {
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index bafb01da59..998c437a22 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -83,22 +83,11 @@ Vector3 Vector3::limit_length(const real_t p_len) const {
}
Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, const real_t p_weight) const {
- Vector3 p0 = p_pre_a;
- Vector3 p1 = *this;
- Vector3 p2 = p_b;
- Vector3 p3 = p_post_b;
-
- real_t t = p_weight;
- real_t t2 = t * t;
- real_t t3 = t2 * t;
-
- Vector3 out;
- out = 0.5f *
- ((p1 * 2.0f) +
- (-p0 + p2) * t +
- (2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3) * t2 +
- (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
- return out;
+ Vector3 res = *this;
+ res.x = Math::cubic_interpolate(res.x, p_b.x, p_pre_a.x, p_post_b.x, p_weight);
+ res.y = Math::cubic_interpolate(res.y, p_b.y, p_pre_a.y, p_post_b.y, p_weight);
+ res.z = Math::cubic_interpolate(res.z, p_b.z, p_pre_a.z, p_post_b.z, p_weight);
+ return res;
}
Vector3 Vector3::move_toward(const Vector3 &p_to, const real_t p_delta) const {
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index 60950099d2..e83c71098d 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -231,6 +231,10 @@ struct VariantUtilityFunctions {
return Math::lerp(from, to, weight);
}
+ static inline double cubic_interpolate(double from, double to, double pre, double post, double weight) {
+ return Math::cubic_interpolate(from, to, pre, post, weight);
+ }
+
static inline double lerp_angle(double from, double to, double weight) {
return Math::lerp_angle(from, to, weight);
}
@@ -1204,6 +1208,7 @@ void Variant::_register_variant_utility_functions() {
FUNCBINDR(snapped, sarray("x", "step"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(lerp, sarray("from", "to", "weight"), Variant::UTILITY_FUNC_TYPE_MATH);
+ FUNCBINDR(cubic_interpolate, sarray("from", "to", "pre", "post", "weight"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(lerp_angle, sarray("from", "to", "weight"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(inverse_lerp, sarray("from", "to", "weight"), Variant::UTILITY_FUNC_TYPE_MATH);
FUNCBINDR(range_lerp, sarray("value", "istart", "istop", "ostart", "ostop"), Variant::UTILITY_FUNC_TYPE_MATH);
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 4c0f89f14d..93439b82f9 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -221,6 +221,17 @@
[/codeblock]
</description>
</method>
+ <method name="cubic_interpolate">
+ <return type="float" />
+ <argument index="0" name="from" type="float" />
+ <argument index="1" name="to" type="float" />
+ <argument index="2" name="pre" type="float" />
+ <argument index="3" name="post" type="float" />
+ <argument index="4" name="weight" type="float" />
+ <description>
+ Cubic interpolates between two values by the factor defined in [code]weight[/code] with pre and post values.
+ </description>
+ </method>
<method name="db2linear">
<return type="float" />
<argument index="0" name="db" type="float" />
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 961eb907bb..fdeee32849 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -1844,11 +1844,14 @@ void AnimationTimelineEdit::_pan_callback(Vector2 p_scroll_vec) {
}
void AnimationTimelineEdit::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt) {
- if (p_scroll_vec.y < 0) {
- get_zoom()->set_value(get_zoom()->get_value() * 1.05);
+ double new_zoom_value;
+ double current_zoom_value = get_zoom()->get_value();
+ if (current_zoom_value <= 0.1) {
+ new_zoom_value = MAX(0.01, current_zoom_value - 0.01 * SIGN(p_scroll_vec.y));
} else {
- get_zoom()->set_value(get_zoom()->get_value() / 1.05);
+ new_zoom_value = p_scroll_vec.y > 0 ? MAX(0.01, current_zoom_value / 1.05) : current_zoom_value * 1.05;
}
+ get_zoom()->set_value(new_zoom_value);
}
void AnimationTimelineEdit::set_use_fps(bool p_use_fps) {
@@ -5332,11 +5335,14 @@ void AnimationTrackEditor::_pan_callback(Vector2 p_scroll_vec) {
}
void AnimationTrackEditor::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt) {
- if (p_scroll_vec.y < 0) {
- timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() * 1.05);
+ double new_zoom_value;
+ double current_zoom_value = timeline->get_zoom()->get_value();
+ if (current_zoom_value <= 0.1) {
+ new_zoom_value = MAX(0.01, current_zoom_value - 0.01 * SIGN(p_scroll_vec.y));
} else {
- timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() / 1.05);
+ new_zoom_value = p_scroll_vec.y > 0 ? MAX(0.01, current_zoom_value / 1.05) : current_zoom_value * 1.05;
}
+ timeline->get_zoom()->set_value(new_zoom_value);
}
void AnimationTrackEditor::_cancel_bezier_edit() {
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 1cd13e10c8..2a9f699ee6 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1863,6 +1863,8 @@ void ProjectList::_bind_methods() {
ADD_SIGNAL(MethodInfo(SIGNAL_PROJECT_ASK_OPEN));
}
+ProjectManager *ProjectManager::singleton = nullptr;
+
void ProjectManager::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_TRANSLATION_CHANGED:
@@ -1908,10 +1910,8 @@ void ProjectManager::_notification(int p_what) {
}
}
-Map<String, Ref<Texture2D>> ProjectManager::icon_type_cache;
-
Ref<Texture2D> ProjectManager::_file_dialog_get_icon(const String &p_path) {
- return icon_type_cache["ObjectHR"];
+ return singleton->icon_type_cache["ObjectHR"];
}
void ProjectManager::_build_icon_type_cache(Ref<Theme> p_theme) {
@@ -2481,6 +2481,8 @@ void ProjectManager::_version_button_pressed() {
}
ProjectManager::ProjectManager() {
+ singleton = this;
+
// load settings
if (!EditorSettings::get_singleton()) {
EditorSettings::create();
@@ -2523,15 +2525,6 @@ ProjectManager::ProjectManager() {
editor_set_scale(EditorSettings::get_singleton()->get("interface/editor/custom_display_scale"));
break;
}
-
- // Define a minimum window size to prevent UI elements from overlapping or being cut off
- DisplayServer::get_singleton()->window_set_min_size(Size2(750, 420) * EDSCALE);
-
- // TODO: Resize windows on hiDPI displays on Windows and Linux and remove the lines below
- float scale_factor = MAX(1, EDSCALE);
- Vector2i window_size = DisplayServer::get_singleton()->window_get_size();
- DisplayServer::get_singleton()->window_set_size(Vector2i(window_size.x * scale_factor, window_size.y * scale_factor));
-
EditorFileDialog::get_icon_func = &ProjectManager::_file_dialog_get_icon;
}
@@ -2866,10 +2859,27 @@ ProjectManager::ProjectManager() {
SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped));
+ // Define a minimum window size to prevent UI elements from overlapping or being cut off
+ DisplayServer::get_singleton()->window_set_min_size(Size2(750, 420) * EDSCALE);
+
+ // Resize the bootsplash window based on Editor display scale EDSCALE.
+ float scale_factor = MAX(1, EDSCALE);
+ if (scale_factor > 1.0) {
+ Vector2i window_size = DisplayServer::get_singleton()->window_get_size();
+ Vector2i screen_size = DisplayServer::get_singleton()->screen_get_size();
+ window_size *= scale_factor;
+ Vector2i window_position;
+ window_position.x = (screen_size.x - window_size.x) / 2;
+ window_position.y = (screen_size.y - window_size.y) / 2;
+ DisplayServer::get_singleton()->window_set_size(window_size);
+ DisplayServer::get_singleton()->window_set_position(window_position);
+ }
+
OS::get_singleton()->set_low_processor_usage_mode(true);
}
ProjectManager::~ProjectManager() {
+ singleton = nullptr;
if (EditorSettings::get_singleton()) {
EditorSettings::destroy();
}
diff --git a/editor/project_manager.h b/editor/project_manager.h
index d3cd929eb7..2965dc7d2e 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -50,8 +50,10 @@ enum FilterOption {
class ProjectManager : public Control {
GDCLASS(ProjectManager, Control);
- static Map<String, Ref<Texture2D>> icon_type_cache;
- static void _build_icon_type_cache(Ref<Theme> p_theme);
+ Map<String, Ref<Texture2D>> icon_type_cache;
+ void _build_icon_type_cache(Ref<Theme> p_theme);
+
+ static ProjectManager *singleton;
TabContainer *tabs;
@@ -139,6 +141,8 @@ protected:
static void _bind_methods();
public:
+ static ProjectManager *get_singleton() { return singleton; }
+
ProjectManager();
~ProjectManager();
};
diff --git a/main/main.cpp b/main/main.cpp
index bfe560fa31..7cbafe37a3 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1212,6 +1212,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// If we didn't find a project, we fall back to the project manager.
project_manager = !found_project && !cmdline_tool;
}
+
+ if (project_manager) {
+ Engine::get_singleton()->set_project_manager_hint(true);
+ }
#endif
GLOBAL_DEF("debug/file_logging/enable_file_logging", false);
@@ -2540,7 +2544,6 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
if (project_manager) {
Engine::get_singleton()->set_editor_hint(true);
- Engine::get_singleton()->set_project_manager_hint(true);
ProjectManager *pmanager = memnew(ProjectManager);
ProgressDialog *progress_dialog = memnew(ProgressDialog);
pmanager->add_child(progress_dialog);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs
index bfe9600084..ce213da6a7 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs
@@ -180,6 +180,24 @@ namespace Godot
}
/// <summary>
+ /// Cubic interpolates between two values by a normalized value with pre and post values.
+ /// </summary>
+ /// <param name="from">The start value for interpolation.</param>
+ /// <param name="to">The destination value for interpolation.</param>
+ /// <param name="pre">The value which before "from" value for interpolation.</param>
+ /// <param name="post">The value which after "to" value for interpolation.</param>
+ /// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
+ /// <returns>The resulting value of the interpolation.</returns>
+ public static real_t CubicInterpolate(real_t from, real_t to, real_t pre, real_t post, real_t weight)
+ {
+ return 0.5f *
+ ((from * 2.0f) +
+ (-pre + to) * weight +
+ (2.0f * pre - 5.0f * from + 4.0f * to - post) * (weight * weight) +
+ (-pre + 3.0f * from - 3.0f * to + post) * (weight * weight * weight));
+ }
+
+ /// <summary>
/// Converts an angle expressed in degrees to radians.
/// </summary>
/// <param name="deg">An angle expressed in degrees.</param>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
index fa7838633c..8679f28132 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
@@ -204,20 +204,10 @@ namespace Godot
/// <returns>The interpolated vector.</returns>
public Vector2 CubicInterpolate(Vector2 b, Vector2 preA, Vector2 postB, real_t weight)
{
- Vector2 p0 = preA;
- Vector2 p1 = this;
- Vector2 p2 = b;
- Vector2 p3 = postB;
-
- real_t t = weight;
- real_t t2 = t * t;
- real_t t3 = t2 * t;
-
- return 0.5f * (
- (p1 * 2.0f) +
- ((-p0 + p2) * t) +
- (((2.0f * p0) - (5.0f * p1) + (4 * p2) - p3) * t2) +
- ((-p0 + (3.0f * p1) - (3.0f * p2) + p3) * t3)
+ return new Vector2
+ (
+ Mathf.CubicInterpolate(x, b.x, preA.x, postB.x, weight),
+ Mathf.CubicInterpolate(y, b.y, preA.y, postB.y, weight)
);
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
index 0faf13f8b7..1e60fb9523 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
@@ -195,19 +195,11 @@ namespace Godot
/// <returns>The interpolated vector.</returns>
public Vector3 CubicInterpolate(Vector3 b, Vector3 preA, Vector3 postB, real_t weight)
{
- Vector3 p0 = preA;
- Vector3 p1 = this;
- Vector3 p2 = b;
- Vector3 p3 = postB;
-
- real_t t = weight;
- real_t t2 = t * t;
- real_t t3 = t2 * t;
-
- return 0.5f * (
- (p1 * 2.0f) + ((-p0 + p2) * t) +
- (((2.0f * p0) - (5.0f * p1) + (4f * p2) - p3) * t2) +
- ((-p0 + (3.0f * p1) - (3.0f * p2) + p3) * t3)
+ return new Vector3
+ (
+ Mathf.CubicInterpolate(x, b.x, preA.x, postB.x, weight),
+ Mathf.CubicInterpolate(y, b.y, preA.y, postB.y, weight),
+ Mathf.CubicInterpolate(z, b.z, preA.z, postB.z, weight)
);
}
diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
index 1ac5768755..55afacbea1 100644
--- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
+++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
@@ -96,123 +96,125 @@
<constant name="MATH_LERP" value="26" enum="BuiltinFunc">
Returns a number linearly interpolated between the first two inputs, based on the third input. Uses the formula [code]a + (a - b) * t[/code].
</constant>
- <constant name="MATH_INVERSE_LERP" value="27" enum="BuiltinFunc">
+ <constant name="MATH_CUBIC_INTERPOLATE" value="27" enum="BuiltinFunc">
</constant>
- <constant name="MATH_RANGE_LERP" value="28" enum="BuiltinFunc">
+ <constant name="MATH_INVERSE_LERP" value="28" enum="BuiltinFunc">
</constant>
- <constant name="MATH_MOVE_TOWARD" value="29" enum="BuiltinFunc">
+ <constant name="MATH_RANGE_LERP" value="29" enum="BuiltinFunc">
+ </constant>
+ <constant name="MATH_MOVE_TOWARD" value="30" enum="BuiltinFunc">
Moves the number toward a value, based on the third input.
</constant>
- <constant name="MATH_RANDOMIZE" value="30" enum="BuiltinFunc">
+ <constant name="MATH_RANDOMIZE" value="31" enum="BuiltinFunc">
Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
</constant>
- <constant name="MATH_RANDI" value="31" enum="BuiltinFunc">
+ <constant name="MATH_RANDI" value="32" enum="BuiltinFunc">
Returns a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use it with the remainder function.
</constant>
- <constant name="MATH_RANDF" value="32" enum="BuiltinFunc">
+ <constant name="MATH_RANDF" value="33" enum="BuiltinFunc">
Returns a random floating-point value between 0 and 1. To obtain a random value between 0 to N, you can use it with multiplication.
</constant>
- <constant name="MATH_RANDI_RANGE" value="33" enum="BuiltinFunc">
+ <constant name="MATH_RANDI_RANGE" value="34" enum="BuiltinFunc">
Returns a random 32-bit integer value between the two inputs.
</constant>
- <constant name="MATH_RANDF_RANGE" value="34" enum="BuiltinFunc">
+ <constant name="MATH_RANDF_RANGE" value="35" enum="BuiltinFunc">
Returns a random floating-point value between the two inputs.
</constant>
- <constant name="MATH_RANDFN" value="35" enum="BuiltinFunc">
+ <constant name="MATH_RANDFN" value="36" enum="BuiltinFunc">
Returns a normally-distributed pseudo-random number, using Box-Muller transform with the specified mean and a standard deviation. This is also called Gaussian distribution.
</constant>
- <constant name="MATH_SEED" value="36" enum="BuiltinFunc">
+ <constant name="MATH_SEED" value="37" enum="BuiltinFunc">
Set the seed for the random number generator.
</constant>
- <constant name="MATH_RANDSEED" value="37" enum="BuiltinFunc">
+ <constant name="MATH_RANDSEED" value="38" enum="BuiltinFunc">
Returns a random value from the given seed, along with the new seed.
</constant>
- <constant name="MATH_DEG2RAD" value="38" enum="BuiltinFunc">
+ <constant name="MATH_DEG2RAD" value="39" enum="BuiltinFunc">
Convert the input from degrees to radians.
</constant>
- <constant name="MATH_RAD2DEG" value="39" enum="BuiltinFunc">
+ <constant name="MATH_RAD2DEG" value="40" enum="BuiltinFunc">
Convert the input from radians to degrees.
</constant>
- <constant name="MATH_LINEAR2DB" value="40" enum="BuiltinFunc">
+ <constant name="MATH_LINEAR2DB" value="41" enum="BuiltinFunc">
Convert the input from linear volume to decibel volume.
</constant>
- <constant name="MATH_DB2LINEAR" value="41" enum="BuiltinFunc">
+ <constant name="MATH_DB2LINEAR" value="42" enum="BuiltinFunc">
Convert the input from decibel volume to linear volume.
</constant>
- <constant name="MATH_WRAP" value="42" enum="BuiltinFunc">
+ <constant name="MATH_WRAP" value="43" enum="BuiltinFunc">
</constant>
- <constant name="MATH_WRAPF" value="43" enum="BuiltinFunc">
+ <constant name="MATH_WRAPF" value="44" enum="BuiltinFunc">
</constant>
- <constant name="MATH_PINGPONG" value="44" enum="BuiltinFunc">
+ <constant name="MATH_PINGPONG" value="45" enum="BuiltinFunc">
Returns the [code]value[/code] wrapped between [code]0[/code] and the [code]length[/code]. If the limit is reached, the next value the function returned is decreased to the [code]0[/code] side or increased to the [code]length[/code] side (like a triangle wave). If [code]length[/code] is less than zero, it becomes positive.
</constant>
- <constant name="LOGIC_MAX" value="45" enum="BuiltinFunc">
+ <constant name="LOGIC_MAX" value="46" enum="BuiltinFunc">
Returns the greater of the two numbers, also known as their maximum.
</constant>
- <constant name="LOGIC_MIN" value="46" enum="BuiltinFunc">
+ <constant name="LOGIC_MIN" value="47" enum="BuiltinFunc">
Returns the lesser of the two numbers, also known as their minimum.
</constant>
- <constant name="LOGIC_CLAMP" value="47" enum="BuiltinFunc">
+ <constant name="LOGIC_CLAMP" value="48" enum="BuiltinFunc">
Returns the input clamped inside the given range, ensuring the result is never outside it. Equivalent to [code]min(max(input, range_low), range_high)[/code].
</constant>
- <constant name="LOGIC_NEAREST_PO2" value="48" enum="BuiltinFunc">
+ <constant name="LOGIC_NEAREST_PO2" value="49" enum="BuiltinFunc">
Returns the nearest power of 2 to the input.
</constant>
- <constant name="OBJ_WEAKREF" value="49" enum="BuiltinFunc">
+ <constant name="OBJ_WEAKREF" value="50" enum="BuiltinFunc">
Create a [WeakRef] from the input.
</constant>
- <constant name="TYPE_CONVERT" value="50" enum="BuiltinFunc">
+ <constant name="TYPE_CONVERT" value="51" enum="BuiltinFunc">
Convert between types.
</constant>
- <constant name="TYPE_OF" value="51" enum="BuiltinFunc">
+ <constant name="TYPE_OF" value="52" enum="BuiltinFunc">
Returns the type of the input as an integer. Check [enum Variant.Type] for the integers that might be returned.
</constant>
- <constant name="TYPE_EXISTS" value="52" enum="BuiltinFunc">
+ <constant name="TYPE_EXISTS" value="53" enum="BuiltinFunc">
Checks if a type is registered in the [ClassDB].
</constant>
- <constant name="TEXT_CHAR" value="53" enum="BuiltinFunc">
+ <constant name="TEXT_CHAR" value="54" enum="BuiltinFunc">
Returns a character with the given ascii value.
</constant>
- <constant name="TEXT_STR" value="54" enum="BuiltinFunc">
+ <constant name="TEXT_STR" value="55" enum="BuiltinFunc">
Convert the input to a string.
</constant>
- <constant name="TEXT_PRINT" value="55" enum="BuiltinFunc">
+ <constant name="TEXT_PRINT" value="56" enum="BuiltinFunc">
Print the given string to the output window.
</constant>
- <constant name="TEXT_PRINTERR" value="56" enum="BuiltinFunc">
+ <constant name="TEXT_PRINTERR" value="57" enum="BuiltinFunc">
Print the given string to the standard error output.
</constant>
- <constant name="TEXT_PRINTRAW" value="57" enum="BuiltinFunc">
+ <constant name="TEXT_PRINTRAW" value="58" enum="BuiltinFunc">
Print the given string to the standard output, without adding a newline.
</constant>
- <constant name="TEXT_PRINT_VERBOSE" value="58" enum="BuiltinFunc">
+ <constant name="TEXT_PRINT_VERBOSE" value="59" enum="BuiltinFunc">
</constant>
- <constant name="VAR_TO_STR" value="59" enum="BuiltinFunc">
+ <constant name="VAR_TO_STR" value="60" enum="BuiltinFunc">
Serialize a [Variant] to a string.
</constant>
- <constant name="STR_TO_VAR" value="60" enum="BuiltinFunc">
+ <constant name="STR_TO_VAR" value="61" enum="BuiltinFunc">
Deserialize a [Variant] from a string serialized using [constant VAR_TO_STR].
</constant>
- <constant name="VAR_TO_BYTES" value="61" enum="BuiltinFunc">
+ <constant name="VAR_TO_BYTES" value="62" enum="BuiltinFunc">
Serialize a [Variant] to a [PackedByteArray].
</constant>
- <constant name="BYTES_TO_VAR" value="62" enum="BuiltinFunc">
+ <constant name="BYTES_TO_VAR" value="63" enum="BuiltinFunc">
Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES].
</constant>
- <constant name="MATH_SMOOTHSTEP" value="63" enum="BuiltinFunc">
+ <constant name="MATH_SMOOTHSTEP" value="64" enum="BuiltinFunc">
Returns a number smoothly interpolated between the first two inputs, based on the third input. Similar to [constant MATH_LERP], but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula:
[codeblock]
var t = clamp((weight - from) / (to - from), 0.0, 1.0)
return t * t * (3.0 - 2.0 * t)
[/codeblock]
</constant>
- <constant name="MATH_POSMOD" value="64" enum="BuiltinFunc">
+ <constant name="MATH_POSMOD" value="65" enum="BuiltinFunc">
</constant>
- <constant name="MATH_LERP_ANGLE" value="65" enum="BuiltinFunc">
+ <constant name="MATH_LERP_ANGLE" value="66" enum="BuiltinFunc">
</constant>
- <constant name="TEXT_ORD" value="66" enum="BuiltinFunc">
+ <constant name="TEXT_ORD" value="67" enum="BuiltinFunc">
</constant>
- <constant name="FUNC_MAX" value="67" enum="BuiltinFunc">
+ <constant name="FUNC_MAX" value="68" enum="BuiltinFunc">
Represents the size of the [enum BuiltinFunc] enum.
</constant>
</constants>
diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp
index 5ea8eaff00..9433f3dba2 100644
--- a/modules/visual_script/editor/visual_script_editor.cpp
+++ b/modules/visual_script/editor/visual_script_editor.cpp
@@ -1510,6 +1510,7 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
function_name_edit->popup();
function_name_box->set_text(selected);
function_name_box->select_all();
+ function_name_box->grab_focus();
}
}
@@ -2098,11 +2099,15 @@ void VisualScriptEditor::_fn_name_box_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed() && key->get_keycode() == Key::ENTER) {
function_name_edit->hide();
- _rename_function(selected, function_name_box->get_text());
+ _on_fn_name_box_confirmed();
function_name_box->clear();
}
}
+void VisualScriptEditor::_on_fn_name_box_confirmed() {
+ _rename_function(selected, function_name_box->get_text());
+}
+
Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
if (p_from == members) {
TreeItem *it = members->get_item_at_position(p_point);
@@ -4415,6 +4420,7 @@ void VisualScriptEditor::_member_option(int p_option) {
function_name_edit->popup();
function_name_box->set_text(selected);
function_name_box->select_all();
+ function_name_box->grab_focus();
}
} break;
case MEMBER_VARIABLE: {
@@ -4545,9 +4551,11 @@ VisualScriptEditor::VisualScriptEditor() {
member_popup->connect("id_pressed", callable_mp(this, &VisualScriptEditor::_member_option));
function_name_edit = memnew(AcceptDialog);
+ function_name_edit->set_title(TTR("Rename Function"));
function_name_box = memnew(LineEdit);
function_name_edit->add_child(function_name_box);
function_name_box->connect("gui_input", callable_mp(this, &VisualScriptEditor::_fn_name_box_input));
+ function_name_edit->get_ok_button()->connect("pressed", callable_mp(this, &VisualScriptEditor::_on_fn_name_box_confirmed));
function_name_box->set_expand_to_text_length_enabled(true);
add_child(function_name_edit);
diff --git a/modules/visual_script/editor/visual_script_editor.h b/modules/visual_script/editor/visual_script_editor.h
index b01732b2fd..e178f5cf72 100644
--- a/modules/visual_script/editor/visual_script_editor.h
+++ b/modules/visual_script/editor/visual_script_editor.h
@@ -247,6 +247,7 @@ class VisualScriptEditor : public ScriptEditorBase {
void _graph_gui_input(const Ref<InputEvent> &p_event);
void _members_gui_input(const Ref<InputEvent> &p_event);
void _fn_name_box_input(const Ref<InputEvent> &p_event);
+ void _on_fn_name_box_confirmed();
void _rename_function(const String &p_name, const String &p_new_name);
void _create_function_dialog();
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index fd55796a66..f6bc855a50 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -65,6 +65,7 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX
"step_decimals",
"snapped",
"lerp",
+ "cubic_interpolate",
"inverse_lerp",
"range_lerp",
"move_toward",
@@ -212,6 +213,7 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) {
case MATH_WRAPF:
case LOGIC_CLAMP:
return 3;
+ case MATH_CUBIC_INTERPOLATE:
case MATH_RANGE_LERP:
return 5;
case FUNC_MAX: {
@@ -329,6 +331,19 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::FLOAT, "weight");
}
} break;
+ case MATH_CUBIC_INTERPOLATE: {
+ if (p_idx == 0) {
+ return PropertyInfo(Variant::FLOAT, "from");
+ } else if (p_idx == 1) {
+ return PropertyInfo(Variant::FLOAT, "to");
+ } else if (p_idx == 2) {
+ return PropertyInfo(Variant::FLOAT, "pre");
+ } else if (p_idx == 3) {
+ return PropertyInfo(Variant::FLOAT, "post");
+ } else {
+ return PropertyInfo(Variant::FLOAT, "weight");
+ }
+ } break;
case MATH_RANGE_LERP: {
if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "value");
@@ -525,6 +540,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
} break;
case MATH_SNAPPED:
case MATH_LERP:
+ case MATH_CUBIC_INTERPOLATE:
case MATH_LERP_ANGLE:
case MATH_INVERSE_LERP:
case MATH_RANGE_LERP:
@@ -795,6 +811,14 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
VALIDATE_ARG_NUM(2);
*r_return = Math::lerp((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
+ case VisualScriptBuiltinFunc::MATH_CUBIC_INTERPOLATE: {
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ VALIDATE_ARG_NUM(2);
+ VALIDATE_ARG_NUM(3);
+ VALIDATE_ARG_NUM(4);
+ *r_return = Math::cubic_interpolate((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2], (double)*p_inputs[3], (double)*p_inputs[4]);
+ } break;
case VisualScriptBuiltinFunc::MATH_LERP_ANGLE: {
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
@@ -1220,6 +1244,7 @@ void VisualScriptBuiltinFunc::_bind_methods() {
BIND_ENUM_CONSTANT(MATH_STEP_DECIMALS);
BIND_ENUM_CONSTANT(MATH_SNAPPED);
BIND_ENUM_CONSTANT(MATH_LERP);
+ BIND_ENUM_CONSTANT(MATH_CUBIC_INTERPOLATE);
BIND_ENUM_CONSTANT(MATH_INVERSE_LERP);
BIND_ENUM_CONSTANT(MATH_RANGE_LERP);
BIND_ENUM_CONSTANT(MATH_MOVE_TOWARD);
@@ -1309,6 +1334,7 @@ void register_visual_script_builtin_func_node() {
VisualScriptLanguage::singleton->add_register_func("functions/built_in/step_decimals", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_STEP_DECIMALS>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/snapped", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SNAPPED>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/lerp", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LERP>);
+ VisualScriptLanguage::singleton->add_register_func("functions/built_in/cubic_interpolate", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_CUBIC_INTERPOLATE>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/lerp_angle", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LERP_ANGLE>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/inverse_lerp", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_INVERSE_LERP>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/range_lerp", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANGE_LERP>);
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index d689296233..18935b9995 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -65,6 +65,7 @@ public:
MATH_STEP_DECIMALS,
MATH_SNAPPED,
MATH_LERP,
+ MATH_CUBIC_INTERPOLATE,
MATH_INVERSE_LERP,
MATH_RANGE_LERP,
MATH_MOVE_TOWARD,
diff --git a/platform/osx/godot_content_view.mm b/platform/osx/godot_content_view.mm
index 4e831e1ccc..76d9cfb081 100644
--- a/platform/osx/godot_content_view.mm
+++ b/platform/osx/godot_content_view.mm
@@ -117,6 +117,10 @@
}
}
+- (void)doCommandBySelector:(SEL)aSelector {
+ [self tryToPerform:aSelector with:self];
+}
+
- (void)unmarkText {
ime_input_event_in_progress = false;
[[marked_text mutableString] setString:@""];
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index aa59df6337..943ba8dfb1 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1585,14 +1585,25 @@ void Control::set_anchor_and_offset(Side p_side, real_t p_anchor, real_t p_pos,
}
void Control::_set_anchors_layout_preset(int p_preset) {
- set_meta("_edit_layout_mode", (int)LayoutMode::LAYOUT_MODE_ANCHORS);
+ bool list_changed = false;
+
+ if (has_meta("_edit_layout_mode") && (int)get_meta("_edit_layout_mode") != (int)LayoutMode::LAYOUT_MODE_ANCHORS) {
+ list_changed = true;
+ set_meta("_edit_layout_mode", (int)LayoutMode::LAYOUT_MODE_ANCHORS);
+ }
if (p_preset == -1) {
- set_meta("_edit_use_custom_anchors", true);
- notify_property_list_changed();
+ if (!has_meta("_edit_use_custom_anchors") || !(bool)get_meta("_edit_use_custom_anchors")) {
+ set_meta("_edit_use_custom_anchors", true);
+ notify_property_list_changed();
+ }
return; // Keep settings as is.
}
- set_meta("_edit_use_custom_anchors", false);
+
+ if (!has_meta("_edit_use_custom_anchors") || (bool)get_meta("_edit_use_custom_anchors")) {
+ list_changed = true;
+ set_meta("_edit_use_custom_anchors", false);
+ }
LayoutPreset preset = (LayoutPreset)p_preset;
// Set correct anchors.
@@ -1625,7 +1636,9 @@ void Control::_set_anchors_layout_preset(int p_preset) {
// Select correct grow directions.
set_grow_direction_preset(preset);
- notify_property_list_changed();
+ if (list_changed) {
+ notify_property_list_changed();
+ }
}
int Control::_get_anchors_layout_preset() const {
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index b6151bccf4..bc533ff022 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -2320,22 +2320,12 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
if (vformat == ((1 << Variant::INT) | (1 << Variant::FLOAT)) || vformat == (1 << Variant::FLOAT)) {
//mix of real and int
+ real_t a = p_a;
+ real_t b = p_b;
+ real_t pa = p_pre_a;
+ real_t pb = p_post_b;
- real_t p0 = p_pre_a;
- real_t p1 = p_a;
- real_t p2 = p_b;
- real_t p3 = p_post_b;
-
- real_t t = p_c;
- real_t t2 = t * t;
- real_t t3 = t2 * t;
-
- return 0.5f *
- ((p1 * 2.0f) +
- (-p0 + p2) * t +
- (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 +
- (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
-
+ return Math::cubic_interpolate(a, b, pa, pb, p_c);
} else if ((vformat & (vformat - 1))) {
return p_a; //can't interpolate, mix of types
}