Bugfix: render instancing didn't work correct with layer ipo's,
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 11 Mar 2008 12:29:59 +0000 (12:29 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 11 Mar 2008 12:29:59 +0000 (12:29 +0000)
each instance should have it's own layer.

source/blender/render/intern/include/render_types.h
source/blender/render/intern/include/renderdatabase.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/rayshade.c
source/blender/render/intern/source/renderdatabase.c
source/blender/render/intern/source/shadbuf.c
source/blender/render/intern/source/shadeoutput.c
source/blender/render/intern/source/zbuf.c

index edb5f1442b20a5ead8ba8f140be4d4e73ef43c37..b9adaf2c8877d3fe91b8151e49433eb837a629f7 100644 (file)
@@ -273,7 +273,7 @@ typedef struct ObjectInstanceRen {
 
        ObjectRen *obr;
        Object *ob, *par;
-       int index, psysindex;
+       int index, psysindex, lay;
 
        float mat[4][4], imat[3][3];
        short flag;
index 7576be6e0e6615b3fbc1f648c6d64fcb17cb8150..dc28eae1cc20d219931b86fa94c9069623b46a9b 100644 (file)
@@ -99,7 +99,7 @@ struct HaloRen *RE_inithalo_particle(struct Render *re, struct ObjectRen *obr, s
 struct StrandBuffer *RE_addStrandBuffer(struct ObjectRen *obr, int totvert);
 
 struct ObjectRen *RE_addRenderObject(struct Render *re, struct Object *ob, struct Object *par, int index, int psysindex, int lay);
-struct ObjectInstanceRen *RE_addRenderInstance(struct Render *re, struct ObjectRen *obr, struct Object *ob, struct Object *par, int index, int psysindex, float mat[][4]);
+struct ObjectInstanceRen *RE_addRenderInstance(struct Render *re, struct ObjectRen *obr, struct Object *ob, struct Object *par, int index, int psysindex, float mat[][4], int lay);
 void RE_makeRenderInstances(struct Render *re);
 void RE_instanceTransformNormal(struct ObjectInstanceRen *obi, float *nor, float *tnor);
 
index 40ee4b5d7473900c2abbc75145166af362c8a1e9..bd431b70cdc9fa4d386d1e0053ffa2dad4223510 100644 (file)
@@ -4334,7 +4334,7 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject *
 
                /* only add instance for objects that have not been used for dupli */
                if(!(ob->transflag & OB_RENDER_DUPLI)) {
-                       obi= RE_addRenderInstance(re, obr, ob, par, index, 0, NULL);
+                       obi= RE_addRenderInstance(re, obr, ob, par, index, 0, NULL, ob->lay);
                        if(dob) set_dupli_tex_mat(re, obi, dob);
                }
                else
@@ -4357,7 +4357,7 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject *
 
                        /* only add instance for objects that have not been used for dupli */
                        if(!(ob->transflag & OB_RENDER_DUPLI)) {
-                               obi= RE_addRenderInstance(re, obr, ob, par, index, psysindex, NULL);
+                               obi= RE_addRenderInstance(re, obr, ob, par, index, psysindex, NULL, ob->lay);
                                if(dob) set_dupli_tex_mat(re, obi, dob);
                        }
                        else
@@ -4708,7 +4708,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
                                                 * a dupligroup that has already been created before */
                                                if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) {
                                                        Mat4MulMat4(mat, dob->mat, re->viewmat);
-                                                       obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat);
+                                                       obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat, obd->lay);
 
                                                        /* fill in instance variables for texturing */
                                                        set_dupli_tex_mat(re, obi, dob);
@@ -4736,7 +4736,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
                                                psysindex= 1;
                                                for(psys=obd->particlesystem.first; psys; psys=psys->next) {
                                                        if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, ob, psysindex))) {
-                                                               obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, psysindex++, mat);
+                                                               obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, psysindex++, mat, obd->lay);
 
                                                                set_dupli_tex_mat(re, obi, dob);
                                                                if(dob->type != OB_DUPLIGROUP) {
@@ -5136,7 +5136,7 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve
                                else strand++;
 
                                index= RE_strandren_get_face(obr, strand, 0);
-                               if(index) {
+                               if(index && *index < mesh->totface) {
                                        speed= RE_strandren_get_winspeed(obi, strand, 1);
 
                                        /* interpolate speed vectors from strand surface */
index ba1298dbdd4ba0d2df05843e5e218460a11847ef..d0f9be3fd79ff98916c454fd172a01cd4400d905 100644 (file)
@@ -86,7 +86,7 @@ static int vlr_check_intersect(Isect *is, int ob, RayFace *face)
        if(is->mode==RE_RAY_MIRROR)
                return !(vlr->mat->mode & MA_ONLYCAST);
        else
-               return (is->lay & obi->obr->lay);
+               return (is->lay & obi->lay);
 }
 
 static float *vlr_get_transform(void *userdata, int i)
index 6bd8298739711096d98633a69a6e05bc9cf2cba6..9d3fa35eebba541451e5659edda73eed04097faa 100644 (file)
@@ -1316,7 +1316,7 @@ void project_renderdata(Render *re, void (*projectfunc)(float *, float mat[][4],
 
 /* ------------------------------------------------------------------------- */
 
-ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob, Object *par, int index, int psysindex, float mat[][4])
+ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob, Object *par, int index, int psysindex, float mat[][4], int lay)
 {
        ObjectInstanceRen *obi;
        float mat3[3][3];
@@ -1327,6 +1327,7 @@ ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob,
        obi->par= par;
        obi->index= index;
        obi->psysindex= psysindex;
+       obi->lay= lay;
 
        if(mat) {
                Mat4CpyMat4(obi->mat, mat);
index 35d77ccb38333732ae1ebdcff6dee15d5b815cee..95c9311b8af90ace0a2386ca00ca5125d8e13bef 100644 (file)
@@ -327,7 +327,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
                                if((ma->mode & MA_SHADBUF)==0) ok= 0;
                        }
                        
-                       if(ok && (obr->lay & lay)) {
+                       if(ok && (obi->lay & lay)) {
                                clipflag[vlr->v1->index]= 1;
                                clipflag[vlr->v2->index]= 1;
                                clipflag[vlr->v3->index]= 1;
@@ -1561,7 +1561,7 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root)
                                zspanstrand.shad_alpha= zspan.shad_alpha= ma->shad_alpha;
                        }
                        
-                       if(ok && (obr->lay & lay)) {
+                       if(ok && (obi->lay & lay)) {
                                float hoco[4][4];
                                int c1, c2, c3, c4=0;
                                int d1, d2, d3, d4=0;
index a7dbec2e525c3e16b2866e931eeb185666db520d..303511c3a5d64b4ce01b817b7d85da98005a4c5e 100644 (file)
@@ -355,7 +355,7 @@ void renderspothalo(ShadeInput *shi, float *col, float alpha)
                if(lar->type==LA_SPOT && (lar->mode & LA_HALO) && lar->haint>0) {
                        
                        if(lar->mode & LA_LAYER) 
-                               if(shi->vlr && (lar->lay & shi->obr->lay)==0) 
+                               if(shi->vlr && (lar->lay & shi->obi->lay)==0) 
                                        continue;
                        if((lar->lay & shi->lay)==0) 
                                continue;
@@ -1463,7 +1463,7 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr)
                        /* yafray: ignore shading by photonlights, not used in Blender */
                        if (lar->type==LA_YF_PHOTON) continue;
                        
-                       if(lar->mode & LA_LAYER) if((lar->lay & shi->obr->lay)==0) continue;
+                       if(lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) continue;
                        if((lar->lay & shi->lay)==0) continue;
                        
                        if(lar->shb || (lar->mode & LA_SHAD_RAY)) {
@@ -1601,7 +1601,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
                        if (lar->type==LA_YF_PHOTON) continue;
                        
                        /* test for lamp layer */
-                       if(lar->mode & LA_LAYER) if((lar->lay & shi->obr->lay)==0) continue;
+                       if(lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) continue;
                        if((lar->lay & shi->lay)==0) continue;
                        
                        /* accumulates in shr->diff and shr->spec and shr->shad (diffuse with shadow!) */
index 1243e99e5211e87afcda28e15e6f1354c2ad8e60..579905315bb4c46d06e15b3b2f337cd33cf502cf 100644 (file)
@@ -2120,10 +2120,10 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*,
 
                        /* continue happens in 2 different ways... zmaskpass only does lay_zmask stuff */
                        if(zmaskpass) {
-                               if((obr->lay & lay_zmask)==0)
+                               if((obi->lay & lay_zmask)==0)
                                        continue;
                        }
-                       else if(!all_z && !(obr->lay & (lay|lay_zmask)))
+                       else if(!all_z && !(obi->lay & (lay|lay_zmask)))
                                continue;
                        
                        if(obi->flag & R_TRANSFORMED)
@@ -2141,7 +2141,7 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*,
                                else vlr++;
 
                                /* the cases: visible for render, only z values, zmask, nothing */
-                               if(obr->lay & lay) {
+                               if(obi->lay & lay) {
                                        if(vlr->mat!=ma) {
                                                ma= vlr->mat;
                                                nofill= ma->mode & (MA_ZTRA|MA_ONLYCAST);
@@ -2156,7 +2156,7 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*,
                                                }
                                        }
                                }
-                               else if(all_z || (obr->lay & lay_zmask)) {
+                               else if(all_z || (obi->lay & lay_zmask)) {
                                        env= 1;
                                        nofill= 0;
                                        ma= NULL; 
@@ -2436,7 +2436,7 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int
 
                if(obr->ob==re->excludeob)
                        continue;
-               else if(!(obr->lay & lay))
+               else if(!(obi->lay & lay))
                        continue;
 
                if(obi->flag & R_TRANSFORMED)
@@ -2462,7 +2462,7 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int
                                if((ma->mode & MA_SHADBUF)==0) ok= 0;
                        }
 
-                       if(ok && (obr->lay & lay) && !(vlr->flag & R_HIDDEN)) {
+                       if(ok && (obi->lay & lay) && !(vlr->flag & R_HIDDEN)) {
                                c1= zbuf_shadow_project(cache, vlr->v1->index, obwinmat, vlr->v1->co, ho1);
                                c2= zbuf_shadow_project(cache, vlr->v2->index, obwinmat, vlr->v2->co, ho2);
                                c3= zbuf_shadow_project(cache, vlr->v3->index, obwinmat, vlr->v3->co, ho3);
@@ -2673,7 +2673,7 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo
        for(i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) {
                obr= obi->obr;
 
-               if(!(obr->lay & lay))
+               if(!(obi->lay & lay))
                        continue;
 
                if(obi->flag & R_TRANSFORMED)
@@ -2692,7 +2692,7 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo
                        
                        if(material_in_material(vlr->mat, sss_ma)) {
                                /* three cases, visible for render, only z values and nothing */
-                               if(obr->lay & lay) {
+                               if(obi->lay & lay) {
                                        if(vlr->mat!=ma) {
                                                ma= vlr->mat;
                                                nofill= ma->mode & MA_ONLYCAST;
@@ -3370,7 +3370,7 @@ static int zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, Re
        for(i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) {
                obr= obi->obr;
 
-               if(!(obr->lay & lay))
+               if(!(obi->lay & lay))
                        continue;
 
                if(obi->flag & R_TRANSFORMED)
@@ -3394,7 +3394,7 @@ static int zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, Re
                        }
                        
                        if(dofill) {
-                               if(!(vlr->flag & R_HIDDEN) && (obr->lay & lay)) {
+                               if(!(vlr->flag & R_HIDDEN) && (obi->lay & lay)) {
                                        unsigned short partclip;
                                        
                                        v1= vlr->v1;