[Bf-blender-cvs] [f050fa32537] master: Modifier: New Weld Modifier

mano-wii noreply at git.blender.org
Thu Dec 12 02:34:25 CET 2019


Commit: f050fa325375ecf8931750baca7846cd830c7370
Author: mano-wii
Date:   Wed Dec 11 22:31:20 2019 -0300
Branches: master
https://developer.blender.org/rBf050fa325375ecf8931750baca7846cd830c7370

Modifier: New Weld Modifier

Part of T70240

This is the initial implementation of Weld Modifier.
New features will be added later.

ToDo:
- Seams: restrict welding to vertices along boundary edges.
- Edge Collapse: collapse edges below the length threshold.
- New icon.
- Some customdata are not being correctly interpolated.

Differential Revision: https://developer.blender.org/D6383

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/MOD_modifiertypes.h
M	source/blender/modifiers/intern/MOD_util.c
A	source/blender/modifiers/intern/MOD_weld.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index f576a29a783..c872b9acd4a 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1481,6 +1481,11 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         col.prop(md, "material_offset", text="Material Offset")
 
+    def WELD(self, layout, ob, md):
+        layout.prop(md, "merge_threshold", text="Distance")
+        layout.prop(md, "max_interactions")
+        layout.prop_search(md, "vertex_group", ob, "vertex_groups")
+
     def DATA_TRANSFER(self, layout, ob, md):
         row = layout.row(align=True)
         row.prop(md, "object")
@@ -2372,7 +2377,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         subcol.enabled = md.duplications > 0
         subcol.prop(md, "distance")
         subcol.prop(md, "offset", slider=True)
-    
+
         subcol.separator()
 
         subcol.prop(md, "enable_fading")
@@ -2408,7 +2413,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         row = layout.row(align=True)
         row.prop(md, "layer_pass", text="Pass")
         row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
-            
+
 classes = (
     DATA_PT_modifiers,
     DATA_PT_gpencil_modifiers,
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index d25bca2dc0e..486be952b2f 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2172,6 +2172,9 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
             case eModifierType_Wireframe:
               data.icon = ICON_MOD_WIREFRAME;
               break;
+            case eModifierType_Weld:
+              data.icon = ICON_AUTOMERGE_OFF; /* XXX, needs own icon */
+              break;
             case eModifierType_LaplacianDeform:
               data.icon = ICON_MOD_MESHDEFORM; /* XXX, needs own icon */
               break;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index a8db46238d8..0ed9a7f3e5e 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -86,6 +86,7 @@ typedef enum ModifierType {
   eModifierType_MeshSequenceCache = 52,
   eModifierType_SurfaceDeform = 53,
   eModifierType_WeightedNormal = 54,
+  eModifierType_Weld = 55,
   NUM_MODIFIER_TYPES,
 } ModifierType;
 
@@ -1810,6 +1811,16 @@ enum {
   MOD_WIREFRAME_CREASE = (1 << 5),
 };
 
+typedef struct WeldModifierData {
+  ModifierData modifier;
+
+  /* the limit below which to merge vertices in adjacent duplicates */
+  float merge_dist;
+  unsigned int max_interactions;
+  /** Name of vertex group to use to mask, MAX_VGROUP_NAME. */
+  char defgrp_name[64];
+} WeldModifierData;
+
 typedef struct DataTransferModifierData {
   ModifierData modifier;
 
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 94f2ec25ded..696503539a2 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -741,6 +741,7 @@ extern StructRNA RNA_Window;
 extern StructRNA RNA_WindowManager;
 extern StructRNA RNA_WipeSequence;
 extern StructRNA RNA_WireframeModifier;
+extern StructRNA RNA_WeldModifier;
 extern StructRNA RNA_WoodTexture;
 extern StructRNA RNA_WorkSpace;
 extern StructRNA RNA_World;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 1c5b4618bf8..3bb8be38682 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -187,6 +187,11 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
      ICON_MOD_WIREFRAME,
      "Wireframe",
      "Convert faces into thickened edges"},
+    {eModifierType_Weld,
+     "WELD",
+     ICON_AUTOMERGE_OFF,
+     "Weld",
+     "Finds groups of vertices closer then dist and merges them together"},
     {0, "", 0, N_("Deform"), ""},
     {eModifierType_Armature,
      "ARMATURE",
@@ -700,6 +705,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
       return &RNA_LaplacianDeformModifier;
     case eModifierType_Wireframe:
       return &RNA_WireframeModifier;
+    case eModifierType_Weld:
+      return &RNA_WeldModifier;
     case eModifierType_DataTransfer:
       return &RNA_DataTransferModifier;
     case eModifierType_NormalEdit:
@@ -803,6 +810,7 @@ RNA_MOD_VGROUP_NAME_SET(WeightVGMix, mask_defgrp_name);
 RNA_MOD_VGROUP_NAME_SET(WeightVGProximity, defgrp_name);
 RNA_MOD_VGROUP_NAME_SET(WeightVGProximity, mask_defgrp_name);
 RNA_MOD_VGROUP_NAME_SET(WeightedNormal, defgrp_name);
+RNA_MOD_VGROUP_NAME_SET(Weld, defgrp_name);
 RNA_MOD_VGROUP_NAME_SET(Wireframe, defgrp_name);
 
 static void rna_ExplodeModifier_vgroup_get(PointerRNA *ptr, char *value)
@@ -5659,6 +5667,40 @@ static void rna_def_modifier_wireframe(BlenderRNA *brna)
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
+static void rna_def_modifier_weld(BlenderRNA *brna)
+{
+  StructRNA *srna;
+  PropertyRNA *prop;
+
+  srna = RNA_def_struct(brna, "WeldModifier", "Modifier");
+  RNA_def_struct_ui_text(srna, "Weld Modifier", "Weld modifier");
+  RNA_def_struct_sdna(srna, "WeldModifierData");
+  RNA_def_struct_ui_icon(srna, ICON_AUTOMERGE_OFF);
+
+  prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
+  RNA_def_property_float_sdna(prop, NULL, "merge_dist");
+  RNA_def_property_range(prop, 0, FLT_MAX);
+  RNA_def_property_ui_range(prop, 0, 1, 0.001, 6);
+  RNA_def_property_ui_text(prop, "Merge Distance", "Limit below which to merge vertices");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+  prop = RNA_def_property(srna, "max_interactions", PROP_INT, PROP_UNSIGNED);
+  RNA_def_property_int_sdna(prop, NULL, "max_interactions");
+  RNA_def_property_ui_text(
+      prop,
+      "Duplicate Limit",
+      "For a better performance, limits the number of elements found per vertex. "
+      "(0 makes it infinite)");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+  prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
+  RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
+  RNA_def_property_ui_text(
+      prop, "Vertex Group", "Vertex group name for selecting the affected areas");
+  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeldModifier_defgrp_name_set");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
 static void rna_def_modifier_datatransfer(BlenderRNA *brna)
 {
   StructRNA *srna;
@@ -6368,6 +6410,7 @@ void RNA_def_modifier(BlenderRNA *brna)
   rna_def_modifier_meshcache(brna);
   rna_def_modifier_laplaciandeform(brna);
   rna_def_modifier_wireframe(brna);
+  rna_def_modifier_weld(brna);
   rna_def_modifier_datatransfer(brna);
   rna_def_modifier_normaledit(brna);
   rna_def_modifier_meshseqcache(brna);
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 602ef634e1b..11c27ad9066 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -101,6 +101,7 @@ set(SRC
   intern/MOD_weightvgedit.c
   intern/MOD_weightvgmix.c
   intern/MOD_weightvgproximity.c
+  intern/MOD_weld.c
   intern/MOD_wireframe.c
 
   MOD_modifiertypes.h
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index 96622bf7763..d678c6b84fa 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -75,6 +75,7 @@ extern ModifierTypeInfo modifierType_UVWarp;
 extern ModifierTypeInfo modifierType_MeshCache;
 extern ModifierTypeInfo modifierType_LaplacianDeform;
 extern ModifierTypeInfo modifierType_Wireframe;
+extern ModifierTypeInfo modifierType_Weld;
 extern ModifierTypeInfo modifierType_DataTransfer;
 extern ModifierTypeInfo modifierType_NormalEdit;
 extern ModifierTypeInfo modifierType_CorrectiveSmooth;
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 1e3c747022c..05bd8b5e01a 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -301,6 +301,7 @@ void modifier_type_init(ModifierTypeInfo *types[])
   INIT_TYPE(MeshCache);
   INIT_TYPE(LaplacianDeform);
   INIT_TYPE(Wireframe);
+  INIT_TYPE(Weld);
   INIT_TYPE(DataTransfer);
   INIT_TYPE(NormalEdit);
   INIT_TYPE(CorrectiveSmooth);
diff --git a/source/blender/modifiers/intern/MOD_weld.c b/source/blender/modifiers/intern/MOD_weld.c
new file mode 100644
index 00000000000..ca6998b9aa4
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_weld.c
@@ -0,0 +1,1910 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software  Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 by the Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup modifiers
+ *
+ * Weld modifier: Remove doubles.
+ */
+
+/* TODOs:
+ * - Review weight and vertex color interpolation.;
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
+#include "BLI_alloca.h"
+#include "BLI_kdopbvh.h"
+#include "BLI_math.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_deform.h"
+#include "BKE_bvhutils.h"
+#include "BKE_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list