Fix T70357: ANT Landscape Line artifacts

This commit is contained in:
Jimmy Hazevoet 2020-05-07 10:44:18 +10:00 committed by meta-androcto
parent c2f727ad65
commit 0af9a7b3c4
Notes: blender-bot 2023-02-14 19:07:43 +01:00
Referenced by issue #70357, A.N.T.Landscape line artifacts if seed is NOT 0
2 changed files with 27 additions and 30 deletions

View File

@ -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

View File

@ -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)