[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46890] trunk/blender: Add skin modifier: DNA, RNA, UI, and MOD_skin.c implementation.

Nicholas Bishop nicholasbishop at gmail.com
Tue May 22 17:29:02 CEST 2012


Revision: 46890
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46890
Author:   nicholasbishop
Date:     2012-05-22 15:29:01 +0000 (Tue, 22 May 2012)
Log Message:
-----------
Add skin modifier: DNA, RNA, UI, and MOD_skin.c implementation.

Skin modifier documentation:
http://wiki.blender.org/index.php/User:Nicholasbishop/SkinModifier

Implementation based in part off the paper "B-Mesh: A Fast Modeling
System for Base Meshes of 3D Articulated Shapes" (Zhongping Ji,
Ligang Liu, Yigang Wang)

Note that to avoid confusion with Blender's BMesh data structure,
this tool is renamed as the Skin modifier.

The B-Mesh paper is current available here:
http://www.math.zju.edu.cn/ligangliu/CAGD/Projects/BMesh/

The main missing features in this code compared to the paper are:

* No mesh evolution. The paper suggests iteratively subsurfing the
  skin output and adapting the output to better conform with the
  spheres of influence surrounding each vertex.

* No mesh fairing. The paper suggests re-aligning output edges to
  follow principal mesh curvatures.

* No auxiliary balls. These would serve to influence mesh
  evolution, which as noted above is not implemented.

The code also adds some features not present in the paper:

* Loops in the input edge graph.

* Concave surfaces around branch nodes. The paper does not discuss
  how to handle non-convex regions; this code adds a number of
  cleanup operations to handle many (though not all) of these
  cases.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
    trunk/blender/source/blender/makesdna/DNA_modifier_types.h
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_modifier.c
    trunk/blender/source/blender/modifiers/CMakeLists.txt
    trunk/blender/source/blender/modifiers/MOD_modifiertypes.h
    trunk/blender/source/blender/modifiers/intern/MOD_util.c

Added Paths:
-----------
    trunk/blender/source/blender/modifiers/intern/MOD_skin.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py	2012-05-22 15:28:44 UTC (rev 46889)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py	2012-05-22 15:29:01 UTC (rev 46890)
@@ -959,5 +959,29 @@
         layout.separator()
         self.vertex_weight_mask(layout, ob, md)
 
+    def SKIN(self, layout, ob, md):
+        layout.operator("object.skin_armature_create", text="Create Armature")
+
+        layout.separator()
+        layout.prop(md, "branch_smoothing")
+        layout.prop(md, "use_smooth_shade")
+
+        layout.label(text="Selected Vertices:")
+        split = layout.split()
+        
+        col = split.column(align=True)
+        col.operator("object.skin_loose_mark_clear", text="Mark Loose").action = "MARK"
+        col.operator("object.skin_loose_mark_clear", text="Clear Loose").action = "CLEAR"
+
+        col = split.column()
+        col.operator("object.skin_root_mark", text="Mark Root")
+        col.operator("object.skin_radii_equalize", text="Equalize Radii")
+
+        layout.label(text="Symmetry Axes:")
+        col = layout.column()
+        col.prop(md, "use_x_symmetry")
+        col.prop(md, "use_y_symmetry")
+        col.prop(md, "use_z_symmetry")
+        
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)

Modified: trunk/blender/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_modifier_types.h	2012-05-22 15:28:44 UTC (rev 46889)
+++ trunk/blender/source/blender/makesdna/DNA_modifier_types.h	2012-05-22 15:29:01 UTC (rev 46890)
@@ -77,6 +77,7 @@
 	eModifierType_Ocean,
 	eModifierType_DynamicPaint,
 	eModifierType_Remesh,
+	eModifierType_Skin,
 	NUM_MODIFIER_TYPES
 } ModifierType;
 
@@ -1065,4 +1066,30 @@
 	char pad;
 } RemeshModifierData;
 
+/* Skin modifier */
+
+typedef struct SkinModifierData {
+	ModifierData modifier;
+
+	float branch_smoothing;
+
+	char flag;
+	
+	char symmetry_axes;
+
+	char pad[2];
+} SkinModifierData;
+
+/* SkinModifierData.symmetry_axes */
+enum {
+	MOD_SKIN_SYMM_X = 1,
+	MOD_SKIN_SYMM_Y = 2,
+	MOD_SKIN_SYMM_Z = 4,
+};
+
+/* SkinModifierData.flag */
+enum {
+	MOD_SKIN_SMOOTH_SHADING = 1
+};
+
 #endif

Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h	2012-05-22 15:28:44 UTC (rev 46889)
+++ trunk/blender/source/blender/makesrna/RNA_access.h	2012-05-22 15:29:01 UTC (rev 46890)
@@ -466,6 +466,7 @@
 extern StructRNA RNA_ShrinkwrapConstraint;
 extern StructRNA RNA_ShrinkwrapModifier;
 extern StructRNA RNA_SimpleDeformModifier;
+extern StructRNA RNA_SkinModifier;
 extern StructRNA RNA_SmokeCollSettings;
 extern StructRNA RNA_SmokeDomainSettings;
 extern StructRNA RNA_SmokeFlowSettings;

Modified: trunk/blender/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_modifier.c	2012-05-22 15:28:44 UTC (rev 46889)
+++ trunk/blender/source/blender/makesrna/intern/rna_modifier.c	2012-05-22 15:29:01 UTC (rev 46890)
@@ -75,6 +75,7 @@
 	{eModifierType_Multires, "MULTIRES", ICON_MOD_MULTIRES, "Multiresolution", ""},
 	{eModifierType_Remesh, "REMESH", ICON_MOD_REMESH, "Remesh", ""},
 	{eModifierType_Screw, "SCREW", ICON_MOD_SCREW, "Screw", ""},
+	{eModifierType_Skin, "SKIN", ICON_MOD_SKIN, "Skin", ""},
 	{eModifierType_Solidify, "SOLIDIFY", ICON_MOD_SOLIDIFY, "Solidify", ""},
 	{eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""},
 	{0, "", 0, N_("Deform"), ""},
@@ -207,6 +208,8 @@
 			return &RNA_DynamicPaintModifier;
 		case eModifierType_Remesh:
 			return &RNA_RemeshModifier;
+		case eModifierType_Skin:
+			return &RNA_SkinModifier;
 		default:
 			return &RNA_Modifier;
 	}
@@ -3196,6 +3199,42 @@
 	/* XXX how to update? */
 }
 
+static void rna_def_modifier_skin(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	srna= RNA_def_struct(brna, "SkinModifier", "Modifier");
+	RNA_def_struct_ui_text(srna, "Skin Modifier", "Generate Skin");
+	RNA_def_struct_sdna(srna, "SkinModifierData");
+	RNA_def_struct_ui_icon(srna, ICON_MOD_SKIN);
+
+	prop = RNA_def_property(srna, "branch_smoothing", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_ui_text(prop, "Branch Smoothing", "Smooth complex geometry around branches");
+	RNA_def_property_ui_range(prop, 0, 1, 1, 0);
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "use_smooth_shade", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SKIN_SMOOTH_SHADING);
+	RNA_def_property_ui_text(prop, "Smooth Shading", "Output faces with smooth shading rather than flat shaded");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "use_x_symmetry", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_X);
+	RNA_def_property_ui_text(prop, "X", "Avoid making unsymmetric quads across the X axis");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "use_y_symmetry", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Y);
+	RNA_def_property_ui_text(prop, "Y", "Avoid making unsymmetric quads across the Y axis");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "use_z_symmetry", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Z);
+	RNA_def_property_ui_text(prop, "Z", "Avoid making unsymmetric quads across the Z axis");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
 void RNA_def_modifier(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -3301,6 +3340,7 @@
 	rna_def_modifier_dynamic_paint(brna);
 	rna_def_modifier_ocean(brna);
 	rna_def_modifier_remesh(brna);
+	rna_def_modifier_skin(brna);
 }
 
 #endif

Modified: trunk/blender/source/blender/modifiers/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/modifiers/CMakeLists.txt	2012-05-22 15:28:44 UTC (rev 46889)
+++ trunk/blender/source/blender/modifiers/CMakeLists.txt	2012-05-22 15:29:01 UTC (rev 46890)
@@ -77,6 +77,7 @@
 	intern/MOD_shapekey.c
 	intern/MOD_shrinkwrap.c
 	intern/MOD_simpledeform.c
+	intern/MOD_skin.c
 	intern/MOD_smoke.c
 	intern/MOD_smooth.c
 	intern/MOD_softbody.c

Modified: trunk/blender/source/blender/modifiers/MOD_modifiertypes.h
===================================================================
--- trunk/blender/source/blender/modifiers/MOD_modifiertypes.h	2012-05-22 15:28:44 UTC (rev 46889)
+++ trunk/blender/source/blender/modifiers/MOD_modifiertypes.h	2012-05-22 15:29:01 UTC (rev 46890)
@@ -74,6 +74,7 @@
 extern ModifierTypeInfo modifierType_WeightVGProximity;
 extern ModifierTypeInfo modifierType_DynamicPaint;
 extern ModifierTypeInfo modifierType_Remesh;
+extern ModifierTypeInfo modifierType_Skin;
 
 /* MOD_util.c */
 void modifier_type_init(ModifierTypeInfo *types[]);

Added: trunk/blender/source/blender/modifiers/intern/MOD_skin.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_skin.c	                        (rev 0)
+++ trunk/blender/source/blender/modifiers/intern/MOD_skin.c	2012-05-22 15:29:01 UTC (rev 46890)
@@ -0,0 +1,1854 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * Contributor(s): Nicholas Bishop
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/modifiers/intern/MOD_skin.c
+ *  \ingroup modifiers
+ */
+
+/* Implementation based in part off the paper "B-Mesh: A Fast Modeling
+ * System for Base Meshes of 3D Articulated Shapes" (Zhongping Ji,
+ * Ligang Liu, Yigang Wang)
+ * 
+ * Note that to avoid confusion with Blender's BMesh data structure,
+ * this tool is renamed as the Skin modifier.
+ *
+ * The B-Mesh paper is current available here:
+ * http://www.math.zju.edu.cn/ligangliu/CAGD/Projects/BMesh/
+ *
+ * The main missing features in this code compared to the paper are:
+ * 
+ * + No mesh evolution. The paper suggests iteratively subsurfing the
+ *   skin output and adapting the output to better conform with the
+ *   spheres of influence surrounding each vertex.
+ *
+ * + No mesh fairing. The paper suggests re-aligning output edges to
+ *   follow principal mesh curvatures.
+ *
+ * + No auxiliary balls. These would serve to influence mesh
+ *   evolution, which as noted above is not implemented.
+ *
+ * The code also adds some features not present in the paper:
+ *
+ * + Loops in the input edge graph.
+ *
+ * + Concave surfaces around branch nodes. The paper does not discuss
+ *   how to handle non-convex regions; this code adds a number of
+ *   cleanup operations to handle many (though not all) of these
+ *   cases.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_modifier_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_array.h"
+#include "BLI_heap.h"
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_deform.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_mesh.h"
+#include "BKE_modifier.h"
+#include "BKE_tessmesh.h"
+
+#include "MOD_util.h"
+
+typedef struct {
+	float mat[3][3];
+	/* Vert that edge is pointing away from, no relation to

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list