@@ -513,7 +513,12 @@ def call_rust(config: dict[str, str], active_obj, second_mesh=None, second_mesh_
513
513
vertices = [Vector3 (v .co .x , v .co .y , v .co .z ) for v in active_obj .data .vertices if v .select ]
514
514
else :
515
515
# 4. Gather triangle vertex indices
516
- indices = [vert_idx for face in active_obj_to_process .data .polygons for vert_idx in face .vertices ]
516
+ if not all (len (face .vertices ) == 3 for face in active_obj_to_process .data .polygons ):
517
+ raise HallrException (f"The '{ active_obj_to_process .name } ' mesh is not fully triangulated!" )
518
+ indices = [v for face in active_obj_to_process .data .polygons for v in face .vertices ]
519
+ if len (indices ) == 0 :
520
+ raise HallrException (
521
+ f"No polygons found in '{ active_obj_to_process .name } ', maybe the mesh is not fully triangulated?" )
517
522
518
523
# 5. Convert the data to a ctypes-friendly format
519
524
vertices = [Vector3 (v .co .x , v .co .y , v .co .z ) for v in active_obj_to_process .data .vertices ]
@@ -536,10 +541,14 @@ def call_rust(config: dict[str, str], active_obj, second_mesh=None, second_mesh_
536
541
indices .append (edge .vertices [0 ])
537
542
indices .append (edge .vertices [1 ])
538
543
else :
544
+ first_indices_len = len (indices )
539
545
# Treat second mesh as triangulated mesh (like active_obj)
540
- indices += [vert_idx
541
- for face in second_obj_to_process .data .polygons
542
- for vert_idx in face .vertices ]
546
+ if not all (len (face .vertices ) == 3 for face in second_obj_to_process .data .polygons ):
547
+ raise HallrException (f"The '{ second_obj_to_process .name } ' mesh is not fully triangulated!" )
548
+ indices += [v for face in second_obj_to_process .data .polygons for v in face .vertices ]
549
+ if len (indices )- first_indices_len == 0 :
550
+ raise HallrException (f"No polygons found in '{ second_obj_to_process .name } ', maybe the mesh is not fully triangulated?" )
551
+
543
552
544
553
if active_obj_is_duplicated :
545
554
cleanup_duplicated_object (active_obj_to_process )
@@ -627,11 +636,9 @@ def call_rust_direct(config, active_obj, use_line_chunks=False):
627
636
else :
628
637
config ["mesh.format" ] = "triangulated"
629
638
# Collect vertices and check if the mesh is fully triangulated
630
- indices = []
631
- for face in active_obj_to_process .data .polygons :
632
- if len (face .vertices ) != 3 :
633
- raise HallrException ("The mesh is not fully triangulated!" )
634
- indices .extend (face .vertices )
639
+ if not all (len (face .vertices ) == 3 for face in active_obj_to_process .data .polygons ):
640
+ raise HallrException ("The mesh is not fully triangulated!" )
641
+ indices = [v for face in active_obj_to_process .data .polygons for v in face .vertices ]
635
642
if len (indices ) == 0 :
636
643
raise HallrException ("No polygons found, maybe the mesh is not fully triangulated?" )
637
644
indices_ptr = (ctypes .c_size_t * len (indices ))(* indices )
0 commit comments