Bugfix: render instancing didn't work correct with layer ipo's,
each instance should have it's own layer.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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!) */
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user