[Bf-extensions-cvs] [7fd30539] blender-v2.83-release: Fix T70357: ANT Landscape Line artifacts

Jimmy Haze noreply at git.blender.org
Wed Jun 3 11:45:03 CEST 2020


Commit: 7fd30539c69ce4aa3363e0d7c5e00ff4ca13886b
Author: Jimmy Haze
Date:   Thu May 7 10:44:18 2020 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rBA7fd30539c69ce4aa3363e0d7c5e00ff4ca13886b

Fix T70357: ANT Landscape Line artifacts

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

M	ant_landscape/ant_functions.py
M	ant_landscape/ant_noise.py

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

diff --git a/ant_landscape/ant_functions.py b/ant_landscape/ant_functions.py
index b4e1e1f5..5298db3d 100644
--- a/ant_landscape/ant_functions.py
+++ b/ant_landscape/ant_functions.py
@@ -59,32 +59,28 @@ def create_mesh_object(context, verts, edges, faces, name):
 def grid_gen(sub_d_x, sub_d_y, tri, meshsize_x, meshsize_y, props, water_plane, water_level):
     verts = []
     faces = []
+    vappend = verts.append
+    fappend = faces.append
     for i in range (0, sub_d_x):
         x = meshsize_x * (i / (sub_d_x - 1) - 1 / 2)
         for j in range(0, sub_d_y):
             y = meshsize_y * (j / (sub_d_y - 1) - 1 / 2)
-            if water_plane:
-                z = water_level
-            else:
+            if not water_plane:
                 z = noise_gen((x, y, 0), props)
-
-            verts.append((x,y,z))
-
-    count = 0
-    for i in range (0, sub_d_y * (sub_d_x - 1)):
-        if count < sub_d_y - 1 :
-            A = i + 1
-            B = i
-            C = (i + sub_d_y)
-            D = (i + sub_d_y) + 1
-            if tri:
-                faces.append((A, B, D))
-                faces.append((B, C, D))
             else:
-                faces.append((A, B, C, D))
-            count = count + 1
-        else:
-            count = 0
+                z = water_level
+            vappend((x,y,z))
+
+            if i > 0 and j > 0:
+                A = i * sub_d_y + (j - 1)
+                B = i * sub_d_y + j
+                C = (i - 1) * sub_d_y + j
+                D = (i - 1) * sub_d_y + (j - 1)
+                if not tri:
+                    fappend((A, B, C, D))
+                else:
+                    fappend((A, B, D))
+                    fappend((B, C, D))
 
     return verts, faces
 
@@ -93,6 +89,8 @@ def grid_gen(sub_d_x, sub_d_y, tri, meshsize_x, meshsize_y, props, water_plane,
 def sphere_gen(sub_d_x, sub_d_y, tri, meshsize, props, water_plane, water_level):
     verts = []
     faces = []
+    vappend = verts.append
+    fappend = faces.append
     sub_d_x += 1
     sub_d_y += 1
     for i in range(0, sub_d_x):
@@ -104,7 +102,7 @@ def sphere_gen(sub_d_x, sub_d_y, tri, meshsize, props, water_plane, water_level)
                 h = water_level
             else:
                 h = noise_gen((u, v, w), props) / meshsize
-            verts.append(((u + u * h), (v + v * h), (w + w * h)))
+            vappend(((u + u * h), (v + v * h), (w + w * h)))
 
     count = 0
     for i in range (0, sub_d_y * (sub_d_x - 1)):
@@ -114,10 +112,10 @@ def sphere_gen(sub_d_x, sub_d_y, tri, meshsize, props, water_plane, water_level)
             C = (i + sub_d_y)
             D = (i + sub_d_y) + 1
             if tri:
-                faces.append((A, B, D))
-                faces.append((B, C, D))
+                fappend((A, B, D))
+                fappend((B, C, D))
             else:
-                faces.append((A, B, C, D))
+                fappend((A, B, C, D))
             count = count + 1
         else:
             count = 0
@@ -139,7 +137,6 @@ class AntLandscapeRefresh(bpy.types.Operator):
         ob = bpy.context.active_object
         return (ob.ant_landscape and not ob.ant_landscape['sphere_mesh'])
 
-
     def execute(self, context):
         # ant object items
         obj = bpy.context.active_object
diff --git a/ant_landscape/ant_noise.py b/ant_landscape/ant_noise.py
index c1ddda19..7d6b12e8 100644
--- a/ant_landscape/ant_noise.py
+++ b/ant_landscape/ant_noise.py
@@ -565,15 +565,15 @@ def noise_gen(coords, props):
         o_range = 1.0
     else:
         # Randomise origin
-        o_range = 10000.0
+        o_range = 100
         seed_set(rseed)
         origin = random_unit_vector()
         ox = (origin[0] * o_range)
         oy = (origin[1] * o_range)
-        oz = (origin[2] * o_range)
-        origin_x = (ox - (ox / 2)) + x_offset
-        origin_y = (oy - (oy / 2)) + y_offset
-        origin_z = (oz - (oz / 2)) + z_offset
+        oz = 0
+        origin_x = (ox - (ox * 0.5)) + x_offset
+        origin_y = (oy - (oy * 0.5)) + y_offset
+        origin_z = oz + z_offset
 
     ncoords = (x / (nsize * size_x) + origin_x, y / (nsize * size_y) + origin_y, z / (nsize * size_z) + origin_z)



More information about the Bf-extensions-cvs mailing list