diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index b84dc85f3fc..a4089327a5c 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -828,12 +828,11 @@ public: static const int HIDDEN = 1; static const int ON_TOP = 2; -private: +protected: int current_state; List current_gizmos; HashMap > > materials; -protected: static void _bind_methods(); virtual bool has_gizmo(Spatial *p_spatial); virtual Ref create_gizmo(Spatial *p_spatial); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index c94b0eeab0f..838aa4d2f7b 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -4075,6 +4075,25 @@ JointSpatialGizmoPlugin::JointSpatialGizmoPlugin() { create_material("joint_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1))); create_material("joint_body_a_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint_body_a", Color(0.6, 0.8, 1))); create_material("joint_body_b_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint_body_b", Color(0.6, 0.9, 1))); + + update_timer = memnew(Timer); + update_timer->set_name("JointGizmoUpdateTimer"); + update_timer->set_wait_time(1.0 / 120.0); + update_timer->connect("timeout", this, "incremental_update_gizmos"); + update_timer->set_autostart(true); + EditorNode::get_singleton()->call_deferred("add_child", update_timer); +} + +void JointSpatialGizmoPlugin::_bind_methods() { + ClassDB::bind_method(D_METHOD("incremental_update_gizmos"), &JointSpatialGizmoPlugin::incremental_update_gizmos); +} + +void JointSpatialGizmoPlugin::incremental_update_gizmos() { + if (!current_gizmos.empty()) { + update_idx++; + update_idx = update_idx % current_gizmos.size(); + redraw(current_gizmos[update_idx]); + } } bool JointSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index 81b62981acc..c0084c13d59 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -390,6 +390,14 @@ class JointSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { GDCLASS(JointSpatialGizmoPlugin, EditorSpatialGizmoPlugin); + Timer *update_timer; + uint64_t update_idx = 0; + + void incremental_update_gizmos(); + +protected: + static void _bind_methods(); + public: bool has_gizmo(Spatial *p_spatial); String get_name() const;