From 987c3462feb3acf8117bf079e788cc87f9f8488b Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Thu, 11 Mar 2021 18:27:48 -0700 Subject: [PATCH] Fix pinned vertices in SoftBody editor gizmo The wrong vertices could be highlighted/selected due to generating a debug triangle mesh to gather points, which can modify the order of vertices. --- editor/spatial_editor_gizmos.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index db64f88ace0..25140ba4d05 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -2148,7 +2148,17 @@ void SoftBodySpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Ref tm = soft_body->get_mesh()->generate_triangle_mesh(); Vector points; - soft_body->get_mesh()->generate_debug_mesh_indices(points); + for (int i = 0; i < soft_body->get_mesh()->get_surface_count(); i++) { + Array arrays = soft_body->get_mesh()->surface_get_arrays(i); + ERR_CONTINUE(arrays.empty()); + + const PoolVector &vertices = arrays[Mesh::ARRAY_VERTEX]; + PoolVector::Read vertices_read = vertices.read(); + int vertex_count = vertices.size(); + for (int index = 0; index < vertex_count; ++index) { + points.push_back(vertices_read[index]); + } + } Ref material = get_material("shape_material", p_gizmo);