diff options
-rw-r--r-- | doc/classes/Image.xml | 2 | ||||
-rw-r--r-- | doc/classes/SceneTreeTimer.xml | 3 | ||||
-rw-r--r-- | editor/editor_inspector.cpp | 5 | ||||
-rw-r--r-- | editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp | 46 | ||||
-rw-r--r-- | editor/plugins/gpu_particles_collision_sdf_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/plugins/voxel_gi_editor_plugin.cpp | 45 | ||||
-rw-r--r-- | editor/plugins/voxel_gi_editor_plugin.h | 1 | ||||
-rw-r--r-- | modules/mono/SdkPackageVersions.props | 5 | ||||
-rw-r--r-- | modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets | 2 | ||||
-rw-r--r-- | modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs | 16 | ||||
-rw-r--r-- | modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs | 19 |
11 files changed, 84 insertions, 61 deletions
diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index 8a4bbee0fa..29feb107d4 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -286,7 +286,7 @@ <return type="int" enum="Error" /> <argument index="0" name="path" type="String" /> <description> - Loads an image from file [code]path[/code]. See [url=$DOCS_URL/getting_started/workflow/assets/importing_images.html#supported-image-formats]Supported image formats[/url] for a list of supported image formats and limitations. + Loads an image from file [code]path[/code]. See [url=$DOCS_URL/tutorials/assets_pipeline/importing_images.html#supported-image-formats]Supported image formats[/url] for a list of supported image formats and limitations. [b]Warning:[/b] This method should only be used in the editor or in cases when you need to load external images at run-time, such as images located at the [code]user://[/code] directory, and may not work in exported projects. See also [ImageTexture] description for usage examples. </description> diff --git a/doc/classes/SceneTreeTimer.xml b/doc/classes/SceneTreeTimer.xml index b0509a322e..80f0a54e70 100644 --- a/doc/classes/SceneTreeTimer.xml +++ b/doc/classes/SceneTreeTimer.xml @@ -22,12 +22,13 @@ } [/csharp] [/codeblocks] + The timer will be automatically freed after its time elapses. </description> <tutorials> </tutorials> <members> <member name="time_left" type="float" setter="set_time_left" getter="get_time_left"> - The time remaining. + The time remaining (in seconds). </member> </members> <signals> diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index e1fae47057..a6cd07dab3 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2194,10 +2194,7 @@ void EditorInspector::remove_inspector_plugin(const Ref<EditorInspectorPlugin> & for (int i = idx; i < inspector_plugin_count - 1; i++) { inspector_plugins[i] = inspector_plugins[i + 1]; } - - if (idx == inspector_plugin_count - 1) { - inspector_plugins[idx] = Ref<EditorInspectorPlugin>(); - } + inspector_plugins[inspector_plugin_count - 1] = Ref<EditorInspectorPlugin>(); inspector_plugin_count--; } diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index 6df2e34ceb..57279c57e7 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -68,32 +68,36 @@ void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) { return; } + // Set information tooltip on the Bake button. This information is useful + // to optimize performance (video RAM size) and reduce collision tunneling (individual cell size). + const Vector3i size = col_sdf->get_estimated_cell_size(); - String text = vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z); - int data_size = 2; - const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); - text += " - " + vformat(TTR("VRAM Size: %s MB"), String::num(size_mb, 2)); + const Vector3 extents = col_sdf->get_extents(); - if (bake_info->get_text() == text) { - return; + int data_size = 2; + const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); + // Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF node is using a lot of VRAM. + String size_quality; + if (size_mb < 8.0) { + size_quality = TTR("Low"); + } else if (size_mb < 32.0) { + size_quality = TTR("Moderate"); + } else { + size_quality = TTR("High"); } - // Color the label depending on the estimated performance level. - Color color; - if (size_mb <= 16.0 + CMP_EPSILON) { - // Fast. - color = bake_info->get_theme_color(SNAME("success_color"), SNAME("Editor")); - } else if (size_mb <= 64.0 + CMP_EPSILON) { - // Medium. - color = bake_info->get_theme_color(SNAME("warning_color"), SNAME("Editor")); - } else { - // Slow. - color = bake_info->get_theme_color(SNAME("error_color"), SNAME("Editor")); + String text; + text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n"; + text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n"; + text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality); + + // Only update the tooltip when needed to avoid constant redrawing. + if (bake->get_tooltip(Point2()) == text) { + return; } - bake_info->add_theme_color_override("font_color", color); - bake_info->set_text(text); + bake->set_tooltip(text); } } @@ -178,10 +182,6 @@ GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(Edito bake->set_text(TTR("Bake SDF")); bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_bake)); bake_hb->add_child(bake); - bake_info = memnew(Label); - bake_info->set_h_size_flags(Control::SIZE_EXPAND_FILL); - bake_info->set_clip_text(true); - bake_hb->add_child(bake_info); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb); col_sdf = nullptr; diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h index 5a71fc44ef..26b8b352d6 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h @@ -42,7 +42,6 @@ class GPUParticlesCollisionSDFEditorPlugin : public EditorPlugin { GPUParticlesCollisionSDF *col_sdf; HBoxContainer *bake_hb; - Label *bake_info; Button *bake; EditorNode *editor; diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp index 9a44d40dcb..4f3cb9e189 100644 --- a/editor/plugins/voxel_gi_editor_plugin.cpp +++ b/editor/plugins/voxel_gi_editor_plugin.cpp @@ -67,31 +67,36 @@ void VoxelGIEditorPlugin::_notification(int p_what) { return; } + // Set information tooltip on the Bake button. This information is useful + // to optimize performance (video RAM size) and reduce light leaking (individual cell size). + const Vector3i size = voxel_gi->get_estimated_cell_size(); - String text = vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z); + + const Vector3 extents = voxel_gi->get_extents(); + const int data_size = 4; const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); - text += " - " + vformat(TTR("VRAM Size: %s MB"), String::num(size_mb, 2)); - - if (bake_info->get_text() == text) { - return; + // Add a qualitative measurement to help the user assess whether a VoxelGI node is using a lot of VRAM. + String size_quality; + if (size_mb < 16.0) { + size_quality = TTR("Low"); + } else if (size_mb < 64.0) { + size_quality = TTR("Moderate"); + } else { + size_quality = TTR("High"); } - // Color the label depending on the estimated performance level. - Color color; - if (size_mb <= 16.0 + CMP_EPSILON) { - // Fast. - color = bake_info->get_theme_color(SNAME("success_color"), SNAME("Editor")); - } else if (size_mb <= 64.0 + CMP_EPSILON) { - // Medium. - color = bake_info->get_theme_color(SNAME("warning_color"), SNAME("Editor")); - } else { - // Slow. - color = bake_info->get_theme_color(SNAME("error_color"), SNAME("Editor")); + String text; + text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n"; + text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n"; + text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality); + + // Only update the tooltip when needed to avoid constant redrawing. + if (bake->get_tooltip(Point2()) == text) { + return; } - bake_info->add_theme_color_override("font_color", color); - bake_info->set_text(text); + bake->set_tooltip(text); } } @@ -147,10 +152,6 @@ VoxelGIEditorPlugin::VoxelGIEditorPlugin(EditorNode *p_node) { bake->set_text(TTR("Bake GI Probe")); bake->connect("pressed", callable_mp(this, &VoxelGIEditorPlugin::_bake)); bake_hb->add_child(bake); - bake_info = memnew(Label); - bake_info->set_h_size_flags(Control::SIZE_EXPAND_FILL); - bake_info->set_clip_text(true); - bake_hb->add_child(bake_info); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb); voxel_gi = nullptr; diff --git a/editor/plugins/voxel_gi_editor_plugin.h b/editor/plugins/voxel_gi_editor_plugin.h index 4d3cfe90f6..ed66728557 100644 --- a/editor/plugins/voxel_gi_editor_plugin.h +++ b/editor/plugins/voxel_gi_editor_plugin.h @@ -42,7 +42,6 @@ class VoxelGIEditorPlugin : public EditorPlugin { VoxelGI *voxel_gi; HBoxContainer *bake_hb; - Label *bake_info; Button *bake; EditorNode *editor; diff --git a/modules/mono/SdkPackageVersions.props b/modules/mono/SdkPackageVersions.props index df3ebe581c..bdec051625 100644 --- a/modules/mono/SdkPackageVersions.props +++ b/modules/mono/SdkPackageVersions.props @@ -1,6 +1,7 @@ <Project> <PropertyGroup> - <PackageVersion_Godot_NET_Sdk>4.0.0-dev5</PackageVersion_Godot_NET_Sdk> - <PackageVersion_Godot_SourceGenerators>4.0.0-dev2</PackageVersion_Godot_SourceGenerators> + <PackageFloatingVersion_Godot>4.0.*-*</PackageFloatingVersion_Godot> + <PackageVersion_Godot_NET_Sdk>4.0.0-dev6</PackageVersion_Godot_NET_Sdk> + <PackageVersion_Godot_SourceGenerators>4.0.0-dev3</PackageVersion_Godot_SourceGenerators> </PropertyGroup> </Project> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets index 92e299d2f3..397ede9644 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets @@ -17,6 +17,6 @@ <!-- C# source generators --> <ItemGroup Condition=" '$(DisableImplicitGodotGeneratorReferences)' != 'true' "> - <PackageReference Include="Godot.SourceGenerators" Version="$(PackageVersion_Godot_SourceGenerators)" /> + <PackageReference Include="Godot.SourceGenerators" Version="$(PackageFloatingVersion_Godot)" /> </ItemGroup> </Project> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs new file mode 100644 index 0000000000..2ddb8880c2 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs @@ -0,0 +1,16 @@ +namespace Godot.SourceGenerators.Sample +{ + partial class Generic<T> : Godot.Object + { + } + + // Generic again but different generic parameters + partial class Generic<T, R> : Godot.Object + { + } + + // Generic again but without generic parameters + partial class Generic : Godot.Object + { + } +} diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs index a51728e221..fa65595290 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs @@ -97,9 +97,13 @@ namespace Godot.SourceGenerators string.Empty; bool hasNamespace = classNs.Length != 0; - string uniqueName = hasNamespace ? - classNs + "." + className + "_ScriptPath_Generated" : - className + "_ScriptPath_Generated"; + var uniqueName = new StringBuilder(); + if (hasNamespace) + uniqueName.Append($"{classNs}."); + uniqueName.Append(className); + if (symbol.IsGenericType) + uniqueName.Append($"Of{string.Join(string.Empty, symbol.TypeParameters)}"); + uniqueName.Append("_ScriptPath_Generated"); var source = new StringBuilder(); @@ -121,6 +125,8 @@ namespace Godot.SourceGenerators source.Append(attributes); source.Append("\n partial class "); source.Append(className); + if (symbol.IsGenericType) + source.Append($"<{string.Join(", ", symbol.TypeParameters)}>"); source.Append("\n{\n}\n"); if (hasNamespace) @@ -128,7 +134,7 @@ namespace Godot.SourceGenerators source.Append("\n}\n"); } - context.AddSource(uniqueName, SourceText.From(source.ToString(), Encoding.UTF8)); + context.AddSource(uniqueName.ToString(), SourceText.From(source.ToString(), Encoding.UTF8)); } private static void AddScriptTypesAssemblyAttr(GeneratorExecutionContext context, @@ -145,12 +151,15 @@ namespace Godot.SourceGenerators foreach (var godotClass in godotClasses) { var qualifiedName = godotClass.Key.ToDisplayString( - NullableFlowState.NotNull, SymbolDisplayFormat.FullyQualifiedFormat); + NullableFlowState.NotNull, SymbolDisplayFormat.FullyQualifiedFormat + .WithGenericsOptions(SymbolDisplayGenericsOptions.None)); if (!first) sourceBuilder.Append(", "); first = false; sourceBuilder.Append("typeof("); sourceBuilder.Append(qualifiedName); + if (godotClass.Key.IsGenericType) + sourceBuilder.Append($"<{new string(',', godotClass.Key.TypeParameters.Count() - 1)}>"); sourceBuilder.Append(")"); } |