|
@@ -68,32 +68,36 @@ void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) {
|
|
return;
|
|
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();
|
|
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->set_text(TTR("Bake SDF"));
|
|
bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_bake));
|
|
bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_bake));
|
|
bake_hb->add_child(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);
|
|
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb);
|
|
col_sdf = nullptr;
|
|
col_sdf = nullptr;
|