From 05697ee848d0f17605fe3416da57c0fcc2eb6323 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 3 Jun 2021 18:21:43 +0200 Subject: Display a editor gizmo icon for Listener3D The icon was present in `editor/icons/`, but it was never implemented in the editor gizmos code. This also removes some unused gizmo drawing code (overridden methods that are no longer called anywhere). --- editor/plugins/node_3d_editor_gizmos.cpp | 25 +++++++++++++++++++++++-- editor/plugins/node_3d_editor_gizmos.h | 13 +++++++++++++ editor/plugins/node_3d_editor_plugin.cpp | 1 + 3 files changed, 37 insertions(+), 2 deletions(-) (limited to 'editor/plugins') diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index e61571edff..7962d186dc 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -1481,8 +1481,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } } -////// - //// player gizmo AudioStreamPlayer3DGizmoPlugin::AudioStreamPlayer3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1)); @@ -1621,6 +1619,29 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ////// +Listener3DGizmoPlugin::Listener3DGizmoPlugin() { + create_icon_material("listener_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoListener3D", "EditorIcons")); +} + +bool Listener3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to(p_spatial) != nullptr; +} + +String Listener3DGizmoPlugin::get_gizmo_name() const { + return "Listener3D"; +} + +int Listener3DGizmoPlugin::get_priority() const { + return -1; +} + +void Listener3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { + const Ref icon = get_material("listener_3d_icon", p_gizmo); + p_gizmo->add_unscaled_billboard(icon, 0.05); +} + +////// + Camera3DGizmoPlugin::Camera3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8)); diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index 415ed5da5c..5dace06cd7 100644 --- a/editor/plugins/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -249,6 +249,19 @@ public: AudioStreamPlayer3DGizmoPlugin(); }; +class Listener3DGizmoPlugin : public EditorNode3DGizmoPlugin { + GDCLASS(Listener3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial) override; + String get_gizmo_name() const override; + int get_priority() const override; + + void redraw(EditorNode3DGizmo *p_gizmo) override; + + Listener3DGizmoPlugin(); +}; + class Camera3DGizmoPlugin : public EditorNode3DGizmoPlugin { GDCLASS(Camera3DGizmoPlugin, EditorNode3DGizmoPlugin); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index be5d756444..875474253d 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -6863,6 +6863,7 @@ void Node3DEditor::_register_all_gizmos() { add_gizmo_plugin(Ref(memnew(Camera3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Light3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(AudioStreamPlayer3DGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(Listener3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(MeshInstance3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(OccluderInstance3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SoftBody3DGizmoPlugin))); -- cgit v1.2.3