diff options
author | Ton Roosendaal <ton@blender.org> | 2006-06-26 21:50:48 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-06-26 21:50:48 +0400 |
commit | 2670797e8a432c84c04cd8d190bbfd925371e905 (patch) | |
tree | e832fb712ee91285adcdaaf25ab6b76d417e1e62 | |
parent | 1fa9af5dbc08f2a89a3f02822657e40c6d9e43fb (diff) |
Plumiferos report:
The new Material "LightGroups" only worked with lamps in visible layers.
Now also lamps from the group that are not visible are included for
rendering, ensuring that a lightgroup always works on that material,
disregarding layer settings (unless lamp is type 'layer lamp').
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_material_types.h | 6 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 20 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 6 |
4 files changed, 23 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e2db7404048..ad9b4db8844 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -102,7 +102,6 @@ void free_material(Material *ma) void init_material(Material *ma) { - ma->lay= 1; ma->r= ma->g= ma->b= ma->ref= 0.8; ma->specr= ma->specg= ma->specb= 1.0; ma->mirr= ma->mirg= ma->mirb= 1.0; @@ -658,9 +657,12 @@ void init_render_materials(int osa, float *amb) Material *ma; /* two steps, first initialize, then or the flags for layers */ - for(ma= G.main->mat.first; ma; ma= ma->id.next) + for(ma= G.main->mat.first; ma; ma= ma->id.next) { + /* is_used flag comes back in convertblender.c */ + ma->flag &= ~MA_IS_USED; if(ma->id.us) init_render_material(ma, osa, amb); + } } /* only needed for nodes now */ diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 7cbb4c2cd96..6d31db900a7 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -54,7 +54,7 @@ struct bNodeTree; typedef struct Material { ID id; - short colormodel, lay; /* lay: for dynamics (old engine, until 2.04) */ + short colormodel, flag; /* note, keep this below synced with render_types.h */ float r, g, b; float specr, specg, specb; @@ -129,6 +129,10 @@ typedef struct Material { #define MA_YUV 2 #define MA_HSV 3 +/* flag */ + /* for render */ +#define MA_IS_USED 1 + /* mode (is int) */ #define MA_TRACEBLE 1 #define MA_SHADOW 2 diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index c7b96ad28f3..0c3bbf2fc99 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1007,6 +1007,9 @@ static Material *give_render_material(Render *re, Object *ob, int nr) if(re->r.mode & R_SPEED) ma->texco |= NEED_UV; + /* for light groups */ + ma->flag |= MA_IS_USED; + return ma; } @@ -2150,7 +2153,7 @@ static void area_lamp_vectors(LampRen *lar) } /* If lar takes more lamp data, the decoupling will be better. */ -static void add_render_lamp(Render *re, Object *ob) +static LampRen *add_render_lamp(Render *re, Object *ob) { Lamp *la= ob->data; LampRen *lar; @@ -2161,7 +2164,7 @@ static void add_render_lamp(Render *re, Object *ob) /* prevent only shadow from rendering light */ if(la->mode & LA_ONLYSHADOW) if((re->r.mode & R_SHADOW)==0) - return; + return NULL; go= MEM_callocN(sizeof(GroupObject), "groupobject"); BLI_addtail(&re->lights, go); @@ -2347,6 +2350,7 @@ static void add_render_lamp(Render *re, Object *ob) lar->mode &= ~LA_SHAD_RAY; } } + return lar; } /* ------------------------------------------------------------------------- */ @@ -3092,11 +3096,15 @@ static void set_material_lightgroups(Render *re) if(ma->group) { for(go= ma->group->gobject.first; go; go= go->next) { go->lampren= NULL; - for(gol= re->lights.first; gol; gol= gol->next) { - if(gol->ob==go->ob) { - go->lampren= gol->lampren; - break; + if(go->ob && go->ob->type==OB_LAMP) { + for(gol= re->lights.first; gol; gol= gol->next) { + if(gol->ob==go->ob) { + go->lampren= gol->lampren; + break; + } } + if(go->lampren==NULL) + go->lampren= add_render_lamp(re, go->ob); } } } diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index 3b0ad44a9a5..0bd96b89af2 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -2524,12 +2524,6 @@ void do_matbuts(unsigned short event) scrarea_queue_winredraw(curarea); } break; - case B_MATLAY: - if(ma && ma->lay==0) { - ma->lay= 1; - scrarea_queue_winredraw(curarea); - } - break; case B_MATZTRANSP: if(ma) { ma->mode &= ~MA_RAYTRANSP; |