Fixes:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 21 Jan 2008 14:18:24 +0000 (14:18 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 21 Jan 2008 14:18:24 +0000 (14:18 +0000)
- 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.

source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/shadbuf.c
source/blender/render/intern/source/shadeoutput.c

index 399f67b728896531f3efd9737f869d958b9e656e..af5713b565d88c98c7e8c0fe0343fac062ecc1a2 100644 (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);
index bf8d1e9d8aa949ab34bc5621f9a6fd9aacc03af4..9cfc7e9dafe97044253add78190a753e3db28e50 100644 (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)
 {
index 94cfdadbb16a13c0e8d34ecfb255bb814c5ae0f4..88a75a50ce568d38ad00bad9bf944a058142592d 100644 (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);
 
index 293b367a04933fe9a1803201c0616ef4ed5a21b3..ff227b1c67031aa7cf481fae19b245b643bdc354 100644 (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;
                }
        }
 }
index 34fd5b0154a44242af3a9430b804d20fbd5fc754..42086d078f67c7e04943f6d0bf1456bbd885bd0f 100644 (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) {
index 0ba7c09cdd8c53c179beb1d087d39ad701f0b011..1498683baab82d96349a2f269cdc0799500d5f45 100644 (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);