From 6b33e12b90bbadef879099dd0dd3062857b273c9 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 24 Sep 2005 09:05:48 +0000 Subject: [PATCH] Bug fix #3094 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 | 3 +- source/blender/blenkernel/intern/anim.c | 27 ++++++++++++++- source/blender/include/BSE_edit.h | 1 - source/blender/src/drawview.c | 2 +- source/blender/src/edit.c | 45 +++++++++++++------------ source/blender/src/headerbuttons.c | 12 +------ 6 files changed, 54 insertions(+), 36 deletions(-) diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h index a83c9d9c219..16e8b5652aa 100644 --- a/source/blender/blenkernel/BKE_anim.h +++ b/source/blender/blenkernel/BKE_anim.h @@ -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 diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index ab210b0a653..56983adba15 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -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; +} diff --git a/source/blender/include/BSE_edit.h b/source/blender/include/BSE_edit.h index e96f2e303fc..cceee274d7a 100644 --- a/source/blender/include/BSE_edit.h +++ b/source/blender/include/BSE_edit.h @@ -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); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index d64443108a1..23539ac18e2 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -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; diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c index 8bb6101f64a..9d5ba5f3f75 100644 --- a/source/blender/src/edit.c +++ b/source/blender/src/edit.c @@ -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; diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index 05fde92f7a0..3023c2347fb 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -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 ); }