diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-07-19 08:27:43 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-07-19 08:27:43 +0400 |
commit | 59a298061124d5773993ae3ac350dd883844784d (patch) | |
tree | 452042f33e525d8b5823234b2594cc664b84ccb8 /source/blender | |
parent | 2dbb9409df34d107ef4402d8b2daf6da3158312e (diff) |
- some missing changes for switch of mesh_modifier to
deform new verts array.
I don't really know how to use softbody, so it would be nice
if someone would test this for me.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_softbody.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/softbody.c | 45 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 6 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 4 |
5 files changed, 31 insertions, 28 deletions
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h index 529668c5fc8..af764b149be 100644 --- a/source/blender/blenkernel/BKE_softbody.h +++ b/source/blender/blenkernel/BKE_softbody.h @@ -62,7 +62,7 @@ extern void sbFree(struct SoftBody *sb); extern void sbObjectStep(struct Object *ob, float framnr, float (*vertexCos)[3]); /* makes totally fresh start situation, resets time */ -extern void sbObjectToSoftbody(struct Object *ob); +extern void sbObjectToSoftbody(struct Object *ob, float (*vertexCos)[3]); /* resets all motion and time */ extern void sbObjectReset(struct Object *ob); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 099a121ed57..3e6c4ee8587 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1045,7 +1045,7 @@ static void clear_and_build_mesh_data(Object *ob, int mustBuildForMesh) float min[3], max[3]; Mesh *me= ob->data; - if(ob->flag&OB_FROMDUPLI) return; // XXX is this needed + if(ob->flag&OB_FROMDUPLI) return; /* also serves as signal to remake texspace */ if (me->bb) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 93c2c46ae22..d038d6a61ea 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -770,23 +770,24 @@ static void set_body_point(Object *ob, BodyPoint *bp, float *vec) /* copy original (new) situation in softbody, as result of matrices or deform */ /* is assumed to enter function with ob->soft, but can be without points */ -static void mesh_update_softbody(Object *ob) +static void mesh_update_softbody(Object *ob, float (*vertexCos)[3]) { Mesh *me= ob->data; - MVert *mvert= me->mvert; -/* MEdge *medge= me->medge; */ /*unused*/ BodyPoint *bp; int a; /* possible after a file read... */ - if(ob->soft->bpoint==NULL) sbObjectToSoftbody(ob); + if(ob->soft->bpoint==NULL) sbObjectToSoftbody(ob, NULL); if(me->totvert) { - bp= ob->soft->bpoint; - for(a=0; a<me->totvert; a++, mvert++, bp++) { + for(a=0; a<me->totvert; a++, bp++) { + if (vertexCos) { + VECCOPY(bp->origE, vertexCos[a]); + } else { + VECCOPY(bp->origE, me->mvert[a].co); + } VECCOPY(bp->origS, bp->origE); - VECCOPY(bp->origE, mvert->co); Mat4MulVecfl(ob->obmat, bp->origE); VECCOPY(bp->origT, bp->origE); } @@ -795,7 +796,7 @@ static void mesh_update_softbody(Object *ob) /* happens when in UI edges was set */ if(ob->soft->bspring==NULL) - if(object_has_edges(ob)) sbObjectToSoftbody(ob); + if(object_has_edges(ob)) sbObjectToSoftbody(ob, NULL); /* hrms .. do springs alter their lenght ? (yes, mesh keys would (ton)) if(medge) { @@ -837,11 +838,10 @@ static void get_scalar_from_vertexgroup(Object *ob, int vertID, short groupindex } /* makes totally fresh start situation */ -static void mesh_to_softbody(Object *ob) +static void mesh_to_softbody(Object *ob, float (*vertexCos)[3]) { SoftBody *sb; Mesh *me= ob->data; - MVert *mvert= me->mvert; MEdge *medge= me->medge; BodyPoint *bp; BodySpring *bs; @@ -859,9 +859,12 @@ static void mesh_to_softbody(Object *ob) bp= sb->bpoint; goalfac= ABS(sb->maxgoal - sb->mingoal); - for(a=me->totvert; a>0; a--, mvert++, bp++) { - - set_body_point(ob, bp, mvert->co); + for(a=0; a<me->totvert; a++, bp++) { + if (vertexCos) { + set_body_point(ob, bp, vertexCos[a]); + } else { + set_body_point(ob, bp, me->mvert[a].co); + } /* get scalar values needed *per vertex* from vertex group functions, so we can *paint* them nicly .. @@ -974,7 +977,7 @@ static void lattice_update_softbody(Object *ob) totvert= lt->pntsu*lt->pntsv*lt->pntsw; /* possible after a file read... */ - if(ob->soft->bpoint==NULL) sbObjectToSoftbody(ob); + if(ob->soft->bpoint==NULL) sbObjectToSoftbody(ob, NULL); for(a= totvert, bp= lt->def, bop= ob->soft->bpoint; a>0; a--, bp++, bop++) { VECCOPY(bop->origS, bop->origE); @@ -1008,12 +1011,12 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3]) /* copy original (new) situation in softbody, as result of matrices or deform */ /* used in sbObjectStep() and sbObjectReset() */ /* assumes to have ob->soft, but can be entered without points */ -static void object_update_softbody(Object *ob) +static void object_update_softbody(Object *ob, float (*vertexCos)[3]) { switch(ob->type) { case OB_MESH: - mesh_update_softbody(ob); + mesh_update_softbody(ob, vertexCos); break; case OB_LATTICE: lattice_update_softbody(ob); @@ -1168,12 +1171,12 @@ void sbFree(SoftBody *sb) /* makes totally fresh start situation */ -void sbObjectToSoftbody(Object *ob) +void sbObjectToSoftbody(Object *ob, float (*vertexCos)[3]) { switch(ob->type) { case OB_MESH: - mesh_to_softbody(ob); + mesh_to_softbody(ob, vertexCos); break; case OB_LATTICE: lattice_to_softbody(ob); @@ -1196,7 +1199,7 @@ void sbObjectReset(Object *ob) sb->ctime= bsystem_time(ob, NULL, (float)G.scene->r.cfra, 0.0); - object_update_softbody(ob); + object_update_softbody(ob, NULL); for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { // origS is previous timestep @@ -1239,7 +1242,7 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3]) 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 - sbObjectToSoftbody(ob); + sbObjectToSoftbody(ob, vertexCos); sb= ob->soft; @@ -1267,7 +1270,7 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3]) //dtime is still in [frames] //we made sure dtime is >= 0.0 //but still need to handle dtime == 0.0 -> just return sb as is, just to be nice - object_update_softbody(ob); + object_update_softbody(ob, vertexCos); if (TRUE) { // RSOL1 always true now (ton) /* special case of 2nd order Runge-Kutta type AKA Heun */ diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index c835b4c2257..b2845765e19 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -1097,7 +1097,7 @@ static void softbody_bake(Object *ob) G.scene->r.framelen= 1.0; // baking has to be in uncorrected time CFRA= sb->sfra; update_for_newframe_muted(); // put everything on this frame - sbObjectToSoftbody(ob); // put softbody in restposition + sbObjectToSoftbody(ob, NULL); // put softbody in restposition ob->softflag |= OB_SB_BAKEDO; curarea->win_swap= 0; // clean swapbuffers @@ -1122,7 +1122,7 @@ static void softbody_bake(Object *ob) if(event==ESCKEY) break; } - if(event==ESCKEY) sbObjectToSoftbody(ob); // clears all + if(event==ESCKEY) sbObjectToSoftbody(ob, NULL); // clears all /* restore */ waitcursor(0); @@ -1247,7 +1247,7 @@ void do_object_panels(unsigned short event) break; case B_SOFTBODY_BAKE_FREE: ob= OBACT; - if(ob && ob->soft) sbObjectToSoftbody(ob); + if(ob && ob->soft) sbObjectToSoftbody(ob, NULL); allqueue(REDRAWBUTSOBJECT, 0); allqueue(REDRAWVIEW3D, 0); break; diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 2d10018fdc0..f77abdf7bba 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -1513,9 +1513,9 @@ void exit_editmode(int freedata) /* freedata==0 at render, 1= freedata, 2= do un if(sb->keys) { if( okee("Erase Baked SoftBody") ) - sbObjectToSoftbody(ob); + sbObjectToSoftbody(ob, NULL); } - else sbObjectToSoftbody(ob); + else sbObjectToSoftbody(ob, NULL); } DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); |