Povray: Fix bunch of issues after recent refactor.

Those were breaking automated tests, since (un)registering was not
working properly. Mainly:

* Use `hasattr` instead of try/except when batch-assigning to a variable
  that does not always exist.
* Fix some incorrect call to sub-`register()` from parent `unregister()`
  functions.
* Remove double definition (in two different files) of World's pov
  textures.
This commit is contained in:
Bastien Montagne 2021-05-27 17:26:34 +02:00
parent ea587cffd1
commit 73c752effe
8 changed files with 22 additions and 214 deletions

View File

@ -422,7 +422,7 @@ def unregister():
scripting.unregister()
base_ui.unregister()
render.unregister()
scenography.register()
scenography.unregister()
scripting_properties.unregister()
object_properties.unregister()
texturing_properties.unregister()
@ -430,7 +430,7 @@ def unregister():
scenography_properties.unregister()
render_properties.unregister()
for cls in classes:
for cls in reversed(classes):
unregister_class(cls)

View File

@ -304,4 +304,4 @@ def unregister():
shading_gui.unregister()
object_gui.unregister()
scenography_gui.unregister()
render_gui.register()
render_gui.unregister()

View File

@ -34,11 +34,8 @@ from bl_ui import properties_data_modifier
for member in dir(properties_data_modifier):
subclass = getattr(properties_data_modifier, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
del properties_data_modifier

View File

@ -36,38 +36,26 @@ from bl_ui import properties_output
for member in dir(properties_output):
subclass = getattr(properties_output, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_output
from bl_ui import properties_freestyle
for member in dir(properties_freestyle):
subclass = getattr(properties_freestyle, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
if not (subclass.bl_space_type == 'PROPERTIES' and subclass.bl_context == "render"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
# subclass.bl_parent_id = "RENDER_PT_POV_filter"
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_freestyle
from bl_ui import properties_view_layer
for member in dir(properties_view_layer):
subclass = getattr(properties_view_layer, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_view_layer
# Use some of the existing buttons.
@ -452,17 +440,13 @@ if check_render_freestyle_svg():
'''
for member in dir(render_freestyle_svg):
subclass = getattr(render_freestyle_svg, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
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_order = 11
print(subclass.bl_info)
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
# del render_freestyle_svg.RENDER_PT_SVGExporterPanel.bl_parent_id

View File

@ -31,12 +31,8 @@ from bl_ui import properties_data_camera
for member in dir(properties_data_camera):
subclass = getattr(properties_data_camera, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_data_camera
# ##################################
@ -54,12 +50,8 @@ from bl_ui import properties_physics_common
for member in dir(properties_physics_common):
subclass = getattr(properties_physics_common, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_physics_common
# Physics Rigid Bodies wrapping every class 'as is'
@ -67,12 +59,8 @@ from bl_ui import properties_physics_rigidbody
for member in dir(properties_physics_rigidbody):
subclass = getattr(properties_physics_rigidbody, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_physics_rigidbody
# Physics Rigid Body Constraint wrapping every class 'as is'
@ -80,12 +68,8 @@ from bl_ui import properties_physics_rigidbody_constraint
for member in dir(properties_physics_rigidbody_constraint):
subclass = getattr(properties_physics_rigidbody_constraint, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_physics_rigidbody_constraint
# Physics Smoke and fluids wrapping every class 'as is'
@ -93,12 +77,8 @@ from bl_ui import properties_physics_fluid
for member in dir(properties_physics_fluid):
subclass = getattr(properties_physics_fluid, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_physics_fluid
# Physics softbody wrapping every class 'as is'
@ -106,12 +86,8 @@ from bl_ui import properties_physics_softbody
for member in dir(properties_physics_softbody):
subclass = getattr(properties_physics_softbody, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_physics_softbody
# Physics Field wrapping every class 'as is'
@ -119,12 +95,8 @@ from bl_ui import properties_physics_field
for member in dir(properties_physics_field):
subclass = getattr(properties_physics_field, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_physics_field
# Physics Cloth wrapping every class 'as is'
@ -132,12 +104,8 @@ from bl_ui import properties_physics_cloth
for member in dir(properties_physics_cloth):
subclass = getattr(properties_physics_cloth, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_physics_cloth
# Physics Dynamic Paint wrapping every class 'as is'
@ -145,24 +113,16 @@ from bl_ui import properties_physics_dynamicpaint
for member in dir(properties_physics_dynamicpaint):
subclass = getattr(properties_physics_dynamicpaint, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_physics_dynamicpaint
from bl_ui import properties_particle
for member in dir(properties_particle): # add all "particle" panels from blender
subclass = getattr(properties_particle, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_particle
@ -795,6 +755,7 @@ def register():
def unregister():
bpy.types.LIGHT_PT_POV_light.remove(light_panel_func)
for cls in reversed(classes):
unregister_class(cls)
bpy.types.LIGHT_PT_POV_light.remove(light_panel_func)

View File

@ -353,125 +353,6 @@ class RenderPovSettingsWorld(PropertyGroup):
)
class WorldTextureSlot(PropertyGroup):
"""Declare world texture slot level properties for UI and translated to POV."""
bl_idname = ("pov_texture_slots",)
bl_description = ("Texture_slots from Blender-2.79",)
# Adding a "real" texture datablock as property is not possible
# (or at least not easy through a dynamically populated EnumProperty).
# That's why we'll use a prop_search() UILayout function in texturing_gui.py.
# So we'll assign the name of the needed texture datablock to the below StringProperty.
texture: StringProperty(update=active_texture_name_from_uilist)
# and use another temporary StringProperty to change the linked data
texture_search: StringProperty(
name="", update=active_texture_name_from_search, description="Browse Texture to be linked"
)
blend_factor: FloatProperty(
name="Blend",
description="Amount texture affects color progression of the " "background",
soft_min=0.0,
soft_max=1.0,
default=1.0,
)
horizon_factor: FloatProperty(
name="Horizon",
description="Amount texture affects color of the horizon",
soft_min=0.0,
soft_max=1.0,
default=1.0,
)
object: StringProperty(
name="Object",
description="Object to use for mapping with Object texture coordinates",
default="",
)
offset: FloatVectorProperty(
name="Offset",
description=("Fine tune of the texture mapping X, Y and Z locations "),
precision=4,
step=0.1,
soft_min=-100.0,
soft_max=100.0,
default=(0.0, 0.0, 0.0),
options={"ANIMATABLE"},
subtype="TRANSLATION",
)
scale: FloatVectorProperty(
name="Size",
subtype="XYZ",
size=3,
description="Set scaling for the textures X, Y and Z sizes ",
precision=4,
step=0.1,
soft_min=-100.0,
soft_max=100.0,
default=(1.0, 1.0, 1.0),
options={"ANIMATABLE"},
)
texture_coords: EnumProperty(
name="Coordinates",
description="Texture coordinates used to map the texture onto the background",
items=(
("VIEW", "View", "Use view vector for the texture coordinates"),
(
"GLOBAL",
"Global",
"Use global coordinates for the texture coordinates (interior mist)",
),
(
"ANGMAP",
"AngMap",
"Use 360 degree angular coordinates, e.g. for spherical light probes",
),
("SPHERE", "Sphere", "For 360 degree panorama sky, spherical mapped, only top half"),
("EQUIRECT", "Equirectangular", "For 360 degree panorama sky, equirectangular mapping"),
("TUBE", "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half"),
("OBJECT", "Object", "Use linked objects coordinates for texture coordinates"),
),
default="VIEW",
)
use_map_blend: BoolProperty(
name="Blend Map", description="Affect the color progression of the background", default=True
)
use_map_horizon: BoolProperty(
name="Horizon Map", description="Affect the color of the horizon", default=False
)
use_map_zenith_down: BoolProperty(
name="", description="Affect the color of the zenith below", default=False
)
use_map_zenith_up: BoolProperty(
name="Zenith Up Map", description="Affect the color of the zenith above", default=False
)
zenith_down_factor: FloatProperty(
name="Zenith Down",
description="Amount texture affects color of the zenith below",
soft_min=0.0,
soft_max=1.0,
default=1.0,
)
zenith_up_factor: FloatProperty(
name="Zenith Up",
description="Amount texture affects color of the zenith above",
soft_min=0.0,
soft_max=1.0,
default=1.0,
)
"""
# class WORLD_TEXTURE_SLOTS_UL_layerlist(bpy.types.UIList):
# texture_slots:
@ -490,7 +371,6 @@ classes = (
RenderPovSettingsCamera,
RenderPovSettingsLight,
RenderPovSettingsWorld,
WorldTextureSlot,
)
@ -501,14 +381,12 @@ def register():
bpy.types.Camera.pov = PointerProperty(type=RenderPovSettingsCamera)
bpy.types.Light.pov = PointerProperty(type=RenderPovSettingsLight)
bpy.types.World.pov = PointerProperty(type=RenderPovSettingsWorld)
bpy.types.World.pov_texture_slots = CollectionProperty(type=WorldTextureSlot)
def unregister():
del bpy.types.Camera.pov
del bpy.types.Light.pov
del bpy.types.World.pov
del bpy.types.World.pov_texture_slots
for cls in reversed(classes):
unregister_class(cls)

View File

@ -29,16 +29,8 @@ from bl_ui import properties_material
for member in dir(properties_material):
subclass = getattr(properties_material, member)
try:
# mat=bpy.context.active_object.active_material
# if (mat and mat.pov.type == "SURFACE"
# and not (mat.pov.material_use_nodes or mat.use_nodes)):
# and (engine in cls.COMPAT_ENGINES)) if subclasses were sorted
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_material
from .shading_properties import check_material

View File

@ -49,12 +49,8 @@ from bl_ui import properties_texture
for member in dir(properties_texture):
subclass = getattr(properties_texture, member)
try:
if hasattr(subclass, "COMPAT_ENGINES"):
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except BaseException as e:
print(e.__doc__)
print('An exception occurred: {}'.format(e))
pass
del properties_texture