Merge pull request #43683 from akien-mga/3.2-cherrypicks

Cherry-picks for the 3.2 branch (future 3.2.4) - 9th batch
This commit is contained in:
Rémi Verschelde 2020-11-19 22:12:23 +01:00 committed by GitHub
commit 06389f705b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 48 additions and 26 deletions

View File

@ -236,3 +236,13 @@ Engine::Engine() {
_frame_step = 0; _frame_step = 0;
editor_hint = false; editor_hint = false;
} }
Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr) :
name(p_name),
ptr(p_ptr) {
#ifdef DEBUG_ENABLED
if (Object::cast_to<Reference>(p_ptr)) {
ERR_PRINT("A class intended to be used as a singleton must *not* inherit from Reference.");
}
#endif
}

View File

@ -42,10 +42,7 @@ public:
struct Singleton { struct Singleton {
StringName name; StringName name;
Object *ptr; Object *ptr;
Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) : Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL);
name(p_name),
ptr(p_ptr) {
}
}; };
private: private:

View File

@ -155,8 +155,8 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
List<PropertyInfo> plist; List<PropertyInfo> plist;
get_property_list(&plist); get_property_list(&plist);
Resource *r = Object::cast_to<Resource>(ClassDB::instance(get_class())); Ref<Resource> r = Object::cast_to<Resource>(ClassDB::instance(get_class()));
ERR_FAIL_COND_V(!r, Ref<Resource>()); ERR_FAIL_COND_V(r.is_null(), Ref<Resource>());
r->local_scene = p_for_scene; r->local_scene = p_for_scene;
@ -186,9 +186,7 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
r->set(E->get().name, p); r->set(E->get().name, p);
} }
RES res = Ref<Resource>(r); return r;
return res;
} }
void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource> > &remap_cache) { void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource> > &remap_cache) {

View File

@ -188,7 +188,7 @@
<argument index="0" name="exit_code" type="int" default="-1"> <argument index="0" name="exit_code" type="int" default="-1">
</argument> </argument>
<description> <description>
Quits the application. A process [code]exit_code[/code] can optionally be passed as an argument. If this argument is [code]0[/code] or greater, it will override the [member OS.exit_code] defined before quitting the application. Quits the application at the end of the current iteration. A process [code]exit_code[/code] can optionally be passed as an argument. If this argument is [code]0[/code] or greater, it will override the [member OS.exit_code] defined before quitting the application.
</description> </description>
</method> </method>
<method name="reload_current_scene"> <method name="reload_current_scene">

View File

@ -1491,7 +1491,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
// Start rotation // Start rotation
if (drag_type == DRAG_NONE) { if (drag_type == DRAG_NONE) {
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) { if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
if ((b->get_control() && !b->get_alt() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) { if ((b->get_command() && !b->get_alt() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) {
List<CanvasItem *> selection = _get_edited_canvas_items(); List<CanvasItem *> selection = _get_edited_canvas_items();
// Remove not movable nodes // Remove not movable nodes

View File

@ -4993,6 +4993,8 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
} }
} }
} }
_finish_grid();
_init_grid();
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(p_option), grid_enabled); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(p_option), grid_enabled);

View File

@ -517,6 +517,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tools[SHAPE_NEW_RECTANGLE]->set_button_group(tg); tools[SHAPE_NEW_RECTANGLE]->set_button_group(tg);
tools[SHAPE_NEW_RECTANGLE]->set_tooltip(TTR("Create a new rectangle.")); tools[SHAPE_NEW_RECTANGLE]->set_tooltip(TTR("Create a new rectangle."));
tools[SHAPE_NEW_RECTANGLE]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_NEW_RECTANGLE)); tools[SHAPE_NEW_RECTANGLE]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_NEW_RECTANGLE));
tools[SHAPE_NEW_RECTANGLE]->set_shortcut(ED_SHORTCUT("tileset_editor/shape_new_rectangle", TTR("New Rectangle"), KEY_MASK_SHIFT | KEY_R));
tools[SHAPE_NEW_POLYGON] = memnew(ToolButton); tools[SHAPE_NEW_POLYGON] = memnew(ToolButton);
toolbar->add_child(tools[SHAPE_NEW_POLYGON]); toolbar->add_child(tools[SHAPE_NEW_POLYGON]);
@ -524,6 +525,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tools[SHAPE_NEW_POLYGON]->set_button_group(tg); tools[SHAPE_NEW_POLYGON]->set_button_group(tg);
tools[SHAPE_NEW_POLYGON]->set_tooltip(TTR("Create a new polygon.")); tools[SHAPE_NEW_POLYGON]->set_tooltip(TTR("Create a new polygon."));
tools[SHAPE_NEW_POLYGON]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_NEW_POLYGON)); tools[SHAPE_NEW_POLYGON]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_NEW_POLYGON));
tools[SHAPE_NEW_POLYGON]->set_shortcut(ED_SHORTCUT("tileset_editor/shape_new_polygon", TTR("New Polygon"), KEY_MASK_SHIFT | KEY_P));
separator_shape_toggle = memnew(VSeparator); separator_shape_toggle = memnew(VSeparator);
toolbar->add_child(separator_shape_toggle); toolbar->add_child(separator_shape_toggle);
@ -535,6 +537,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
toolbar->add_child(separator_delete); toolbar->add_child(separator_delete);
tools[SHAPE_DELETE] = memnew(ToolButton); tools[SHAPE_DELETE] = memnew(ToolButton);
tools[SHAPE_DELETE]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_DELETE)); tools[SHAPE_DELETE]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_DELETE));
tools[SHAPE_DELETE]->set_shortcut(ED_SHORTCUT("tileset_editor/shape_delete", TTR("Delete Selected Shape"), KEY_MASK_SHIFT | KEY_BACKSPACE));
toolbar->add_child(tools[SHAPE_DELETE]); toolbar->add_child(tools[SHAPE_DELETE]);
spin_priority = memnew(SpinBox); spin_priority = memnew(SpinBox);

View File

@ -2121,7 +2121,7 @@ void ProjectManager::_run_project_confirm() {
if (selected_main == "") { if (selected_main == "") {
run_error_diag->set_text(TTR("Can't run project: no main scene defined.\nPlease edit the project and set the main scene in the Project Settings under the \"Application\" category.")); run_error_diag->set_text(TTR("Can't run project: no main scene defined.\nPlease edit the project and set the main scene in the Project Settings under the \"Application\" category."));
run_error_diag->popup_centered(); run_error_diag->popup_centered();
return; continue;
} }
const String &selected = selected_list[i].project_key; const String &selected = selected_list[i].project_key;
@ -2130,7 +2130,7 @@ void ProjectManager::_run_project_confirm() {
if (!DirAccess::exists(path + "/.import")) { if (!DirAccess::exists(path + "/.import")) {
run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import.")); run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import."));
run_error_diag->popup_centered(); run_error_diag->popup_centered();
return; continue;
} }
print_line("Running project: " + path + " (" + selected + ")"); print_line("Running project: " + path + " (" + selected + ")");

View File

@ -2630,6 +2630,13 @@ public:
Error _zip_align_project(const String &sdk_path, const String &unaligned_file_path, const String &aligned_file_path) { Error _zip_align_project(const String &sdk_path, const String &unaligned_file_path, const String &aligned_file_path) {
// Look for the zipalign tool. // Look for the zipalign tool.
String zipalign_command_name;
#ifdef WINDOWS_ENABLED
zipalign_command_name = "zipalign.exe";
#else
zipalign_command_name = "zipalign";
#endif
String zipalign_command; String zipalign_command;
Error errn; Error errn;
String build_tools_dir = sdk_path.plus_file("build-tools"); String build_tools_dir = sdk_path.plus_file("build-tools");
@ -2644,7 +2651,7 @@ public:
while (!sub_dir.empty()) { while (!sub_dir.empty()) {
if (!sub_dir.begins_with(".") && da->current_is_dir()) { if (!sub_dir.begins_with(".") && da->current_is_dir()) {
// Check if the tool is here. // Check if the tool is here.
String tool_path = build_tools_dir.plus_file(sub_dir).plus_file("zipalign"); String tool_path = build_tools_dir.plus_file(sub_dir).plus_file(zipalign_command_name);
if (FileAccess::exists(tool_path)) { if (FileAccess::exists(tool_path)) {
zipalign_command = tool_path; zipalign_command = tool_path;
break; break;

View File

@ -45,9 +45,11 @@ def configure(env):
if env["target"] == "release": if env["target"] == "release":
if env["debug_symbols"] != "full": if env["debug_symbols"] != "full":
if env["optimize"] == "speed": # optimize for speed (default) if env["optimize"] == "speed": # optimize for speed (default)
env.Prepend(CCFLAGS=["-O3", "-fomit-frame-pointer", "-ftree-vectorize", "-msse2"]) env.Prepend(CCFLAGS=["-O3", "-fomit-frame-pointer", "-ftree-vectorize"])
else: # optimize for size else: # optimize for size
env.Prepend(CCFLAGS=["-Os", "-ftree-vectorize", "-msse2"]) env.Prepend(CCFLAGS=["-Os", "-ftree-vectorize"])
if env["arch"] != "arm64":
env.Prepend(CCFLAGS=["-msse2"])
if env["debug_symbols"] == "yes": if env["debug_symbols"] == "yes":
env.Prepend(CCFLAGS=["-g2"]) env.Prepend(CCFLAGS=["-g2"])
@ -81,16 +83,16 @@ def configure(env):
if "OSXCROSS_ROOT" in os.environ: if "OSXCROSS_ROOT" in os.environ:
env["osxcross"] = True env["osxcross"] = True
if not "osxcross" in env: # regular native build if env["arch"] == "arm64":
if env["arch"] == "arm64": print("Building for macOS 10.15+, platform arm64.")
print("Building for macOS 10.15+, platform arm64.") env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"])
env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15"]) env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"])
env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15"]) else:
else: print("Building for macOS 10.9+, platform x86-64.")
print("Building for macOS 10.9+, platform x86-64.") env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"])
env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"]) env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"])
env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"])
if not "osxcross" in env: # regular native build
if env["macports_clang"] != "no": if env["macports_clang"] != "no":
mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local")
mpclangver = env["macports_clang"] mpclangver = env["macports_clang"]
@ -111,7 +113,10 @@ def configure(env):
else: # osxcross build else: # osxcross build
root = os.environ.get("OSXCROSS_ROOT", 0) root = os.environ.get("OSXCROSS_ROOT", 0)
basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" if env["arch"] == "arm64":
basecmd = root + "/target/bin/arm64-apple-" + env["osxcross_sdk"] + "-"
else:
basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
ccache_path = os.environ.get("CCACHE") ccache_path = os.environ.get("CCACHE")
if ccache_path is None: if ccache_path is None: