Merge pull request #94698 from aaronp64/current_gizmos_hashset

Improve time to close scene with many 3D gizmos
This commit is contained in:
Rémi Verschelde 2024-09-02 12:12:51 +02:00
commit 2312345be8
No known key found for this signature in database
GPG Key ID: C3336907360768E1
4 changed files with 12 additions and 6 deletions

View File

@ -293,9 +293,15 @@ Joint3DGizmoPlugin::Joint3DGizmoPlugin() {
void Joint3DGizmoPlugin::incremental_update_gizmos() { void Joint3DGizmoPlugin::incremental_update_gizmos() {
if (!current_gizmos.is_empty()) { if (!current_gizmos.is_empty()) {
update_idx++; HashSet<EditorNode3DGizmo *>::Iterator E = current_gizmos.find(last_drawn);
update_idx = update_idx % current_gizmos.size(); if (E) {
redraw(current_gizmos.get(update_idx)); ++E;
}
if (!E) {
E = current_gizmos.begin();
}
redraw(*E);
last_drawn = *E;
} }
} }

View File

@ -37,7 +37,7 @@ class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(Joint3DGizmoPlugin, EditorNode3DGizmoPlugin); GDCLASS(Joint3DGizmoPlugin, EditorNode3DGizmoPlugin);
Timer *update_timer = nullptr; Timer *update_timer = nullptr;
uint64_t update_idx = 0; EditorNode3DGizmo *last_drawn = nullptr;
void incremental_update_gizmos(); void incremental_update_gizmos();

View File

@ -1060,7 +1060,7 @@ Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::get_gizmo(Node3D *p_spatial) {
ref->set_node_3d(p_spatial); ref->set_node_3d(p_spatial);
ref->set_hidden(current_state == HIDDEN); ref->set_hidden(current_state == HIDDEN);
current_gizmos.push_back(ref.ptr()); current_gizmos.insert(ref.ptr());
return ref; return ref;
} }

View File

@ -157,7 +157,7 @@ public:
protected: protected:
int current_state; int current_state;
List<EditorNode3DGizmo *> current_gizmos; HashSet<EditorNode3DGizmo *> current_gizmos;
HashMap<String, Vector<Ref<StandardMaterial3D>>> materials; HashMap<String, Vector<Ref<StandardMaterial3D>>> materials;
static void _bind_methods(); static void _bind_methods();