From c05ff94b8432cf82f225069de63cb037304b9558 Mon Sep 17 00:00:00 2001 From: skyace65 Date: Thu, 10 Sep 2020 13:41:58 -0400 Subject: [PATCH 01/18] Improve SpriteFrames get_animation_loop description (cherry picked from commit d311c48d6a3cabd434a5dda85efc21f3ef8243d0) --- doc/classes/SpriteFrames.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/classes/SpriteFrames.xml b/doc/classes/SpriteFrames.xml index f002933ec69..ad3faa89a4e 100644 --- a/doc/classes/SpriteFrames.xml +++ b/doc/classes/SpriteFrames.xml @@ -54,7 +54,7 @@ - If [code]true[/code], the given animation will loop. + Returns [code]true[/code] if the given animation is configured to loop when it finishes playing. Otherwise, returns [code]false[/code]. From f8c4ffcdde4ac140cd4e26b9a1142b0473fb094c Mon Sep 17 00:00:00 2001 From: Pasi Nuutinmaki Date: Sun, 15 Mar 2020 10:01:28 +0200 Subject: [PATCH 02/18] Fix area calculation of Face3 There seemed to be a bug in area calculation in Face3::get_area()-function. It returned the area of "imaginary" parallelogram instead of the triangle. Therefore the area returned was twice the real area. This manifested itself when using a hydro module for godot ( https://gitlab.com/ringtechsolutions/godot-tools/hydro/hydro ) causing the buoyancy to be two times the expected value. "Reference": http://www.maths.usyd.edu.au/u/MOW/vectors/vectors-11/v-11-7.html (cherry picked from commit a165eed73bd9783a07cdec4571a4912df71464ce) --- core/math/face3.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/math/face3.cpp b/core/math/face3.cpp index a7a5e91d51a..674c5068a8c 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -180,8 +180,7 @@ Vector3 Face3::get_median_point() const { } real_t Face3::get_area() const { - - return vec3_cross(vertex[0] - vertex[1], vertex[0] - vertex[2]).length(); + return vec3_cross(vertex[0] - vertex[1], vertex[0] - vertex[2]).length() * 0.5; } ClockDirection Face3::get_clock_dir() const { From 11b8b8ad2715d8770e03fab7fd4ae63040154001 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Thu, 15 Oct 2020 07:53:18 -0700 Subject: [PATCH 03/18] Allow renaming bones and blendshapes. (cherry picked from commit d13568a8d1290713bbdab5a32a99e03d762cefc9) --- doc/classes/ArrayMesh.xml | 10 ++++++++++ doc/classes/Skeleton.xml | 10 ++++++++++ scene/3d/skeleton.cpp | 13 +++++++++++++ scene/3d/skeleton.h | 1 + scene/resources/mesh.cpp | 18 ++++++++++++++++++ scene/resources/mesh.h | 2 ++ scene/resources/primitive_meshes.cpp | 3 +++ scene/resources/primitive_meshes.h | 1 + 8 files changed, 58 insertions(+) diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index de47261ad1b..a270389616e 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -97,6 +97,16 @@ Will regenerate normal maps for the [ArrayMesh]. + + + + + + + + + + diff --git a/doc/classes/Skeleton.xml b/doc/classes/Skeleton.xml index 11b9ead4c6e..244cb29b7bf 100644 --- a/doc/classes/Skeleton.xml +++ b/doc/classes/Skeleton.xml @@ -212,6 +212,16 @@ + + + + + + + + + + diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 5a44cdac239..3f266e163a6 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -440,6 +440,18 @@ String Skeleton::get_bone_name(int p_bone) const { return bones[p_bone].name; } +void Skeleton::set_bone_name(int p_bone, const String &p_name) { + ERR_FAIL_INDEX(p_bone, bones.size()); + + for (int i = 0; i < bones.size(); i++) { + if (i != p_bone) { + ERR_FAIL_COND(bones[i].name == p_name); + } + } + + bones.write[p_bone].name = p_name; +} + bool Skeleton::is_bone_parent_of(int p_bone, int p_parent_bone_id) const { int parent_of_bone = get_bone_parent(p_bone); @@ -855,6 +867,7 @@ void Skeleton::_bind_methods() { ClassDB::bind_method(D_METHOD("add_bone", "name"), &Skeleton::add_bone); ClassDB::bind_method(D_METHOD("find_bone", "name"), &Skeleton::find_bone); ClassDB::bind_method(D_METHOD("get_bone_name", "bone_idx"), &Skeleton::get_bone_name); + ClassDB::bind_method(D_METHOD("set_bone_name", "bone_idx", "name"), &Skeleton::set_bone_name); ClassDB::bind_method(D_METHOD("get_bone_parent", "bone_idx"), &Skeleton::get_bone_parent); ClassDB::bind_method(D_METHOD("set_bone_parent", "bone_idx", "parent_idx"), &Skeleton::set_bone_parent); diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h index fb5d1367d4e..5713e40f002 100644 --- a/scene/3d/skeleton.h +++ b/scene/3d/skeleton.h @@ -161,6 +161,7 @@ public: void add_bone(const String &p_name); int find_bone(const String &p_name) const; String get_bone_name(int p_bone) const; + void set_bone_name(int p_bone, const String &p_name); bool is_bone_parent_of(int p_bone_id, int p_parent_bone_id) const; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index f997929ed3f..992958e4c41 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -918,6 +918,23 @@ StringName ArrayMesh::get_blend_shape_name(int p_index) const { ERR_FAIL_INDEX_V(p_index, blend_shapes.size(), StringName()); return blend_shapes[p_index]; } + +void ArrayMesh::set_blend_shape_name(int p_index, const StringName &p_name) { + ERR_FAIL_INDEX(p_index, blend_shapes.size()); + + StringName name = p_name; + int found = blend_shapes.find(name); + if (found != -1 && found != p_index) { + int count = 2; + do { + name = String(p_name) + " " + itos(count); + count++; + } while (blend_shapes.find(name) != -1); + } + + blend_shapes.write[p_index] = name; +} + void ArrayMesh::clear_blend_shapes() { ERR_FAIL_COND_MSG(surfaces.size(), "Can't set shape key count if surfaces are already created."); @@ -1439,6 +1456,7 @@ void ArrayMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("add_blend_shape", "name"), &ArrayMesh::add_blend_shape); ClassDB::bind_method(D_METHOD("get_blend_shape_count"), &ArrayMesh::get_blend_shape_count); ClassDB::bind_method(D_METHOD("get_blend_shape_name", "index"), &ArrayMesh::get_blend_shape_name); + ClassDB::bind_method(D_METHOD("set_blend_shape_name", "index", "name"), &ArrayMesh::set_blend_shape_name); ClassDB::bind_method(D_METHOD("clear_blend_shapes"), &ArrayMesh::clear_blend_shapes); ClassDB::bind_method(D_METHOD("set_blend_shape_mode", "mode"), &ArrayMesh::set_blend_shape_mode); ClassDB::bind_method(D_METHOD("get_blend_shape_mode"), &ArrayMesh::get_blend_shape_mode); diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index 3c4cbb570e5..0e3911156f1 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -129,6 +129,7 @@ public: virtual Ref surface_get_material(int p_idx) const = 0; virtual int get_blend_shape_count() const = 0; virtual StringName get_blend_shape_name(int p_index) const = 0; + virtual void set_blend_shape_name(int p_index, const StringName &p_name) = 0; PoolVector get_faces() const; Ref generate_triangle_mesh() const; @@ -195,6 +196,7 @@ public: void add_blend_shape(const StringName &p_name); int get_blend_shape_count() const; StringName get_blend_shape_name(int p_index) const; + void set_blend_shape_name(int p_index, const StringName &p_name); void clear_blend_shapes(); void set_blend_shape_mode(BlendShapeMode p_mode); diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index fe5bc09f7ca..a562d75f079 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -177,6 +177,9 @@ StringName PrimitiveMesh::get_blend_shape_name(int p_index) const { return StringName(); } +void PrimitiveMesh::set_blend_shape_name(int p_index, const StringName &p_name) { +} + AABB PrimitiveMesh::get_aabb() const { if (pending_request) { _update(); diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h index 8d9847cd965..209facf0305 100644 --- a/scene/resources/primitive_meshes.h +++ b/scene/resources/primitive_meshes.h @@ -76,6 +76,7 @@ public: virtual Ref surface_get_material(int p_idx) const; virtual int get_blend_shape_count() const; virtual StringName get_blend_shape_name(int p_index) const; + virtual void set_blend_shape_name(int p_index, const StringName &p_name); virtual AABB get_aabb() const; virtual RID get_rid() const; From 266314ba26c1b9591d5da48f1656335b22528b60 Mon Sep 17 00:00:00 2001 From: Jordan Schidlowsky Date: Fri, 4 Dec 2020 22:12:47 -0600 Subject: [PATCH 04/18] make 2d constraint solving more deterministic by solving in push order (cherry picked from commit 043b6c2d93a560209fcd59fbff6de083659835bc) --- servers/physics_2d/area_pair_2d_sw.cpp | 2 +- servers/physics_2d/body_2d_sw.cpp | 9 +++------ servers/physics_2d/body_2d_sw.h | 12 +++++++----- servers/physics_2d/body_pair_2d_sw.cpp | 5 ++--- servers/physics_2d/joints_2d_sw.cpp | 21 ++++++++++----------- servers/physics_2d/physics_2d_server_sw.cpp | 2 +- servers/physics_2d/step_2d_sw.cpp | 7 +++---- 7 files changed, 27 insertions(+), 31 deletions(-) diff --git a/servers/physics_2d/area_pair_2d_sw.cpp b/servers/physics_2d/area_pair_2d_sw.cpp index fb4113d6383..54991f05e3f 100644 --- a/servers/physics_2d/area_pair_2d_sw.cpp +++ b/servers/physics_2d/area_pair_2d_sw.cpp @@ -89,7 +89,7 @@ AreaPair2DSW::~AreaPair2DSW() { if (area->has_monitor_callback()) area->remove_body_from_query(body, body_shape, area_shape); } - body->remove_constraint(this); + body->remove_constraint(this, 0); area->remove_constraint(this); } diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index b4f837b3557..9cb22563545 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -576,16 +576,13 @@ void Body2DSW::integrate_velocities(real_t p_step) { } void Body2DSW::wakeup_neighbours() { - - for (Map::Element *E = constraint_map.front(); E; E = E->next()) { - - const Constraint2DSW *c = E->key(); + for (List >::Element *E = constraint_list.front(); E; E = E->next()) { + const Constraint2DSW *c = E->get().first; Body2DSW **n = c->get_body_ptr(); int bc = c->get_body_count(); for (int i = 0; i < bc; i++) { - - if (i == E->get()) + if (i == E->get().second) continue; Body2DSW *b = n[i]; if (b->mode != Physics2DServer::BODY_MODE_RIGID) diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h index 6f3a2b9ab7c..1755b411106 100644 --- a/servers/physics_2d/body_2d_sw.h +++ b/servers/physics_2d/body_2d_sw.h @@ -33,6 +33,8 @@ #include "area_2d_sw.h" #include "collision_object_2d_sw.h" +#include "core/list.h" +#include "core/pair.h" #include "core/vset.h" class Constraint2DSW; @@ -84,7 +86,7 @@ class Body2DSW : public CollisionObject2DSW { virtual void _shapes_changed(); Transform2D new_transform; - Map constraint_map; + List > constraint_list; struct AreaCMP { @@ -180,10 +182,10 @@ public: _FORCE_INLINE_ Body2DSW *get_island_list_next() const { return island_list_next; } _FORCE_INLINE_ void set_island_list_next(Body2DSW *p_next) { island_list_next = p_next; } - _FORCE_INLINE_ void add_constraint(Constraint2DSW *p_constraint, int p_pos) { constraint_map[p_constraint] = p_pos; } - _FORCE_INLINE_ void remove_constraint(Constraint2DSW *p_constraint) { constraint_map.erase(p_constraint); } - const Map &get_constraint_map() const { return constraint_map; } - _FORCE_INLINE_ void clear_constraint_map() { constraint_map.clear(); } + _FORCE_INLINE_ void add_constraint(Constraint2DSW *p_constraint, int p_pos) { constraint_list.push_back({ p_constraint, p_pos }); } + _FORCE_INLINE_ void remove_constraint(Constraint2DSW *p_constraint, int p_pos) { constraint_list.erase({ p_constraint, p_pos }); } + const List > &get_constraint_list() const { return constraint_list; } + _FORCE_INLINE_ void clear_constraint_list() { constraint_list.clear(); } _FORCE_INLINE_ void set_omit_force_integration(bool p_omit_force_integration) { omit_force_integration = p_omit_force_integration; } _FORCE_INLINE_ bool get_omit_force_integration() const { return omit_force_integration; } diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index 52f10d9a09d..282cc60824f 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -516,7 +516,6 @@ BodyPair2DSW::BodyPair2DSW(Body2DSW *p_A, int p_shape_A, Body2DSW *p_B, int p_sh } BodyPair2DSW::~BodyPair2DSW() { - - A->remove_constraint(this); - B->remove_constraint(this); + A->remove_constraint(this, 0); + B->remove_constraint(this, 1); } diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp index 0a1a38f9a5f..f1dc872b8f3 100644 --- a/servers/physics_2d/joints_2d_sw.cpp +++ b/servers/physics_2d/joints_2d_sw.cpp @@ -204,11 +204,12 @@ PinJoint2DSW::PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p } PinJoint2DSW::~PinJoint2DSW() { - - if (A) - A->remove_constraint(this); - if (B) - B->remove_constraint(this); + if (A) { + A->remove_constraint(this, 0); + } + if (B) { + B->remove_constraint(this, 1); + } } ////////////////////////////////////////////// @@ -350,9 +351,8 @@ GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_ } GrooveJoint2DSW::~GrooveJoint2DSW() { - - A->remove_constraint(this); - B->remove_constraint(this); + A->remove_constraint(this, 0); + B->remove_constraint(this, 1); } ////////////////////////////////////////////// @@ -463,7 +463,6 @@ DampedSpringJoint2DSW::DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Ve } DampedSpringJoint2DSW::~DampedSpringJoint2DSW() { - - A->remove_constraint(this); - B->remove_constraint(this); + A->remove_constraint(this, 0); + B->remove_constraint(this, 1); } diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index dd1e78d094e..8bc6e731e6d 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -598,7 +598,7 @@ void Physics2DServerSW::body_set_space(RID p_body, RID p_space) { if (body->get_space() == space) return; //pointless - body->clear_constraint_map(); + body->clear_constraint_list(); body->set_space(space); }; diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp index 05005b0fe06..b5e88c70da9 100644 --- a/servers/physics_2d/step_2d_sw.cpp +++ b/servers/physics_2d/step_2d_sw.cpp @@ -37,9 +37,8 @@ void Step2DSW::_populate_island(Body2DSW *p_body, Body2DSW **p_island, Constrain p_body->set_island_next(*p_island); *p_island = p_body; - for (Map::Element *E = p_body->get_constraint_map().front(); E; E = E->next()) { - - Constraint2DSW *c = (Constraint2DSW *)E->key(); + for (const List >::Element *E = p_body->get_constraint_list().front(); E; E = E->next()) { + Constraint2DSW *c = (Constraint2DSW *)E->get().first; if (c->get_island_step() == _step) continue; //already processed c->set_island_step(_step); @@ -47,7 +46,7 @@ void Step2DSW::_populate_island(Body2DSW *p_body, Body2DSW **p_island, Constrain *p_constraint_island = c; for (int i = 0; i < c->get_body_count(); i++) { - if (i == E->get()) + if (i == E->get().second) continue; Body2DSW *b = c->get_body_ptr()[i]; if (b->get_island_step() == _step || b->get_mode() == Physics2DServer::BODY_MODE_STATIC || b->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC) From a5842a83627942a42960f6b0c86f99d486d4eba7 Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Sun, 13 Dec 2020 02:37:23 +0100 Subject: [PATCH 05/18] Save resource: implement extension priority give .res less priority and .tres more priority as preferred extensions. (cherry picked from commit f2e906496b403452dd83b04f512cc53eb6dc7e4f) --- editor/editor_node.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6d33b8c2779..d4a60183c43 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1024,14 +1024,23 @@ void EditorNode::save_resource_as(const Ref &p_resource, const String file->clear_filters(); List preferred; - for (int i = 0; i < extensions.size(); i++) { - - if (p_resource->is_class("Script") && (extensions[i] == "tres" || extensions[i] == "res" || extensions[i] == "xml")) { + for (List::Element *E = extensions.front(); E; E = E->next()) { + if (p_resource->is_class("Script") && (E->get() == "tres" || E->get() == "res")) { //this serves no purpose and confused people continue; } - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); - preferred.push_back(extensions[i]); + file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + preferred.push_back(E->get()); + } + // Lowest priority extension + List::Element *res_element = preferred.find("res"); + if (res_element) { + preferred.move_to_back(res_element); + } + // Highest priority extension + List::Element *tres_element = preferred.find("tres"); + if (tres_element) { + preferred.move_to_front(tres_element); } if (p_at_path != String()) { From 43d3eca5e9e787521f857b14df79dbcdc7221437 Mon Sep 17 00:00:00 2001 From: univeous Date: Wed, 27 Jan 2021 11:47:35 +0800 Subject: [PATCH 06/18] allow input echo when changing ui focus (cherry picked from commit f5b506763e5448dfbba8414139a83a2fc3765b60) --- scene/main/viewport.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 07ee5253b46..1395b01daad 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2520,35 +2520,27 @@ void Viewport::_gui_input_event(Ref p_event) { if (from && p_event->is_pressed()) { Control *next = NULL; - Input *input = Input::get_singleton(); - - if (p_event->is_action_pressed("ui_focus_next") && input->is_action_just_pressed("ui_focus_next")) { - + if (p_event->is_action_pressed("ui_focus_next", true)) { next = from->find_next_valid_focus(); } - if (p_event->is_action_pressed("ui_focus_prev") && input->is_action_just_pressed("ui_focus_prev")) { - + if (p_event->is_action_pressed("ui_focus_prev", true)) { next = from->find_prev_valid_focus(); } - if (!mods && p_event->is_action_pressed("ui_up") && input->is_action_just_pressed("ui_up")) { - + if (!mods && p_event->is_action_pressed("ui_up", true)) { next = from->_get_focus_neighbour(MARGIN_TOP); } - if (!mods && p_event->is_action_pressed("ui_left") && input->is_action_just_pressed("ui_left")) { - + if (!mods && p_event->is_action_pressed("ui_left", true)) { next = from->_get_focus_neighbour(MARGIN_LEFT); } - if (!mods && p_event->is_action_pressed("ui_right") && input->is_action_just_pressed("ui_right")) { - + if (!mods && p_event->is_action_pressed("ui_right", true)) { next = from->_get_focus_neighbour(MARGIN_RIGHT); } - if (!mods && p_event->is_action_pressed("ui_down") && input->is_action_just_pressed("ui_down")) { - + if (!mods && p_event->is_action_pressed("ui_down", true)) { next = from->_get_focus_neighbour(MARGIN_BOTTOM); } From 224fce946bf29abcf9d06c26d4dd08f03780892a Mon Sep 17 00:00:00 2001 From: David Hoppenbrouwers Date: Sun, 20 Dec 2020 18:39:18 +0100 Subject: [PATCH 07/18] Fix joint RID not being passed to _set in PhysicalBone Also remove default RID() argument from JointData._set() (cherry picked from commit 41e00b678788138ecc4539cedfb053eb367ca298) --- scene/3d/physics_body.cpp | 2 +- scene/3d/physics_body.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 0d21fbe1b60..f5ae6cea092 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -2127,7 +2127,7 @@ bool PhysicalBone::_set(const StringName &p_name, const Variant &p_value) { } if (joint_data) { - if (joint_data->_set(p_name, p_value)) { + if (joint_data->_set(p_name, p_value, joint)) { #ifdef TOOLS_ENABLED if (get_gizmo().is_valid()) get_gizmo()->redraw(); diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 7e47fdc2973..de192f86c83 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -394,7 +394,7 @@ public: virtual JointType get_joint_type() { return JOINT_TYPE_NONE; } /// "j" is used to set the parameter inside the PhysicsServer - virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID()); + virtual bool _set(const StringName &p_name, const Variant &p_value, RID j); virtual bool _get(const StringName &p_name, Variant &r_ret) const; virtual void _get_property_list(List *p_list) const; @@ -404,7 +404,7 @@ public: struct PinJointData : public JointData { virtual JointType get_joint_type() { return JOINT_TYPE_PIN; } - virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID()); + virtual bool _set(const StringName &p_name, const Variant &p_value, RID j); virtual bool _get(const StringName &p_name, Variant &r_ret) const; virtual void _get_property_list(List *p_list) const; @@ -421,7 +421,7 @@ public: struct ConeJointData : public JointData { virtual JointType get_joint_type() { return JOINT_TYPE_CONE; } - virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID()); + virtual bool _set(const StringName &p_name, const Variant &p_value, RID j); virtual bool _get(const StringName &p_name, Variant &r_ret) const; virtual void _get_property_list(List *p_list) const; @@ -442,7 +442,7 @@ public: struct HingeJointData : public JointData { virtual JointType get_joint_type() { return JOINT_TYPE_HINGE; } - virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID()); + virtual bool _set(const StringName &p_name, const Variant &p_value, RID j); virtual bool _get(const StringName &p_name, Variant &r_ret) const; virtual void _get_property_list(List *p_list) const; @@ -465,7 +465,7 @@ public: struct SliderJointData : public JointData { virtual JointType get_joint_type() { return JOINT_TYPE_SLIDER; } - virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID()); + virtual bool _set(const StringName &p_name, const Variant &p_value, RID j); virtual bool _get(const StringName &p_name, Variant &r_ret) const; virtual void _get_property_list(List *p_list) const; @@ -543,7 +543,7 @@ public: virtual JointType get_joint_type() { return JOINT_TYPE_6DOF; } - virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID()); + virtual bool _set(const StringName &p_name, const Variant &p_value, RID j); virtual bool _get(const StringName &p_name, Variant &r_ret) const; virtual void _get_property_list(List *p_list) const; From 4628ab2a15ce24f92a9ef09e773b2c8bbdd22437 Mon Sep 17 00:00:00 2001 From: floppyhammer Date: Sun, 21 Feb 2021 18:52:20 +0800 Subject: [PATCH 08/18] ImproveCompletionPanelPositionInShaderEditor (cherry picked from commit e927a9fef031a8990185776d0aeee65ed78552d9) --- scene/gui/text_edit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index effeb181279..e999f6a8626 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1643,7 +1643,7 @@ void TextEdit::_notification(int p_what) { completion_rect.position.x = cursor_pos.x - completion_base_width - icon_area_width - csb_offset.x; - if (ajdusted_cursor_y + row_height + total_height > get_size().height) { + if (ajdusted_cursor_y + row_height + total_height > get_size().height && ajdusted_cursor_y > total_height) { // Completion panel above the cursor line completion_rect.position.y = ajdusted_cursor_y - total_height; } else { From b406e904ecb5066344f9d0113e19bc715b96dddd Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Sat, 13 Mar 2021 15:08:16 -0300 Subject: [PATCH 09/18] Fix EditorInspector not updating its theme on rare occasions (cherry picked from commit efa3927b49a4e3311083773779b78d3d752f2504) --- editor/editor_inspector.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index ca954a0228c..2b8d09cf8ce 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2216,11 +2216,10 @@ void EditorInspector::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", this, "_feature_profile_changed"); + _update_inspector_bg(); } if (p_what == NOTIFICATION_ENTER_TREE) { - - _update_inspector_bg(); if (!sub_inspector) { get_tree()->connect("node_removed", this, "_node_removed"); } From 917630107ca0196d330a1a620b543f400ad40ba9 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Fri, 19 Mar 2021 18:49:21 -0300 Subject: [PATCH 10/18] Select non-perfect matches if necessary in the Search Help dialog (cherry picked from commit 77597ea47cb6c5e7e0b9506cc8e8c305f0f59d9c) --- editor/editor_help_search.cpp | 24 +++++++++++++++--------- editor/editor_help_search.h | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 6057edeedc2..2eefa3dd488 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -127,7 +127,7 @@ void EditorHelpSearch::_notification(int p_what) { if (search->work()) { // Search done. - // Only point to the perfect match if it's a new search, and not just reopening a old one. + // Only point to the match if it's a new search, and not just reopening a old one. if (!old_search) results_tree->ensure_cursor_is_visible(); else @@ -321,6 +321,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes_init() { iterator_doc = EditorHelp::get_doc_data()->class_list.front(); matches.clear(); matched_item = NULL; + match_highest_score = 0; return true; } @@ -444,15 +445,20 @@ bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String } void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_text) { + float inverse_length = 1.f / float(p_text.length()); - if (!matched_item) { - if (search_flags & SEARCH_CASE_SENSITIVE) { - if (p_text.casecmp_to(term) == 0) - matched_item = p_item; - } else { - if (p_text.nocasecmp_to(term) == 0) - matched_item = p_item; - } + // Favor types where search term is a substring close to the start of the type. + float w = 0.5f; + int pos = p_text.findn(term); + float score = (pos > -1) ? 1.0f - w * MIN(1, 3 * pos * inverse_length) : MAX(0.f, .9f - w); + + // Favor shorter items: they resemble the search term more. + w = 0.1f; + score *= (1 - w) + w * (term.length() * inverse_length); + + if (match_highest_score == 0 || score > match_highest_score) { + matched_item = p_item; + match_highest_score = score; } } diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index 5ef8b9d2a3a..ef5786b2c52 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -125,6 +125,7 @@ class EditorHelpSearch::Runner : public Reference { TreeItem *root_item; Map class_items; TreeItem *matched_item; + float match_highest_score = 0; bool _is_class_disabled_by_feature_profile(const StringName &p_class); From d304187357594283ca419cf349cf92fd64f483ce Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Tue, 29 Sep 2020 01:31:41 -0400 Subject: [PATCH 11/18] Warn when creating a script with the same name as the parent class (cherry picked from commit 5a9037f828ce84a07c3e748e20b50b334b896991) --- editor/script_create_dialog.cpp | 29 +++++++++++++++++++++-------- editor/script_create_dialog.h | 2 ++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 3c95d408e7b..3cc1286b224 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -225,6 +225,14 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must return ""; } +String ScriptCreateDialog::_get_class_name() const { + if (has_named_classes) { + return class_name->get_text(); + } else { + return ProjectSettings::get_singleton()->localize_path(file_path->get_text()).get_file().get_basename(); + } +} + void ScriptCreateDialog::_class_name_changed(const String &p_name) { if (_validate_class(class_name->get_text())) { @@ -278,14 +286,7 @@ void ScriptCreateDialog::ok_pressed() { } void ScriptCreateDialog::_create_new() { - - String cname_param; - - if (has_named_classes) { - cname_param = class_name->get_text(); - } else { - cname_param = ProjectSettings::get_singleton()->localize_path(file_path->get_text()).get_file().get_basename(); - } + String cname_param = _get_class_name(); Ref