diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2023-09-15 01:41:28 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2023-09-15 01:59:49 +0200 |
commit | 1024ba0c0d52822acf1e77a791392e9b7f52d225 (patch) | |
tree | 18d979776979768e4065923efc962dd810ae3740 /editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp | |
parent | b467afe65d826f9215f962fe7d78d6bbc1101624 (diff) | |
download | redot-engine-1024ba0c0d52822acf1e77a791392e9b7f52d225.tar.gz |
Show visual-oriented 3D node gizmos only when selected
Affected nodes:
- DirectionalLight3D, OmniLight3D, SpotLight3D
- ReflectionProbe
- LightmapGI
- VoxelGI
- GPUParticles3D (but not collision/attractor nodes)
- AudioStreamPlayer3D
This reduces visual clutter in the editor with 3D scenes.
Diffstat (limited to 'editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp')
-rw-r--r-- | editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp b/editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp index f4d524e39c..3aa3d09c47 100644 --- a/editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp @@ -151,55 +151,57 @@ void ReflectionProbeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, } void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_node_3d()); - p_gizmo->clear(); - Vector<Vector3> lines; - Vector<Vector3> internal_lines; - Vector3 size = probe->get_size(); + if (p_gizmo->is_selected()) { + ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_node_3d()); + Vector<Vector3> lines; + Vector<Vector3> internal_lines; + Vector3 size = probe->get_size(); - AABB aabb; - aabb.position = -size / 2; - aabb.size = size; + AABB aabb; + aabb.position = -size / 2; + aabb.size = size; - for (int i = 0; i < 12; i++) { - Vector3 a, b; - aabb.get_edge(i, a, b); - lines.push_back(a); - lines.push_back(b); - } + for (int i = 0; i < 12; i++) { + Vector3 a, b; + aabb.get_edge(i, a, b); + lines.push_back(a); + lines.push_back(b); + } - for (int i = 0; i < 8; i++) { - Vector3 ep = aabb.get_endpoint(i); - internal_lines.push_back(probe->get_origin_offset()); - internal_lines.push_back(ep); - } + for (int i = 0; i < 8; i++) { + Vector3 ep = aabb.get_endpoint(i); + internal_lines.push_back(probe->get_origin_offset()); + internal_lines.push_back(ep); + } - Vector<Vector3> handles = helper->box_get_handles(probe->get_size()); + Vector<Vector3> handles = helper->box_get_handles(probe->get_size()); - for (int i = 0; i < 3; i++) { - Vector3 orig_handle = probe->get_origin_offset(); - orig_handle[i] -= 0.25; - lines.push_back(orig_handle); - handles.push_back(orig_handle); + for (int i = 0; i < 3; i++) { + Vector3 orig_handle = probe->get_origin_offset(); + orig_handle[i] -= 0.25; + lines.push_back(orig_handle); + handles.push_back(orig_handle); - orig_handle[i] += 0.5; - lines.push_back(orig_handle); - } + orig_handle[i] += 0.5; + lines.push_back(orig_handle); + } - Ref<Material> material = get_material("reflection_probe_material", p_gizmo); - Ref<Material> material_internal = get_material("reflection_internal_material", p_gizmo); - Ref<Material> icon = get_material("reflection_probe_icon", p_gizmo); + Ref<Material> material = get_material("reflection_probe_material", p_gizmo); + Ref<Material> material_internal = get_material("reflection_internal_material", p_gizmo); - p_gizmo->add_lines(lines, material); - p_gizmo->add_lines(internal_lines, material_internal); + p_gizmo->add_lines(lines, material); + p_gizmo->add_lines(internal_lines, material_internal); - if (p_gizmo->is_selected()) { - Ref<Material> solid_material = get_material("reflection_probe_solid_material", p_gizmo); - p_gizmo->add_solid_box(solid_material, probe->get_size()); + if (p_gizmo->is_selected()) { + Ref<Material> solid_material = get_material("reflection_probe_solid_material", p_gizmo); + p_gizmo->add_solid_box(solid_material, probe->get_size()); + } + + p_gizmo->add_handles(handles, get_material("handles")); } + Ref<Material> icon = get_material("reflection_probe_icon", p_gizmo); p_gizmo->add_unscaled_billboard(icon, 0.05); - p_gizmo->add_handles(handles, get_material("handles")); } |