[Durian-svn] [915] hack to have raytrace off for blendfiles.
campbell
durian-svn at blender.org
Thu Feb 11 16:09:14 CET 2010
Revision: 915
https://blenderinstitute.dyndns.org/durian-svn/?do=log&project=durian&path=/&rev=915
Author: campbell
Date: 2010-02-11 16:09:14 +0100 (Thu, 11 Feb 2010)
Log Message:
-----------
hack to have raytrace off for blendfiles.
- new materials have traceable disabled.
- menu item to disable all trace options except for materials with "_eye_" in their name. library materials will report warnings.
Added Paths:
-----------
pro/scripts/ui/material_raytrace_hack.py
Added: pro/scripts/ui/material_raytrace_hack.py
===================================================================
--- pro/scripts/ui/material_raytrace_hack.py (rev 0)
+++ pro/scripts/ui/material_raytrace_hack.py 2010-02-11 15:09:14 UTC (rev 915)
@@ -0,0 +1,103 @@
+import bpy
+
+class MaterialNew(bpy.types.Operator):
+ bl_idname = "material.new_noray"
+ bl_label = "Material New"
+
+ def execute(self, context):
+ bpy.ops.material.new()
+ mat = context.object.active_material
+ mat.traceable = False
+ return {'FINISHED'}
+
+
+class MaterialRayOff(bpy.types.Operator):
+ bl_idname = "material.ray_off"
+ bl_label = "Material Trace Off"
+
+ def execute(self, context):
+ for mat in bpy.data.materials:
+ if "_eye_" in mat.name:
+ continue
+
+ if mat.traceable:
+ if not mat.library:
+ mat.traceable = False
+ else:
+ self.report({'WARNING'}, "Trace Could not be disabled for '%s' of '%s'\n" % (mat.name, mat.library.filename))
+
+ return {'FINISHED'}
+
+# keep in sync with properties_material.py
+narrowui = 180
+import properties_material
+class MATERIAL_PT_context_material(properties_material.MaterialButtonsPanel):
+ bl_label = ""
+ bl_show_header = False
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+
+ def poll(self, context):
+ # An exception, dont call the parent poll func because
+ # this manages materials for all engine types
+
+ engine = context.scene.render_data.engine
+ return (context.material or context.object) and (engine in self.COMPAT_ENGINES)
+
+ def draw(self, context):
+ layout = self.layout
+
+ mat = context.material
+ ob = context.object
+ slot = context.material_slot
+ space = context.space_data
+ wide_ui = context.region.width > narrowui
+
+ if ob:
+ row = layout.row()
+
+ row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
+
+ col = row.column(align=True)
+ col.operator("object.material_slot_add", icon='ZOOMIN', text="")
+ col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
+
+ col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
+
+ if ob.mode == 'EDIT':
+ row = layout.row(align=True)
+ row.operator("object.material_slot_assign", text="Assign")
+ row.operator("object.material_slot_select", text="Select")
+ row.operator("object.material_slot_deselect", text="Deselect")
+
+ if wide_ui:
+ split = layout.split(percentage=0.65)
+
+ if ob:
+ split.template_ID(ob, "active_material", new="material.new_noray") # ----------------------- < only changed line
+ row = split.row()
+ if slot:
+ row.prop(slot, "link", text="")
+ else:
+ row.label()
+ elif mat:
+ split.template_ID(space, "pin_id")
+ split.separator()
+ else:
+ if ob:
+ layout.template_ID(ob, "active_material", new="material.new_noray") # ----------------------- < only changed line
+ elif mat:
+ layout.template_ID(space, "pin_id")
+
+ if mat:
+ if wide_ui:
+ layout.prop(mat, "type", expand=True)
+ else:
+ layout.prop(mat, "type", text="")
+
+
+bpy.types.register(MATERIAL_PT_context_material)
+bpy.types.register(MaterialNew)
+bpy.types.register(MaterialRayOff)
+
+menu_func = (lambda self, context: self.layout.operator(MaterialRayOff.bl_idname))
+bpy.types.MATERIAL_MT_specials.append(menu_func)
More information about the Durian-svn
mailing list