Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show visual-oriented 3D node gizmos only when selected #75303

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
11 changes: 6 additions & 5 deletions editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
}
17 changes: 13 additions & 4 deletions editor/plugins/gizmos/light_3d_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Use both a billboard circle and 3 non-billboard circles for a better sphere-like representation
// 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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions editor/plugins/gizmos/lightmap_gi_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 6 additions & 4 deletions editor/plugins/gizmos/reflection_probe_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
12 changes: 7 additions & 5 deletions editor/plugins/gizmos/voxel_gi_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
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> icon = get_material("voxel_gi_icon", p_gizmo);
Ref<Material> material_internal = get_material("voxel_gi_internal_material", p_gizmo);

p_gizmo->clear();

Vector<Vector3> lines;
Vector3 size = probe->get_size();

Expand Down Expand Up @@ -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);
}
Loading