From b876876ae8f3a2d97c27f6fb4df236bcbfc53b7a Mon Sep 17 00:00:00 2001 From: Luke Pflibsen-Jones Date: Sun, 25 Jul 2021 22:27:57 -0700 Subject: [PATCH 1/2] Automate vertex merging --- gui.py | 3 +++ utilities.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gui.py b/gui.py index 281fa7c..fe6800a 100644 --- a/gui.py +++ b/gui.py @@ -185,6 +185,8 @@ class TreeGen(bpy.types.Operator): # Convert selected tree to mesh _scene.tree_gen_convert_to_mesh_input = _props.BoolProperty(name="Convert to Mesh After Generation", default=False, description="After generation, automatically convert the branches from a curve to a mesh") + _scene.tree_gen_merge_verts_by_distance = _props.BoolProperty(name="Merge Nearby Vertices", default=False, + description="After mesh conversion, merge nearby vertices together") # Create LODs _scene.tree_gen_create_lods_input = _props.BoolProperty(name="Create LODs After Generation", default=False, @@ -693,6 +695,7 @@ def label_row(label, prop, checkbox=False, dropdown=False, container=None): box = layout.box() box.row() label_row('', 'tree_gen_convert_to_mesh_input', checkbox=True, container=box) + label_row('', 'tree_gen_merge_verts_by_distance', checkbox=True, container=box) box.row() box.operator(TreeGenConvertToMesh.bl_idname) box.row() diff --git a/utilities.py b/utilities.py index dfc5140..58d4587 100644 --- a/utilities.py +++ b/utilities.py @@ -51,6 +51,9 @@ def update_log(msg): return update_log + def update_log(msg): + pass + return lambda _: None @@ -66,6 +69,9 @@ def convert_to_mesh(context): Converts tree branches from curve to mesh """ + from . import parametric + update_log = parametric.gen.update_log + try: tree = context.object except AttributeError: @@ -108,6 +114,14 @@ def convert_to_mesh(context): new_branches.matrix_world = tree.matrix_world new_branches.parent = tree + if context.scene.tree_gen_merge_verts_by_distance: + update_log('Merging duplicate vertices; this will take a bit for complex trees.\n') + + context.view_layer.objects.active = new_branches + bpy.ops.object.mode_set(mode='EDIT', toggle=True) + bpy.ops.mesh.select_all(action='SELECT') + bpy.ops.mesh.remove_doubles(threshold=0.0001) + def generate_lods(context, level_count=3): from . import parametric From b9f8c1f3b179949e37c9d819d1f775d04746b030 Mon Sep 17 00:00:00 2001 From: Luke Pflibsen-Jones Date: Mon, 26 Jul 2021 00:50:03 -0700 Subject: [PATCH 2/2] Align parameters --- gui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui.py b/gui.py index fe6800a..4020a11 100644 --- a/gui.py +++ b/gui.py @@ -186,7 +186,7 @@ class TreeGen(bpy.types.Operator): _scene.tree_gen_convert_to_mesh_input = _props.BoolProperty(name="Convert to Mesh After Generation", default=False, description="After generation, automatically convert the branches from a curve to a mesh") _scene.tree_gen_merge_verts_by_distance = _props.BoolProperty(name="Merge Nearby Vertices", default=False, - description="After mesh conversion, merge nearby vertices together") + description="After mesh conversion, merge nearby vertices together") # Create LODs _scene.tree_gen_create_lods_input = _props.BoolProperty(name="Create LODs After Generation", default=False,