Skip to content

Commit

Permalink
Merge pull request #44947 from akien-mga/3.2-cherrypicks
Browse files Browse the repository at this point in the history
Cherry-picks for the 3.2 branch (future 3.2.4) - 15th batch
  • Loading branch information
akien-mga authored Jan 6, 2021
2 parents 3032b38 + d7102ac commit d242f7a
Show file tree
Hide file tree
Showing 29 changed files with 197 additions and 163 deletions.
5 changes: 1 addition & 4 deletions core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,7 @@ void _OS::print_resources_by_type(const Vector<String> &p_types) {
List<Ref<Resource> > resources;
ResourceCache::get_cached_resources(&resources);

List<Ref<Resource> > rsrc;
ResourceCache::get_cached_resources(&rsrc);

for (List<Ref<Resource> >::Element *E = rsrc.front(); E; E = E->next()) {
for (List<Ref<Resource> >::Element *E = resources.front(); E; E = E->next()) {

Ref<Resource> r = E->get();

Expand Down
20 changes: 9 additions & 11 deletions core/io/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "core/os/dir_access.h"
#include "core/os/os.h"
#include "core/print_string.h"
#include "core/project_settings.h"

// va_copy was defined in the C99, but not in C++ standards before C++11.
// When you compile C++ without --std=c++<XX> option, compilers still define
Expand Down Expand Up @@ -205,14 +204,15 @@ void RotatedFileLogger::logv(const char *p_format, va_list p_list, bool p_err) {
}
va_end(list_copy);
file->store_buffer((uint8_t *)buf, len);

if (len >= static_buf_size) {
Memory::free_static(buf);
}

if (p_err || GLOBAL_GET("application/run/flush_stdout_on_print")) {
// Don't always flush when printing stdout to avoid performance
// issues when `print()` is spammed in release builds.
#ifdef DEBUG_ENABLED
const bool need_flush = true;
#else
bool need_flush = p_err;
#endif
if (need_flush) {
file->flush();
}
}
Expand All @@ -231,11 +231,9 @@ void StdLogger::logv(const char *p_format, va_list p_list, bool p_err) {
vfprintf(stderr, p_format, p_list);
} else {
vprintf(p_format, p_list);
if (GLOBAL_GET("application/run/flush_stdout_on_print")) {
// Don't always flush when printing stdout to avoid performance
// issues when `print()` is spammed in release builds.
fflush(stdout);
}
#ifdef DEBUG_ENABLED
fflush(stdout);
#endif
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/math/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const {

Vector3 point = p_plane.normal * p_plane.d;
Vector3 point_dir = point + p_plane.normal;
xform_inv(point);
xform_inv(point_dir);
point = xform_inv(point);
point_dir = xform_inv(point_dir);

Vector3 normal = point_dir - point;
normal.normalize();
Expand Down
8 changes: 7 additions & 1 deletion core/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,13 @@ void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const

ERR_FAIL_NULL(p_to_object);
Signal *s = signal_map.getptr(p_signal);
ERR_FAIL_COND_MSG(!s, vformat("Nonexistent signal '%s' in %s.", p_signal, to_string()));
if (!s) {
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal) ||
(!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal));
ERR_FAIL_COND_MSG(signal_is_valid, vformat("Attempt to disconnect a nonexistent connection to signal '%s' in %s, with target '%s' in %s.",
p_signal, to_string(), p_to_method, p_to_object->to_string()));
}
ERR_FAIL_COND_MSG(!s, vformat("Disconnecting nonexistent signal '%s' in %s.", p_signal, to_string()));

Signal::Target target(p_to_object->get_instance_id(), p_to_method);

Expand Down
6 changes: 4 additions & 2 deletions doc/classes/AStar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
return min(0, abs(u - v) - 1)
[/codeblock]
[method _estimate_cost] should return a lower bound of the distance, i.e. [code]_estimate_cost(u, v) &lt;= _compute_cost(u, v)[/code]. This serves as a hint to the algorithm because the custom [code]_compute_cost[/code] might be computation-heavy. If this is not the case, make [method _estimate_cost] return the same value as [method _compute_cost] to provide the algorithm with the most accurate information.
If the default [method _estimate_cost] and [method _compute_cost] methods are used, or if the supplied [method _estimate_cost] method returns a lower bound of the cost, then the paths returned by A* will be the lowest cost paths. Here, the cost of a path equals to the sum of the [method _compute_cost] results of all segments in the path multiplied by the [code]weight_scale[/code]s of the end points of the respective segments. If the default methods are used and the [code]weight_scale[/code]s of all points are set to [code]1.0[/code], then this equals to the sum of Euclidean distances of all segments in the path.
</description>
<tutorials>
</tutorials>
Expand Down Expand Up @@ -56,7 +57,8 @@
<argument index="2" name="weight_scale" type="float" default="1.0">
</argument>
<description>
Adds a new point at the given position with the given identifier. The algorithm prefers points with lower [code]weight_scale[/code] to form a path. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger.
Adds a new point at the given position with the given identifier. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger.
The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower [code]weight_scale[/code]s to form a path.
[codeblock]
var astar = AStar.new()
astar.add_point(1, Vector3(1, 0, 0), 4) # Adds the point (1, 0, 0) with weight_scale 4 and id 1
Expand Down Expand Up @@ -315,7 +317,7 @@
<argument index="1" name="weight_scale" type="float">
</argument>
<description>
Sets the [code]weight_scale[/code] for the point with the given [code]id[/code].
Sets the [code]weight_scale[/code] for the point with the given [code]id[/code]. The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point.
</description>
</method>
</methods>
Expand Down
5 changes: 3 additions & 2 deletions doc/classes/AStar2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
<argument index="2" name="weight_scale" type="float" default="1.0">
</argument>
<description>
Adds a new point at the given position with the given identifier. The algorithm prefers points with lower [code]weight_scale[/code] to form a path. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger.
Adds a new point at the given position with the given identifier. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger.
The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower [code]weight_scale[/code]s to form a path.
[codeblock]
var astar = AStar2D.new()
astar.add_point(1, Vector2(1, 0), 4) # Adds the point (1, 0) with weight_scale 4 and id 1
Expand Down Expand Up @@ -298,7 +299,7 @@
<argument index="1" name="weight_scale" type="float">
</argument>
<description>
Sets the [code]weight_scale[/code] for the point with the given [code]id[/code].
Sets the [code]weight_scale[/code] for the point with the given [code]id[/code]. The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point.
</description>
</method>
</methods>
Expand Down
13 changes: 13 additions & 0 deletions doc/classes/AnimationNodeStateMachinePlayback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,26 @@
<link>https://docs.godotengine.org/en/3.2/tutorials/animation/animation_tree.html</link>
</tutorials>
<methods>
<method name="get_current_length" qualifiers="const">
<return type="float">
</return>
<description>
</description>
</method>
<method name="get_current_node" qualifiers="const">
<return type="String">
</return>
<description>
Returns the currently playing animation state.
</description>
</method>
<method name="get_current_play_position" qualifiers="const">
<return type="float">
</return>
<description>
Returns the playback position within the current animation state.
</description>
</method>
<method name="get_travel_path" qualifiers="const">
<return type="PoolStringArray">
</return>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/MainLoop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<argument index="0" name="delta" type="float">
</argument>
<description>
Called each physics frame with the time since the last physics frame as argument (in seconds). Equivalent to [method Node._physics_process].
Called each physics frame with the time since the last physics frame as argument ([code]delta[/code], in seconds). Equivalent to [method Node._physics_process].
If implemented, the method must return a boolean value. [code]true[/code] ends the main loop, while [code]false[/code] lets it proceed to the next frame.
</description>
</method>
Expand Down
10 changes: 5 additions & 5 deletions doc/classes/Node.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[b]Scene tree:[/b] The [SceneTree] contains the active tree of nodes. When a node is added to the scene tree, it receives the [constant NOTIFICATION_ENTER_TREE] notification and its [method _enter_tree] callback is triggered. Child nodes are always added [i]after[/i] their parent node, i.e. the [method _enter_tree] callback of a parent node will be triggered before its child's.
Once all nodes have been added in the scene tree, they receive the [constant NOTIFICATION_READY] notification and their respective [method _ready] callbacks are triggered. For groups of nodes, the [method _ready] callback is called in reverse order, starting with the children and moving up to the parent nodes.
This means that when adding a node to the scene tree, the following order will be used for the callbacks: [method _enter_tree] of the parent, [method _enter_tree] of the children, [method _ready] of the children and finally [method _ready] of the parent (recursively for the entire scene tree).
[b]Processing:[/b] Nodes can override the "process" state, so that they receive a callback on each frame requesting them to process (do something). Normal processing (callback [method _process], toggled with [method set_process]) happens as fast as possible and is dependent on the frame rate, so the processing time [i]delta[/i] is passed as an argument. Physics processing (callback [method _physics_process], toggled with [method set_physics_process]) happens a fixed number of times per second (60 by default) and is useful for code related to the physics engine.
[b]Processing:[/b] Nodes can override the "process" state, so that they receive a callback on each frame requesting them to process (do something). Normal processing (callback [method _process], toggled with [method set_process]) happens as fast as possible and is dependent on the frame rate, so the processing time [i]delta[/i] (in seconds) is passed as an argument. Physics processing (callback [method _physics_process], toggled with [method set_physics_process]) happens a fixed number of times per second (60 by default) and is useful for code related to the physics engine.
Nodes can also process input events. When present, the [method _input] function will be called for each input that the program receives. In many cases, this can be overkill (unless used for simple projects), and the [method _unhandled_input] function might be preferred; it is called when the input event was not handled by anyone else (typically, GUI [Control] nodes), ensuring that the node only receives the events that were meant for it.
To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an "owner" can be set for the node with the [member owner] property. This keeps track of who instanced what. This is mostly useful when writing editors and tools, though.
Finally, when a node is freed with [method Object.free] or [method queue_free], it will also free all its children.
Expand Down Expand Up @@ -65,7 +65,7 @@
<argument index="0" name="delta" type="float">
</argument>
<description>
Called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the [code]delta[/code] variable should be constant.
Called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the [code]delta[/code] variable should be constant. [code]delta[/code] is in seconds.
It is only called if physics processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_physics_process].
Corresponds to the [constant NOTIFICATION_PHYSICS_PROCESS] notification in [method Object._notification].
[b]Note:[/b] This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
Expand All @@ -77,7 +77,7 @@
<argument index="0" name="delta" type="float">
</argument>
<description>
Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the [code]delta[/code] time since the previous frame is not constant.
Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the [code]delta[/code] time since the previous frame is not constant. [code]delta[/code] is in seconds.
It is only called if processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process].
Corresponds to the [constant NOTIFICATION_PROCESS] notification in [method Object._notification].
[b]Note:[/b] This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
Expand Down Expand Up @@ -334,7 +334,7 @@
<return type="float">
</return>
<description>
Returns the time elapsed since the last physics-bound frame (see [method _physics_process]). This is always a constant value in physics processing unless the frames per second is changed via [member Engine.iterations_per_second].
Returns the time elapsed (in seconds) since the last physics-bound frame (see [method _physics_process]). This is always a constant value in physics processing unless the frames per second is changed via [member Engine.iterations_per_second].
</description>
</method>
<method name="get_position_in_parent" qualifiers="const">
Expand Down Expand Up @@ -570,7 +570,7 @@
<return type="void">
</return>
<description>
Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs ([Control] nodes), because their order of drawing depends on their order in the tree, i.e. the further they are on the node list, the higher they are drawn. After using [code]raise[/code], a Control will be drawn on top of their siblings.
Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs ([Control] nodes), because their order of drawing depends on their order in the tree. The top Node is drawn first, then any siblings below the top Node in the hierarchy are successively drawn on top of it. After using [code]raise[/code], a Control will be drawn on top of its siblings.
</description>
</method>
<method name="remove_and_skip">
Expand Down
11 changes: 3 additions & 8 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,6 @@
<member name="application/run/disable_stdout" type="bool" setter="" getter="" default="false">
If [code]true[/code], disables printing to standard output in an exported build.
</member>
<member name="application/run/flush_stdout_on_print" type="bool" setter="" getter="" default="false">
If [code]true[/code], flushes the standard output stream every time a line is printed. This affects both terminal logging and file logging.
When running a project, this setting must be enabled if you want logs to be collected by service managers such as systemd/journalctl. This setting is disabled by default on release builds, since flushing on every printed line will negatively affect performance if lots of lines are printed in a rapid succession. Also, if this setting is enabled, logged files will still be written successfully if the application crashes or is otherwise killed by the user (without being closed "normally").
[b]Note:[/b] Regardless of this setting, the standard error stream ([code]stderr[/code]) is always flushed when a line is printed to it.
</member>
<member name="application/run/flush_stdout_on_print.debug" type="bool" setter="" getter="" default="true">
Debug build override for [member application/run/flush_stdout_on_print], as performance is less important during debugging.
</member>
<member name="application/run/frame_delay_msec" type="int" setter="" getter="" default="0">
Forces a delay between frames in the main loop (in milliseconds). This may be useful if you plan to disable vertical synchronization.
</member>
Expand Down Expand Up @@ -850,6 +842,7 @@
If [code]true[/code], logs all output to files.
</member>
<member name="logging/file_logging/enable_file_logging.pc" type="bool" setter="" getter="" default="true">
Desktop override for [member logging/file_logging/enable_file_logging], as log files are not readily accessible on mobile/Web platforms.
</member>
<member name="logging/file_logging/log_path" type="String" setter="" getter="" default="&quot;user://logs/godot.log&quot;">
Path to logs within the project. Using an [code]user://[/code] path is recommended.
Expand Down Expand Up @@ -1105,6 +1098,8 @@
Choose between default mode where corner scalings are preserved matching the artwork, and scaling mode.
Not available in GLES3 when [member rendering/batching/options/use_batching] is off.
</member>
<member name="rendering/quality/2d/use_camera_snap" type="bool" setter="" getter="" default="false">
</member>
<member name="rendering/quality/2d/use_nvidia_rect_flicker_workaround" type="bool" setter="" getter="" default="false">
Some NVIDIA GPU drivers have a bug which produces flickering issues for the [code]draw_rect[/code] method, especially as used in [TileMap]. Refer to [url=https://github.com/godotengine/godot/issues/9913]GitHub issue 9913[/url] for details.
If [code]true[/code], this option enables a "safe" code path for such NVIDIA GPUs at the cost of performance. This option affects GLES2 and GLES3 rendering, but only on desktop platforms.
Expand Down
35 changes: 23 additions & 12 deletions editor/editor_file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ void EditorFileDialog::update_dir() {
void EditorFileDialog::_dir_entered(String p_dir) {

dir_access->change_dir(p_dir);
file->set_text("");
invalidate();
update_dir();
_push_history();
Expand All @@ -244,6 +243,14 @@ void EditorFileDialog::_save_confirm_pressed() {
void EditorFileDialog::_post_popup() {

ConfirmationDialog::_post_popup();

// Check if the current path doesn't exist and correct it.
String current = dir_access->get_current_dir();
while (!dir_access->dir_exists(current)) {
current = current.get_base_dir();
}
set_current_dir(current);

if (invalidated) {
update_file_list();
invalidated = false;
Expand Down Expand Up @@ -279,11 +286,17 @@ void EditorFileDialog::_post_popup() {
} else {
name = name.get_file() + "/";
}

recent->add_item(name, folder);
recent->set_item_metadata(recent->get_item_count() - 1, recentd[i]);
recent->set_item_icon_modulate(recent->get_item_count() - 1, folder_color);
bool exists = dir_access->dir_exists(recentd[i]);
if (!exists) {
// Remove invalid directory from the list of Recent directories.
recentd.remove(i--);
} else {
recent->add_item(name, folder);
recent->set_item_metadata(recent->get_item_count() - 1, recentd[i]);
recent->set_item_icon_modulate(recent->get_item_count() - 1, folder_color);
}
}
EditorSettings::get_singleton()->set_recent_dirs(recentd);

local_history.clear();
local_history_pos = -1;
Expand Down Expand Up @@ -441,10 +454,12 @@ void EditorFileDialog::_action_pressed() {
}
}

// Add first extension of filter if no valid extension is found.
if (!valid) {

exterr->popup_centered_minsize(Size2(250, 80) * EDSCALE);
return;
int idx = filter->get_selected();
String flt = filters[idx].get_slice(";", 0);
String ext = flt.get_slice(",", 0).strip_edges().get_extension();
f += "." + ext;
}

if (dir_access->file_exists(f) && !disable_overwrite_warning) {
Expand Down Expand Up @@ -1735,10 +1750,6 @@ EditorFileDialog::EditorFileDialog() {
mkdirerr->set_text(TTR("Could not create folder."));
add_child(mkdirerr);

exterr = memnew(AcceptDialog);
exterr->set_text(TTR("Must use a valid extension."));
add_child(exterr);

update_filters();
update_dir();

Expand Down
Loading

0 comments on commit d242f7a

Please sign in to comment.