diff options
author | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2022-04-25 15:38:30 +0300 |
---|---|---|
committer | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2022-04-25 15:38:30 +0300 |
commit | d1b824f3c2a7a7b3e37e70f336e5a1580028c63e (patch) | |
tree | 5173c455757cbb873633adf47104b7a70975bd53 /render_povray/render_gui.py | |
parent | d8258116362889d6d5f7af4e544f7b9f1abef1e8 (diff) |
POV: fix some nested code and further files structure cleanup
* FIX: wrongly nested pov braces made the default outpout file fail
* FIX: use agnostic metallic property rather than create a duplicate
* FIX: some 2.8 deprecated properties rewired in spec;diff; emit;ambient
* FIX: clean up, hierarchize and redesign Global Settings ui panel
* FIX: re-wire world background alpha to agnostic prop and redo its ui
* FIX: wrong nested pov braces making the default outpout file fail
* FIX: use agnostic metallic property rather than create a duplicate
* FIX: reduced arguments numbers by imports and relocating variables
* FIX: use more list comprehesions to reduce nested conditions levels
* FIX: use more consistent class names but cleanup still not finished
* FIX: use single quotes for enums preferably to distinguish strings
* FIX: basic level of nodes based material (diffuse color) broken API
* FIX: blurry reflection corner case caused output file to fail
* FIX: added context managing ("with") syntaxes reducing crash cases
___________________________________________________________
* ADD: model_all.py file to extract mostly object level loop and utils
* ADD: model_meta_topology.py file to extract metaballs export
* ADD: object_primitives_topology.py to extract pov compound primitives
* ADD: nodes_fn.py file to extract main node exporting function
* ADD: nodes_gui.py file to extract node operators and menus
* ADD: nodes_properties.py file to extract nodes sub parameters
* ADD: particles_properties.py to extract particles and fx parameters
* ADD: render_core.py to extract main RenderEngine inheriting class(es)
* ADD: shading_ray_properties.py to extract pathtraced shader parameters
* ADD: texturing_procedural.py to extract algorithmic texture influences
___________________________________________________________
* UPDATE: workspace tools icons and a couple of other icons choices
* RENAME: pov.add.polygontocircle.dat macro workspace tool icon
* RENAME: base_ui.py to ui_core.py
* RENAME: shading_nodes.py to nodes.py
* RENAME: df3_library.py to voxel_lib.py to make dot lookup inform more
* RENAME: object_mesh_topology.py to model_poly_topology.py
* RENAME: object_curve_topology.py to model_curve_topology.py
* RENAME: object_gui.py to model_gui.py
* RENAME: object_primitives.py to model_primitives.py
* RENAME: object_properties.py to model_properties.py
* RENAME: object_particles.py to particles.py
Diffstat (limited to 'render_povray/render_gui.py')
-rwxr-xr-x | render_povray/render_gui.py | 250 |
1 files changed, 170 insertions, 80 deletions
diff --git a/render_povray/render_gui.py b/render_povray/render_gui.py index cc3dcf23..465f5a48 100755 --- a/render_povray/render_gui.py +++ b/render_povray/render_gui.py @@ -21,7 +21,7 @@ from bl_ui import properties_output for member in dir(properties_output): subclass = getattr(properties_output, member) if hasattr(subclass, "COMPAT_ENGINES"): - subclass.COMPAT_ENGINES.add('POVRAY_RENDER') + subclass.COMPAT_ENGINES.add("POVRAY_RENDER") del properties_output from bl_ui import properties_freestyle @@ -29,10 +29,9 @@ from bl_ui import properties_freestyle for member in dir(properties_freestyle): subclass = getattr(properties_freestyle, member) if hasattr(subclass, "COMPAT_ENGINES") and ( - subclass.bl_space_type != 'PROPERTIES' - or subclass.bl_context != "render" + subclass.bl_space_type != "PROPERTIES" or subclass.bl_context != "render" ): - subclass.COMPAT_ENGINES.add('POVRAY_RENDER') + subclass.COMPAT_ENGINES.add("POVRAY_RENDER") # subclass.bl_parent_id = "RENDER_PT_POV_filter" del properties_freestyle @@ -41,7 +40,7 @@ from bl_ui import properties_view_layer for member in dir(properties_view_layer): subclass = getattr(properties_view_layer, member) if hasattr(subclass, "COMPAT_ENGINES"): - subclass.COMPAT_ENGINES.add('POVRAY_RENDER') + subclass.COMPAT_ENGINES.add("POVRAY_RENDER") del properties_view_layer # Use some of the existing buttons. @@ -68,10 +67,10 @@ class RenderButtonsPanel: """Use this class to define buttons from the render tab of properties window.""" - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" bl_context = "render" - COMPAT_ENGINES = {'POVRAY_RENDER'} + COMPAT_ENGINES = {"POVRAY_RENDER"} @classmethod def poll(cls, context): @@ -82,16 +81,16 @@ class RenderButtonsPanel: class RENDER_PT_POV_export_settings(RenderButtonsPanel, Panel): """Use this class to define pov ini settings buttons.""" - bl_options = {'DEFAULT_CLOSED'} + bl_options = {"DEFAULT_CLOSED"} bl_label = "Auto Start" - COMPAT_ENGINES = {'POVRAY_RENDER'} + COMPAT_ENGINES = {"POVRAY_RENDER"} def draw_header(self, context): scene = context.scene if scene.pov.tempfiles_enable: - self.layout.prop(scene.pov, "tempfiles_enable", text="", icon='AUTO') + self.layout.prop(scene.pov, "tempfiles_enable", text="", icon="AUTO") else: - self.layout.prop(scene.pov, "tempfiles_enable", text="", icon='CONSOLE') + self.layout.prop(scene.pov, "tempfiles_enable", text="", icon="CONSOLE") def draw(self, context): @@ -104,13 +103,15 @@ class RENDER_PT_POV_export_settings(RenderButtonsPanel, Panel): col = split.column() col.label(text="Command line options:") - col.prop(scene.pov, "command_line_switches", text="", icon='RIGHTARROW') + col.prop(scene.pov, "command_line_switches", text="", icon="RIGHTARROW") split = layout.split() # layout.active = not scene.pov.tempfiles_enable if not scene.pov.tempfiles_enable: - split.prop(scene.pov, "deletefiles_enable", text="Delete files") - split.prop(scene.pov, "pov_editor", text="POV Editor") + split.prop(scene.pov, "deletefiles_enable", text="Delete") + if not platform.startswith("win"): + split.prop(scene.pov, "sdl_window_enable", text="Show") + split.prop(scene.pov, "pov_editor", text="Edit") col = layout.column() col.prop(scene.pov, "scene_name", text="Name") @@ -120,7 +121,7 @@ class RENDER_PT_POV_export_settings(RenderButtonsPanel, Panel): split = layout.split() split.prop(scene.pov, "indentation_character", text="Indent") - if scene.pov.indentation_character == 'SPACE': + if scene.pov.indentation_character == "SPACE": split.prop(scene.pov, "indentation_spaces", text="Spaces") row = layout.row() @@ -129,19 +130,35 @@ class RENDER_PT_POV_export_settings(RenderButtonsPanel, Panel): class RENDER_PT_POV_render_settings(RenderButtonsPanel, Panel): - """Use this class to define pov render settings buttons.""" + """Use this class to host pov render settings buttons from other sub panels.""" bl_label = "Global Settings" - bl_icon = 'SETTINGS' - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'POVRAY_RENDER'} + bl_icon = "SETTINGS" + bl_options = {"DEFAULT_CLOSED"} + COMPAT_ENGINES = {"POVRAY_RENDER"} def draw_header(self, context): scene = context.scene if scene.pov.global_settings_advanced: - self.layout.prop(scene.pov, "global_settings_advanced", text="", icon='SETTINGS') + self.layout.prop(scene.pov, "global_settings_advanced", text="", icon="PREFERENCES") else: - self.layout.prop(scene.pov, "global_settings_advanced", text="", icon='PREFERENCES') + self.layout.prop(scene.pov, "global_settings_advanced", text="", icon="SETTINGS") + + def draw(self, context): + layout = self.layout + + scene = context.scene + + layout.active = scene.pov.global_settings_advanced + + +class RENDER_PT_POV_light_paths(RenderButtonsPanel, Panel): + """Use this class to define pov's main light ray relative settings buttons.""" + + bl_label = "Light Paths Tracing" + bl_parent_id = "RENDER_PT_POV_render_settings" + bl_options = {"DEFAULT_CLOSED"} + COMPAT_ENGINES = {"POVRAY_RENDER"} def draw(self, context): layout = self.layout @@ -149,41 +166,110 @@ class RENDER_PT_POV_render_settings(RenderButtonsPanel, Panel): scene = context.scene # rd = context.scene.render # layout.active = (scene.pov.max_trace_level != 0) + layout.active = scene.pov.global_settings_advanced + if scene.pov.use_shadows: + layout.prop(scene.pov, "use_shadows", icon="COMMUNITY") + else: + layout.prop(scene.pov, "use_shadows", icon="USER") + col = layout.column() + col.prop(scene.pov, "max_trace_level", text="Ray Depth") + row = layout.row(align=True) + row.prop(scene.pov, "adc_bailout") + + +class RENDER_PT_POV_film(RenderButtonsPanel, Panel): + """Use this class to define pov film settings buttons.""" + + bl_label = "Film" + bl_parent_id = "RENDER_PT_POV_render_settings" + bl_options = {"DEFAULT_CLOSED"} + COMPAT_ENGINES = {"POVRAY_RENDER"} - if not platform.startswith('win'): - layout.prop(scene.pov, "sdl_window_enable", text="POV-Ray SDL Window") + def draw(self, context): + layout = self.layout + + povprops = context.scene.pov + agnosticprops = context.scene.render + layout.active = povprops.global_settings_advanced col = layout.column() - col.label(text="Main Path Tracing:") - col.prop(scene.pov, "max_trace_level", text="Ray Depth") - align = True + col.label(text="Background") + row = layout.row(align=True) + if agnosticprops.film_transparent: + row.prop( + agnosticprops, + "film_transparent", + text="Blender alpha", + icon="NODE_COMPOSITING", + invert_checkbox=True, + ) + else: + row.prop( + agnosticprops, + "film_transparent", + text="POV alpha", + icon="IMAGE_ALPHA", + invert_checkbox=True, + ) + row.prop(povprops, "alpha_mode", text="") + if povprops.alpha_mode == "SKY": + row.label(text=" (color only)") + elif povprops.alpha_mode == "TRANSPARENT": + row.prop(povprops, "alpha_filter", text="(premultiplied)", slider=True) + else: + # povprops.alpha_mode == 'STRAIGHT' + row.label(text=" (unassociated)") + + +class RENDER_PT_POV_hues(RenderButtonsPanel, Panel): + """Use this class to define pov RGB tweaking buttons.""" + + bl_label = "Hues" + bl_parent_id = "RENDER_PT_POV_render_settings" + bl_options = {"DEFAULT_CLOSED"} + COMPAT_ENGINES = {"POVRAY_RENDER"} + + def draw(self, context): + layout = self.layout + + scene = context.scene + layout.active = scene.pov.global_settings_advanced - row = layout.row(align=align) - row.prop(scene.pov, "adc_bailout") - row = layout.row(align=align) + + row = layout.row(align=True) row.prop(scene.pov, "ambient_light") - row = layout.row(align=align) + row = layout.row(align=True) row.prop(scene.pov, "irid_wavelength") - row = layout.row(align=align) - row.prop(scene.pov, "number_of_waves") - row = layout.row(align=align) - row.prop(scene.pov, "noise_generator") + row = layout.row(align=True) - split = layout.split() - split.label(text="Shading:") - split = layout.split() - row = split.row(align=align) - row.prop(scene.pov, "use_shadows") - row.prop(scene.pov, "alpha_mode") +class RENDER_PT_POV_pattern_rules(RenderButtonsPanel, Panel): + """Use this class to change pov sets of texture generating algorythms.""" + + bl_label = "Pattern Rules" + bl_parent_id = "RENDER_PT_POV_render_settings" + bl_options = {"DEFAULT_CLOSED"} + COMPAT_ENGINES = {"POVRAY_RENDER"} + + def draw(self, context): + layout = self.layout + + scene = context.scene + + layout.active = scene.pov.global_settings_advanced + + row = layout.row(align=True) + row.prop(scene.pov, "number_of_waves") + row = layout.row(align=True) + row.prop(scene.pov, "noise_generator") class RENDER_PT_POV_photons(RenderButtonsPanel, Panel): """Use this class to define pov photons buttons.""" bl_label = "Photons" - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'POVRAY_RENDER'} + bl_options = {"DEFAULT_CLOSED"} + COMPAT_ENGINES = {"POVRAY_RENDER"} # def draw_header(self, context): # self.layout.label(icon='SETTINGS') @@ -191,9 +277,9 @@ class RENDER_PT_POV_photons(RenderButtonsPanel, Panel): def draw_header(self, context): scene = context.scene if scene.pov.photon_enable: - self.layout.prop(scene.pov, "photon_enable", text="", icon='PMARKER_ACT') + self.layout.prop(scene.pov, "photon_enable", text="", icon="PARTICLES") else: - self.layout.prop(scene.pov, "photon_enable", text="", icon='PMARKER') + self.layout.prop(scene.pov, "photon_enable", text="", icon="MOD_PARTICLES") def draw(self, context): scene = context.scene @@ -214,20 +300,20 @@ class RENDER_PT_POV_photons(RenderButtonsPanel, Panel): col.prop(scene.pov, "photon_gather_max") box = layout.box() - box.label(text='Photon Map File:') + box.label(text="Photon Map File:") row = box.row() row.prop(scene.pov, "photon_map_file_save_load", expand=True) - if scene.pov.photon_map_file_save_load in {'save'}: + if scene.pov.photon_map_file_save_load in {"save"}: box.prop(scene.pov, "photon_map_dir") box.prop(scene.pov, "photon_map_filename") - if scene.pov.photon_map_file_save_load in {'load'}: + if scene.pov.photon_map_file_save_load in {"load"}: box.prop(scene.pov, "photon_map_file") # end main photons def uberpov_only_qmc_til_pov38release(layout): col = layout.column() - col.alignment = 'CENTER' + col.alignment = "CENTER" col.label(text="Stochastic Anti Aliasing is") col.label(text="Only Available with UberPOV") col.label(text="Feature Set in User Preferences.") @@ -252,18 +338,18 @@ class RENDER_PT_POV_antialias(RenderButtonsPanel, Panel): """Use this class to define pov antialiasing buttons.""" bl_label = "Anti-Aliasing" - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'POVRAY_RENDER'} + bl_options = {"DEFAULT_CLOSED"} + COMPAT_ENGINES = {"POVRAY_RENDER"} def draw_header(self, context): prefs = bpy.context.preferences.addons[__package__].preferences scene = context.scene - if prefs.branch_feature_set_povray != 'uberpov' and scene.pov.antialias_method == '2': - self.layout.prop(scene.pov, "antialias_enable", text="", icon='ERROR') + if prefs.branch_feature_set_povray != "uberpov" and scene.pov.antialias_method == "2": + self.layout.prop(scene.pov, "antialias_enable", text="", icon="ERROR") elif scene.pov.antialias_enable: - self.layout.prop(scene.pov, "antialias_enable", text="", icon='ANTIALIASED') + self.layout.prop(scene.pov, "antialias_enable", text="", icon="ANTIALIASED") else: - self.layout.prop(scene.pov, "antialias_enable", text="", icon='ALIASED') + self.layout.prop(scene.pov, "antialias_enable", text="", icon="ALIASED") def draw(self, context): prefs = bpy.context.preferences.addons[__package__].preferences @@ -275,29 +361,29 @@ class RENDER_PT_POV_antialias(RenderButtonsPanel, Panel): row = layout.row() row.prop(scene.pov, "antialias_method", text="") - if prefs.branch_feature_set_povray != 'uberpov' and scene.pov.antialias_method == '2': + if prefs.branch_feature_set_povray != "uberpov" and scene.pov.antialias_method == "2": uberpov_only_qmc_til_pov38release(layout) else: no_qmc_fallbacks(row, scene, layout) - if prefs.branch_feature_set_povray == 'uberpov': + if prefs.branch_feature_set_povray == "uberpov": row = layout.row() row.prop(scene.pov, "antialias_confidence", text="AA Confidence") - row.enabled = scene.pov.antialias_method == '2' + row.enabled = scene.pov.antialias_method == "2" class RENDER_PT_POV_radiosity(RenderButtonsPanel, Panel): """Use this class to define pov radiosity buttons.""" bl_label = "Diffuse Radiosity" - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'POVRAY_RENDER'} + bl_options = {"DEFAULT_CLOSED"} + COMPAT_ENGINES = {"POVRAY_RENDER"} def draw_header(self, context): scene = context.scene if scene.pov.radio_enable: - self.layout.prop(scene.pov, "radio_enable", text="", icon='OUTLINER_OB_LIGHTPROBE') + self.layout.prop(scene.pov, "radio_enable", text="", icon="OUTLINER_OB_LIGHTPROBE") else: - self.layout.prop(scene.pov, "radio_enable", text="", icon='LIGHTPROBE_CUBEMAP') + self.layout.prop(scene.pov, "radio_enable", text="", icon="LIGHTPROBE_CUBEMAP") def draw(self, context): layout = self.layout @@ -340,7 +426,7 @@ class RENDER_PT_POV_radiosity(RenderButtonsPanel, Panel): col.prop(scene.pov, "radio_subsurface") -class POV_RADIOSITY_MT_presets(Menu): +class RADIOSITY_MT_POV_presets(Menu): """Use this class to define pov radiosity presets menu.""" bl_label = "Radiosity Presets" @@ -352,10 +438,10 @@ class POV_RADIOSITY_MT_presets(Menu): class RENDER_OT_POV_radiosity_add_preset(AddPresetBase, Operator): """Use this class to define pov radiosity add presets button""" - '''Add a Radiosity Preset''' + """Add a Radiosity Preset""" bl_idname = "scene.radiosity_preset_add" bl_label = "Add Radiosity Preset" - preset_menu = "POV_RADIOSITY_MT_presets" + preset_menu = "RADIOSITY_MT_POV_presets" # variable used for all preset values preset_defines = ["scene = bpy.context.scene"] @@ -391,10 +477,10 @@ def rad_panel_func(self, context): layout = self.layout row = layout.row(align=True) - row.menu(POV_RADIOSITY_MT_presets.__name__, text=POV_RADIOSITY_MT_presets.bl_label) - row.operator(RENDER_OT_POV_radiosity_add_preset.bl_idname, text="", icon='ADD') + row.menu(RADIOSITY_MT_POV_presets.__name__, text=RADIOSITY_MT_POV_presets.bl_label) + row.operator(RENDER_OT_POV_radiosity_add_preset.bl_idname, text="", icon="ADD") row.operator( - RENDER_OT_POV_radiosity_add_preset.bl_idname, text="", icon='REMOVE' + RENDER_OT_POV_radiosity_add_preset.bl_idname, text="", icon="REMOVE" ).remove_active = True @@ -408,27 +494,27 @@ def rad_panel_func(self, context): bpy.utils.script_paths(subdir="addons") # render_freestyle_svg = os.path.join(bpy.utils.script_paths(subdir="addons"), "render_freestyle_svg.py") -render_freestyle_svg = bpy.context.preferences.addons.get('render_freestyle_svg') +render_freestyle_svg = bpy.context.preferences.addons.get("render_freestyle_svg") # mpath=addon_utils.paths()[0].render_freestyle_svg # import mpath # from mpath import render_freestyle_svg #= addon_utils.modules(module_cache=['Freestyle SVG Exporter']) # from scripts\\addons import render_freestyle_svg if check_render_freestyle_svg(): - ''' + """ snippetsWIP import myscript import importlib importlib.reload(myscript) myscript.main() - ''' + """ for member in dir(render_freestyle_svg): subclass = getattr(render_freestyle_svg, member) if hasattr(subclass, "COMPAT_ENGINES"): - subclass.COMPAT_ENGINES.add('POVRAY_RENDER') + subclass.COMPAT_ENGINES.add("POVRAY_RENDER") if subclass.bl_idname == "RENDER_PT_SVGExporterPanel": subclass.bl_parent_id = "RENDER_PT_POV_filter" - subclass.bl_options = {'HIDE_HEADER'} + subclass.bl_options = {"HIDE_HEADER"} # subclass.bl_order = 11 print(subclass.bl_info) @@ -439,14 +525,14 @@ class RENDER_PT_POV_filter(RenderButtonsPanel, Panel): """Use this class to invoke stuff like Freestyle UI.""" bl_label = "Freestyle" - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'POVRAY_RENDER'} + bl_options = {"DEFAULT_CLOSED"} + COMPAT_ENGINES = {"POVRAY_RENDER"} @classmethod def poll(cls, context): with_freestyle = bpy.app.build_options.freestyle engine = context.scene.render.engine - return with_freestyle and engine == 'POVRAY_RENDER' + return with_freestyle and engine == "POVRAY_RENDER" def draw_header(self, context): @@ -455,10 +541,10 @@ class RENDER_PT_POV_filter(RenderButtonsPanel, Panel): layout = self.layout if rd.use_freestyle: - layout.prop(rd, "use_freestyle", text="", icon='LINE_DATA') + layout.prop(rd, "use_freestyle", text="", icon="LINE_DATA") else: - layout.prop(rd, "use_freestyle", text="", icon='OUTLINER_OB_IMAGE') + layout.prop(rd, "use_freestyle", text="", icon="MOD_LINEART") def draw(self, context): rd = context.scene.render @@ -472,7 +558,7 @@ class RENDER_PT_POV_filter(RenderButtonsPanel, Panel): flow.prop(rd, "line_thickness_mode", expand=True) - if rd.line_thickness_mode == 'ABSOLUTE': + if rd.line_thickness_mode == "ABSOLUTE": flow.prop(rd, "line_thickness") # Warning if the Freestyle SVG Exporter addon is not enabled @@ -508,12 +594,16 @@ class RENDER_PT_POV_filter(RenderButtonsPanel, Panel): classes = ( RENDER_PT_POV_export_settings, RENDER_PT_POV_render_settings, + RENDER_PT_POV_light_paths, + RENDER_PT_POV_film, + RENDER_PT_POV_hues, + RENDER_PT_POV_pattern_rules, RENDER_PT_POV_photons, RENDER_PT_POV_antialias, RENDER_PT_POV_radiosity, RENDER_PT_POV_filter, # RENDER_PT_povray_baking, - POV_RADIOSITY_MT_presets, + RADIOSITY_MT_POV_presets, RENDER_OT_POV_radiosity_add_preset, ) |