From a885950276ea98dfa6a67c6d035198b59692a658 Mon Sep 17 00:00:00 2001
From: Maurice Raybaud <mauriceraybaud@hotmail.fr>
Date: Thu, 27 May 2021 18:36:18 +0200
Subject: [PATCH] POV : fix registering

Fix : Removed some duplicate class that caused addon register /
unregister to fail after previous commit
---
 render_povray/__init__.py               |  14 ++-
 render_povray/object_gui.py             |   5 +-
 render_povray/object_primitives.py      |   2 +-
 render_povray/render.py                 |   8 +-
 render_povray/render_gui.py             |  28 +++--
 render_povray/render_properties.py      |   4 +-
 render_povray/scenography.py            |  15 +--
 render_povray/scenography_gui.py        |  66 +++++++++---
 render_povray/scenography_properties.py | 125 +++++++++++++++++++++++
 render_povray/scripting.py              |  11 +-
 render_povray/scripting_gui.py          |   2 -
 render_povray/scripting_properties.py   |   6 +-
 render_povray/shading_gui.py            |  15 ++-
 render_povray/shading_nodes.py          |  14 ++-
 render_povray/texturing_gui.py          |   8 +-
 render_povray/texturing_properties.py   | 129 +-----------------------
 16 files changed, 263 insertions(+), 189 deletions(-)

diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index f0734c5fe..21de6ff89 100755
--- a/render_povray/__init__.py
+++ b/render_povray/__init__.py
@@ -250,7 +250,8 @@ class POV_OT_update_addon(bpy.types.Operator):
         with tempfile.TemporaryDirectory() as temp_dir_path:
             temp_zip_path = os.path.join(temp_dir_path, 'master.zip')
 
-            # Download zip archive of latest addons master branch commit (So we also get presets)
+            # Download zip archive of latest addons master branch commit
+            # More work needed so we also get the pov presets from addons shared folder.
             # switch this URL back to the BF hosted one as soon as gitweb snapshot gets fixed
             url = 'https://github.com/blender/blender-addons/archive/refs/heads/master.zip'
             try:
@@ -397,7 +398,10 @@ class PovrayPreferences(bpy.types.AddonPreferences):
         layout.operator("pov.update_addon", icon='FILE_REFRESH')
 
 
-classes = (POV_OT_update_addon, PovrayPreferences)
+classes = (
+    POV_OT_update_addon, # already registered as a subclass
+    PovrayPreferences
+)
 
 
 def register():
@@ -410,7 +414,7 @@ def register():
     texturing_properties.register()
     object_properties.register()
     scripting_properties.register()
-    scenography.register()
+    #scenography.register()
     render.register()
     base_ui.register()
     scripting.register()
@@ -422,7 +426,7 @@ def unregister():
     scripting.unregister()
     base_ui.unregister()
     render.unregister()
-    scenography.unregister()
+    #scenography.unregister()
     scripting_properties.unregister()
     object_properties.unregister()
     texturing_properties.unregister()
@@ -430,7 +434,7 @@ def unregister():
     scenography_properties.unregister()
     render_properties.unregister()
 
-    for cls in reversed(classes):
+    for cls in classes:
         unregister_class(cls)
 
 
diff --git a/render_povray/object_gui.py b/render_povray/object_gui.py
index 9fbf8a8b4..bc7df9f44 100755
--- a/render_povray/object_gui.py
+++ b/render_povray/object_gui.py
@@ -34,8 +34,11 @@ from bl_ui import properties_data_modifier
 
 for member in dir(properties_data_modifier):
     subclass = getattr(properties_data_modifier, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
+    except BaseException as e:
+        print(e.__doc__)
+        print('An exception occurred: {}'.format(e))
 del properties_data_modifier
 
 
diff --git a/render_povray/object_primitives.py b/render_povray/object_primitives.py
index 4556f2df5..fc6bafdeb 100755
--- a/render_povray/object_primitives.py
+++ b/render_povray/object_primitives.py
@@ -1769,5 +1769,5 @@ def register():
 
 
 def unregister():
-    for cls in classes:
+    for cls in reversed(classes):
         unregister_class(cls)
diff --git a/render_povray/render.py b/render_povray/render.py
index 45a94912b..7b6e5810f 100755
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -17,7 +17,9 @@
 # #**** END GPL LICENSE BLOCK #****
 
 # <pep8 compliant>
+
 """Wirte the POV file using this file's functions and some from other modules then render it."""
+
 import bpy
 import subprocess
 import os
@@ -1807,7 +1809,11 @@ class RunPovTextRender(Operator):
         return {'FINISHED'}
 
 
-classes = (PovrayRender, RenderPovTexturePreview, RunPovTextRender)
+classes = (
+    PovrayRender,
+    RenderPovTexturePreview,
+    RunPovTextRender,
+)
 
 
 def register():
diff --git a/render_povray/render_gui.py b/render_povray/render_gui.py
index 018821cb3..464ba367c 100755
--- a/render_povray/render_gui.py
+++ b/render_povray/render_gui.py
@@ -36,26 +36,38 @@ from bl_ui import properties_output
 
 for member in dir(properties_output):
     subclass = getattr(properties_output, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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.
@@ -440,13 +452,17 @@ if check_render_freestyle_svg():
     '''
     for member in dir(render_freestyle_svg):
         subclass = getattr(render_freestyle_svg, member)
-        if hasattr(subclass, "COMPAT_ENGINES"):
+        try:
             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
 
@@ -537,10 +553,10 @@ classes = (
 def register():
     for cls in classes:
         register_class(cls)
-    bpy.types.RENDER_PT_POV_radiosity.prepend(rad_panel_func)
+    RENDER_PT_POV_radiosity.prepend(rad_panel_func)
 
 
 def unregister():
-    bpy.types.RENDER_PT_POV_radiosity.remove(rad_panel_func)
+    RENDER_PT_POV_radiosity.remove(rad_panel_func)
     for cls in reversed(classes):
         unregister_class(cls)
diff --git a/render_povray/render_properties.py b/render_povray/render_properties.py
index 9096c9864..20e9761d8 100755
--- a/render_povray/render_properties.py
+++ b/render_povray/render_properties.py
@@ -672,7 +672,9 @@ class RenderPovSettingsScene(PropertyGroup):
     )
 
 
-classes = (RenderPovSettingsScene,)
+classes = (
+    RenderPovSettingsScene,
+)
 
 
 def register():
diff --git a/render_povray/scenography.py b/render_povray/scenography.py
index 4b0c99e32..6c9aed805 100755
--- a/render_povray/scenography.py
+++ b/render_povray/scenography.py
@@ -23,7 +23,7 @@
 with world, sky, atmospheric effects such as rainbows or smoke """
 
 import bpy
-from bpy.utils import register_class, unregister_class
+
 import os
 from imghdr import what  # imghdr is a python lib to identify image file types
 from math import atan, pi, sqrt, degrees
@@ -832,16 +832,3 @@ def export_smoke(file, smoke_obj_name, smoke_path, comments, global_matrix, writ
         # file.write("               frequency 0\n")
         # file.write("   }\n")
         # file.write("}\n")
-
-
-classes = ()
-
-
-def register():
-    for cls in classes:
-        register_class(cls)
-
-
-def unregister():
-    for cls in classes:
-        unregister_class(cls)
diff --git a/render_povray/scenography_gui.py b/render_povray/scenography_gui.py
index 6eb5aed90..41e25a21c 100755
--- a/render_povray/scenography_gui.py
+++ b/render_povray/scenography_gui.py
@@ -31,8 +31,12 @@ from bl_ui import properties_data_camera
 
 for member in dir(properties_data_camera):
     subclass = getattr(properties_data_camera, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
+    except BaseException as e:
+        print(e.__doc__)
+        print('An exception occurred: {}'.format(e))
+        pass
 del properties_data_camera
 
 # ##################################
@@ -50,8 +54,12 @@ from bl_ui import properties_physics_common
 
 for member in dir(properties_physics_common):
     subclass = getattr(properties_physics_common, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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'
@@ -59,8 +67,12 @@ from bl_ui import properties_physics_rigidbody
 
 for member in dir(properties_physics_rigidbody):
     subclass = getattr(properties_physics_rigidbody, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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'
@@ -68,8 +80,12 @@ from bl_ui import properties_physics_rigidbody_constraint
 
 for member in dir(properties_physics_rigidbody_constraint):
     subclass = getattr(properties_physics_rigidbody_constraint, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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'
@@ -77,8 +93,12 @@ from bl_ui import properties_physics_fluid
 
 for member in dir(properties_physics_fluid):
     subclass = getattr(properties_physics_fluid, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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'
@@ -86,8 +106,12 @@ from bl_ui import properties_physics_softbody
 
 for member in dir(properties_physics_softbody):
     subclass = getattr(properties_physics_softbody, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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'
@@ -95,8 +119,12 @@ from bl_ui import properties_physics_field
 
 for member in dir(properties_physics_field):
     subclass = getattr(properties_physics_field, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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'
@@ -104,8 +132,12 @@ from bl_ui import properties_physics_cloth
 
 for member in dir(properties_physics_cloth):
     subclass = getattr(properties_physics_cloth, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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'
@@ -113,16 +145,24 @@ from bl_ui import properties_physics_dynamicpaint
 
 for member in dir(properties_physics_dynamicpaint):
     subclass = getattr(properties_physics_dynamicpaint, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         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)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
+    except BaseException as e:
+        print(e.__doc__)
+        print('An exception occurred: {}'.format(e))
+        pass
 del properties_particle
 
 
@@ -750,12 +790,10 @@ def register():
 
     for cls in classes:
         register_class(cls)
-    bpy.types.LIGHT_PT_POV_light.prepend(light_panel_func)
+    LIGHT_PT_POV_light.prepend(light_panel_func)
 
 
 def unregister():
-
-    bpy.types.LIGHT_PT_POV_light.remove(light_panel_func)
+    LIGHT_PT_POV_light.remove(light_panel_func)
     for cls in reversed(classes):
         unregister_class(cls)
-
diff --git a/render_povray/scenography_properties.py b/render_povray/scenography_properties.py
index dd8865135..97c856f65 100755
--- a/render_povray/scenography_properties.py
+++ b/render_povray/scenography_properties.py
@@ -352,6 +352,128 @@ class RenderPovSettingsWorld(PropertyGroup):
         name="Index for texture_slots", default=0, update=brush_texture_update
     )
 
+###############################################################################
+# Texture slots (World context) exported as POV texture properties.
+###############################################################################
+
+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 texture’s 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 object’s 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):
@@ -371,6 +493,7 @@ classes = (
     RenderPovSettingsCamera,
     RenderPovSettingsLight,
     RenderPovSettingsWorld,
+    WorldTextureSlot,
 )
 
 
@@ -381,12 +504,14 @@ 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)
diff --git a/render_povray/scripting.py b/render_povray/scripting.py
index 02ca6444b..307573df4 100755
--- a/render_povray/scripting.py
+++ b/render_povray/scripting.py
@@ -25,6 +25,7 @@ load, create or edit"""
 import bpy
 from bpy.props import StringProperty, BoolProperty, CollectionProperty
 from bpy_extras.io_utils import ImportHelper
+from bpy.utils import register_class, unregister_class
 
 from mathutils import Vector
 from math import pi
@@ -520,10 +521,16 @@ class ImportPOV(bpy.types.Operator, ImportHelper):
         # obj.location = (0,0,0)
         return {'FINISHED'}
 
+classes = (
+    ImportPOV,
+)
 
 def register():
-    bpy.utils.register_class(ImportPOV)
+    for cls in classes:
+        register_class(cls)
 
 
 def unregister():
-    bpy.utils.unregister_class(ImportPOV)
+    for cls in reversed(classes):
+        unregister_class(cls)
+
diff --git a/render_povray/scripting_gui.py b/render_povray/scripting_gui.py
index 99006af15..c4d2fe013 100755
--- a/render_povray/scripting_gui.py
+++ b/render_povray/scripting_gui.py
@@ -251,7 +251,6 @@ classes = (
 
 
 def register():
-
     for cls in classes:
         register_class(cls)
 
@@ -260,7 +259,6 @@ def register():
 
 
 def unregister():
-
     bpy.types.TEXT_MT_templates.remove(menu_func_templates)
     bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
 
diff --git a/render_povray/scripting_properties.py b/render_povray/scripting_properties.py
index 3e743da37..66bb01917 100755
--- a/render_povray/scripting_properties.py
+++ b/render_povray/scripting_properties.py
@@ -17,10 +17,10 @@
 # ##### END GPL LICENSE BLOCK #####
 
 # <pep8 compliant>
-import bpy
 
 """Declare pov native file syntax properties controllable in UI hooks and text blocks"""
 
+import bpy
 from bpy.utils import register_class, unregister_class
 from bpy.types import PropertyGroup
 from bpy.props import EnumProperty, PointerProperty
@@ -42,7 +42,9 @@ class RenderPovSettingsText(PropertyGroup):
     )
 
 
-classes = (RenderPovSettingsText,)
+classes = (
+    RenderPovSettingsText,
+)
 
 
 def register():
diff --git a/render_povray/shading_gui.py b/render_povray/shading_gui.py
index 428542c83..3d2862607 100755
--- a/render_povray/shading_gui.py
+++ b/render_povray/shading_gui.py
@@ -29,8 +29,16 @@ from bl_ui import properties_material
 
 for member in dir(properties_material):
     subclass = getattr(properties_material, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    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
         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
@@ -44,8 +52,7 @@ def simple_material(mat):
 
 
 class MaterialButtonsPanel:
-    """Use this class to define buttons from the material tab of
-    properties window."""
+    """Use this class to define buttons from the material tab of properties window."""
 
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -669,12 +676,10 @@ classes = (
 
 
 def register():
-
     for cls in classes:
         register_class(cls)
 
 
 def unregister():
-
     for cls in reversed(classes):
         unregister_class(cls)
diff --git a/render_povray/shading_nodes.py b/render_povray/shading_nodes.py
index 2e8484f9c..c27014eb8 100755
--- a/render_povray/shading_nodes.py
+++ b/render_povray/shading_nodes.py
@@ -1995,17 +1995,15 @@ classes = (
 
 
 def register():
-    # from bpy.utils import register_class
-    bpy.types.NODE_HT_header.append(menu_func_nodes)
-    nodeitems_utils.register_node_categories("POVRAYNODES", node_categories)
     for cls in classes:
         register_class(cls)
-
+    nodeitems_utils.register_node_categories("POVRAYNODES", node_categories)
+    bpy.types.NODE_HT_header.append(menu_func_nodes)
 
 def unregister():
-    # from bpy.utils import unregister_class
-
+    bpy.types.NODE_HT_header.remove(menu_func_nodes)
+    nodeitems_utils.unregister_node_categories("POVRAYNODES")
     for cls in reversed(classes):
         unregister_class(cls)
-    nodeitems_utils.unregister_node_categories("POVRAYNODES")
-    bpy.types.NODE_HT_header.remove(menu_func_nodes)
+
+
diff --git a/render_povray/texturing_gui.py b/render_povray/texturing_gui.py
index ad889f432..c59f5d572 100755
--- a/render_povray/texturing_gui.py
+++ b/render_povray/texturing_gui.py
@@ -49,8 +49,12 @@ from bl_ui import properties_texture
 
 for member in dir(properties_texture):
     subclass = getattr(properties_texture, member)
-    if hasattr(subclass, "COMPAT_ENGINES"):
+    try:
         subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
+    except BaseException as e:
+        print(e.__doc__)
+        print('An exception occurred: {}'.format(e))
+        pass
 del properties_texture
 
 
@@ -1224,6 +1228,7 @@ class TEXTURE_PT_POV_tex_gamma(TextureButtonsPanel, Panel):
 classes = (
     WORLD_TEXTURE_SLOTS_UL_POV_layerlist,
     TEXTURE_MT_POV_specials,
+    #TEXTURE_PT_context,
     TEXTURE_PT_POV_context_texture,
     TEXTURE_PT_colors,
     TEXTURE_PT_POV_type,
@@ -1239,7 +1244,6 @@ classes = (
 
 
 def register():
-
     for cls in classes:
         register_class(cls)
 
diff --git a/render_povray/texturing_properties.py b/render_povray/texturing_properties.py
index bb89ee025..6551b8c32 100755
--- a/render_povray/texturing_properties.py
+++ b/render_povray/texturing_properties.py
@@ -17,6 +17,7 @@
 # ##### END GPL LICENSE BLOCK #####
 
 # <pep8 compliant>
+
 """Declare texturing properties controllable in UI."""
 
 import bpy
@@ -461,128 +462,6 @@ class MaterialTextureSlot(PropertyGroup):
     )
 
 
-###############################################################################
-# Texture slots (World context) exported as POV texture properties.
-###############################################################################
-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 ui.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 texture’s 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 object’s 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,
-    )
-
-
 ###############################################################################
 # Space properties from  removed former Blender Internal
 ###############################################################################
@@ -1116,7 +995,9 @@ class RenderPovSettingsTexture(PropertyGroup):
     tex_scale_z: FloatProperty(name="Scale Z", description="", min=0.0, max=10000.0, default=1.0)
 
 
-classes = (MaterialTextureSlot, WorldTextureSlot, RenderPovSettingsTexture)
+classes = (
+    MaterialTextureSlot,
+    RenderPovSettingsTexture)
 
 
 def register():
@@ -1124,13 +1005,11 @@ def register():
         register_class(cls)
 
     bpy.types.Material.pov_texture_slots = CollectionProperty(type=MaterialTextureSlot)
-    bpy.types.World.pov_texture_slots = CollectionProperty(type=WorldTextureSlot)
     bpy.types.Texture.pov = PointerProperty(type=RenderPovSettingsTexture)
 
 
 def unregister():
     del bpy.types.Texture.pov
-    del bpy.types.World.pov_texture_slots
     del bpy.types.Material.pov_texture_slots
 
     for cls in reversed(classes):
-- 
GitLab