code cleanup:
[blender.git] / intern / cycles / blender / addon / __init__.py
index bb418340f5576de86be13de05d609b234be91888..36fb5c0418d461ad96ba9a5863396b225a2a7a69 100644 (file)
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 
+# <pep8 compliant>
+
 bl_info = {
     "name": "Cycles Render Engine",
     "author": "",
-    "version": (0,0),
-    "blender": (2, 5, 6),
-    "api": 34462,
+    "blender": (2, 60, 5),
     "location": "Info header, render engine menu",
-    "description": "Cycles Render Engine integration.",
+    "description": "Cycles Render Engine integration",
     "warning": "",
-    "wiki_url": "",
+    "wiki_url": "http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles",
     "tracker_url": "",
+    "support": 'OFFICIAL',
     "category": "Render"}
 
 import bpy
 
-from cycles import ui
-from cycles import properties
-from cycles import xml
-from cycles import engine
+from . import engine
+
 
 class CyclesRender(bpy.types.RenderEngine):
-       bl_idname = 'CYCLES'
-       bl_label = "Cycles"
+    bl_idname = 'CYCLES'
+    bl_label = "Cycles Render"
+    bl_use_shading_nodes = True
+
+    def __init__(self):
+        self.session = None
+
+    def __del__(self):
+        engine.free(self)
+
+    # final render
+    def update(self, data, scene):
+        if not self.session:
+            engine.create(self, data, scene)
+        else:
+            engine.reset(self, data, scene)
+
+        engine.update(self, data, scene)
 
-       def __init__(self):
-               engine.init()
-               self.session = None
-       
-       def __del__(self):
-               engine.free(self)
+    def render(self, scene):
+        engine.render(self)
 
-       def render(self, scene):
-               scene.frame_set(scene.frame_current) # should this be done already?
-               engine.create(self, scene, True)
-               engine.render(self, scene)
+    # preview render
+    # def preview_update(self, context, id):
+    #    pass
+    #
+    # def preview_render(self):
+    #    pass
 
-       def draw(self, scene):
-               if not self.session:
-                       engine.create(self, scene, False)
-               engine.draw(self, scene)
+    # viewport render
+    def view_update(self, context):
+        if not self.session:
+            engine.create(self, context.blend_data, context.scene,
+                          context.region, context.space_data, context.region_data)
+        engine.update(self, context.blend_data, context.scene)
+
+    def view_draw(self, context):
+        engine.draw(self, context.region, context.space_data, context.region_data)
+
+    def update_script_node(self, node):
+        if engine.with_osl():
+            from . import osl
+            osl.update_script_node(node, self.report)
+        else:
+            self.report({'ERROR'}, "OSL support disabled in this build.")
 
-       def update(self, scene):
-               engine.update(self, scene)
 
 def register():
-       properties.register()
-       ui.register()
-       xml.register()
-       bpy.utils.register_module(__name__)
+    from . import ui
+    from . import properties
+    from . import presets
+
+    engine.init()
+
+    properties.register()
+    ui.register()
+    presets.register()
+    bpy.utils.register_module(__name__)
+
 
 def unregister():
-       xml.unregister()
-       ui.unregister()
-       properties.unregister()
-       bpy.utils.unregister_module(__name__)
+    from . import ui
+    from . import properties
+    from . import presets
 
+    ui.unregister()
+    properties.unregister()
+    presets.unregister()
+    bpy.utils.unregister_module(__name__)