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).
This commit is contained in:
Hugo Locurcio 2021-06-03 18:21:43 +02:00
parent 73ec378c64
commit 05697ee848
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
12 changed files with 37 additions and 34 deletions

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -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<Listener3D>(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<Material> 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));

View file

@ -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);

View file

@ -6863,6 +6863,7 @@ void Node3DEditor::_register_all_gizmos() {
add_gizmo_plugin(Ref<Camera3DGizmoPlugin>(memnew(Camera3DGizmoPlugin)));
add_gizmo_plugin(Ref<Light3DGizmoPlugin>(memnew(Light3DGizmoPlugin)));
add_gizmo_plugin(Ref<AudioStreamPlayer3DGizmoPlugin>(memnew(AudioStreamPlayer3DGizmoPlugin)));
add_gizmo_plugin(Ref<Listener3DGizmoPlugin>(memnew(Listener3DGizmoPlugin)));
add_gizmo_plugin(Ref<MeshInstance3DGizmoPlugin>(memnew(MeshInstance3DGizmoPlugin)));
add_gizmo_plugin(Ref<OccluderInstance3DGizmoPlugin>(memnew(OccluderInstance3DGizmoPlugin)));
add_gizmo_plugin(Ref<SoftBody3DGizmoPlugin>(memnew(SoftBody3DGizmoPlugin)));

View file

@ -254,10 +254,6 @@ bool Camera3D::is_current() const {
}
}
bool Camera3D::_can_gizmo_scale() const {
return false;
}
Vector3 Camera3D::project_ray_normal(const Point2 &p_pos) const {
Vector3 ray = project_local_ray_normal(p_pos);
return get_camera_transform().basis.xform(ray).normalized();

View file

@ -79,8 +79,6 @@ private:
Ref<Environment> environment;
Ref<CameraEffects> effects;
virtual bool _can_gizmo_scale() const;
// void _camera_make_current(Node *p_camera);
friend class Viewport;
void _update_audio_listener_state();

View file

@ -30,10 +30,6 @@
#include "light_3d.h"
bool Light3D::_can_gizmo_scale() const {
return false;
}
void Light3D::set_param(Param p_param, real_t p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
param[p_param] = p_value;

View file

@ -86,8 +86,6 @@ private:
protected:
RID light;
virtual bool _can_gizmo_scale() const;
static void _bind_methods();
void _notification(int p_what);
virtual void _validate_property(PropertyInfo &property) const override;

View file

@ -141,16 +141,6 @@ bool Listener3D::is_current() const {
return false;
}
bool Listener3D::_can_gizmo_scale() const {
return false;
}
RES Listener3D::_get_gizmo_geometry() const {
Ref<ArrayMesh> mesh = memnew(ArrayMesh);
return mesh;
}
void Listener3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("make_current"), &Listener3D::make_current);
ClassDB::bind_method(D_METHOD("clear_current"), &Listener3D::clear_current);
@ -160,7 +150,6 @@ void Listener3D::_bind_methods() {
Listener3D::Listener3D() {
set_notify_transform(true);
//active=false;
}
Listener3D::~Listener3D() {

View file

@ -42,9 +42,6 @@ private:
RID scenario_id;
virtual bool _can_gizmo_scale() const;
virtual RES _get_gizmo_geometry() const;
friend class Viewport;
void _update_audio_listener_state();

View file

@ -91,9 +91,6 @@ SceneStringNames::SceneStringNames() {
update = StaticCString::create("update");
updated = StaticCString::create("updated");
_get_gizmo_geometry = StaticCString::create("_get_gizmo_geometry");
_can_gizmo_scale = StaticCString::create("_can_gizmo_scale");
_physics_process = StaticCString::create("_physics_process");
_process = StaticCString::create("_process");

View file

@ -111,9 +111,6 @@ public:
StringName _body_inout;
StringName _area_inout;
StringName _get_gizmo_geometry;
StringName _can_gizmo_scale;
StringName _physics_process;
StringName _process;
StringName _enter_world;