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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-04-20 09:07:03 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-04-21 12:09:06 +0300
commit0a65c4811af31121fd988c38ea8ff1247f0ec83c (patch)
tree5ca78abcc496845461f34e75c893a7a26510bc50
parent812901b2818a72b558d45b6062d0073881adf697 (diff)
Cleanup: run autopep8 on intern/cycles/
Disable autopep8 for the block that yields passes in list_render_passes, for better readability.
-rw-r--r--intern/cycles/app/io_export_cycles_xml.py41
-rw-r--r--intern/cycles/blender/addon/camera.py22
-rw-r--r--intern/cycles/blender/addon/engine.py14
-rw-r--r--intern/cycles/blender/addon/operators.py6
-rw-r--r--intern/cycles/blender/addon/presets.py1
-rw-r--r--intern/cycles/blender/addon/properties.py20
-rw-r--r--intern/cycles/blender/addon/ui.py33
-rw-r--r--intern/cycles/blender/addon/version_update.py32
8 files changed, 112 insertions, 57 deletions
diff --git a/intern/cycles/app/io_export_cycles_xml.py b/intern/cycles/app/io_export_cycles_xml.py
index 0009995653e..ceb30f8fb56 100644
--- a/intern/cycles/app/io_export_cycles_xml.py
+++ b/intern/cycles/app/io_export_cycles_xml.py
@@ -10,6 +10,7 @@ import bpy
from bpy_extras.io_utils import ExportHelper
from bpy.props import PointerProperty, StringProperty
+
def strip(root):
root.text = None
root.tail = None
@@ -17,6 +18,7 @@ def strip(root):
for elem in root:
strip(elem)
+
def write(node, fname):
strip(node)
@@ -26,25 +28,31 @@ def write(node, fname):
f = open(fname, "w")
f.write(s)
+
class CyclesXMLSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
bpy.types.Scene.cycles_xml = PointerProperty(
- type=cls,
- name="Cycles XML export Settings",
- description="Cycles XML export settings")
+ type=cls,
+ name="Cycles XML export Settings",
+ description="Cycles XML export settings",
+ )
cls.filepath = StringProperty(
- name='Filepath',
- description='Filepath for the .xml file',
- maxlen=256,
- default='',
- subtype='FILE_PATH')
+ name='Filepath',
+ description='Filepath for the .xml file',
+ maxlen=256,
+ default='',
+ subtype='FILE_PATH',
+ )
@classmethod
def unregister(cls):
del bpy.types.Scene.cycles_xml
-# User Interface Drawing Code
+
+# User Interface Drawing Code.
+
+
class RenderButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
@@ -114,22 +122,31 @@ class ExportCyclesXML(bpy.types.Operator, ExportHelper):
uvs += str(uvf.uv1[0]) + " " + str(uvf.uv1[1]) + " "
uvs += str(uvf.uv2[0]) + " " + str(uvf.uv2[1]) + " "
uvs += str(uvf.uv3[0]) + " " + str(uvf.uv3[1]) + " "
- if vcount==4:
+ if vcount == 4:
uvs += " " + str(uvf.uv4[0]) + " " + str(uvf.uv4[1]) + " "
-
- node = etree.Element('mesh', attrib={'nverts': nverts.strip(), 'verts': verts.strip(), 'P': P, 'UV' : uvs.strip()})
+ node = etree.Element(
+ 'mesh',
+ attrib={
+ 'nverts': nverts.strip(),
+ 'verts': verts.strip(),
+ 'P': P,
+ 'UV': uvs.strip(),
+ })
# write to file
write(node, filepath)
return {'FINISHED'}
+
def register():
bpy.utils.register_module(__name__)
+
def unregister():
bpy.utils.unregister_module(__name__)
+
if __name__ == "__main__":
register()
diff --git a/intern/cycles/blender/addon/camera.py b/intern/cycles/blender/addon/camera.py
index 9841e031201..0e78112699e 100644
--- a/intern/cycles/blender/addon/camera.py
+++ b/intern/cycles/blender/addon/camera.py
@@ -4,11 +4,14 @@
# <pep8 compliant>
# Fit to match default projective camera with focal_length 50 and sensor_width 36.
-default_fisheye_polynomial = [-1.1735143712967577e-05,
- -0.019988736953434998,
- -3.3525322965709175e-06,
- 3.099275275886036e-06,
- -2.6064646454854524e-08]
+default_fisheye_polynomial = [
+ -1.1735143712967577e-05,
+ -0.019988736953434998,
+ -3.3525322965709175e-06,
+ 3.099275275886036e-06,
+ -2.6064646454854524e-08,
+]
+
# Utilities to generate lens polynomials to match built-in camera types, only here
# for reference at the moment, not used by the code.
@@ -51,7 +54,9 @@ def fisheye_lens_polynomial_from_equidistant(fov=180, sensor_width=36, sensor_he
return [0, -np.radians(fov) / sensor_width, 0, 0, 0]
-def fisheye_lens_polynomial_from_distorted_projective_polynomial(k1, k2, k3, focal_length=50, sensor_width=36, sensor_height=None):
+def fisheye_lens_polynomial_from_distorted_projective_polynomial(
+ k1, k2, k3, focal_length=50, sensor_width=36, sensor_height=None,
+):
import numpy as np
rr = create_grid(sensor_height, sensor_width)
r2 = (rr / focal_length) ** 2
@@ -61,7 +66,10 @@ def fisheye_lens_polynomial_from_distorted_projective_polynomial(k1, k2, k3, foc
polynomial = np.polyfit(rr.flat, (-np.arctan(rr / focal_length * r_coeff)).flat, 4)
return list(reversed(polynomial))
-def fisheye_lens_polynomial_from_distorted_projective_divisions(k1, k2, focal_length=50, sensor_width=36, sensor_height=None):
+
+def fisheye_lens_polynomial_from_distorted_projective_divisions(
+ k1, k2, focal_length=50, sensor_width=36, sensor_height=None,
+):
import numpy as np
rr = create_grid(sensor_height, sensor_width)
r2 = (rr / focal_length) ** 2
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index 1b03581ae03..724e1b8f727 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -98,6 +98,7 @@ def render_frame_finish(engine):
import _cycles
_cycles.render_frame_finish(engine.session)
+
def draw(engine, depsgraph, space_image):
if not engine.session:
return
@@ -168,6 +169,9 @@ def list_render_passes(scene, srl):
# Combined pass.
yield ("Combined", "RGBA", 'COLOR')
+ # Keep alignment for readability.
+ # autopep8: off
+
# Data passes.
if srl.use_pass_z: yield ("Depth", "Z", 'VALUE')
if srl.use_pass_mist: yield ("Mist", "Z", 'VALUE')
@@ -195,9 +199,11 @@ def list_render_passes(scene, srl):
if srl.use_pass_shadow: yield ("Shadow", "RGB", 'COLOR')
if srl.use_pass_ambient_occlusion: yield ("AO", "RGB", 'COLOR')
if crl.use_pass_shadow_catcher: yield ("Shadow Catcher", "RGB", 'COLOR')
+ # autopep8: on
# Debug passes.
- if crl.pass_debug_sample_count: yield ("Debug Sample Count", "X", 'VALUE')
+ if crl.pass_debug_sample_count:
+ yield ("Debug Sample Count", "X", 'VALUE')
# Cryptomatte passes.
crypto_depth = (srl.pass_cryptomatte_depth + 1) // 2
@@ -217,9 +223,9 @@ def list_render_passes(scene, srl):
if crl.use_pass_shadow_catcher:
yield ("Noisy Shadow Catcher", "RGBA", 'COLOR')
if crl.denoising_store_passes:
- yield ("Denoising Normal", "XYZ", 'VECTOR')
- yield ("Denoising Albedo", "RGB", 'COLOR')
- yield ("Denoising Depth", "Z", 'VALUE')
+ yield ("Denoising Normal", "XYZ", 'VECTOR')
+ yield ("Denoising Albedo", "RGB", 'COLOR')
+ yield ("Denoising Depth", "Z", 'VALUE')
# Custom AOV passes.
for aov in srl.aovs:
diff --git a/intern/cycles/blender/addon/operators.py b/intern/cycles/blender/addon/operators.py
index 973088ac3e7..e5d7f00a381 100644
--- a/intern/cycles/blender/addon/operators.py
+++ b/intern/cycles/blender/addon/operators.py
@@ -34,8 +34,8 @@ class CYCLES_OT_use_shading_nodes(Operator):
class CYCLES_OT_denoise_animation(Operator):
"Denoise rendered animation sequence using current scene and view " \
- "layer settings. Requires denoising data passes and output to " \
- "OpenEXR multilayer files"
+ "layer settings. Requires denoising data passes and output to " \
+ "OpenEXR multilayer files"
bl_idname = "cycles.denoise_animation"
bl_label = "Denoise Animation"
@@ -117,7 +117,7 @@ class CYCLES_OT_denoise_animation(Operator):
class CYCLES_OT_merge_images(Operator):
"Combine OpenEXR multilayer images rendered with different sample " \
- "ranges into one image with reduced noise"
+ "ranges into one image with reduced noise"
bl_idname = "cycles.merge_images"
bl_label = "Merge Images"
diff --git a/intern/cycles/blender/addon/presets.py b/intern/cycles/blender/addon/presets.py
index a84c9f07c55..5eaa592a9de 100644
--- a/intern/cycles/blender/addon/presets.py
+++ b/intern/cycles/blender/addon/presets.py
@@ -85,6 +85,7 @@ class AddPresetViewportSampling(AddPresetBase, Operator):
preset_subdir = "cycles/viewport_sampling"
+
classes = (
AddPresetIntegrator,
AddPresetSampling,
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index ed054b041d8..715561ba03d 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -83,7 +83,8 @@ enum_sampling_pattern = (
enum_volume_sampling = (
('DISTANCE', "Distance", "Use distance sampling, best for dense volumes with lights far away"),
('EQUIANGULAR', "Equiangular", "Use equiangular sampling, best for volumes with low density with light inside or near the volume"),
- ('MULTIPLE_IMPORTANCE', "Multiple Importance", "Combine distance and equi-angular sampling for volumes where neither method is ideal"),
+ ('MULTIPLE_IMPORTANCE', "Multiple Importance",
+ "Combine distance and equi-angular sampling for volumes where neither method is ideal"),
)
enum_volume_interpolation = (
@@ -181,7 +182,12 @@ def enum_preview_denoiser(self, context):
oidn_items = enum_openimagedenoise_denoiser(self, context)
if len(optix_items) or len(oidn_items):
- items = [('AUTO', "Automatic", "Use the fastest available denoiser for viewport rendering (OptiX if available, OpenImageDenoise otherwise)", 0)]
+ items = [
+ ('AUTO',
+ "Automatic",
+ ("Use the fastest available denoiser for viewport rendering "
+ "(OptiX if available, OpenImageDenoise otherwise)"),
+ 0)]
else:
items = [('AUTO', "None", "Blender was compiled without a viewport denoiser", 0)]
@@ -210,11 +216,14 @@ enum_denoising_prefilter = (
)
enum_direct_light_sampling_type = (
- ('MULTIPLE_IMPORTANCE_SAMPLING', "Multiple Importance Sampling", "Multiple importance sampling is used to combine direct light contributions from next-event estimation and forward path tracing", 0),
+ ('MULTIPLE_IMPORTANCE_SAMPLING', "Multiple Importance Sampling",
+ "Multiple importance sampling is used to combine direct light contributions from next-event estimation and forward path tracing", 0),
('FORWARD_PATH_TRACING', "Forward Path Tracing", "Direct light contributions are only sampled using forward path tracing", 1),
- ('NEXT_EVENT_ESTIMATION', "Next-Event Estimation", "Direct light contributions are only sampled using next-event estimation", 2),
+ ('NEXT_EVENT_ESTIMATION', "Next-Event Estimation",
+ "Direct light contributions are only sampled using next-event estimation", 2),
)
+
def update_render_passes(self, context):
view_layer = context.view_layer
view_layer.update_render_passes()
@@ -262,7 +271,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Denoise the image with the selected denoiser. "
"For denoising the image after rendering",
items=enum_denoiser,
- default=4, # Use integer to avoid error in builds without OpenImageDenoise.
+ default=4, # Use integer to avoid error in builds without OpenImageDenoise.
update=update_render_passes,
)
denoising_prefilter: EnumProperty(
@@ -1547,7 +1556,6 @@ class CyclesPreferences(bpy.types.AddonPreferences):
row.use_property_split = True
row.prop(self, "use_metalrt")
-
def draw(self, context):
self.draw_impl(self.layout, context)
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 8a7b0635ed7..131b849a094 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -14,6 +14,7 @@ from bl_ui.properties_grease_pencil_common import GreasePencilSimplifyPanel
from bl_ui.properties_render import draw_curves_settings
from bl_ui.properties_view_layer import ViewLayerCryptomattePanel, ViewLayerAOVPanel, ViewLayerLightgroupsPanel
+
class CyclesPresetPanel(PresetPanel, Panel):
COMPAT_ENGINES = {'CYCLES'}
preset_operator = "script.execute_preset"
@@ -25,16 +26,19 @@ class CyclesPresetPanel(PresetPanel, Panel):
render = context.scene.render
render.filter_size = render.filter_size
+
class CYCLES_PT_sampling_presets(CyclesPresetPanel):
bl_label = "Sampling Presets"
preset_subdir = "cycles/sampling"
preset_add_operator = "render.cycles_sampling_preset_add"
+
class CYCLES_PT_viewport_sampling_presets(CyclesPresetPanel):
bl_label = "Viewport Sampling Presets"
preset_subdir = "cycles/viewport_sampling"
preset_add_operator = "render.cycles_viewport_sampling_preset_add"
+
class CYCLES_PT_integrator_presets(CyclesPresetPanel):
bl_label = "Integrator Presets"
preset_subdir = "cycles/integrator"
@@ -90,6 +94,7 @@ def use_metal(context):
return (get_device_type(context) == 'METAL' and cscene.device == 'GPU')
+
def use_cuda(context):
cscene = context.scene.cycles
@@ -101,11 +106,13 @@ def use_hip(context):
return (get_device_type(context) == 'HIP' and cscene.device == 'GPU')
+
def use_optix(context):
cscene = context.scene.cycles
return (get_device_type(context) == 'OPTIX' and cscene.device == 'GPU')
+
def use_multi_device(context):
cscene = context.scene.cycles
if cscene.device != 'GPU':
@@ -133,7 +140,6 @@ def get_effective_preview_denoiser(context):
return 'OIDN'
-
class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
bl_label = "Sampling"
@@ -353,6 +359,7 @@ class CYCLES_RENDER_PT_curves(CyclesButtonsPanel, Panel):
if ccscene.shape == 'RIBBONS':
col.prop(ccscene, "subdivisions", text="Curve Subdivisions")
+
class CYCLES_RENDER_PT_curves_viewport_display(CyclesButtonsPanel, Panel):
bl_label = "Viewport Display"
bl_parent_id = "CYCLES_RENDER_PT_curves"
@@ -361,6 +368,7 @@ class CYCLES_RENDER_PT_curves_viewport_display(CyclesButtonsPanel, Panel):
def draw(self, context):
draw_curves_settings(self, context)
+
class CYCLES_RENDER_PT_volumes(CyclesButtonsPanel, Panel):
bl_label = "Volumes"
bl_options = {'DEFAULT_CLOSED'}
@@ -478,10 +486,10 @@ class CYCLES_RENDER_PT_light_paths_fast_gi(CyclesButtonsPanel, Panel):
col.prop(cscene, "fast_gi_method", text="Method")
if world:
- light = world.light_settings
- col = layout.column(align=True)
- col.prop(light, "ao_factor", text="AO Factor")
- col.prop(light, "distance", text="AO Distance")
+ light = world.light_settings
+ col = layout.column(align=True)
+ col.prop(light, "ao_factor", text="AO Factor")
+ col.prop(light, "distance", text="AO Distance")
if cscene.fast_gi_method == 'REPLACE':
col = layout.column(align=True)
@@ -1034,7 +1042,8 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
def poll(cls, context):
ob = context.object
if CyclesButtonsPanel.poll(context) and ob:
- if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'CAMERA', 'CURVES', 'POINTCLOUD', 'VOLUME'}:
+ if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT',
+ 'META', 'CAMERA', 'CURVES', 'POINTCLOUD', 'VOLUME'}:
return True
if ob.instance_type == 'COLLECTION' and ob.instance_collection:
return True
@@ -1446,7 +1455,14 @@ class CYCLES_WORLD_PT_surface(CyclesButtonsPanel, Panel):
row.use_property_decorate = False
sub = row.column(align=True)
- sub.prop_search(world, "lightgroup", view_layer, "lightgroups", text="Light Group", results_are_suggestions=True)
+ sub.prop_search(
+ world,
+ "lightgroup",
+ view_layer,
+ "lightgroups",
+ text="Light Group",
+ results_are_suggestions=True,
+ )
sub = row.column(align=True)
sub.active = bool(world.lightgroup) and not any(lg.name == world.lightgroup for lg in view_layer.lightgroups)
@@ -1572,7 +1588,6 @@ class CYCLES_WORLD_PT_settings_surface(CyclesButtonsPanel, Panel):
sub.prop(cworld, "is_caustics_light", text="Shadow Caustics")
-
class CYCLES_WORLD_PT_settings_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume"
bl_parent_id = "CYCLES_WORLD_PT_settings"
@@ -1894,6 +1909,7 @@ class CYCLES_RENDER_PT_bake_output(CyclesButtonsPanel, Panel):
if cbk.target == 'IMAGE_TEXTURES':
layout.prop(cbk, "use_clear", text="Clear Image")
+
class CYCLES_RENDER_PT_bake_output_margin(CyclesButtonsPanel, Panel):
bl_label = "Margin"
bl_context = "render"
@@ -1932,7 +1948,6 @@ class CYCLES_RENDER_PT_bake_output_margin(CyclesButtonsPanel, Panel):
layout.prop(cbk, "margin", text="Size")
-
class CYCLES_RENDER_PT_debug(CyclesDebugButtonsPanel, Panel):
bl_label = "Debug"
bl_context = "render"
diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py
index aade864e4c7..651613b0407 100644
--- a/intern/cycles/blender/addon/version_update.py
+++ b/intern/cycles/blender/addon/version_update.py
@@ -72,7 +72,7 @@ def do_versions(self):
# Device might not currently be available so this can fail
try:
if system.legacy_compute_device_type == 1:
- prop.compute_device_type = 'NONE' # Was OpenCL
+ prop.compute_device_type = 'NONE' # Was OpenCL
elif system.legacy_compute_device_type == 2:
prop.compute_device_type = 'CUDA'
else:
@@ -181,24 +181,24 @@ def do_versions(self):
if version <= (2, 92, 4):
if scene.render.engine == 'CYCLES':
- for view_layer in scene.view_layers:
- cview_layer = view_layer.cycles
- view_layer.use_pass_cryptomatte_object = cview_layer.get("use_pass_crypto_object", False)
- view_layer.use_pass_cryptomatte_material = cview_layer.get("use_pass_crypto_material", False)
- view_layer.use_pass_cryptomatte_asset = cview_layer.get("use_pass_crypto_asset", False)
- view_layer.pass_cryptomatte_depth = cview_layer.get("pass_crypto_depth", 6)
+ for view_layer in scene.view_layers:
+ cview_layer = view_layer.cycles
+ view_layer.use_pass_cryptomatte_object = cview_layer.get("use_pass_crypto_object", False)
+ view_layer.use_pass_cryptomatte_material = cview_layer.get("use_pass_crypto_material", False)
+ view_layer.use_pass_cryptomatte_asset = cview_layer.get("use_pass_crypto_asset", False)
+ view_layer.pass_cryptomatte_depth = cview_layer.get("pass_crypto_depth", 6)
if version <= (2, 93, 7):
if scene.render.engine == 'CYCLES':
- for view_layer in scene.view_layers:
- cview_layer = view_layer.cycles
- for caov in cview_layer.get("aovs", []):
- aov_name = caov.get("name", "AOV")
- if aov_name in view_layer.aovs:
- continue
- baov = view_layer.aovs.add()
- baov.name = caov.get("name", "AOV")
- baov.type = "COLOR" if caov.get("type", 1) == 1 else "VALUE"
+ for view_layer in scene.view_layers:
+ cview_layer = view_layer.cycles
+ for caov in cview_layer.get("aovs", []):
+ aov_name = caov.get("name", "AOV")
+ if aov_name in view_layer.aovs:
+ continue
+ baov = view_layer.aovs.add()
+ baov.name = caov.get("name", "AOV")
+ baov.type = "COLOR" if caov.get("type", 1) == 1 else "VALUE"
if version <= (2, 93, 16):
cscene = scene.cycles