And more particle issues... the attempts to allow particle systems to be
part of duplicators (groups especially) isn't easy to get working!
This commit solves regular animated particle systems... they rendered on
the wrong location, using wrong object transform.
This commit is contained in:
Ton Roosendaal
2006-06-09 11:15:52 +00:00
parent ed5c132db1
commit 908389b787
3 changed files with 33 additions and 14 deletions

View File

@@ -280,6 +280,7 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK
static void new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay, int index)
{
DupliObject *dob= MEM_mallocN(sizeof(DupliObject), "dupliobject");
BLI_addtail(lb, dob);
dob->ob= ob;
Mat4CpyMat4(dob->mat, mat);
@@ -287,6 +288,15 @@ static void new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay,
dob->origlay= ob->lay;
dob->index= index;
ob->lay= lay;
/* allowing duplicators for particle systems... a bit silly still */
{
PartEff *paf= give_parteff(ob);
if(paf) {
Mat4Invert(ob->imat, ob->obmat);
Mat4CpyMat4(paf->imat, ob->imat);
}
}
}
static void group_duplilist(ListBase *lb, Object *ob)
@@ -660,6 +670,7 @@ ListBase *object_duplilist(Scene *sce, Object *ob)
frames_duplilist(&duplilist, ob);
else if(ob->transflag & OB_DUPLIGROUP)
group_duplilist(&duplilist, ob);
}
return &duplilist;

View File

@@ -843,7 +843,7 @@ static Material *give_render_material(Render *re, Object *ob, int nr)
static void render_particle_system(Render *re, Object *ob, PartEff *paf)
static void render_particle_system(Render *re, Object *ob, Object *par, PartEff *paf)
{
Particle *pa=0;
HaloRen *har=0;
@@ -855,8 +855,6 @@ static void render_particle_system(Render *re, Object *ob, PartEff *paf)
float haloScale = 1.0; //NT scale halos
float iniAlpha = 0.0; // restore material alpha
pa= paf->keys;
if(pa==NULL || paf->disp!=100) {
build_particle_system(ob);
@@ -870,11 +868,20 @@ static void render_particle_system(Render *re, Object *ob, PartEff *paf)
MTC_Mat4Invert(ob->imat, mat); /* this is correct, for imat texture */
/* enable duplicators to work */
Mat4MulMat4(tmat, paf->imat, ob->obmat);
MTC_Mat4MulMat4(mat, tmat, re->viewmat);
MTC_Mat4Invert(tmat, mat);
MTC_Mat3CpyMat4(imat, tmat);
if(par) {
Mat4MulMat4(tmat, paf->imat, ob->obmat);
MTC_Mat4MulMat4(mat, tmat, re->viewmat);
MTC_Mat4Invert(tmat, mat);
MTC_Mat3CpyMat4(imat, tmat);
}
else {
MTC_Mat4CpyMat4(mat, re->viewmat);
MTC_Mat4Invert(tmat, re->viewmat);
MTC_Mat3CpyMat4(imat, tmat);
}
re->flag |= R_HALO;
@@ -1561,7 +1568,7 @@ static void use_mesh_edge_lookup(Render *re, Mesh *me, DispListMesh *dlm, MEdge
}
}
static void init_render_mesh(Render *re, Object *ob, int only_verts)
static void init_render_mesh(Render *re, Object *ob, Object *par, int only_verts)
{
Mesh *me;
MVert *mvert = NULL;
@@ -1587,7 +1594,7 @@ static void init_render_mesh(Render *re, Object *ob, int only_verts)
if(paf) {
/* warning; build_particle_system does modifier calls itself */
if(paf->flag & PAF_STATIC) render_static_particle_system(re, ob, paf);
else render_particle_system(re, ob, paf);
else render_particle_system(re, ob, par, paf);
if((paf->flag & PAF_SHOWE)==0) return;
}
@@ -2676,7 +2683,7 @@ static void init_render_object(Render *re, Object *ob, Object *par, int index, i
else if(ob->type==OB_SURF)
init_render_surf(re, ob);
else if(ob->type==OB_MESH)
init_render_mesh(re, ob, only_verts);
init_render_mesh(re, ob, par, only_verts);
else if(ob->type==OB_MBALL)
init_render_mball(re, ob);
else {

View File

@@ -2526,8 +2526,9 @@ static int drawDispList(Base *base, int dt)
/* ******************************** */
static void draw_particle_system(Object *ob, PartEff *paf)
static void draw_particle_system(Base *base, PartEff *paf)
{
Object *ob= base->object;
Particle *pa;
float ptime, ctime, vec[3], vec1[3], mat[4][4];
int a, totpart;
@@ -2544,7 +2545,7 @@ static void draw_particle_system(Object *ob, PartEff *paf)
myloadmatrix(G.vd->viewmat);
/* flag abuse... but I need working code too now. This feature doesnt work for per frame animated objects */
if(ob->flag & OB_FROMGROUP) {
if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) {
Mat4MulMat4(mat, paf->imat, ob->obmat);
mymultmatrix(mat);
}
@@ -3787,7 +3788,7 @@ void draw_object(Base *base, int flag)
if(paf) {
if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */
if(paf->flag & PAF_STATIC) draw_static_particle_system(ob, paf, dt);
else if((flag & DRAW_PICKING) == 0) draw_particle_system(ob, paf); // selection errors happen to easy
else if((flag & DRAW_PICKING) == 0) draw_particle_system(base, paf); // selection errors happen to easy
if(col) cpack(col);
}
}