diff options
author | Jimmy Haze <jimhazevoet@gmail.com> | 2020-05-07 03:44:18 +0300 |
---|---|---|
committer | meta-androcto <meta.androcto1@gmail.com> | 2020-05-07 03:44:18 +0300 |
commit | 0af9a7b3c440cb4ad039e791c7c3a1c248793c2e (patch) | |
tree | 436aef57cc4c8d5b2fe349b0370e8f9d2f8d5ee7 /ant_landscape | |
parent | c2f727ad650f79d1d416633d83a6f7f6c529d6f9 (diff) |
Fix T70357: ANT Landscape Line artifacts
Diffstat (limited to 'ant_landscape')
-rw-r--r-- | ant_landscape/ant_functions.py | 47 | ||||
-rw-r--r-- | ant_landscape/ant_noise.py | 10 |
2 files changed, 27 insertions, 30 deletions
diff --git a/ant_landscape/ant_functions.py b/ant_landscape/ant_functions.py index 3c3c2c71..47de9ef2 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) |