Bug fix: Particles in dupligroups were mostly drawn properly in 3d view, but rendering them was a real mess.

* After countless different bugs particles should now render correctly inside dupligroups.
* Only particles with metaball visualization are still problematic, this is mostly due to the ancient metaball code.
* I'll also add a test file for some of the situations, so that hopefully these cases stay fixed :)
This commit is contained in:
2011-02-06 15:50:00 +00:00
parent d9aa3f66a6
commit 0ea9271f43
4 changed files with 32 additions and 16 deletions

View File

@@ -1492,13 +1492,13 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
StrandBound *sbound= 0;
StrandRen *strand=0;
RNG *rng= 0;
float loc[3],loc1[3],loc0[3],mat[4][4],nmat[3][3],co[3],nor[3];
float loc[3],loc1[3],loc0[3],mat[4][4],nmat[3][3],co[3],nor[3],duplimat[4][4];
float strandlen=0.0f, curlen=0.0f;
float hasize, pa_size, r_tilt, r_length;
float pa_time, pa_birthtime, pa_dietime;
float random, simplify[2], pa_co[3];
const float cfra= BKE_curframe(re->scene);
int i, a, k, max_k=0, totpart, dosimplify = 0, dosurfacecache = 0;
int i, a, k, max_k=0, totpart, dosimplify = 0, dosurfacecache = 0, use_duplimat = 0;
int totchild=0;
int seed, path_nbr=0, orco1=0, num;
int totface, *origindex = 0;
@@ -1638,6 +1638,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
copy_m3_m4(nmat, ob->imat);
transpose_m3(nmat);
if(psys->flag & PSYS_USE_IMAT) {
/* psys->imat is the original emitter's inverse matrix, ob->obmat is the duplicated object's matrix */
mul_m4_m4m4(duplimat, psys->imat, ob->obmat);
use_duplimat = 1;
}
/* 2.6 setup strand rendering */
if(part->ren_as == PART_DRAW_PATH && psys->pathcache){
path_nbr=(int)pow(2.0,(double) part->ren_step);
@@ -1949,6 +1955,9 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(psys->parent)
mul_m4_v3(psys->parent->obmat, state.co);
if(use_duplimat)
mul_m4_v4(duplimat, state.co);
if(part->ren_as == PART_DRAW_BB) {
bb.random = random;
bb.size = pa_size;
@@ -1971,6 +1980,9 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(psys->parent)
mul_m4_v3(psys->parent->obmat, state.co);
if(use_duplimat)
mul_m4_v4(duplimat, state.co);
if(part->ren_as == PART_DRAW_BB) {
bb.random = random;
bb.size = pa_size;
@@ -4345,7 +4357,7 @@ static void init_render_object_data(Render *re, ObjectRen *obr, int timeoffset)
int i;
if(obr->psysindex) {
if((!obr->prev || obr->prev->ob != ob) && ob->type==OB_MESH) {
if((!obr->prev || obr->prev->ob != ob || (obr->prev->flag & R_INSTANCEABLE)==0) && ob->type==OB_MESH) {
/* the emitter mesh wasn't rendered so the modifier stack wasn't
* evaluated with render settings */
DerivedMesh *dm;
@@ -4437,8 +4449,11 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject *
}
if(obr->lay & vectorlay)
obr->flag |= R_NEED_VECTORS;
if(dob)
psys->flag |= PSYS_USE_IMAT;
init_render_object_data(re, obr, timeoffset);
psys_render_restore(ob, psys);
psys->flag &= ~PSYS_USE_IMAT;
/* only add instance for objects that have not been used for dupli */
if(!(ob->transflag & OB_RENDER_DUPLI)) {