[Bf-blender-cvs] [3a00152fe71] lanpr-under-gp: LineArt: Option for remove doubles when loading mesh.

YimingWu noreply at git.blender.org
Mon Oct 19 08:34:37 CEST 2020


Commit: 3a00152fe711665bcb911a318dc856c582cc09ad
Author: YimingWu
Date:   Mon Oct 19 14:34:17 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB3a00152fe711665bcb911a318dc856c582cc09ad

LineArt: Option for remove doubles when loading mesh.

===================================================================

M	release/scripts/startup/bl_ui/properties_render.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/editors/include/ED_lineart.h
M	source/blender/editors/lineart/lineart_cpu.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 36c2f2ed23c..d15091ae659 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -760,6 +760,7 @@ class RENDER_PT_lineart_line_types(RenderButtonsPanel, Panel):
         layout.prop(lineart, "allow_duplication", text="Allow Instances")
         layout.prop(lineart, "allow_overlapping_edges")
         layout.prop(lineart, "allow_clipping_boundaries")
+        layout.prop(lineart, "remove_doubles")
 
 
 class RENDER_PT_lineart_baking(RenderButtonsPanel, Panel):
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index b7617e85ce3..c44e9b5efff 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -5115,16 +5115,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
       }
     }
 
-    for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
-      if (!DNA_struct_find(fd->filesdna, "SceneLineart")) {
-        for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
-          scene->lineart.crease_threshold = 145.0f; /* in degrees. */
-          scene->lineart.line_types |= LRT_EDGE_FLAG_ALL_TYPE;
-          scene->lineart.flags |= LRT_ALLOW_DUPLI_OBJECTS;
-        }
-      }
-    }
-
     for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
       /* Don't rotate light with the viewer by default, make it fixed. Shading settings can't be
        * edited and this flag should always be set. So we can always execute this. */
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 5e6fdad8509..6d4244e789c 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -862,6 +862,16 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
         part->phystype = PART_PHYS_NO;
       }
     }
+
+    for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+      if (!DNA_struct_find(fd->filesdna, "SceneLineart")) {
+        for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+          scene->lineart.crease_threshold = 145.0f; /* in degrees. */
+          scene->lineart.line_types |= LRT_EDGE_FLAG_ALL_TYPE;
+          scene->lineart.flags |= (LRT_ALLOW_DUPLI_OBJECTS | LRT_REMOVE_DOUBLES);
+        }
+      }
+    }
   }
 
   /**
diff --git a/source/blender/editors/include/ED_lineart.h b/source/blender/editors/include/ED_lineart.h
index 524ec7ba2b0..57054c4ee8e 100644
--- a/source/blender/editors/include/ED_lineart.h
+++ b/source/blender/editors/include/ED_lineart.h
@@ -259,6 +259,7 @@ typedef struct LineartRenderBuffer {
   char fuzzy_intersections;
   char fuzzy_everything;
   char allow_boundaries;
+  char remove_doubles;
 
   /** Keep an copy of these data so the scene can be freed when lineart is runnning. */
   char cam_is_persp;
diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index d5b4b58c7e7..727795a13c3 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -37,6 +37,7 @@
 #include "BKE_curve.h"
 #include "BKE_customdata.h"
 #include "BKE_deform.h"
+#include "BKE_editmesh.h"
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
 #include "BKE_gpencil_geom.h"
@@ -1592,6 +1593,30 @@ static void lineart_geometry_object_load(Depsgraph *dg,
                        &((struct BMeshFromMeshParams){
                            .calc_face_normal = true,
                        }));
+
+    if (rb->remove_doubles) {
+      BMEditMesh *em = BKE_editmesh_create(bm, false);
+      BMOperator findop, weldop;
+      BMO_op_initf(bm,
+                   &findop,
+                   BMO_FLAG_DEFAULTS,
+                   "find_doubles verts=%av keep_verts=%Hv dist=%f",
+                   BM_ELEM_SELECT,
+                   0.0001);
+
+      BMO_op_exec(bm, &findop);
+
+      /* weld the vertices */
+      BMO_op_init(bm, &weldop, BMO_FLAG_DEFAULTS, "weld_verts");
+      BMO_slot_copy(&findop, slots_out, "targetmap.out", &weldop, slots_in, "targetmap");
+      BMO_op_exec(bm, &weldop);
+
+      BMO_op_finish(bm, &findop);
+      BMO_op_finish(bm, &weldop);
+
+      MEM_freeN(em);
+    }
+
     BM_mesh_elem_hflag_disable_all(bm, BM_FACE | BM_EDGE, BM_ELEM_TAG, false);
     BM_mesh_triangulate(
         bm, MOD_TRIANGULATE_QUAD_BEAUTY, MOD_TRIANGULATE_NGON_BEAUTY, 4, false, NULL, NULL, NULL);
@@ -2727,6 +2752,7 @@ LineartRenderBuffer *ED_lineart_create_render_buffer(Scene *scene)
   rb->fuzzy_intersections = (scene->lineart.flags & LRT_INTERSECTION_AS_CONTOUR) != 0;
   rb->fuzzy_everything = (scene->lineart.flags & LRT_EVERYTHING_AS_CONTOUR) != 0;
   rb->allow_boundaries = (scene->lineart.flags & LRT_ALLOW_CLIPPING_BOUNDARIES) != 0;
+  rb->remove_doubles = (scene->lineart.flags & LRT_REMOVE_DOUBLES) != 0;
 
   rb->use_contour = (scene->lineart.line_types & LRT_EDGE_FLAG_CONTOUR) != 0;
   rb->use_crease = (scene->lineart.line_types & LRT_EDGE_FLAG_CREASE) != 0;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 654007ac6ee..1ae87a700f5 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1678,6 +1678,7 @@ typedef enum eLineartMainFlags {
   LRT_ALLOW_CLIPPING_BOUNDARIES = (1 << 11),
   LRT_BAKING_FINAL_RANGE = (1 << 12),
   LRT_BAKING_KEYFRAMES_ONLY = (1 << 13),
+  LRT_REMOVE_DOUBLES = (1 << 14),
 } eLineartMainFlags;
 
 typedef struct SceneLineart {
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 4f498d409b3..e9b6e726dce 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -7444,6 +7444,13 @@ static void rna_def_scene_lineart(BlenderRNA *brna)
   RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(179), 0.01f, 2);
   RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update");
 
+  prop = RNA_def_property(srna, "remove_doubles", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_REMOVE_DOUBLES);
+  RNA_def_property_boolean_default(prop, 0);
+  RNA_def_property_ui_text(
+      prop, "Remove Doubles", "Remove doubles internally when running line art");
+  RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update");
+
   /* types */
   prop = RNA_def_property(srna, "use_contour", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "line_types", LRT_EDGE_FLAG_CONTOUR);



More information about the Bf-blender-cvs mailing list