From 0746e7edb3510c81eccbdd45ea2bfa08728f8c42 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 20 Sep 2005 10:21:30 +0000 Subject: [PATCH] Bug fix #3044 Undid Daniels' commit (version 1.42) for this file, which claimed to fix "free baked softbody". Result was that baked softbodies couldn't be read from a file (always were freed). I tested the free bake, and it works properly. Daniel: your move! --- source/blender/blenkernel/intern/softbody.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 1865b6345a6..c925997e30a 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -297,7 +297,7 @@ static void free_softbody_baked(SoftBody *sb) { SBVertex *key; int k; - + for(k=0; ktotkey; k++) { key= *(sb->keys + k); if(key) MEM_freeN(key); @@ -1238,7 +1238,9 @@ static int softbody_baked_step(Object *ob, float framenr, float (*vertexCos)[3], /* precondition check */ if(sb==NULL || sb->keys==NULL || sb->totkey==0) return 0; - + /* so we got keys, but no bodypoints... even without simul we need it for the bake */ + if(sb->bpoint==NULL) sb->bpoint= MEM_callocN( sb->totpoint*sizeof(BodyPoint), "bodypoint"); + /* convert cfra time to system time */ sfra= (float)sb->sfra; cfra= bsystem_time(ob, NULL, framenr, 0.0); @@ -1402,7 +1404,12 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3], int numVerts float ctime, forcetime; float err; - /* remake softbody if: */ + /* baking works with global time */ + if(!(ob->softflag & OB_SB_BAKEDO) ) + if(softbody_baked_step(ob, framenr, vertexCos, numVerts) ) return; + + + /* remake softbody if: */ if( (ob->softflag & OB_SB_REDO) || // signal after weightpainting (ob->soft==NULL) || // just to be nice we allow full init (ob->soft->bpoint==NULL) || // after reading new file, or acceptable as signal to refresh @@ -1426,10 +1433,6 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3], int numVerts ob->softflag &= ~OB_SB_REDO; } - /* baking works with global time */ - if(!(ob->softflag & OB_SB_BAKEDO) ) - if(softbody_baked_step(ob, framenr, vertexCos, numVerts) ) return; - sb= ob->soft; /* still no points? go away */