[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41809] branches/soc-2008-mxcurioni: Added new options for splitting chains of feature edges by a minimum

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sun Nov 13 21:20:53 CET 2011


Revision: 41809
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41809
Author:   kjym3
Date:     2011-11-13 20:20:50 +0000 (Sun, 13 Nov 2011)
Log Message:
-----------
Added new options for splitting chains of feature edges by a minimum
and maximum 2D angle.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
    branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
    branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c

Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py	2011-11-13 18:18:48 UTC (rev 41808)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py	2011-11-13 20:20:50 UTC (rev 41809)
@@ -802,6 +802,23 @@
         idx2 = fe.materialIndex() if fe.isSmooth() else fe.bMaterialIndex()
         return idx1 != idx2
 
+class Curvature2DAngleThresholdUP0D(UnaryPredicate0D):
+    def __init__(self, min_angle=None, max_angle=None):
+        UnaryPredicate0D.__init__(self)
+        print(min_angle, max_angle)
+        self._min_angle = min_angle
+        self._max_angle = max_angle
+        self._func = Curvature2DAngleF0D()
+    def getName(self):
+        return "Curvature2DAngleThresholdUP0D"
+    def __call__(self, inter):
+        angle = math.pi - self._func(inter)
+        if self._min_angle is not None and angle < self._min_angle:
+            return True
+        if self._max_angle is not None and angle > self._max_angle:
+            return True
+        return False
+
 # Seed for random number generation
 
 class Seed:
@@ -926,6 +943,10 @@
     # split chains
     if linestyle.material_boundary:
         Operators.sequentialSplit(MaterialBoundaryUP0D())
+    if linestyle.use_min_angle or linestyle.use_max_angle:
+        min_angle = linestyle.min_angle if linestyle.use_min_angle else None
+        max_angle = linestyle.max_angle if linestyle.use_max_angle else None
+        Operators.sequentialSplit(Curvature2DAngleThresholdUP0D(min_angle, max_angle))
     # select chains
     if linestyle.use_min_length or linestyle.use_max_length:
         min_length = linestyle.min_length if linestyle.use_min_length else None

Modified: branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py	2011-11-13 18:18:48 UTC (rev 41808)
+++ branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py	2011-11-13 20:20:50 UTC (rev 41809)
@@ -588,7 +588,18 @@
             # Splitting
             col = layout.column()
             col.label(text="Splitting:")
-            row = col.row(align=True)
+            sub = col.row()
+            subcol = sub.column()
+            subcol.prop(linestyle, "use_min_angle", text="Min Angle")
+            subsub = subcol.split()
+            subsub.prop(linestyle, "min_angle", text="")
+            subsub.enabled = linestyle.use_min_angle
+            subcol = sub.column()
+            subcol.prop(linestyle, "use_max_angle", text="Max Angle")
+            subsub = subcol.split()
+            subsub.prop(linestyle, "max_angle", text="")
+            subsub.enabled = linestyle.use_max_angle
+            row = col.row()
             row.prop(linestyle, "material_boundary")
             # Selection
             col = layout.column()

Modified: branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h	2011-11-13 18:18:48 UTC (rev 41808)
+++ branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h	2011-11-13 20:20:50 UTC (rev 41809)
@@ -358,6 +358,8 @@
 #define LS_MIN_2D_LENGTH      16
 #define LS_MAX_2D_LENGTH      32
 #define LS_NO_CHAINING        64
+#define LS_MIN_2D_ANGLE       128
+#define LS_MAX_2D_ANGLE       256
 
 /* FreestyleLineStyle::chaining */
 #define LS_CHAINING_PLAIN    1
@@ -377,6 +379,7 @@
 	int flag, caps;
 	int chaining;
 	unsigned int rounds;
+	float min_angle, max_angle; /* for splitting */
 	float min_length, max_length;
 	unsigned short dash1, gap1, dash2, gap2, dash3, gap3;
 	int panel; /* for UI */

Modified: branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c	2011-11-13 18:18:48 UTC (rev 41808)
+++ branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c	2011-11-13 20:20:50 UTC (rev 41809)
@@ -184,7 +184,7 @@
 
 #else
 
-#include "DNA_material_types.h"
+#include "BLI_math.h"
 
 static void rna_def_modifier_type_common(StructRNA *srna, EnumPropertyItem *modifier_type_items, int blend, int color)
 {
@@ -823,6 +823,28 @@
 	RNA_def_property_ui_text(prop, "Same Object", "If true, only feature edges of the same object are joined");
 	RNA_def_property_update(prop, NC_SCENE, NULL);
 
+	prop= RNA_def_property(srna, "use_min_angle", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MIN_2D_ANGLE);
+	RNA_def_property_ui_text(prop, "Use Min 2D Angle", "Split chains at points with angles smaller than the minimum 2D angle");
+	RNA_def_property_update(prop, NC_SCENE, NULL);
+
+	prop= RNA_def_property(srna, "min_angle", PROP_FLOAT, PROP_ANGLE);
+	RNA_def_property_float_sdna(prop, NULL, "min_angle");
+	RNA_def_property_range(prop, 0.0f, (float)M_PI);
+	RNA_def_property_ui_text(prop, "Min 2D Angle", "Minimum 2D angle for splitting chains");
+	RNA_def_property_update(prop, NC_SCENE, NULL);
+
+	prop= RNA_def_property(srna, "use_max_angle", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MAX_2D_ANGLE);
+	RNA_def_property_ui_text(prop, "Use Max 2D Angle", "Split chains at points with angles larger than the maximum 2D angle");
+	RNA_def_property_update(prop, NC_SCENE, NULL);
+
+	prop= RNA_def_property(srna, "max_angle", PROP_FLOAT, PROP_ANGLE);
+	RNA_def_property_float_sdna(prop, NULL, "max_angle");
+	RNA_def_property_range(prop, 0.0f, (float)M_PI);
+	RNA_def_property_ui_text(prop, "Max 2D Angle", "Maximum 2D angle for splitting chains");
+	RNA_def_property_update(prop, NC_SCENE, NULL);
+
 	prop= RNA_def_property(srna, "use_min_length", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MIN_2D_LENGTH);
 	RNA_def_property_ui_text(prop, "Use Min 2D Length", "Enable the selection of chains by a minimum 2D length");




More information about the Bf-blender-cvs mailing list