From 20585a8b8dc50bc1a090f2d44066540839ee7303 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 17 Oct 2012 13:32:43 +0000 Subject: Render: local light group option for materials, blender internal feature from the render branch. When a material is linked in and has a light group override, this can now use a local group in the scene file, by replacing the linked light group with a local group that has the same name. A use case might be controlling the specular highlight on linked character's eyes per scene. Patch from render branch by Pablo Vazquez. --- release/scripts/startup/bl_ui/properties_material.py | 1 + source/blender/blenkernel/intern/material.c | 10 ++++++++++ source/blender/makesdna/DNA_material_types.h | 1 + source/blender/makesrna/intern/rna_material.c | 7 ++++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 8eecbf4b604..951644db752 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -753,6 +753,7 @@ class MATERIAL_PT_options(MaterialButtonsPanel, Panel): row = sub.row() row.active = bool(mat.light_group) row.prop(mat, "use_light_group_exclusive", text="Exclusive") + row.prop(mat, "use_light_group_local", text="Local") col = split.column() col.prop(mat, "use_face_texture") diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index bea0e33da9a..7d5ed058cca 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -38,6 +38,7 @@ #include "DNA_anim_types.h" #include "DNA_curve_types.h" +#include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -980,6 +981,15 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) /* parses the geom+tex nodes */ if (ma->nodetree && ma->use_nodes) ntreeShaderGetTexcoMode(ma->nodetree, r_mode, &ma->texco, &ma->mode_l); + + /* local group override */ + if((ma->shade_flag & MA_GROUP_LOCAL) && ma->id.lib && ma->group && ma->group->id.lib) { + Group *group; + + for(group= G.main->group.first; group; group= group->id.next) + if(!group->id.lib && strcmp(group->id.name, ma->group->id.name) == 0) + ma->group = group; + } } static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode, float *amb) diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 374cc8e7379..51f9af278fe 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -292,6 +292,7 @@ typedef struct Material { #define MA_CUBIC 1 #define MA_OBCOLOR 2 #define MA_APPROX_OCCLUSION 4 +#define MA_GROUP_LOCAL 8 /* diff_shader */ #define MA_DIFF_LAMBERT 0 diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index ed40f8cffb6..f53adcc6837 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -1823,7 +1823,12 @@ void RNA_def_material(BlenderRNA *brna) "Material uses the light group exclusively - these lamps are excluded " "from other scene lighting"); RNA_def_property_update(prop, 0, "rna_Material_update"); - + + prop= RNA_def_property(srna, "use_light_group_local", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_GROUP_LOCAL); + RNA_def_property_ui_text(prop, "Light Group Local", "When linked in, Material uses local light group with the same name"); + RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRACEBLE); RNA_def_property_ui_text(prop, "Traceable", -- cgit v1.2.3