Merge pull request #82902 from kleonc/sprite-base-3d-gizmo-plugin-3x

[3.x] Make gizmo plugin handle `SpriteBase3D` instead of `Sprite3D`
This commit is contained in:
Rémi Verschelde 2023-11-14 11:37:12 +01:00
commit 575399ee38
No known key found for this signature in database
GPG key ID: C3336907360768E1
5 changed files with 15 additions and 17 deletions

View file

@ -6775,7 +6775,7 @@ void SpatialEditor::_register_all_gizmos() {
add_gizmo_plugin(Ref<ListenerSpatialGizmoPlugin>(memnew(ListenerSpatialGizmoPlugin))); add_gizmo_plugin(Ref<ListenerSpatialGizmoPlugin>(memnew(ListenerSpatialGizmoPlugin)));
add_gizmo_plugin(Ref<MeshInstanceSpatialGizmoPlugin>(memnew(MeshInstanceSpatialGizmoPlugin))); add_gizmo_plugin(Ref<MeshInstanceSpatialGizmoPlugin>(memnew(MeshInstanceSpatialGizmoPlugin)));
add_gizmo_plugin(Ref<SoftBodySpatialGizmoPlugin>(memnew(SoftBodySpatialGizmoPlugin))); add_gizmo_plugin(Ref<SoftBodySpatialGizmoPlugin>(memnew(SoftBodySpatialGizmoPlugin)));
add_gizmo_plugin(Ref<Sprite3DSpatialGizmoPlugin>(memnew(Sprite3DSpatialGizmoPlugin))); add_gizmo_plugin(Ref<SpriteBase3DSpatialGizmoPlugin>(memnew(SpriteBase3DSpatialGizmoPlugin)));
add_gizmo_plugin(Ref<Label3DSpatialGizmoPlugin>(memnew(Label3DSpatialGizmoPlugin))); add_gizmo_plugin(Ref<Label3DSpatialGizmoPlugin>(memnew(Label3DSpatialGizmoPlugin)));
add_gizmo_plugin(Ref<SkeletonSpatialGizmoPlugin>(memnew(SkeletonSpatialGizmoPlugin))); add_gizmo_plugin(Ref<SkeletonSpatialGizmoPlugin>(memnew(SkeletonSpatialGizmoPlugin)));
add_gizmo_plugin(Ref<Position3DSpatialGizmoPlugin>(memnew(Position3DSpatialGizmoPlugin))); add_gizmo_plugin(Ref<Position3DSpatialGizmoPlugin>(memnew(Position3DSpatialGizmoPlugin)));

View file

@ -1534,31 +1534,31 @@ void MeshInstanceSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
} }
///// /////
Sprite3DSpatialGizmoPlugin::Sprite3DSpatialGizmoPlugin() { SpriteBase3DSpatialGizmoPlugin::SpriteBase3DSpatialGizmoPlugin() {
} }
bool Sprite3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { bool SpriteBase3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
return Object::cast_to<Sprite3D>(p_spatial) != nullptr; return Object::cast_to<SpriteBase3D>(p_spatial) != nullptr;
} }
String Sprite3DSpatialGizmoPlugin::get_name() const { String SpriteBase3DSpatialGizmoPlugin::get_name() const {
return "Sprite3D"; return "SpriteBase3D";
} }
int Sprite3DSpatialGizmoPlugin::get_priority() const { int SpriteBase3DSpatialGizmoPlugin::get_priority() const {
return -1; return -1;
} }
bool Sprite3DSpatialGizmoPlugin::can_be_hidden() const { bool SpriteBase3DSpatialGizmoPlugin::can_be_hidden() const {
return false; return false;
} }
void Sprite3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { void SpriteBase3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
Sprite3D *sprite = Object::cast_to<Sprite3D>(p_gizmo->get_spatial_node()); SpriteBase3D *sprite_base = Object::cast_to<SpriteBase3D>(p_gizmo->get_spatial_node());
p_gizmo->clear(); p_gizmo->clear();
Ref<TriangleMesh> tm = sprite->generate_triangle_mesh(); Ref<TriangleMesh> tm = sprite_base->generate_triangle_mesh();
if (tm.is_valid()) { if (tm.is_valid()) {
p_gizmo->add_collision_triangles(tm); p_gizmo->add_collision_triangles(tm);
} }

View file

@ -113,8 +113,8 @@ public:
MeshInstanceSpatialGizmoPlugin(); MeshInstanceSpatialGizmoPlugin();
}; };
class Sprite3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { class SpriteBase3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
GDCLASS(Sprite3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin); GDCLASS(SpriteBase3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
public: public:
bool has_gizmo(Spatial *p_spatial); bool has_gizmo(Spatial *p_spatial);
@ -123,7 +123,7 @@ public:
bool can_be_hidden() const; bool can_be_hidden() const;
void redraw(EditorSpatialGizmo *p_gizmo); void redraw(EditorSpatialGizmo *p_gizmo);
Sprite3DSpatialGizmoPlugin(); SpriteBase3DSpatialGizmoPlugin();
}; };
class Label3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { class Label3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {

View file

@ -1013,7 +1013,7 @@ Rect2 AnimatedSprite3D::get_item_rect() const {
Size2 s = t->get_size(); Size2 s = t->get_size();
Point2 ofs = get_offset(); Point2 ofs = get_offset();
if (centered) { if (is_centered()) {
ofs -= s / 2; ofs -= s / 2;
} }

View file

@ -206,8 +206,6 @@ class AnimatedSprite3D : public SpriteBase3D {
StringName animation; StringName animation;
int frame; int frame;
bool centered;
float timeout; float timeout;
bool hflip; bool hflip;