add use_simplify toggle in simplify check panel
This commit is contained in:
parent
d08557a7b7
commit
c33eab6f32
100
operators/scene_checker.py
Normal file
100
operators/scene_checker.py
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
import bpy
|
||||||
|
|
||||||
|
from .. import fn
|
||||||
|
from .simplify_conflicts import list_simplify_affected_objects
|
||||||
|
|
||||||
|
## WIP : checker operator to perform all check at once (sometimes a limited version of the check) to expose useful solving operators.
|
||||||
|
|
||||||
|
# region Scene check
|
||||||
|
|
||||||
|
class RT_OT_scene_checker(Operator):
|
||||||
|
bl_idname = "rt.scene_checker"
|
||||||
|
bl_label = "Check Scene "
|
||||||
|
bl_description = "Check / correct some aspect of the scene and objects, properties, etc. and report"
|
||||||
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
|
## List of possible actions calls :
|
||||||
|
# set scene res
|
||||||
|
# set scene percentage at 100:
|
||||||
|
# Disabled animation
|
||||||
|
# Objects visibility conflict
|
||||||
|
# Objects modifiers visibility conflict
|
||||||
|
|
||||||
|
apply_fixes : bpy.props.BoolProperty(name="Apply Fixes", default=False,
|
||||||
|
description="Apply possible fixes instead of just listing (pop the list again in fix mode)",
|
||||||
|
options={'SKIP_SAVE'})
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
self.ctrl = event.ctrl
|
||||||
|
return self.execute(context)
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
problems = []
|
||||||
|
|
||||||
|
## Old method : Apply fixes based on pref (inverted by ctrl key)
|
||||||
|
# # If Ctrl is pressed, invert behavior (invert boolean)
|
||||||
|
# apply ^= self.ctrl
|
||||||
|
|
||||||
|
# apply = self.apply_fixes
|
||||||
|
# if self.ctrl:
|
||||||
|
# apply = True
|
||||||
|
|
||||||
|
## Object visibility conflict
|
||||||
|
viz_ct = 0
|
||||||
|
for o in context.scene.objects:
|
||||||
|
if not (o.hide_get() == o.hide_viewport == o.hide_render):
|
||||||
|
hv = 'No' if o.hide_get() else 'Yes'
|
||||||
|
vp = 'No' if o.hide_viewport else 'Yes'
|
||||||
|
rd = 'No' if o.hide_render else 'Yes'
|
||||||
|
viz_ct += 1
|
||||||
|
print(f'{o.name} : viewlayer {hv} - viewport {vp} - render {rd}')
|
||||||
|
if viz_ct:
|
||||||
|
problems.append(['rt.list_object_visibility_conflicts', f'{viz_ct} objects visibility conflicts (details in console)', 'OBJECT_DATAMODE'])
|
||||||
|
|
||||||
|
## GP modifiers visibility conflict
|
||||||
|
mod_viz_ct = 0
|
||||||
|
for o in context.scene.objects:
|
||||||
|
for m in o.modifiers:
|
||||||
|
if m.show_viewport != m.show_render:
|
||||||
|
vp = 'Yes' if m.show_viewport else 'No'
|
||||||
|
rd = 'Yes' if m.show_render else 'No'
|
||||||
|
mod_viz_ct += 1
|
||||||
|
print(f'{o.name} - modifier {m.name}: viewport {vp} != render {rd}')
|
||||||
|
if mod_viz_ct:
|
||||||
|
problems.append(['rt.list_modifier_visibility', f'{mod_viz_ct} modifiers visibility conflicts (details in console)', 'MODIFIER_DATA'])
|
||||||
|
|
||||||
|
## Collection
|
||||||
|
# TODO: add check for collection visibility conflicts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Simplify affected object
|
||||||
|
if context.scene.render.use_simplify and list_simplify_affected_objects(context):
|
||||||
|
problems.append(['rt.list_object_affected_by_simplify', 'Some objects are affected by simplify (details in console)', 'MOD_SIMPLIFY'])
|
||||||
|
|
||||||
|
|
||||||
|
#### --- print fix/problems report
|
||||||
|
if problems:
|
||||||
|
print('===File check===')
|
||||||
|
for p in problems:
|
||||||
|
if isinstance(p, str):
|
||||||
|
print(p)
|
||||||
|
else:
|
||||||
|
print(p[0])
|
||||||
|
|
||||||
|
if not self.apply_fixes:
|
||||||
|
## button to call the operator again with apply_fixes set to True
|
||||||
|
problems.append(['OPERATOR', 'gp.file_checker', 'Apply Fixes', 'FORWARD', {'apply_fixes': True}])
|
||||||
|
|
||||||
|
# Show in viewport
|
||||||
|
title = "Changed Settings" if apply else "Checked Settings (nothing changed)"
|
||||||
|
fn.show_message_box(problems, _title = title, _icon = 'INFO')
|
||||||
|
else:
|
||||||
|
self.report({'INFO'}, 'All good')
|
||||||
|
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
|
# RT_OT_scene_checker,
|
@ -7,6 +7,102 @@ from bpy.props import (BoolProperty,
|
|||||||
CollectionProperty,
|
CollectionProperty,
|
||||||
StringProperty)
|
StringProperty)
|
||||||
|
|
||||||
|
def list_simplify_affected_objects(context):
|
||||||
|
ob_list = []
|
||||||
|
# Get simplify settings
|
||||||
|
render = context.scene.render
|
||||||
|
simplify_viewport = render.simplify_subdivision
|
||||||
|
simplify_render = render.simplify_subdivision_render
|
||||||
|
max_child_particles = min(render.simplify_child_particles, render.simplify_child_particles_render)
|
||||||
|
volume_limit_resolution = render.simplify_volumes
|
||||||
|
|
||||||
|
for obj in context.scene.objects:
|
||||||
|
affected_data = []
|
||||||
|
|
||||||
|
if hasattr(obj, 'modifiers'):
|
||||||
|
# Check subdivision surface modifiers
|
||||||
|
for modifier in obj.modifiers:
|
||||||
|
if modifier.type == 'SUBSURF':
|
||||||
|
viewport_limited = modifier.levels > simplify_viewport
|
||||||
|
render_limited = modifier.render_levels > simplify_render
|
||||||
|
|
||||||
|
if viewport_limited or render_limited:
|
||||||
|
affected_data.append({
|
||||||
|
'type': 'SUBSURF',
|
||||||
|
'modifier': modifier,
|
||||||
|
'viewport_current': modifier.levels,
|
||||||
|
'viewport_limited': min(modifier.levels, simplify_viewport),
|
||||||
|
'render_current': modifier.render_levels,
|
||||||
|
'render_limited': min(modifier.render_levels, simplify_render),
|
||||||
|
'is_limited': viewport_limited or render_limited
|
||||||
|
})
|
||||||
|
|
||||||
|
# Check multires modifiers
|
||||||
|
if modifier.type == 'MULTIRES':
|
||||||
|
viewport_limited = modifier.levels > simplify_viewport
|
||||||
|
render_limited = modifier.render_levels > simplify_render
|
||||||
|
|
||||||
|
if viewport_limited or render_limited:
|
||||||
|
affected_data.append({
|
||||||
|
'type': 'MULTIRES',
|
||||||
|
'modifier': modifier,
|
||||||
|
'viewport_current': modifier.levels,
|
||||||
|
'viewport_limited': min(modifier.levels, simplify_viewport),
|
||||||
|
'render_current': modifier.render_levels,
|
||||||
|
'render_limited': min(modifier.render_levels, simplify_render),
|
||||||
|
'is_limited': viewport_limited or render_limited
|
||||||
|
})
|
||||||
|
|
||||||
|
# # Check particle systems
|
||||||
|
if hasattr(obj, 'particle_systems') and len(obj.particle_systems) > 0 and max_child_particles < 1.0:
|
||||||
|
for psys in obj.particle_systems:
|
||||||
|
if psys.settings.type in ['EMITTER', 'HAIR']:
|
||||||
|
affected_data.append({
|
||||||
|
'type': 'PARTICLE',
|
||||||
|
'particle_system': psys,
|
||||||
|
'particle_type': psys.settings.type,
|
||||||
|
'count': psys.settings.count
|
||||||
|
})
|
||||||
|
|
||||||
|
# Check materials for subsurface scattering and volumes
|
||||||
|
# material_affected = False
|
||||||
|
# if obj.material_slots:
|
||||||
|
# for slot in obj.material_slots:
|
||||||
|
# if slot.material and slot.material.node_tree:
|
||||||
|
# nodes = slot.material.node_tree.nodes
|
||||||
|
# for node in nodes:
|
||||||
|
# if node.type == 'BSDF_PRINCIPLED':
|
||||||
|
# if hasattr(node.inputs['Subsurface'], 'default_value'):
|
||||||
|
# if node.inputs['Subsurface'].default_value > 0:
|
||||||
|
# affected_data.append({
|
||||||
|
# 'type': 'SUBSURFACE',
|
||||||
|
# 'material': slot.material,
|
||||||
|
# 'subsurface_value': node.inputs['Subsurface'].default_value
|
||||||
|
# })
|
||||||
|
# material_affected = True
|
||||||
|
# break
|
||||||
|
# elif node.type == 'VOLUME_PRINCIPLED':
|
||||||
|
# affected_data.append({
|
||||||
|
# 'type': 'VOLUME_MAT',
|
||||||
|
# 'material': slot.material
|
||||||
|
# })
|
||||||
|
# material_affected = True
|
||||||
|
# break
|
||||||
|
# if material_affected:
|
||||||
|
# break
|
||||||
|
|
||||||
|
# Check for volume objects
|
||||||
|
if obj.type == 'VOLUME' and volume_limit_resolution < 1.0:
|
||||||
|
affected_data.append({
|
||||||
|
'type': 'VOLUME_OBJ'
|
||||||
|
})
|
||||||
|
|
||||||
|
# If object has affected data, add it to the list
|
||||||
|
if affected_data:
|
||||||
|
ob_list.append([obj, affected_data, "OUTLINER_OB_" + obj.type])
|
||||||
|
|
||||||
|
return ob_list
|
||||||
|
|
||||||
class RT_OT_list_object_affected_by_simplify(Operator):
|
class RT_OT_list_object_affected_by_simplify(Operator):
|
||||||
bl_idname = "rt.list_object_affected_by_simplify"
|
bl_idname = "rt.list_object_affected_by_simplify"
|
||||||
bl_label = "List Objects Affected By Simplify"
|
bl_label = "List Objects Affected By Simplify"
|
||||||
@ -14,100 +110,8 @@ class RT_OT_list_object_affected_by_simplify(Operator):
|
|||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
self.ob_list = []
|
# self.ob_list = []
|
||||||
|
self.ob_list = list_simplify_affected_objects(context)
|
||||||
# Get simplify settings
|
|
||||||
render = context.scene.render
|
|
||||||
simplify_viewport = render.simplify_subdivision
|
|
||||||
simplify_render = render.simplify_subdivision_render
|
|
||||||
max_child_particles = min(render.simplify_child_particles, render.simplify_child_particles_render)
|
|
||||||
volume_limit_resolution = render.simplify_volumes
|
|
||||||
|
|
||||||
for obj in context.scene.objects:
|
|
||||||
affected_data = []
|
|
||||||
|
|
||||||
if hasattr(obj, 'modifiers'):
|
|
||||||
# Check subdivision surface modifiers
|
|
||||||
for modifier in obj.modifiers:
|
|
||||||
if modifier.type == 'SUBSURF':
|
|
||||||
viewport_limited = modifier.levels > simplify_viewport
|
|
||||||
render_limited = modifier.render_levels > simplify_render
|
|
||||||
|
|
||||||
if viewport_limited or render_limited:
|
|
||||||
affected_data.append({
|
|
||||||
'type': 'SUBSURF',
|
|
||||||
'modifier': modifier,
|
|
||||||
'viewport_current': modifier.levels,
|
|
||||||
'viewport_limited': min(modifier.levels, simplify_viewport),
|
|
||||||
'render_current': modifier.render_levels,
|
|
||||||
'render_limited': min(modifier.render_levels, simplify_render),
|
|
||||||
'is_limited': viewport_limited or render_limited
|
|
||||||
})
|
|
||||||
|
|
||||||
# Check multires modifiers
|
|
||||||
if modifier.type == 'MULTIRES':
|
|
||||||
viewport_limited = modifier.levels > simplify_viewport
|
|
||||||
render_limited = modifier.render_levels > simplify_render
|
|
||||||
|
|
||||||
if viewport_limited or render_limited:
|
|
||||||
affected_data.append({
|
|
||||||
'type': 'MULTIRES',
|
|
||||||
'modifier': modifier,
|
|
||||||
'viewport_current': modifier.levels,
|
|
||||||
'viewport_limited': min(modifier.levels, simplify_viewport),
|
|
||||||
'render_current': modifier.render_levels,
|
|
||||||
'render_limited': min(modifier.render_levels, simplify_render),
|
|
||||||
'is_limited': viewport_limited or render_limited
|
|
||||||
})
|
|
||||||
|
|
||||||
# # Check particle systems
|
|
||||||
if hasattr(obj, 'particle_systems') and len(obj.particle_systems) > 0 and max_child_particles < 1.0:
|
|
||||||
for psys in obj.particle_systems:
|
|
||||||
if psys.settings.type in ['EMITTER', 'HAIR']:
|
|
||||||
affected_data.append({
|
|
||||||
'type': 'PARTICLE',
|
|
||||||
'particle_system': psys,
|
|
||||||
'particle_type': psys.settings.type,
|
|
||||||
'count': psys.settings.count
|
|
||||||
})
|
|
||||||
|
|
||||||
# Check materials for subsurface scattering and volumes
|
|
||||||
# material_affected = False
|
|
||||||
# if obj.material_slots:
|
|
||||||
# for slot in obj.material_slots:
|
|
||||||
# if slot.material and slot.material.node_tree:
|
|
||||||
# nodes = slot.material.node_tree.nodes
|
|
||||||
# for node in nodes:
|
|
||||||
# if node.type == 'BSDF_PRINCIPLED':
|
|
||||||
# if hasattr(node.inputs['Subsurface'], 'default_value'):
|
|
||||||
# if node.inputs['Subsurface'].default_value > 0:
|
|
||||||
# affected_data.append({
|
|
||||||
# 'type': 'SUBSURFACE',
|
|
||||||
# 'material': slot.material,
|
|
||||||
# 'subsurface_value': node.inputs['Subsurface'].default_value
|
|
||||||
# })
|
|
||||||
# material_affected = True
|
|
||||||
# break
|
|
||||||
# elif node.type == 'VOLUME_PRINCIPLED':
|
|
||||||
# affected_data.append({
|
|
||||||
# 'type': 'VOLUME_MAT',
|
|
||||||
# 'material': slot.material
|
|
||||||
# })
|
|
||||||
# material_affected = True
|
|
||||||
# break
|
|
||||||
# if material_affected:
|
|
||||||
# break
|
|
||||||
|
|
||||||
# Check for volume objects
|
|
||||||
if obj.type == 'VOLUME' and volume_limit_resolution < 1.0:
|
|
||||||
affected_data.append({
|
|
||||||
'type': 'VOLUME_OBJ'
|
|
||||||
})
|
|
||||||
|
|
||||||
# If object has affected data, add it to the list
|
|
||||||
if affected_data:
|
|
||||||
self.ob_list.append([obj, affected_data, "OUTLINER_OB_" + obj.type])
|
|
||||||
|
|
||||||
# Sort by object type, then by name
|
# Sort by object type, then by name
|
||||||
self.ob_list.sort(key=lambda x: (x[2], x[0].name))
|
self.ob_list.sort(key=lambda x: (x[2], x[0].name))
|
||||||
|
|
||||||
@ -119,6 +123,11 @@ class RT_OT_list_object_affected_by_simplify(Operator):
|
|||||||
layout.use_property_split = True
|
layout.use_property_split = True
|
||||||
render = context.scene.render
|
render = context.scene.render
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(render, "use_simplify", text="Use Simplify")
|
||||||
|
if not render.use_simplify:
|
||||||
|
row.label(text="Simplify is Disabled", icon='INFO')
|
||||||
|
|
||||||
# Get current simplify settings
|
# Get current simplify settings
|
||||||
simplify_viewport = render.simplify_subdivision
|
simplify_viewport = render.simplify_subdivision
|
||||||
simplify_render = render.simplify_subdivision_render
|
simplify_render = render.simplify_subdivision_render
|
||||||
|
Loading…
x
Reference in New Issue
Block a user