modified fix for commits r33811, 33812.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 20 Dec 2010 23:26:29 +0000 (23:26 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 20 Dec 2010 23:26:29 +0000 (23:26 +0000)
- SSS Presets were not working on pinned materials.
- added ability for save-presets to define variables to stop them becoming too verbose.
- remove object.active_node_material

12 files changed:
release/scripts/op/presets.py
release/scripts/presets/sss/apple.py
release/scripts/presets/sss/chicken.py
release/scripts/presets/sss/cream.py
release/scripts/presets/sss/ketchup.py
release/scripts/presets/sss/marble.py
release/scripts/presets/sss/potato.py
release/scripts/presets/sss/skim_milk.py
release/scripts/presets/sss/skin1.py
release/scripts/presets/sss/skin2.py
release/scripts/presets/sss/whole_milk.py
source/blender/makesrna/intern/rna_object.c

index 0ee20966fad96e4a8462951972f16b2bcf56ba05..b0dd7de3f1c606ec2ee7d0a67f175e2eeeb79ff7 100644 (file)
@@ -69,6 +69,12 @@ class AddPresetBase():
                 file_preset = open(filepath, 'w')
                 file_preset.write("import bpy\n")
 
+                if hasattr(self, "preset_defines"):
+                    for rna_path in self.preset_defines:
+                        exec(rna_path)
+                        file_preset.write("%s\n" % rna_path)
+                    file_preset.write("\n")
+
                 for rna_path in self.preset_values:
                     value = eval(rna_path)
                     # convert thin wrapped sequences to simple lists to repr()
@@ -150,17 +156,21 @@ class AddPresetRender(AddPresetBase, bpy.types.Operator):
     bl_label = "Add Render Preset"
     preset_menu = "RENDER_MT_presets"
 
+    preset_defines = [
+        "scene = bpy.context.scene"
+    ]
+
     preset_values = [
-        "bpy.context.scene.render.field_order",
-        "bpy.context.scene.render.fps",
-        "bpy.context.scene.render.fps_base",
-        "bpy.context.scene.render.pixel_aspect_x",
-        "bpy.context.scene.render.pixel_aspect_y",
-        "bpy.context.scene.render.resolution_percentage",
-        "bpy.context.scene.render.resolution_x",
-        "bpy.context.scene.render.resolution_y",
-        "bpy.context.scene.render.use_fields",
-        "bpy.context.scene.render.use_fields_still",
+        "scene.render.field_order",
+        "scene.render.fps",
+        "scene.render.fps_base",
+        "scene.render.pixel_aspect_x",
+        "scene.render.pixel_aspect_y",
+        "scene.render.resolution_percentage",
+        "scene.render.resolution_x",
+        "scene.render.resolution_y",
+        "scene.render.use_fields",
+        "scene.render.use_fields_still",
     ]
 
     preset_subdir = "render"
@@ -172,20 +182,20 @@ class AddPresetSSS(AddPresetBase, bpy.types.Operator):
     bl_label = "Add SSS Preset"
     preset_menu = "MATERIAL_MT_sss_presets"
 
+    preset_defines = [
+        "material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)"
+    ]
+
     preset_values = [
-        "bpy.context.material.subsurface_scattering.back",
-        "bpy.context.material.subsurface_scattering.color[0]",
-        "bpy.context.material.subsurface_scattering.color[1]",
-        "bpy.context.material.subsurface_scattering.color[2]",
-        "bpy.context.material.subsurface_scattering.color_factor",
-        "bpy.context.material.subsurface_scattering.error_threshold",
-        "bpy.context.material.subsurface_scattering.front",
-        "bpy.context.material.subsurface_scattering.ior",
-        "bpy.context.material.subsurface_scattering.radius[0]",
-        "bpy.context.material.subsurface_scattering.radius[1]",
-        "bpy.context.material.subsurface_scattering.radius[2]",
-        "bpy.context.material.subsurface_scattering.scale",
-        "bpy.context.material.subsurface_scattering.texture_factor",
+        "material.subsurface_scattering.back",
+        "material.subsurface_scattering.color",
+        "material.subsurface_scattering.color_factor",
+        "material.subsurface_scattering.error_threshold",
+        "material.subsurface_scattering.front",
+        "material.subsurface_scattering.ior",
+        "material.subsurface_scattering.radius",
+        "material.subsurface_scattering.scale",
+        "material.subsurface_scattering.texture_factor",
     ]
 
     preset_subdir = "sss"
@@ -197,13 +207,17 @@ class AddPresetCloth(AddPresetBase, bpy.types.Operator):
     bl_label = "Add Cloth Preset"
     preset_menu = "CLOTH_MT_presets"
 
+    preset_defines = [
+        "cloth = bpy.context.cloth"
+    ]
+
     preset_values = [
-        "bpy.context.cloth.settings.air_damping",
-        "bpy.context.cloth.settings.bending_stiffness",
-        "bpy.context.cloth.settings.mass",
-        "bpy.context.cloth.settings.quality",
-        "bpy.context.cloth.settings.spring_damping",
-        "bpy.context.cloth.settings.structural_stiffness",
+        "cloth.settings.air_damping",
+        "cloth.settings.bending_stiffness",
+        "cloth.settings.mass",
+        "cloth.settings.quality",
+        "cloth.settings.spring_damping",
+        "cloth.settings.structural_stiffness",
     ]
 
     preset_subdir = "cloth"
@@ -215,20 +229,24 @@ class AddPresetSunSky(AddPresetBase, bpy.types.Operator):
     bl_label = "Add Sunsky Preset"
     preset_menu = "LAMP_MT_sunsky_presets"
 
+    preset_defines = [
+        "sky = bpy.context.object.data.sky"
+    ]
+
     preset_values = [
-        "bpy.context.object.data.sky.atmosphere_extinction",
-        "bpy.context.object.data.sky.atmosphere_inscattering",
-        "bpy.context.object.data.sky.atmosphere_turbidity",
-        "bpy.context.object.data.sky.backscattered_light",
-        "bpy.context.object.data.sky.horizon_brightness",
-        "bpy.context.object.data.sky.spread",
-        "bpy.context.object.data.sky.sun_brightness",
-        "bpy.context.object.data.sky.sun_intensity",
-        "bpy.context.object.data.sky.sun_size",
-        "bpy.context.object.data.sky.use_sky_blend",
-        "bpy.context.object.data.sky.use_sky_blend_type",
-        "bpy.context.object.data.sky.use_sky_color_space",
-        "bpy.context.object.data.sky.use_sky_exposure",
+        "sky.atmosphere_extinction",
+        "sky.atmosphere_inscattering",
+        "sky.atmosphere_turbidity",
+        "sky.backscattered_light",
+        "sky.horizon_brightness",
+        "sky.spread",
+        "sky.sun_brightness",
+        "sky.sun_intensity",
+        "sky.sun_size",
+        "sky.use_sky_blend",
+        "sky.use_sky_blend_type",
+        "sky.use_sky_color_space",
+        "sky.use_sky_exposure",
     ]
 
     preset_subdir = "sunsky"
@@ -240,17 +258,21 @@ class AddPresetInteraction(AddPresetBase, bpy.types.Operator):
     bl_label = "Add Interaction Preset"
     preset_menu = "USERPREF_MT_interaction_presets"
 
+    preset_defines = [
+        "user_preferences = bpy.context.user_preferences"
+    ]
+
     preset_values = [
-        "bpy.context.user_preferences.edit.use_drag_immediately",
-        "bpy.context.user_preferences.edit.use_insertkey_xyz_to_rgb",
-        "bpy.context.user_preferences.inputs.invert_mouse_wheel_zoom",
-        "bpy.context.user_preferences.inputs.select_mouse",
-        "bpy.context.user_preferences.inputs.use_emulate_numpad",
-        "bpy.context.user_preferences.inputs.use_mouse_continuous",
-        "bpy.context.user_preferences.inputs.use_mouse_emulate_3_button",
-        "bpy.context.user_preferences.inputs.view_rotate_method",
-        "bpy.context.user_preferences.inputs.view_zoom_axis",
-        "bpy.context.user_preferences.inputs.view_zoom_method",
+        "user_preferences.edit.use_drag_immediately",
+        "user_preferences.edit.use_insertkey_xyz_to_rgb",
+        "user_preferences.inputs.invert_mouse_wheel_zoom",
+        "user_preferences.inputs.select_mouse",
+        "user_preferences.inputs.use_emulate_numpad",
+        "user_preferences.inputs.use_mouse_continuous",
+        "user_preferences.inputs.use_mouse_emulate_3_button",
+        "user_preferences.inputs.view_rotate_method",
+        "user_preferences.inputs.view_zoom_axis",
+        "user_preferences.inputs.view_zoom_method",
     ]
 
     preset_subdir = "interaction"
index 52ed4642ac6f58f7e5a96770791f08d017adbed8..c5f60ee509562da7c6dc55762a5b3c47dc1eaf0e 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 11.605, 3.884, 1.754
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.430, 0.210, 0.168
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+    
+material.subsurface_scattering.radius = 11.605, 3.884, 1.754
+material.subsurface_scattering.color = 0.430, 0.210, 0.168
index 1891ef95555a616f03da25bfc03a38f9bdabe666..9acc2f3e25f99f8bc2967f66cd1438af32b3075c 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 9.436, 3.348, 1.790
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.439, 0.216, 0.141
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+
+material.subsurface_scattering.radius = 9.436, 3.348, 1.790
+material.subsurface_scattering.color = 0.439, 0.216, 0.141
index c5e812ffd19158fb3ef237e6c1ca310a3082ad94..c03cc0243d949b05caaf475ec29923c6797e14b1 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 15.028, 4.664, 2.541
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.987, 0.943, 0.827
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+
+material.subsurface_scattering.radius = 15.028, 4.664, 2.541
+material.subsurface_scattering.color = 0.987, 0.943, 0.827
index d56746762823243528ad171c3297bac6a1a49a97..b94c7cced276b6cbf781f09810e427153a27cfed 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 4.762, 0.575, 0.394
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.222, 0.008, 0.002
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+
+material.subsurface_scattering.radius = 4.762, 0.575, 0.394
+material.subsurface_scattering.color = 0.222, 0.008, 0.002
index ad753a7a770c6aeba27d44089285174b73567feb..c85719900e29e9a83e1fb0929de9d9019f2f5d09 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 8.509, 5.566, 3.951
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.925, 0.905, 0.884
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+
+material.subsurface_scattering.radius = 8.509, 5.566, 3.951
+material.subsurface_scattering.color = 0.925, 0.905, 0.884
index 3610c16198fbe832987802bd3ac246aa08c59588..74807014bd3cb1fb14a2544ab2a3a3dd39f60185 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 14.266, 7.228, 2.036
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.855, 0.740, 0.292
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+
+material.subsurface_scattering.radius = 14.266, 7.228, 2.036
+material.subsurface_scattering.color = 0.855, 0.740, 0.292
index eec84f72aa9fef919c1b1b86d9b7110c8b1cde05..163659faf34cdf9bcab2ae3bc2c97acc32a0997e 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 18.424, 10.443, 3.502
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.889, 0.888, 0.796
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+
+material.subsurface_scattering.radius = 18.424, 10.443, 3.502
+material.subsurface_scattering.color = 0.889, 0.888, 0.796
index ba991f8d0d89ceda5f786e2038ae704f24c1fc59..ef28401963770b6f110d9e5213c04774525e3f2a 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 3.673, 1.367, 0.683
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.574, 0.313, 0.174
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+
+material.subsurface_scattering.radius = 3.673, 1.367, 0.683
+material.subsurface_scattering.color = 0.574, 0.313, 0.174
index 6ac556336193cd4ce8dc521ed89c6619800ff80f..16a7d1543094ee867295849b674f3b7efaa03ebd 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 4.821, 1.694, 1.090
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.749, 0.571, 0.467
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+
+material.subsurface_scattering.radius = 4.821, 1.694, 1.090
+material.subsurface_scattering.color = 0.749, 0.571, 0.467
index 4421fc360046170aa82a5bf7007b4dfbf4077cb5..c11b18557e3ac68e865d4cf0abb51250fbbb74f7 100644 (file)
@@ -1,3 +1,5 @@
 import bpy
-bpy.context.active_object.active_node_material.subsurface_scattering.radius = 10.899, 6.575, 2.508
-bpy.context.active_object.active_node_material.subsurface_scattering.color = 0.947, 0.931, 0.852
+material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
+
+material.subsurface_scattering.radius = 10.899, 6.575, 2.508
+material.subsurface_scattering.color = 0.947, 0.931, 0.852
index 6031d3e29d9da775e9ab433ee493f6a358560c5f..6dbf6fca1088c3ad9e252ff4e00abbdadf15e957 100644 (file)
@@ -597,22 +597,6 @@ static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
 }
 
-/* returns (optional) active node material in base material */
-static PointerRNA rna_Object_active_node_material_get(PointerRNA *ptr)
-{
-       Object *ob= (Object*)ptr->id.data;
-       Material *ma;
-       
-       ma= (ob->totcol)? give_current_material(ob, ob->actcol): NULL;
-       if(ma) {
-               Material *manode= give_node_material(ma);
-               if(manode)
-                       return rna_pointer_inherit_refine(ptr, &RNA_Material, manode);
-       }
-       
-       return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
-}
-
 static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
 {
        Object *ob= (Object*)ptr->id.data;
@@ -1794,13 +1778,6 @@ static void rna_def_object(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MaterialSlot_update");
 
-       prop= RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE);
-       RNA_def_property_struct_type(prop, "Material");
-       RNA_def_property_pointer_funcs(prop, "rna_Object_active_node_material_get", NULL, NULL, NULL);
-       RNA_def_property_ui_text(prop, "Active Material", "Active (node) material being displayed");
-       RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
-       
-       
        prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
        RNA_def_property_int_sdna(prop, NULL, "actcol");
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);