1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Path3D: custom debug color and custom debug show

This commit is contained in:
ywmaa
2023-09-25 21:47:28 +03:00
committed by ywmaa
parent 76a135926a
commit 275f046e4a
5 changed files with 87 additions and 8 deletions

View File

@@ -272,7 +272,6 @@ void Path3DGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_res
void Path3DGizmo::redraw() {
clear();
Ref<StandardMaterial3D> path_material = gizmo_plugin->get_material("path_material", this);
Ref<StandardMaterial3D> path_thin_material = gizmo_plugin->get_material("path_thin_material", this);
Ref<StandardMaterial3D> path_tilt_material = gizmo_plugin->get_material("path_tilt_material", this);
Ref<StandardMaterial3D> path_tilt_muted_material = gizmo_plugin->get_material("path_tilt_muted_material", this);
@@ -284,11 +283,24 @@ void Path3DGizmo::redraw() {
return;
}
debug_material = gizmo_plugin->get_material("path_material", this);
Color path_color = path->get_debug_custom_color();
if (path_color != Color(0.0, 0.0, 0.0)) {
debug_material.instantiate();
debug_material->set_albedo(path_color);
debug_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
debug_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
debug_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
debug_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
debug_material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
}
real_t interval = 0.1;
const real_t length = c->get_baked_length();
// 1. Draw curve and bones.
if (length > CMP_EPSILON) {
// 1. Draw curve and bones if it is visible (alpha > 0.0).
if (length > CMP_EPSILON && path_color.a > 0.0) {
const int sample_count = int(length / interval) + 2;
interval = length / (sample_count - 1); // Recalculate real interval length.
@@ -346,8 +358,8 @@ void Path3DGizmo::redraw() {
}
add_collision_segments(_collision_segments);
add_lines(bones, path_material);
add_vertices(ribbon, path_material, Mesh::PRIMITIVE_LINE_STRIP);
add_lines(bones, debug_material);
add_vertices(ribbon, debug_material, Mesh::PRIMITIVE_LINE_STRIP);
}
// 2. Draw handles when selected.
@@ -427,7 +439,7 @@ void Path3DGizmo::redraw() {
const Vector3 edge = sin(a) * side + cos(a) * up;
disk.append(pos + edge * disk_size);
}
add_vertices(disk, path_tilt_material, Mesh::PRIMITIVE_LINE_STRIP);
add_vertices(disk, debug_material, Mesh::PRIMITIVE_LINE_STRIP);
}
}
}
@@ -464,6 +476,7 @@ Path3DGizmo::Path3DGizmo(Path3D *p_path, float p_disk_size) {
// Connecting to a signal once, rather than plaguing the implementation with calls to `Node3DEditor::update_transform_gizmo`.
path->connect("curve_changed", callable_mp(this, &Path3DGizmo::_update_transform_gizmo));
path->connect("debug_color_changed", callable_mp(this, &Path3DGizmo::redraw));
Path3DEditorPlugin::singleton->curve_edit->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw));
Path3DEditorPlugin::singleton->curve_edit_curve->connect(SceneStringName(pressed), callable_mp(this, &Path3DGizmo::redraw));