Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/addon/version_update.py
| Show All 14 Lines | |||||
| # | # | ||||
| # <pep8 compliant> | # <pep8 compliant> | ||||
| import bpy | import bpy | ||||
| from bpy.app.handlers import persistent | from bpy.app.handlers import persistent | ||||
| def foreach_cycles_node(callback): | |||||
| traversed_materials = set() | |||||
| for scene in bpy.data.scenes: | |||||
| if scene.render.engine == 'CYCLES': | |||||
| for object in scene.objects: | |||||
campbellbarton: Would use `obj` since `object` is a python class. | |||||
| for slot in object.material_slots: | |||||
| if slot.material and slot.material.use_nodes: | |||||
| if slot.material in traversed_materials: | |||||
| continue | |||||
| traversed_materials.add(slot.material) | |||||
| for node in slot.material.node_tree.nodes: | |||||
| callback(node) | |||||
| def mapping_node_order_flip(node): | |||||
| """ | |||||
| Flip euler order of mapping shader node | |||||
| """ | |||||
| if node.bl_idname == 'ShaderNodeMapping': | |||||
| rot = node.rotation.copy() | |||||
| rot.order = 'ZYX' | |||||
| quat = rot.to_quaternion() | |||||
| node.rotation = quat.to_euler('XYZ') | |||||
| @persistent | @persistent | ||||
| def do_versions(self): | def do_versions(self): | ||||
| # We don't modify startup file because it assumes to | # We don't modify startup file because it assumes to | ||||
| # have all the default values only. | # have all the default values only. | ||||
| if not bpy.data.is_saved: | if not bpy.data.is_saved: | ||||
Not Done Inline ActionsShould be if 'NEW_SHADING' in node.shading_compatibility: campbellbarton: Should be `if 'NEW_SHADING' in node.shading_compatibility:` | |||||
| return | return | ||||
| # Clamp Direct/Indirect separation in 270 | # Clamp Direct/Indirect separation in 270 | ||||
| if bpy.data.version <= (2, 70, 0): | if bpy.data.version <= (2, 70, 0): | ||||
| for scene in bpy.data.scenes: | for scene in bpy.data.scenes: | ||||
| cscene = scene.cycles | cscene = scene.cycles | ||||
| sample_clamp = cscene.get("sample_clamp", False) | sample_clamp = cscene.get("sample_clamp", False) | ||||
| if (sample_clamp and | if (sample_clamp and | ||||
| Show All 15 Lines | if bpy.data.version <= (2, 72, 0): | ||||
| for scene in bpy.data.scenes: | for scene in bpy.data.scenes: | ||||
| cscene = scene.cycles | cscene = scene.cycles | ||||
| if (cscene.get("no_caustics", False) and | if (cscene.get("no_caustics", False) and | ||||
| not cscene.is_property_set("caustics_reflective") and | not cscene.is_property_set("caustics_reflective") and | ||||
| not cscene.is_property_set("caustics_refractive")): | not cscene.is_property_set("caustics_refractive")): | ||||
| cscene.caustics_reflective = False | cscene.caustics_reflective = False | ||||
| cscene.caustics_refractive = False | cscene.caustics_refractive = False | ||||
| if bpy.data.version <= (2, 73, 3): | |||||
| foreach_cycles_node(mapping_node_order_flip) | |||||
Would use obj since object is a python class.