Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Haze <jimhazevoet@gmail.com>2020-05-07 03:44:18 +0300
committerNathan Letwory <nathan@blender.org>2020-06-03 11:54:29 +0300
commit7fd30539c69ce4aa3363e0d7c5e00ff4ca13886b (patch)
treef8369c767614ade82b1d56b1de14ca8b7ada94d9
parentd9dd9e0bb81776f3fdc4a917a3f1ed4759420075 (diff)
-rw-r--r--ant_landscape/ant_functions.py47
-rw-r--r--ant_landscape/ant_noise.py10
2 files changed, 27 insertions, 30 deletions
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)