Cycles: integrator presets, patch by Thomas.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 29 Aug 2011 17:55:14 +0000 (17:55 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 29 Aug 2011 17:55:14 +0000 (17:55 +0000)
intern/cycles/blender/CMakeLists.txt
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/presets.py [new file with mode: 0644]
intern/cycles/blender/addon/ui.py
release/scripts/presets/cycles/integrator/direct_light.py [new file with mode: 0644]

index a035d8fde6bb0ee5e7963f20cba770356e83be9c..a4f290f4abdebc4b467833e0fd5924b92c6f1180 100644 (file)
@@ -16,6 +16,7 @@ set(addonfiles
        addon/__init__.py
        addon/engine.py 
        addon/enums.py
+       addon/presets.py
        addon/properties.py
        addon/ui.py
        addon/xml.py)
index 418f3d4cd27939c54ec1d97024bef7ee99c3265e..3ff1a8f3d41013f9bbf2929e370f4d388c409e87 100644 (file)
@@ -35,6 +35,7 @@ from cycles import ui
 from cycles import properties
 from cycles import xml
 from cycles import engine
+from cycles import presets
 
 class CyclesRender(bpy.types.RenderEngine):
     bl_idname = 'CYCLES'
@@ -76,11 +77,13 @@ def register():
     properties.register()
     ui.register()
     xml.register()
+    presets.register()
     bpy.utils.register_module(__name__)
 
 def unregister():
     xml.unregister()
     ui.unregister()
     properties.unregister()
+    presets.unregister()
     bpy.utils.unregister_module(__name__)
 
diff --git a/intern/cycles/blender/addon/presets.py b/intern/cycles/blender/addon/presets.py
new file mode 100644 (file)
index 0000000..983d6dd
--- /dev/null
@@ -0,0 +1,48 @@
+#
+# Copyright 2011, Blender Foundation.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+from bl_operators.presets import AddPresetBase
+from bpy.types import Operator
+
+class AddPresetIntegrator(AddPresetBase, Operator):
+    '''Add an Integrator Preset'''
+    bl_idname = "render.cycles_integrator_preset_add"
+    bl_label = "Add Integrator Preset"
+    preset_menu = "CYCLES_MT_integrator_presets"
+
+    preset_defines = [
+        "cycles = bpy.context.scene.cycles"
+    ]
+
+    preset_values = [
+        "cycles.max_bounces",
+        "cycles.min_bounces",
+        "cycles.no_caustics",
+    ]
+
+    preset_subdir = "cycles/integrator"
+    
+def register():
+    pass
+
+def unregister():
+    pass
+    
+if __name__ == "__main__":
+    register()
+
index ec753590cceac1677a5817f06ca31f7a40b4f8ab..dc102b97db816b5b9a63373fae30d281448c8660 100644 (file)
 
 import bpy
 
-from bpy.types import Panel
+from bpy.types import Panel, Menu
 
 from cycles import enums
 from cycles import engine
 
+class CYCLES_MT_integrator_presets(Menu):
+    bl_label = "Integrator Presets"
+    preset_subdir = "cycles/integrator"
+    preset_operator = "script.execute_preset"
+    COMPAT_ENGINES = {'CYCLES'}
+    draw = Menu.draw_preset
+
 class CyclesButtonsPanel():
     bl_space_type = "PROPERTIES"
     bl_region_type = "WINDOW"
@@ -41,6 +48,11 @@ class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
 
         scene = context.scene
         cscene = scene.cycles
+        
+        row = layout.row(align=True)
+        row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
+        row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
+        row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMOUT").remove_active = True
 
         split = layout.split()
 
diff --git a/release/scripts/presets/cycles/integrator/direct_light.py b/release/scripts/presets/cycles/integrator/direct_light.py
new file mode 100644 (file)
index 0000000..0b79154
--- /dev/null
@@ -0,0 +1,6 @@
+import bpy
+cycles = bpy.context.scene.cycles
+
+cycles.max_bounces = 0
+cycles.min_bounces = 0
+cycles.no_caustics = False