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:
-rw-r--r--add_camera_rigs/__init__.py4
-rw-r--r--add_camera_rigs/operators.py28
-rw-r--r--add_camera_rigs/ui_panels.py33
-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
-rw-r--r--archimesh/__init__.py4
-rw-r--r--archimesh/achm_gltools.py24
-rw-r--r--archimesh/achm_main_panel.py1
-rw-r--r--io_mesh_uv_layout/__init__.py10
-rw-r--r--io_mesh_uv_layout/export_uv_eps.py6
-rw-r--r--io_mesh_uv_layout/export_uv_png.py30
-rw-r--r--io_mesh_uv_layout/export_uv_svg.py6
-rw-r--r--measureit/__init__.py4
-rw-r--r--measureit/measureit_geometry.py7
-rw-r--r--measureit/measureit_main.py9
-rw-r--r--measureit/measureit_render.py10
-rw-r--r--mesh_tissue/weight_tools.py6
-rw-r--r--object_scatter/__init__.py4
-rw-r--r--object_scatter/operator.py11
-rwxr-xr-xpower_sequencer/__init__.py9
-rw-r--r--power_sequencer/addon_preferences.py5
-rw-r--r--power_sequencer/addon_properties.py9
-rw-r--r--power_sequencer/handlers.py40
-rwxr-xr-xpower_sequencer/operators/__init__.py7
-rw-r--r--power_sequencer/operators/channel_offset.py14
-rw-r--r--power_sequencer/operators/concatenate_strips.py5
-rw-r--r--power_sequencer/operators/copy_selected_sequences.py5
-rw-r--r--power_sequencer/operators/crossfade_add.py7
-rw-r--r--power_sequencer/operators/crossfade_edit.py5
-rw-r--r--power_sequencer/operators/cut_strips_under_cursor.py5
-rw-r--r--power_sequencer/operators/delete_direct.py5
-rw-r--r--power_sequencer/operators/deselect_all_left_or_right.py5
-rw-r--r--power_sequencer/operators/deselect_handles_and_grab.py5
-rw-r--r--power_sequencer/operators/duplicate_move.py5
-rw-r--r--power_sequencer/operators/expand_to_surrounding_cuts.py11
-rw-r--r--power_sequencer/operators/fade_add.py12
-rw-r--r--power_sequencer/operators/fade_clear.py11
-rw-r--r--power_sequencer/operators/gap_remove.py5
-rw-r--r--power_sequencer/operators/grab.py5
-rw-r--r--power_sequencer/operators/grab_closest_handle_or_cut.py5
-rw-r--r--power_sequencer/operators/grab_sequence_handles.py9
-rw-r--r--power_sequencer/operators/import_local_footage.py5
-rw-r--r--power_sequencer/operators/jump_time_offset.py5
-rw-r--r--power_sequencer/operators/jump_to_cut.py62
-rw-r--r--power_sequencer/operators/make_hold_frame.py5
-rw-r--r--power_sequencer/operators/marker_delete_closest.py5
-rw-r--r--power_sequencer/operators/marker_delete_direct.py5
-rw-r--r--power_sequencer/operators/marker_snap_to_cursor.py5
-rw-r--r--power_sequencer/operators/markers_as_timecodes.py5
-rw-r--r--power_sequencer/operators/markers_create_from_selected.py5
-rw-r--r--power_sequencer/operators/markers_set_preview_in_between.py5
-rw-r--r--power_sequencer/operators/markers_snap_matching_strips.py5
-rw-r--r--power_sequencer/operators/meta_resize_to_content.py5
-rw-r--r--power_sequencer/operators/meta_trim_content_to_bounds.py5
-rw-r--r--power_sequencer/operators/meta_ungroup_and_trim.py5
-rw-r--r--power_sequencer/operators/mouse_toggle_mute.py5
-rw-r--r--power_sequencer/operators/mouse_trim_instantly.py5
-rw-r--r--power_sequencer/operators/mouse_trim_modal.py16
-rw-r--r--power_sequencer/operators/open_project_directory.py5
-rw-r--r--power_sequencer/operators/playback_speed_decrease.py52
-rw-r--r--power_sequencer/operators/playback_speed_increase.py52
-rw-r--r--power_sequencer/operators/playback_speed_set.py17
-rw-r--r--power_sequencer/operators/preview_closest_cut.py5
-rw-r--r--power_sequencer/operators/preview_to_selection.py5
-rw-r--r--power_sequencer/operators/render_apply_preset.py5
-rw-r--r--power_sequencer/operators/render_presets/twitter_720p.py5
-rw-r--r--power_sequencer/operators/render_presets/youtube_1080.py5
-rw-r--r--power_sequencer/operators/ripple_delete.py5
-rw-r--r--power_sequencer/operators/save_direct.py5
-rw-r--r--power_sequencer/operators/scene_create_from_selection.py5
-rw-r--r--power_sequencer/operators/scene_cycle.py5
-rw-r--r--power_sequencer/operators/scene_merge_from.py5
-rw-r--r--power_sequencer/operators/scene_open_from_strip.py5
-rw-r--r--power_sequencer/operators/scene_rename_with_strip.py5
-rw-r--r--power_sequencer/operators/select_all_left_or_right.py13
-rw-r--r--power_sequencer/operators/select_closest_to_mouse.py5
-rw-r--r--power_sequencer/operators/select_linked_effect.py5
-rw-r--r--power_sequencer/operators/select_linked_strips.py5
-rw-r--r--power_sequencer/operators/select_related_strips.py5
-rw-r--r--power_sequencer/operators/select_strips_under_cursor.py5
-rw-r--r--power_sequencer/operators/set_timeline_range.py5
-rw-r--r--power_sequencer/operators/snap.py11
-rw-r--r--power_sequencer/operators/snap_selection.py11
-rw-r--r--power_sequencer/operators/space_sequences.py5
-rw-r--r--power_sequencer/operators/speed_remove_effect.py5
-rw-r--r--power_sequencer/operators/speed_up_movie_strip.py23
-rw-r--r--power_sequencer/operators/swap_strips.py5
-rw-r--r--power_sequencer/operators/toggle_selected_mute.py5
-rw-r--r--power_sequencer/operators/toggle_waveforms.py5
-rw-r--r--power_sequencer/operators/transitions_remove.py5
-rw-r--r--power_sequencer/operators/trim_left_or_right_handles.py5
-rw-r--r--power_sequencer/operators/trim_three_point_edit.py5
-rw-r--r--power_sequencer/operators/trim_to_surrounding_cuts.py5
-rw-r--r--power_sequencer/operators/utils/__init__.py4
-rw-r--r--power_sequencer/operators/utils/doc.py5
-rw-r--r--power_sequencer/operators/utils/draw.py5
-rw-r--r--power_sequencer/operators/utils/functions.py31
-rw-r--r--power_sequencer/operators/utils/global_settings.py5
-rw-r--r--power_sequencer/operators/utils/info_progress_bar.py5
-rw-r--r--power_sequencer/operators/value_offset.py10
-rw-r--r--power_sequencer/tools/__init__.py7
-rw-r--r--power_sequencer/tools/trim.py5
-rw-r--r--power_sequencer/ui/__init__.py5
-rw-r--r--power_sequencer/ui/menu_contextual.py5
-rwxr-xr-xpower_sequencer/ui/menu_toolbar.py5
-rw-r--r--power_sequencer/utils/addon_auto_imports.py5
-rw-r--r--power_sequencer/utils/register_shortcuts.py5
-rw-r--r--precision_drawing_tools/__init__.py2
-rw-r--r--precision_drawing_tools/pdt_functions.py3
-rw-r--r--space_view3d_math_vis/__init__.py4
-rw-r--r--space_view3d_math_vis/draw.py5
-rw-r--r--viewport_vr_preview/__init__.py2
-rw-r--r--viewport_vr_preview/operators.py13
120 files changed, 2061 insertions, 2325 deletions
diff --git a/add_camera_rigs/__init__.py b/add_camera_rigs/__init__.py
index 878d4555..cbf83d95 100644
--- a/add_camera_rigs/__init__.py
+++ b/add_camera_rigs/__init__.py
@@ -3,8 +3,8 @@
bl_info = {
"name": "Add Camera Rigs",
"author": "Wayne Dixon, Brian Raschko, Kris Wittig, Damien Picard, Flavio Perez",
- "version": (1, 4, 4),
- "blender": (2, 80, 0),
+ "version": (1, 5, 0),
+ "blender": (3, 3, 0),
"location": "View3D > Add > Camera > Dolly or Crane Rig",
"description": "Adds a Camera Rig with UI",
"doc_url": "{BLENDER_MANUAL_URL}/addons/camera/camera_rigs.html",
diff --git a/add_camera_rigs/operators.py b/add_camera_rigs/operators.py
index 18300e08..29e77e3b 100644
--- a/add_camera_rigs/operators.py
+++ b/add_camera_rigs/operators.py
@@ -73,30 +73,16 @@ class ADD_CAMERA_RIGS_OT_add_marker_bind(Operator, CameraRigMixin):
return {'FINISHED'}
-class ADD_CAMERA_RIGS_OT_add_dof_object(Operator, CameraRigMixin):
- bl_idname = "add_camera_rigs.add_dof_object"
- bl_label = "Add DOF Object"
- bl_description = "Create Empty and add as DOF Object"
+class ADD_CAMERA_RIGS_OT_set_dof_bone(Operator, CameraRigMixin):
+ bl_idname = "add_camera_rigs.set_dof_bone"
+ bl_label = "Set DOF Bone"
+ bl_description = "Set the Aim bone as a DOF target"
def execute(self, context):
rig, cam = get_rig_and_cam(context.active_object)
- bone = rig.data.bones['Aim_shape_rotation-MCH']
- # Add Empty
- empty_obj = bpy.data.objects.new("EmptyDOF", None)
- context.scene.collection.objects.link(empty_obj)
-
- # Parent to Aim Child bone
- empty_obj.parent = rig
- empty_obj.parent_type = "BONE"
- empty_obj.parent_bone = "Aim_shape_rotation-MCH"
-
- # Move to bone head
- empty_obj.location = bone.head
-
- # Make this new empty the dof_object
- cam.data.dof.use_dof = True
- cam.data.dof.focus_object = empty_obj
+ cam.data.dof.focus_object = rig
+ cam.data.dof.focus_subtarget = 'Aim_shape_rotation-MCH'
return {'FINISHED'}
@@ -104,7 +90,7 @@ class ADD_CAMERA_RIGS_OT_add_dof_object(Operator, CameraRigMixin):
classes = (
ADD_CAMERA_RIGS_OT_set_scene_camera,
ADD_CAMERA_RIGS_OT_add_marker_bind,
- ADD_CAMERA_RIGS_OT_add_dof_object,
+ ADD_CAMERA_RIGS_OT_set_dof_bone,
)
diff --git a/add_camera_rigs/ui_panels.py b/add_camera_rigs/ui_panels.py
index c6066147..5d545d3a 100644
--- a/add_camera_rigs/ui_panels.py
+++ b/add_camera_rigs/ui_panels.py
@@ -32,20 +32,23 @@ class ADD_CAMERA_RIGS_PT_camera_rig_ui(Panel, CameraRigMixin):
layout.prop(cam_data, "type")
# DoF
- col = layout.column(align=True)
+ col = layout.column(align=False)
col.prop(cam_data.dof, "use_dof")
if cam_data.dof.use_dof:
- if rig["rig_id"].lower() in ("crane_rig", "dolly_rig"):
- if cam_data.dof.focus_object is None:
- col.operator("add_camera_rigs.add_dof_object",
- text="Add DOF Empty", icon="OUTLINER_OB_EMPTY")
- else:
- col.prop(cam_data.dof, "focus_object")
- row = col.row(align=True)
+ sub = col.column(align=True)
+ if cam_data.dof.focus_object is None:
+ sub.operator("add_camera_rigs.set_dof_bone")
+ sub.prop(cam_data.dof, "focus_object")
+ if (cam_data.dof.focus_object is not None
+ and cam_data.dof.focus_object.type == 'ARMATURE'):
+ sub.prop_search(cam_data.dof, "focus_subtarget",
+ cam_data.dof.focus_object.data, "bones")
+ sub = col.column(align=True)
+ row = sub.row(align=True)
row.active = cam_data.dof.focus_object is None
row.prop(pose_bones["Camera"],
'["focus_distance"]', text="Focus Distance")
- col.prop(pose_bones["Camera"],
+ sub.prop(pose_bones["Camera"],
'["aperture_fstop"]', text="F-Stop")
# Viewport display
@@ -74,9 +77,15 @@ class ADD_CAMERA_RIGS_PT_camera_rig_ui(Panel, CameraRigMixin):
if rig["rig_id"].lower() in ("dolly_rig", "crane_rig"):
# Track to Constraint
col = layout.column(align=True)
- col.label(text="Tracking:")
- col.prop(pose_bones["Camera"].constraints["Track To"],
- 'influence', text="Aim Lock", slider=True)
+ track_to_constraint = None
+ for con in pose_bones["Camera"].constraints:
+ if con.type == 'TRACK_TO':
+ track_to_constraint = con
+ break
+ if track_to_constraint is not None:
+ col.label(text="Tracking:")
+ col.prop(track_to_constraint, 'influence',
+ text="Aim Lock", slider=True)
# Crane arm stuff
if rig["rig_id"].lower() == "crane_rig":
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
diff --git a/archimesh/__init__.py b/archimesh/__init__.py
index 261397f1..d79e02f7 100644
--- a/archimesh/__init__.py
+++ b/archimesh/__init__.py
@@ -11,8 +11,8 @@ bl_info = {
"name": "Archimesh",
"author": "Antonio Vazquez (antonioya)",
"location": "View3D > Add Mesh / Sidebar > Create Tab",
- "version": (1, 2, 2),
- "blender": (2, 80, 0),
+ "version": (1, 2, 3),
+ "blender": (3, 0, 0),
"description": "Generate rooms, doors, windows, and other architecture objects",
"doc_url": "{BLENDER_MANUAL_URL}/addons/add_mesh/archimesh.html",
"category": "Add Mesh"
diff --git a/archimesh/achm_gltools.py b/archimesh/achm_gltools.py
index de11226d..00160989 100644
--- a/archimesh/achm_gltools.py
+++ b/archimesh/achm_gltools.py
@@ -16,7 +16,6 @@ from mathutils import Vector
from bpy_extras import view3d_utils
from .achm_room_maker import get_wall_points
# GPU
-import bgl
import gpu
from gpu_extras.batch import batch_for_shader
@@ -39,7 +38,7 @@ def draw_main(context):
measure = scene.archimesh_gl_measure
dspname = scene.archimesh_gl_name
- bgl.glEnable(bgl.GL_BLEND)
+ gpu.state.blend_set('ALPHA')
# Display selected or all
if scene.archimesh_gl_ghost is False:
objlist = context.selected_objects
@@ -81,8 +80,8 @@ def draw_main(context):
# -----------------------
# restore opengl defaults
# -----------------------
- bgl.glLineWidth(1)
- bgl.glDisable(bgl.GL_BLEND)
+ gpu.state.line_width_set(1.0)
+ gpu.state.blend_set('NONE')
# -------------------------------------------------------------
@@ -175,8 +174,8 @@ def draw_room_data(myobj, op, region, rv3d, rgba, rgbaw, fsize, wfsize, space, m
screen_point_b2 = view3d_utils.location_3d_to_region_2d(region, rv3d, b2_s2)
# colour + line setup
- bgl.glEnable(bgl.GL_BLEND)
- bgl.glLineWidth(1)
+ gpu.state.blend_set('ALPHA')
+ gpu.state.line_width_set(1.0)
# --------------------------------
# Measures
# --------------------------------
@@ -284,8 +283,8 @@ def draw_door_data(myobj, op, region, rv3d, rgba, fsize, space, measure):
screen_point_ep3 = view3d_utils.location_3d_to_region_2d(region, rv3d, e_p3)
# colour + line setup
- bgl.glEnable(bgl.GL_BLEND)
- bgl.glLineWidth(1)
+ gpu.state.blend_set('ALPHA')
+ gpu.state.line_width_set(1.0)
# --------------------------------
# Measures
@@ -368,8 +367,8 @@ def draw_window_rail_data(myobj, op, region, rv3d, rgba, fsize, space, measure):
screen_point_tp3 = view3d_utils.location_3d_to_region_2d(region, rv3d, t_p3)
# colour + line setup
- bgl.glEnable(bgl.GL_BLEND)
- bgl.glLineWidth(1)
+ gpu.state.blend_set('ALPHA')
+ gpu.state.line_width_set(1.0)
# --------------------------------
# Measures
@@ -473,9 +472,10 @@ def draw_window_panel_data(myobj, op, region, rv3d, rgba, fsize, space, measure)
screen_point_gp3 = view3d_utils.location_3d_to_region_2d(region, rv3d, g_p3)
screen_point_gp4 = view3d_utils.location_3d_to_region_2d(region, rv3d, g_p4)
screen_point_gp5 = view3d_utils.location_3d_to_region_2d(region, rv3d, g_p5)
+
# colour + line setup
- bgl.glEnable(bgl.GL_BLEND)
- bgl.glLineWidth(1)
+ gpu.state.blend_set('ALPHA')
+ gpu.state.line_width_set(1.0)
# --------------------------------
# Measures
diff --git a/archimesh/achm_main_panel.py b/archimesh/achm_main_panel.py
index 97c7d19d..fda383f4 100644
--- a/archimesh/achm_main_panel.py
+++ b/archimesh/achm_main_panel.py
@@ -8,7 +8,6 @@
# noinspection PyUnresolvedReferences
import bpy
# noinspection PyUnresolvedReferences
-import bgl
from bpy.types import Operator, Panel, SpaceView3D
from math import sqrt, fabs, pi, asin
from .achm_tools import *
diff --git a/io_mesh_uv_layout/__init__.py b/io_mesh_uv_layout/__init__.py
index ceb5ddbc..40d9b501 100644
--- a/io_mesh_uv_layout/__init__.py
+++ b/io_mesh_uv_layout/__init__.py
@@ -3,7 +3,7 @@
bl_info = {
"name": "UV Layout",
"author": "Campbell Barton, Matt Ebb",
- "version": (1, 1, 2),
+ "version": (1, 1, 3),
"blender": (3, 0, 0),
"location": "Image-Window > UVs > Export UV Layout",
"description": "Export the UV layout as a 2D graphic",
@@ -128,10 +128,10 @@ class ExportUVLayout(bpy.types.Operator):
polygon_data = list(self.iter_polygon_data_to_draw(context, meshes))
different_colors = set(color for _, color in polygon_data)
if self.modified:
- depsgraph = context.evaluated_depsgraph_get()
- for obj in self.iter_objects_to_export(context):
- obj_eval = obj.evaluated_get(depsgraph)
- obj_eval.to_mesh_clear()
+ depsgraph = context.evaluated_depsgraph_get()
+ for obj in self.iter_objects_to_export(context):
+ obj_eval = obj.evaluated_get(depsgraph)
+ obj_eval.to_mesh_clear()
export = self.get_exporter()
export(filepath, polygon_data, different_colors, self.size[0], self.size[1], self.opacity)
diff --git a/io_mesh_uv_layout/export_uv_eps.py b/io_mesh_uv_layout/export_uv_eps.py
index 04b8a38e..9e013e13 100644
--- a/io_mesh_uv_layout/export_uv_eps.py
+++ b/io_mesh_uv_layout/export_uv_eps.py
@@ -8,6 +8,7 @@ def export(filepath, face_data, colors, width, height, opacity):
for text in get_file_parts(face_data, colors, width, height, opacity):
file.write(text)
+
def get_file_parts(face_data, colors, width, height, opacity):
yield from header(width, height)
if opacity > 0.0:
@@ -35,6 +36,7 @@ def header(width, height):
yield "1 setlinejoin\n"
yield "1 setlinecap\n"
+
def prepare_colors(colors, out_name_by_color):
for i, color in enumerate(colors):
name = f"COLOR_{i}"
@@ -48,18 +50,21 @@ def prepare_colors(colors, out_name_by_color):
yield "0 setgray\n"
yield "} def\n"
+
def draw_colored_polygons(face_data, name_by_color, width, height):
for uvs, color in face_data:
yield from draw_polygon_path(uvs, width, height)
yield "closepath\n"
yield "%s\n" % name_by_color[color]
+
def draw_lines(face_data, width, height):
for uvs, _ in face_data:
yield from draw_polygon_path(uvs, width, height)
yield "closepath\n"
yield "stroke\n"
+
def draw_polygon_path(uvs, width, height):
yield "newpath\n"
for j, uv in enumerate(uvs):
@@ -69,6 +74,7 @@ def draw_polygon_path(uvs, width, height):
else:
yield "%.5f %.5f lineto\n" % uv_scale
+
def footer():
yield "showpage\n"
yield "%%EOF\n"
diff --git a/io_mesh_uv_layout/export_uv_png.py b/io_mesh_uv_layout/export_uv_png.py
index 78f9f6a2..b051c980 100644
--- a/io_mesh_uv_layout/export_uv_png.py
+++ b/io_mesh_uv_layout/export_uv_png.py
@@ -6,6 +6,7 @@ from mathutils import Vector, Matrix
from mathutils.geometry import tessellate_polygon
from gpu_extras.batch import batch_for_shader
+
def export(filepath, face_data, colors, width, height, opacity):
offscreen = gpu.types.GPUOffScreen(width, height)
offscreen.bind()
@@ -22,6 +23,7 @@ def export(filepath, face_data, colors, width, height, opacity):
offscreen.unbind()
offscreen.free()
+
def draw_image(face_data, opacity):
gpu.state.blend_set('ALPHA_PREMULT')
@@ -34,6 +36,7 @@ def draw_image(face_data, opacity):
gpu.state.blend_set('NONE')
+
def get_normalize_uvs_matrix():
'''matrix maps x and y coordinates from [0, 1] to [-1, 1]'''
matrix = Matrix.Identity(4)
@@ -43,6 +46,7 @@ def get_normalize_uvs_matrix():
matrix[1][1] = 2
return matrix
+
def draw_background_colors(face_data, opacity):
coords = [uv for uvs, _ in face_data for uv in uvs]
colors = [(*color, opacity) for uvs, color in face_data for _ in range(len(uvs))]
@@ -55,33 +59,39 @@ def draw_background_colors(face_data, opacity):
offset += len(uvs)
shader = gpu.shader.from_builtin('2D_FLAT_COLOR')
- batch = batch_for_shader(shader, 'TRIS',
- {"pos" : coords,
- "color" : colors},
- indices=indices)
+ batch = batch_for_shader(
+ shader, 'TRIS',
+ {"pos": coords, "color": colors},
+ indices=indices,
+ )
batch.draw(shader)
+
def tessellate_uvs(uvs):
return tessellate_polygon([uvs])
+
def draw_lines(face_data):
coords = []
for uvs, _ in face_data:
for i in range(len(uvs)):
start = uvs[i]
- end = uvs[(i+1) % len(uvs)]
- coords.append((start[0], start[1], 0.0))
- coords.append((end[0], end[1], 0.0))
-
- # Use '2D_UNIFORM_COLOR' if smooth lines are not required.
+ end = uvs[(i + 1) % len(uvs)]
+ coords.append((start[0], start[1]))
+ coords.append((end[0], end[1]))
+
+ # Use '2D_UNIFORM_COLOR' in the `batch_for_shader` so we don't need to
+ # convert the coordinates to 3D as in the case of
+ # '3D_POLYLINE_UNIFORM_COLOR'.
+ batch = batch_for_shader(gpu.shader.from_builtin('2D_UNIFORM_COLOR'), 'LINES', {"pos": coords})
shader = gpu.shader.from_builtin('3D_POLYLINE_UNIFORM_COLOR')
- batch = batch_for_shader(shader, 'LINES', {"pos" : coords})
shader.bind()
shader.uniform_float("viewportSize", gpu.state.viewport_get()[2:])
shader.uniform_float("lineWidth", 0.5)
shader.uniform_float("color", (0, 0, 0, 1))
batch.draw(shader)
+
def save_pixels(filepath, pixel_data, width, height):
image = bpy.data.images.new("temp", width, height, alpha=True)
image.filepath = filepath
diff --git a/io_mesh_uv_layout/export_uv_svg.py b/io_mesh_uv_layout/export_uv_svg.py
index d8e2b5a4..a4b6a3c3 100644
--- a/io_mesh_uv_layout/export_uv_svg.py
+++ b/io_mesh_uv_layout/export_uv_svg.py
@@ -4,16 +4,19 @@ import bpy
from os.path import basename
from xml.sax.saxutils import escape
+
def export(filepath, face_data, colors, width, height, opacity):
with open(filepath, 'w', encoding='utf-8') as file:
for text in get_file_parts(face_data, colors, width, height, opacity):
file.write(text)
+
def get_file_parts(face_data, colors, width, height, opacity):
yield from header(width, height)
yield from draw_polygons(face_data, width, height, opacity)
yield from footer()
+
def header(width, height):
yield '<?xml version="1.0" standalone="no"?>\n'
yield '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" \n'
@@ -23,6 +26,7 @@ def header(width, height):
desc = f"{basename(bpy.data.filepath)}, (Blender {bpy.app.version_string})"
yield f'<desc>{escape(desc)}</desc>\n'
+
def draw_polygons(face_data, width, height, opacity):
for uvs, color in face_data:
fill = f'fill="{get_color_string(color)}"'
@@ -37,10 +41,12 @@ def draw_polygons(face_data, width, height, opacity):
yield f'{x*width:.3f},{y*height:.3f} '
yield '" />\n'
+
def get_color_string(color):
r, g, b = color
return f"rgb({round(r*255)}, {round(g*255)}, {round(b*255)})"
+
def footer():
yield '\n'
yield '</svg>\n'
diff --git a/measureit/__init__.py b/measureit/__init__.py
index 8d4b9576..c7f4fc7e 100644
--- a/measureit/__init__.py
+++ b/measureit/__init__.py
@@ -11,8 +11,8 @@ bl_info = {
"name": "MeasureIt",
"author": "Antonio Vazquez (antonioya)",
"location": "View3D > Sidebar > View Tab",
- "version": (1, 8, 1),
- "blender": (2, 80, 0),
+ "version": (1, 8, 2),
+ "blender": (3, 0, 0),
"description": "Tools for measuring objects.",
"doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/measureit.html",
"category": "3D View"
diff --git a/measureit/measureit_geometry.py b/measureit/measureit_geometry.py
index a1e90b9e..56efad0e 100644
--- a/measureit/measureit_geometry.py
+++ b/measureit/measureit_geometry.py
@@ -17,7 +17,6 @@ from bpy_extras import view3d_utils, mesh_utils
import bpy_extras.object_utils as object_utils
from sys import exc_info
# GPU
-import bgl
import gpu
from gpu_extras.batch import batch_for_shader
@@ -477,7 +476,7 @@ def draw_segments(context, myobj, op, region, rv3d):
# ------------------------------------
# Draw lines
# ------------------------------------
- bgl.glEnable(bgl.GL_BLEND)
+ gpu.state.blend_set('ALPHA')
if ms.gltype == 1: # Segment
draw_line(screen_point_ap1, screen_point_v11, rgba)
@@ -1175,7 +1174,7 @@ def draw_faces(context, myobj, region, rv3d):
a_p2 = (a_p1[0] + normal[0] * ln, a_p1[1] + normal[1] * ln, a_p1[2] + normal[2] * ln)
# line setup
- bgl.glEnable(bgl.GL_BLEND)
+ gpu.state.blend_set('ALPHA')
imm_set_line_width(th)
# converting to screen coordinates
txtpoint2d = get_2d_point(region, rv3d, a_p1)
@@ -1185,7 +1184,7 @@ def draw_faces(context, myobj, region, rv3d):
draw_text(myobj, txtpoint2d, str(f.index), rgba, fsize)
# Draw Normal
if scene.measureit_debug_normals is True:
- bgl.glEnable(bgl.GL_BLEND)
+ gpu.state.blend_set('ALPHA')
draw_arrow(txtpoint2d, point2, rgba, 10, "99", "1")
if len(obverts) > 2 and scene.measureit_debug_normal_details is True:
diff --git a/measureit/measureit_main.py b/measureit/measureit_main.py
index 23e9de46..d69ba268 100644
--- a/measureit/measureit_main.py
+++ b/measureit/measureit_main.py
@@ -11,7 +11,6 @@ import bpy
import bmesh
from bmesh import from_edit_mesh
# noinspection PyUnresolvedReferences
-import bgl
from bpy.types import PropertyGroup, Panel, Object, Operator, SpaceView3D
from bpy.props import IntProperty, CollectionProperty, FloatVectorProperty, BoolProperty, StringProperty, \
FloatProperty, EnumProperty
@@ -1933,8 +1932,8 @@ def draw_main(context):
else:
objlist = context.view_layer.objects
- # Enable GL drawing
- bgl.glEnable(bgl.GL_BLEND)
+ # Enable drawing
+ gpu.state.blend_set('ALPHA')
# ---------------------------------------
# Generate all OpenGL calls for measures
# ---------------------------------------
@@ -1964,9 +1963,9 @@ def draw_main(context):
draw_faces(context, myobj, region, rv3d)
# -----------------------
- # restore opengl defaults
+ # restore defaults
# -----------------------
- bgl.glDisable(bgl.GL_BLEND)
+ gpu.state.blend_set('NONE')
# -------------------------------------------------------------
diff --git a/measureit/measureit_render.py b/measureit/measureit_render.py
index efc5c1b0..093149d5 100644
--- a/measureit/measureit_render.py
+++ b/measureit/measureit_render.py
@@ -8,7 +8,6 @@
# noinspection PyUnresolvedReferences
import bpy
import gpu
-import bgl
# noinspection PyUnresolvedReferences
import blf
from os import path, remove
@@ -54,8 +53,8 @@ def render_main(self, context, animation=False):
[0, 0, 0, 1]])
with offscreen.bind():
- bgl.glClearColor(0.0, 0.0, 0.0, 0.0)
- bgl.glClear(bgl.GL_COLOR_BUFFER_BIT)
+ fb = gpu.state.active_framebuffer_get()
+ fb.clear(color=(0.0, 0.0, 0.0, 0.0))
gpu.matrix.reset()
gpu.matrix.load_matrix(view_matrix)
gpu.matrix.load_projection_matrix(Matrix.Identity(4))
@@ -101,9 +100,8 @@ def render_main(self, context, animation=False):
y2 = height - y1
draw_rectangle((x1, y1), (x2, y2), rfcolor)
- buffer = bgl.Buffer(bgl.GL_BYTE, width * height * 4)
- bgl.glReadBuffer(bgl.GL_COLOR_ATTACHMENT0)
- bgl.glReadPixels(0, 0, width, height, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, buffer)
+ buffer = fb.read_color(0, 0, width, height, 4, 0, 'UBYTE')
+ buffer.dimensions = width * height * 4
offscreen.free()
diff --git a/mesh_tissue/weight_tools.py b/mesh_tissue/weight_tools.py
index 2736945e..8576b88c 100644
--- a/mesh_tissue/weight_tools.py
+++ b/mesh_tissue/weight_tools.py
@@ -2513,7 +2513,7 @@ class vertex_group_to_vertex_colors(Operator):
bpy.ops.object.mode_set(mode='OBJECT')
group_name = obj.vertex_groups[group_id].name
- bpy.ops.mesh.vertex_color_add()
+ me.vertex_colors.new()
colors_id = obj.data.vertex_colors.active_index
colors_name = group_name
@@ -2694,8 +2694,8 @@ class curvature_to_vertex_groups(Operator):
def execute(self, context):
bpy.ops.object.mode_set(mode='OBJECT')
- bpy.ops.mesh.vertex_color_add()
vertex_colors = context.active_object.data.vertex_colors
+ vertex_colors.new()
vertex_colors[-1].active = True
vertex_colors[-1].active_render = True
vertex_colors[-1].name = "Curvature"
@@ -2706,7 +2706,7 @@ class curvature_to_vertex_groups(Operator):
blur_iterations=self.blur_iterations, clean_angle=self.max_angle,
dirt_angle=self.min_angle)
bpy.ops.object.vertex_colors_to_vertex_groups(invert=self.invert)
- bpy.ops.mesh.vertex_color_remove()
+ vertex_colors.remove(vertex_colors.active)
return {'FINISHED'}
class face_area_to_vertex_groups(Operator):
diff --git a/object_scatter/__init__.py b/object_scatter/__init__.py
index 12bc8ca0..8edeac71 100644
--- a/object_scatter/__init__.py
+++ b/object_scatter/__init__.py
@@ -3,8 +3,8 @@
bl_info = {
"name": "Scatter Objects",
"author": "Jacques Lucke",
- "version": (0, 1),
- "blender": (2, 80, 0),
+ "version": (0, 2),
+ "blender": (3, 0, 0),
"location": "3D View",
"description": "Distribute object instances on another object.",
"warning": "",
diff --git a/object_scatter/operator.py b/object_scatter/operator.py
index 07bf3884..8be78672 100644
--- a/object_scatter/operator.py
+++ b/object_scatter/operator.py
@@ -2,7 +2,6 @@
import bpy
import gpu
-import bgl
import blf
import math
import enum
@@ -340,14 +339,14 @@ def draw_matrices_batches(batches):
shader.bind()
shader.uniform_float("color", (0.4, 0.4, 1.0, 0.3))
- bgl.glEnable(bgl.GL_BLEND)
- bgl.glDepthMask(bgl.GL_FALSE)
+ gpu.state.blend_set('ALPHA')
+ gpu.state.depth_mask_set(False)
for batch in batches:
batch.draw(shader)
- bgl.glDisable(bgl.GL_BLEND)
- bgl.glDepthMask(bgl.GL_TRUE)
+ gpu.state.blend_set('NONE')
+ gpu.state.depth_mask_set(True)
def create_batch_for_matrices(matrices, base_scale):
coords = []
@@ -367,7 +366,7 @@ def create_batch_for_matrices(matrices, base_scale):
def draw_line_strip_batch(batch, color, thickness=1):
shader = get_uniform_color_shader()
- bgl.glLineWidth(thickness)
+ gpu.state.line_width_set(thickness)
shader.bind()
shader.uniform_float("color", color)
batch.draw(shader)
diff --git a/power_sequencer/__init__.py b/power_sequencer/__init__.py
index c646da7c..877de302 100755
--- a/power_sequencer/__init__.py
+++ b/power_sequencer/__init__.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
from typing import List, Tuple, Type
import bpy
@@ -27,8 +24,8 @@ bl_info = {
"name": "Power Sequencer",
"description": "Video editing tools for content creators",
"author": "Nathan Lovato",
- "version": (1, 5, 0),
- "blender": (2, 81, 0),
+ "version": (2, 0, 2),
+ "blender": (2, 93, 3),
"location": "Sequencer",
"tracker_url": "https://github.com/GDquest/Blender-power-sequencer/issues",
"wiki_url": "https://www.gdquest.com/docs/documentation/power-sequencer/",
diff --git a/power_sequencer/addon_preferences.py b/power_sequencer/addon_preferences.py
index 4220e89c..cfa21334 100644
--- a/power_sequencer/addon_preferences.py
+++ b/power_sequencer/addon_preferences.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
"""
Add-on preferences and interface in the Blender preferences window.
"""
diff --git a/power_sequencer/addon_properties.py b/power_sequencer/addon_properties.py
index 575a3954..3e7a4df3 100644
--- a/power_sequencer/addon_properties.py
+++ b/power_sequencer/addon_properties.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
@@ -10,8 +7,6 @@ class PowerSequencerProperties(bpy.types.PropertyGroup):
playback_speed: bpy.props.EnumProperty(
items=[
("NORMAL", "Normal (1x)", ""),
- ("FAST", "Fast (1.33x)", ""),
- ("FASTER", "Faster (1.66x)", ""),
("DOUBLE", "Double (2x)", ""),
("TRIPLE", "Triple (3x)", ""),
],
@@ -19,8 +14,6 @@ class PowerSequencerProperties(bpy.types.PropertyGroup):
default="NORMAL",
)
- frame_pre: bpy.props.IntProperty(name="Frame before frame_change", default=0, min=0)
-
active_tab: bpy.props.StringProperty(
name="Active Tab", description="The name of the active tab in the UI", default="Sequencer"
)
diff --git a/power_sequencer/handlers.py b/power_sequencer/handlers.py
index d9c107da..c743d18b 100644
--- a/power_sequencer/handlers.py
+++ b/power_sequencer/handlers.py
@@ -1,22 +1,10 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from bpy.app.handlers import persistent
@persistent
-def power_sequencer_load_file_post(arg):
- """
- Called after loading the blend file
- """
- for scene in bpy.data.scenes:
- scene.power_sequencer.frame_pre = bpy.context.scene.frame_current
-
-
-@persistent
def power_sequencer_playback_speed_post(scene):
"""
Handler function for faster playback
@@ -24,27 +12,23 @@ def power_sequencer_playback_speed_post(scene):
It steps over frame rather than increase the playback speed smoothly,
but it's still useful for faster editing
"""
+
+ # Calling this function triggers a callback to this function via the frame
+ # changed handler, causing a stack overflow. We use a property to prevent
+ # errors.
if bpy.context.screen and not bpy.context.screen.is_animation_playing:
return
playback_speed = scene.power_sequencer.playback_speed
- frame_start = scene.frame_current
- frame_post = scene.frame_current
-
- if playback_speed == "FAST" and frame_start % 3 == 0:
- frame_post += 1
- elif playback_speed == "FASTER" and frame_start % 2 == 0:
- frame_post += 1
- elif playback_speed == "DOUBLE":
- # 2.5x -> skip 5 frames for 2. 2 then 3 then 2 etc.
- frame_post += 1
+ target_frame = scene.frame_current
+ if playback_speed == "DOUBLE":
+ target_frame += 1
elif playback_speed == "TRIPLE":
- frame_post += 2
+ target_frame += 2
- if frame_start != frame_post:
- bpy.ops.screen.frame_offset(delta=frame_post - frame_start)
- scene.power_sequencer.frame_pre = scene.frame_current
+ if target_frame != scene.frame_current:
+ bpy.ops.screen.frame_offset(delta=target_frame - scene.frame_current)
def draw_playback_speed(self, context):
@@ -64,7 +48,6 @@ def register_handlers():
bpy.types.SEQUENCER_HT_header.append(draw_playback_speed)
# Handlers
- bpy.app.handlers.load_post.append(power_sequencer_load_file_post)
bpy.app.handlers.frame_change_post.append(power_sequencer_playback_speed_post)
@@ -74,5 +57,4 @@ def unregister_handlers():
bpy.types.SEQUENCER_HT_header.remove(draw_playback_speed)
# Handlers
- bpy.app.handlers.load_post.remove(power_sequencer_load_file_post)
bpy.app.handlers.frame_change_post.remove(power_sequencer_playback_speed_post)
diff --git a/power_sequencer/operators/__init__.py b/power_sequencer/operators/__init__.py
index b1222a18..57dbe2bb 100755
--- a/power_sequencer/operators/__init__.py
+++ b/power_sequencer/operators/__init__.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import importlib
import os
@@ -16,7 +13,7 @@ def get_operator_classes():
module_paths = ["." + os.path.splitext(f)[0] for f in module_files]
classes = []
for path in module_paths:
- module = importlib.import_module(path, package="power_sequencer.operators")
+ module = importlib.import_module(path, package=__package__)
operator_names = [entry for entry in dir(module) if entry.startswith("POWER_SEQUENCER_OT")]
classes.extend([getattr(module, name) for name in operator_names])
return classes
diff --git a/power_sequencer/operators/channel_offset.py b/power_sequencer/operators/channel_offset.py
index b7569afa..1e9c97f7 100644
--- a/power_sequencer/operators/channel_offset.py
+++ b/power_sequencer/operators/channel_offset.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
from operator import attrgetter
import bpy
@@ -117,12 +114,11 @@ class POWER_SEQUENCER_OT_channel_offset(bpy.types.Operator):
context, s.frame_final_start, s.frame_final_end, to_trim, to_delete
)
- if not self.keep_selection_offset:
- s.channel = comparison_function(limit_channel, s.channel + channel_offset)
- if s.channel == limit_channel:
- move_selection(context, [s], 0, 0)
+ s.channel = comparison_function(limit_channel, s.channel + channel_offset)
+ if s.channel == limit_channel:
+ move_selection(context, [s], 0, 0)
- if self.keep_selection_offset:
+ if self.keep_selection_offset and not self.trim_target_channel:
start_frame = head.frame_final_start
x_difference = 0
while not head.channel == limit_channel:
diff --git a/power_sequencer/operators/concatenate_strips.py b/power_sequencer/operators/concatenate_strips.py
index 32f5f59b..17ff4ee4 100644
--- a/power_sequencer/operators/concatenate_strips.py
+++ b/power_sequencer/operators/concatenate_strips.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from operator import attrgetter
diff --git a/power_sequencer/operators/copy_selected_sequences.py b/power_sequencer/operators/copy_selected_sequences.py
index 643ecb33..338f1cff 100644
--- a/power_sequencer/operators/copy_selected_sequences.py
+++ b/power_sequencer/operators/copy_selected_sequences.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from operator import attrgetter
diff --git a/power_sequencer/operators/crossfade_add.py b/power_sequencer/operators/crossfade_add.py
index 73644c80..25ce7ae7 100644
--- a/power_sequencer/operators/crossfade_add.py
+++ b/power_sequencer/operators/crossfade_add.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import find_sequences_after
@@ -94,7 +91,7 @@ class POWER_SEQUENCER_OT_crossfade_add(bpy.types.Operator):
Moves the handles of the two sequences before adding the crossfade
"""
fade_duration = convert_duration_to_frames(context, self.crossfade_duration)
- fade_offset = fade_duration / 2
+ fade_offset = int(fade_duration / 2)
if hasattr(sequence_1, "input_1"):
sequence_1.input_1.frame_final_end -= fade_offset
diff --git a/power_sequencer/operators/crossfade_edit.py b/power_sequencer/operators/crossfade_edit.py
index 0e330e10..6d3be976 100644
--- a/power_sequencer/operators/crossfade_edit.py
+++ b/power_sequencer/operators/crossfade_edit.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.global_settings import SequenceTypes
diff --git a/power_sequencer/operators/cut_strips_under_cursor.py b/power_sequencer/operators/cut_strips_under_cursor.py
index 4a66a782..51bf0789 100644
--- a/power_sequencer/operators/cut_strips_under_cursor.py
+++ b/power_sequencer/operators/cut_strips_under_cursor.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/delete_direct.py b/power_sequencer/operators/delete_direct.py
index bda5face..1fc8bf60 100644
--- a/power_sequencer/operators/delete_direct.py
+++ b/power_sequencer/operators/delete_direct.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_mouse_frame_and_channel
diff --git a/power_sequencer/operators/deselect_all_left_or_right.py b/power_sequencer/operators/deselect_all_left_or_right.py
index 6769d173..3ba79483 100644
--- a/power_sequencer/operators/deselect_all_left_or_right.py
+++ b/power_sequencer/operators/deselect_all_left_or_right.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/deselect_handles_and_grab.py b/power_sequencer/operators/deselect_handles_and_grab.py
index 468baf8b..36f547df 100644
--- a/power_sequencer/operators/deselect_handles_and_grab.py
+++ b/power_sequencer/operators/deselect_handles_and_grab.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/duplicate_move.py b/power_sequencer/operators/duplicate_move.py
index 32c62a56..cce7a6ed 100644
--- a/power_sequencer/operators/duplicate_move.py
+++ b/power_sequencer/operators/duplicate_move.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_mouse_frame_and_channel
diff --git a/power_sequencer/operators/expand_to_surrounding_cuts.py b/power_sequencer/operators/expand_to_surrounding_cuts.py
index 7129e42d..4b8a6f93 100644
--- a/power_sequencer/operators/expand_to_surrounding_cuts.py
+++ b/power_sequencer/operators/expand_to_surrounding_cuts.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import slice_selection
@@ -22,7 +19,11 @@ class POWER_SEQUENCER_OT_expand_to_surrounding_cuts(bpy.types.Operator):
"demo": "",
"description": doc_description(__doc__),
"shortcuts": [
- ({"type": "E", "value": "PRESS", "ctrl": True}, {}, "Expand to Surrounding Cuts",)
+ (
+ {"type": "E", "value": "PRESS", "ctrl": True},
+ {},
+ "Expand to Surrounding Cuts",
+ )
],
"keymap": "Sequencer",
}
diff --git a/power_sequencer/operators/fade_add.py b/power_sequencer/operators/fade_add.py
index 39fe18a9..ab692dba 100644
--- a/power_sequencer/operators/fade_add.py
+++ b/power_sequencer/operators/fade_add.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from mathutils import Vector
from math import floor
@@ -16,7 +13,7 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator):
Fade options:
- In, Out, In and Out create a fade animation of the given duration from
- the start of the sequence, to the end of the sequence, or on both sides
+ the start of the sequence, to the end of the sequence, or on boths sides
- From playhead: the fade animation goes from the start of sequences under the playhead to the playhead
- To playhead: the fade animation goes from the playhead to the end of sequences under the playhead
@@ -40,7 +37,10 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator):
bl_options = {"REGISTER", "UNDO"}
duration_seconds: bpy.props.FloatProperty(
- name="Fade Duration", description="Duration of the fade in seconds", default=1.0, min=0.01,
+ name="Fade Duration",
+ description="Duration of the fade in seconds",
+ default=1.0,
+ min=0.01,
)
type: bpy.props.EnumProperty(
items=[
diff --git a/power_sequencer/operators/fade_clear.py b/power_sequencer/operators/fade_clear.py
index c74b27cf..d73c7347 100644
--- a/power_sequencer/operators/fade_clear.py
+++ b/power_sequencer/operators/fade_clear.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
@@ -21,7 +18,11 @@ class POWER_SEQUENCER_OT_fade_clear(bpy.types.Operator):
"demo": "",
"description": doc_description(__doc__),
"shortcuts": [
- ({"type": "F", "value": "PRESS", "alt": True, "ctrl": True}, {}, "Clear Fades",)
+ (
+ {"type": "F", "value": "PRESS", "alt": True, "ctrl": True},
+ {},
+ "Clear Fades",
+ )
],
"keymap": "Sequencer",
}
diff --git a/power_sequencer/operators/gap_remove.py b/power_sequencer/operators/gap_remove.py
index 7f2ec5ae..64070667 100644
--- a/power_sequencer/operators/gap_remove.py
+++ b/power_sequencer/operators/gap_remove.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from operator import attrgetter
diff --git a/power_sequencer/operators/grab.py b/power_sequencer/operators/grab.py
index de53d2a4..57299d72 100644
--- a/power_sequencer/operators/grab.py
+++ b/power_sequencer/operators/grab.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_mouse_frame_and_channel
diff --git a/power_sequencer/operators/grab_closest_handle_or_cut.py b/power_sequencer/operators/grab_closest_handle_or_cut.py
index 55440b95..7a7a056d 100644
--- a/power_sequencer/operators/grab_closest_handle_or_cut.py
+++ b/power_sequencer/operators/grab_closest_handle_or_cut.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
"""
Selects and grabs the strip handle or cut closest to the mouse cursor.
Hover near a cut and use this operator to slide it.
diff --git a/power_sequencer/operators/grab_sequence_handles.py b/power_sequencer/operators/grab_sequence_handles.py
index ecbe8c4b..d8137b0f 100644
--- a/power_sequencer/operators/grab_sequence_handles.py
+++ b/power_sequencer/operators/grab_sequence_handles.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.global_settings import SequenceTypes
@@ -34,8 +31,8 @@ class POWER_SEQUENCER_OT_grab_sequence_handles(bpy.types.Operator):
bl_options = {"REGISTER", "UNDO"}
always_find_closest: bpy.props.BoolProperty(name="Always find closest", default=False)
- frame: bpy.props.IntProperty(name="Frame", default=-1, options={"HIDDEN"})
- channel: bpy.props.IntProperty(name="Channel", default=-1, options={"HIDDEN"})
+ frame: bpy.props.FloatProperty(name="Frame", default=-1.0, options={"HIDDEN"})
+ channel: bpy.props.FloatProperty(name="Channel", default=-1.0, options={"HIDDEN"})
@classmethod
def poll(cls, context):
diff --git a/power_sequencer/operators/import_local_footage.py b/power_sequencer/operators/import_local_footage.py
index 8612210a..7eb7120b 100644
--- a/power_sequencer/operators/import_local_footage.py
+++ b/power_sequencer/operators/import_local_footage.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import json
import os
import re
diff --git a/power_sequencer/operators/jump_time_offset.py b/power_sequencer/operators/jump_time_offset.py
index ee9b1f9b..79941827 100644
--- a/power_sequencer/operators/jump_time_offset.py
+++ b/power_sequencer/operators/jump_time_offset.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import convert_duration_to_frames
diff --git a/power_sequencer/operators/jump_to_cut.py b/power_sequencer/operators/jump_to_cut.py
index add0dab9..02a0b9f9 100644
--- a/power_sequencer/operators/jump_to_cut.py
+++ b/power_sequencer/operators/jump_to_cut.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from operator import attrgetter
@@ -45,8 +42,8 @@ class POWER_SEQUENCER_OT_jump_to_cut(bpy.types.Operator):
name="Direction",
description="Jump direction, either forward or backward",
items=[
- ("RIGHT", "Forward", "Jump forward in time"),
- ("LEFT", "Backward", "Jump backward in time"),
+ ("RIGHT", "Right", "Jump forward in time"),
+ ("LEFT", "Left", "Jump backward in time"),
],
)
@@ -56,9 +53,6 @@ class POWER_SEQUENCER_OT_jump_to_cut(bpy.types.Operator):
def execute(self, context):
frame_current = context.scene.frame_current
- sorted_sequences = sorted(
- context.sequences, key=attrgetter("frame_final_start", "frame_final_end")
- )
fcurves = []
animation_data = context.scene.animation_data
@@ -66,43 +60,53 @@ class POWER_SEQUENCER_OT_jump_to_cut(bpy.types.Operator):
fcurves = animation_data.action.fcurves
frame_target = -1
+
+ # First find the closest cut, then if that sequence has an associated
+ # fcurve, loop through the curve's keyframes.
if self.direction == "RIGHT":
- sequences = [s for s in sorted_sequences if s.frame_final_end > frame_current]
- for s in sequences:
+ frame_target = 100_000_000
+ for s in context.sequences:
+ if s.frame_final_end <= frame_current:
+ continue
+
+ candidates = [frame_target, s.frame_final_end]
+ if s.frame_final_start > frame_current:
+ candidates.append(s.frame_final_start)
- frame_target = (
- s.frame_final_end
- if s.frame_final_start <= frame_current
- else s.frame_final_start
- )
+ frame_target = min(candidates)
for f in fcurves:
+ if s.name not in f.data_path:
+ continue
+
for k in f.keyframe_points:
frame = k.co[0]
- if frame <= context.scene.frame_current:
+ if frame <= frame_current:
continue
frame_target = min(frame_target, frame)
- break
elif self.direction == "LEFT":
- sequences = [
- s for s in reversed(sorted_sequences) if s.frame_final_start < frame_current
- ]
- for s in sequences:
+ for s in context.sequences:
+ if s.frame_final_start >= frame_current:
+ continue
+
+ candidates = [frame_target, s.frame_final_start]
+ if s.frame_final_end < frame_current:
+ candidates.append(s.frame_final_end)
- frame_target = (
- s.frame_final_start if s.frame_final_end >= frame_current else s.frame_final_end
- )
+ frame_target = max(candidates)
for f in fcurves:
+ if s.name not in f.data_path:
+ continue
+
for k in f.keyframe_points:
frame = k.co[0]
- if frame >= context.scene.frame_current:
+ if frame >= frame_current:
continue
frame_target = max(frame_target, frame)
- break
- if frame_target != -1:
- context.scene.frame_current = max(1, frame_target)
+ if frame_target > 0 and frame_target != 100_000_000:
+ context.scene.frame_current = int(frame_target)
return {"FINISHED"}
diff --git a/power_sequencer/operators/make_hold_frame.py b/power_sequencer/operators/make_hold_frame.py
index 4c1f110d..3650a4cb 100644
--- a/power_sequencer/operators/make_hold_frame.py
+++ b/power_sequencer/operators/make_hold_frame.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
import operator
diff --git a/power_sequencer/operators/marker_delete_closest.py b/power_sequencer/operators/marker_delete_closest.py
index a4756958..68659b51 100644
--- a/power_sequencer/operators/marker_delete_closest.py
+++ b/power_sequencer/operators/marker_delete_closest.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/marker_delete_direct.py b/power_sequencer/operators/marker_delete_direct.py
index efc8ba66..3b6f9297 100644
--- a/power_sequencer/operators/marker_delete_direct.py
+++ b/power_sequencer/operators/marker_delete_direct.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/marker_snap_to_cursor.py b/power_sequencer/operators/marker_snap_to_cursor.py
index dbb3a6c7..8fe80653 100644
--- a/power_sequencer/operators/marker_snap_to_cursor.py
+++ b/power_sequencer/operators/marker_snap_to_cursor.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/markers_as_timecodes.py b/power_sequencer/operators/markers_as_timecodes.py
index 52658838..74b42794 100644
--- a/power_sequencer/operators/markers_as_timecodes.py
+++ b/power_sequencer/operators/markers_as_timecodes.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
import datetime as dt
diff --git a/power_sequencer/operators/markers_create_from_selected.py b/power_sequencer/operators/markers_create_from_selected.py
index bd346d84..620995de 100644
--- a/power_sequencer/operators/markers_create_from_selected.py
+++ b/power_sequencer/operators/markers_create_from_selected.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/markers_set_preview_in_between.py b/power_sequencer/operators/markers_set_preview_in_between.py
index 60724312..8ac0e9f6 100644
--- a/power_sequencer/operators/markers_set_preview_in_between.py
+++ b/power_sequencer/operators/markers_set_preview_in_between.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import find_neighboring_markers
diff --git a/power_sequencer/operators/markers_snap_matching_strips.py b/power_sequencer/operators/markers_snap_matching_strips.py
index da475eeb..b9eab7b4 100644
--- a/power_sequencer/operators/markers_snap_matching_strips.py
+++ b/power_sequencer/operators/markers_snap_matching_strips.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/meta_resize_to_content.py b/power_sequencer/operators/meta_resize_to_content.py
index ed54ebca..b5d0b29f 100644
--- a/power_sequencer/operators/meta_resize_to_content.py
+++ b/power_sequencer/operators/meta_resize_to_content.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_frame_range
diff --git a/power_sequencer/operators/meta_trim_content_to_bounds.py b/power_sequencer/operators/meta_trim_content_to_bounds.py
index 11b48369..e309f8e1 100644
--- a/power_sequencer/operators/meta_trim_content_to_bounds.py
+++ b/power_sequencer/operators/meta_trim_content_to_bounds.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.global_settings import SequenceTypes
diff --git a/power_sequencer/operators/meta_ungroup_and_trim.py b/power_sequencer/operators/meta_ungroup_and_trim.py
index 00c79cf4..e467492d 100644
--- a/power_sequencer/operators/meta_ungroup_and_trim.py
+++ b/power_sequencer/operators/meta_ungroup_and_trim.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/mouse_toggle_mute.py b/power_sequencer/operators/mouse_toggle_mute.py
index 362b2e9d..cd135829 100644
--- a/power_sequencer/operators/mouse_toggle_mute.py
+++ b/power_sequencer/operators/mouse_toggle_mute.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
"""Toggle mute a sequence as you click on it"""
import bpy
from math import floor
diff --git a/power_sequencer/operators/mouse_trim_instantly.py b/power_sequencer/operators/mouse_trim_instantly.py
index 332053fc..3a79a5a7 100644
--- a/power_sequencer/operators/mouse_trim_instantly.py
+++ b/power_sequencer/operators/mouse_trim_instantly.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from math import floor
diff --git a/power_sequencer/operators/mouse_trim_modal.py b/power_sequencer/operators/mouse_trim_modal.py
index a138933b..e8f751c9 100644
--- a/power_sequencer/operators/mouse_trim_modal.py
+++ b/power_sequencer/operators/mouse_trim_modal.py
@@ -1,10 +1,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
-import bgl
import gpu
import math
from mathutils import Vector
@@ -35,7 +31,7 @@ class POWER_SEQUENCER_OT_mouse_trim(bpy.types.Operator):
*brief* Cut or Trim strips quickly with the mouse cursor
- Click somewhere in the Sequencer to insert a cut, click and drag to trim
+ Click somehwere in the Sequencer to insert a cut, click and drag to trim
With this function you can quickly cut and remove a section of strips while keeping or
collapsing the remaining gap.
Press <kbd>Ctrl</kbd> to snap to cuts.
@@ -361,8 +357,8 @@ def draw(self, context, frame_start=-1, frame_end=-1, target_strips=[], draw_arr
rect_origin = Vector((start_x, start_y))
rect_size = Vector((end_x - start_x, abs(start_y - end_y)))
- bgl.glEnable(bgl.GL_BLEND)
- bgl.glLineWidth(3)
+ gpu.state.blend_set('ALPHA')
+ gpu.state.line_width_set(3.0)
draw_rectangle(SHADER, rect_origin, rect_size, color_fill)
# Vertical lines
draw_line(SHADER, Vector((start_x, start_y)), Vector((start_x, end_y)), color_line)
@@ -377,8 +373,8 @@ def draw(self, context, frame_start=-1, frame_end=-1, target_strips=[], draw_arr
draw_triangle_equilateral(SHADER, center_1, radius, color=color_line)
draw_triangle_equilateral(SHADER, center_2, radius, math.pi, color=color_line)
- bgl.glLineWidth(1)
- bgl.glDisable(bgl.GL_BLEND)
+ gpu.state.line_width_set(1)
+ gpu.state.blend_set('NONE')
def get_frame_and_channel(event):
diff --git a/power_sequencer/operators/open_project_directory.py b/power_sequencer/operators/open_project_directory.py
index f32f2ac2..02c72de1 100644
--- a/power_sequencer/operators/open_project_directory.py
+++ b/power_sequencer/operators/open_project_directory.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
import os
from platform import system
diff --git a/power_sequencer/operators/playback_speed_decrease.py b/power_sequencer/operators/playback_speed_decrease.py
deleted file mode 100644
index a856ac4b..00000000
--- a/power_sequencer/operators/playback_speed_decrease.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
-import bpy
-
-from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
-
-
-class POWER_SEQUENCER_OT_playback_speed_decrease(bpy.types.Operator):
- """
- *brief* Decrease playback speed incrementally down to normal
-
-
- Playback speed may be set to any of the following speeds:
-
- * Normal (1x)
- * Fast (1.33x)
- * Faster (1.66x)
- * Double (2x)
- * Triple (3x)
-
- Activating this operator will decrease playback speed through each
- of these steps until minimum speed is reached.
- """
-
- doc = {
- "name": doc_name(__qualname__),
- "demo": "",
- "description": doc_description(__doc__),
- "shortcuts": [({"type": "COMMA", "value": "PRESS"}, {}, "Decrease Playback Speed")],
- "keymap": "Sequencer",
- }
- bl_idname = doc_idname(__qualname__)
- bl_label = doc["name"]
- bl_description = doc_brief(doc["description"])
-
- @classmethod
- def poll(cls, context):
- return context.sequences
-
- def execute(self, context):
- scene = context.scene
-
- speeds = ["NORMAL", "FAST", "FASTER", "DOUBLE", "TRIPLE"]
- playback_speed = scene.power_sequencer.playback_speed
-
- index = max(0, speeds.index(playback_speed) - 1)
- scene.power_sequencer.playback_speed = speeds[index]
-
- return {"FINISHED"}
diff --git a/power_sequencer/operators/playback_speed_increase.py b/power_sequencer/operators/playback_speed_increase.py
deleted file mode 100644
index 7c2f2ad2..00000000
--- a/power_sequencer/operators/playback_speed_increase.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
-import bpy
-
-from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
-
-
-class POWER_SEQUENCER_OT_playback_speed_increase(bpy.types.Operator):
- """
- *brief* Increase playback speed up to triple
-
-
- Playback speed may be set to any of the following speeds:
-
- * Normal (1x)
- * Fast (1.33x)
- * Faster (1.66x)
- * Double (2x)
- * Triple (3x)
-
- Activating this operator will increase playback speed through each
- of these steps until maximum speed is reached.
- """
-
- doc = {
- "name": doc_name(__qualname__),
- "demo": "",
- "description": doc_description(__doc__),
- "shortcuts": [({"type": "PERIOD", "value": "PRESS"}, {}, "Increase playback speed")],
- "keymap": "Sequencer",
- }
- bl_idname = doc_idname(__qualname__)
- bl_label = doc["name"]
- bl_description = doc_brief(doc["description"])
-
- @classmethod
- def poll(cls, context):
- return context.sequences
-
- def execute(self, context):
- scene = context.scene
-
- speeds = ["NORMAL", "FAST", "FASTER", "DOUBLE", "TRIPLE"]
- playback_speed = scene.power_sequencer.playback_speed
-
- index = min(speeds.index(playback_speed) + 1, len(speeds) - 1)
- scene.power_sequencer.playback_speed = speeds[index]
-
- return {"FINISHED"}
diff --git a/power_sequencer/operators/playback_speed_set.py b/power_sequencer/operators/playback_speed_set.py
index 9f576247..82c45b7a 100644
--- a/power_sequencer/operators/playback_speed_set.py
+++ b/power_sequencer/operators/playback_speed_set.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
@@ -19,14 +16,8 @@ class POWER_SEQUENCER_OT_playback_speed_set(bpy.types.Operator):
"description": doc_description(__doc__),
"shortcuts": [
({"type": "ONE", "ctrl": True, "value": "PRESS"}, {"speed": "NORMAL"}, "Speed to 1x"),
- ({"type": "TWO", "ctrl": True, "value": "PRESS"}, {"speed": "FAST"}, "Speed to 1.33x"),
- (
- {"type": "THREE", "ctrl": True, "value": "PRESS"},
- {"speed": "FASTER"},
- "Speed to 1.66x",
- ),
- ({"type": "FOUR", "ctrl": True, "value": "PRESS"}, {"speed": "DOUBLE"}, "Speed to 2x"),
- ({"type": "FIVE", "ctrl": True, "value": "PRESS"}, {"speed": "TRIPLE"}, "Speed to 3x"),
+ ({"type": "TWO", "ctrl": True, "value": "PRESS"}, {"speed": "DOUBLE"}, "Speed to 2x"),
+ ({"type": "THREE", "ctrl": True, "value": "PRESS"}, {"speed": "TRIPLE"}, "Speed to 3x"),
],
"keymap": "Sequencer",
}
@@ -38,8 +29,6 @@ class POWER_SEQUENCER_OT_playback_speed_set(bpy.types.Operator):
speed: bpy.props.EnumProperty(
items=[
("NORMAL", "Normal (1x)", ""),
- ("FAST", "Fast (1.33x)", ""),
- ("FASTER", "Faster (1.66x)", ""),
("DOUBLE", "Double (2x)", ""),
("TRIPLE", "Triple (3x)", ""),
],
diff --git a/power_sequencer/operators/preview_closest_cut.py b/power_sequencer/operators/preview_closest_cut.py
index 312be788..2375c21a 100644
--- a/power_sequencer/operators/preview_closest_cut.py
+++ b/power_sequencer/operators/preview_closest_cut.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_frame_range
diff --git a/power_sequencer/operators/preview_to_selection.py b/power_sequencer/operators/preview_to_selection.py
index ea6c0ed7..7ad8e2c7 100644
--- a/power_sequencer/operators/preview_to_selection.py
+++ b/power_sequencer/operators/preview_to_selection.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_frame_range
diff --git a/power_sequencer/operators/render_apply_preset.py b/power_sequencer/operators/render_apply_preset.py
index dc3b0ed1..d7ad5b38 100644
--- a/power_sequencer/operators/render_apply_preset.py
+++ b/power_sequencer/operators/render_apply_preset.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
import os
diff --git a/power_sequencer/operators/render_presets/twitter_720p.py b/power_sequencer/operators/render_presets/twitter_720p.py
index 109090cc..eadb4266 100644
--- a/power_sequencer/operators/render_presets/twitter_720p.py
+++ b/power_sequencer/operators/render_presets/twitter_720p.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
if __name__ == "__main__":
import bpy
diff --git a/power_sequencer/operators/render_presets/youtube_1080.py b/power_sequencer/operators/render_presets/youtube_1080.py
index 5bf6e826..61bab65d 100644
--- a/power_sequencer/operators/render_presets/youtube_1080.py
+++ b/power_sequencer/operators/render_presets/youtube_1080.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
if __name__ == "__main__":
import bpy
diff --git a/power_sequencer/operators/ripple_delete.py b/power_sequencer/operators/ripple_delete.py
index 939da4e0..515f318f 100644
--- a/power_sequencer/operators/ripple_delete.py
+++ b/power_sequencer/operators/ripple_delete.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_brief, doc_description, doc_idname, doc_name
diff --git a/power_sequencer/operators/save_direct.py b/power_sequencer/operators/save_direct.py
index f41c3d4f..09b130a3 100644
--- a/power_sequencer/operators/save_direct.py
+++ b/power_sequencer/operators/save_direct.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/scene_create_from_selection.py b/power_sequencer/operators/scene_create_from_selection.py
index 206e385a..15ed0237 100644
--- a/power_sequencer/operators/scene_create_from_selection.py
+++ b/power_sequencer/operators/scene_create_from_selection.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from operator import attrgetter
diff --git a/power_sequencer/operators/scene_cycle.py b/power_sequencer/operators/scene_cycle.py
index 1be39ab9..05b861e7 100644
--- a/power_sequencer/operators/scene_cycle.py
+++ b/power_sequencer/operators/scene_cycle.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/scene_merge_from.py b/power_sequencer/operators/scene_merge_from.py
index b411e039..9d790baf 100644
--- a/power_sequencer/operators/scene_merge_from.py
+++ b/power_sequencer/operators/scene_merge_from.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/scene_open_from_strip.py b/power_sequencer/operators/scene_open_from_strip.py
index 0b992356..8c868bc3 100644
--- a/power_sequencer/operators/scene_open_from_strip.py
+++ b/power_sequencer/operators/scene_open_from_strip.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/scene_rename_with_strip.py b/power_sequencer/operators/scene_rename_with_strip.py
index 8bc6432f..b5327439 100644
--- a/power_sequencer/operators/scene_rename_with_strip.py
+++ b/power_sequencer/operators/scene_rename_with_strip.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/select_all_left_or_right.py b/power_sequencer/operators/select_all_left_or_right.py
index 7d9087ee..794a9378 100644
--- a/power_sequencer/operators/select_all_left_or_right.py
+++ b/power_sequencer/operators/select_all_left_or_right.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
@@ -51,4 +48,10 @@ class POWER_SEQUENCER_OT_select_all_left_or_right(bpy.types.Operator):
return context.sequences
def execute(self, context):
- return bpy.ops.sequencer.select("INVOKE_DEFAULT", left_right=self.side)
+ if self.side == "LEFT":
+ for s in context.sequences:
+ s.select = s.frame_final_end < context.scene.frame_current
+ else:
+ for s in context.sequences:
+ s.select = s.frame_final_start > context.scene.frame_current
+ return {"FINISHED"}
diff --git a/power_sequencer/operators/select_closest_to_mouse.py b/power_sequencer/operators/select_closest_to_mouse.py
index f14bc309..dee7e967 100644
--- a/power_sequencer/operators/select_closest_to_mouse.py
+++ b/power_sequencer/operators/select_closest_to_mouse.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import find_strips_mouse
diff --git a/power_sequencer/operators/select_linked_effect.py b/power_sequencer/operators/select_linked_effect.py
index a63096f1..d00a7a4a 100644
--- a/power_sequencer/operators/select_linked_effect.py
+++ b/power_sequencer/operators/select_linked_effect.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import find_linked
diff --git a/power_sequencer/operators/select_linked_strips.py b/power_sequencer/operators/select_linked_strips.py
index 5716d13d..29022257 100644
--- a/power_sequencer/operators/select_linked_strips.py
+++ b/power_sequencer/operators/select_linked_strips.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/select_related_strips.py b/power_sequencer/operators/select_related_strips.py
index 0e442ebd..e7101fee 100644
--- a/power_sequencer/operators/select_related_strips.py
+++ b/power_sequencer/operators/select_related_strips.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.global_settings import SequenceTypes
diff --git a/power_sequencer/operators/select_strips_under_cursor.py b/power_sequencer/operators/select_strips_under_cursor.py
index a47d6e80..0c4712b5 100644
--- a/power_sequencer/operators/select_strips_under_cursor.py
+++ b/power_sequencer/operators/select_strips_under_cursor.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_sequences_under_cursor
diff --git a/power_sequencer/operators/set_timeline_range.py b/power_sequencer/operators/set_timeline_range.py
index 65a90f4d..a9bbd163 100644
--- a/power_sequencer/operators/set_timeline_range.py
+++ b/power_sequencer/operators/set_timeline_range.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/snap.py b/power_sequencer/operators/snap.py
index 793f5bd9..24a4f52a 100644
--- a/power_sequencer/operators/snap.py
+++ b/power_sequencer/operators/snap.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_sequences_under_cursor
@@ -21,7 +18,11 @@ class POWER_SEQUENCER_OT_snap(bpy.types.Operator):
"demo": "",
"description": doc_description(__doc__),
"shortcuts": [
- ({"type": "S", "value": "PRESS", "shift": True}, {}, "Snap sequences to cursor",)
+ (
+ {"type": "S", "value": "PRESS", "shift": True},
+ {},
+ "Snap sequences to cursor",
+ )
],
"keymap": "Sequencer",
}
diff --git a/power_sequencer/operators/snap_selection.py b/power_sequencer/operators/snap_selection.py
index 38da4c17..b73c5561 100644
--- a/power_sequencer/operators/snap_selection.py
+++ b/power_sequencer/operators/snap_selection.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_sequences_under_cursor, move_selection
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
@@ -21,7 +18,11 @@ class POWER_SEQUENCER_OT_snap_selection(bpy.types.Operator):
"demo": "",
"description": doc_description(__doc__),
"shortcuts": [
- ({"type": "S", "value": "PRESS", "alt": True}, {}, "Snap selection to cursor",)
+ (
+ {"type": "S", "value": "PRESS", "alt": True},
+ {},
+ "Snap selection to cursor",
+ )
],
"keymap": "Sequencer",
}
diff --git a/power_sequencer/operators/space_sequences.py b/power_sequencer/operators/space_sequences.py
index ddb28dfe..da3a0ac5 100644
--- a/power_sequencer/operators/space_sequences.py
+++ b/power_sequencer/operators/space_sequences.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import convert_duration_to_frames
diff --git a/power_sequencer/operators/speed_remove_effect.py b/power_sequencer/operators/speed_remove_effect.py
index ae2a4d35..69348461 100644
--- a/power_sequencer/operators/speed_remove_effect.py
+++ b/power_sequencer/operators/speed_remove_effect.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/speed_up_movie_strip.py b/power_sequencer/operators/speed_up_movie_strip.py
index c004e2fc..9e863f36 100644
--- a/power_sequencer/operators/speed_up_movie_strip.py
+++ b/power_sequencer/operators/speed_up_movie_strip.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from math import ceil
@@ -24,9 +21,21 @@ class POWER_SEQUENCER_OT_speed_up_movie_strip(bpy.types.Operator):
"demo": "https://i.imgur.com/ZyEd0jD.gif",
"description": doc_description(__doc__),
"shortcuts": [
- ({"type": "TWO", "value": "PRESS", "alt": True}, {"speed_factor": 2.0}, "Speed x2",),
- ({"type": "THREE", "value": "PRESS", "alt": True}, {"speed_factor": 3.0}, "Speed x3",),
- ({"type": "FOUR", "value": "PRESS", "alt": True}, {"speed_factor": 4.0}, "Speed x4",),
+ (
+ {"type": "TWO", "value": "PRESS", "alt": True},
+ {"speed_factor": 2.0},
+ "Speed x2",
+ ),
+ (
+ {"type": "THREE", "value": "PRESS", "alt": True},
+ {"speed_factor": 3.0},
+ "Speed x3",
+ ),
+ (
+ {"type": "FOUR", "value": "PRESS", "alt": True},
+ {"speed_factor": 4.0},
+ "Speed x4",
+ ),
],
"keymap": "Sequencer",
}
diff --git a/power_sequencer/operators/swap_strips.py b/power_sequencer/operators/swap_strips.py
index 44537c43..6b0460fa 100644
--- a/power_sequencer/operators/swap_strips.py
+++ b/power_sequencer/operators/swap_strips.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from operator import attrgetter
diff --git a/power_sequencer/operators/toggle_selected_mute.py b/power_sequencer/operators/toggle_selected_mute.py
index 3ee1a022..1a79237f 100644
--- a/power_sequencer/operators/toggle_selected_mute.py
+++ b/power_sequencer/operators/toggle_selected_mute.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_name, doc_idname, doc_brief, doc_description
diff --git a/power_sequencer/operators/toggle_waveforms.py b/power_sequencer/operators/toggle_waveforms.py
index 3e064182..12104493 100644
--- a/power_sequencer/operators/toggle_waveforms.py
+++ b/power_sequencer/operators/toggle_waveforms.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.global_settings import SequenceTypes
diff --git a/power_sequencer/operators/transitions_remove.py b/power_sequencer/operators/transitions_remove.py
index d1db0d74..1fb1b0d0 100644
--- a/power_sequencer/operators/transitions_remove.py
+++ b/power_sequencer/operators/transitions_remove.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from operator import attrgetter
diff --git a/power_sequencer/operators/trim_left_or_right_handles.py b/power_sequencer/operators/trim_left_or_right_handles.py
index aea81610..c02b8650 100644
--- a/power_sequencer/operators/trim_left_or_right_handles.py
+++ b/power_sequencer/operators/trim_left_or_right_handles.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
from operator import attrgetter
import bpy
diff --git a/power_sequencer/operators/trim_three_point_edit.py b/power_sequencer/operators/trim_three_point_edit.py
index f174589e..6d173258 100644
--- a/power_sequencer/operators/trim_three_point_edit.py
+++ b/power_sequencer/operators/trim_three_point_edit.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.functions import get_mouse_frame_and_channel
diff --git a/power_sequencer/operators/trim_to_surrounding_cuts.py b/power_sequencer/operators/trim_to_surrounding_cuts.py
index ab5df939..3057dfe5 100644
--- a/power_sequencer/operators/trim_to_surrounding_cuts.py
+++ b/power_sequencer/operators/trim_to_surrounding_cuts.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
"""
Find the two closest cuts, trims and deletes all strips above in the range but leaves some
margin. Removes the newly formed gap.
diff --git a/power_sequencer/operators/utils/__init__.py b/power_sequencer/operators/utils/__init__.py
index 71fca8c4..be8d8b53 100644
--- a/power_sequencer/operators/utils/__init__.py
+++ b/power_sequencer/operators/utils/__init__.py
@@ -1,4 +1,2 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
diff --git a/power_sequencer/operators/utils/doc.py b/power_sequencer/operators/utils/doc.py
index 8bdae410..be52c7c2 100644
--- a/power_sequencer/operators/utils/doc.py
+++ b/power_sequencer/operators/utils/doc.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
"""
Utilities to convert operator names and docstrings to human-readable text.
Used to generate names for Blender's operator search, and to generate Power Sequencer's documentation.
diff --git a/power_sequencer/operators/utils/draw.py b/power_sequencer/operators/utils/draw.py
index 5a156bea..3cede778 100644
--- a/power_sequencer/operators/utils/draw.py
+++ b/power_sequencer/operators/utils/draw.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
"""Drawing utilities. A list of functions to draw common elements"""
# import bgl
import blf
diff --git a/power_sequencer/operators/utils/functions.py b/power_sequencer/operators/utils/functions.py
index 0d5c9fcf..c4552c2d 100644
--- a/power_sequencer/operators/utils/functions.py
+++ b/power_sequencer/operators/utils/functions.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
from math import floor, sqrt
from operator import attrgetter
@@ -279,9 +276,7 @@ def trim_strips(context, frame_start, frame_end, to_trim, to_delete=[]):
elif s.frame_final_end > trim_start and s.frame_final_start < trim_start:
s.frame_final_end = trim_start
- for s in to_delete:
- bpy.context.sequences.remove(s)
-
+ delete_strips(to_delete)
for s in initial_selection:
s.select = True
return {"FINISHED"}
@@ -331,7 +326,8 @@ def get_sequences_under_cursor(context):
def ripple_move(context, sequences, duration_frames, delete=False):
- """Moves sequences in the list and ripples the change to all sequences after them, in the corresponding channels
+ """
+ Moves sequences in the list and ripples the change to all sequences after them, in the corresponding channels
The `duration_frames` can be positive or negative.
If `delete` is True, deletes every sequence in `sequences`.
"""
@@ -344,10 +340,7 @@ def ripple_move(context, sequences, duration_frames, delete=False):
]
if delete:
- bpy.ops.sequencer.select_all(action="DESELECT")
- for s in sequences:
- s.select = True
- bpy.ops.sequencer.delete()
+ delete_strips(sequences)
else:
to_ripple = set(to_ripple + sequences)
@@ -390,8 +383,20 @@ def find_strips_in_range(frame_start, frame_end, sequences, find_overlapping=Tru
return strips_inside_range, strips_overlapping_range
+def delete_strips(to_delete):
+ """
+ Deletes the list of sequences `to_delete`
+ """
+ # Effect strips get deleted with their source so we skip them to avoid errors.
+ to_delete = [s for s in to_delete if s.type in SequenceTypes.CUTABLE]
+ sequences = bpy.context.scene.sequence_editor.sequences
+ for s in to_delete:
+ sequences.remove(s)
+
+
def move_selection(context, sequences, frame_offset, channel_offset=0):
- """Offsets the selected `sequences` horizontally and vertically and preserves
+ """
+ Offsets the selected `sequences` horizontally and vertically and preserves
the current selected sequences.
"""
if not sequences:
diff --git a/power_sequencer/operators/utils/global_settings.py b/power_sequencer/operators/utils/global_settings.py
index a5c9756b..6c5ed55a 100644
--- a/power_sequencer/operators/utils/global_settings.py
+++ b/power_sequencer/operators/utils/global_settings.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
class ProjectSettings:
RESOLUTION_X = 1920
RESOLUTION_Y = 1080
diff --git a/power_sequencer/operators/utils/info_progress_bar.py b/power_sequencer/operators/utils/info_progress_bar.py
index e645c762..e479aecf 100644
--- a/power_sequencer/operators/utils/info_progress_bar.py
+++ b/power_sequencer/operators/utils/info_progress_bar.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
diff --git a/power_sequencer/operators/value_offset.py b/power_sequencer/operators/value_offset.py
index 919e8a43..f7ea129f 100644
--- a/power_sequencer/operators/value_offset.py
+++ b/power_sequencer/operators/value_offset.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .utils.doc import doc_brief, doc_description, doc_idname, doc_name
@@ -10,8 +7,9 @@ from .utils.functions import convert_duration_to_frames
class POWER_SEQUENCER_OT_value_offset(bpy.types.Operator):
- """Instantly offset selected strips, either using frames or seconds. """ \
- """Allows to nudge the selection quickly, using keyboard shortcuts"""
+ """Instantly offset selected strips, either using frames or seconds. Allows to
+ nudge the selection quickly, using keyboard shortcuts.
+ """
doc = {
"name": doc_name(__qualname__),
diff --git a/power_sequencer/tools/__init__.py b/power_sequencer/tools/__init__.py
index e7ac0ddc..6c24a950 100644
--- a/power_sequencer/tools/__init__.py
+++ b/power_sequencer/tools/__init__.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import importlib
import os
@@ -16,7 +13,7 @@ def get_tool_classes():
module_paths = ["." + os.path.splitext(f)[0] for f in module_files]
classes = []
for path in module_paths:
- module = importlib.import_module(path, package="power_sequencer.tools")
+ module = importlib.import_module(path, package=__package__)
tool_names = [entry for entry in dir(module) if entry.startswith("POWER_SEQUENCER_TOOL")]
classes.extend([getattr(module, name) for name in tool_names])
return classes
diff --git a/power_sequencer/tools/trim.py b/power_sequencer/tools/trim.py
index 9c60b2d0..7b740828 100644
--- a/power_sequencer/tools/trim.py
+++ b/power_sequencer/tools/trim.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from bpy.types import WorkSpaceTool
diff --git a/power_sequencer/ui/__init__.py b/power_sequencer/ui/__init__.py
index 9b5b5c6b..b81bdea2 100644
--- a/power_sequencer/ui/__init__.py
+++ b/power_sequencer/ui/__init__.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from .menu_contextual import POWER_SEQUENCER_MT_contextual
from .menu_toolbar import (
diff --git a/power_sequencer/ui/menu_contextual.py b/power_sequencer/ui/menu_contextual.py
index 41628448..56b1b33a 100644
--- a/power_sequencer/ui/menu_contextual.py
+++ b/power_sequencer/ui/menu_contextual.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
from ..operators.utils.global_settings import SequenceTypes
diff --git a/power_sequencer/ui/menu_toolbar.py b/power_sequencer/ui/menu_toolbar.py
index 4feb1ea7..6372f139 100755
--- a/power_sequencer/ui/menu_toolbar.py
+++ b/power_sequencer/ui/menu_toolbar.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
diff --git a/power_sequencer/utils/addon_auto_imports.py b/power_sequencer/utils/addon_auto_imports.py
index 47f430b9..21a45615 100644
--- a/power_sequencer/utils/addon_auto_imports.py
+++ b/power_sequencer/utils/addon_auto_imports.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import pkgutil
import importlib
diff --git a/power_sequencer/utils/register_shortcuts.py b/power_sequencer/utils/register_shortcuts.py
index f928f7ff..29694cee 100644
--- a/power_sequencer/utils/register_shortcuts.py
+++ b/power_sequencer/utils/register_shortcuts.py
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
-# Copyright 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
-
-# This file is part of Power Sequencer.
-
+# Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
import bpy
import operator as op
from .. import operators
diff --git a/precision_drawing_tools/__init__.py b/precision_drawing_tools/__init__.py
index 6cb9ab52..6fdb72f2 100644
--- a/precision_drawing_tools/__init__.py
+++ b/precision_drawing_tools/__init__.py
@@ -12,7 +12,7 @@
bl_info = {
"name": "Precision Drawing Tools (PDT)",
"author": "Alan Odom (Clockmender), Rune Morling (ermo)",
- "version": (1, 5, 2),
+ "version": (1, 5, 3),
"blender": (3, 0, 0),
"location": "View3D > UI > PDT",
"description": "Precision Drawing Tools for Accurate Modelling",
diff --git a/precision_drawing_tools/pdt_functions.py b/precision_drawing_tools/pdt_functions.py
index 66bf1de2..9352b66f 100644
--- a/precision_drawing_tools/pdt_functions.py
+++ b/precision_drawing_tools/pdt_functions.py
@@ -8,7 +8,6 @@
import bpy
import bmesh
-import bgl
import gpu
import numpy as np
from mathutils import Vector, Quaternion
@@ -584,7 +583,7 @@ def draw_3d(coords, gtype, rgba, context):
try:
if coords is not None:
- bgl.glEnable(bgl.GL_BLEND)
+ gpu.state.blend_set('ALPHA')
SHADER.bind()
SHADER.uniform_float("color", rgba)
batch.draw(SHADER)
diff --git a/space_view3d_math_vis/__init__.py b/space_view3d_math_vis/__init__.py
index b6aac3cd..ac05ffc6 100644
--- a/space_view3d_math_vis/__init__.py
+++ b/space_view3d_math_vis/__init__.py
@@ -3,8 +3,8 @@
bl_info = {
"name": "Math Vis (Console)",
"author": "Campbell Barton",
- "version": (0, 2, 1),
- "blender": (2, 80, 0),
+ "version": (0, 2, 2),
+ "blender": (3, 0, 0),
"location": "Properties: Scene > Math Vis Console and Python Console: Menu",
"description": "Display console defined mathutils variables in the 3D view",
"doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/math_vis_console.html",
diff --git a/space_view3d_math_vis/draw.py b/space_view3d_math_vis/draw.py
index de7ad946..0b7084eb 100644
--- a/space_view3d_math_vis/draw.py
+++ b/space_view3d_math_vis/draw.py
@@ -3,7 +3,6 @@
import bpy
import blf
import gpu
-import bgl
from gpu_extras.batch import batch_for_shader
from . import utils
@@ -126,9 +125,9 @@ def draw_callback_view():
with_bounding_box = not settings.bbox_hide
if settings.in_front:
- bgl.glDepthFunc(bgl.GL_ALWAYS)
+ gpu.state.depth_test_set('ALWAYS')
else:
- bgl.glDepthFunc(bgl.GL_LESS)
+ gpu.state.depth_test_set('LESS')
data_matrix, data_quat, data_euler, data_vector, data_vector_array = utils.console_math_data()
if settings.index in range(0,len(prop_states)):
diff --git a/viewport_vr_preview/__init__.py b/viewport_vr_preview/__init__.py
index eb7dca4d..cc4580ae 100644
--- a/viewport_vr_preview/__init__.py
+++ b/viewport_vr_preview/__init__.py
@@ -3,7 +3,7 @@
bl_info = {
"name": "VR Scene Inspection",
"author": "Julian Eisel (Severin), Sebastian Koenig, Peter Kim (muxed-reality)",
- "version": (0, 11, 0),
+ "version": (0, 11, 1),
"blender": (3, 2, 0),
"location": "3D View > Sidebar > VR",
"description": ("View the viewport with virtual reality glasses "
diff --git a/viewport_vr_preview/operators.py b/viewport_vr_preview/operators.py
index 3c92a44f..7981511e 100644
--- a/viewport_vr_preview/operators.py
+++ b/viewport_vr_preview/operators.py
@@ -12,7 +12,6 @@ from bpy.types import (
GizmoGroup,
Operator,
)
-import bgl
import math
from math import radians
from mathutils import Euler, Matrix, Quaternion, Vector
@@ -305,8 +304,8 @@ class VIEW3D_GT_vr_camera_cone(Gizmo):
'LINES', lines_shape_verts)
# Ensure correct GL state (otherwise other gizmos might mess that up)
- bgl.glLineWidth(1)
- bgl.glEnable(bgl.GL_BLEND)
+ gpu.state.line_width_set(1.0)
+ gpu.state.blend_set('ALPHA')
self.draw_custom_shape(self.frame_shape)
self.draw_custom_shape(self.lines_shape)
@@ -316,8 +315,8 @@ class VIEW3D_GT_vr_controller_grip(Gizmo):
bl_idname = "VIEW_3D_GT_vr_controller_grip"
def draw(self, context):
- bgl.glLineWidth(1)
- bgl.glEnable(bgl.GL_BLEND)
+ gpu.state.line_width_set(1.0)
+ gpu.state.blend_set('ALPHA')
self.color = 0.422, 0.438, 0.446
self.draw_preset_circle(self.matrix_basis, axis='POS_X')
@@ -329,8 +328,8 @@ class VIEW3D_GT_vr_controller_aim(Gizmo):
bl_idname = "VIEW_3D_GT_vr_controller_aim"
def draw(self, context):
- bgl.glLineWidth(1)
- bgl.glEnable(bgl.GL_BLEND)
+ gpu.state.line_width_set(1.0)
+ gpu.state.blend_set('ALPHA')
self.color = 1.0, 0.2, 0.322
self.draw_preset_arrow(self.matrix_basis, axis='POS_X')