diff options
author | Ton Roosendaal <ton@blender.org> | 2006-03-02 02:45:25 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-03-02 02:45:25 +0300 |
commit | a85d160a3e9df3d93132e924870e45394ebd7808 (patch) | |
tree | d1bd87f32506b131cc13a5c94d382d7b9592927f /source/blender | |
parent | a8afa6dc201c8e5869744ba2cbf51114ec075632 (diff) |
Feature: Sofbody bake "Local"
Sofbody simulation happens in global coordinate space, and this was also
used for baking softbodies. Too bad you cannot re-use or further animate
the baked softbody then... :)
If you now use the new "Local" button in the Bake menu, it will allow to
animate or move the baked object.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/softbody.c | 14 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_force.h | 3 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 5 |
3 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 40f0f0ec6bb..0bbd7d3496d 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1570,7 +1570,7 @@ static void curve_surf_to_softbody(Object *ob) /* copies softbody result back in object */ -static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts) +static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, int local) { BodyPoint *bp= ob->soft->bpoint; int a; @@ -1580,7 +1580,8 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts) for(a=0; a<numVerts; a++, bp++) { VECCOPY(vertexCos[a], bp->pos); - Mat4MulVecfl(ob->imat, vertexCos[a]); /* softbody is in global coords */ + if(local==0) + Mat4MulVecfl(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */ } } @@ -1637,7 +1638,7 @@ static int softbody_baked_step(Object *ob, float framenr, float (*vertexCos)[3], bp->pos[2]= data[0]*key0->vec[2] + data[1]*key1->vec[2] + data[2]*key2->vec[2] + data[3]*key3->vec[2]; } - softbody_to_object(ob, vertexCos, numVerts); + softbody_to_object(ob, vertexCos, numVerts, sb->local); return 1; } @@ -1666,6 +1667,9 @@ static void softbody_baked_add(Object *ob, float framenr) sb->keys= MEM_callocN( sizeof(void *)*sb->totkey, "sb keys"); } + /* inverse matrix might not be uptodate... */ + Mat4Invert(ob->imat, ob->obmat); + /* now find out if we have to store a key */ /* offset in keys array */ @@ -1685,6 +1689,8 @@ static void softbody_baked_add(Object *ob, float framenr) for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++, key++) { VECCOPY(key->vec, bp->pos); + if(sb->local) + Mat4MulVecfl(ob->imat, key->vec); } } } @@ -1924,7 +1930,7 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3], int numVerts free_sumo_handles(); } - softbody_to_object(ob, vertexCos, numVerts); + softbody_to_object(ob, vertexCos, numVerts, 0); sb->ctime= ctime; diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 03487f478f9..35cb4ecbf8b 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -92,7 +92,8 @@ typedef struct SoftBody { /* baking */ int sfra, efra; - int interval, pad2; + int interval; + short local, pad2; /* local==1: use local coords for baking */ SBVertex **keys; /* array of size totpointkey */ int totpointkey, totkey; /* if totpointkey != totpoint or totkey!- (efra-sfra)/interval -> free keys */ diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index f584109db81..76c09fac7eb 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -2056,10 +2056,13 @@ static void object_softbodies(Object *ob) uiDefButI(block, NUM, B_DIFF, "Start:", 10, 170,100,20, &sb->sfra, 1.0, 10000.0, 10, 0, "Start frame for baking"); uiDefButI(block, NUM, B_DIFF, "End:", 110, 170,100,20, &sb->efra, 1.0, 10000.0, 10, 0, "End frame for baking"); uiDefButI(block, NUM, B_DIFF, "Interval:", 210, 170,100,20, &sb->interval, 1.0, 10.0, 10, 0, "Interval in frames between baked keys"); + uiBlockEndAlign(block); - uiClearButLock(); + uiDefButS(block, TOG, B_DIFF, "Local", 10, 145,100,20, &sb->local, 0.0, 0.0, 0, 0, "Use local coordinates for baking"); + uiClearButLock(); uiBlockBeginAlign(block); + if(sb->keys) { char str[128]; uiDefIconTextBut(block, BUT, B_SOFTBODY_BAKE_FREE, ICON_X, "FREE BAKE", 10, 120,300,20, NULL, 0.0, 0.0, 0, 0, "Free baked result"); |