Fix #129110: Join triangles can assert when topology influence is used

Also add test.

Ref: !129121
This commit is contained in:
Jason C. Wenger 2024-10-16 11:19:16 -05:00 committed by Campbell Barton
parent 3e6565b9d7
commit da689835e8
2 changed files with 12 additions and 11 deletions

View file

@ -973,9 +973,6 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
s.use_topo_influence = (s.topo_influnce != 0.0f);
s.edge_queue = BLI_heap_new();
s.select_tris_only = BMO_slot_bool_get(op->slots_in, "deselect_joined");
#ifndef NDEBUG
const int edges_num_init = bm->totedge;
#endif
if (s.use_topo_influence) {
s.edge_queue_nodes = static_cast<HeapNode **>(
MEM_malloc_arrayN(bm->totedge, sizeof(HeapNode *), __func__));
@ -1065,13 +1062,9 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
while (!BLI_heap_is_empty(s.edge_queue)) {
/* Get the best merge from the priority queue.
* Remove it from the both priority queue and the index. */
* Remove it from the priority queue. */
const float f_error = BLI_heap_top_value(s.edge_queue);
BMEdge *e = reinterpret_cast<BMEdge *>(BLI_heap_pop_min(s.edge_queue));
if (s.use_topo_influence) {
BLI_assert(BM_elem_index_get(e) >= 0);
s.edge_queue_nodes[BM_elem_index_get(e)] = nullptr;
}
/* Attempt the merge. */
BMFace *f_new = bm_faces_join_pair_by_edge(bm,
@ -1123,9 +1116,6 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
{
/* Expect a full processing to have occurred. */
BLI_assert(BLI_heap_is_empty(s.edge_queue));
if (s.use_topo_influence) {
BLI_assert(BLI_array_is_zeroed(s.edge_queue_nodes, sizeof(HeapNode *) * edges_num_init));
}
}
/* Clean up. */

View file

@ -506,6 +506,17 @@ def main():
"VERT", {i for i in range(42)})],
),
SpecMeshTest(
"TrisToQuads 10 deg negligible topo", "testPlanesTrisToQuad", "expectedPlanesTrisToQuad.10.notopo",
[OperatorSpecEditMode(
"tris_convert_to_quads",
{"face_threshold": 0.174533, "shape_threshold": 0.174533,
"topology_influence": 0.01, "deselect_joined": False,
"uvs": True, "vcols": True, "seam": True, "sharp": True, "materials": True},
"VERT", {i for i in range(42)})],
),
SpecMeshTest(
"TrisToQuads 180 deg no topo", "testPlanesTrisToQuad", "expectedPlanesTrisToQuad.180.notopo",
[OperatorSpecEditMode(