Skip to content

Commit 4bbf0ff

Browse files
author
eadf
committed
0.1.7
Added mesh triangulation checks
1 parent 29966a2 commit 4bbf0ff

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
version = "0.1.6"
2+
version = "0.1.7"
33
name = "hallr"
44
edition = "2024"
55
readme = "README.md"

blender_addon/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"category": "Object",
1313
"description": "A collection of addons written in Rust",
1414
"author": "EAD https://github.com/eadf",
15-
"version": (0, 1, 6),
15+
"version": (0, 1, 7),
1616
"warning": "This executes compiled rust code on your computer",
1717
}
1818

blender_addon/hallr_ffi_utils.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,12 @@ def call_rust(config: dict[str, str], active_obj, second_mesh=None, second_mesh_
513513
vertices = [Vector3(v.co.x, v.co.y, v.co.z) for v in active_obj.data.vertices if v.select]
514514
else:
515515
# 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?")
517522

518523
# 5. Convert the data to a ctypes-friendly format
519524
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_
536541
indices.append(edge.vertices[0])
537542
indices.append(edge.vertices[1])
538543
else:
544+
first_indices_len = len(indices)
539545
# 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+
543552

544553
if active_obj_is_duplicated:
545554
cleanup_duplicated_object(active_obj_to_process)
@@ -627,11 +636,9 @@ def call_rust_direct(config, active_obj, use_line_chunks=False):
627636
else:
628637
config["mesh.format"] = "triangulated"
629638
# 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]
635642
if len(indices) == 0:
636643
raise HallrException("No polygons found, maybe the mesh is not fully triangulated?")
637644
indices_ptr = (ctypes.c_size_t * len(indices))(*indices)

blender_addon/hallr_meander_toolpath.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ def execute(self, context):
103103
if settings.bounding_shape is not None:
104104
settings.bounding_shape = None
105105
return {'FINISHED'}
106+
107+
if settings.mesh is not None and bounding_shape == settings.mesh:
108+
self.report({'ERROR'}, "This object is already selected as the mesh. Please select a different object.")
109+
return {'CANCELLED'}
110+
106111
if bounding_shape.type != 'MESH':
107112
self.report({'ERROR'}, "The bounding shape should be of type 'MESH'.")
108113
settings.bounding_shape = None
@@ -135,6 +140,11 @@ def execute(self, context):
135140
settings.mesh = None
136141
return {'FINISHED'}
137142

143+
if settings.bounding_shape is not None and active_object == settings.bounding_shape:
144+
self.report({'ERROR'},
145+
"This object is already selected as the bounding shape. Please select a different object.")
146+
return {'CANCELLED'}
147+
138148
if active_object.type != 'MESH':
139149
self.report({'ERROR'}, "The mesh shape should be of type 'MESH'.")
140150
settings.mesh = None

0 commit comments

Comments
 (0)