[Bf-extensions-cvs] [401caf7] master: ANT landscape: Cleanup, remove star imports

lijenstina noreply at git.blender.org
Sat Apr 15 22:59:45 CEST 2017


Commit: 401caf74d91d419c09eb6966b864732a84f5cbb7
Author: lijenstina
Date:   Sat Apr 15 22:58:43 2017 +0200
Branches: master
https://developer.blender.org/rBA401caf74d91d419c09eb6966b864732a84f5cbb7

ANT landscape: Cleanup, remove star imports

Bumped version to 0.1.5
Remove star imports
Imports as tuples
Pep8 cleanup
Consistent prop definitions
Some small UI fixes (use align where possible)
Some tooltips and EnumProperty UI names
Update links

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

M	add_mesh_ant_landscape.py

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

diff --git a/add_mesh_ant_landscape.py b/add_mesh_ant_landscape.py
index bf12176..2081b96 100644
--- a/add_mesh_ant_landscape.py
+++ b/add_mesh_ant_landscape.py
@@ -19,14 +19,13 @@
 bl_info = {
     "name": "ANT Landscape",
     "author": "Jimmy Hazevoet",
-    "version": (0, 1, 4),
+    "version": (0, 1, 5),
     "blender": (2, 77, 0),
     "location": "View3D > Add > Mesh",
     "description": "Add a landscape primitive",
-    "warning": "", # used for warning icon and text in addons panel
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+    "warning": "",
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
                 "Scripts/Add_Mesh/ANT_Landscape",
-    "tracker_url": "https://developer.blender.org/maniphest/task/create/?project=3&type=Bug",
     "category": "Add Mesh",
 }
 
@@ -46,9 +45,12 @@ Y_Offset:        Noise y offset in blender units
 NOISE OPTIONS: ( Most of these options are the same as in blender textures. )
 Random seed:     Use this to randomise the origin of the noise function.
 Noise size:      Size of the noise.
-Noise type:      Available noise types: multiFractal, ridgedMFractal, fBm, hybridMFractal, heteroTerrain, Turbulence, Distorted Noise, Marble, Shattered_hTerrain, Strata_hTerrain, Planet_noise
-Noise basis:     Blender, Perlin, NewPerlin, Voronoi_F1, Voronoi_F2, Voronoi_F3, Voronoi_F4, Voronoi_F2-F1, Voronoi Crackle, Cellnoise
-VLNoise basis:   Blender, Perlin, NewPerlin, Voronoi_F1, Voronoi_F2, Voronoi_F3, Voronoi_F4, Voronoi_F2-F1, Voronoi Crackle, Cellnoise
+Noise type:      Available noise types: multiFractal, ridgedMFractal, fBm, hybridMFractal, heteroTerrain,
+                 Turbulence, Distorted Noise, Marble, Shattered_hTerrain, Strata_hTerrain, Planet_noise
+Noise basis:     Blender, Perlin, NewPerlin, Voronoi_F1, Voronoi_F2, Voronoi_F3, Voronoi_F4, Voronoi_F2-F1,
+                 Voronoi Crackle, Cellnoise
+VLNoise basis:   Blender, Perlin, NewPerlin, Voronoi_F1, Voronoi_F2, Voronoi_F3, Voronoi_F4, Voronoi_F2-F1,
+                 Voronoi Crackle, Cellnoise
 Distortion:      Distortion amount.
 Hard:            Hard/Soft turbulence noise.
 Depth:           Noise depth, number of frequencies in the fBm.
@@ -73,10 +75,28 @@ Strata type:     Strata types, Smooth, Sharp-sub, Sharp-add
 
 # import modules
 import bpy
-from bpy.props import *
-from mathutils import *
-from mathutils.noise import *
-from math import *
+from bpy.props import (
+        BoolProperty,
+        EnumProperty,
+        FloatProperty,
+        IntProperty,
+        )
+from mathutils.noise import (
+        seed_set,
+        turbulence,
+        turbulence_vector,
+        fractal,
+        hybrid_multi_fractal,
+        multi_fractal,
+        ridged_multi_fractal,
+        hetero_terrain,
+        random_unit_vector,
+        variable_lacunarity,
+        )
+from math import (
+        floor, hypot,
+        sin, cos, pi,
+        )
 
 
 # Create a new mesh (object) from verts/edges/faces.
@@ -113,7 +133,8 @@ def saw_bias(a):
     b = 2 * pi
     n = int(a / b)
     a -= n * b
-    if a < 0: a += b
+    if a < 0:
+        a += b
     return a / b
 
 
@@ -132,8 +153,8 @@ def sharper(a):
 def shapes(x, y, shape=0):
     if shape == 1:
         # ring
-        x = x*2
-        y = y*2
+        x = x * 2
+        y = y * 2
         s = (-cos(x**2 + y**2) / (x**2 + y**2 + 0.5))
     elif shape == 2:
         # swirl
@@ -207,18 +228,18 @@ def strata_hterrain(x, y, z, H, lacunarity, octaves, offset, distort, basis):
 
 # planet_noise by Farsthary: https://farsthary.com/2010/11/24/new-planet-procedural-texture/
 def planet_noise(coords, oct=6, hard=0, noisebasis=1, nabla=0.001):
-    x,y,z = coords
+    x, y, z = coords
     d = 0.001
     offset = nabla * 1000
     x = turbulence((x, y, z), oct, hard, noisebasis)
-    y = turbulence((x + offset, y , z), oct, hard, noisebasis)
+    y = turbulence((x + offset, y, z), oct, hard, noisebasis)
     z = turbulence((x, y + offset, z), oct, hard, noisebasis)
-    xdy = x-turbulence((x, y + d, z), oct, hard, noisebasis)
-    xdz = x-turbulence((x, y, z + d), oct, hard, noisebasis)
-    ydx = y-turbulence((x + d, y, z), oct, hard, noisebasis)
-    ydz = y-turbulence((x, y, z + d), oct, hard, noisebasis)
-    zdx = z-turbulence((x + d, y, z), oct, hard, noisebasis)
-    zdy = z-turbulence((x, y + d, z), oct, hard, noisebasis)
+    xdy = x - turbulence((x, y + d, z), oct, hard, noisebasis)
+    xdz = x - turbulence((x, y, z + d), oct, hard, noisebasis)
+    ydx = y - turbulence((x + d, y, z), oct, hard, noisebasis)
+    ydz = y - turbulence((x, y, z + d), oct, hard, noisebasis)
+    zdx = z - turbulence((x + d, y, z), oct, hard, noisebasis)
+    zdy = z - turbulence((x, y + d, z), oct, hard, noisebasis)
     return (zdy - ydz), (zdx - xdz), (ydx - xdy)
 
 
@@ -226,7 +247,8 @@ def planet_noise(coords, oct=6, hard=0, noisebasis=1, nabla=0.001):
 # landscape_gen
 def landscape_gen(x, y, z, falloffsize, options):
 
-    # options = [0, 1.0, 'multi_fractal', 0, 0, 1.0, 0, 6, 1.0, 2.0, 1.0, 2.0, 0, 0, 0, 1.0, 0.0, 1, 0.0, 1.0, 0, 0, 0, 0.0, 0.0]
+    # options = [0, 1.0, 'multi_fractal', 0, 0, 1.0, 0, 6, 1.0, 2.0, 1.0, 2.0,
+    #            0, 0, 0, 1.0, 0.0, 1, 0.0, 1.0, 0, 0, 0, 0.0, 0.0]
     rseed = options[0]
     nsize = options[1]
     ntype = options[2]
@@ -276,11 +298,11 @@ def landscape_gen(x, y, z, falloffsize, options):
     # noise basis type's
     if nbasis == 9:
         nbasis = 14  # to get cellnoise basis you must set 14 instead of 9
-    if vlbasis ==9:
+    if vlbasis == 9:
         vlbasis = 14
 
     # noise type's
-    if ntype ==   'multi_fractal':
+    if ntype == 'multi_fractal':
         value = multi_fractal(ncoords, dimension, lacunarity, depth, nbasis) * 0.5
 
     elif ntype == 'ridged_multi_fractal':
@@ -302,13 +324,23 @@ def landscape_gen(x, y, z, falloffsize, options):
         value = variable_lacunarity(ncoords, distortion, nbasis, vlbasis) + 0.5
 
     elif ntype == 'marble_noise':
-        value = marble_noise(x * 2.0 / falloffsize, y * 2.0 / falloffsize, z * 2 / falloffsize, origin, nsize, marbleshape, marblebias, marblesharpnes, distortion, depth, hardnoise, nbasis)
+        value = marble_noise(
+                        x * 2.0 / falloffsize, y * 2.0 / falloffsize, z * 2 / falloffsize,
+                        origin, nsize, marbleshape, marblebias, marblesharpnes, distortion,
+                        depth, hardnoise, nbasis
+                        )
 
     elif ntype == 'shattered_hterrain':
-        value = shattered_hterrain(ncoords[0], ncoords[1], ncoords[2], dimension, lacunarity, depth, offset, distortion, nbasis)
+        value = shattered_hterrain(
+                        ncoords[0], ncoords[1], ncoords[2], dimension, lacunarity,
+                        depth, offset, distortion, nbasis
+                        )
 
     elif ntype == 'strata_hterrain':
-        value = strata_hterrain(ncoords[0], ncoords[1], ncoords[2], dimension, lacunarity, depth, offset, distortion, nbasis)
+        value = strata_hterrain(
+                        ncoords[0], ncoords[1], ncoords[2], dimension, lacunarity,
+                        depth, offset, distortion, nbasis
+                        )
 
     elif ntype == 'planet_noise':
         value = planet_noise(ncoords, depth, hardnoise, nbasis)[2] * 0.5 + 0.5
@@ -316,17 +348,17 @@ def landscape_gen(x, y, z, falloffsize, options):
         value = 0.0
 
     # adjust height
-    if invert !=0:
+    if invert != 0:
         value = (1 - value) * height + heightoffset
     else:
         value = value * height + heightoffset
 
     # edge falloff
-    if sphere == 0: # no edge falloff if spherical
+    if sphere == 0:  # no edge falloff if spherical
         if falloff != 0:
             fallofftypes = [0, hypot(x * x, y * y), hypot(x, y), abs(y), abs(x)]
             dist = fallofftypes[falloff]
-            if falloff ==1:
+            if falloff == 1:
                 radius = (falloffsize / 2)**2
             else:
                 radius = falloffsize / 2
@@ -340,7 +372,7 @@ def landscape_gen(x, y, z, falloffsize, options):
                 value = sealevel
 
     # strata / terrace / layered
-    if stratatype !='0':
+    if stratatype != '0':
         strata = strata / height
 
     if stratatype == '1':
@@ -350,11 +382,11 @@ def landscape_gen(x, y, z, falloffsize, options):
 
     elif stratatype == '2':
         steps = -abs(sin(value * strata * pi) * (0.1 / strata * pi))
-        value =(value * (1.0 - 0.5) + steps * 0.5) * 2.0
+        value = (value * (1.0 - 0.5) + steps * 0.5) * 2.0
 
     elif stratatype == '3':
         steps = abs(sin(value * strata * pi) * (0.1 / strata * pi))
-        value =(value * (1.0 - 0.5) + steps * 0.5) * 2.0
+        value = (value * (1.0 - 0.5) + steps * 0.5) * 2.0
 
     else:
         value = value
@@ -376,7 +408,7 @@ def grid_gen(sub_d, size_me, options):
     faces = []
 
     # fill verts array
-    for i in range (0, sub_d):
+    for i in range(0, sub_d):
         for j in range(0, sub_d):
             u = (i / (sub_d - 1) - 1 / 2)
             v = (j / (sub_d - 1) - 1 / 2)
@@ -388,7 +420,7 @@ def grid_gen(sub_d, size_me, options):
 
     # fill faces array
     count = 0
-    for i in range (0, sub_d*(sub_d - 1)):
+    for i in range(0, sub_d * (sub_d - 1)):
         if count < sub_d - 1:
             A = i + 1
             B = i
@@ -410,19 +442,19 @@ def sphere_gen(sub_d, size_me, options):
     faces = []
 
     # fill verts array
-    for i in range (0, sub_d):
+    for i in range(0, sub_d):
         for j in range(0, sub_d):
             u = sin(j * pi * 2 / (sub_d - 1)) * cos(-pi / 2 + i * pi / (sub_d - 1)) * size_me / 2
             v = cos(j * pi * 2 / (sub_d - 1)) * cos(-pi / 2 + i * pi / (sub_d - 1)) * size_me / 2
             w = sin(-pi / 2 + i * pi / (sub_d - 1)) * size_me / 2
             h = landscape_gen(u, v, w, size_me, options) / size_me
-            u,v,w = u + u * h, v + v * h, w + w * h
+            u, v, w = u + u * h, v + v * h, w + w * h
             vert = (u, v, w)
             verts.append(vert)
 
     # fill faces array
     count = 0
-    for i in range (0, sub_d * (sub_d - 1)):
+    for i in r

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list