diff options
-rw-r--r-- | core/math/a_star.cpp | 135 | ||||
-rw-r--r-- | core/math/a_star.h | 39 | ||||
-rw-r--r-- | core/register_core_types.cpp | 1 | ||||
-rw-r--r-- | doc/classes/AStar.xml | 2 | ||||
-rw-r--r-- | doc/classes/AStar2D.xml | 258 | ||||
-rw-r--r-- | doc/classes/AcceptDialog.xml | 5 | ||||
-rw-r--r-- | editor/animation_track_editor.cpp | 15 | ||||
-rw-r--r-- | editor/animation_track_editor.h | 2 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 29 | ||||
-rw-r--r-- | editor/scene_tree_dock.h | 1 | ||||
-rw-r--r-- | platform/x11/detect_prime.cpp | 14 | ||||
-rw-r--r-- | platform/x11/joypad_linux.cpp | 4 | ||||
-rw-r--r-- | scene/3d/area.cpp | 2 | ||||
-rw-r--r-- | scene/animation/animation_node_state_machine.cpp | 3 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 14 | ||||
-rw-r--r-- | scene/gui/dialogs.h | 3 | ||||
-rw-r--r-- | scene/resources/animation.cpp | 8 | ||||
-rw-r--r-- | servers/physics/area_sw.cpp | 2 |
18 files changed, 513 insertions, 24 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 359446dde6..7ce3824505 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -458,13 +458,12 @@ void AStar::_bind_methods() { ClassDB::bind_method(D_METHOD("set_point_weight_scale", "id", "weight_scale"), &AStar::set_point_weight_scale); ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar::remove_point); ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar::has_point); + ClassDB::bind_method(D_METHOD("get_point_connections", "id"), &AStar::get_point_connections); ClassDB::bind_method(D_METHOD("get_points"), &AStar::get_points); ClassDB::bind_method(D_METHOD("set_point_disabled", "id", "disabled"), &AStar::set_point_disabled, DEFVAL(true)); ClassDB::bind_method(D_METHOD("is_point_disabled", "id"), &AStar::is_point_disabled); - ClassDB::bind_method(D_METHOD("get_point_connections", "id"), &AStar::get_point_connections); - ClassDB::bind_method(D_METHOD("connect_points", "id", "to_id", "bidirectional"), &AStar::connect_points, DEFVAL(true)); ClassDB::bind_method(D_METHOD("disconnect_points", "id", "to_id"), &AStar::disconnect_points); ClassDB::bind_method(D_METHOD("are_points_connected", "id", "to_id"), &AStar::are_points_connected); @@ -491,3 +490,135 @@ AStar::~AStar() { pass = 1; clear(); } + +///////////////////////////////////////////////////////////// + +int AStar2D::get_available_point_id() const { + return astar.get_available_point_id(); +} + +void AStar2D::add_point(int p_id, const Vector2 &p_pos, real_t p_weight_scale) { + astar.add_point(p_id, Vector3(p_pos.x, p_pos.y, 0), p_weight_scale); +} + +Vector2 AStar2D::get_point_position(int p_id) const { + Vector3 p = astar.get_point_position(p_id); + return Vector2(p.x, p.y); +} + +void AStar2D::set_point_position(int p_id, const Vector2 &p_pos) { + astar.set_point_position(p_id, Vector3(p_pos.x, p_pos.y, 0)); +} + +real_t AStar2D::get_point_weight_scale(int p_id) const { + return astar.get_point_weight_scale(p_id); +} + +void AStar2D::set_point_weight_scale(int p_id, real_t p_weight_scale) { + astar.set_point_weight_scale(p_id, p_weight_scale); +} + +void AStar2D::remove_point(int p_id) { + astar.remove_point(p_id); +} + +bool AStar2D::has_point(int p_id) const { + return astar.has_point(p_id); +} + +PoolVector<int> AStar2D::get_point_connections(int p_id) { + return astar.get_point_connections(p_id); +} + +Array AStar2D::get_points() { + return astar.get_points(); +} + +void AStar2D::set_point_disabled(int p_id, bool p_disabled) { + astar.set_point_disabled(p_id, p_disabled); +} + +bool AStar2D::is_point_disabled(int p_id) const { + return astar.is_point_disabled(p_id); +} + +void AStar2D::connect_points(int p_id, int p_with_id, bool p_bidirectional) { + astar.connect_points(p_id, p_with_id, p_bidirectional); +} + +void AStar2D::disconnect_points(int p_id, int p_with_id) { + astar.disconnect_points(p_id, p_with_id); +} + +bool AStar2D::are_points_connected(int p_id, int p_with_id) const { + return astar.are_points_connected(p_id, p_with_id); +} + +void AStar2D::clear() { + astar.clear(); +} + +int AStar2D::get_closest_point(const Vector2 &p_point) const { + return astar.get_closest_point(Vector3(p_point.x, p_point.y, 0)); +} + +Vector2 AStar2D::get_closest_position_in_segment(const Vector2 &p_point) const { + Vector3 p = astar.get_closest_position_in_segment(Vector3(p_point.x, p_point.y, 0)); + return Vector2(p.x, p.y); +} + +PoolVector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) { + + PoolVector3Array pv = astar.get_point_path(p_from_id, p_to_id); + int size = pv.size(); + PoolVector2Array path; + path.resize(size); + { + PoolVector<Vector3>::Read r = pv.read(); + PoolVector<Vector2>::Write w = path.write(); + for (int i = 0; i < size; i++) { + Vector3 p = r[i]; + w[i] = Vector2(p.x, p.y); + } + } + return path; +} + +PoolVector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) { + return astar.get_id_path(p_from_id, p_to_id); +} + +void AStar2D::_bind_methods() { + + ClassDB::bind_method(D_METHOD("get_available_point_id"), &AStar2D::get_available_point_id); + ClassDB::bind_method(D_METHOD("add_point", "id", "position", "weight_scale"), &AStar2D::add_point, DEFVAL(1.0)); + ClassDB::bind_method(D_METHOD("get_point_position", "id"), &AStar2D::get_point_position); + ClassDB::bind_method(D_METHOD("set_point_position", "id", "position"), &AStar2D::set_point_position); + ClassDB::bind_method(D_METHOD("get_point_weight_scale", "id"), &AStar2D::get_point_weight_scale); + ClassDB::bind_method(D_METHOD("set_point_weight_scale", "id", "weight_scale"), &AStar2D::set_point_weight_scale); + ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar2D::remove_point); + ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar2D::has_point); + ClassDB::bind_method(D_METHOD("get_point_connections", "id"), &AStar2D::get_point_connections); + ClassDB::bind_method(D_METHOD("get_points"), &AStar2D::get_points); + + ClassDB::bind_method(D_METHOD("set_point_disabled", "id", "disabled"), &AStar2D::set_point_disabled, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("is_point_disabled", "id"), &AStar2D::is_point_disabled); + + ClassDB::bind_method(D_METHOD("connect_points", "id", "to_id", "bidirectional"), &AStar2D::connect_points, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("disconnect_points", "id", "to_id"), &AStar2D::disconnect_points); + ClassDB::bind_method(D_METHOD("are_points_connected", "id", "to_id"), &AStar2D::are_points_connected); + + ClassDB::bind_method(D_METHOD("clear"), &AStar2D::clear); + + ClassDB::bind_method(D_METHOD("get_closest_point", "to_position"), &AStar2D::get_closest_point); + ClassDB::bind_method(D_METHOD("get_closest_position_in_segment", "to_position"), &AStar2D::get_closest_position_in_segment); + + ClassDB::bind_method(D_METHOD("get_point_path", "from_id", "to_id"), &AStar2D::get_point_path); + ClassDB::bind_method(D_METHOD("get_id_path", "from_id", "to_id"), &AStar2D::get_id_path); +} + +AStar2D::AStar2D() { +} + +AStar2D::~AStar2D() { +} diff --git a/core/math/a_star.h b/core/math/a_star.h index ba35d929b3..e2a0356c7c 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -143,4 +143,43 @@ public: ~AStar(); }; +class AStar2D : public Reference { + GDCLASS(AStar2D, Reference); + AStar astar; + +protected: + static void _bind_methods(); + +public: + int get_available_point_id() const; + + void add_point(int p_id, const Vector2 &p_pos, real_t p_weight_scale = 1); + Vector2 get_point_position(int p_id) const; + void set_point_position(int p_id, const Vector2 &p_pos); + real_t get_point_weight_scale(int p_id) const; + void set_point_weight_scale(int p_id, real_t p_weight_scale); + void remove_point(int p_id); + bool has_point(int p_id) const; + PoolVector<int> get_point_connections(int p_id); + Array get_points(); + + void set_point_disabled(int p_id, bool p_disabled = true); + bool is_point_disabled(int p_id) const; + + void connect_points(int p_id, int p_with_id, bool p_bidirectional = true); + void disconnect_points(int p_id, int p_with_id); + bool are_points_connected(int p_id, int p_with_id) const; + + void clear(); + + int get_closest_point(const Vector2 &p_point) const; + Vector2 get_closest_position_in_segment(const Vector2 &p_point) const; + + PoolVector<Vector2> get_point_path(int p_from_id, int p_to_id); + PoolVector<int> get_id_path(int p_from_id, int p_to_id); + + AStar2D(); + ~AStar2D(); +}; + #endif // ASTAR_H diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 97c96b4018..135df4e5bd 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -184,6 +184,7 @@ void register_core_types() { ClassDB::register_class<PackedDataContainer>(); ClassDB::register_virtual_class<PackedDataContainerRef>(); ClassDB::register_class<AStar>(); + ClassDB::register_class<AStar2D>(); ClassDB::register_class<EncodedObjectAsID>(); ClassDB::register_class<RandomNumberGenerator>(); diff --git a/doc/classes/AStar.xml b/doc/classes/AStar.xml index 16ceb293ad..81722535c2 100644 --- a/doc/classes/AStar.xml +++ b/doc/classes/AStar.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AStar" inherits="Reference" category="Core" version="3.2"> <brief_description> - AStar class representation that uses vectors as edges. + AStar class representation that uses 3d-vectors as edges. </brief_description> <description> A* (A star) is a computer algorithm that is widely used in pathfinding and graph traversal, the process of plotting an efficiently directed path between multiple points. It enjoys widespread use due to its performance and accuracy. Godot's A* implementation make use of vectors as points. diff --git a/doc/classes/AStar2D.xml b/doc/classes/AStar2D.xml new file mode 100644 index 0000000000..b86e53d4d4 --- /dev/null +++ b/doc/classes/AStar2D.xml @@ -0,0 +1,258 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="AStar2D" inherits="Reference" category="Core" version="3.2"> + <brief_description> + AStar class representation that uses 2d-vectors as edges. + </brief_description> + <description> + This is a wrapper for the [AStar] class which uses 2D vectors instead of 3D vectors. + </description> + <tutorials> + </tutorials> + <methods> + <method name="add_point"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="position" type="Vector2"> + </argument> + <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. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(1, 0), 4) # Adds the point (1, 0) with weight_scale 4 and id 1 + [/codeblock] + If there already exists a point for the given id, its position and weight scale are updated to the given values. + </description> + </method> + <method name="are_points_connected" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + Returns whether there is a connection/segment between the given points. + </description> + </method> + <method name="clear"> + <return type="void"> + </return> + <description> + Clears all the points and segments. + </description> + </method> + <method name="connect_points"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <argument index="2" name="bidirectional" type="bool" default="true"> + </argument> + <description> + Creates a segment between the given points. If [code]bidirectional[/code] is [code]false[/code], only movement from [code]id[/code] to [code]to_id[/code] is allowed, not the reverse direction. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(1, 1)) + as.add_point(2, Vector2(0, 5)) + as.connect_points(1, 2, false) + [/codeblock] + </description> + </method> + <method name="disconnect_points"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + Deletes the segment between the given points. + </description> + </method> + <method name="get_available_point_id" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns the next available point id with no point associated to it. + </description> + </method> + <method name="get_closest_point" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="to_position" type="Vector2"> + </argument> + <description> + Returns the id of the closest point to [code]to_position[/code]. Returns -1 if there are no points in the points pool. + </description> + </method> + <method name="get_closest_position_in_segment" qualifiers="const"> + <return type="Vector2"> + </return> + <argument index="0" name="to_position" type="Vector2"> + </argument> + <description> + Returns the closest position to [code]to_position[/code] that resides inside a segment between two connected points. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(0, 0)) + as.add_point(2, Vector2(0, 5)) + as.connect_points(1, 2) + var res = as.get_closest_position_in_segment(Vector2(3, 3)) # returns (0, 3) + [/codeblock] + The result is in the segment that goes from [code]y = 0[/code] to [code]y = 5[/code]. It's the closest position in the segment to the given point. + </description> + </method> + <method name="get_id_path"> + <return type="PoolIntArray"> + </return> + <argument index="0" name="from_id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + Returns an array with the ids of the points that form the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(0, 0)) + as.add_point(2, Vector2(0, 1), 1) # default weight is 1 + as.add_point(3, Vector2(1, 1)) + as.add_point(4, Vector2(2, 0)) + + as.connect_points(1, 2, false) + as.connect_points(2, 3, false) + as.connect_points(4, 3, false) + as.connect_points(1, 4, false) + as.connect_points(5, 4, false) + + var res = as.get_id_path(1, 3) # returns [1, 2, 3] + [/codeblock] + If you change the 2nd point's weight to 3, then the result will be [code][1, 4, 3][/code] instead, because now even though the distance is longer, it's "easier" to get through point 4 than through point 2. + </description> + </method> + <method name="get_point_connections"> + <return type="PoolIntArray"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns an array with the ids of the points that form the connect with the given point. + [codeblock] + var as = AStar2D.new() + as.add_point(1, Vector2(0, 0)) + as.add_point(2, Vector2(0, 1)) + as.add_point(3, Vector2(1, 1)) + as.add_point(4, Vector2(2, 0)) + + as.connect_points(1, 2, true) + as.connect_points(1, 3, true) + + var neighbors = as.get_point_connections(1) # returns [2, 3] + [/codeblock] + </description> + </method> + <method name="get_point_path"> + <return type="PoolVector2Array"> + </return> + <argument index="0" name="from_id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + Returns an array with the points that are in the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path. + </description> + </method> + <method name="get_point_position" qualifiers="const"> + <return type="Vector2"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns the position of the point associated with the given id. + </description> + </method> + <method name="get_point_weight_scale" qualifiers="const"> + <return type="float"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns the weight scale of the point associated with the given id. + </description> + </method> + <method name="get_points"> + <return type="Array"> + </return> + <description> + Returns an array of all points. + </description> + </method> + <method name="has_point" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns whether a point associated with the given id exists. + </description> + </method> + <method name="is_point_disabled" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Returns whether a point is disabled or not for pathfinding. By default, all points are enabled. + </description> + </method> + <method name="remove_point"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + Removes the point associated with the given id from the points pool. + </description> + </method> + <method name="set_point_disabled"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="disabled" type="bool" default="true"> + </argument> + <description> + Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle. + </description> + </method> + <method name="set_point_position"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="position" type="Vector2"> + </argument> + <description> + Sets the position for the point with the given id. + </description> + </method> + <method name="set_point_weight_scale"> + <return type="void"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="weight_scale" type="float"> + </argument> + <description> + Sets the [code]weight_scale[/code] for the point with the given id. + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml index db35b2f352..3ea280cba3 100644 --- a/doc/classes/AcceptDialog.xml +++ b/doc/classes/AcceptDialog.xml @@ -57,12 +57,15 @@ </method> </methods> <members> + <member name="dialog_autowrap" type="bool" setter="set_autowrap" getter="has_autowrap"> + Sets autowrapping for the text in the dialog. + </member> <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok"> If [code]true[/code], the dialog is hidden when the OK button is pressed. You can set it to [code]false[/code] if you want to do e.g. input validation when receiving the [signal confirmed] signal, and handle hiding the dialog in your own logic. Default value: [code]true[/code]. Note: Some nodes derived from this class can have a different default value, and potentially their own built-in logic overriding this setting. For example [FileDialog] defaults to [code]false[/code], and has its own input validation code that is called when you press OK, which eventually hides the dialog if the input is valid. As such this property can't be used in [FileDialog] to disable hiding the dialog when pressing OK. </member> <member name="dialog_text" type="String" setter="set_text" getter="get_text"> - The text displayed by this dialog. + The text displayed by the dialog. </member> </members> <signals> diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 3295753bda..67e42dfb8c 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -2083,8 +2083,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { moving_selection_from_ofs = (mb->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale(); } accept_event(); - } else { - emit_signal("clear_selection"); } } @@ -2326,7 +2324,7 @@ void AnimationTrackEdit::set_in_group(bool p_enable) { update(); } -void AnimationTrackEdit::append_to_selection(const Rect2 &p_box) { +void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselection) { Rect2 select_rect(timeline->get_name_limit(), 0, get_size().width - timeline->get_name_limit() - timeline->get_buttons_width(), get_size().height); select_rect = select_rect.clip(p_box); @@ -2339,7 +2337,10 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box) { rect.position.x += offset; if (select_rect.intersects(rect)) { - emit_signal("select_key", i, false); + if (p_deselection) + emit_signal("deselect_key", i); + else + emit_signal("select_key", i, false); } } } @@ -4342,7 +4343,7 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { Rect2 local_rect = box_select_rect; local_rect.position -= track_edits[i]->get_global_position(); - track_edits[i]->append_to_selection(local_rect); + track_edits[i]->append_to_selection(local_rect, mb->get_command()); } if (_get_track_selected() == -1 && track_edits.size() > 0) { //minimal hack to make shortcuts work @@ -4374,8 +4375,8 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { } if (!box_selection->is_visible_in_tree()) { - if (!mm->get_shift()) { - _clear_selection(); //only append if shift is pressed + if (!mm->get_command() && !mm->get_shift()) { + _clear_selection(); } box_selection->show(); } diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index c64f663b3b..54e0675ab7 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -231,7 +231,7 @@ public: void cancel_drop(); void set_in_group(bool p_enable); - void append_to_selection(const Rect2 &p_box); + void append_to_selection(const Rect2 &p_box, bool p_deselection); AnimationTrackEdit(); }; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index e8f5139cd5..a15ae2efda 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -269,7 +269,7 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) { int childCount = p_desired_node->get_child_count(); - if (p_desired_node->get_filename() == p_target_scene_path) { + if (_track_inherit(p_target_scene_path, p_desired_node)) { return true; } @@ -284,6 +284,33 @@ bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_pat return false; } +bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_desired_node) { + Node *p = p_desired_node; + bool result = false; + Vector<Node *> instances; + while (true) { + if (p->get_filename() == p_target_scene_path) { + result = true; + break; + } + Ref<SceneState> ss = p->get_scene_inherited_state(); + if (ss.is_valid()) { + String path = ss->get_path(); + Ref<PackedScene> data = ResourceLoader::load(path); + if (data.is_valid()) { + p = data->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); + instances.push_back(p); + } else + break; + } else + break; + } + for (int i = 0; i < instances.size(); i++) { + memdelete(instances[i]); + } + return result; +} + void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option = p_tool; diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 9f9e93f2df..b645c22295 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -165,6 +165,7 @@ class SceneTreeDock : public VBoxContainer { void _script_open_request(const Ref<Script> &p_script); bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node); + bool _track_inherit(const String &p_target_scene_path, Node *p_desired_node); void _node_selected(); void _node_renamed(); diff --git a/platform/x11/detect_prime.cpp b/platform/x11/detect_prime.cpp index 0fde2a0c04..26008feade 100644 --- a/platform/x11/detect_prime.cpp +++ b/platform/x11/detect_prime.cpp @@ -159,10 +159,11 @@ int detect_prime() { if (!stat_loc) { // No need to do anything complicated here. Anything less than // PIPE_BUF will be delivered in one read() call. - read(fdset[0], string, sizeof(string) - 1); - - vendors[i] = string; - renderers[i] = string + strlen(string) + 1; + // Leave it 'Unknown' otherwise. + if (read(fdset[0], string, sizeof(string) - 1) > 0) { + vendors[i] = string; + renderers[i] = string + strlen(string) + 1; + } } close(fdset[0]); @@ -190,8 +191,9 @@ int detect_prime() { memcpy(&string, vendor, vendor_len); memcpy(&string[vendor_len], renderer, renderer_len); - write(fdset[1], string, vendor_len + renderer_len); - + if (write(fdset[1], string, vendor_len + renderer_len) == -1) { + print_verbose("Couldn't write vendor/renderer string."); + } close(fdset[1]); exit(0); } diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp index 3e9e8033e8..21c3b0ac91 100644 --- a/platform/x11/joypad_linux.cpp +++ b/platform/x11/joypad_linux.cpp @@ -414,7 +414,9 @@ void JoypadLinux::joypad_vibration_start(int p_id, float p_weak_magnitude, float play.type = EV_FF; play.code = effect.id; play.value = 1; - write(joy.fd, (const void *)&play, sizeof(play)); + if (write(joy.fd, (const void *)&play, sizeof(play)) == -1) { + print_verbose("Couldn't write to Joypad device."); + } joy.ff_effect_id = effect.id; joy.ff_effect_timestamp = p_timestamp; diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 3557f0425c..4247266e3d 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -752,7 +752,7 @@ Area::Area() : gravity_is_point = false; gravity_distance_scale = 0; linear_damp = 0.1; - angular_damp = 1; + angular_damp = 0.1; priority = 0; monitoring = false; monitorable = false; diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 60f8806b25..a2411743d4 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -599,6 +599,9 @@ void AnimationNodeStateMachine::remove_node(const StringName &p_name) { { Ref<AnimationNode> node = states[p_name].node; + + ERR_FAIL_COND(node.is_null()); + node->disconnect("tree_changed", this, "_tree_changed"); } diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 89f3d509d0..4da11b671e 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -406,12 +406,20 @@ void AcceptDialog::set_hide_on_ok(bool p_hide) { hide_on_ok = p_hide; } - bool AcceptDialog::get_hide_on_ok() const { return hide_on_ok; } +void AcceptDialog::set_autowrap(bool p_autowrap) { + + label->set_autowrap(p_autowrap); +} +bool AcceptDialog::has_autowrap() { + + return label->has_autowrap(); +} + void AcceptDialog::register_text_enter(Node *p_line_edit) { ERR_FAIL_NULL(p_line_edit); @@ -530,6 +538,8 @@ void AcceptDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_custom_action"), &AcceptDialog::_custom_action); ClassDB::bind_method(D_METHOD("set_text", "text"), &AcceptDialog::set_text); ClassDB::bind_method(D_METHOD("get_text"), &AcceptDialog::get_text); + ClassDB::bind_method(D_METHOD("set_autowrap", "autowrap"), &AcceptDialog::set_autowrap); + ClassDB::bind_method(D_METHOD("has_autowrap"), &AcceptDialog::has_autowrap); ADD_SIGNAL(MethodInfo("confirmed")); ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING, "action"))); @@ -537,6 +547,7 @@ void AcceptDialog::_bind_methods() { ADD_GROUP("Dialog", "dialog"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "dialog_text", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_DEFAULT_INTL), "set_text", "get_text"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_hide_on_ok"), "set_hide_on_ok", "get_hide_on_ok"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_autowrap"), "set_autowrap", "has_autowrap"); } bool AcceptDialog::swap_ok_cancel = false; @@ -555,7 +566,6 @@ AcceptDialog::AcceptDialog() { label->set_anchor(MARGIN_BOTTOM, ANCHOR_END); label->set_begin(Point2(margin, margin)); label->set_end(Point2(-margin, -button_margin - 10)); - //label->set_autowrap(true); add_child(label); hbc = memnew(HBoxContainer); diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h index 4b89ac54c5..c1a7f26a85 100644 --- a/scene/gui/dialogs.h +++ b/scene/gui/dialogs.h @@ -145,6 +145,9 @@ public: void set_text(String p_text); String get_text() const; + void set_autowrap(bool p_autowrap); + bool has_autowrap(); + AcceptDialog(); ~AcceptDialog(); }; diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index e4da659b0d..1ca643cd7a 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1425,7 +1425,9 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p TransformTrack *tt = static_cast<TransformTrack *>(t); ERR_FAIL_INDEX(p_key_idx, tt->transforms.size()); + Dictionary d = p_value; + if (d.has("location")) tt->transforms.write[p_key_idx].value.loc = d["location"]; if (d.has("rotation")) @@ -1438,6 +1440,7 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p ValueTrack *vt = static_cast<ValueTrack *>(t); ERR_FAIL_INDEX(p_key_idx, vt->values.size()); + vt->values.write[p_key_idx].value = p_value; } break; @@ -1445,11 +1448,14 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p MethodTrack *mt = static_cast<MethodTrack *>(t); ERR_FAIL_INDEX(p_key_idx, mt->methods.size()); + Dictionary d = p_value; + if (d.has("method")) mt->methods.write[p_key_idx].method = d["method"]; if (d.has("args")) mt->methods.write[p_key_idx].params = d["args"]; + } break; case TYPE_BEZIER: { @@ -1469,6 +1475,7 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p case TYPE_AUDIO: { AudioTrack *at = static_cast<AudioTrack *>(t); + ERR_FAIL_INDEX(p_key_idx, at->values.size()); Dictionary k = p_value; ERR_FAIL_COND(!k.has("start_offset")); @@ -1483,6 +1490,7 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p case TYPE_ANIMATION: { AnimationTrack *at = static_cast<AnimationTrack *>(t); + ERR_FAIL_INDEX(p_key_idx, at->values.size()); at->values.write[p_key_idx].value = p_value; diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp index 9d68869bc2..ad3e40916d 100644 --- a/servers/physics/area_sw.cpp +++ b/servers/physics/area_sw.cpp @@ -250,7 +250,7 @@ AreaSW::AreaSW() : gravity_is_point = false; gravity_distance_scale = 0; point_attenuation = 1; - angular_damp = 1.0; + angular_damp = 0.1; linear_damp = 0.1; priority = 0; set_ray_pickable(false); |