Merge pull request #82901 from kleonc/sprite-base-3d-gizmo-plugin
Make gizmo plugin handle `SpriteBase3D` instead of `Sprite3D`
This commit is contained in:
commit
fba341ce44
|
@ -1,5 +1,5 @@
|
|||
/**************************************************************************/
|
||||
/* sprite_3d_gizmo_plugin.cpp */
|
||||
/* sprite_base_3d_gizmo_plugin.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,36 +28,36 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "sprite_3d_gizmo_plugin.h"
|
||||
#include "sprite_base_3d_gizmo_plugin.h"
|
||||
|
||||
#include "editor/plugins/node_3d_editor_plugin.h"
|
||||
#include "scene/3d/sprite_3d.h"
|
||||
|
||||
Sprite3DGizmoPlugin::Sprite3DGizmoPlugin() {
|
||||
SpriteBase3DGizmoPlugin::SpriteBase3DGizmoPlugin() {
|
||||
}
|
||||
|
||||
bool Sprite3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
|
||||
return Object::cast_to<Sprite3D>(p_spatial) != nullptr;
|
||||
bool SpriteBase3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
|
||||
return Object::cast_to<SpriteBase3D>(p_spatial) != nullptr;
|
||||
}
|
||||
|
||||
String Sprite3DGizmoPlugin::get_gizmo_name() const {
|
||||
return "Sprite3D";
|
||||
String SpriteBase3DGizmoPlugin::get_gizmo_name() const {
|
||||
return "SpriteBase3D";
|
||||
}
|
||||
|
||||
int Sprite3DGizmoPlugin::get_priority() const {
|
||||
int SpriteBase3DGizmoPlugin::get_priority() const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool Sprite3DGizmoPlugin::can_be_hidden() const {
|
||||
bool SpriteBase3DGizmoPlugin::can_be_hidden() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Sprite3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
Sprite3D *sprite = Object::cast_to<Sprite3D>(p_gizmo->get_node_3d());
|
||||
void SpriteBase3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
SpriteBase3D *sprite_base = Object::cast_to<SpriteBase3D>(p_gizmo->get_node_3d());
|
||||
|
||||
p_gizmo->clear();
|
||||
|
||||
Ref<TriangleMesh> tm = sprite->generate_triangle_mesh();
|
||||
Ref<TriangleMesh> tm = sprite_base->generate_triangle_mesh();
|
||||
if (tm.is_valid()) {
|
||||
p_gizmo->add_collision_triangles(tm);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**************************************************************************/
|
||||
/* sprite_3d_gizmo_plugin.h */
|
||||
/* sprite_base_3d_gizmo_plugin.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,13 +28,13 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SPRITE_3D_GIZMO_PLUGIN_H
|
||||
#define SPRITE_3D_GIZMO_PLUGIN_H
|
||||
#ifndef SPRITE_BASE_3D_GIZMO_PLUGIN_H
|
||||
#define SPRITE_BASE_3D_GIZMO_PLUGIN_H
|
||||
|
||||
#include "editor/plugins/node_3d_editor_gizmos.h"
|
||||
|
||||
class Sprite3DGizmoPlugin : public EditorNode3DGizmoPlugin {
|
||||
GDCLASS(Sprite3DGizmoPlugin, EditorNode3DGizmoPlugin);
|
||||
class SpriteBase3DGizmoPlugin : public EditorNode3DGizmoPlugin {
|
||||
GDCLASS(SpriteBase3DGizmoPlugin, EditorNode3DGizmoPlugin);
|
||||
|
||||
public:
|
||||
bool has_gizmo(Node3D *p_spatial) override;
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
bool can_be_hidden() const override;
|
||||
void redraw(EditorNode3DGizmo *p_gizmo) override;
|
||||
|
||||
Sprite3DGizmoPlugin();
|
||||
SpriteBase3DGizmoPlugin();
|
||||
};
|
||||
|
||||
#endif // SPRITE_3D_GIZMO_PLUGIN_H
|
||||
#endif // SPRITE_BASE_3D_GIZMO_PLUGIN_H
|
|
@ -71,7 +71,7 @@
|
|||
#include "editor/plugins/gizmos/shape_cast_3d_gizmo_plugin.h"
|
||||
#include "editor/plugins/gizmos/soft_body_3d_gizmo_plugin.h"
|
||||
#include "editor/plugins/gizmos/spring_arm_3d_gizmo_plugin.h"
|
||||
#include "editor/plugins/gizmos/sprite_3d_gizmo_plugin.h"
|
||||
#include "editor/plugins/gizmos/sprite_base_3d_gizmo_plugin.h"
|
||||
#include "editor/plugins/gizmos/vehicle_body_3d_gizmo_plugin.h"
|
||||
#include "editor/plugins/gizmos/visible_on_screen_notifier_3d_gizmo_plugin.h"
|
||||
#include "editor/plugins/gizmos/voxel_gi_gizmo_plugin.h"
|
||||
|
@ -7972,7 +7972,7 @@ void Node3DEditor::_register_all_gizmos() {
|
|||
add_gizmo_plugin(Ref<MeshInstance3DGizmoPlugin>(memnew(MeshInstance3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<OccluderInstance3DGizmoPlugin>(memnew(OccluderInstance3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<SoftBody3DGizmoPlugin>(memnew(SoftBody3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Sprite3DGizmoPlugin>(memnew(Sprite3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<SpriteBase3DGizmoPlugin>(memnew(SpriteBase3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Label3DGizmoPlugin>(memnew(Label3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Marker3DGizmoPlugin>(memnew(Marker3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<RayCast3DGizmoPlugin>(memnew(RayCast3DGizmoPlugin)));
|
||||
|
|
|
@ -398,12 +398,10 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
|
|||
real_t px_size = get_pixel_size();
|
||||
|
||||
Vector2 vertices[4] = {
|
||||
|
||||
(final_rect.position + Vector2(0, final_rect.size.y)) * px_size,
|
||||
(final_rect.position + final_rect.size) * px_size,
|
||||
(final_rect.position + Vector2(final_rect.size.x, 0)) * px_size,
|
||||
final_rect.position * px_size,
|
||||
|
||||
};
|
||||
|
||||
int x_axis = ((axis + 1) % 3);
|
||||
|
@ -1191,7 +1189,7 @@ Rect2 AnimatedSprite3D::get_item_rect() const {
|
|||
Size2 s = t->get_size();
|
||||
|
||||
Point2 ofs = get_offset();
|
||||
if (centered) {
|
||||
if (is_centered()) {
|
||||
ofs -= s / 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -236,8 +236,6 @@ class AnimatedSprite3D : public SpriteBase3D {
|
|||
float speed_scale = 1.0;
|
||||
float custom_speed_scale = 1.0;
|
||||
|
||||
bool centered = false;
|
||||
|
||||
real_t frame_speed_scale = 1.0;
|
||||
real_t frame_progress = 0.0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue