Amaranth Toolset: Fix registration with current master
authorlijenstina <lijenstina@gmail.com>
Fri, 29 Sep 2017 14:29:52 +0000 (16:29 +0200)
committerlijenstina <lijenstina@gmail.com>
Fri, 29 Sep 2017 14:29:52 +0000 (16:29 +0200)
Bump version to 1.0.4

Part of T52564:
Fix crash during registration accessing Cycles
in current master (Blender 2.79.1)
- Properties cannot be accessed through types
- Changes to names of cycles classes
- Use versioning code, so 2.79 is supported for now too

amaranth/__init__.py
amaranth/render/samples_scene.py
amaranth/render/unsimplify.py

index 81f6538..a40a105 100644 (file)
@@ -90,7 +90,7 @@ from amaranth.misc import (
 bl_info = {
     "name": "Amaranth Toolset",
     "author": "Pablo Vazquez, Bassam Kurdali, Sergey Sharybin, Lukas Tönne, Cesar Saez",
-    "version": (1, 0, 3),
+    "version": (1, 0, 4),
     "blender": (2, 74),
     "location": "Everywhere!",
     "description": "A collection of tools and settings to improve productivity",
index 00105cd..8ea216b 100644 (file)
@@ -28,6 +28,10 @@ Developed during Caminandes Open Movie Project
 
 import bpy
 from amaranth import utils
+from bpy.props import (
+        BoolProperty,
+        IntProperty,
+        )
 
 
 class AMTH_RENDER_OT_cycles_samples_percentage_set(bpy.types.Operator):
@@ -60,10 +64,11 @@ class AMTH_RENDER_OT_cycles_samples_percentage(bpy.types.Operator):
     bl_idname = "scene.amaranth_cycles_samples_percentage"
     bl_label = "Set Render Samples Percentage"
 
-    percent = bpy.props.IntProperty(
-        name="Percentage",
-        description="Percentage to divide render samples by",
-        subtype="PERCENTAGE", default=0)
+    percent = IntProperty(
+            name="Percentage",
+            description="Percentage to divide render samples by",
+            subtype="PERCENTAGE", default=0
+            )
 
     def execute(self, context):
         percent = self.percent
@@ -196,11 +201,21 @@ def init():
         scene.amaranth_cycles_list_sampling = bpy.props.BoolProperty(
             default=False,
             name="Samples Per:")
+        # Note: add versioning code to adress changes introduced in 2.79.1
+        if bpy.app.version >= (2, 79, 1):
+            from cycles import properties as _cycles_props
+            _cycles_props.CyclesRenderSettings.use_samples_final = BoolProperty(
+                    name="Use Final Render Samples",
+                    description="Use current shader samples as final render samples",
+                    default=False
+                    )
+        else:
+            bpy.types.CyclesRenderSettings.use_samples_final = BoolProperty(
+                    name="Use Final Render Samples",
+                    description="Use current shader samples as final render samples",
+                    default=False
+                    )
 
-        bpy.types.CyclesRenderSettings.use_samples_final = bpy.props.BoolProperty(
-            name="Use Final Render Samples",
-            description="Use current shader samples as final render samples",
-            default=False)
 
 
 def clear():
@@ -215,12 +230,20 @@ def register():
     bpy.utils.register_class(AMTH_RENDER_OT_cycles_samples_percentage)
     bpy.utils.register_class(AMTH_RENDER_OT_cycles_samples_percentage_set)
     if utils.cycles_exists():
-        bpy.types.CyclesRender_PT_sampling.append(render_cycles_scene_samples)
+        if bpy.app.version >= (2, 79, 1):
+            bpy.types.CYCLES_RENDER_PT_sampling.append(render_cycles_scene_samples)
+        else:
+            bpy.types.CyclesRender_PT_sampling.append(render_cycles_scene_samples)
 
 
 def unregister():
     bpy.utils.unregister_class(AMTH_RENDER_OT_cycles_samples_percentage)
     bpy.utils.unregister_class(AMTH_RENDER_OT_cycles_samples_percentage_set)
     if utils.cycles_exists():
-        bpy.types.CyclesRender_PT_sampling.remove(render_cycles_scene_samples)
+        if bpy.app.version >= (2, 79, 1):
+            bpy.types.CYCLES_RENDER_PT_sampling.remove(render_cycles_scene_samples)
+        else:
+            bpy.types.CyclesRender_PT_sampling.remove(render_cycles_scene_samples)
+
+
     clear()
index 90b66c0..9d01b08 100644 (file)
@@ -64,7 +64,11 @@ def register():
     bpy.app.handlers.render_post.append(unsimplify_render_post)
     bpy.types.SCENE_PT_simplify.append(unsimplify_ui)
     if utils.cycles_exists():
-        bpy.types.CyclesScene_PT_simplify.append(unsimplify_ui)
+        if bpy.app.version >= (2, 79, 1):
+            bpy.types.CYCLES_SCENE_PT_simplify.append(unsimplify_ui)
+        else:
+            bpy.types.CyclesScene_PT_simplify.append(unsimplify_ui)
+
 
 
 def unregister():
@@ -73,4 +77,8 @@ def unregister():
     bpy.app.handlers.render_post.remove(unsimplify_render_post)
     bpy.types.SCENE_PT_simplify.remove(unsimplify_ui)
     if utils.cycles_exists():
-        bpy.types.CyclesScene_PT_simplify.remove(unsimplify_ui)
+        if bpy.app.version >= (2, 79, 1):
+            bpy.types.CYCLES_SCENE_PT_simplify.remove(unsimplify_ui)
+        else:
+            bpy.types.CyclesScene_PT_simplify.remove(unsimplify_ui)
+