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:
authorCampbell Barton <ideasman42@gmail.com>2022-07-29 08:38:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2022-07-29 08:48:46 +0300
commit4e71e31be00e78942e5a3103911e4a3f878cb338 (patch)
tree2ac76ce81d9030f7017f286a77b6c77deb67e80f
parent8669c66177eab49871e9ae758c74da05cce89adf (diff)
Cleanup: run autopep8 on ant_landscape
-rw-r--r--ant_landscape/__init__.py726
-rw-r--r--ant_landscape/add_mesh_ant_landscape.py838
-rw-r--r--ant_landscape/ant_functions.py463
-rw-r--r--ant_landscape/ant_noise.py187
-rw-r--r--ant_landscape/eroder.py411
-rw-r--r--ant_landscape/mesh_ant_displace.py759
-rw-r--r--ant_landscape/stats.py7
-rw-r--r--ant_landscape/test.py2
-rw-r--r--ant_landscape/utils.py4
9 files changed, 1731 insertions, 1666 deletions
diff --git a/ant_landscape/__init__.py b/ant_landscape/__init__.py
index 295793b9..c330ad5e 100644
--- a/ant_landscape/__init__.py
+++ b/ant_landscape/__init__.py
@@ -30,23 +30,24 @@ else:
import bpy
from bpy.props import (
- BoolProperty,
- FloatProperty,
- IntProperty,
- StringProperty,
- PointerProperty,
- EnumProperty,
- )
+ BoolProperty,
+ FloatProperty,
+ IntProperty,
+ StringProperty,
+ PointerProperty,
+ EnumProperty,
+)
from .ant_functions import (
- draw_ant_refresh,
- draw_ant_main,
- draw_ant_noise,
- draw_ant_displace,
- )
+ draw_ant_refresh,
+ draw_ant_main,
+ draw_ant_noise,
+ draw_ant_displace,
+)
# ------------------------------------------------------------
# Menu's and panels
+
def menu_func_eroder(self, context):
ob = bpy.context.active_object
if ob and (ob.ant_landscape.keys() and not ob.ant_landscape['sphere_mesh']):
@@ -129,7 +130,7 @@ class AntMainSettingsPanel(bpy.types.Panel):
if ant.sphere_mesh:
split.prop(ant, "remove_double", toggle=True, text="Remove Doubles", icon='MESH_DATA')
box.prop(ant, "ant_terrain_name")
- box.prop_search(ant, "land_material", bpy.data, "materials")
+ box.prop_search(ant, "land_material", bpy.data, "materials")
col = box.column(align=True)
col.prop(ant, "subdivision_x")
col.prop(ant, "subdivision_y")
@@ -398,131 +399,131 @@ class AntDisplaceSettingsPanel(bpy.types.Panel):
class AntLandscapePropertiesGroup(bpy.types.PropertyGroup):
ant_terrain_name: StringProperty(
- name="Name",
- default="Landscape"
- )
+ name="Name",
+ default="Landscape"
+ )
land_material: StringProperty(
- name='Material',
- default="",
- description="Terrain material"
- )
+ name='Material',
+ default="",
+ description="Terrain material"
+ )
water_material: StringProperty(
- name='Material',
- default="",
- description="Water plane material"
- )
+ name='Material',
+ default="",
+ description="Water plane material"
+ )
texture_block: StringProperty(
- name="Texture",
- default=""
- )
+ name="Texture",
+ default=""
+ )
at_cursor: BoolProperty(
- name="Cursor",
- default=True,
- description="Place at cursor location",
- )
+ name="Cursor",
+ default=True,
+ description="Place at cursor location",
+ )
smooth_mesh: BoolProperty(
- name="Smooth",
- default=True,
- description="Shade smooth"
- )
+ name="Smooth",
+ default=True,
+ description="Shade smooth"
+ )
tri_face: BoolProperty(
- name="Triangulate",
- default=False,
- description="Triangulate faces"
- )
+ name="Triangulate",
+ default=False,
+ description="Triangulate faces"
+ )
sphere_mesh: BoolProperty(
- name="Sphere",
- default=False,
- description="Generate uv sphere - remove doubles when ready"
- )
+ name="Sphere",
+ default=False,
+ description="Generate uv sphere - remove doubles when ready"
+ )
subdivision_x: IntProperty(
- name="Subdivisions X",
- default=128,
- min=4,
- max=6400,
- description="Mesh X subdivisions"
- )
+ name="Subdivisions X",
+ default=128,
+ min=4,
+ max=6400,
+ description="Mesh X subdivisions"
+ )
subdivision_y: IntProperty(
- default=128,
- name="Subdivisions Y",
- min=4,
- max=6400,
- description="Mesh Y subdivisions"
- )
+ default=128,
+ name="Subdivisions Y",
+ min=4,
+ max=6400,
+ description="Mesh Y subdivisions"
+ )
mesh_size: FloatProperty(
- default=2.0,
- name="Mesh Size",
- min=0.01,
- max=100000.0,
- description="Mesh size"
- )
+ default=2.0,
+ name="Mesh Size",
+ min=0.01,
+ max=100000.0,
+ description="Mesh size"
+ )
mesh_size_x: FloatProperty(
- default=2.0,
- name="Mesh Size X",
- min=0.01,
- description="Mesh x size"
- )
+ default=2.0,
+ name="Mesh Size X",
+ min=0.01,
+ description="Mesh x size"
+ )
mesh_size_y: FloatProperty(
- name="Mesh Size Y",
- default=2.0,
- min=0.01,
- description="Mesh y size"
- )
+ name="Mesh Size Y",
+ default=2.0,
+ min=0.01,
+ description="Mesh y size"
+ )
random_seed: IntProperty(
- name="Random Seed",
- default=0,
- min=0,
- description="Randomize noise origin"
- )
+ name="Random Seed",
+ default=0,
+ min=0,
+ description="Randomize noise origin"
+ )
noise_offset_x: FloatProperty(
- name="Offset X",
- default=0.0,
- description="Noise X Offset"
- )
+ name="Offset X",
+ default=0.0,
+ description="Noise X Offset"
+ )
noise_offset_y: FloatProperty(
- name="Offset Y",
- default=0.0,
- description="Noise Y Offset"
- )
+ name="Offset Y",
+ default=0.0,
+ description="Noise Y Offset"
+ )
noise_offset_z: FloatProperty(
- name="Offset Z",
- default=0.0,
- description="Noise Z Offset"
- )
+ name="Offset Z",
+ default=0.0,
+ description="Noise Z Offset"
+ )
noise_size_x: FloatProperty(
- default=1.0,
- name="Size X",
- min=0.01,
- max=1000.0,
- description="Noise x size"
- )
+ default=1.0,
+ name="Size X",
+ min=0.01,
+ max=1000.0,
+ description="Noise x size"
+ )
noise_size_y: FloatProperty(
- name="Size Y",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Noise y size"
- )
+ name="Size Y",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Noise y size"
+ )
noise_size_z: FloatProperty(
- name="Size Z",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Noise Z size"
- )
+ name="Size Z",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Noise Z size"
+ )
noise_size: FloatProperty(
- name="Noise Size",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Noise size"
- )
+ name="Noise Size",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Noise size"
+ )
noise_type: EnumProperty(
- name="Noise Type",
- default='hetero_terrain',
- description="Noise type",
- items = [
+ name="Noise Type",
+ default='hetero_terrain',
+ description="Noise type",
+ items=[
('multi_fractal', "Multi Fractal", "Blender: Multi Fractal algorithm", 0),
('ridged_multi_fractal', "Ridged MFractal", "Blender: Ridged Multi Fractal", 1),
('hybrid_multi_fractal', "Hybrid MFractal", "Blender: Hybrid Multi Fractal", 2),
@@ -542,110 +543,110 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup):
('slick_rock', "Slick Rock", "A.N.T: slick rock", 16),
('planet_noise', "Planet Noise", "Planet Noise by: Farsthary", 17),
('blender_texture', "Blender Texture - Texture Nodes", "Blender texture data block", 18)]
- )
+ )
basis_type: EnumProperty(
- name="Noise Basis",
- default=ant_noise.noise_basis_default,
- description="Noise basis algorithms",
- items = ant_noise.noise_basis
- )
+ name="Noise Basis",
+ default=ant_noise.noise_basis_default,
+ description="Noise basis algorithms",
+ items=ant_noise.noise_basis
+ )
vl_basis_type: EnumProperty(
- name="vlNoise Basis",
- default=ant_noise.noise_basis_default,
- description="VLNoise basis algorithms",
- items = ant_noise.noise_basis
- )
+ name="vlNoise Basis",
+ default=ant_noise.noise_basis_default,
+ description="VLNoise basis algorithms",
+ items=ant_noise.noise_basis
+ )
distortion: FloatProperty(
- name="Distortion",
- default=1.0,
- min=0.01,
- max=100.0,
- description="Distortion amount"
- )
+ name="Distortion",
+ default=1.0,
+ min=0.01,
+ max=100.0,
+ description="Distortion amount"
+ )
hard_noise: EnumProperty(
- name="Soft Hard",
- default="0",
- description="Soft Noise, Hard noise",
- items = [
+ name="Soft Hard",
+ default="0",
+ description="Soft Noise, Hard noise",
+ items=[
("0", "Soft", "Soft Noise", 0),
("1", "Hard", "Hard noise", 1)]
- )
+ )
noise_depth: IntProperty(
- name="Depth",
- default=8,
- min=0,
- max=16,
- description="Noise Depth - number of frequencies in the fBm"
- )
+ name="Depth",
+ default=8,
+ min=0,
+ max=16,
+ description="Noise Depth - number of frequencies in the fBm"
+ )
amplitude: FloatProperty(
- name="Amp",
- default=0.5,
- min=0.01,
- max=1.0,
- description="Amplitude"
- )
+ name="Amp",
+ default=0.5,
+ min=0.01,
+ max=1.0,
+ description="Amplitude"
+ )
frequency: FloatProperty(
- name="Freq",
- default=2.0,
- min=0.01,
- max=5.0,
- description="Frequency"
- )
+ name="Freq",
+ default=2.0,
+ min=0.01,
+ max=5.0,
+ description="Frequency"
+ )
dimension: FloatProperty(
- name="Dimension",
- default=1.0,
- min=0.01,
- max=2.0,
- description="H - fractal dimension of the roughest areas"
- )
+ name="Dimension",
+ default=1.0,
+ min=0.01,
+ max=2.0,
+ description="H - fractal dimension of the roughest areas"
+ )
lacunarity: FloatProperty(
- name="Lacunarity",
- min=0.01,
- max=6.0,
- default=2.0,
- description="Lacunarity - gap between successive frequencies"
- )
+ name="Lacunarity",
+ min=0.01,
+ max=6.0,
+ default=2.0,
+ description="Lacunarity - gap between successive frequencies"
+ )
offset: FloatProperty(
- name="Offset",
- default=1.0,
- min=0.01,
- max=6.0,
- description="Offset - raises the terrain from sea level"
- )
+ name="Offset",
+ default=1.0,
+ min=0.01,
+ max=6.0,
+ description="Offset - raises the terrain from sea level"
+ )
gain: FloatProperty(
- name="Gain",
- default=1.0,
- min=0.01,
- max=6.0,
- description="Gain - scale factor"
- )
+ name="Gain",
+ default=1.0,
+ min=0.01,
+ max=6.0,
+ description="Gain - scale factor"
+ )
marble_bias: EnumProperty(
- name="Bias",
- default="0",
- description="Marble bias",
- items = [
+ name="Bias",
+ default="0",
+ description="Marble bias",
+ items=[
("0", "Sin", "Sin", 0),
("1", "Cos", "Cos", 1),
("2", "Tri", "Tri", 2),
("3", "Saw", "Saw", 3)]
- )
+ )
marble_sharp: EnumProperty(
- name="Sharp",
- default="0",
- description="Marble sharpness",
- items = [
+ name="Sharp",
+ default="0",
+ description="Marble sharpness",
+ items=[
("0", "Soft", "Soft", 0),
("1", "Sharp", "Sharp", 1),
("2", "Sharper", "Sharper", 2),
("3", "Soft inv.", "Soft", 3),
("4", "Sharp inv.", "Sharp", 4),
("5", "Sharper inv.", "Sharper", 5)]
- )
+ )
marble_shape: EnumProperty(
- name="Shape",
- default="0",
- description="Marble shape",
- items= [
+ name="Shape",
+ default="0",
+ description="Marble shape",
+ items=[
("0", "Default", "Default", 0),
("1", "Ring", "Ring", 1),
("2", "Swirl", "Swirl", 2),
@@ -654,38 +655,38 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup):
("5", "Z", "Z", 5),
("6", "Y", "Y", 6),
("7", "X", "X", 7)]
- )
+ )
height: FloatProperty(
- name="Height",
- default=0.5,
- min=-10000.0,
- max=10000.0,
- description="Noise intensity scale"
- )
+ name="Height",
+ default=0.5,
+ min=-10000.0,
+ max=10000.0,
+ description="Noise intensity scale"
+ )
height_invert: BoolProperty(
- name="Invert",
- default=False,
- description="Height invert",
- )
+ name="Invert",
+ default=False,
+ description="Height invert",
+ )
height_offset: FloatProperty(
- name="Offset",
- default=0.0,
- min=-10000.0,
- max=10000.0,
- description="Height offset"
- )
+ name="Offset",
+ default=0.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Height offset"
+ )
fx_mixfactor: FloatProperty(
- name="Mix Factor",
- default=0.0,
- min=-1.0,
- max=1.0,
- description="Effect mix factor: -1.0 = Noise, +1.0 = Effect"
- )
+ name="Mix Factor",
+ default=0.0,
+ min=-1.0,
+ max=1.0,
+ description="Effect mix factor: -1.0 = Noise, +1.0 = Effect"
+ )
fx_mix_mode: EnumProperty(
- name="Effect Mix",
- default="0",
- description="Effect mix mode",
- items = [
+ name="Effect Mix",
+ default="0",
+ description="Effect mix mode",
+ items=[
("0", "Mix", "Mix", 0),
("1", "Add", "Add", 1),
("2", "Sub", "Subtract", 2),
@@ -695,13 +696,13 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup):
("6", "Mod", "Modulo", 6),
("7", "Min", "Minimum", 7),
("8", "Max", "Maximum", 8)
- ]
- )
+ ]
+ )
fx_type: EnumProperty(
- name="Effect Type",
- default="0",
- description="Effect type",
- items = [
+ name="Effect Type",
+ default="0",
+ description="Effect type",
+ items=[
("0", "None", "No effect", 0),
("1", "Gradient", "Gradient", 1),
("2", "Waves", "Waves - Bumps", 2),
@@ -724,183 +725,184 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup):
("19", "Stone", "Stone", 19),
("20", "Flat Turb", "Flat turbulence", 20),
("21", "Flat Voronoi", "Flat voronoi", 21)
- ]
- )
+ ]
+ )
fx_bias: EnumProperty(
- name="Effect Bias",
- default="0",
- description="Effect bias type",
- items = [
+ name="Effect Bias",
+ default="0",
+ description="Effect bias type",
+ items=[
("0", "Sin", "Sin", 0),
("1", "Cos", "Cos", 1),
("2", "Tri", "Tri", 2),
("3", "Saw", "Saw", 3),
("4", "None", "None", 4)]
- )
+ )
fx_turb: FloatProperty(
- name="Distortion",
- default=0.0,
- min=0.0,
- max=1000.0,
- description="Effect turbulence distortion"
- )
+ name="Distortion",
+ default=0.0,
+ min=0.0,
+ max=1000.0,
+ description="Effect turbulence distortion"
+ )
fx_depth: IntProperty(
- name="Depth",
- default=0,
- min=0,
- max=16,
- description="Effect depth - number of frequencies"
- )
+ name="Depth",
+ default=0,
+ min=0,
+ max=16,
+ description="Effect depth - number of frequencies"
+ )
fx_amplitude: FloatProperty(
- name="Amp",
- default=0.5,
- min=0.01,
- max=1.0,
- description="Amplitude"
- )
+ name="Amp",
+ default=0.5,
+ min=0.01,
+ max=1.0,
+ description="Amplitude"
+ )
fx_frequency: FloatProperty(
- name="Freq",
- default=2.0,
- min=0.01,
- max=5.0,
- description="Frequency"
- )
+ name="Freq",
+ default=2.0,
+ min=0.01,
+ max=5.0,
+ description="Frequency"
+ )
fx_size: FloatProperty(
- name="Effect Size",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Effect size"
- )
+ name="Effect Size",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Effect size"
+ )
fx_loc_x: FloatProperty(
- name="Offset X",
- default=0.0,
- description="Effect x offset"
- )
+ name="Offset X",
+ default=0.0,
+ description="Effect x offset"
+ )
fx_loc_y: FloatProperty(
- name="Offset Y",
- default=0.0,
- description="Effect y offset"
- )
+ name="Offset Y",
+ default=0.0,
+ description="Effect y offset"
+ )
fx_height: FloatProperty(
- name="Intensity",
- default=1.0,
- min=-1000.0,
- max=1000.0,
- description="Effect intensity scale"
- )
+ name="Intensity",
+ default=1.0,
+ min=-1000.0,
+ max=1000.0,
+ description="Effect intensity scale"
+ )
fx_invert: BoolProperty(
- name="Invert",
- default=False,
- description="Effect invert"
- )
+ name="Invert",
+ default=False,
+ description="Effect invert"
+ )
fx_offset: FloatProperty(
- name="Offset",
- default=0.0,
- min=-1000.0,
- max=1000.0,
- description="Effect height offset"
- )
+ name="Offset",
+ default=0.0,
+ min=-1000.0,
+ max=1000.0,
+ description="Effect height offset"
+ )
edge_falloff: EnumProperty(
- name="Falloff",
- default="3",
- description="Flatten edges",
- items = [
+ name="Falloff",
+ default="3",
+ description="Flatten edges",
+ items=[
("0", "None", "None", 0),
("1", "Y", "Y Falloff", 1),
("2", "X", "X Falloff", 2),
("3", "X Y", "X Y Falloff", 3)]
- )
+ )
falloff_x: FloatProperty(
- name="Falloff X",
- default=4.0,
- min=0.1,
- max=100.0,
- description="Falloff x scale"
- )
+ name="Falloff X",
+ default=4.0,
+ min=0.1,
+ max=100.0,
+ description="Falloff x scale"
+ )
falloff_y: FloatProperty(
- name="Falloff Y",
- default=4.0,
- min=0.1,
- max=100.0,
- description="Falloff y scale"
- )
+ name="Falloff Y",
+ default=4.0,
+ min=0.1,
+ max=100.0,
+ description="Falloff y scale"
+ )
edge_level: FloatProperty(
- name="Edge Level",
- default=0.0,
- min=-10000.0,
- max=10000.0,
- description="Edge level, sealevel offset"
- )
+ name="Edge Level",
+ default=0.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Edge level, sealevel offset"
+ )
maximum: FloatProperty(
- name="Maximum",
- default=1.0,
- min=-10000.0,
- max=10000.0,
- description="Maximum, flattens terrain at plateau level"
- )
+ name="Maximum",
+ default=1.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Maximum, flattens terrain at plateau level"
+ )
minimum: FloatProperty(
- name="Minimum",
- default=-1.0,
- min=-10000.0,
- max=10000.0,
- description="Minimum, flattens terrain at seabed level"
- )
+ name="Minimum",
+ default=-1.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Minimum, flattens terrain at seabed level"
+ )
vert_group: StringProperty(
- name="Vertex Group",
- default=""
- )
+ name="Vertex Group",
+ default=""
+ )
strata: FloatProperty(
- name="Amount",
- default=5.0,
- min=0.01,
- max=1000.0,
- description="Strata layers / terraces"
- )
+ name="Amount",
+ default=5.0,
+ min=0.01,
+ max=1000.0,
+ description="Strata layers / terraces"
+ )
strata_type: EnumProperty(
- name="Strata",
- default="0",
- description="Strata types",
- items = [
+ name="Strata",
+ default="0",
+ description="Strata types",
+ items=[
("0", "None", "No strata", 0),
("1", "Smooth", "Smooth transitions", 1),
("2", "Sharp Sub", "Sharp subtract transitions", 2),
("3", "Sharp Add", "Sharp add transitions", 3),
("4", "Quantize", "Quantize", 4),
("5", "Quantize Mix", "Quantize mixed", 5)]
- )
+ )
water_plane: BoolProperty(
- name="Water Plane",
- default=False,
- description="Add water plane"
- )
+ name="Water Plane",
+ default=False,
+ description="Add water plane"
+ )
water_level: FloatProperty(
- name="Level",
- default=0.01,
- min=-10000.0,
- max=10000.0,
- description="Water level"
- )
+ name="Level",
+ default=0.01,
+ min=-10000.0,
+ max=10000.0,
+ description="Water level"
+ )
remove_double: BoolProperty(
- name="Remove Doubles",
- default=False,
- description="Remove doubles"
- )
+ name="Remove Doubles",
+ default=False,
+ description="Remove doubles"
+ )
refresh: BoolProperty(
- name="Refresh",
- default=False,
- description="Refresh"
- )
+ name="Refresh",
+ default=False,
+ description="Refresh"
+ )
auto_refresh: BoolProperty(
- name="Auto",
- default=True,
- description="Automatic refresh"
- )
+ name="Auto",
+ default=True,
+ description="Automatic refresh"
+ )
# ------------------------------------------------------------
# Register:
+
classes = (
AntLandscapeAddPanel,
AntLandscapeToolsPanel,
@@ -916,12 +918,16 @@ classes = (
ant_functions.Eroder,
)
+
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.VIEW3D_MT_mesh_add.append(menu_func_landscape)
- bpy.types.Object.ant_landscape = PointerProperty(type=AntLandscapePropertiesGroup, name="ANT_Landscape", description="Landscape properties")
+ bpy.types.Object.ant_landscape = PointerProperty(
+ type=AntLandscapePropertiesGroup,
+ name="ANT_Landscape",
+ description="Landscape properties")
bpy.types.VIEW3D_MT_paint_weight.append(menu_func_eroder)
diff --git a/ant_landscape/add_mesh_ant_landscape.py b/ant_landscape/add_mesh_ant_landscape.py
index a148f448..e12561bc 100644
--- a/ant_landscape/add_mesh_ant_landscape.py
+++ b/ant_landscape/add_mesh_ant_landscape.py
@@ -6,30 +6,32 @@
# import modules
import bpy
from bpy.props import (
- BoolProperty,
- EnumProperty,
- FloatProperty,
- IntProperty,
- StringProperty,
- FloatVectorProperty,
- )
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ IntProperty,
+ StringProperty,
+ FloatVectorProperty,
+)
from .ant_functions import (
- grid_gen,
- sphere_gen,
- create_mesh_object,
- store_properties,
- draw_ant_refresh,
- draw_ant_main,
- draw_ant_noise,
- draw_ant_displace,
- draw_ant_water,
- )
+ grid_gen,
+ sphere_gen,
+ create_mesh_object,
+ store_properties,
+ draw_ant_refresh,
+ draw_ant_main,
+ draw_ant_noise,
+ draw_ant_displace,
+ draw_ant_water,
+)
from ant_landscape import ant_noise
# ------------------------------------------------------------
# Add landscape
+
+
class AntAddLandscape(bpy.types.Operator):
bl_idname = "mesh.landscape_add"
bl_label = "Another Noise Tool - Landscape"
@@ -37,131 +39,131 @@ class AntAddLandscape(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
ant_terrain_name: StringProperty(
- name="Name",
- default="Landscape"
- )
+ name="Name",
+ default="Landscape"
+ )
land_material: StringProperty(
- name='Material',
- default="",
- description="Terrain material"
- )
+ name='Material',
+ default="",
+ description="Terrain material"
+ )
water_material: StringProperty(
- name='Material',
- default="",
- description="Water plane material"
- )
+ name='Material',
+ default="",
+ description="Water plane material"
+ )
texture_block: StringProperty(
- name="Texture",
- default=""
- )
+ name="Texture",
+ default=""
+ )
at_cursor: BoolProperty(
- name="Cursor",
- default=True,
- description="Place at cursor location",
- )
+ name="Cursor",
+ default=True,
+ description="Place at cursor location",
+ )
smooth_mesh: BoolProperty(
- name="Smooth",
- default=True,
- description="Shade smooth"
- )
+ name="Smooth",
+ default=True,
+ description="Shade smooth"
+ )
tri_face: BoolProperty(
- name="Triangulate",
- default=False,
- description="Triangulate faces"
- )
+ name="Triangulate",
+ default=False,
+ description="Triangulate faces"
+ )
sphere_mesh: BoolProperty(
- name="Sphere",
- default=False,
- description="Generate uv sphere - remove doubles when ready"
- )
+ name="Sphere",
+ default=False,
+ description="Generate uv sphere - remove doubles when ready"
+ )
subdivision_x: IntProperty(
- name="Subdivisions X",
- default=128,
- min=4,
- max=6400,
- description="Mesh X subdivisions"
- )
+ name="Subdivisions X",
+ default=128,
+ min=4,
+ max=6400,
+ description="Mesh X subdivisions"
+ )
subdivision_y: IntProperty(
- default=128,
- name="Subdivisions Y",
- min=4,
- max=6400,
- description="Mesh Y subdivisions"
- )
+ default=128,
+ name="Subdivisions Y",
+ min=4,
+ max=6400,
+ description="Mesh Y subdivisions"
+ )
mesh_size: FloatProperty(
- default=2.0,
- name="Mesh Size",
- min=0.01,
- max=100000.0,
- description="Mesh size"
- )
+ default=2.0,
+ name="Mesh Size",
+ min=0.01,
+ max=100000.0,
+ description="Mesh size"
+ )
mesh_size_x: FloatProperty(
- default=2.0,
- name="Mesh Size X",
- min=0.01,
- description="Mesh x size"
- )
+ default=2.0,
+ name="Mesh Size X",
+ min=0.01,
+ description="Mesh x size"
+ )
mesh_size_y: FloatProperty(
- name="Mesh Size Y",
- default=2.0,
- min=0.01,
- description="Mesh y size"
- )
+ name="Mesh Size Y",
+ default=2.0,
+ min=0.01,
+ description="Mesh y size"
+ )
random_seed: IntProperty(
- name="Random Seed",
- default=0,
- min=0,
- description="Randomize noise origin"
- )
+ name="Random Seed",
+ default=0,
+ min=0,
+ description="Randomize noise origin"
+ )
noise_offset_x: FloatProperty(
- name="Offset X",
- default=0.0,
- description="Noise X Offset"
- )
+ name="Offset X",
+ default=0.0,
+ description="Noise X Offset"
+ )
noise_offset_y: FloatProperty(
- name="Offset Y",
- default=0.0,
- description="Noise Y Offset"
- )
+ name="Offset Y",
+ default=0.0,
+ description="Noise Y Offset"
+ )
noise_offset_z: FloatProperty(
- name="Offset Z",
- default=0.0,
- description="Noise Z Offset"
- )
+ name="Offset Z",
+ default=0.0,
+ description="Noise Z Offset"
+ )
noise_size_x: FloatProperty(
- default=1.0,
- name="Size X",
- min=0.01,
- max=1000.0,
- description="Noise x size"
- )
+ default=1.0,
+ name="Size X",
+ min=0.01,
+ max=1000.0,
+ description="Noise x size"
+ )
noise_size_y: FloatProperty(
- name="Size Y",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Noise y size"
- )
+ name="Size Y",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Noise y size"
+ )
noise_size_z: FloatProperty(
- name="Size Z",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Noise Z size"
- )
+ name="Size Z",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Noise Z size"
+ )
noise_size: FloatProperty(
- name="Noise Size",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Noise size"
- )
+ name="Noise Size",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Noise size"
+ )
noise_type: EnumProperty(
- name="Noise Type",
- default='hetero_terrain',
- description="Noise type",
- items = [
+ name="Noise Type",
+ default='hetero_terrain',
+ description="Noise type",
+ items=[
('multi_fractal', "Multi Fractal", "Blender: Multi Fractal algorithm", 0),
('ridged_multi_fractal', "Ridged MFractal", "Blender: Ridged Multi Fractal", 1),
('hybrid_multi_fractal', "Hybrid MFractal", "Blender: Hybrid Multi Fractal", 2),
@@ -181,110 +183,110 @@ class AntAddLandscape(bpy.types.Operator):
('slick_rock', "Slick Rock", "A.N.T: slick rock", 16),
('planet_noise', "Planet Noise", "Planet Noise by: Farsthary", 17),
('blender_texture', "Blender Texture - Texture Nodes", "Blender texture data block", 18)]
- )
+ )
basis_type: EnumProperty(
- name="Noise Basis",
- default=ant_noise.noise_basis_default,
- description="Noise basis algorithms",
- items = ant_noise.noise_basis
- )
+ name="Noise Basis",
+ default=ant_noise.noise_basis_default,
+ description="Noise basis algorithms",
+ items=ant_noise.noise_basis
+ )
vl_basis_type: EnumProperty(
- name="vlNoise Basis",
- default=ant_noise.noise_basis_default,
- description="VLNoise basis algorithms",
- items = ant_noise.noise_basis
- )
+ name="vlNoise Basis",
+ default=ant_noise.noise_basis_default,
+ description="VLNoise basis algorithms",
+ items=ant_noise.noise_basis
+ )
distortion: FloatProperty(
- name="Distortion",
- default=1.0,
- min=0.01,
- max=100.0,
- description="Distortion amount"
- )
+ name="Distortion",
+ default=1.0,
+ min=0.01,
+ max=100.0,
+ description="Distortion amount"
+ )
hard_noise: EnumProperty(
- name="Soft Hard",
- default="0",
- description="Soft Noise, Hard noise",
- items = [
+ name="Soft Hard",
+ default="0",
+ description="Soft Noise, Hard noise",
+ items=[
("0", "Soft", "Soft Noise", 0),
("1", "Hard", "Hard noise", 1)]
- )
+ )
noise_depth: IntProperty(
- name="Depth",
- default=8,
- min=0,
- max=16,
- description="Noise Depth - number of frequencies in the fBm"
- )
+ name="Depth",
+ default=8,
+ min=0,
+ max=16,
+ description="Noise Depth - number of frequencies in the fBm"
+ )
amplitude: FloatProperty(
- name="Amp",
- default=0.5,
- min=0.01,
- max=1.0,
- description="Amplitude"
- )
+ name="Amp",
+ default=0.5,
+ min=0.01,
+ max=1.0,
+ description="Amplitude"
+ )
frequency: FloatProperty(
- name="Freq",
- default=2.0,
- min=0.01,
- max=5.0,
- description="Frequency"
- )
+ name="Freq",
+ default=2.0,
+ min=0.01,
+ max=5.0,
+ description="Frequency"
+ )
dimension: FloatProperty(
- name="Dimension",
- default=1.0,
- min=0.01,
- max=2.0,
- description="H - fractal dimension of the roughest areas"
- )
+ name="Dimension",
+ default=1.0,
+ min=0.01,
+ max=2.0,
+ description="H - fractal dimension of the roughest areas"
+ )
lacunarity: FloatProperty(
- name="Lacunarity",
- min=0.01,
- max=6.0,
- default=2.0,
- description="Lacunarity - gap between successive frequencies"
- )
+ name="Lacunarity",
+ min=0.01,
+ max=6.0,
+ default=2.0,
+ description="Lacunarity - gap between successive frequencies"
+ )
offset: FloatProperty(
- name="Offset",
- default=1.0,
- min=0.01,
- max=6.0,
- description="Offset - raises the terrain from sea level"
- )
+ name="Offset",
+ default=1.0,
+ min=0.01,
+ max=6.0,
+ description="Offset - raises the terrain from sea level"
+ )
gain: FloatProperty(
- name="Gain",
- default=1.0,
- min=0.01,
- max=6.0,
- description="Gain - scale factor"
- )
+ name="Gain",
+ default=1.0,
+ min=0.01,
+ max=6.0,
+ description="Gain - scale factor"
+ )
marble_bias: EnumProperty(
- name="Bias",
- default="0",
- description="Marble bias",
- items = [
+ name="Bias",
+ default="0",
+ description="Marble bias",
+ items=[
("0", "Sin", "Sin", 0),
("1", "Cos", "Cos", 1),
("2", "Tri", "Tri", 2),
("3", "Saw", "Saw", 3)]
- )
+ )
marble_sharp: EnumProperty(
- name="Sharp",
- default="0",
- description="Marble sharpness",
- items = [
+ name="Sharp",
+ default="0",
+ description="Marble sharpness",
+ items=[
("0", "Soft", "Soft", 0),
("1", "Sharp", "Sharp", 1),
("2", "Sharper", "Sharper", 2),
("3", "Soft inv.", "Soft", 3),
("4", "Sharp inv.", "Sharp", 4),
("5", "Sharper inv.", "Sharper", 5)]
- )
+ )
marble_shape: EnumProperty(
- name="Shape",
- default="0",
- description="Marble shape",
- items= [
+ name="Shape",
+ default="0",
+ description="Marble shape",
+ items=[
("0", "Default", "Default", 0),
("1", "Ring", "Ring", 1),
("2", "Swirl", "Swirl", 2),
@@ -293,38 +295,38 @@ class AntAddLandscape(bpy.types.Operator):
("5", "Z", "Z", 5),
("6", "Y", "Y", 6),
("7", "X", "X", 7)]
- )
+ )
height: FloatProperty(
- name="Height",
- default=0.5,
- min=-10000.0,
- max=10000.0,
- description="Noise intensity scale"
- )
+ name="Height",
+ default=0.5,
+ min=-10000.0,
+ max=10000.0,
+ description="Noise intensity scale"
+ )
height_invert: BoolProperty(
- name="Invert",
- default=False,
- description="Height invert",
- )
+ name="Invert",
+ default=False,
+ description="Height invert",
+ )
height_offset: FloatProperty(
- name="Offset",
- default=0.0,
- min=-10000.0,
- max=10000.0,
- description="Height offset"
- )
+ name="Offset",
+ default=0.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Height offset"
+ )
fx_mixfactor: FloatProperty(
- name="Mix Factor",
- default=0.0,
- min=-1.0,
- max=1.0,
- description="Effect mix factor: -1.0 = Noise, +1.0 = Effect"
- )
+ name="Mix Factor",
+ default=0.0,
+ min=-1.0,
+ max=1.0,
+ description="Effect mix factor: -1.0 = Noise, +1.0 = Effect"
+ )
fx_mix_mode: EnumProperty(
- name="Effect Mix",
- default="0",
- description="Effect mix mode",
- items = [
+ name="Effect Mix",
+ default="0",
+ description="Effect mix mode",
+ items=[
("0", "Mix", "Mix", 0),
("1", "Add", "Add", 1),
("2", "Sub", "Subtract", 2),
@@ -334,13 +336,13 @@ class AntAddLandscape(bpy.types.Operator):
("6", "Mod", "Modulo", 6),
("7", "Min", "Minimum", 7),
("8", "Max", "Maximum", 8)
- ]
- )
+ ]
+ )
fx_type: EnumProperty(
- name="Effect Type",
- default="0",
- description="Effect type",
- items = [
+ name="Effect Type",
+ default="0",
+ description="Effect type",
+ items=[
("0", "None", "No effect", 0),
("1", "Gradient", "Gradient", 1),
("2", "Waves", "Waves - Bumps", 2),
@@ -363,194 +365,194 @@ class AntAddLandscape(bpy.types.Operator):
("19", "Stone", "Stone", 19),
("20", "Flat Turb", "Flat turbulence", 20),
("21", "Flat Voronoi", "Flat voronoi", 21)
- ]
- )
+ ]
+ )
fx_bias: EnumProperty(
- name="Effect Bias",
- default="0",
- description="Effect bias type",
- items = [
+ name="Effect Bias",
+ default="0",
+ description="Effect bias type",
+ items=[
("0", "Sin", "Sin", 0),
("1", "Cos", "Cos", 1),
("2", "Tri", "Tri", 2),
("3", "Saw", "Saw", 3),
("4", "None", "None", 4)]
- )
+ )
fx_turb: FloatProperty(
- name="Distortion",
- default=0.0,
- min=0.0,
- max=1000.0,
- description="Effect turbulence distortion"
- )
+ name="Distortion",
+ default=0.0,
+ min=0.0,
+ max=1000.0,
+ description="Effect turbulence distortion"
+ )
fx_depth: IntProperty(
- name="Depth",
- default=0,
- min=0,
- max=16,
- description="Effect depth - number of frequencies"
- )
+ name="Depth",
+ default=0,
+ min=0,
+ max=16,
+ description="Effect depth - number of frequencies"
+ )
fx_amplitude: FloatProperty(
- name="Amp",
- default=0.5,
- min=0.01,
- max=1.0,
- description="Amplitude"
- )
+ name="Amp",
+ default=0.5,
+ min=0.01,
+ max=1.0,
+ description="Amplitude"
+ )
fx_frequency: FloatProperty(
- name="Freq",
- default=2.0,
- min=0.01,
- max=5.0,
- description="Frequency"
- )
+ name="Freq",
+ default=2.0,
+ min=0.01,
+ max=5.0,
+ description="Frequency"
+ )
fx_size: FloatProperty(
- name="Effect Size",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Effect size"
- )
+ name="Effect Size",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Effect size"
+ )
fx_loc_x: FloatProperty(
- name="Offset X",
- default=0.0,
- description="Effect x offset"
- )
+ name="Offset X",
+ default=0.0,
+ description="Effect x offset"
+ )
fx_loc_y: FloatProperty(
- name="Offset Y",
- default=0.0,
- description="Effect y offset"
- )
+ name="Offset Y",
+ default=0.0,
+ description="Effect y offset"
+ )
fx_height: FloatProperty(
- name="Intensity",
- default=1.0,
- min=-1000.0,
- max=1000.0,
- description="Effect intensity scale"
- )
+ name="Intensity",
+ default=1.0,
+ min=-1000.0,
+ max=1000.0,
+ description="Effect intensity scale"
+ )
fx_invert: BoolProperty(
- name="Invert",
- default=False,
- description="Effect invert"
- )
+ name="Invert",
+ default=False,
+ description="Effect invert"
+ )
fx_offset: FloatProperty(
- name="Offset",
- default=0.0,
- min=-1000.0,
- max=1000.0,
- description="Effect height offset"
- )
+ name="Offset",
+ default=0.0,
+ min=-1000.0,
+ max=1000.0,
+ description="Effect height offset"
+ )
edge_falloff: EnumProperty(
- name="Falloff",
- default="3",
- description="Flatten edges",
- items = [
+ name="Falloff",
+ default="3",
+ description="Flatten edges",
+ items=[
("0", "None", "None", 0),
("1", "Y", "Y Falloff", 1),
("2", "X", "X Falloff", 2),
("3", "X Y", "X Y Falloff", 3)]
- )
+ )
falloff_x: FloatProperty(
- name="Falloff X",
- default=4.0,
- min=0.1,
- max=100.0,
- description="Falloff x scale"
- )
+ name="Falloff X",
+ default=4.0,
+ min=0.1,
+ max=100.0,
+ description="Falloff x scale"
+ )
falloff_y: FloatProperty(
- name="Falloff Y",
- default=4.0,
- min=0.1,
- max=100.0,
- description="Falloff y scale"
- )
+ name="Falloff Y",
+ default=4.0,
+ min=0.1,
+ max=100.0,
+ description="Falloff y scale"
+ )
edge_level: FloatProperty(
- name="Edge Level",
- default=0.0,
- min=-10000.0,
- max=10000.0,
- description="Edge level, sealevel offset"
- )
+ name="Edge Level",
+ default=0.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Edge level, sealevel offset"
+ )
maximum: FloatProperty(
- name="Maximum",
- default=1.0,
- min=-10000.0,
- max=10000.0,
- description="Maximum, flattens terrain at plateau level"
- )
+ name="Maximum",
+ default=1.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Maximum, flattens terrain at plateau level"
+ )
minimum: FloatProperty(
- name="Minimum",
- default=-1.0,
- min=-10000.0,
- max=10000.0,
- description="Minimum, flattens terrain at seabed level"
- )
+ name="Minimum",
+ default=-1.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Minimum, flattens terrain at seabed level"
+ )
vert_group: StringProperty(
- name="Vertex Group",
- default=""
- )
+ name="Vertex Group",
+ default=""
+ )
strata: FloatProperty(
- name="Amount",
- default=5.0,
- min=0.01,
- max=1000.0,
- description="Strata layers / terraces"
- )
+ name="Amount",
+ default=5.0,
+ min=0.01,
+ max=1000.0,
+ description="Strata layers / terraces"
+ )
strata_type: EnumProperty(
- name="Strata",
- default="0",
- description="Strata types",
- items = [
+ name="Strata",
+ default="0",
+ description="Strata types",
+ items=[
("0", "None", "No strata", 0),
("1", "Smooth", "Smooth transitions", 1),
("2", "Sharp Sub", "Sharp subtract transitions", 2),
("3", "Sharp Add", "Sharp add transitions", 3),
("4", "Quantize", "Quantize", 4),
("5", "Quantize Mix", "Quantize mixed", 5)]
- )
+ )
water_plane: BoolProperty(
- name="Water Plane",
- default=False,
- description="Add water plane"
- )
+ name="Water Plane",
+ default=False,
+ description="Add water plane"
+ )
water_level: FloatProperty(
- name="Level",
- default=0.01,
- min=-10000.0,
- max=10000.0,
- description="Water level"
- )
+ name="Level",
+ default=0.01,
+ min=-10000.0,
+ max=10000.0,
+ description="Water level"
+ )
remove_double: BoolProperty(
- name="Remove Doubles",
- default=False,
- description="Remove doubles"
- )
+ name="Remove Doubles",
+ default=False,
+ description="Remove doubles"
+ )
show_main_settings: BoolProperty(
- name="Main Settings",
- default=True,
- description="Show settings"
- )
+ name="Main Settings",
+ default=True,
+ description="Show settings"
+ )
show_noise_settings: BoolProperty(
- name="Noise Settings",
- default=True,
- description="Show noise settings"
- )
+ name="Noise Settings",
+ default=True,
+ description="Show noise settings"
+ )
show_displace_settings: BoolProperty(
- name="Displace Settings",
- default=True,
- description="Show displace settings"
- )
+ name="Displace Settings",
+ default=True,
+ description="Show displace settings"
+ )
refresh: BoolProperty(
- name="Refresh",
- default=False,
- description="Refresh"
- )
+ name="Refresh",
+ default=False,
+ description="Refresh"
+ )
auto_refresh: BoolProperty(
- name="Auto",
- default=True,
- description="Automatic refresh"
- )
+ name="Auto",
+ default=True,
+ description="Automatic refresh"
+ )
@classmethod
def poll(self, context):
@@ -567,12 +569,10 @@ class AntAddLandscape(bpy.types.Operator):
draw_ant_displace(self, context, generate=True)
draw_ant_water(self, context)
-
def invoke(self, context, event):
self.refresh = True
return self.execute(context)
-
def execute(self, context):
if not self.refresh:
return {'PASS_THROUGH'}
@@ -652,7 +652,7 @@ class AntAddLandscape(bpy.types.Operator):
self.fx_height,
self.fx_offset,
self.fx_invert
- ]
+ ]
scene = context.scene
vl = context.view_layer
@@ -661,37 +661,37 @@ class AntAddLandscape(bpy.types.Operator):
if self.ant_terrain_name != "":
new_name = self.ant_terrain_name
else:
- new_name = "Landscape"
+ new_name = "Landscape"
if self.sphere_mesh:
# sphere
verts, faces = sphere_gen(
- self.subdivision_y,
- self.subdivision_x,
- self.tri_face,
- self.mesh_size,
- ant_props,
- False,
- 0.0
- )
+ self.subdivision_y,
+ self.subdivision_x,
+ self.tri_face,
+ self.mesh_size,
+ ant_props,
+ False,
+ 0.0,
+ )
new_ob = create_mesh_object(context, verts, [], faces, new_name)
if self.remove_double:
new_ob.select_set(True)
- bpy.ops.object.mode_set(mode = 'EDIT')
+ bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False)
- bpy.ops.object.mode_set(mode = 'OBJECT')
+ bpy.ops.object.mode_set(mode='OBJECT')
else:
# grid
verts, faces = grid_gen(
- self.subdivision_x,
- self.subdivision_y,
- self.tri_face,
- self.mesh_size_x,
- self.mesh_size_y,
- ant_props,
- False,
- 0.0
- )
+ self.subdivision_x,
+ self.subdivision_y,
+ self.tri_face,
+ self.mesh_size_x,
+ self.mesh_size_y,
+ ant_props,
+ False,
+ 0.0,
+ )
new_ob = create_mesh_object(context, verts, [], faces, new_name)
new_ob.select_set(True)
@@ -712,33 +712,33 @@ class AntAddLandscape(bpy.types.Operator):
if self.sphere_mesh:
# sphere
verts, faces = sphere_gen(
- self.subdivision_y,
- self.subdivision_x,
- self.tri_face,
- self.mesh_size,
- ant_props,
- self.water_plane,
- self.water_level
- )
- wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane")
+ self.subdivision_y,
+ self.subdivision_x,
+ self.tri_face,
+ self.mesh_size,
+ ant_props,
+ self.water_plane,
+ self.water_level,
+ )
+ wobj = create_mesh_object(context, verts, [], faces, new_name + "_plane")
if self.remove_double:
wobj.select_set(True)
- bpy.ops.object.mode_set(mode = 'EDIT')
+ bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False)
- bpy.ops.object.mode_set(mode = 'OBJECT')
+ bpy.ops.object.mode_set(mode='OBJECT')
else:
# grid
verts, faces = grid_gen(
- 2,
- 2,
- self.tri_face,
- self.mesh_size_x,
- self.mesh_size_y,
- ant_props,
- self.water_plane,
- self.water_level
- )
- wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane")
+ 2,
+ 2,
+ self.tri_face,
+ self.mesh_size_x,
+ self.mesh_size_y,
+ ant_props,
+ self.water_plane,
+ self.water_level,
+ )
+ wobj = create_mesh_object(context, verts, [], faces, new_name + "_plane")
wobj.select_set(True)
diff --git a/ant_landscape/ant_functions.py b/ant_landscape/ant_functions.py
index 77bb5c83..1337533c 100644
--- a/ant_landscape/ant_functions.py
+++ b/ant_landscape/ant_functions.py
@@ -9,16 +9,16 @@
# import modules
import bpy
from bpy.props import (
- BoolProperty,
- FloatProperty,
- StringProperty,
- EnumProperty,
- IntProperty,
- PointerProperty,
- )
+ BoolProperty,
+ FloatProperty,
+ StringProperty,
+ EnumProperty,
+ IntProperty,
+ PointerProperty,
+)
from math import (
- sin, cos, pi,
- )
+ sin, cos, pi,
+)
from .ant_noise import noise_gen
# ------------------------------------------------------------
@@ -29,6 +29,7 @@ from .ant_noise import noise_gen
from bpy_extras import object_utils
+
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
mesh = bpy.data.meshes.new(name)
@@ -45,7 +46,7 @@ def grid_gen(sub_d_x, sub_d_y, tri, meshsize_x, meshsize_y, props, water_plane,
faces = []
vappend = verts.append
fappend = faces.append
- for i in range (0, sub_d_x):
+ 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)
@@ -53,7 +54,7 @@ def grid_gen(sub_d_x, sub_d_y, tri, meshsize_x, meshsize_y, props, water_plane,
z = noise_gen((x, y, 0), props)
else:
z = water_level
- vappend((x,y,z))
+ vappend((x, y, z))
if i > 0 and j > 0:
A = i * sub_d_y + (j - 1)
@@ -89,8 +90,8 @@ def sphere_gen(sub_d_x, sub_d_y, tri, meshsize, props, water_plane, water_level)
vappend(((u + u * h), (v + v * h), (w + w * h)))
count = 0
- for i in range (0, sub_d_y * (sub_d_x - 1)):
- if count < sub_d_y - 1 :
+ 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)
@@ -115,7 +116,6 @@ class AntLandscapeRefresh(bpy.types.Operator):
bl_description = "Refresh landscape with current settings"
bl_options = {'REGISTER', 'UNDO'}
-
@classmethod
def poll(cls, context):
ob = bpy.context.active_object
@@ -125,8 +125,8 @@ class AntLandscapeRefresh(bpy.types.Operator):
# ant object items
obj = bpy.context.active_object
- bpy.ops.object.mode_set(mode = 'EDIT')
- bpy.ops.object.mode_set(mode = 'OBJECT')
+ bpy.ops.object.mode_set(mode='EDIT')
+ bpy.ops.object.mode_set(mode='OBJECT')
keys = obj.ant_landscape.keys()
if keys:
@@ -158,13 +158,14 @@ class AntLandscapeRefresh(bpy.types.Operator):
# ------------------------------------------------------------
# Do regenerate
+
+
class AntLandscapeRegenerate(bpy.types.Operator):
bl_idname = "mesh.ant_landscape_regenerate"
bl_label = "Regenerate"
bl_description = "Regenerate landscape with current settings"
bl_options = {'REGISTER', 'UNDO'}
-
@classmethod
def poll(cls, context):
ob = bpy.context.active_object
@@ -172,7 +173,6 @@ class AntLandscapeRegenerate(bpy.types.Operator):
return False
return ob.ant_landscape
-
def execute(self, context):
view_layer = bpy.context.view_layer
@@ -192,32 +192,32 @@ class AntLandscapeRegenerate(bpy.types.Operator):
if ob['sphere_mesh']:
# sphere
verts, faces = sphere_gen(
- ob['subdivision_y'],
- ob['subdivision_x'],
- ob['tri_face'],
- ob['mesh_size'],
- ant_props,
- False,
- 0.0
- )
+ ob['subdivision_y'],
+ ob['subdivision_x'],
+ ob['tri_face'],
+ ob['mesh_size'],
+ ant_props,
+ False,
+ 0.0,
+ )
new_ob = create_mesh_object(context, verts, [], faces, new_name)
if ob['remove_double']:
new_ob.select_set(True)
- bpy.ops.object.mode_set(mode = 'EDIT')
+ bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False)
- bpy.ops.object.mode_set(mode = 'OBJECT')
+ bpy.ops.object.mode_set(mode='OBJECT')
else:
# grid
verts, faces = grid_gen(
- ob['subdivision_x'],
- ob['subdivision_y'],
- ob['tri_face'],
- ob['mesh_size_x'],
- ob['mesh_size_y'],
- ant_props,
- False,
- 0.0
- )
+ ob['subdivision_x'],
+ ob['subdivision_y'],
+ ob['tri_face'],
+ ob['mesh_size_x'],
+ ob['mesh_size_y'],
+ ant_props,
+ False,
+ 0.0,
+ )
new_ob = create_mesh_object(context, verts, [], faces, new_name)
new_ob.select_set(True)
@@ -235,33 +235,33 @@ class AntLandscapeRegenerate(bpy.types.Operator):
if ob['sphere_mesh']:
# sphere
verts, faces = sphere_gen(
- ob['subdivision_y'],
- ob['subdivision_x'],
- ob['tri_face'],
- ob['mesh_size'],
- ant_props,
- ob['water_plane'],
- ob['water_level']
- )
- wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane")
+ ob['subdivision_y'],
+ ob['subdivision_x'],
+ ob['tri_face'],
+ ob['mesh_size'],
+ ant_props,
+ ob['water_plane'],
+ ob['water_level'],
+ )
+ wobj = create_mesh_object(context, verts, [], faces, new_name + "_plane")
if ob['remove_double']:
wobj.select_set(True)
- bpy.ops.object.mode_set(mode = 'EDIT')
+ bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False)
- bpy.ops.object.mode_set(mode = 'OBJECT')
+ bpy.ops.object.mode_set(mode='OBJECT')
else:
# grid
verts, faces = grid_gen(
- 2,
- 2,
- ob['tri_face'],
- ob['mesh_size_x'],
- ob['mesh_size_y'],
- ant_props,
- ob['water_plane'],
- ob['water_level']
- )
- wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane")
+ 2,
+ 2,
+ ob['tri_face'],
+ ob['mesh_size_x'],
+ ob['mesh_size_y'],
+ ant_props,
+ ob['water_plane'],
+ ob['water_level'],
+ )
+ wobj = create_mesh_object(context, verts, [], faces, new_name + "_plane")
wobj.select_set(True)
@@ -310,41 +310,39 @@ class AntVgSlopeMap(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'}
z_method: EnumProperty(
- name="Method:",
- default='SLOPE_Z',
- items=[
+ name="Method:",
+ default='SLOPE_Z',
+ items=[
('SLOPE_Z', "Z Slope", "Slope for planar mesh"),
('SLOPE_XYZ', "Sphere Slope", "Slope for spherical mesh")
- ])
+ ])
group_name: StringProperty(
- name="Vertex Group Name:",
- default="Slope",
- description="Name"
- )
+ name="Vertex Group Name:",
+ default="Slope",
+ description="Name"
+ )
select_flat: BoolProperty(
- name="Vert Select:",
- default=True,
- description="Select vertices on flat surface"
- )
+ name="Vert Select:",
+ default=True,
+ description="Select vertices on flat surface"
+ )
select_range: FloatProperty(
- name="Vert Select Range:",
- default=0.0,
- min=0.0,
- max=1.0,
- description="Increase to select more vertices on slopes"
- )
+ name="Vert Select Range:",
+ default=0.0,
+ min=0.0,
+ max=1.0,
+ description="Increase to select more vertices on slopes"
+ )
@classmethod
def poll(cls, context):
ob = context.object
return (ob and ob.type == 'MESH')
-
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
-
def execute(self, context):
message = "Popup Values: %d, %f, %s, %s" % \
(self.select_flat, self.select_range, self.group_name, self.z_method)
@@ -421,7 +419,7 @@ def draw_ant_main(self, context, generate=True):
split.prop(self, "remove_double", toggle=True)
box.prop(self, "ant_terrain_name")
- box.prop_search(self, "land_material", bpy.data, "materials")
+ box.prop_search(self, "land_material", bpy.data, "materials")
col = box.column(align=True)
col.prop(self, "subdivision_x")
@@ -450,11 +448,11 @@ def draw_ant_noise(self, context, generate=True):
col = box.column(align=True)
col.prop(self, "noise_offset_x")
col.prop(self, "noise_offset_y")
- if self.sphere_mesh == True or generate == False:
+ if self.sphere_mesh or generate == False:
col.prop(self, "noise_offset_z")
col.prop(self, "noise_size_x")
col.prop(self, "noise_size_y")
- if self.sphere_mesh == True or generate == False:
+ if self.sphere_mesh or generate == False:
col.prop(self, "noise_size_z")
col = box.column(align=True)
@@ -647,7 +645,7 @@ def draw_ant_displace(self, context, generate=True):
if not generate:
col = box.column(align=False)
- col.prop_search(self, "vert_group", bpy.context.object, "vertex_groups")
+ col.prop_search(self, "vert_group", bpy.context.object, "vertex_groups")
def draw_ant_water(self, context):
@@ -657,7 +655,7 @@ def draw_ant_water(self, context):
col.prop(self, "water_plane", toggle=True)
if self.water_plane:
col = box.column(align=True)
- col.prop_search(self, "water_material", bpy.data, "materials")
+ col.prop_search(self, "water_material", bpy.data, "materials")
col = box.column()
col.prop(self, "water_level")
@@ -744,8 +742,8 @@ from .utils import numexpr_available
def availableVertexGroupsOrNone(self, context):
- groups = [ ('None', 'None', 'None', 1) ]
- return groups + [(name, name, name, n+1) for n,name in enumerate(context.active_object.vertex_groups.keys())]
+ groups = [('None', 'None', 'None', 1)]
+ return groups + [(name, name, name, n + 1) for n, name in enumerate(context.active_object.vertex_groups.keys())]
class Eroder(bpy.types.Operator):
@@ -755,159 +753,160 @@ class Eroder(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
Iterations: IntProperty(
- name="Iterations",
- description="Number of overall iterations",
- default=1,
- min=1,
- soft_max=100
- )
+ name="Iterations",
+ description="Number of overall iterations",
+ default=1,
+ min=1,
+ soft_max=100
+ )
IterRiver: IntProperty(
- name="River Iterations",
- description="Number of river iterations",
- default=30,
- min=1,
- soft_max=1000
- )
+ name="River Iterations",
+ description="Number of river iterations",
+ default=30,
+ min=1,
+ soft_max=1000
+ )
IterAva: IntProperty(
- name="Avalanche Iterations",
- description="Number of avalanche iterations",
- default=5,
- min=1,
- soft_max=10
- )
+ name="Avalanche Iterations",
+ description="Number of avalanche iterations",
+ default=5,
+ min=1,
+ soft_max=10
+ )
IterDiffuse: IntProperty(
- name="Diffuse Iterations",
- description="Number of diffuse iterations",
- default=5,
- min=1,
- soft_max=10
- )
+ name="Diffuse Iterations",
+ description="Number of diffuse iterations",
+ default=5,
+ min=1,
+ soft_max=10
+ )
Ef: FloatProperty(
- name="Rain on Plains",
- description="1 gives equal rain across the terrain, 0 rains more at the mountain tops",
- default=0.0,
- min=0,
- max=1
- )
+ name="Rain on Plains",
+ description="1 gives equal rain across the terrain, 0 rains more at the mountain tops",
+ default=0.0,
+ min=0,
+ max=1
+ )
Kd: FloatProperty(
- name="Kd",
- description="Thermal diffusion rate (1.0 is a fairly high rate)",
- default=0.1,
- min=0,
- soft_max=100
- )
+ name="Kd",
+ description="Thermal diffusion rate (1.0 is a fairly high rate)",
+ default=0.1,
+ min=0,
+ soft_max=100
+ )
Kt: FloatProperty(
- name="Kt",
- description="Maximum stable talus angle",
- default=radians(60),
- min=0,
- max=radians(90),
- subtype='ANGLE'
- )
+ name="Kt",
+ description="Maximum stable talus angle",
+ default=radians(60),
+ min=0,
+ max=radians(90),
+ subtype='ANGLE'
+ )
Kr: FloatProperty(
- name="Rain amount",
- description="Total Rain amount",
- default=.01,
- min=0,
- soft_max=1,
- precision=3
- )
+ name="Rain amount",
+ description="Total Rain amount",
+ default=.01,
+ min=0,
+ soft_max=1,
+ precision=3
+ )
Kv: FloatProperty(
- name="Rain variance",
- description="Rain variance (0 is constant, 1 is uniform)",
- default=0,
- min=0,
- max=1
- )
+ name="Rain variance",
+ description="Rain variance (0 is constant, 1 is uniform)",
+ default=0,
+ min=0,
+ max=1
+ )
userainmap: BoolProperty(
- name="Use rain map",
- description="Use active vertex group as a rain map",
- default=True
- )
+ name="Use rain map",
+ description="Use active vertex group as a rain map",
+ default=True
+ )
Ks: FloatProperty(
- name="Soil solubility",
- description="Soil solubility - how quickly water quickly reaches saturation point",
- default=0.5,
- min=0,
- soft_max=1
- )
+ name="Soil solubility",
+ description="Soil solubility - how quickly water quickly reaches saturation point",
+ default=0.5,
+ min=0,
+ soft_max=1
+ )
Kdep: FloatProperty(
- name="Deposition rate",
- description="Sediment deposition rate - how quickly silt is laid down once water stops flowing quickly",
- default=0.1,
- min=0,
- soft_max=1
- )
- Kz: FloatProperty(name="Fluvial Erosion Rate",
- description="Amount of sediment moved each main iteration - if 0, then rivers are formed but the mesh is not changed",
- default=0.3,
- min=0,
- soft_max=20
- )
+ name="Deposition rate",
+ description="Sediment deposition rate - how quickly silt is laid down once water stops flowing quickly",
+ default=0.1,
+ min=0,
+ soft_max=1
+ )
+ Kz: FloatProperty(
+ name="Fluvial Erosion Rate",
+ description="Amount of sediment moved each main iteration - if 0, then rivers are formed but the mesh is not changed",
+ default=0.3,
+ min=0,
+ soft_max=20)
Kc: FloatProperty(
- name="Carrying capacity",
- description="Base sediment carrying capacity",
- default=0.9,
- min=0,
- soft_max=1
- )
+ name="Carrying capacity",
+ description="Base sediment carrying capacity",
+ default=0.9,
+ min=0,
+ soft_max=1
+ )
Ka: FloatProperty(
- name="Slope dependence",
- description="Slope dependence of carrying capacity (not used)",
- default=1.0,
- min=0,
- soft_max=2
- )
+ name="Slope dependence",
+ description="Slope dependence of carrying capacity (not used)",
+ default=1.0,
+ min=0,
+ soft_max=2
+ )
Kev: FloatProperty(
- name="Evaporation",
- description="Evaporation Rate per grid square in % - causes sediment to be dropped closer to the hills",
- default=.5,
- min=0,
- soft_max=2
- )
+ name="Evaporation",
+ description="Evaporation Rate per grid square in % - causes sediment to be dropped closer to the hills",
+ default=.5,
+ min=0,
+ soft_max=2
+ )
numexpr: BoolProperty(
- name="Numexpr",
- description="Use numexpr module (if available)",
- default=True
- )
+ name="Numexpr",
+ description="Use numexpr module (if available)",
+ default=True
+ )
Pd: FloatProperty(
- name="Diffusion Amount",
- description="Diffusion probability",
- default=0.2,
- min=0,
- max=1
- )
+ name="Diffusion Amount",
+ description="Diffusion probability",
+ default=0.2,
+ min=0,
+ max=1
+ )
Pa: FloatProperty(
- name="Avalanche Amount",
- description="Avalanche amount",
- default=0.5,
- min=0,
- max=1
- )
+ name="Avalanche Amount",
+ description="Avalanche amount",
+ default=0.5,
+ min=0,
+ max=1
+ )
Pw: FloatProperty(
- name="River Amount",
- description="Water erosion probability",
- default=1,
- min=0,
- max=1
- )
+ name="River Amount",
+ description="Water erosion probability",
+ default=1,
+ min=0,
+ max=1
+ )
smooth: BoolProperty(
- name="Smooth",
- description="Set smooth shading",
- default=True
- )
+ name="Smooth",
+ description="Set smooth shading",
+ default=True
+ )
showiterstats: BoolProperty(
- name="Iteration Stats",
- description="Show iteraration statistics",
- default=False
- )
- showmeshstats: BoolProperty(name="Mesh Stats",
- description="Show mesh statistics",
- default=False
- )
+ name="Iteration Stats",
+ description="Show iteraration statistics",
+ default=False
+ )
+ showmeshstats: BoolProperty(
+ name="Mesh Stats",
+ description="Show mesh statistics",
+ default=False
+ )
stats = Stats()
- counts= {}
+ counts = {}
maps = {
'rainmap': lambda g, r, c: g.rainmap[r, c],
'scree': lambda g, r, c: g.avalanced[r, c],
@@ -945,21 +944,36 @@ class Eroder(bpy.types.Operator):
for i in range(self.Iterations):
if self.IterRiver > 0:
for i in range(self.IterRiver):
- g.rivergeneration(self.Kr, self.Kv, self.userainmap, self.Kc, self.Ks, self.Kdep, self.Ka, self.Kev/100, 0,0,0,0, self.numexpr)
+ g.rivergeneration(
+ self.Kr,
+ self.Kv,
+ self.userainmap,
+ self.Kc,
+ self.Ks,
+ self.Kdep,
+ self.Ka,
+ self.Kev / 100,
+ 0,
+ 0,
+ 0,
+ 0,
+ self.numexpr,
+ )
if self.Kd > 0.0:
for k in range(self.IterDiffuse):
g.diffuse(self.Kd / 5, self.IterDiffuse, self.numexpr)
- self.counts['diffuse']+=1
+ self.counts['diffuse'] += 1
if self.Kt < radians(90) and self.Pa > 0:
for k in range(self.IterAva):
# since dx and dy are scaled to 1, tan(Kt) is the height for a given angle
g.avalanche(tan(self.Kt), self.IterAva, self.Pa, self.numexpr)
- self.counts['avalanche']+=1
+ self.counts['avalanche'] += 1
if self.Kz > 0:
- g.fluvial_erosion(self.Kr, self.Kv, self.userainmap, self.Kc, self.Ks, self.Kz*50, self.Ka, 0,0,0,0, self.numexpr)
- self.counts['water']+=1
+ g.fluvial_erosion(self.Kr, self.Kv, self.userainmap, self.Kc, self.Ks,
+ self.Kz * 50, self.Ka, 0, 0, 0, 0, self.numexpr)
+ self.counts['water'] += 1
newMesh = bpy.data.meshes.new(oldMesh.name)
g.toBlenderMesh(newMesh)
@@ -994,11 +1008,10 @@ class Eroder(bpy.types.Operator):
return {'FINISHED'}
-
- def draw(self,context):
+ def draw(self, context):
layout = self.layout
- layout.operator('screen.repeat_last', text="Repeat", icon='FILE_REFRESH' )
+ layout.operator('screen.repeat_last', text="Repeat", icon='FILE_REFRESH')
layout.prop(self, 'Iterations')
@@ -1029,4 +1042,4 @@ class Eroder(bpy.types.Operator):
col.prop(self, 'Ef')
- layout.prop(self,'smooth')
+ layout.prop(self, 'smooth')
diff --git a/ant_landscape/ant_noise.py b/ant_landscape/ant_noise.py
index 7eec29b6..9385d4b4 100644
--- a/ant_landscape/ant_noise.py
+++ b/ant_landscape/ant_noise.py
@@ -5,23 +5,23 @@
import bpy
from mathutils.noise import (
- seed_set,
- noise,
- turbulence,
- turbulence_vector,
- fractal,
- hybrid_multi_fractal,
- multi_fractal,
- ridged_multi_fractal,
- hetero_terrain,
- random_unit_vector,
- variable_lacunarity,
- voronoi,
- )
+ seed_set,
+ noise,
+ turbulence,
+ turbulence_vector,
+ fractal,
+ hybrid_multi_fractal,
+ multi_fractal,
+ ridged_multi_fractal,
+ hetero_terrain,
+ random_unit_vector,
+ variable_lacunarity,
+ voronoi,
+)
from math import (
- floor, sqrt,
- sin, cos, pi,
- )
+ floor, sqrt,
+ sin, cos, pi,
+)
noise_basis_default = "BLENDER"
noise_basis = [
@@ -39,6 +39,8 @@ noise_basis = [
# ------------------------------------------------------------
# Height scale:
+
+
def Height_Scale(input, iscale, offset, invert):
if invert != 0:
return (1.0 - input) * iscale + offset
@@ -176,14 +178,15 @@ def vlnTurbMode(coords, distort, basis, vlbasis, hardnoise):
def vl_noise_turbulence(coords, distort, depth, basis, vlbasis, hardnoise, amp, freq):
x, y, z = coords
value = vlnTurbMode(coords, distort, basis, vlbasis, hardnoise)
- i=0
+ i = 0
for i in range(depth):
- i+=1
- value += vlnTurbMode((x * (freq * i), y * (freq * i), z * (freq * i)), distort, basis, vlbasis, hardnoise) * (amp * 0.5 / i)
+ i += 1
+ value += vlnTurbMode((x * (freq * i), y * (freq * i), z * (freq * i)),
+ distort, basis, vlbasis, hardnoise) * (amp * 0.5 / i)
return value
-## duo_multiFractal:
+# duo_multiFractal:
def double_multiFractal(coords, H, lacunarity, octaves, offset, gain, basis, vlbasis):
x, y, z = coords
n1 = multi_fractal((x * 1.5 + 1, y * 1.5 + 1, z * 1.5 + 1), 1.0, 1.0, 1.0, noise_basis=basis) * (offset * 0.5)
@@ -191,27 +194,27 @@ def double_multiFractal(coords, H, lacunarity, octaves, offset, gain, basis, vlb
return (n1 * n1 + n2 * n2) * 0.5
-## distorted_heteroTerrain:
+# distorted_heteroTerrain:
def distorted_heteroTerrain(coords, H, lacunarity, octaves, offset, distort, basis, vlbasis):
x, y, z = coords
h1 = (hetero_terrain((x, y, z), 1.0, 2.0, 1.0, 1.0, noise_basis=basis) * 0.5)
- d = h1 * distort
+ d = h1 * distort
h2 = (hetero_terrain((x + d, y + d, z + d), H, lacunarity, octaves, offset, noise_basis=vlbasis) * 0.25)
return (h1 * h1 + h2 * h2) * 0.5
-## SlickRock:
+# SlickRock:
def slick_rock(coords, H, lacunarity, octaves, offset, gain, distort, basis, vlbasis):
x, y, z = coords
- n = multi_fractal((x,y,z), 1.0, 2.0, 2.0, noise_basis=basis) * distort * 0.25
+ n = multi_fractal((x, y, z), 1.0, 2.0, 2.0, noise_basis=basis) * distort * 0.25
r = ridged_multi_fractal((x + n, y + n, z + n), H, lacunarity, octaves, offset + 0.1, gain * 2, noise_basis=vlbasis)
return (n + (n * r)) * 0.5
-## vlhTerrain
+# vlhTerrain
def vl_hTerrain(coords, H, lacunarity, octaves, offset, basis, vlbasis, distort):
x, y, z = coords
- ht = hetero_terrain((x, y, z), H, lacunarity, octaves, offset, noise_basis=basis ) * 0.25
+ ht = hetero_terrain((x, y, z), H, lacunarity, octaves, offset, noise_basis=basis) * 0.25
vl = ht * variable_lacunarity((x, y, z), distort, noise_type1=basis, noise_type2=vlbasis) * 0.5 + 0.5
return vl * ht
@@ -219,13 +222,14 @@ def vl_hTerrain(coords, H, lacunarity, octaves, offset, basis, vlbasis, distort)
# another turbulence
def ant_turbulence(coords, depth, hardnoise, nbasis, amp, freq, distortion):
x, y, z = coords
- t = turbulence_vector((x/2, y/2, z/2), depth, 0, noise_basis=nbasis, amplitude_scale=amp, frequency_scale=freq) * 0.5 * distortion
+ t = turbulence_vector((x / 2, y / 2, z / 2), depth, 0, noise_basis=nbasis,
+ amplitude_scale=amp, frequency_scale=freq) * 0.5 * distortion
return turbulence((t[0], t[1], t[2]), 2, hardnoise, noise_basis="VORONOI_F1") * 0.5 + 0.5
# rocks noise
def rocks_noise(coords, depth, hardnoise, nbasis, distortion):
- x,y,z = coords
+ x, y, z = coords
p = turbulence((x, y, z), 4, 0, noise_basis='BLENDER') * 0.125 * distortion
xx, yy, zz = x, y, z
a = turbulence((xx + p, yy + p, zz), 2, 0, noise_basis='VORONOI_F2F1')
@@ -269,16 +273,18 @@ def planet_noise(coords, oct=6, hard=0, noisebasis='PERLIN_ORIGINAL', nabla=0.00
return (zdy - ydz), (zdx - xdz), (ydx - xdy)
-###----------------------------------------------------------------------
+# ----------------------------------------------------------------------
# v.1.04 Effect functions:
def maximum(a, b):
- if (a > b): b = a
+ if (a > b):
+ b = a
return b
def minimum(a, b):
- if (a < b): b = a
+ if (a < b):
+ b = a
return b
@@ -286,38 +292,38 @@ def Mix_Modes(a, b, mixfactor, mode):
mode = int(mode)
a = a * (1.0 - mixfactor)
b = b * (1.0 + mixfactor)
- #1 mix
+ # 1 mix
if mode == 0:
return (a * (1.0 - 0.5) + b * 0.5)
- #2 add
+ # 2 add
elif mode == 1:
return (a + b)
- #3 sub.
+ # 3 sub.
elif mode == 2:
return (a - b)
- #4 mult.
+ # 4 mult.
elif mode == 3:
return (a * b)
- #5 abs diff.
+ # 5 abs diff.
elif mode == 4:
return (abs(a - b))
- #6 screen
+ # 6 screen
elif mode == 5:
return 1.0 - ((1.0 - a) * (1.0 - b) / 1.0)
- #7 addmodulo
+ # 7 addmodulo
elif mode == 6:
return (a + b) % 1.0
- #8 min.
+ # 8 min.
elif mode == 7:
return minimum(a, b)
- #9 max.
+ # 9 max.
elif mode == 8:
return maximum(a, b)
else:
return 0
-Bias_Types = [sin_bias, cos_bias, tri_bias, saw_bias, no_bias]
+Bias_Types = [sin_bias, cos_bias, tri_bias, saw_bias, no_bias]
Sharp_Types = [soft, sharp, sharper]
@@ -337,46 +343,47 @@ def Effect_Basis_Function(coords, type, bias):
iscale = 1.0
offset = 0.0
- ## gradient:
+ # gradient:
if type == 1:
effect = offset + iscale * (Bias_Types[bias](x + y))
- ## waves / bumps:
+ # waves / bumps:
elif type == 2:
effect = offset + iscale * 0.5 * (Bias_Types[bias](x * pi) + Bias_Types[bias](y * pi))
- ## zigzag:
+ # zigzag:
elif type == 3:
effect = offset + iscale * Bias_Types[bias](offset + iscale * sin(x * pi + sin(y * pi)))
- ## wavy:
+ # wavy:
elif type == 4:
effect = offset + iscale * (Bias_Types[bias](cos(x) + sin(y) + cos(x * 2 + y * 2) - sin(-x * 4 + y * 4)))
- ## sine bump:
+ # sine bump:
elif type == 5:
- effect = offset + iscale * 1 - Bias_Types[bias]((sin(x * pi) + sin(y * pi)))
- ## dots:
+ effect = offset + iscale * 1 - Bias_Types[bias]((sin(x * pi) + sin(y * pi)))
+ # dots:
elif type == 6:
effect = offset + iscale * (Bias_Types[bias](x * pi * 2) * Bias_Types[bias](y * pi * 2)) - 0.5
- ## rings:
+ # rings:
elif type == 7:
- effect = offset + iscale * (Bias_Types[bias ](1.0 - (x * x + y * y)))
- ## spiral:
+ effect = offset + iscale * (Bias_Types[bias](1.0 - (x * x + y * y)))
+ # spiral:
elif type == 8:
- effect = offset + iscale * Bias_Types[bias]( (x * sin(x * x + y * y) + y * cos(x * x + y * y)) / (x**2 + y**2 + 0.5)) * 2
- ## square / piramide:
+ effect = offset + iscale * \
+ Bias_Types[bias]((x * sin(x * x + y * y) + y * cos(x * x + y * y)) / (x**2 + y**2 + 0.5)) * 2
+ # square / piramide:
elif type == 9:
effect = offset + iscale * Bias_Types[bias](1.0 - sqrt((x * x)**10 + (y * y)**10)**0.1)
- ## blocks:
+ # blocks:
elif type == 10:
- effect = (0.5 - max(Bias_Types[bias](x * pi) , Bias_Types[bias](y * pi)))
+ effect = (0.5 - max(Bias_Types[bias](x * pi), Bias_Types[bias](y * pi)))
if effect > 0.0:
effect = 1.0
effect = offset + iscale * effect
- ## grid:
+ # grid:
elif type == 11:
effect = (0.025 - min(Bias_Types[bias](x * pi), Bias_Types[bias](y * pi)))
if effect > 0.0:
effect = 1.0
effect = offset + iscale * effect
- ## tech:
+ # tech:
elif type == 12:
a = max(Bias_Types[bias](x * pi), Bias_Types[bias](y * pi))
b = max(Bias_Types[bias](x * pi * 2 + 2), Bias_Types[bias](y * pi * 2 + 2))
@@ -384,51 +391,51 @@ def Effect_Basis_Function(coords, type, bias):
if effect > 0.5:
effect = 1.0
effect = offset + iscale * effect
- ## crackle:
+ # crackle:
elif type == 13:
t = turbulence((x, y, 0), 6, 0, noise_basis="BLENDER") * 0.25
effect = variable_lacunarity((x, y, t), 0.25, noise_type2='VORONOI_CRACKLE')
if effect > 0.5:
effect = 0.5
effect = offset + iscale * effect
- ## sparse cracks noise:
+ # sparse cracks noise:
elif type == 14:
effect = 2.5 * abs(noise((x, y, 0), noise_basis="PERLIN_ORIGINAL")) - 0.1
if effect > 0.25:
effect = 0.25
effect = offset + iscale * (effect * 2.5)
- ## shattered rock noise:
+ # shattered rock noise:
elif type == 15:
effect = 0.5 + noise((x, y, 0), noise_basis="VORONOI_F2F1")
if effect > 0.75:
effect = 0.75
effect = offset + iscale * effect
- ## lunar noise:
+ # lunar noise:
elif type == 16:
effect = 0.25 + 1.5 * voronoi((x, y, 0), distance_metric='DISTANCE_SQUARED')[0][0]
if effect > 0.5:
effect = 0.5
effect = offset + iscale * effect * 2
- ## cosine noise:
+ # cosine noise:
elif type == 17:
effect = cos(5 * noise((x, y, 0), noise_basis="BLENDER"))
effect = offset + iscale * (effect * 0.5)
- ## spikey noise:
+ # spikey noise:
elif type == 18:
n = 0.5 + 0.5 * turbulence((x * 5, y * 5, 0), 8, 0, noise_basis="BLENDER")
effect = ((n * n)**5)
effect = offset + iscale * effect
- ## stone noise:
+ # stone noise:
elif type == 19:
effect = offset + iscale * (noise((x * 2, y * 2, 0), noise_basis="BLENDER") * 1.5 - 0.75)
- ## Flat Turb:
+ # Flat Turb:
elif type == 20:
t = turbulence((x, y, 0), 6, 0, noise_basis="BLENDER")
effect = t * 2.0
if effect > 0.25:
effect = 0.25
effect = offset + iscale * effect
- ## Flat Voronoi:
+ # Flat Voronoi:
elif type == 21:
t = 1 - voronoi((x, y, 0), distance_metric='DISTANCE_SQUARED')[0][0]
effect = t * 2 - 1.5
@@ -448,19 +455,19 @@ def Effect_Basis_Function(coords, type, bias):
def Effect_Function(coords, type, bias, turb, depth, frequency, amplitude):
x, y, z = coords
- ## turbulence:
+ # turbulence:
if turb > 0.0:
- t = turb * ( 0.5 + 0.5 * turbulence(coords, 6, 0, noise_basis="BLENDER"))
+ t = turb * (0.5 + 0.5 * turbulence(coords, 6, 0, noise_basis="BLENDER"))
x = x + t
y = y + t
z = z + t
result = Effect_Basis_Function((x, y, z), type, bias) * amplitude
- ## fractalize:
+ # fractalize:
if depth != 0:
- i=0
+ i = 0
for i in range(depth):
- i+=1
+ i += 1
x *= frequency
y *= frequency
result += Effect_Basis_Function((x, y, z), type, bias) * amplitude / i
@@ -578,20 +585,21 @@ def noise_gen(coords, props):
value = fractal(ncoords, dimension, lacunarity, depth, noise_basis=nbasis)
elif ntype in [5, 'turbulence_vector']:
- value = turbulence_vector(ncoords, depth, hardnoise, noise_basis=nbasis, amplitude_scale=amp, frequency_scale=freq)[0]
+ value = turbulence_vector(ncoords, depth, hardnoise, noise_basis=nbasis,
+ amplitude_scale=amp, frequency_scale=freq)[0]
elif ntype in [6, 'variable_lacunarity']:
value = variable_lacunarity(ncoords, distortion, noise_type1=nbasis, noise_type2=vlbasis)
elif ntype in [7, 'marble_noise']:
value = marble_noise(
- (ncoords[0] - origin_x + x_offset),
- (ncoords[1] - origin_y + y_offset),
- (ncoords[2] - origin_z + z_offset),
- (origin[0] + x_offset, origin[1] + y_offset, origin[2] + z_offset), nsize,
- marbleshape, marblebias, marblesharpnes,
- distortion, depth, hardnoise, nbasis, amp, freq
- )
+ (ncoords[0] - origin_x + x_offset),
+ (ncoords[1] - origin_y + y_offset),
+ (ncoords[2] - origin_z + z_offset),
+ (origin[0] + x_offset, origin[1] + y_offset, origin[2] + z_offset), nsize,
+ marbleshape, marblebias, marblesharpnes,
+ distortion, depth, hardnoise, nbasis, amp, freq
+ )
elif ntype in [8, 'shattered_hterrain']:
value = shattered_hterrain(ncoords, dimension, lacunarity, depth, offset, distortion, nbasis)
@@ -617,7 +625,7 @@ def noise_gen(coords, props):
value = rocks_noise(ncoords, depth, hardnoise, nbasis, distortion)
elif ntype in [16, 'slick_rock']:
- value = slick_rock(ncoords,dimension, lacunarity, depth, offset, gain, distortion, nbasis, vlbasis)
+ value = slick_rock(ncoords, dimension, lacunarity, depth, offset, gain, distortion, nbasis, vlbasis)
elif ntype in [17, 'planet_noise']:
value = planet_noise(ncoords, depth, hardnoise, nbasis)[2] * 0.5 + 0.5
@@ -632,7 +640,7 @@ def noise_gen(coords, props):
# Effect mix
val = value
- if fx_type in [0,"0"]:
+ if fx_type in [0, "0"]:
fx_mixfactor = -1.0
fxval = val
else:
@@ -649,14 +657,15 @@ def noise_gen(coords, props):
if not sphere:
if falloff:
ratio_x, ratio_y = abs(x) * 2 / meshsize_x, abs(y) * 2 / meshsize_y
- fallofftypes = [0,
- sqrt(ratio_y**falloffsize_y),
- sqrt(ratio_x**falloffsize_x),
- sqrt(ratio_x**falloffsize_x + ratio_y**falloffsize_y)
- ]
+ fallofftypes = [
+ 0,
+ sqrt(ratio_y**falloffsize_y),
+ sqrt(ratio_x**falloffsize_x),
+ sqrt(ratio_x**falloffsize_x + ratio_y**falloffsize_y)
+ ]
dist = fallofftypes[falloff]
value -= edge_level
- if(dist < 1.0):
+ if dist < 1.0:
dist = (dist * dist * (3 - 2 * dist))
value = (value - value * dist) + edge_level
else:
@@ -682,11 +691,11 @@ def noise_gen(coords, props):
elif stratatype in [4, "4"]:
strata = strata / height
- value = int( value * strata ) * 1.0 / strata
+ value = int(value * strata) * 1.0 / strata
elif stratatype in [5, "5"]:
strata = strata / height
- steps = (int( value * strata ) * 1.0 / strata)
+ steps = (int(value * strata) * 1.0 / strata)
value = (value * (1.0 - 0.5) + steps * 0.5)
# Clamp height min max
diff --git a/ant_landscape/eroder.py b/ant_landscape/eroder.py
index 558d2edb..ae1326df 100644
--- a/ant_landscape/eroder.py
+++ b/ant_landscape/eroder.py
@@ -43,7 +43,6 @@ class Grid:
self.sedmax = 1.0
self.scourmin = 1.0
-
def init_water_and_sediment(self):
if self.water is None:
self.water = np.zeros(self.center.shape, dtype=np.single)
@@ -60,39 +59,34 @@ class Grid:
if self.avalanced is None:
self.avalanced = np.zeros(self.center.shape, dtype=np.single)
-
def __str__(self):
return ''.join(self.__str_iter__(fmt="%.3f"))
-
def __str_iter__(self, fmt):
for row in self.center[::]:
- values=[]
+ values = []
for v in row:
- values.append(fmt%v)
- yield ' '.join(values) + '\n'
-
+ values.append(fmt % v)
+ yield ' '.join(values) + '\n'
@staticmethod
def fromFile(filename):
if filename == '-':
filename = sys.stdin
- g=Grid()
- g.center=np.loadtxt(filename,np.single)
+ g = Grid()
+ g.center = np.loadtxt(filename, np.single)
return g
-
def toFile(self, filename, fmt="%.3f"):
- if filename == '-' :
+ if filename == '-':
filename = sys.stdout.fileno()
- with open(filename,"w") as f:
+ with open(filename, "w") as f:
for line in self.__str_iter__(fmt):
f.write(line)
-
- def raw(self,format="%.3f"):
- fstr=format+" "+ format+" "+ format+" "
- a=self.center / self.zscale
+ def raw(self, format="%.3f"):
+ fstr = format + " " + format + " " + format + " "
+ a = self.center / self.zscale
minx = 0.0 if self.minx is None else self.minx
miny = 0.0 if self.miny is None else self.miny
maxx = 1.0 if self.maxx is None else self.maxx
@@ -105,21 +99,19 @@ class Grid:
for col in range(a.shape[1] - 1):
col0 = minx + col * dx
col1 = col0 + dx
- yield (fstr%(row0 ,col0 ,a[row ][col ])+
- fstr%(row0 ,col1 ,a[row ][col+1])+
- fstr%(row1 ,col0 ,a[row+1][col ])+"\n")
- yield (fstr%(row0 ,col1 ,a[row ][col+1])+
- fstr%(row1 ,col0 ,a[row+1][col ])+
- fstr%(row1 ,col1 ,a[row+1][col+1])+"\n")
-
+ yield (fstr % (row0, col0, a[row][col]) +
+ fstr % (row0, col1, a[row][col + 1]) +
+ fstr % (row1, col0, a[row + 1][col]) + "\n")
+ yield (fstr % (row0, col1, a[row][col + 1]) +
+ fstr % (row1, col0, a[row + 1][col]) +
+ fstr % (row1, col1, a[row + 1][col + 1]) + "\n")
def toRaw(self, filename, infomap=None):
- with open(filename if type(filename) == str else sys.stdout.fileno() , "w") as f:
+ with open(filename if type(filename) == str else sys.stdout.fileno(), "w") as f:
f.writelines(self.raw())
if infomap:
- with open(os.path.splitext(filename)[0]+".inf" if type(filename) == str else sys.stdout.fileno() , "w") as f:
- f.writelines("\n".join("%-15s: %s"%t for t in sorted(infomap.items())))
-
+ with open(os.path.splitext(filename)[0] + ".inf" if type(filename) == str else sys.stdout.fileno(), "w") as f:
+ f.writelines("\n".join("%-15s: %s" % t for t in sorted(infomap.items())))
@staticmethod
def fromRaw(filename):
@@ -128,15 +120,14 @@ class Grid:
"""
g = Grid.fromFile(filename)
# we assume tris and an axis aligned grid
- g.center = np.reshape(g.center,(-1,3))
+ g.center = np.reshape(g.center, (-1, 3))
g._sort()
return g
-
def _sort(self, expfact):
# keep unique vertices only by creating a set and sort first on x then on y coordinate
# using rather slow python sort but couldn't wrap my head around np.lexsort
- verts = sorted(list({ tuple(t) for t in self.center[::] }))
+ verts = sorted(list({tuple(t) for t in self.center[::]}))
x = set(c[0] for c in verts)
y = set(c[1] for c in verts)
nx = len(x)
@@ -145,41 +136,40 @@ class Grid:
self.maxx = max(x)
self.miny = min(y)
self.maxy = max(y)
- xscale = (self.maxx-self.minx)/(nx-1)
- yscale = (self.maxy-self.miny)/(ny-1)
+ xscale = (self.maxx - self.minx) / (nx - 1)
+ yscale = (self.maxy - self.miny) / (ny - 1)
# note: a purely flat plane cannot be scaled
- if (yscale != 0.0) and (abs(xscale/yscale) - 1.0 > 1e-3):
- raise ValueError("Mesh spacing not square %d x %d %.4f x %4.f"%(nx,ny,xscale,yscale))
+ if (yscale != 0.0) and (abs(xscale / yscale) - 1.0 > 1e-3):
+ raise ValueError("Mesh spacing not square %d x %d %.4f x %4.f" % (nx, ny, xscale, yscale))
self.zscale = 1.0
- if abs(yscale) > 1e-6 :
- self.zscale = 1.0/yscale
+ if abs(yscale) > 1e-6:
+ self.zscale = 1.0 / yscale
# keep just the z-values and null any offset
- # we might catch a reshape error that will occur if nx*ny != # of vertices (if we are not dealing with a heightfield but with a mesh with duplicate x,y coords, like an axis aligned cube
- self.center = np.array([c[2] for c in verts],dtype=np.single).reshape(nx,ny)
- self.center = (self.center-np.amin(self.center))*self.zscale
+ # we might catch a reshape error that will occur if nx*ny != # of vertices
+ # (if we are not dealing with a heightfield but with a mesh with duplicate
+ # x,y coords, like an axis aligned cube
+ self.center = np.array([c[2] for c in verts], dtype=np.single).reshape(nx, ny)
+ self.center = (self.center - np.amin(self.center)) * self.zscale
if self.rainmap is not None:
rmscale = np.max(self.center)
- self.rainmap = expfact + (1-expfact)*(self.center/rmscale)
-
+ self.rainmap = expfact + (1 - expfact) * (self.center / rmscale)
@staticmethod
def fromBlenderMesh(me, vg, expfact):
g = Grid()
- g.center = np.asarray(list(tuple(v.co) for v in me.vertices), dtype=np.single )
+ g.center = np.asarray(list(tuple(v.co) for v in me.vertices), dtype=np.single)
g.rainmap = None
if vg is not None:
for v in me.vertices:
- vg.add([v.index],0.0,'ADD')
- g.rainmap=np.asarray(list( (v.co[0], v.co[1], vg.weight(v.index)) for v in me.vertices), dtype=np.single )
+ vg.add([v.index], 0.0, 'ADD')
+ g.rainmap = np.asarray(list((v.co[0], v.co[1], vg.weight(v.index)) for v in me.vertices), dtype=np.single)
g._sort(expfact)
return g
-
def setrainmap(self, rainmap):
self.rainmap = rainmap
-
def _verts(self, surface):
a = surface / self.zscale
minx = 0.0 if self.minx is None else self.minx
@@ -192,90 +182,81 @@ class Grid:
row0 = miny + row * dy
for col in range(a.shape[1]):
col0 = minx + col * dx
- yield (row0 ,col0 ,a[row ][col ])
-
+ yield (row0, col0, a[row][col])
def _faces(self):
nrow, ncol = self.center.shape
- for row in range(nrow-1):
- for col in range(ncol-1):
- vi = row * ncol + col
- yield (vi, vi+ncol, vi+1)
- yield (vi+1, vi+ncol, vi+ncol+1)
-
+ for row in range(nrow - 1):
+ for col in range(ncol - 1):
+ vi = row * ncol + col
+ yield (vi, vi + ncol, vi + 1)
+ yield (vi + 1, vi + ncol, vi + ncol + 1)
def toBlenderMesh(self, me):
# pass me as argument so that we don't need to import bpy and create a dependency
- # the docs state that from_pydata takes iterators as arguments but it will fail with generators because it does len(arg)
- me.from_pydata(list(self._verts(self.center)),[],list(self._faces()))
-
+ # the docs state that from_pydata takes iterators as arguments but it will
+ # fail with generators because it does len(arg)
+ me.from_pydata(list(self._verts(self.center)), [], list(self._faces()))
def toWaterMesh(self, me):
# pass me as argument so that we don't need to import bpy and create a dependency
- # the docs state that from_pydata takes iterators as arguments but it will fail with generators because it does len(arg)
- me.from_pydata(list(self._verts(self.water)),[],list(self._faces()))
-
+ # the docs state that from_pydata takes iterators as arguments but it will
+ # fail with generators because it does len(arg)
+ me.from_pydata(list(self._verts(self.water)), [], list(self._faces()))
def peak(self, value=1):
- nx,ny = self.center.shape
- self.center[int(nx/2),int(ny/2)] += value
-
+ nx, ny = self.center.shape
+ self.center[int(nx / 2), int(ny / 2)] += value
def shelf(self, value=1):
- nx,ny = self.center.shape
- self.center[:nx/2] += value
-
+ nx, ny = self.center.shape
+ self.center[:nx / 2] += value
def mesa(self, value=1):
- nx,ny = self.center.shape
- self.center[nx/4:3*nx/4,ny/4:3*ny/4] += value
-
+ nx, ny = self.center.shape
+ self.center[nx / 4:3 * nx / 4, ny / 4:3 * ny / 4] += value
def random(self, value=1):
- self.center += np.random.random_sample(self.center.shape)*value
-
+ self.center += np.random.random_sample(self.center.shape) * value
def neighborgrid(self):
- self.up = np.roll(self.center,-1,0)
- self.down = np.roll(self.center,1,0)
- self.left = np.roll(self.center,-1,1)
- self.right = np.roll(self.center,1,1)
-
+ self.up = np.roll(self.center, -1, 0)
+ self.down = np.roll(self.center, 1, 0)
+ self.left = np.roll(self.center, -1, 1)
+ self.right = np.roll(self.center, 1, 1)
def zeroedge(self, quantity=None):
c = self.center if quantity is None else quantity
- c[0,:] = 0
- c[-1,:] = 0
- c[:,0] = 0
- c[:,-1] = 0
-
+ c[0, :] = 0
+ c[-1, :] = 0
+ c[:, 0] = 0
+ c[:, -1] = 0
def diffuse(self, Kd, IterDiffuse, numexpr):
self.zeroedge()
- c = self.center[1:-1,1:-1]
- up = self.center[ :-2,1:-1]
- down = self.center[2: ,1:-1]
+ c = self.center[1:-1, 1:-1]
+ up = self.center[:-2, 1:-1]
+ down = self.center[2:, 1:-1]
left = self.center[1:-1, :-2]
- right = self.center[1:-1,2: ]
+ right = self.center[1:-1, 2:]
if(numexpr and numexpr_available):
- self.center[1:-1,1:-1] = ne.evaluate('c + Kd * (up + down + left + right - 4.0 * c)')
+ self.center[1:-1, 1:-1] = ne.evaluate('c + Kd * (up + down + left + right - 4.0 * c)')
else:
- self.center[1:-1,1:-1] = c + (Kd/IterDiffuse) * (up + down + left + right - 4.0 * c)
+ self.center[1:-1, 1:-1] = c + (Kd / IterDiffuse) * (up + down + left + right - 4.0 * c)
self.maxrss = max(getmemsize(), self.maxrss)
return self.center
-
def avalanche(self, delta, iterava, prob, numexpr):
self.zeroedge()
- c = self.center[1:-1,1:-1]
- up = self.center[ :-2,1:-1]
- down = self.center[2: ,1:-1]
- left = self.center[1:-1, :-2]
- right = self.center[1:-1,2: ]
+ c = self.center[1:-1, 1:-1]
+ up = self.center[:-2, 1:-1]
+ down = self.center[2:, 1:-1]
+ left = self.center[1:-1, :-2]
+ right = self.center[1:-1, 2:]
where = np.where
if(numexpr and numexpr_available):
- self.center[1:-1,1:-1] = ne.evaluate('c + where((up -c) > delta ,(up -c -delta)/2, 0) \
+ self.center[1:-1, 1:-1] = ne.evaluate('c + where((up -c) > delta ,(up -c -delta)/2, 0) \
+ where((down -c) > delta ,(down -c -delta)/2, 0) \
+ where((left -c) > delta ,(left -c -delta)/2, 0) \
+ where((right-c) > delta ,(right-c -delta)/2, 0) \
@@ -286,38 +267,36 @@ class Grid:
else:
sa = (
# incoming
- where((up -c) > delta ,(up -c -delta)/2, 0)
- + where((down -c) > delta ,(down -c -delta)/2, 0)
- + where((left -c) > delta ,(left -c -delta)/2, 0)
- + where((right-c) > delta ,(right-c -delta)/2, 0)
+ where((up - c) > delta, (up - c - delta) / 2, 0)
+ + where((down - c) > delta, (down - c - delta) / 2, 0)
+ + where((left - c) > delta, (left - c - delta) / 2, 0)
+ + where((right - c) > delta, (right - c - delta) / 2, 0)
# outgoing
- + where((up -c) < -delta,(up -c +delta)/2, 0)
- + where((down -c) < -delta,(down -c +delta)/2, 0)
- + where((left -c) < -delta,(left -c +delta)/2, 0)
- + where((right-c) < -delta,(right-c +delta)/2, 0)
- )
- randarray = np.random.randint(0,100,sa.shape) *0.01
+ + where((up - c) < -delta, (up - c + delta) / 2, 0)
+ + where((down - c) < -delta, (down - c + delta) / 2, 0)
+ + where((left - c) < -delta, (left - c + delta) / 2, 0)
+ + where((right - c) < -delta, (right - c + delta) / 2, 0)
+ )
+ randarray = np.random.randint(0, 100, sa.shape) * 0.01
sa = where(randarray < prob, sa, 0)
- self.avalanced[1:-1,1:-1] = self.avalanced[1:-1,1:-1] + sa/iterava
- self.center[1:-1,1:-1] = c + sa/iterava
+ self.avalanced[1:-1, 1:-1] = self.avalanced[1:-1, 1:-1] + sa / iterava
+ self.center[1:-1, 1:-1] = c + sa / iterava
self.maxrss = max(getmemsize(), self.maxrss)
return self.center
-
def rain(self, amount=1, variance=0, userainmap=False):
- self.water += (1.0 - np.random.random(self.water.shape) * variance) * (amount if ((self.rainmap is None) or (not userainmap)) else self.rainmap * amount)
-
+ self.water += (1.0 - np.random.random(self.water.shape) * variance) * \
+ (amount if ((self.rainmap is None) or (not userainmap)) else self.rainmap * amount)
def spring(self, amount, px, py, radius):
# px, py and radius are all fractions
nx, ny = self.center.shape
- rx = max(int(nx*radius),1)
- ry = max(int(ny*radius),1)
- px = int(nx*px)
- py = int(ny*py)
- self.water[px-rx:px+rx+1,py-ry:py+ry+1] += amount
-
+ rx = max(int(nx * radius), 1)
+ ry = max(int(ny * radius), 1)
+ px = int(nx * px)
+ py = int(ny * py)
+ self.water[px - rx:px + rx + 1, py - ry:py + ry + 1] += amount
def river(self, Kc, Ks, Kdep, Ka, Kev, numexpr):
zeros = np.zeros
@@ -328,11 +307,11 @@ class Grid:
arctan = np.arctan
sin = np.sin
- center = (slice( 1, -1,None),slice( 1, -1,None))
- up = (slice(None, -2,None),slice( 1, -1,None))
- down = (slice( 2, None,None),slice( 1, -1,None))
- left = (slice( 1, -1,None),slice(None, -2,None))
- right = (slice( 1, -1,None),slice( 2,None,None))
+ center = (slice(1, -1, None), slice(1, -1, None))
+ up = (slice(None, -2, None), slice(1, -1, None))
+ down = (slice(2, None, None), slice(1, -1, None))
+ left = (slice(1, -1, None), slice(None, -2, None))
+ right = (slice(1, -1, None), slice(2, None, None))
water = self.water
rock = self.center
@@ -348,7 +327,7 @@ class Grid:
svdw = zeros(water[center].shape)
sds = zeros(water[center].shape)
angle = zeros(water[center].shape)
- for d in (up,down,left,right):
+ for d in (up, down, left, right):
if(numexpr and numexpr_available):
hdd = height[d]
hcc = height[center]
@@ -356,25 +335,26 @@ class Grid:
inflow = ne.evaluate('dw > 0')
wdd = water[d]
wcc = water[center]
- dw = ne.evaluate('where(inflow, where(wdd<dw, wdd, dw), where(-wcc>dw, -wcc, dw))/4.0') # nested where() represent min() and max()
- sdw = ne.evaluate('sdw + dw')
- scd = sc[d]
- scc = sc[center]
- rockd= rock[d]
- rockc= rock[center]
- sds = ne.evaluate('sds + dw * where(inflow, scd, scc)')
+ # nested where() represent min() and max()
+ dw = ne.evaluate('where(inflow, where(wdd<dw, wdd, dw), where(-wcc>dw, -wcc, dw))/4.0')
+ sdw = ne.evaluate('sdw + dw')
+ scd = sc[d]
+ scc = sc[center]
+ rockd = rock[d]
+ rockc = rock[center]
+ sds = ne.evaluate('sds + dw * where(inflow, scd, scc)')
svdw = ne.evaluate('svdw + abs(dw)')
- angle= ne.evaluate('angle + arctan(abs(rockd-rockc))')
+ angle = ne.evaluate('angle + arctan(abs(rockd-rockc))')
else:
- dw = (height[d]-height[center])
+ dw = (height[d] - height[center])
inflow = dw > 0
- dw = where(inflow, min(water[d], dw), max(-water[center], dw))/4.0
- sdw = sdw + dw
- sds = sds + dw * where(inflow, sc[d], sc[center])
+ dw = where(inflow, min(water[d], dw), max(-water[center], dw)) / 4.0
+ sdw = sdw + dw
+ sds = sds + dw * where(inflow, sc[d], sc[center])
svdw = svdw + abs(dw)
- angle= angle + np.arctan(abs(rock[d]-rock[center]))
+ angle = angle + np.arctan(abs(rock[d] - rock[center]))
- if(numexpr and numexpr_available):
+ if numexpr and numexpr_available:
wcc = water[center]
scc = sediment[center]
rcc = rock[center]
@@ -391,10 +371,10 @@ class Grid:
wcc = water[center]
scc = sediment[center]
rcc = rock[center]
- water[center] = wcc * (1-Kev) + sdw
+ water[center] = wcc * (1 - Kev) + sdw
sediment[center] = scc + sds
sc = where(wcc > 0, scc / wcc, 2 * Kc)
- fKc = Kc*svdw
+ fKc = Kc * svdw
ds = where(fKc > sc, (fKc - sc) * Ks, (fKc - sc) * Kdep) * wcc
self.flowrate[center] = svdw
self.scour[center] = ds
@@ -402,7 +382,6 @@ class Grid:
self.capacity[center] = fKc
sediment[center] = scc + ds + sds
-
def flow(self, Kc, Ks, Kz, Ka, numexpr):
zeros = np.zeros
where = np.where
@@ -412,16 +391,30 @@ class Grid:
arctan = np.arctan
sin = np.sin
- center = (slice( 1, -1,None),slice( 1, -1,None))
+ center = (slice(1, -1, None), slice(1, -1, None))
rock = self.center
ds = self.scour[center]
rcc = rock[center]
rock[center] = rcc - ds * Kz
# there isn't really a bottom to the rock but negative values look ugly
- rock[center] = where(rcc<0,0,rcc)
-
-
- def rivergeneration(self, rainamount, rainvariance, userainmap, Kc, Ks, Kdep, Ka, Kev, Kspring, Kspringx, Kspringy, Kspringr, numexpr):
+ rock[center] = where(rcc < 0, 0, rcc)
+
+ def rivergeneration(
+ self,
+ rainamount,
+ rainvariance,
+ userainmap,
+ Kc,
+ Ks,
+ Kdep,
+ Ka,
+ Kev,
+ Kspring,
+ Kspringx,
+ Kspringy,
+ Kspringr,
+ numexpr,
+ ):
self.init_water_and_sediment()
self.rain(rainamount, rainvariance, userainmap)
self.zeroedge(self.water)
@@ -429,32 +422,43 @@ class Grid:
self.river(Kc, Ks, Kdep, Ka, Kev, numexpr)
self.watermax = np.max(self.water)
-
- def fluvial_erosion(self, rainamount, rainvariance, userainmap, Kc, Ks, Kdep, Ka, Kspring, Kspringx, Kspringy, Kspringr, numexpr):
+ def fluvial_erosion(
+ self,
+ rainamount,
+ rainvariance,
+ userainmap,
+ Kc,
+ Ks,
+ Kdep,
+ Ka,
+ Kspring,
+ Kspringx,
+ Kspringy,
+ Kspringr,
+ numexpr,
+ ):
self.flow(Kc, Ks, Kdep, Ka, numexpr)
self.flowratemax = np.max(self.flowrate)
self.scourmax = np.max(self.scour)
self.scourmin = np.min(self.scour)
self.sedmax = np.max(self.sediment)
-
def analyze(self):
self.neighborgrid()
# just looking at up and left to avoid needless double calculations
- slopes=np.concatenate((np.abs(self.left - self.center),np.abs(self.up - self.center)))
- return '\n'.join(["%-15s: %.3f"%t for t in [
- ('height average', np.average(self.center)),
- ('height median', np.median(self.center)),
- ('height max', np.max(self.center)),
- ('height min', np.min(self.center)),
- ('height std', np.std(self.center)),
- ('slope average', np.average(slopes)),
- ('slope median', np.median(slopes)),
- ('slope max', np.max(slopes)),
- ('slope min', np.min(slopes)),
- ('slope std', np.std(slopes))
- ]]
- )
+ slopes = np.concatenate((np.abs(self.left - self.center), np.abs(self.up - self.center)))
+ return '\n'.join(["%-15s: %.3f" % t for t in [
+ ('height average', np.average(self.center)),
+ ('height median', np.median(self.center)),
+ ('height max', np.max(self.center)),
+ ('height min', np.min(self.center)),
+ ('height std', np.std(self.center)),
+ ('slope average', np.average(slopes)),
+ ('slope median', np.median(slopes)),
+ ('slope max', np.max(slopes)),
+ ('slope min', np.min(slopes)),
+ ('slope std', np.std(slopes))
+ ]])
class TestGrid(unittest.TestCase):
@@ -462,12 +466,11 @@ class TestGrid(unittest.TestCase):
def test_diffuse(self):
g = Grid(5)
g.peak(1)
- self.assertEqual(g.center[2,2],1.0)
+ self.assertEqual(g.center[2, 2], 1.0)
g.diffuse(0.1, numexpr=False)
- for n in [(2,1),(2,3),(1,2),(3,2)]:
- self.assertAlmostEqual(g.center[n],0.1)
- self.assertAlmostEqual(g.center[2,2],0.6)
-
+ for n in [(2, 1), (2, 3), (1, 2), (3, 2)]:
+ self.assertAlmostEqual(g.center[n], 0.1)
+ self.assertAlmostEqual(g.center[2, 2], 0.6)
def test_diffuse_numexpr(self):
g = Grid(5)
@@ -476,8 +479,7 @@ class TestGrid(unittest.TestCase):
h = Grid(5)
h.peak(1)
h.diffuse(0.1, numexpr=True)
- self.assertEqual(list(g.center.flat),list(h.center.flat))
-
+ self.assertEqual(list(g.center.flat), list(h.center.flat))
def test_avalanche_numexpr(self):
g = Grid(5)
@@ -488,7 +490,7 @@ class TestGrid(unittest.TestCase):
h.avalanche(0.1, numexpr=True)
print(g)
print(h)
- np.testing.assert_almost_equal(g.center,h.center)
+ np.testing.assert_almost_equal(g.center, h.center)
if __name__ == "__main__":
@@ -501,7 +503,8 @@ if __name__ == "__main__":
parser.add_argument('-Kh', dest='Kh', type=float, default=6, help='Maximum stable cliff height')
parser.add_argument('-Kp', dest='Kp', type=float, default=0.1, help='Avalanche probability for unstable cliffs')
parser.add_argument('-Kr', dest='Kr', type=float, default=0.1, help='Average amount of rain per iteration')
- parser.add_argument('-Kspring', dest='Kspring', type=float, default=0.0, help='Average amount of wellwater per iteration')
+ parser.add_argument('-Kspring', dest='Kspring', type=float, default=0.0,
+ help='Average amount of wellwater per iteration')
parser.add_argument('-Kspringx', dest='Kspringx', type=float, default=0.5, help='relative x position of spring')
parser.add_argument('-Kspringy', dest='Kspringy', type=float, default=0.5, help='relative y position of spring')
parser.add_argument('-Kspringr', dest='Kspringr', type=float, default=0.02, help='radius of spring')
@@ -509,26 +512,45 @@ if __name__ == "__main__":
parser.add_argument('-Ks', dest='Ks', type=float, default=0.1, help='Soil softness constant')
parser.add_argument('-Kc', dest='Kc', type=float, default=1.0, help='Sediment capacity')
parser.add_argument('-Ka', dest='Ka', type=float, default=2.0, help='Slope dependency of erosion')
- parser.add_argument('-ri', action='store_true', dest='rawin', default=False, help='use Blender raw format for input')
- parser.add_argument('-ro', action='store_true', dest='rawout', default=False, help='use Blender raw format for output')
- parser.add_argument('-i', action='store_true', dest='useinputfile', default=False, help='use an inputfile (instead of just a synthesized grid)')
- parser.add_argument('-t', action='store_true', dest='timingonly', default=False, help='do not write anything to an output file')
+ parser.add_argument(
+ '-ri',
+ action='store_true',
+ dest='rawin',
+ default=False,
+ help='use Blender raw format for input')
+ parser.add_argument(
+ '-ro',
+ action='store_true',
+ dest='rawout',
+ default=False,
+ help='use Blender raw format for output')
+ parser.add_argument('-i', action='store_true', dest='useinputfile', default=False,
+ help='use an inputfile (instead of just a synthesized grid)')
+ parser.add_argument(
+ '-t',
+ action='store_true',
+ dest='timingonly',
+ default=False,
+ help='do not write anything to an output file')
parser.add_argument('-infile', type=str, default="-", help='input filename')
parser.add_argument('-outfile', type=str, default="-", help='output filename')
parser.add_argument('-Gn', dest='gridsize', type=int, default=20, help='Gridsize (always square)')
parser.add_argument('-Gp', dest='gridpeak', type=float, default=0, help='Add peak with given height')
parser.add_argument('-Gs', dest='gridshelf', type=float, default=0, help='Add shelve with given height')
parser.add_argument('-Gm', dest='gridmesa', type=float, default=0, help='Add mesa with given height')
- parser.add_argument('-Gr', dest='gridrandom', type=float, default=0, help='Add random values between 0 and given value')
+ parser.add_argument('-Gr', dest='gridrandom', type=float, default=0,
+ help='Add random values between 0 and given value')
parser.add_argument('-m', dest='threads', type=int, default=1, help='number of threads to use')
parser.add_argument('-u', action='store_true', dest='unittest', default=False, help='perform unittests')
- parser.add_argument('-a', action='store_true', dest='analyze', default=False, help='show some statistics of input and output meshes')
- parser.add_argument('-d', action='store_true', dest='dump', default=False, help='show sediment and water meshes at end of run')
+ parser.add_argument('-a', action='store_true', dest='analyze', default=False,
+ help='show some statistics of input and output meshes')
+ parser.add_argument('-d', action='store_true', dest='dump', default=False,
+ help='show sediment and water meshes at end of run')
parser.add_argument('-n', action='store_true', dest='usenumexpr', default=False, help='use numexpr optimizations')
args = parser.parse_args()
print("\nInput arguments:")
- print("\n".join("%-15s: %s"%t for t in sorted(vars(args).items())), file=sys.stderr)
+ print("\n".join("%-15s: %s" % t for t in sorted(vars(args).items())), file=sys.stderr)
if args.unittest:
unittest.main(argv=[sys.argv[0]])
@@ -542,13 +564,17 @@ if __name__ == "__main__":
else:
grid = Grid(args.gridsize)
- if args.gridpeak > 0 : grid.peak(args.gridpeak)
- if args.gridmesa > 0 : grid.mesa(args.gridmesa)
- if args.gridshelf > 0 : grid.shelf(args.gridshelf)
- if args.gridrandom > 0 : grid.random(args.gridrandom)
+ if args.gridpeak > 0:
+ grid.peak(args.gridpeak)
+ if args.gridmesa > 0:
+ grid.mesa(args.gridmesa)
+ if args.gridshelf > 0:
+ grid.shelf(args.gridshelf)
+ if args.gridrandom > 0:
+ grid.random(args.gridrandom)
if args.analyze:
- print('\nstatistics of the input grid:\n\n', grid.analyze(), file=sys.stderr, sep='' )
+ print('\nstatistics of the input grid:\n\n', grid.analyze(), file=sys.stderr, sep='')
t = getptime()
for g in range(args.iterations):
if args.Kd > 0:
@@ -556,9 +582,20 @@ if __name__ == "__main__":
if args.Kh > 0 and args.Kp > rand():
grid.avalanche(args.Kh, args.usenumexpr)
if args.Kr > 0 or args.Kspring > 0:
- grid.fluvial_erosion(args.Kr, args.Kc, args.Ks, args.Kdep, args.Ka, args.Kspring, args.Kspringx, args.Kspringy, args.Kspringr, args.usenumexpr)
+ grid.fluvial_erosion(
+ args.Kr,
+ args.Kc,
+ args.Ks,
+ args.Kdep,
+ args.Ka,
+ args.Kspring,
+ args.Kspringx,
+ args.Kspringy,
+ args.Kspringr,
+ args.usenumexpr,
+ )
t = getptime() - t
- print("\nElapsed time: %.1f seconds, max memory %.1f Mb.\n"%(t,grid.maxrss), file=sys.stderr)
+ print("\nElapsed time: %.1f seconds, max memory %.1f Mb.\n" % (t, grid.maxrss), file=sys.stderr)
if args.analyze:
print('\nstatistics of the output grid:\n\n', grid.analyze(), file=sys.stderr, sep='')
@@ -569,6 +606,6 @@ if __name__ == "__main__":
grid.toFile(args.outfile)
if args.dump:
- print("sediment\n", np.array_str(grid.sediment,precision=3), file=sys.stderr)
- print("water\n", np.array_str(grid.water,precision=3), file=sys.stderr)
- print("sediment concentration\n", np.array_str(grid.sediment/grid.water,precision=3), file=sys.stderr)
+ print("sediment\n", np.array_str(grid.sediment, precision=3), file=sys.stderr)
+ print("water\n", np.array_str(grid.water, precision=3), file=sys.stderr)
+ print("sediment concentration\n", np.array_str(grid.sediment / grid.water, precision=3), file=sys.stderr)
diff --git a/ant_landscape/mesh_ant_displace.py b/ant_landscape/mesh_ant_displace.py
index 5638d96a..132ca6fe 100644
--- a/ant_landscape/mesh_ant_displace.py
+++ b/ant_landscape/mesh_ant_displace.py
@@ -7,24 +7,26 @@
# import modules
import bpy
from bpy.props import (
- BoolProperty,
- EnumProperty,
- FloatProperty,
- IntProperty,
- StringProperty,
- FloatVectorProperty,
- )
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ IntProperty,
+ StringProperty,
+ FloatVectorProperty,
+)
from .ant_functions import (
- draw_ant_refresh,
- draw_ant_main,
- draw_ant_noise,
- draw_ant_displace,
- )
+ draw_ant_refresh,
+ draw_ant_main,
+ draw_ant_noise,
+ draw_ant_displace,
+)
from .ant_noise import noise_gen
from ant_landscape import ant_noise
# ------------------------------------------------------------
# Do vert displacement
+
+
class AntMeshDisplace(bpy.types.Operator):
bl_idname = "mesh.ant_displace"
bl_label = "Another Noise Tool - Displace"
@@ -32,131 +34,131 @@ class AntMeshDisplace(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
ant_terrain_name: StringProperty(
- name="Name",
- default="Landscape"
- )
+ name="Name",
+ default="Landscape"
+ )
land_material: StringProperty(
- name='Material',
- default="",
- description="Terrain material"
- )
+ name='Material',
+ default="",
+ description="Terrain material"
+ )
water_material: StringProperty(
- name='Material',
- default="",
- description="Water plane material"
- )
+ name='Material',
+ default="",
+ description="Water plane material"
+ )
texture_block: StringProperty(
- name="Texture",
- default=""
- )
+ name="Texture",
+ default=""
+ )
at_cursor: BoolProperty(
- name="Cursor",
- default=True,
- description="Place at cursor location",
- )
+ name="Cursor",
+ default=True,
+ description="Place at cursor location",
+ )
smooth_mesh: BoolProperty(
- name="Smooth",
- default=True,
- description="Shade smooth"
- )
+ name="Smooth",
+ default=True,
+ description="Shade smooth"
+ )
tri_face: BoolProperty(
- name="Triangulate",
- default=False,
- description="Triangulate faces"
- )
+ name="Triangulate",
+ default=False,
+ description="Triangulate faces"
+ )
sphere_mesh: BoolProperty(
- name="Sphere",
- default=False,
- description="Generate uv sphere - remove doubles when ready"
- )
+ name="Sphere",
+ default=False,
+ description="Generate uv sphere - remove doubles when ready"
+ )
subdivision_x: IntProperty(
- name="Subdivisions X",
- default=128,
- min=4,
- max=6400,
- description="Mesh X subdivisions"
- )
+ name="Subdivisions X",
+ default=128,
+ min=4,
+ max=6400,
+ description="Mesh X subdivisions"
+ )
subdivision_y: IntProperty(
- default=128,
- name="Subdivisions Y",
- min=4,
- max=6400,
- description="Mesh Y subdivisions"
- )
+ default=128,
+ name="Subdivisions Y",
+ min=4,
+ max=6400,
+ description="Mesh Y subdivisions"
+ )
mesh_size: FloatProperty(
- default=2.0,
- name="Mesh Size",
- min=0.01,
- max=100000.0,
- description="Mesh size"
- )
+ default=2.0,
+ name="Mesh Size",
+ min=0.01,
+ max=100000.0,
+ description="Mesh size"
+ )
mesh_size_x: FloatProperty(
- default=2.0,
- name="Mesh Size X",
- min=0.01,
- description="Mesh x size"
- )
+ default=2.0,
+ name="Mesh Size X",
+ min=0.01,
+ description="Mesh x size"
+ )
mesh_size_y: FloatProperty(
- name="Mesh Size Y",
- default=2.0,
- min=0.01,
- description="Mesh y size"
- )
+ name="Mesh Size Y",
+ default=2.0,
+ min=0.01,
+ description="Mesh y size"
+ )
random_seed: IntProperty(
- name="Random Seed",
- default=0,
- min=0,
- description="Randomize noise origin"
- )
+ name="Random Seed",
+ default=0,
+ min=0,
+ description="Randomize noise origin"
+ )
noise_offset_x: FloatProperty(
- name="Offset X",
- default=0.0,
- description="Noise X Offset"
- )
+ name="Offset X",
+ default=0.0,
+ description="Noise X Offset"
+ )
noise_offset_y: FloatProperty(
- name="Offset Y",
- default=0.0,
- description="Noise Y Offset"
- )
+ name="Offset Y",
+ default=0.0,
+ description="Noise Y Offset"
+ )
noise_offset_z: FloatProperty(
- name="Offset Z",
- default=0.0,
- description="Noise Z Offset"
- )
+ name="Offset Z",
+ default=0.0,
+ description="Noise Z Offset"
+ )
noise_size_x: FloatProperty(
- default=1.0,
- name="Size X",
- min=0.01,
- max=1000.0,
- description="Noise x size"
- )
+ default=1.0,
+ name="Size X",
+ min=0.01,
+ max=1000.0,
+ description="Noise x size"
+ )
noise_size_y: FloatProperty(
- name="Size Y",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Noise y size"
- )
+ name="Size Y",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Noise y size"
+ )
noise_size_z: FloatProperty(
- name="Size Z",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Noise Z size"
- )
+ name="Size Z",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Noise Z size"
+ )
noise_size: FloatProperty(
- name="Noise Size",
- default=0.25,
- min=0.01,
- max=1000.0,
- description="Noise size"
- )
+ name="Noise Size",
+ default=0.25,
+ min=0.01,
+ max=1000.0,
+ description="Noise size"
+ )
noise_type: EnumProperty(
- name="Noise Type",
- default='hetero_terrain',
- description="Noise type",
- items = [
+ name="Noise Type",
+ default='hetero_terrain',
+ description="Noise type",
+ items=[
('multi_fractal', "Multi Fractal", "Blender: Multi Fractal algorithm", 0),
('ridged_multi_fractal', "Ridged MFractal", "Blender: Ridged Multi Fractal", 1),
('hybrid_multi_fractal', "Hybrid MFractal", "Blender: Hybrid Multi Fractal", 2),
@@ -176,110 +178,110 @@ class AntMeshDisplace(bpy.types.Operator):
('slick_rock', "Slick Rock", "A.N.T: slick rock", 16),
('planet_noise', "Planet Noise", "Planet Noise by: Farsthary", 17),
('blender_texture', "Blender Texture - Texture Nodes", "Blender texture data block", 18)]
- )
+ )
basis_type: EnumProperty(
- name="Noise Basis",
- default=ant_noise.noise_basis_default,
- description="Noise basis algorithms",
- items = ant_noise.noise_basis
- )
+ name="Noise Basis",
+ default=ant_noise.noise_basis_default,
+ description="Noise basis algorithms",
+ items=ant_noise.noise_basis
+ )
vl_basis_type: EnumProperty(
- name="vlNoise Basis",
- default=ant_noise.noise_basis_default,
- description="VLNoise basis algorithms",
- items = ant_noise.noise_basis
- )
+ name="vlNoise Basis",
+ default=ant_noise.noise_basis_default,
+ description="VLNoise basis algorithms",
+ items=ant_noise.noise_basis
+ )
distortion: FloatProperty(
- name="Distortion",
- default=1.0,
- min=0.01,
- max=100.0,
- description="Distortion amount"
- )
+ name="Distortion",
+ default=1.0,
+ min=0.01,
+ max=100.0,
+ description="Distortion amount"
+ )
hard_noise: EnumProperty(
- name="Soft Hard",
- default="0",
- description="Soft Noise, Hard noise",
- items = [
+ name="Soft Hard",
+ default="0",
+ description="Soft Noise, Hard noise",
+ items=[
("0", "Soft", "Soft Noise", 0),
("1", "Hard", "Hard noise", 1)]
- )
+ )
noise_depth: IntProperty(
- name="Depth",
- default=8,
- min=0,
- max=16,
- description="Noise Depth - number of frequencies in the fBm"
- )
+ name="Depth",
+ default=8,
+ min=0,
+ max=16,
+ description="Noise Depth - number of frequencies in the fBm"
+ )
amplitude: FloatProperty(
- name="Amp",
- default=0.5,
- min=0.01,
- max=1.0,
- description="Amplitude"
- )
+ name="Amp",
+ default=0.5,
+ min=0.01,
+ max=1.0,
+ description="Amplitude"
+ )
frequency: FloatProperty(
- name="Freq",
- default=2.0,
- min=0.01,
- max=5.0,
- description="Frequency"
- )
+ name="Freq",
+ default=2.0,
+ min=0.01,
+ max=5.0,
+ description="Frequency"
+ )
dimension: FloatProperty(
- name="Dimension",
- default=1.0,
- min=0.01,
- max=2.0,
- description="H - fractal dimension of the roughest areas"
- )
+ name="Dimension",
+ default=1.0,
+ min=0.01,
+ max=2.0,
+ description="H - fractal dimension of the roughest areas"
+ )
lacunarity: FloatProperty(
- name="Lacunarity",
- min=0.01,
- max=6.0,
- default=2.0,
- description="Lacunarity - gap between successive frequencies"
- )
+ name="Lacunarity",
+ min=0.01,
+ max=6.0,
+ default=2.0,
+ description="Lacunarity - gap between successive frequencies"
+ )
offset: FloatProperty(
- name="Offset",
- default=1.0,
- min=0.01,
- max=6.0,
- description="Offset - raises the terrain from sea level"
- )
+ name="Offset",
+ default=1.0,
+ min=0.01,
+ max=6.0,
+ description="Offset - raises the terrain from sea level"
+ )
gain: FloatProperty(
- name="Gain",
- default=1.0,
- min=0.01,
- max=6.0,
- description="Gain - scale factor"
- )
+ name="Gain",
+ default=1.0,
+ min=0.01,
+ max=6.0,
+ description="Gain - scale factor"
+ )
marble_bias: EnumProperty(
- name="Bias",
- default="0",
- description="Marble bias",
- items = [
+ name="Bias",
+ default="0",
+ description="Marble bias",
+ items=[
("0", "Sin", "Sin", 0),
("1", "Cos", "Cos", 1),
("2", "Tri", "Tri", 2),
("3", "Saw", "Saw", 3)]
- )
+ )
marble_sharp: EnumProperty(
- name="Sharp",
- default="0",
- description="Marble sharpness",
- items = [
+ name="Sharp",
+ default="0",
+ description="Marble sharpness",
+ items=[
("0", "Soft", "Soft", 0),
("1", "Sharp", "Sharp", 1),
("2", "Sharper", "Sharper", 2),
("3", "Soft inv.", "Soft", 3),
("4", "Sharp inv.", "Sharp", 4),
("5", "Sharper inv.", "Sharper", 5)]
- )
+ )
marble_shape: EnumProperty(
- name="Shape",
- default="0",
- description="Marble shape",
- items= [
+ name="Shape",
+ default="0",
+ description="Marble shape",
+ items=[
("0", "Default", "Default", 0),
("1", "Ring", "Ring", 1),
("2", "Swirl", "Swirl", 2),
@@ -288,39 +290,39 @@ class AntMeshDisplace(bpy.types.Operator):
("5", "Z", "Z", 5),
("6", "Y", "Y", 6),
("7", "X", "X", 7)]
- )
+ )
height: FloatProperty(
- name="Height",
- default=0.25,
- min=-10000.0,
- max=10000.0,
- description="Noise intensity scale"
- )
+ name="Height",
+ default=0.25,
+ min=-10000.0,
+ max=10000.0,
+ description="Noise intensity scale"
+ )
height_invert: BoolProperty(
- name="Invert",
- default=False,
- description="Height invert",
- )
+ name="Invert",
+ default=False,
+ description="Height invert",
+ )
height_offset: FloatProperty(
- name="Offset",
- default=0.0,
- min=-10000.0,
- max=10000.0,
- description="Height offset"
- )
+ name="Offset",
+ default=0.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Height offset"
+ )
fx_mixfactor: FloatProperty(
- name="Mix Factor",
- default=0.0,
- min=-1.0,
- max=1.0,
- description="Effect mix factor: -1.0 = Noise, +1.0 = Effect"
- )
+ name="Mix Factor",
+ default=0.0,
+ min=-1.0,
+ max=1.0,
+ description="Effect mix factor: -1.0 = Noise, +1.0 = Effect"
+ )
fx_mix_mode: EnumProperty(
- name="Effect Mix",
- default="0",
- description="Effect mix mode",
- items = [
+ name="Effect Mix",
+ default="0",
+ description="Effect mix mode",
+ items=[
("0", "Mix", "Mix", 0),
("1", "Add", "Add", 1),
("2", "Sub", "Subtract", 2),
@@ -330,13 +332,13 @@ class AntMeshDisplace(bpy.types.Operator):
("6", "Mod", "Modulo", 6),
("7", "Min", "Minimum", 7),
("8", "Max", "Maximum", 8)
- ]
- )
+ ]
+ )
fx_type: EnumProperty(
- name="Effect Type",
- default="0",
- description="Effect type",
- items = [
+ name="Effect Type",
+ default="0",
+ description="Effect type",
+ items=[
("0", "None", "No effect", 0),
("1", "Gradient", "Gradient", 1),
("2", "Waves", "Waves - Bumps", 2),
@@ -359,223 +361,220 @@ class AntMeshDisplace(bpy.types.Operator):
("19", "Stone", "Stone", 19),
("20", "Flat Turb", "Flat turbulence", 20),
("21", "Flat Voronoi", "Flat voronoi", 21)
- ]
- )
+ ]
+ )
fx_bias: EnumProperty(
- name="Effect Bias",
- default="0",
- description="Effect bias type",
- items = [
+ name="Effect Bias",
+ default="0",
+ description="Effect bias type",
+ items=[
("0", "Sin", "Sin", 0),
("1", "Cos", "Cos", 1),
("2", "Tri", "Tri", 2),
("3", "Saw", "Saw", 3),
("4", "None", "None", 4)
- ]
- )
+ ]
+ )
fx_turb: FloatProperty(
- name="Distortion",
- default=0.0,
- min=0.0,
- max=1000.0,
- description="Effect turbulence distortion"
- )
+ name="Distortion",
+ default=0.0,
+ min=0.0,
+ max=1000.0,
+ description="Effect turbulence distortion"
+ )
fx_depth: IntProperty(
- name="Depth",
- default=0,
- min=0,
- max=16,
- description="Effect depth - number of frequencies"
- )
+ name="Depth",
+ default=0,
+ min=0,
+ max=16,
+ description="Effect depth - number of frequencies"
+ )
fx_amplitude: FloatProperty(
- name="Amp",
- default=0.5,
- min=0.01,
- max=1.0,
- description="Amplitude"
- )
+ name="Amp",
+ default=0.5,
+ min=0.01,
+ max=1.0,
+ description="Amplitude"
+ )
fx_frequency: FloatProperty(
- name="Freq",
- default=2.0,
- min=0.01,
- max=5.0,
- description="Frequency"
- )
+ name="Freq",
+ default=2.0,
+ min=0.01,
+ max=5.0,
+ description="Frequency"
+ )
fx_size: FloatProperty(
- name="Effect Size",
- default=1.0,
- min=0.01,
- max=1000.0,
- description="Effect size"
- )
+ name="Effect Size",
+ default=1.0,
+ min=0.01,
+ max=1000.0,
+ description="Effect size"
+ )
fx_loc_x: FloatProperty(
- name="Offset X",
- default=0.0,
- description="Effect x offset"
- )
+ name="Offset X",
+ default=0.0,
+ description="Effect x offset"
+ )
fx_loc_y: FloatProperty(
- name="Offset Y",
- default=0.0,
- description="Effect y offset"
- )
+ name="Offset Y",
+ default=0.0,
+ description="Effect y offset"
+ )
fx_height: FloatProperty(
- name="Intensity",
- default=1.0,
- min=-1000.0,
- max=1000.0,
- description="Effect intensity scale"
- )
+ name="Intensity",
+ default=1.0,
+ min=-1000.0,
+ max=1000.0,
+ description="Effect intensity scale"
+ )
fx_invert: BoolProperty(
- name="Invert",
- default=False,
- description="Effect invert"
- )
+ name="Invert",
+ default=False,
+ description="Effect invert"
+ )
fx_offset: FloatProperty(
- name="Offset",
- default=0.0,
- min=-1000.0,
- max=1000.0,
- description="Effect height offset"
- )
+ name="Offset",
+ default=0.0,
+ min=-1000.0,
+ max=1000.0,
+ description="Effect height offset"
+ )
edge_falloff: EnumProperty(
- name="Falloff",
- default="0",
- description="Flatten edges",
- items = [
+ name="Falloff",
+ default="0",
+ description="Flatten edges",
+ items=[
("0", "None", "None", 0),
("1", "Y", "Y Falloff", 1),
("2", "X", "X Falloff", 2),
("3", "X Y", "X Y Falloff", 3)]
- )
+ )
falloff_x: FloatProperty(
- name="Falloff X",
- default=4.0,
- min=0.1,
- max=100.0,
- description="Falloff x scale"
- )
+ name="Falloff X",
+ default=4.0,
+ min=0.1,
+ max=100.0,
+ description="Falloff x scale"
+ )
falloff_y: FloatProperty(
- name="Falloff Y",
- default=4.0,
- min=0.1,
- max=100.0,
- description="Falloff y scale"
- )
+ name="Falloff Y",
+ default=4.0,
+ min=0.1,
+ max=100.0,
+ description="Falloff y scale"
+ )
edge_level: FloatProperty(
- name="Edge Level",
- default=0.0,
- min=-10000.0,
- max=10000.0,
- description="Edge level, sealevel offset"
- )
+ name="Edge Level",
+ default=0.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Edge level, sealevel offset"
+ )
maximum: FloatProperty(
- name="Maximum",
- default=1.0,
- min=-10000.0,
- max=10000.0,
- description="Maximum, flattens terrain at plateau level"
- )
+ name="Maximum",
+ default=1.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Maximum, flattens terrain at plateau level"
+ )
minimum: FloatProperty(
- name="Minimum",
- default=-1.0,
- min=-10000.0,
- max=10000.0,
- description="Minimum, flattens terrain at seabed level"
- )
+ name="Minimum",
+ default=-1.0,
+ min=-10000.0,
+ max=10000.0,
+ description="Minimum, flattens terrain at seabed level"
+ )
vert_group: StringProperty(
- name="Vertex Group",
- default=""
- )
+ name="Vertex Group",
+ default=""
+ )
strata: FloatProperty(
- name="Amount",
- default=5.0,
- min=0.01,
- max=1000.0,
- description="Strata layers / terraces"
- )
+ name="Amount",
+ default=5.0,
+ min=0.01,
+ max=1000.0,
+ description="Strata layers / terraces"
+ )
strata_type: EnumProperty(
- name="Strata",
- default="0",
- description="Strata types",
- items = [
+ name="Strata",
+ default="0",
+ description="Strata types",
+ items=[
("0", "None", "No strata", 0),
("1", "Smooth", "Smooth transitions", 1),
("2", "Sharp Sub", "Sharp subtract transitions", 2),
("3", "Sharp Add", "Sharp add transitions", 3),
("4", "Quantize", "Quantize", 4),
("5", "Quantize Mix", "Quantize mixed", 5)]
- )
+ )
water_plane: BoolProperty(
- name="Water Plane",
- default=False,
- description="Add water plane"
- )
+ name="Water Plane",
+ default=False,
+ description="Add water plane"
+ )
water_level: FloatProperty(
- name="Level",
- default=0.01,
- min=-10000.0,
- max=10000.0,
- description="Water level"
- )
+ name="Level",
+ default=0.01,
+ min=-10000.0,
+ max=10000.0,
+ description="Water level"
+ )
remove_double: BoolProperty(
- name="Remove Doubles",
- default=False,
- description="Remove doubles"
- )
+ name="Remove Doubles",
+ default=False,
+ description="Remove doubles"
+ )
direction: EnumProperty(
- name="Direction",
- default="NORMAL",
- description="Displacement direction",
- items = [
+ name="Direction",
+ default="NORMAL",
+ description="Displacement direction",
+ items=[
("NORMAL", "Normal", "Displace along vertex normal direction", 0),
("Z", "Z", "Displace in the Z direction", 1),
("Y", "Y", "Displace in the Y direction", 2),
("X", "X", "Displace in the X direction", 3)]
- )
+ )
show_main_settings: BoolProperty(
- name="Main Settings",
- default=True,
- description="Show settings"
- )
+ name="Main Settings",
+ default=True,
+ description="Show settings"
+ )
show_noise_settings: BoolProperty(
- name="Noise Settings",
- default=True,
- description="Show noise settings"
- )
+ name="Noise Settings",
+ default=True,
+ description="Show noise settings"
+ )
show_displace_settings: BoolProperty(
- name="Displace Settings",
- default=True,
- description="Show terrain settings"
- )
+ name="Displace Settings",
+ default=True,
+ description="Show terrain settings"
+ )
refresh: BoolProperty(
- name="Refresh",
- default=False,
- description="Refresh"
- )
+ name="Refresh",
+ default=False,
+ description="Refresh"
+ )
auto_refresh: BoolProperty(
- name="Auto",
- default=False,
- description="Automatic refresh"
- )
+ name="Auto",
+ default=False,
+ description="Automatic refresh"
+ )
def draw(self, context):
draw_ant_refresh(self, context)
draw_ant_noise(self, context, generate=False)
draw_ant_displace(self, context, generate=False)
-
@classmethod
def poll(cls, context):
ob = context.object
return (ob and ob.type == 'MESH')
-
def invoke(self, context, event):
self.refresh = True
return self.execute(context)
-
def execute(self, context):
if not self.refresh:
return {'PASS_THROUGH'}
@@ -649,7 +648,7 @@ class AntMeshDisplace(bpy.types.Operator):
self.fx_height,
self.fx_offset,
self.fx_invert
- ]
+ ]
# do displace
mesh = ob.data
diff --git a/ant_landscape/stats.py b/ant_landscape/stats.py
index c8793dd9..b217a7b0 100644
--- a/ant_landscape/stats.py
+++ b/ant_landscape/stats.py
@@ -5,15 +5,16 @@ from time import time
try:
import psutil
# print('psutil available')
- psutil_available=True
+ psutil_available = True
except ImportError:
- psutil_available=False
+ psutil_available = False
+
class Stats:
def __init__(self):
self.memstats_available = False
if psutil_available:
- self.process=psutil.Process()
+ self.process = psutil.Process()
self.memstats_available = True
self.reset()
diff --git a/ant_landscape/test.py b/ant_landscape/test.py
index 39d060c4..65e641bd 100644
--- a/ant_landscape/test.py
+++ b/ant_landscape/test.py
@@ -18,6 +18,6 @@ if __name__ == '__main__':
a = cos(a)
print(stats.time())
print(stats.memory())
- a = cos(a)**2+sin(a)**2
+ a = cos(a) ** 2 + sin(a) ** 2
print(stats.time())
print(stats.memory())
diff --git a/ant_landscape/utils.py b/ant_landscape/utils.py
index 7687bd54..9451f83a 100644
--- a/ant_landscape/utils.py
+++ b/ant_landscape/utils.py
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: GPL-2.0-or-later
-numexpr_available=False
+numexpr_available = False
try:
import numexpr
- numexpr_available=True
+ numexpr_available = True
except ImportError:
pass