diff --git a/src/job.py b/src/job.py index bda2973..6134662 100644 --- a/src/job.py +++ b/src/job.py @@ -70,7 +70,7 @@ def finish(self, unwrap, output, added_edges): uvvert_to_meshvert[uv_v] = mesh_verts[uv_v_idx] # the faces will all be separate, so merging by distance joins them - bmesh.ops.remove_doubles(uvbm, verts=uvbm.verts, dist=1e-7) + bmesh.ops.remove_doubles(uvbm, verts=uvbm.verts, dist=0.0001) # find boundary edges of uv bmesh which are seams of original bmesh seams = [] diff --git a/src/manager.py b/src/manager.py index dcad865..f0a856d 100644 --- a/src/manager.py +++ b/src/manager.py @@ -128,7 +128,7 @@ def finish_unwrap(self, unwrap, invalid_pass=False): if unwrap.merge_cuts: bm = new_bmesh(output) - bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=1e-7) + bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001) set_bmesh(bm, output) # automatically add grid material to final object @@ -205,11 +205,6 @@ def start_next(self): ) if self.error_code != 0: - # convert unsigned int - THRESHOLD = 2147483648 - ADJUSTMENT = 4294967296 - if self.error_code >= THRESHOLD: - self.error_code -= ADJUSTMENT err_msg = f"An unknown error occurred: {self.error_code}" msg.append(err_msg) logger.add_data("errors", err_msg) diff --git a/src/ops/start.py b/src/ops/start.py index 08fe96f..cb5fa11 100644 --- a/src/ops/start.py +++ b/src/ops/start.py @@ -21,6 +21,7 @@ calc_center, check_collection, cut, + cut_on_axes, deselect_all, export_obj, get_dir_path, @@ -286,34 +287,13 @@ def create_jobs(self, context): obj.select_set(True) symmetrize_job = None - # bisect if symmetry on - axes = props.sym_axes if props.use_symmetry: + # bisect if symmetry on + axes = props.sym_axes apply_transforms(obj) - - bm = new_bmesh(obj) obj_center = calc_center(obj) symmetrize_job = Symmetrise(1, axes, obj_center, props.sym_merge) - cuts = [] - if "X" in axes: - cuts.append((1, 0, 0)) - if "Y" in axes: - cuts.append((0, 1, 0)) - if "Z" in axes: - cuts.append((0, 0, 1)) - - for direction in cuts: - bmesh.ops.bisect_plane( - bm, - geom=bm.verts[:] + bm.edges[:] + bm.faces[:], - plane_co=obj_center, - plane_no=direction, - clear_inner=True, - ) - # if the object already had vertices down it's center plane - # there will be duplicates - bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=1e-7) - set_bmesh(bm, obj) + cut_on_axes(obj, obj_center, axes) # separate objects bpy.ops.mesh.separate(type="LOOSE") diff --git a/src/unwrap.py b/src/unwrap.py index 97c5f09..92ba015 100644 --- a/src/unwrap.py +++ b/src/unwrap.py @@ -166,8 +166,17 @@ def poll_folder(self): # mesh is invalid msg = "" + # convert unsigned int + THRESHOLD = 2147483648 + ADJUSTMENT = 4294967296 + if ret_code >= THRESHOLD: + ret_code -= ADJUSTMENT + move_to_invalid = False - if ret_code == 101: + if ret_code == -1: + msg = "Mesh needs cleanup" + move_to_invalid = True + elif ret_code == 101: msg = "Non Manifold Edges" move_to_invalid = True elif ret_code == 102: diff --git a/src/utils.py b/src/utils.py index 8473f10..6998e3c 100644 --- a/src/utils.py +++ b/src/utils.py @@ -287,3 +287,27 @@ def cut(num, center, length, dim, bm): bmesh.ops.split_edges( bm, edges=[e for e in cut if isinstance(e, bmesh.types.BMEdge)] ) + + +def cut_on_axes(obj, obj_center, axes): + bm = new_bmesh(obj) + cuts = [] + if "X" in axes: + cuts.append((1, 0, 0)) + if "Y" in axes: + cuts.append((0, 1, 0)) + if "Z" in axes: + cuts.append((0, 0, 1)) + + for direction in cuts: + bmesh.ops.bisect_plane( + bm, + geom=bm.verts[:] + bm.edges[:] + bm.faces[:], + plane_co=obj_center, + plane_no=direction, + clear_inner=True, + ) + # if the object already had vertices down its center plane + # there will be duplicates + bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=0.0001) + set_bmesh(bm, obj)