From 0cde6800e7415d77f74ee86de396a1e4d36d9930 Mon Sep 17 00:00:00 2001 From: kleonc <9283098+kleonc@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:40:02 +0200 Subject: [PATCH] Make gizmo plugin handle SpriteBase3D instead of Sprite3D --- editor/plugins/spatial_editor_plugin.cpp | 2 +- editor/spatial_editor_gizmos.cpp | 20 ++++++++++---------- editor/spatial_editor_gizmos.h | 6 +++--- scene/3d/sprite_3d.cpp | 2 +- scene/3d/sprite_3d.h | 2 -- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index e53c1f868db..b4555aff55e 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -6775,7 +6775,7 @@ void SpatialEditor::_register_all_gizmos() { add_gizmo_plugin(Ref(memnew(ListenerSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(MeshInstanceSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SoftBodySpatialGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(Sprite3DSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(SpriteBase3DSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Label3DSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SkeletonSpatialGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Position3DSpatialGizmoPlugin))); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 6d0354cd1cd..40b49688189 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -1534,31 +1534,31 @@ void MeshInstanceSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } ///// -Sprite3DSpatialGizmoPlugin::Sprite3DSpatialGizmoPlugin() { +SpriteBase3DSpatialGizmoPlugin::SpriteBase3DSpatialGizmoPlugin() { } -bool Sprite3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to(p_spatial) != nullptr; +bool SpriteBase3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { + return Object::cast_to(p_spatial) != nullptr; } -String Sprite3DSpatialGizmoPlugin::get_name() const { - return "Sprite3D"; +String SpriteBase3DSpatialGizmoPlugin::get_name() const { + return "SpriteBase3D"; } -int Sprite3DSpatialGizmoPlugin::get_priority() const { +int SpriteBase3DSpatialGizmoPlugin::get_priority() const { return -1; } -bool Sprite3DSpatialGizmoPlugin::can_be_hidden() const { +bool SpriteBase3DSpatialGizmoPlugin::can_be_hidden() const { return false; } -void Sprite3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { - Sprite3D *sprite = Object::cast_to(p_gizmo->get_spatial_node()); +void SpriteBase3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { + SpriteBase3D *sprite_base = Object::cast_to(p_gizmo->get_spatial_node()); p_gizmo->clear(); - Ref tm = sprite->generate_triangle_mesh(); + Ref tm = sprite_base->generate_triangle_mesh(); if (tm.is_valid()) { p_gizmo->add_collision_triangles(tm); } diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index 8a04a24a4ca..de3b9c8cf2b 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -113,8 +113,8 @@ public: MeshInstanceSpatialGizmoPlugin(); }; -class Sprite3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - GDCLASS(Sprite3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin); +class SpriteBase3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { + GDCLASS(SpriteBase3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin); public: bool has_gizmo(Spatial *p_spatial); @@ -123,7 +123,7 @@ public: bool can_be_hidden() const; void redraw(EditorSpatialGizmo *p_gizmo); - Sprite3DSpatialGizmoPlugin(); + SpriteBase3DSpatialGizmoPlugin(); }; class Label3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 6bd731dbebe..57a2246db16 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -1013,7 +1013,7 @@ Rect2 AnimatedSprite3D::get_item_rect() const { Size2 s = t->get_size(); Point2 ofs = get_offset(); - if (centered) { + if (is_centered()) { ofs -= s / 2; } diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index a7546fdf032..a0ccc94d8f7 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -206,8 +206,6 @@ class AnimatedSprite3D : public SpriteBase3D { StringName animation; int frame; - bool centered; - float timeout; bool hflip;