Revision: 28570
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28570
Author:   joeedh
Date:     2010-05-04 14:26:00 +0200 (Tue, 04 May 2010)

Log Message:
-----------
particle and pointcaches now check if they are recursing; e.g. a particle 
system instancing itself.

Modified Paths:
--------------
    branches/render25/source/blender/blenkernel/BKE_particle.h
    branches/render25/source/blender/blenkernel/intern/pointcache.c
    branches/render25/source/blender/editors/space_view3d/drawobject.c
    branches/render25/source/blender/makesdna/DNA_object_types.h

Modified: branches/render25/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/render25/source/blender/blenkernel/BKE_particle.h  2010-05-04 
11:54:44 UTC (rev 28569)
+++ branches/render25/source/blender/blenkernel/BKE_particle.h  2010-05-04 
12:26:00 UTC (rev 28570)
@@ -182,6 +182,7 @@
        float *ma_r, *ma_g, *ma_b;
        int tot_vec_size, flag;
        int totpoint, totve;
+       int draw_depth; /*used to detect and abort recursions*/
 } ParticleDrawData;
 
 #define PARTICLE_DRAW_DATA_UPDATED  1

Modified: branches/render25/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/pointcache.c     
2010-05-04 11:54:44 UTC (rev 28569)
+++ branches/render25/source/blender/blenkernel/intern/pointcache.c     
2010-05-04 12:26:00 UTC (rev 28570)
@@ -996,6 +996,14 @@
 
        lb->first= lb->last= NULL;
 
+       /*we could actually allow a user-definable number of dupli recursions, 
but for now
+         simply don't allow it at all*/
+
+       if (ob->dupli_depth)
+               return;
+
+       ob->dupli_depth++;
+
        if(ob->soft) {
                pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
                BKE_ptcache_id_from_softbody(pid, ob, ob->soft);
@@ -1047,6 +1055,8 @@
                        free_object_duplilist(lb_dupli_ob);     /* does restore 
*/
                }
        }
+
+       ob->dupli_depth--;
 }
 
 

Modified: branches/render25/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/render25/source/blender/editors/space_view3d/drawobject.c  
2010-05-04 11:54:44 UTC (rev 28569)
+++ branches/render25/source/blender/editors/space_view3d/drawobject.c  
2010-05-04 12:26:00 UTC (rev 28570)
@@ -3433,7 +3433,7 @@
        ParticleKey state, *states=0;
        ParticleBillboardData bb;
        ParticleSimulationData sim = {scene, ob, psys, NULL};
-       ParticleDrawData *pdd = psys->pdd;
+       ParticleDrawData *pdd = psys;
        Material *ma;
        float vel[3], imat[4][4];
        float timestep, pixsize=1.0, pa_size, r_tilt, r_length;
@@ -3449,6 +3449,10 @@
        if(psys==0)
                return;
 
+       pdd = psys->pdd;
+       if (pdd && pdd->draw_depth)
+               return;
+
        part=psys->part;
        pars=psys->particles;
 
@@ -3667,6 +3671,10 @@
                pdd->tot_vec_size= tot_vec_size;
        }
 
+       /*increment draw_depth, used to deal with recursions*/
+       if (pdd)
+               pdd->draw_depth++;
+
        psys->lattice= psys_get_lattice(&sim);
 
        if(pdd && draw_as!=PART_DRAW_PATH){
@@ -4010,6 +4018,10 @@
 
        psys->flag &= ~PSYS_DRAWING;
 
+       /*decrement the recursion tracker variable*/
+       if (pdd)
+               pdd->draw_depth--;
+
        /* draw data can't be saved for billboards as they must update to 
target changes */
        if(draw_as == PART_DRAW_BB) {
                psys_free_pdd(psys);

Modified: branches/render25/source/blender/makesdna/DNA_object_types.h
===================================================================
--- branches/render25/source/blender/makesdna/DNA_object_types.h        
2010-05-04 11:54:44 UTC (rev 28569)
+++ branches/render25/source/blender/makesdna/DNA_object_types.h        
2010-05-04 12:26:00 UTC (rev 28570)
@@ -259,7 +259,7 @@
 
        float *groupmat;                /* runtime, temporarily set during 
group evaluation */
        int groupmodified;              /* runtime, to indicate if we modified 
object matrix */
-       int pad3;
+       int dupli_depth;        /* used to detect if an object references 
itself through its duplis */
 } Object;
 
 /* Warning, this is not used anymore because hooks are now modifiers */


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to