You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-18 14:21:41 +00:00
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.
This commit is contained in:
@@ -121,11 +121,10 @@ void AudioStreamPlayer3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gi
|
||||
}
|
||||
|
||||
void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
const AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_node_3d());
|
||||
|
||||
p_gizmo->clear();
|
||||
|
||||
const Ref<Material> icon = get_material("stream_player_3d_icon", p_gizmo);
|
||||
if (p_gizmo->is_selected()) {
|
||||
const AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_node_3d());
|
||||
|
||||
if (player->get_attenuation_model() != AudioStreamPlayer3D::ATTENUATION_DISABLED || player->get_max_distance() > CMP_EPSILON) {
|
||||
// Draw a circle to represent sound volume attenuation.
|
||||
@@ -251,6 +250,8 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
handles.push_back(Vector3(Math::sin(ha), 0, -Math::cos(ha)));
|
||||
p_gizmo->add_handles(handles, get_material("handles"));
|
||||
}
|
||||
}
|
||||
|
||||
const Ref<Material> icon = get_material("stream_player_3d_icon", p_gizmo);
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05);
|
||||
}
|
||||
|
||||
@@ -151,10 +151,11 @@ void GPUParticles3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo,
|
||||
}
|
||||
|
||||
void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_node_3d());
|
||||
|
||||
p_gizmo->clear();
|
||||
|
||||
if (p_gizmo->is_selected()) {
|
||||
GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_node_3d());
|
||||
|
||||
Vector<Vector3> lines;
|
||||
AABB aabb = particles->get_visibility_aabb();
|
||||
|
||||
@@ -185,15 +186,15 @@ void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
}
|
||||
|
||||
Ref<Material> material = get_material("particles_material", p_gizmo);
|
||||
Ref<Material> icon = get_material("particles_icon", p_gizmo);
|
||||
|
||||
p_gizmo->add_lines(lines, material);
|
||||
|
||||
if (p_gizmo->is_selected()) {
|
||||
Ref<Material> solid_material = get_material("particles_solid_material", p_gizmo);
|
||||
p_gizmo->add_solid_box(solid_material, aabb.get_size(), aabb.get_center());
|
||||
}
|
||||
|
||||
p_gizmo->add_handles(handles, get_material("handles"));
|
||||
}
|
||||
|
||||
Ref<Material> icon = get_material("particles_icon", p_gizmo);
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05);
|
||||
}
|
||||
|
||||
@@ -158,8 +158,8 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
p_gizmo->clear();
|
||||
|
||||
if (Object::cast_to<DirectionalLight3D>(light)) {
|
||||
if (p_gizmo->is_selected()) {
|
||||
Ref<Material> material = get_material("lines_primary", p_gizmo);
|
||||
Ref<Material> icon = get_material("light_directional_icon", p_gizmo);
|
||||
|
||||
const int arrow_points = 7;
|
||||
const float arrow_length = 1.5;
|
||||
@@ -191,14 +191,17 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
}
|
||||
|
||||
p_gizmo->add_lines(lines, material, false, color);
|
||||
}
|
||||
|
||||
Ref<Material> icon = get_material("light_directional_icon", p_gizmo);
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05, color);
|
||||
}
|
||||
|
||||
if (Object::cast_to<OmniLight3D>(light)) {
|
||||
if (p_gizmo->is_selected()) {
|
||||
// Use both a billboard circle and 3 non-billboard circles for a better sphere-like representation
|
||||
const Ref<Material> lines_material = get_material("lines_secondary", p_gizmo);
|
||||
const Ref<Material> lines_billboard_material = get_material("lines_billboard", p_gizmo);
|
||||
const Ref<Material> icon = get_material("light_omni_icon", p_gizmo);
|
||||
|
||||
OmniLight3D *on = Object::cast_to<OmniLight3D>(light);
|
||||
const float r = on->get_param(Light3D::PARAM_RANGE);
|
||||
@@ -227,17 +230,20 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
|
||||
p_gizmo->add_lines(points, lines_material, true, color);
|
||||
p_gizmo->add_lines(points_billboard, lines_billboard_material, true, color);
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05, color);
|
||||
|
||||
Vector<Vector3> handles;
|
||||
handles.push_back(Vector3(r, 0, 0));
|
||||
p_gizmo->add_handles(handles, get_material("handles_billboard"), Vector<int>(), true);
|
||||
}
|
||||
|
||||
const Ref<Material> icon = get_material("light_omni_icon", p_gizmo);
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05, color);
|
||||
}
|
||||
|
||||
if (Object::cast_to<SpotLight3D>(light)) {
|
||||
if (p_gizmo->is_selected()) {
|
||||
const Ref<Material> material_primary = get_material("lines_primary", p_gizmo);
|
||||
const Ref<Material> material_secondary = get_material("lines_secondary", p_gizmo);
|
||||
const Ref<Material> icon = get_material("light_spot_icon", p_gizmo);
|
||||
|
||||
Vector<Vector3> points_primary;
|
||||
Vector<Vector3> points_secondary;
|
||||
@@ -276,6 +282,9 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
};
|
||||
|
||||
p_gizmo->add_handles(handles, get_material("handles"));
|
||||
}
|
||||
|
||||
const Ref<Material> icon = get_material("light_spot_icon", p_gizmo);
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05, color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,17 +68,17 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
LightmapGI *baker = Object::cast_to<LightmapGI>(p_gizmo->get_node_3d());
|
||||
Ref<LightmapGIData> data = baker->get_light_data();
|
||||
|
||||
p_gizmo->clear();
|
||||
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05);
|
||||
|
||||
if (data.is_null()) {
|
||||
if (data.is_null() || !p_gizmo->is_selected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<Material> material_lines = get_material("lightmap_lines", p_gizmo);
|
||||
Ref<Material> material_probes = get_material("lightmap_probe_material", p_gizmo);
|
||||
|
||||
p_gizmo->clear();
|
||||
|
||||
Vector<Vector3> lines;
|
||||
HashSet<Vector2i> lines_found;
|
||||
|
||||
|
||||
@@ -151,10 +151,10 @@ 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();
|
||||
|
||||
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();
|
||||
@@ -190,7 +190,6 @@ void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
|
||||
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);
|
||||
|
||||
p_gizmo->add_lines(lines, material);
|
||||
p_gizmo->add_lines(internal_lines, material_internal);
|
||||
@@ -200,6 +199,9 @@ void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
p_gizmo->add_solid_box(solid_material, probe->get_size());
|
||||
}
|
||||
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -100,14 +100,13 @@ void VoxelGIGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_i
|
||||
}
|
||||
|
||||
void VoxelGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_node_3d());
|
||||
|
||||
Ref<Material> material = get_material("voxel_gi_material", p_gizmo);
|
||||
Ref<Material> icon = get_material("voxel_gi_icon", p_gizmo);
|
||||
Ref<Material> material_internal = get_material("voxel_gi_internal_material", p_gizmo);
|
||||
|
||||
p_gizmo->clear();
|
||||
|
||||
if (p_gizmo->is_selected()) {
|
||||
VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_node_3d());
|
||||
Ref<Material> material = get_material("voxel_gi_material", p_gizmo);
|
||||
Ref<Material> material_internal = get_material("voxel_gi_internal_material", p_gizmo);
|
||||
|
||||
Vector<Vector3> lines;
|
||||
Vector3 size = probe->get_size();
|
||||
|
||||
@@ -168,6 +167,9 @@ void VoxelGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
p_gizmo->add_solid_box(solid_material, aabb.get_size());
|
||||
}
|
||||
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05);
|
||||
p_gizmo->add_handles(handles, get_material("handles"));
|
||||
}
|
||||
|
||||
Ref<Material> icon = get_material("voxel_gi_icon", p_gizmo);
|
||||
p_gizmo->add_unscaled_billboard(icon, 0.05);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user