Fix T46333: Particle Info Node broken w/ BI

Patch from @a.romanov

This also fixes multiple particle systems - which never worked.
This commit is contained in:
Campbell Barton 2015-10-05 23:23:05 +11:00 committed by Sergey Sharybin
parent e5a6c542af
commit e95a213f7a
3 changed files with 32 additions and 31 deletions

View File

@ -115,7 +115,9 @@ 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][4], 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][4], int lay, const struct DupliObject *dob);
void RE_makeRenderInstances(struct Render *re);
void RE_instance_rotate_ray_start(struct ObjectInstanceRen *obi, struct Isect *is);

View File

@ -4658,7 +4658,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, ob->lay);
obi = RE_addRenderInstance(re, obr, ob, par, index, 0, NULL, ob->lay, dob);
if (dob) set_dupli_tex_mat(re, obi, dob, omat);
}
else
@ -4692,7 +4692,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, ob->lay);
obi = RE_addRenderInstance(re, obr, ob, par, index, psysindex, NULL, ob->lay, dob);
if (dob) set_dupli_tex_mat(re, obi, dob, omat);
}
else
@ -5053,7 +5053,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
if (dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) {
mul_m4_m4m4(mat, re->viewmat, dob->mat);
/* ob = particle system, use that layer */
obi= RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], 0, mat, ob->lay);
obi = RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], 0, mat, ob->lay, dob);
/* fill in instance variables for texturing */
set_dupli_tex_mat(re, obi, dob, dob_extra->obmat);
@ -5080,7 +5080,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
if (dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, psysindex))) {
if (obi == NULL)
mul_m4_m4m4(mat, re->viewmat, dob->mat);
obi= RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], psysindex++, mat, obd->lay);
obi = RE_addRenderInstance(re, NULL, obd, ob, dob->persistent_id[0], psysindex++, mat, obd->lay, dob);
set_dupli_tex_mat(re, obi, dob, dob_extra->obmat);
if (dob->type != OB_DUPLIGROUP) {

View File

@ -1363,7 +1363,9 @@ void project_renderdata(Render *re,
/* ------------------------------------------------------------------------- */
ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob, Object *par, int index, int psysindex, float mat[4][4], int lay)
ObjectInstanceRen *RE_addRenderInstance(
Render *re, ObjectRen *obr, Object *ob, Object *par,
int index, int psysindex, float mat[4][4], int lay, const DupliObject *dob)
{
ObjectInstanceRen *obi;
float mat3[3][3];
@ -1377,33 +1379,30 @@ ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob,
obi->lay= lay;
/* Fill particle info */
if (obi->psysindex > 0) {
int psysindex = 1;
int index;
ParticleSystem *psys;
if (obi->par) {
for (psys = obi->par->particlesystem.first; psys; psys = psys->next) {
if (psysindex == obi->psysindex)
break;
++psysindex;
if (par && dob) {
const ParticleSystem *psys = dob->particle_system;
if (psys) {
int index;
if (obi->index < psys->totpart) {
index = obi->index;
}
else if (psys->child) {
index = psys->child[obi->index - psys->totpart].parent;
}
else {
index = -1;
}
if (psys) {
if (obi->index < psys->totpart)
index = obi->index;
else {
index = psys->child[obi->index - psys->totpart].parent;
}
if (index >= 0) {
ParticleData* p = &psys->particles[index];
obi->part_index = index;
obi->part_size = p->size;
obi->part_age = RE_GetStats(re)->cfra - p->time;
obi->part_lifetime = p->lifetime;
copy_v3_v3(obi->part_co, p->state.co);
copy_v3_v3(obi->part_vel, p->state.vel);
copy_v3_v3(obi->part_avel, p->state.ave);
}
if (index >= 0) {
const ParticleData *p = &psys->particles[index];
obi->part_index = index;
obi->part_size = p->size;
obi->part_age = RE_GetStats(re)->cfra - p->time;
obi->part_lifetime = p->lifetime;
copy_v3_v3(obi->part_co, p->state.co);
copy_v3_v3(obi->part_vel, p->state.vel);
copy_v3_v3(obi->part_avel, p->state.ave);
}
}
}