- some missing changes for switch of mesh_modifier to
authorDaniel Dunbar <daniel@zuster.org>
Tue, 19 Jul 2005 04:27:43 +0000 (04:27 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 19 Jul 2005 04:27:43 +0000 (04:27 +0000)
   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.

source/blender/blenkernel/BKE_softbody.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/softbody.c
source/blender/src/buttons_object.c
source/blender/src/editobject.c

index 529668c5fc8b5ae964dde64d18aefddf15bb7ee1..af764b149beeb940f4011173da6ab71e8edca12d 100644 (file)
@@ -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);
index 099a121ed57ad24efc287c7ecd46940fe1da6aac..3e6c4ee8587d7785703e7cbbf625c6e9700771a0 100644 (file)
@@ -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) {
index 93c2c46ae22c3eb3a34f2b149832469355488efe..d038d6a61ea8b2aaf051aac58144d774bc235d79 100644 (file)
@@ -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 */
index c835b4c2257ed583c625772d40ad0a272a06b4fb..b2845765e19d9b1051c88b2d3df1267faac8ab07 100644 (file)
@@ -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;
index 2d10018fdc0e3d6b813b5053756a2f58398e9f5b..f77abdf7bbac3c1e0729adb916e6861b16fee930 100644 (file)
@@ -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);