Skip to content

Commit 6a54d2d

Browse files
committed
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.
1 parent 7598b08 commit 6a54d2d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

editor/plugins/node_3d_editor_gizmos.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,10 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<
486486
void EditorNode3DGizmo::add_solid_box(const Ref<Material> &p_material, Vector3 p_size, Vector3 p_position, const Transform3D &p_xform) {
487487
ERR_FAIL_NULL(spatial_node);
488488

489-
BoxMesh box_mesh;
490-
box_mesh.set_size(p_size);
489+
Array arrays;
490+
arrays.resize(RS::ARRAY_MAX);
491+
BoxMesh::create_mesh_array(arrays, p_size);
491492

492-
Array arrays = box_mesh.surface_get_arrays(0);
493493
PackedVector3Array vertex = arrays[RS::ARRAY_VERTEX];
494494
Vector3 *w = vertex.ptrw();
495495

@@ -499,8 +499,9 @@ void EditorNode3DGizmo::add_solid_box(const Ref<Material> &p_material, Vector3 p
499499

500500
arrays[RS::ARRAY_VERTEX] = vertex;
501501

502-
Ref<ArrayMesh> m = memnew(ArrayMesh);
503-
m->add_surface_from_arrays(box_mesh.surface_get_primitive_type(0), arrays);
502+
Ref<ArrayMesh> m;
503+
m.instantiate();
504+
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays);
504505
add_mesh(m, p_material, p_xform);
505506
}
506507

0 commit comments

Comments
 (0)