Bug fix #3094
authorTon Roosendaal <ton@blender.org>
Sat, 24 Sep 2005 09:05:48 +0000 (09:05 +0000)
committerTon Roosendaal <ton@blender.org>
Sat, 24 Sep 2005 09:05:48 +0000 (09:05 +0000)
Playback of sequencer sound crashed in combination with dupliverted
Objects. (confirmed in osx only btw).

Found out there's old not-needed code in the update_for_newframe() call,
that was intended to do updates for Manipulators (calling countall()).
In countall(), the entire duplilists were generated over, just for
counting the totals.

First step was removing the countall from update_for_newframe, and added
a count_duplilist() call which doesn't generate the full duplilist. That
made Blender not crashing anymore, but gives "Error totblock", without
printing the block names even...

The weird thing also was that the crash showed severe memory corruption in
the malloc library, when combining audio scrubbing (SDL) and duplilists.

I now suspect there's a remaining issue with DerivedMesh, but for that I
need help from Daniel.

source/blender/blenkernel/BKE_anim.h
source/blender/blenkernel/intern/anim.c
source/blender/include/BSE_edit.h
source/blender/src/drawview.c
source/blender/src/edit.c
source/blender/src/headerbuttons.c

index a83c9d9c219ad7a1bc0a9de4a9a535019e16deff..16e8b5652aa0374e55e1563be9974e4623daa854 100644 (file)
@@ -48,6 +48,7 @@ void vertex_duplilist(struct Scene *sce, struct Object *par);
 void particle_duplilist(struct Scene *sce, struct Object *par, struct PartEff *paf);
 void free_duplilist(void);
 void make_duplilist(struct Scene *sce, struct Object *ob);
-       
+int count_duplilist(struct Object *ob);
+
 #endif
 
index ab210b0a6537d2f88ba5bee401c6d1bbd7cc4a6b..56983adba15ed4dbe9f0dfe3bbad33039fb3fbcb 100644 (file)
@@ -507,7 +507,7 @@ void free_duplilist()
 void make_duplilist(Scene *sce, Object *ob)
 {
        PartEff *paf;
-       
+
        if(ob->transflag & OB_DUPLI) {
                if(ob->transflag & OB_DUPLIVERTS) {
                        if(ob->type==OB_MESH) {
@@ -524,3 +524,28 @@ void make_duplilist(Scene *sce, Object *ob)
        }
 }
 
+int count_duplilist(Object *ob)
+{
+       if(ob->transflag & OB_DUPLI) {
+               if(ob->transflag & OB_DUPLIVERTS) {
+                       if(ob->type==OB_MESH) {
+                               if(ob->transflag & OB_DUPLIVERTS) {
+                                       PartEff *paf;
+                                       if( (paf=give_parteff(ob)) ) {
+                                               return paf->totpart;
+                                       }
+                                       else {
+                                               Mesh *me= ob->data;
+                                               return me->totvert;
+                                       }
+                               }
+                       }
+               }
+               else if(ob->transflag & OB_DUPLIFRAMES) {
+                       int tot= ob->dupend - ob->dupsta; 
+                       tot/= (ob->dupon+ob->dupoff);
+                       return tot*ob->dupon;
+               }
+       }
+       return 1;
+}
index e96f2e303fc631ad7d8cc81d57188fbb892e4810..cceee274d7a22f5015f084f0c77d253fd6b3f68f 100644 (file)
@@ -37,7 +37,6 @@ struct Object;
 struct rcti;
 
 int get_border(struct rcti *rect, short col);
-void count_object(struct Object *ob, int sel);
 void countall(void);
 void snapmenu(void); 
 void mergemenu(void);
index d64443108a1254f76c2f89ddda1e13ebe0ebeaf2..23539ac18e2276edaadd7304735879e21001d2ad 100644 (file)
@@ -2162,7 +2162,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
        for(base= G.scene->base.first; base; base= base->next) {
                if(v3d->lay & base->lay) {
                        
-                       /* dupli drawing temporal off here */
+                       /* dupli drawing */
                        if(base->object->transflag & OB_DUPLI) {
                                extern ListBase duplilist;
                                Base tbase;
index 8bb6101f64a1dbef06cb101de2365989ee97fd93..9d5ba5f3f75c1dea6721156f1d90fe4ecd09dd22 100644 (file)
@@ -489,7 +489,7 @@ void circle_selectCB(select_CBfunc callback)
        allqueue(REDRAWINFO, 0);
 }
 
-void count_object(Object *ob, int sel)
+static void count_object(Object *ob, int sel, int totob)
 {
        Mesh *me;
        Curve *cu;
@@ -497,13 +497,13 @@ void count_object(Object *ob, int sel)
        
        switch(ob->type) {
        case OB_MESH:
-               G.totmesh++;
+               G.totmesh+=totob;
                me= get_mesh(ob);
                if(me) {
                        int totvert, totface;
                        
-                       totvert= me->totvert;
-                       totface= me->totface;
+                       totvert= me->totvert*totob;
+                       totface= me->totface*totob;
                        
                        G.totvert+= totvert;
                        G.totface+= totface;
@@ -515,16 +515,18 @@ void count_object(Object *ob, int sel)
                break;
 
        case OB_LAMP:
-               G.totlamp++;
+               G.totlamp+=totob;
                break;
        case OB_SURF:
        case OB_CURVE:
        case OB_FONT:
-               G.totcurve++;
+               G.totcurve+=totob;
                tot=totf= 0;
                cu= ob->data;
                if(cu->disp.first)
                        count_displist( &cu->disp, &tot, &totf);
+               tot*= totob;
+               totf*= totob;
                G.totvert+= tot;
                G.totface+= totf;
                if(sel) {
@@ -534,13 +536,14 @@ void count_object(Object *ob, int sel)
                break;
        case OB_MBALL:
                count_displist( &ob->disp, &tot, &totf);
+               tot*= totob;
+               totf*= totob;
                G.totvert+= tot;
                G.totface+= totf;
                if(sel) {
                        G.totvertsel+= tot;
                        G.totfacesel+= totf;
                }
-               
                break;
        }
        
@@ -695,23 +698,23 @@ void countall()
        base= (G.scene->base.first);
        while(base) {
                if(G.scene->lay & base->lay) {
+                       ob= base->object;       /* warning, ob not is obact anymore */
                        
-                       G.totobj++;
                        if(base->flag & SELECT) G.totobjsel++;
                        
-                       count_object(base->object, base->flag & SELECT);
-                       
-                       if(base->object->transflag & OB_DUPLI) {
-                               extern ListBase duplilist;
-
-                               make_duplilist(G.scene, base->object);
-                               ob= duplilist.first;
-                               while(ob) {
-                                       G.totobj++;
-                                       count_object(ob, base->flag & SELECT);
-                                       ob= ob->id.next;
-                               }
-                               free_duplilist();
+                       if(ob->parent && (ob->parent->transflag & OB_DUPLIVERTS)) {
+                               int tot= count_duplilist(ob->parent);
+                               G.totobj+=tot;
+                               count_object(ob, base->flag & SELECT, tot);
+                       }
+                       else if(ob->transflag & OB_DUPLIFRAMES) {
+                               int tot= count_duplilist(ob);
+                               G.totobj+=tot;
+                               count_object(ob, base->flag & SELECT, tot);
+                       }
+                       else {
+                               count_object(ob, base->flag & SELECT, 1);
+                               G.totobj++;
                        }
                }
                base= base->next;
index 05fde92f7a05e1110b975c0c1c93945f94da370a..3023c2347fbf65d348ed9a6c7cb9636912c3ded4 100644 (file)
@@ -497,17 +497,7 @@ static void do_update_for_newframe(int mute, int events)
        
        /* this function applies the changes too */
        scene_update_for_newframe(G.scene, G.vd?G.vd->lay:G.scene->lay); /* BKE_scene.h */
-               
-       /* manipulators like updates too */
-       for(sa=G.curscreen->areabase.first; sa; sa=sa->next) {
-               if(sa->spacetype==SPACE_VIEW3D) {
-                       View3D *v3d= sa->spacedata.first;
-                       if(v3d->twflag & V3D_USE_MANIPULATOR) break;
-                       else break;     // for now
-               }
-       }
-       if(sa) countall();      // does manipulator centers
-       
+
        if ( (CFRA>1) && (!mute) && (G.scene->audio.flag & AUDIO_SCRUB)) audiostream_scrub( CFRA );
 }