[Bf-blender-cvs] [25638a9] master: Code cleanup: White space and dead code.

Tamito Kajiyama noreply at git.blender.org
Fri Jul 10 16:16:36 CEST 2015


Commit: 25638a96561a262864b3a036ee57adb290665b07
Author: Tamito Kajiyama
Date:   Fri Jul 10 22:53:58 2015 +0900
Branches: master
https://developer.blender.org/rB25638a96561a262864b3a036ee57adb290665b07

Code cleanup: White space and dead code.

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

M	release/scripts/freestyle/modules/freestyle/utils.py
M	release/scripts/freestyle/modules/parameter_editor.py
M	source/blender/makesdna/DNA_linestyle_types.h

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

diff --git a/release/scripts/freestyle/modules/freestyle/utils.py b/release/scripts/freestyle/modules/freestyle/utils.py
index c664268..ac6ea5b 100644
--- a/release/scripts/freestyle/modules/freestyle/utils.py
+++ b/release/scripts/freestyle/modules/freestyle/utils.py
@@ -50,7 +50,6 @@ __all__ = (
     "tripplewise",
     )
 
-
 # module members
 from _freestyle import (
     ContextFunctions,
@@ -71,6 +70,7 @@ from functools import lru_cache, namedtuple
 from math import cos, sin, pi, atan2
 from itertools import tee, compress
 
+
 # -- types -- #
 
 # A named tuple primitive used for storing data that has an upper and
@@ -92,6 +92,7 @@ def rgb_to_bw(r, g, b):
     """Method to convert rgb to a bw intensity value."""
     return 0.35 * r + 0.45 * g + 0.2 * b
 
+
 def bound(lower, x, higher):
     """Returns x bounded by a maximum and minimum value. Equivalent to:
     return min(max(x, lower), higher)
@@ -99,6 +100,7 @@ def bound(lower, x, higher):
     # this is about 50% quicker than min(max(x, lower), higher)
     return (lower if x <= lower else higher if x >= higher else x)
 
+
 def get_strokes():
     """Get all strokes that are currently available"""
     return tuple(map(Operators().get_stroke_from_index, range(Operators().get_strokes_size())))
@@ -132,6 +134,7 @@ def material_from_fedge(fe):
         material = right if (right.priority > left.priority) else left
     return material
 
+
 def bounding_box(stroke):
     """
     Returns the maximum and minimum coordinates (the bounding box) of the stroke's vertices
@@ -139,9 +142,10 @@ def bounding_box(stroke):
     x, y = zip(*(svert.point for svert in stroke))
     return (Vector((min(x), min(y))), Vector((max(x), max(y))))
 
+
 def normal_at_I0D(it: Interface0DIterator) -> Vector:
-    """Normal at an Interface0D object. In contrast to Normal2DF0D this 
-       function uses the actual data instead of underlying Fedge objects. 
+    """Normal at an Interface0D object. In contrast to Normal2DF0D this
+       function uses the actual data instead of underlying Fedge objects.
     """
     if it.at_last and it.is_begin:
         # corner-case
@@ -165,18 +169,20 @@ def normal_at_I0D(it: Interface0DIterator) -> Vector:
         it.decrement()
     return (b.point - a.point).orthogonal().normalized()
 
+
 def angle_x_normal(it: Interface0DIterator):
     """unsigned angle between a Point's normal and the X axis, in radians"""
     normal = normal_at_I0D(it)
     return abs(atan2(normal[1], normal[0]))
 
+
 def curvature_from_stroke_vertex(svert):
     """The 3D curvature of an stroke vertex' underlying geometry
        The result is None or in the range [-inf, inf]"""
     c1 = svert.first_svertex.curvatures
     c2 = svert.second_svertex.curvatures
     if c1 is None and c2 is None:
-        Kr = None 
+        Kr = None
     elif c1 is None:
         Kr = c2[4]
     elif c2 is None:
@@ -185,6 +191,7 @@ def curvature_from_stroke_vertex(svert):
         Kr = c1[4] + svert.t2d * (c2[4] - c1[4])
     return Kr
 
+
 # -- General helper functions -- #
 
 @lru_cache(maxsize=32)
@@ -201,9 +208,8 @@ def phase_to_direction(length):
     return results
 
 
-
-# -- simplification of a set of points; based on simplify.js by Vladimir Agafonkin -- 
-#    https://mourner.github.io/simplify-js/ 
+# -- simplification of a set of points; based on simplify.js by Vladimir Agafonkin --
+#    https://mourner.github.io/simplify-js/
 
 def getSquareSegmentDistance(p, p1, p2):
     """
@@ -260,11 +266,12 @@ def simplifyDouglasPeucker(points, tolerance):
             first_stack.append(index)
             last_stack.append(last)
 
-        first = first_stack.pop() if first_stack else None 
-        last = last_stack.pop() if last_stack else None 
+        first = first_stack.pop() if first_stack else None
+        last = last_stack.pop() if last_stack else None
 
     return tuple(compress(points, markers))
 
+
 def simplify(points, tolerance):
     """Simplifies a set of points"""
     return simplifyDouglasPeucker(points, tolerance * tolerance)
@@ -475,6 +482,7 @@ def iter_distance_along_stroke(stroke):
         distance += (prev - curr).length
         yield distance
 
+
 # -- mathematical operations -- #
 
 def stroke_curvature(it):
@@ -520,24 +528,9 @@ def stroke_normal(stroke):
     for use in geometry modifiers it is advised to
     cast this generator function to a tuple or list
     """
-    # n = len(stroke) - 1
     it = iter(stroke)
     yield from (normal_at_I0D(it) for _ in it)
 
-    #for i, svert in enumerate(stroke):
-    #    if i == 0:
-    #        e = stroke[i + 1].point - svert.point
-    #        yield Vector((e[1], -e[0])).normalized()
-    #    elif i == n:
-    #        e = svert.point - stroke[i - 1].point
-    #        yield Vector((e[1], -e[0])).normalized()
-    #    else:
-    #        e1 = stroke[i + 1].point - svert.point
-    #        e2 = svert.point - stroke[i - 1].point
-    #        n1 = Vector((e1[1], -e1[0])).normalized()
-    #        n2 = Vector((e2[1], -e2[0])).normalized()
-    #        yield (n1 + n2).normalized()
-
 
 def get_test_stroke():
     """Returns a static stroke object for testing """
diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py
index a1d0528..fe6c6f6 100644
--- a/release/scripts/freestyle/modules/parameter_editor.py
+++ b/release/scripts/freestyle/modules/parameter_editor.py
@@ -190,7 +190,7 @@ class CurveMappingModifier(ScalarBlendModifier):
         curve.initialize()
         result = curve.curves[0].evaluate(t)
         # float precision errors in t can give a very weird result for evaluate.
-        # therefore, bound the result by the curve's min and max values 
+        # therefore, bound the result by the curve's min and max values
         return bound(curve.clip_min_y, result, curve.clip_max_y)
 
 
@@ -234,7 +234,6 @@ class ThicknessBlenderMixIn(ThicknessModifierMixIn):
                 thickness = sum(thickness)
             self.blend_thickness_symmetric(svert, thickness)
 
-
     def blend_thickness_symmetric(self, svert, v):
         """Blends and sets the thickness. Thickness is equal on each side of the backbone"""
         outer, inner = svert.attribute.thickness
@@ -443,6 +442,7 @@ class ThicknessDistanceFromObjectShader(ThicknessBlenderMixIn, CurveMappingModif
             b = self.value.min + self.evaluate(t) * self.value.delta
             self.blend_thickness(svert, b)
 
+
 # Material modifiers
 class ColorMaterialShader(ColorRampModifier):
     """Assigns a color to the vertices based on their underlying material."""
@@ -458,7 +458,7 @@ class ColorMaterialShader(ColorRampModifier):
             for svert in it:
                 material = self.func(it)
                 if self.attribute == 'LINE':
-                    b = material.line[0:3] 
+                    b = material.line[0:3]
                 elif self.attribute == 'DIFF':
                     b = material.diffuse[0:3]
                 else:
@@ -471,6 +471,7 @@ class ColorMaterialShader(ColorRampModifier):
                 b = self.evaluate(value)
                 svert.attribute.color = self.blend_ramp(a, b)
 
+
 class AlphaMaterialShader(CurveMappingModifier):
     """Assigns an alpha value to the vertices based on their underlying material."""
     def __init__(self, blend, influence, mapping, invert, curve, material_attribute):
@@ -503,7 +504,6 @@ class ThicknessMaterialShader(ThicknessBlenderMixIn, CurveMappingModifier):
 
 # Calligraphic thickness modifier
 
-
 class CalligraphicThicknessShader(ThicknessBlenderMixIn, ScalarBlendModifier):
     """Thickness modifier for achieving a calligraphy-like effect."""
     def __init__(self, thickness_position, thickness_ratio,
@@ -526,6 +526,7 @@ class CalligraphicThicknessShader(ThicknessBlenderMixIn, ScalarBlendModifier):
                 b = self.thickness.min
             self.blend_thickness(svert, b)
 
+
 # - Tangent Modifiers - #
 
 class TangentColorShader(ColorRampModifier):
@@ -535,7 +536,6 @@ class TangentColorShader(ColorRampModifier):
         for svert in it:
             angle = angle_x_normal(it)
             fac = self.evaluate(angle / pi)
-
             a = svert.attribute.color
             svert.attribute.color = self.blend_ramp(a, fac)
 
@@ -547,14 +547,13 @@ class TangentAlphaShader(CurveMappingModifier):
         for svert in it:
             angle = angle_x_normal(it)
             fac = self.evaluate(angle / pi)
-
             a = svert.attribute.alpha
             svert.attribute.alpha = self.blend(a, fac)
 
 
 class TangentThicknessShader(ThicknessBlenderMixIn, CurveMappingModifier):
     """Thickness based on the direction of the stroke"""
-    def __init__(self, thickness_position, thickness_ratio, blend, influence, mapping, invert, curve, 
+    def __init__(self, thickness_position, thickness_ratio, blend, influence, mapping, invert, curve,
                  thickness_min, thickness_max):
         ThicknessBlenderMixIn.__init__(self, thickness_position, thickness_ratio)
         CurveMappingModifier.__init__(self, blend, influence, mapping, invert, curve)
@@ -567,13 +566,15 @@ class TangentThicknessShader(ThicknessBlenderMixIn, CurveMappingModifier):
             thickness = self.thickness.min + self.evaluate(angle / pi) * self.thickness.delta
             self.blend_thickness(svert, thickness)
 
+
 # - Noise Modifiers - #
+
 class NoiseShader:
     """Base class for noise shaders"""
     def __init__(self, amplitude, period, seed=512):
         self.amplitude = amplitude
         self.scale = 1 / period / seed
-        self.seed = seed 
+        self.seed = seed
 
     def noisegen(self, stroke, n1=Noise(), n2=Noise()):
         """Produces two noise values per StrokeVertex for every vertex in the stroke"""
@@ -584,7 +585,7 @@ class NoiseShader:
             a = n1.turbulence_smooth(self.scale * svert.curvilinear_abscissa + initU1, 2)
             b = n2.turbulence_smooth(self.scale * svert.curvilinear_abscissa + initU2, 2)
             yield (svert, a, b)
- 
+
 
 class ThicknessNoiseShader(ThicknessBlenderMixIn, ScalarBlendModifier, NoiseShader):
     """Thickness based on pseudo-noise"""
@@ -608,7 +609,7 @@ class ColorNo

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list