Bugfix: render instancing didn't work correct with layer ipo's,

each instance should have it's own layer.
This commit is contained in:
2008-03-11 12:29:59 +00:00
parent 51a8a60d96
commit 7f6889a63b
8 changed files with 25 additions and 24 deletions

View File

@@ -273,7 +273,7 @@ typedef struct ObjectInstanceRen {
ObjectRen *obr; ObjectRen *obr;
Object *ob, *par; Object *ob, *par;
int index, psysindex; int index, psysindex, lay;
float mat[4][4], imat[3][3]; float mat[4][4], imat[3][3];
short flag; short flag;

View 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 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 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_makeRenderInstances(struct Render *re);
void RE_instanceTransformNormal(struct ObjectInstanceRen *obi, float *nor, float *tnor); void RE_instanceTransformNormal(struct ObjectInstanceRen *obi, float *nor, float *tnor);

View 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 */ /* only add instance for objects that have not been used for dupli */
if(!(ob->transflag & OB_RENDER_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); if(dob) set_dupli_tex_mat(re, obi, dob);
} }
else 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 */ /* only add instance for objects that have not been used for dupli */
if(!(ob->transflag & OB_RENDER_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); if(dob) set_dupli_tex_mat(re, obi, dob);
} }
else 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 */ * a dupligroup that has already been created before */
if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) { if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) {
Mat4MulMat4(mat, dob->mat, re->viewmat); 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 */ /* fill in instance variables for texturing */
set_dupli_tex_mat(re, obi, dob); 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; psysindex= 1;
for(psys=obd->particlesystem.first; psys; psys=psys->next) { for(psys=obd->particlesystem.first; psys; psys=psys->next) {
if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, ob, psysindex))) { 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); set_dupli_tex_mat(re, obi, dob);
if(dob->type != OB_DUPLIGROUP) { if(dob->type != OB_DUPLIGROUP) {
@@ -5136,7 +5136,7 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve
else strand++; else strand++;
index= RE_strandren_get_face(obr, strand, 0); index= RE_strandren_get_face(obr, strand, 0);
if(index) { if(index && *index < mesh->totface) {
speed= RE_strandren_get_winspeed(obi, strand, 1); speed= RE_strandren_get_winspeed(obi, strand, 1);
/* interpolate speed vectors from strand surface */ /* interpolate speed vectors from strand surface */

View File

@@ -86,7 +86,7 @@ static int vlr_check_intersect(Isect *is, int ob, RayFace *face)
if(is->mode==RE_RAY_MIRROR) if(is->mode==RE_RAY_MIRROR)
return !(vlr->mat->mode & MA_ONLYCAST); return !(vlr->mat->mode & MA_ONLYCAST);
else else
return (is->lay & obi->obr->lay); return (is->lay & obi->lay);
} }
static float *vlr_get_transform(void *userdata, int i) static float *vlr_get_transform(void *userdata, int i)

View 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; ObjectInstanceRen *obi;
float mat3[3][3]; float mat3[3][3];
@@ -1327,6 +1327,7 @@ ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob,
obi->par= par; obi->par= par;
obi->index= index; obi->index= index;
obi->psysindex= psysindex; obi->psysindex= psysindex;
obi->lay= lay;
if(mat) { if(mat) {
Mat4CpyMat4(obi->mat, mat); Mat4CpyMat4(obi->mat, mat);

View File

@@ -327,7 +327,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
if((ma->mode & MA_SHADBUF)==0) ok= 0; 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->v1->index]= 1;
clipflag[vlr->v2->index]= 1; clipflag[vlr->v2->index]= 1;
clipflag[vlr->v3->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; zspanstrand.shad_alpha= zspan.shad_alpha= ma->shad_alpha;
} }
if(ok && (obr->lay & lay)) { if(ok && (obi->lay & lay)) {
float hoco[4][4]; float hoco[4][4];
int c1, c2, c3, c4=0; int c1, c2, c3, c4=0;
int d1, d2, d3, d4=0; int d1, d2, d3, d4=0;

View 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->type==LA_SPOT && (lar->mode & LA_HALO) && lar->haint>0) {
if(lar->mode & LA_LAYER) if(lar->mode & LA_LAYER)
if(shi->vlr && (lar->lay & shi->obr->lay)==0) if(shi->vlr && (lar->lay & shi->obi->lay)==0)
continue; continue;
if((lar->lay & shi->lay)==0) if((lar->lay & shi->lay)==0)
continue; 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 */ /* yafray: ignore shading by photonlights, not used in Blender */
if (lar->type==LA_YF_PHOTON) continue; 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->lay & shi->lay)==0) continue;
if(lar->shb || (lar->mode & LA_SHAD_RAY)) { 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; if (lar->type==LA_YF_PHOTON) continue;
/* test for lamp layer */ /* 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; if((lar->lay & shi->lay)==0) continue;
/* accumulates in shr->diff and shr->spec and shr->shad (diffuse with shadow!) */ /* accumulates in shr->diff and shr->spec and shr->shad (diffuse with shadow!) */

View 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 */ /* continue happens in 2 different ways... zmaskpass only does lay_zmask stuff */
if(zmaskpass) { if(zmaskpass) {
if((obr->lay & lay_zmask)==0) if((obi->lay & lay_zmask)==0)
continue; continue;
} }
else if(!all_z && !(obr->lay & (lay|lay_zmask))) else if(!all_z && !(obi->lay & (lay|lay_zmask)))
continue; continue;
if(obi->flag & R_TRANSFORMED) if(obi->flag & R_TRANSFORMED)
@@ -2141,7 +2141,7 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*,
else vlr++; else vlr++;
/* the cases: visible for render, only z values, zmask, nothing */ /* the cases: visible for render, only z values, zmask, nothing */
if(obr->lay & lay) { if(obi->lay & lay) {
if(vlr->mat!=ma) { if(vlr->mat!=ma) {
ma= vlr->mat; ma= vlr->mat;
nofill= ma->mode & (MA_ZTRA|MA_ONLYCAST); 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; env= 1;
nofill= 0; nofill= 0;
ma= NULL; ma= NULL;
@@ -2436,7 +2436,7 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int
if(obr->ob==re->excludeob) if(obr->ob==re->excludeob)
continue; continue;
else if(!(obr->lay & lay)) else if(!(obi->lay & lay))
continue; continue;
if(obi->flag & R_TRANSFORMED) 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((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); 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); 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); 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) { for(i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) {
obr= obi->obr; obr= obi->obr;
if(!(obr->lay & lay)) if(!(obi->lay & lay))
continue; continue;
if(obi->flag & R_TRANSFORMED) 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)) { if(material_in_material(vlr->mat, sss_ma)) {
/* three cases, visible for render, only z values and nothing */ /* three cases, visible for render, only z values and nothing */
if(obr->lay & lay) { if(obi->lay & lay) {
if(vlr->mat!=ma) { if(vlr->mat!=ma) {
ma= vlr->mat; ma= vlr->mat;
nofill= ma->mode & MA_ONLYCAST; 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) { for(i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) {
obr= obi->obr; obr= obi->obr;
if(!(obr->lay & lay)) if(!(obi->lay & lay))
continue; continue;
if(obi->flag & R_TRANSFORMED) if(obi->flag & R_TRANSFORMED)
@@ -3394,7 +3394,7 @@ static int zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, Re
} }
if(dofill) { if(dofill) {
if(!(vlr->flag & R_HIDDEN) && (obr->lay & lay)) { if(!(vlr->flag & R_HIDDEN) && (obi->lay & lay)) {
unsigned short partclip; unsigned short partclip;
v1= vlr->v1; v1= vlr->v1;