Added new line style options for sketchy chaining of feature edges.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Mon, 19 Sep 2011 22:40:44 +0000 (22:40 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Mon, 19 Sep 2011 22:40:44 +0000 (22:40 +0000)
The default chaining option is now called "Natural", while the new chaining options
are "Sketchy: Topology Preserved" and "Sketchy: Topology broken".  The latter two
options allow for generating chains of feature edges with a sketchy multiple touch.
The "Sketchy: Topology Preserved" option takes account of the topology of objects
in the view map, while the "Sketchy: Topology broken" ignores the edge topology.
The "rounds" option specifies the number of rounds in sketchy strokes.

release/scripts/freestyle/style_modules/parameter_editor.py
release/scripts/startup/bl_ui/properties_render.py
source/blender/blenkernel/intern/linestyle.c
source/blender/makesdna/DNA_linestyle_types.h
source/blender/makesrna/intern/rna_linestyle.c

index 45c242fec8eb6633f7a6a24224cc1633655dfc5c..0324586b13516a3afd1f51e117f8902fd569deb6 100644 (file)
@@ -881,10 +881,15 @@ def process(layer_name, lineset_name):
         upred = TrueUP1D()
     Operators.select(upred)
     # join feature edges to form chains
-    bpred = AngleLargerThanBP1D(1.0) # XXX temporary fix for occasional unexpected long lines
-    if linestyle.same_object:
-        bpred = AndBP1D(bpred, SameShapeIdBP1D())
-    Operators.bidirectionalChain(ChainPredicateIterator(upred, bpred), NotUP1D(upred))
+    if linestyle.chaining == "NATURAL":
+        bpred = AngleLargerThanBP1D(1.0) # XXX temporary fix for occasional unexpected long lines
+        if linestyle.same_object:
+            bpred = AndBP1D(bpred, SameShapeIdBP1D())
+        Operators.bidirectionalChain(ChainPredicateIterator(upred, bpred), NotUP1D(upred))
+    elif linestyle.chaining == "SKETCHY_TOPOLOGY_PRESERVED":
+        Operators.bidirectionalChain(pySketchyChainSilhouetteIterator(linestyle.rounds))
+    elif linestyle.chaining == "SKETCHY_TOPOLOGY_BROKEN":
+        Operators.bidirectionalChain(pySketchyChainingIterator(linestyle.rounds))
     # split chains
     if linestyle.material_boundary:
         Operators.sequentialSplit(MaterialBoundaryUP0D())
index f471ffc65e5fb03303b2a7049a7c06656ae651e8..8d72fc95cf12af3d43933ece6c4f743eb3d3dcef 100644 (file)
@@ -514,7 +514,13 @@ class RENDER_PT_freestyle_linestyle(RenderButtonsPanel, Panel):
             # Chaining
             col = layout.column()
             col.label(text="Chaining:")
-            col.prop(linestyle, "same_object")
+            col.prop(linestyle, "chaining", text="")
+            if linestyle.chaining == "NATURAL":
+                col.prop(linestyle, "same_object")
+            elif linestyle.chaining == "SKETCHY_TOPOLOGY_PRESERVED":
+                col.prop(linestyle, "rounds")
+            elif linestyle.chaining == "SKETCHY_TOPOLOGY_BROKEN":
+                col.prop(linestyle, "rounds")
             # Splitting
             col = layout.column()
             col.label(text="Splitting:")
index 86ea80cb89ed935f6ca9594dca2583874f323519..167f440ffd0017b87fe493386c16b96eb0cbbdaa 100644 (file)
@@ -69,6 +69,8 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle)
        linestyle->r = linestyle->g = linestyle->b = 0.0;
        linestyle->alpha = 1.0;
        linestyle->thickness = 1.0;
+       linestyle->chaining = LS_CHAINING_NATURAL;
+       linestyle->rounds = 3;
        linestyle->min_length = 0.0f;
        linestyle->max_length = 10000.0f;
 
index 85468ce6657bc127a9a3ad5db274db3cb1550b22..d3536da233659115700387ee49d20b5ae3986606 100644 (file)
@@ -322,6 +322,11 @@ typedef struct LineStyleThicknessModifier_Calligraphy {
 #define LS_MIN_2D_LENGTH      16
 #define LS_MAX_2D_LENGTH      32
 
+/* FreestyleLineStyle::chaining */
+#define LS_CHAINING_NATURAL                     1
+#define LS_CHAINING_SKETCHY_TOPOLOGY_PRESERVED  2
+#define LS_CHAINING_SKETCHY_TOPOLOGY_BROKEN     3
+
 /* FreestyleLineStyle::caps */
 #define LS_CAPS_BUTT    1
 #define LS_CAPS_ROUND   2
@@ -334,6 +339,8 @@ typedef struct FreestyleLineStyle {
        float r, g, b, alpha;
        float thickness;
        int flag, caps;
+       int chaining;
+       unsigned int rounds;
        float min_length, max_length;
        unsigned short dash1, gap1, dash2, gap2, dash3, gap3;
        int panel; /* for UI */
index 389d37466712deb95f7aa7f962417c5ebc9cc8eb..415379b39d1510a73a30b0d980cd8f49e6f52223 100644 (file)
@@ -674,6 +674,11 @@ static void rna_def_linestyle(BlenderRNA *brna)
                {LS_PANEL_GEOMETRY, "GEOMETRY", 0, "Geometry", "Show the panel for stroke geometry options."},
                {LS_PANEL_MISC, "MISC", 0, "Misc", "Show the panel for miscellaneous options."},
                {0, NULL, 0, NULL, NULL}};
+       static EnumPropertyItem chaining_items[] = {
+               {LS_CHAINING_NATURAL, "NATURAL", 0, "Natural", "Natural chaining."},
+               {LS_CHAINING_SKETCHY_TOPOLOGY_PRESERVED, "SKETCHY_TOPOLOGY_PRESERVED", 0, "Sketchy: Topology Preserved", "Natural chaining with a sketchy multiple touch."},
+               {LS_CHAINING_SKETCHY_TOPOLOGY_BROKEN, "SKETCHY_TOPOLOGY_BROKEN", 0, "Sketchy: Topology Broken", "Sketchy chaining with a broken topology of objects."},
+               {0, NULL, 0, NULL, NULL}};
        static EnumPropertyItem cap_items[] = {
                {LS_CAPS_BUTT, "BUTT", 0, "Butt", "Butt cap (flat)."},
                {LS_CAPS_ROUND, "ROUND", 0, "Round", "Round cap (half-circle)."},
@@ -723,6 +728,18 @@ static void rna_def_linestyle(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "LineStyleThicknessModifier");
        RNA_def_property_ui_text(prop, "Thickness Modifiers", "List of line thickness modifiers.");
 
+       prop= RNA_def_property(srna, "chaining", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "chaining");
+       RNA_def_property_enum_items(prop, chaining_items);
+       RNA_def_property_ui_text(prop, "Chaining", "Select the way how feature edges are jointed to form chains.");
+       RNA_def_property_update(prop, NC_SCENE, NULL);
+
+       prop= RNA_def_property(srna, "rounds", PROP_INT, PROP_UNSIGNED);
+       RNA_def_property_int_sdna(prop, NULL, "rounds");
+       RNA_def_property_range(prop, 1, 1000);
+       RNA_def_property_ui_text(prop, "Rounds", "Number of rounds in a sketch multiple touch.");
+       RNA_def_property_update(prop, NC_SCENE, NULL);
+
        prop= RNA_def_property(srna, "geometry_modifiers", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "geometry_modifiers", NULL);
        RNA_def_property_struct_type(prop, "LineStyleGeometryModifier");