2
0
Эх сурвалжийг харах

Merge pull request #53136 from akien-mga/3.x-cherrypicks

Rémi Verschelde 4 жил өмнө
parent
commit
65ab9130e1

+ 7 - 2
.github/workflows/linux_builds.yml

@@ -4,7 +4,7 @@ on: [push, pull_request]
 # Global Settings
 env:
   GODOT_BASE_BRANCH: 3.x
-  SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no
+  SCONSFLAGS: verbose=yes warnings=all werror=yes
 
 concurrency:
   group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-linux
@@ -42,7 +42,7 @@ jobs:
             cache-name: linux-template-mono
             target: release
             tools: false
-            sconsflags: module_mono_enabled=yes mono_glue=no
+            sconsflags: module_mono_enabled=yes mono_glue=no debug_symbols=no
             build-mono: false
             artifact: true
 
@@ -125,6 +125,11 @@ jobs:
           DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --doctool . 2>&1 > /dev/null || true
           git diff --color --exit-code && ! git ls-files --others --exclude-standard | sed -e 's/^/New doc file missing in PR: /' | grep 'xml$'
 
+      - name: Prepare artifact
+        if: ${{ matrix.artifact }}
+        run: |
+          strip bin/godot.*
+
       - name: Upload artifact
         uses: ./.github/actions/upload-artifact
         if: ${{ matrix.artifact }}

+ 0 - 1
.github/workflows/windows_builds.yml

@@ -41,7 +41,6 @@ jobs:
           cache-name: ${{ matrix.cache-name }}
         continue-on-error: true
 
-
       - name: Setup python and scons
         uses: ./.github/actions/godot-deps
 

+ 1 - 0
doc/classes/Control.xml

@@ -52,6 +52,7 @@
 				* control is obstructed by another [Control] on top of it, which doesn't have [member mouse_filter] set to [constant MOUSE_FILTER_IGNORE];
 				* control's parent has [member mouse_filter] set to [constant MOUSE_FILTER_STOP] or has accepted the event;
 				* it happens outside the parent's rectangle and the parent has either [member rect_clip_content] or [method _clips_input] enabled.
+				[b]Note:[/b] Event position is relative to the control origin.
 			</description>
 		</method>
 		<method name="_make_custom_tooltip" qualifiers="virtual">

+ 18 - 6
doc/classes/TabContainer.xml

@@ -6,8 +6,6 @@
 	<description>
 		Sets the active tab's [code]visible[/code] property to the value [code]true[/code]. Sets all other children's to [code]false[/code].
 		Ignores non-[Control] children.
-		Individual tabs are always visible unless you use [method set_tab_disabled] and [method set_tab_title] to hide it.
-		To hide only a tab's content, nest the content inside a child [Control], so it receives the [TabContainer]'s visibility setting instead.
 	</description>
 	<tutorials>
 	</tutorials>
@@ -50,6 +48,13 @@
 				Returns [code]true[/code] if the tab at index [code]tab_idx[/code] is disabled.
 			</description>
 		</method>
+		<method name="get_tab_hidden" qualifiers="const">
+			<return type="bool" />
+			<argument index="0" name="tab_idx" type="int" />
+			<description>
+				Returns [code]true[/code] if the tab at index [code]tab_idx[/code] is hidden.
+			</description>
+		</method>
 		<method name="get_tab_icon" qualifiers="const">
 			<return type="Texture" />
 			<argument index="0" name="tab_idx" type="int" />
@@ -89,8 +94,15 @@
 			<argument index="0" name="tab_idx" type="int" />
 			<argument index="1" name="disabled" type="bool" />
 			<description>
-				If [code]disabled[/code] is [code]false[/code], hides the tab at index [code]tab_idx[/code].
-				[b]Note:[/b] Its title text will remain, unless also removed with [method set_tab_title].
+				If [code]disabled[/code] is [code]true[/code], disables the tab at index [code]tab_idx[/code], making it non-interactable.
+			</description>
+		</method>
+		<method name="set_tab_hidden">
+			<return type="void" />
+			<argument index="0" name="tab_idx" type="int" />
+			<argument index="1" name="hidden" type="bool" />
+			<description>
+				If [code]hidden[/code] is [code]true[/code], hides the tab at index [code]tab_idx[/code], making it disappear from the tab area.
 			</description>
 		</method>
 		<method name="set_tab_icon">
@@ -106,14 +118,14 @@
 			<argument index="0" name="tab_idx" type="int" />
 			<argument index="1" name="title" type="String" />
 			<description>
-				Sets a title for the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node, but this can be overridden with [method set_tab_title].
+				Sets a title for the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node.
 			</description>
 		</method>
 		<method name="set_tabs_rearrange_group">
 			<return type="void" />
 			<argument index="0" name="group_id" type="int" />
 			<description>
-				Defines rearrange group id, choose for each [TabContainer] the same value to enable tab drag between [TabContainer]. Enable drag with [code]set_drag_to_rearrange_enabled(true)[/code].
+				Defines rearrange group id, choose for each [TabContainer] the same value to enable tab drag between [TabContainer]. Enable drag with [member drag_to_rearrange_enabled].
 			</description>
 		</method>
 	</methods>

+ 3 - 4
doc/classes/Tabs.xml

@@ -79,7 +79,7 @@
 			<return type="String" />
 			<argument index="0" name="tab_idx" type="int" />
 			<description>
-				Returns the title of the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node, but this can be overridden with [method set_tab_title].
+				Returns the title of the tab at index [code]tab_idx[/code].
 			</description>
 		</method>
 		<method name="get_tabs_rearrange_group" qualifiers="const">
@@ -115,8 +115,7 @@
 			<argument index="0" name="tab_idx" type="int" />
 			<argument index="1" name="disabled" type="bool" />
 			<description>
-				If [code]disabled[/code] is [code]false[/code], hides the tab at index [code]tab_idx[/code].
-				[b]Note:[/b] Its title text will remain unless it is also removed with [method set_tab_title].
+				If [code]disabled[/code] is [code]true[/code], disables the tab at index [code]tab_idx[/code], making it non-interactable.
 			</description>
 		</method>
 		<method name="set_tab_icon">
@@ -139,7 +138,7 @@
 			<return type="void" />
 			<argument index="0" name="group_id" type="int" />
 			<description>
-				Defines the rearrange group ID. Choose for each [Tabs] the same value to dragging tabs between [Tabs]. Enable drag with [code]set_drag_to_rearrange_enabled(true)[/code].
+				Defines the rearrange group ID. Choose for each [Tabs] the same value to dragging tabs between [Tabs]. Enable drag with [member drag_to_rearrange_enabled].
 			</description>
 		</method>
 	</methods>

+ 13 - 12
editor/editor_node.cpp

@@ -485,6 +485,19 @@ void EditorNode::_notification(int p_what) {
 		} break;
 
 		case NOTIFICATION_READY: {
+			{
+				_initializing_addons = true;
+				Vector<String> addons;
+				if (ProjectSettings::get_singleton()->has_setting("editor_plugins/enabled")) {
+					addons = ProjectSettings::get_singleton()->get("editor_plugins/enabled");
+				}
+
+				for (int i = 0; i < addons.size(); i++) {
+					set_addon_plugin_enabled(addons[i], true);
+				}
+				_initializing_addons = false;
+			}
+
 			VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true);
 			VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true);
 			VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true);
@@ -836,18 +849,6 @@ void EditorNode::_sources_changed(bool p_exist) {
 			load_scene(defer_load_scene);
 			defer_load_scene = "";
 		}
-
-		// Only enable addons once resources have been imported
-		_initializing_addons = true;
-		Vector<String> addons;
-		if (ProjectSettings::get_singleton()->has_setting("editor_plugins/enabled")) {
-			addons = ProjectSettings::get_singleton()->get("editor_plugins/enabled");
-		}
-
-		for (int i = 0; i < addons.size(); i++) {
-			set_addon_plugin_enabled(addons[i], true);
-		}
-		_initializing_addons = false;
 	}
 }
 

+ 12 - 6
editor/import_dock.cpp

@@ -127,12 +127,7 @@ void ImportDock::set_edit_path(const String &p_path) {
 		}
 	}
 
-	import_as->add_separator();
-	import_as->add_item(TTR("Keep File (No Import)"));
-	import_as->set_item_metadata(import_as->get_item_count() - 1, "keep");
-	if (importer_name == "keep") {
-		import_as->select(import_as->get_item_count() - 1);
-	}
+	_add_keep_import_option(importer_name);
 
 	import->set_disabled(false);
 	import_as->set_disabled(false);
@@ -141,6 +136,15 @@ void ImportDock::set_edit_path(const String &p_path) {
 	imported->set_text(p_path.get_file());
 }
 
+void ImportDock::_add_keep_import_option(const String &p_importer_name) {
+	import_as->add_separator();
+	import_as->add_item(TTR("Keep File (No Import)"));
+	import_as->set_item_metadata(import_as->get_item_count() - 1, "keep");
+	if (p_importer_name == "keep") {
+		import_as->select(import_as->get_item_count() - 1);
+	}
+}
+
 void ImportDock::_update_options(const Ref<ConfigFile> &p_config) {
 	List<ResourceImporter::ImportOption> options;
 
@@ -262,6 +266,8 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
 		}
 	}
 
+	_add_keep_import_option(params->importer->get_importer_name());
+
 	_update_preset_menu();
 
 	params->paths = p_paths;

+ 1 - 0
editor/import_dock.h

@@ -63,6 +63,7 @@ class ImportDock : public VBoxContainer {
 	void _importer_selected(int i_idx);
 	void _update_options(const Ref<ConfigFile> &p_config = Ref<ConfigFile>());
 	void _update_preset_menu();
+	void _add_keep_import_option(const String &p_importer_name);
 
 	void _property_toggled(const StringName &p_prop, bool p_checked);
 	void _reimport_attempt();

+ 1 - 0
modules/bullet/rigid_body_bullet.cpp

@@ -320,6 +320,7 @@ RigidBodyBullet::~RigidBodyBullet() {
 
 void RigidBodyBullet::init_kinematic_utilities() {
 	kinematic_utilities = memnew(KinematicUtilities(this));
+	reload_kinematic_shapes();
 }
 
 void RigidBodyBullet::destroy_kinematic_utilities() {

+ 0 - 2
modules/bullet/space_bullet.cpp

@@ -967,7 +967,6 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
 
 	if (!p_body->get_kinematic_utilities()) {
 		p_body->init_kinematic_utilities();
-		p_body->reload_kinematic_shapes();
 	}
 
 	btVector3 initial_recover_motion(0, 0, 0);
@@ -1109,7 +1108,6 @@ int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p
 
 	if (!p_body->get_kinematic_utilities()) {
 		p_body->init_kinematic_utilities();
-		p_body->reload_kinematic_shapes();
 	}
 
 	btVector3 recover_motion(0, 0, 0);

+ 2 - 0
scene/gui/tab_container.cpp

@@ -1055,6 +1055,8 @@ void TabContainer::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("get_tab_icon", "tab_idx"), &TabContainer::get_tab_icon);
 	ClassDB::bind_method(D_METHOD("set_tab_disabled", "tab_idx", "disabled"), &TabContainer::set_tab_disabled);
 	ClassDB::bind_method(D_METHOD("get_tab_disabled", "tab_idx"), &TabContainer::get_tab_disabled);
+	ClassDB::bind_method(D_METHOD("set_tab_hidden", "tab_idx", "hidden"), &TabContainer::set_tab_hidden);
+	ClassDB::bind_method(D_METHOD("get_tab_hidden", "tab_idx"), &TabContainer::get_tab_hidden);
 	ClassDB::bind_method(D_METHOD("get_tab_idx_at_point", "point"), &TabContainer::get_tab_idx_at_point);
 	ClassDB::bind_method(D_METHOD("set_popup", "popup"), &TabContainer::set_popup);
 	ClassDB::bind_method(D_METHOD("get_popup"), &TabContainer::get_popup);

+ 11 - 4
scene/gui/tabs.cpp

@@ -89,7 +89,6 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
 	if (mm.is_valid()) {
 		Point2 pos = mm->get_position();
 
-		highlight_arrow = -1;
 		if (buttons_visible) {
 			Ref<Texture> incr = get_icon("increment");
 			Ref<Texture> decr = get_icon("decrement");
@@ -97,14 +96,22 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
 			int limit = get_size().width - incr->get_width() - decr->get_width();
 
 			if (pos.x > limit + decr->get_width()) {
-				highlight_arrow = 1;
+				if (highlight_arrow != 1) {
+					highlight_arrow = 1;
+					update();
+				}
 			} else if (pos.x > limit) {
-				highlight_arrow = 0;
+				if (highlight_arrow != 0) {
+					highlight_arrow = 0;
+					update();
+				}
+			} else if (highlight_arrow != -1) {
+				highlight_arrow = -1;
+				update();
 			}
 		}
 
 		_update_hover();
-		update();
 		return;
 	}
 

+ 2 - 5
scene/resources/primitive_meshes.cpp

@@ -1456,8 +1456,6 @@ void SphereMesh::_create_mesh_array(Array &p_arr) const {
 	int i, j, prevrow, thisrow, point;
 	float x, y, z;
 
-	float scale = height * (is_hemisphere ? 1.0 : 0.5);
-
 	// set our bounding box
 
 	PoolVector<Vector3> points;
@@ -1481,7 +1479,7 @@ void SphereMesh::_create_mesh_array(Array &p_arr) const {
 
 		v /= (rings + 1);
 		w = sin(Math_PI * v);
-		y = scale * cos(Math_PI * v);
+		y = height * (is_hemisphere ? 1.0 : 0.5) * cos(Math_PI * v);
 
 		for (i = 0; i <= radial_segments; i++) {
 			float u = i;
@@ -1496,8 +1494,7 @@ void SphereMesh::_create_mesh_array(Array &p_arr) const {
 			} else {
 				Vector3 p = Vector3(x * radius * w, y, z * radius * w);
 				points.push_back(p);
-				Vector3 normal = Vector3(x * radius * w * scale, y / scale, z * radius * w * scale);
-				normals.push_back(normal.normalized());
+				normals.push_back(p.normalized());
 			};
 			ADD_TANGENT(z, 0.0, -x, 1.0)
 			uvs.push_back(Vector2(u, v));

+ 1 - 1
thirdparty/README.md

@@ -375,7 +375,7 @@ Collection of single-file libraries used in Godot components.
 ## nanosvg
 
 - Upstream: https://github.com/memononen/nanosvg
-- Version: git (3e403ec72a9145cbbcc6c63d94a4caf079aafec2, 2020)
+- Version: git (ccdb1995134d340a93fb20e3a3d323ccb3838dd0, 2021)
 - License: zlib
 
 Files extracted from the upstream source:

+ 4 - 0
thirdparty/misc/easing_equations.cpp

@@ -312,6 +312,10 @@ Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT]
 };
 
 real_t Tween::_run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) {
+	if (d == 0) {
+		// Special case to avoid dividing by 0 in equations.
+		return b + c;
+	}
 
 	interpolater cb = interpolaters[p_trans_type][p_ease_type];
 	ERR_FAIL_COND_V(cb == NULL, b);

+ 18 - 26
thirdparty/nanosvg/nanosvg.h

@@ -1215,35 +1215,22 @@ static const char* nsvg__getNextPathItem(const char* s, char* it)
 
 static unsigned int nsvg__parseColorHex(const char* str)
 {
-	unsigned int c = 0, r = 0, g = 0, b = 0;
-	int n = 0;
-	str++; // skip #
-	// Calculate number of characters.
-	while(str[n] && !nsvg__isspace(str[n]))
-		n++;
-	if (n == 6) {
-		sscanf(str, "%x", &c);
-	} else if (n == 3) {
-		sscanf(str, "%x", &c);
-		c = (c&0xf) | ((c&0xf0) << 4) | ((c&0xf00) << 8);
-		c |= c<<4;
-	}
-	r = (c >> 16) & 0xff;
-	g = (c >> 8) & 0xff;
-	b = c & 0xff;
-	return NSVG_RGB(r,g,b);
+	unsigned int r=0, g=0, b=0;
+	if (sscanf(str, "#%2x%2x%2x", &r, &g, &b) == 3 )		// 2 digit hex
+		return NSVG_RGB(r, g, b);
+	if (sscanf(str, "#%1x%1x%1x", &r, &g, &b) == 3 )		// 1 digit hex, e.g. #abc -> 0xccbbaa
+		return NSVG_RGB(r*17, g*17, b*17);			// same effect as (r<<4|r), (g<<4|g), ..
+	return NSVG_RGB(128, 128, 128);
 }
 
 static unsigned int nsvg__parseColorRGB(const char* str)
 {
-	int r = -1, g = -1, b = -1;
-	char s1[32]="", s2[32]="";
-	sscanf(str + 4, "%d%[%%, \t]%d%[%%, \t]%d", &r, s1, &g, s2, &b);
-	if (strchr(s1, '%')) {
-		return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100);
-	} else {
-		return NSVG_RGB(r,g,b);
-	}
+	unsigned int r=0, g=0, b=0;
+	if (sscanf(str, "rgb(%u, %u, %u)", &r, &g, &b) == 3)		// decimal integers
+		return NSVG_RGB(r, g, b);
+	if (sscanf(str, "rgb(%u%%, %u%%, %u%%)", &r, &g, &b) == 3)	// decimal integer percentage
+		return NSVG_RGB(r*255/100, g*255/100, b*255/100);
+	return NSVG_RGB(128, 128, 128);
 }
 
 typedef struct NSVGNamedColor {
@@ -2187,7 +2174,12 @@ static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args,
 	// The loop assumes an iteration per end point (including start and end), this +1.
 	ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f);
 	hda = (da / (float)ndivs) / 2.0f;
-	kappa = fabsf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda));
+	// Fix for ticket #179: division by 0: avoid cotangens around 0 (infinite)
+	if ((hda < 1e-3f) && (hda > -1e-3f))
+		hda *= 0.5f;
+	else
+		hda = (1.0f - cosf(hda)) / sinf(hda);
+	kappa = fabsf(4.0f / 3.0f * hda);
 	if (da < 0.0f)
 		kappa = -kappa;