diff options
author | Jens Ole Wund <bjornmose@gmx.net> | 2008-04-06 01:29:17 +0400 |
---|---|---|
committer | Jens Ole Wund <bjornmose@gmx.net> | 2008-04-06 01:29:17 +0400 |
commit | 83906a614bfd8f9e36affd4ff34426cbd34b5302 (patch) | |
tree | 26915b79fe08ac1b386f13d1c36dc2acc2f17c5a /source/blender/blenkernel | |
parent | d0004bed8c491655a03bc1df3eb7422bfcf93b2b (diff) |
bug fix soft body can resume with point cache
sneak in .. springs preload
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/softbody.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 834e5fad3dd..aa570085851 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -2751,6 +2751,10 @@ static void springs_from_mesh(Object *ob) if (G.rt > 500){ scale = (G.rt - 500) / 100.0f; } + /* public version shrink to fit */ + if (sb->springpreload != 0 ){ + scale = sb->springpreload / 100.0f; + } for(a=0; a<sb->totspring; a++) { BodySpring *bs = &sb->bspring[a]; bs->len= scale*VecLenf(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS); @@ -3268,6 +3272,9 @@ static void softbody_write_cache(Object *ob, float framenr) for(a=0, bp=sb->bpoint; a<sb->totpoint; a++, bp++) fwrite(&bp->pos, sizeof(float), 3, fp); +/*write velocities too */ + for(a=0, bp=sb->bpoint; a<sb->totpoint; a++, bp++) + fwrite(&bp->vec, sizeof(float), 3, fp); fclose(fp); } @@ -3282,6 +3289,7 @@ static int softbody_read_cache(Object *ob, float framenr) if(sb->totpoint == 0) return 0; + if(sb->particles) stack_index = modifiers_indexInObject(ob,(ModifierData*)psys_get_modifier(ob,sb->particles)); else { @@ -3302,8 +3310,14 @@ static int softbody_read_cache(Object *ob, float framenr) ret = 0; break; } - - fclose(fp); + /*read velocities too !*/ + for(a=0, bp=sb->bpoint; a<sb->totpoint; a++, bp++){ + if(fread(&bp->vec, sizeof(float), 3, fp) != 3) { + ret = 0; + break; + } + } + fclose(fp); } return ret; |