From 6a54d2d55208a55c763b465198eae17bee3e29a5 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Sat, 29 Mar 2025 21:32:38 +0100 Subject: [PATCH] Fix EditorNode3DGizmo::add_solid_box() GPU stalling Fixes EditorNode3DGizmo::add_solid_box() stalling the GPU because it used a function that queries the mesh arrays from the GPU. --- editor/plugins/node_3d_editor_gizmos.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index d4a8a404163..3b08684502e 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -486,10 +486,10 @@ void EditorNode3DGizmo::add_handles(const Vector &p_handles, const Ref< void EditorNode3DGizmo::add_solid_box(const Ref &p_material, Vector3 p_size, Vector3 p_position, const Transform3D &p_xform) { ERR_FAIL_NULL(spatial_node); - BoxMesh box_mesh; - box_mesh.set_size(p_size); + Array arrays; + arrays.resize(RS::ARRAY_MAX); + BoxMesh::create_mesh_array(arrays, p_size); - Array arrays = box_mesh.surface_get_arrays(0); PackedVector3Array vertex = arrays[RS::ARRAY_VERTEX]; Vector3 *w = vertex.ptrw(); @@ -499,8 +499,9 @@ void EditorNode3DGizmo::add_solid_box(const Ref &p_material, Vector3 p arrays[RS::ARRAY_VERTEX] = vertex; - Ref m = memnew(ArrayMesh); - m->add_surface_from_arrays(box_mesh.surface_get_primitive_type(0), arrays); + Ref m; + m.instantiate(); + m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays); add_mesh(m, p_material, p_xform); }