[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59373] trunk/blender/release/scripts/ freestyle/style_modules/parameter_editor.py: Temporary fix for gaps in strokes when objects are behind the lines.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Wed Aug 21 23:20:51 CEST 2013


Revision: 59373
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59373
Author:   kjym3
Date:     2013-08-21 21:20:51 +0000 (Wed, 21 Aug 2013)
Log Message:
-----------
Temporary fix for gaps in strokes when objects are behind the lines.
Problem report by Light BWK through personal communications, thanks a lot!

Apparently there is something wrong in the way how edges are chained to
create strokes.  For some unknown reason, strokes may contain a very small
line segment that proceeds in the opposite direction (e.g., downward
even when adjacent stroke segments proceed upward), resulting in the
reported visual artefact.

This revision is intended to address the reported issue in most cases.
The present solution is not a proper fix of the issue.  Another code
update with better understanding of the real cause is due in the future
work.

Modified Paths:
--------------
    trunk/blender/release/scripts/freestyle/style_modules/parameter_editor.py

Modified: trunk/blender/release/scripts/freestyle/style_modules/parameter_editor.py
===================================================================
--- trunk/blender/release/scripts/freestyle/style_modules/parameter_editor.py	2013-08-21 20:45:51 UTC (rev 59372)
+++ trunk/blender/release/scripts/freestyle/style_modules/parameter_editor.py	2013-08-21 21:20:51 UTC (rev 59373)
@@ -971,6 +971,44 @@
 
 _seed = Seed()
 
+### T.K. 07-Aug-2013 Temporary fix for unexpected line gaps
+
+def iter_three_segments(stroke):
+    n = stroke.stroke_vertices_size()
+    if n >= 4:
+        it1 = stroke.stroke_vertices_begin()
+        it2 = stroke.stroke_vertices_begin()
+        it2.increment()
+        it3 = stroke.stroke_vertices_begin()
+        it3.increment()
+        it3.increment()
+        it4 = stroke.stroke_vertices_begin()
+        it4.increment()
+        it4.increment()
+        it4.increment()
+        while not it4.is_end:
+            yield (it1.object, it2.object, it3.object, it4.object)
+            it1.increment()
+            it2.increment()
+            it3.increment()
+            it4.increment()
+
+class StrokeCleaner(StrokeShader):
+    def shade(self, stroke):
+        for sv1, sv2, sv3, sv4 in iter_three_segments(stroke):
+            seg1 = sv2.point - sv1.point
+            seg2 = sv3.point - sv2.point
+            seg3 = sv4.point - sv3.point
+            if seg1.dot(seg2) < 0 and seg2.dot(seg3) < 0:
+                print(sv2.first_svertex.viewvertex)
+                print(sv2.second_svertex.viewvertex)
+                print(sv3.first_svertex.viewvertex)
+                print(sv3.second_svertex.viewvertex)
+                p2 = mathutils.Vector(sv2.point)
+                p3 = mathutils.Vector(sv3.point)
+                sv2.point = p3
+                sv3.point = p2
+
 # main function for parameter processing
 
 def process(layer_name, lineset_name):
@@ -1150,6 +1188,9 @@
         elif m.type == '2D_TRANSFORM':
             shaders_list.append(Transform2DShader(
                 m.pivot, m.scale_x, m.scale_y, m.angle, m.pivot_u, m.pivot_x, m.pivot_y))
+    ###
+    shaders_list.append(StrokeCleaner())
+    ###
     color = linestyle.color
     if (not linestyle.use_chaining) or (linestyle.chaining == 'PLAIN' and linestyle.use_same_object):
         thickness_position = linestyle.thickness_position




More information about the Bf-blender-cvs mailing list