- Particle system distribution wasn't flushed properly for non-edited hair.
- For instances in the renderer, also count their verts and faces in the stats.
- Fix for error in the "surface diffuse" formula for strand shading.
This commit is contained in:
Brecht Van Lommel
2008-01-21 14:18:24 +00:00
parent 91e5b638c6
commit 14241f8349
6 changed files with 33 additions and 5 deletions

View File

@@ -213,6 +213,7 @@ void psys_free_path_cache(struct ParticleSystem *psys);
void free_hair(struct ParticleSystem *psys);
void free_keyed_keys(struct ParticleSystem *psys);
void psys_free(struct Object * ob, struct ParticleSystem * psys);
void psys_free_children(struct ParticleSystem *psys);
void psys_render_set(struct Object *ob, struct ParticleSystem *psys, float viewmat[][4], float winmat[][4], int winx, int winy);
void psys_render_restore(struct Object *ob, struct ParticleSystem *psys);

View File

@@ -318,6 +318,16 @@ void psys_free_path_cache(ParticleSystem *psys)
}
free_child_path_cache(psys);
}
void psys_free_children(ParticleSystem *psys)
{
if(psys->child) {
MEM_freeN(psys->child);
psys->child=0;
psys->totchild=0;
}
free_child_path_cache(psys);
}
/* free everything */
void psys_free(Object *ob, ParticleSystem * psys)
{

View File

@@ -4468,9 +4468,11 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
distribute_particles(ob, psys, part->from);
if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE))
if(get_alloc_child_particles_tot(psys))
distribute_particles(ob, psys, PART_FROM_CHILD);
if((psys->part->type == PART_HAIR) && !(psys->flag & PSYS_HAIR_DONE))
/* don't generate children while growing hair - waste of time */
psys_free_children(psys);
else if(get_alloc_child_particles_tot(psys))
distribute_particles(ob, psys, PART_FROM_CHILD);
}
initialize_all_particles(ob, psys, psmd);

View File

@@ -3894,6 +3894,7 @@ static void find_dupli_instances(Render *re, ObjectRen *obr)
{
ObjectInstanceRen *obi;
float imat[4][4], obmat[4][4], obimat[4][4], nmat[3][3];
int first = 1;
Mat4MulMat4(obmat, obr->ob->obmat, re->viewmat);
Mat4Invert(imat, obmat);
@@ -3909,6 +3910,15 @@ static void find_dupli_instances(Render *re, ObjectRen *obr)
Mat3CpyMat4(nmat, obi->mat);
Mat3Inv(obi->imat, nmat);
if(!first) {
re->totvert += obr->totvert;
re->totvlak += obr->totvlak;
re->tothalo += obr->tothalo;
re->totstrand += obr->totstrand;
}
else
first= 0;
}
}
}

View File

@@ -288,7 +288,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
Material *ma= NULL;
float minz, maxz, vec[3], viewmat[4][4], obviewmat[4][4];
unsigned int lay = -1;
int i, a, ok= 1;
int i, a, maxtotvert, ok= 1;
char *clipflag;
minz= 1.0e30f; maxz= -1.0e30f;
@@ -296,7 +296,11 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
if(lar->mode & LA_LAYER) lay= lar->lay;
clipflag= MEM_callocN(sizeof(char)*re->totvert, "autoclipflag");
maxtotvert= 0;
for(obr=re->objecttable.first; obr; obr=obr->next)
maxtotvert= MAX2(obr->totvert, maxtotvert);
clipflag= MEM_callocN(sizeof(char)*maxtotvert, "autoclipflag");
/* set clip in vertices when face visible */
for(i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) {

View File

@@ -1228,6 +1228,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
Crossf(nstrand, vn, cross);
blend= INPR(nstrand, shi->surfnor);
blend= 1.0f - blend;
CLAMP(blend, 0.0f, 1.0f);
VecLerpf(vnor, nstrand, shi->surfnor, blend);