diff options
-rw-r--r-- | editor/editor_inspector.cpp | 10 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 24 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 90 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/property_selector.cpp | 9 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs | 47 | ||||
-rw-r--r-- | platform/osx/detect.py | 6 |
7 files changed, 148 insertions, 39 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index a4385cdcf9..cbfd6ae6de 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -3479,10 +3479,14 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li String path = s->get_path(); String name = EditorNode::get_editor_data().script_class_get_name(path); if (name.is_empty()) { - if (!s->is_built_in()) { - name = path.get_file(); + if (s->is_built_in()) { + if (s->get_name().is_empty()) { + name = TTR("Built-in script"); + } else { + name = vformat("%s (%s)", s->get_name(), TTR("Built-in")); + } } else { - name = TTR("Built-in script"); + name = path.get_file(); } } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 2d65d73f21..c91351022f 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1225,6 +1225,30 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin if (err != OK) { EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + ".import\n"); } + + // Remove uid from .import file to avoid conflict. + Ref<ConfigFile> cfg; + cfg.instantiate(); + cfg->load(new_path + ".import"); + cfg->erase_section_key("remap", "uid"); + cfg->save(new_path + ".import"); + } else if (p_item.is_file && (old_path.get_extension() == "tscn" || old_path.get_extension() == "tres")) { + // FIXME: Quick hack to fix text resources. This should be fixed properly. + FileAccessRef file = FileAccess::open(old_path, FileAccess::READ, &err); + if (err == OK) { + PackedStringArray lines = file->get_as_utf8_string().split("\n"); + String line = lines[0]; + + if (line.contains("uid")) { + line = line.substr(0, line.find(" uid")) + "]"; + lines.write[0] = line; + + FileAccessRef file2 = FileAccess::open(new_path, FileAccess::WRITE, &err); + if (err == OK) { + file2->store_string(String("\n").join(lines)); + } + } + } } } else { EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + "\n"); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index dea637e82e..2e8ae1a286 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -1041,24 +1041,40 @@ bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, b if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) { int col_axis = -1; - float col_d = 1e20; - for (int i = 0; i < 3; i++) { - Plane plane(gt.basis.get_axis(i).normalized(), gt.origin); - Vector3 r; - if (!plane.intersects_ray(ray_pos, ray, &r)) { - continue; + Vector3 hit_position; + Vector3 hit_normal; + real_t ray_length = gt.origin.distance_to(ray_pos) + (GIZMO_CIRCLE_SIZE * gizmo_scale) * 4.0f; + if (Geometry3D::segment_intersects_sphere(ray_pos, ray_pos + ray * ray_length, gt.origin, gizmo_scale * (GIZMO_CIRCLE_SIZE), &hit_position, &hit_normal)) { + if (hit_normal.dot(_get_camera_normal()) < 0.05) { + hit_position = gt.xform_inv(hit_position).abs(); + int min_axis = hit_position.min_axis_index(); + if (hit_position[min_axis] < gizmo_scale * GIZMO_RING_HALF_WIDTH) { + col_axis = min_axis; + } } + } + + if (col_axis == -1) { + float col_d = 1e20; - const real_t dist = r.distance_to(gt.origin); - const Vector3 r_dir = (r - gt.origin).normalized(); + for (int i = 0; i < 3; i++) { + Plane plane(gt.basis.get_axis(i).normalized(), gt.origin); + Vector3 r; + if (!plane.intersects_ray(ray_pos, ray, &r)) { + continue; + } + + const real_t dist = r.distance_to(gt.origin); + const Vector3 r_dir = (r - gt.origin).normalized(); - if (_get_camera_normal().dot(r_dir) <= 0.005) { - if (dist > gizmo_scale * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && dist < gizmo_scale * (GIZMO_CIRCLE_SIZE + GIZMO_RING_HALF_WIDTH)) { - const real_t d = ray_pos.distance_to(r); - if (d < col_d) { - col_d = d; - col_axis = i; + if (_get_camera_normal().dot(r_dir) <= 0.005) { + if (dist > gizmo_scale * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && dist < gizmo_scale * (GIZMO_CIRCLE_SIZE + GIZMO_RING_HALF_WIDTH)) { + const real_t d = ray_pos.distance_to(r); + if (d < col_d) { + col_d = d; + col_axis = i; + } } } } @@ -2730,7 +2746,7 @@ void Node3DEditorViewport::_draw() { font->draw_string(ci, msgpos, message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 1)); } - if (_edit.mode == TRANSFORM_ROTATE) { + if (_edit.mode == TRANSFORM_ROTATE && _edit.show_rotation_line) { Point2 center = _point_to_screen(_edit.center); Color handle_color; @@ -4278,24 +4294,23 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { } break; case TRANSFORM_ROTATE: { - Plane plane; - Vector3 axis; + Plane plane = Plane(_get_camera_normal(), _edit.center); + Vector3 local_axis; + Vector3 global_axis; switch (_edit.plane) { case TRANSFORM_VIEW: - plane = Plane(_get_camera_normal(), _edit.center); + // local_axis unused + global_axis = _get_camera_normal(); break; case TRANSFORM_X_AXIS: - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(), _edit.center); - axis = Vector3(1, 0, 0); + local_axis = Vector3(1, 0, 0); break; case TRANSFORM_Y_AXIS: - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(), _edit.center); - axis = Vector3(0, 1, 0); + local_axis = Vector3(0, 1, 0); break; case TRANSFORM_Z_AXIS: - plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(), _edit.center); - axis = Vector3(0, 0, 1); + local_axis = Vector3(0, 0, 1); break; case TRANSFORM_YZ: case TRANSFORM_XZ: @@ -4303,6 +4318,10 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { break; } + if (_edit.plane != TRANSFORM_VIEW) { + global_axis = spatial_editor->get_gizmo_transform().basis.xform(local_axis).normalized(); + } + Vector3 intersection; if (!plane.intersects_ray(ray_pos, ray, &intersection)) { break; @@ -4313,10 +4332,22 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { break; } - Vector3 y_axis = (click - _edit.center).normalized(); - Vector3 x_axis = plane.normal.cross(y_axis).normalized(); + static const float orthogonal_threshold = Math::cos(Math::deg2rad(87.0f)); + bool axis_is_orthogonal = ABS(plane.normal.dot(global_axis)) < orthogonal_threshold; - double angle = Math::atan2(x_axis.dot(intersection - _edit.center), y_axis.dot(intersection - _edit.center)); + double angle = 0.0f; + if (axis_is_orthogonal) { + _edit.show_rotation_line = false; + Vector3 projection_axis = plane.normal.cross(global_axis); + Vector3 delta = intersection - click; + float projection = delta.dot(projection_axis); + angle = (projection * (Math_PI / 2.0f)) / (gizmo_scale * GIZMO_CIRCLE_SIZE); + } else { + _edit.show_rotation_line = true; + Vector3 click_axis = (click - _edit.center).normalized(); + Vector3 current_axis = (intersection - _edit.center).normalized(); + angle = click_axis.signed_angle_to(current_axis, global_axis); + } if (_edit.snap || spatial_editor->is_snap_enabled()) { snap = spatial_editor->get_rotate_snap(); @@ -4344,7 +4375,7 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { continue; } - Vector3 compute_axis = local_coords ? axis : plane.normal; + Vector3 compute_axis = local_coords ? local_axis : global_axis; if (se->gizmo.is_valid()) { for (KeyValue<int, Transform3D> &GE : se->subgizmos) { Transform3D xform = GE.value; @@ -4377,7 +4408,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito _edit.mode = TRANSFORM_NONE; _edit.plane = TRANSFORM_VIEW; _edit.snap = true; - _edit.instant = true; + _edit.show_rotation_line = true; + _edit.instant = false; _edit.gizmo_handle = -1; _edit.gizmo_handle_secondary = false; diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index 5c5980eb88..bbe5615570 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -311,6 +311,7 @@ private: Point2 mouse_pos; Point2 original_mouse_pos; bool snap = false; + bool show_rotation_line = false; Ref<EditorNode3DGizmo> gizmo; int gizmo_handle = 0; bool gizmo_handle_secondary = false; diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 406bcbe342..0862efb4ee 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -214,10 +214,13 @@ void PropertySelector::_update_search() { Variant::construct(type, v, nullptr, 0, ce); v.get_method_list(&methods); } else { - Object *obj = ObjectDB::get_instance(script); - if (Object::cast_to<Script>(obj)) { + Ref<Script> script_ref = Object::cast_to<Script>(ObjectDB::get_instance(script)); + if (script_ref.is_valid()) { methods.push_back(MethodInfo("*Script Methods")); - Object::cast_to<Script>(obj)->get_script_method_list(&methods); + if (script_ref->is_built_in()) { + script_ref->reload(true); + } + script_ref->get_script_method_list(&methods); } StringName base = base_type; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index eba0ea9a79..a1f058ffe5 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -266,7 +266,7 @@ namespace Godot /// <returns>The capitalized string.</returns> public static string Capitalize(this string instance) { - string aux = instance.Replace("_", " ").ToLower(); + string aux = instance.CamelcaseToUnderscore(true).Replace("_", " ").Trim(); string cap = string.Empty; for (int i = 0; i < aux.GetSliceCount(" "); i++) @@ -284,6 +284,51 @@ namespace Godot return cap; } + private static string CamelcaseToUnderscore(this string instance, bool lowerCase) + { + string newString = string.Empty; + int startIndex = 0; + + for (int i = 1; i < instance.Length; i++) + { + bool isUpper = char.IsUpper(instance[i]); + bool isNumber = char.IsDigit(instance[i]); + + bool areNext2Lower = false; + bool isNextLower = false; + bool isNextNumber = false; + bool wasPrecedentUpper = char.IsUpper(instance[i - 1]); + bool wasPrecedentNumber = char.IsDigit(instance[i - 1]); + + if (i + 2 < instance.Length) + { + areNext2Lower = char.IsLower(instance[i + 1]) && char.IsLower(instance[i + 2]); + } + + if (i + 1 < instance.Length) + { + isNextLower = char.IsLower(instance[i + 1]); + isNextNumber = char.IsDigit(instance[i + 1]); + } + + bool condA = isUpper && !wasPrecedentUpper && !wasPrecedentNumber; + bool condB = wasPrecedentUpper && isUpper && areNext2Lower; + bool condC = isNumber && !wasPrecedentNumber; + bool canBreakNumberLetter = isNumber && !wasPrecedentNumber && isNextLower; + bool canBreakLetterNumber = !isNumber && wasPrecedentNumber && (isNextLower || isNextNumber); + + bool shouldSplit = condA || condB || condC || canBreakNumberLetter || canBreakLetterNumber; + if (shouldSplit) + { + newString += instance.Substring(startIndex, i - startIndex) + "_"; + startIndex = i; + } + } + + newString += instance.Substring(startIndex, instance.Length - startIndex); + return lowerCase ? newString.ToLower() : newString; + } + /// <summary> /// Performs a case-sensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater. /// </summary> diff --git a/platform/osx/detect.py b/platform/osx/detect.py index e7fe37d4b5..0ff93bedb4 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -78,9 +78,9 @@ def configure(env): env["osxcross"] = True if env["arch"] == "arm64": - print("Building for macOS 11.00+, platform arm64.") - env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.00"]) - env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.00"]) + print("Building for macOS 11.0+, platform arm64.") + env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.0"]) + env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.0"]) else: print("Building for macOS 10.12+, platform x86_64.") env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) |