Added signal OB_SB_REDO for ob->softflag to force a recalc.
Now used after weight painting, so it updates immediately.
This commit is contained in:
@@ -668,7 +668,7 @@ static int get_scalar_from_named_vertexgroup(Object *ob, char *name, int vertID,
|
||||
/* Lets see if this vert is in the weight group */
|
||||
for (i=0; i<dv->totweight; i++){
|
||||
if (dv->dw[i].def_nr == groupindex){
|
||||
*target=dv->dw[i].weight; /* got it ! */
|
||||
*target= dv->dw[i].weight; /* got it ! */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -696,16 +696,19 @@ static void mesh_to_softbody(Object *ob)
|
||||
sb= ob->soft;
|
||||
bp= sb->bpoint;
|
||||
for(a=me->totvert; a>0; a--, mvert++, bp++) {
|
||||
|
||||
VECCOPY(bp->pos, mvert->co);
|
||||
Mat4MulVecfl(ob->obmat, bp->pos); // yep, sofbody is global coords
|
||||
VECCOPY(bp->origS, bp->pos);
|
||||
VECCOPY(bp->origE, bp->pos);
|
||||
VECCOPY(bp->origT, bp->pos);
|
||||
|
||||
bp->vec[0]= bp->vec[1]= bp->vec[2]= 0.0;
|
||||
bp->weight= 1.0;
|
||||
bp->goal= 0.5;
|
||||
bp->nofsprings=0;
|
||||
bp->springs=NULL;
|
||||
bp->nofsprings= 0;
|
||||
bp->springs= NULL;
|
||||
|
||||
if (1) { /* switch to vg scalars*/
|
||||
/* get scalar values needed *per vertex* from vertex group functions,
|
||||
so we can *paint* them nicly ..
|
||||
@@ -717,12 +720,13 @@ static void mesh_to_softbody(Object *ob)
|
||||
char name[32] = "SOFTGOAL";
|
||||
float temp;
|
||||
|
||||
error = get_scalar_from_named_vertexgroup(ob,name,me->totvert - a,&temp);
|
||||
error = get_scalar_from_named_vertexgroup(ob, name, me->totvert - a, &temp);
|
||||
if (!error) bp->goal = temp;
|
||||
if (bp->goal < sb->mingoal) bp->goal = sb->mingoal;
|
||||
if (bp->goal > sb->maxgoal) bp->goal = sb->maxgoal;
|
||||
/* a little ad hoc changing the goal control to be less *sharp* */
|
||||
bp->goal = (float)pow(bp->goal,4.0f);
|
||||
|
||||
/* to proove the concept
|
||||
this would enable per vertex *mass painting*
|
||||
strcpy(name,"SOFTMASS");
|
||||
@@ -755,6 +759,7 @@ static void mesh_to_softbody(Object *ob)
|
||||
|
||||
build_bps_springlist(ob); /* big mesh optimization */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* copies current sofbody position in mesh, so do this within modifier stacks! */
|
||||
@@ -870,6 +875,7 @@ void sbObjectToSoftbody(Object *ob)
|
||||
}
|
||||
|
||||
if(ob->soft) ob->soft->ctime= bsystem_time(ob, NULL, (float)G.scene->r.cfra, 0.0);
|
||||
ob->softflag &= ~OB_SB_REDO;
|
||||
}
|
||||
|
||||
/* reset all motion */
|
||||
@@ -904,10 +910,11 @@ void sbObjectStep(Object *ob, float framenr)
|
||||
float ctime, forcetime;
|
||||
float err;
|
||||
|
||||
/* just to be nice we allow full init */
|
||||
if(ob->soft==NULL) sbObjectToSoftbody(ob);
|
||||
/* this is after reading new file, or acceptable as signal to refresh */
|
||||
else if(ob->soft->totpoint==0) sbObjectToSoftbody(ob);
|
||||
/* 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->totpoint==0) ) // after reading new file, or acceptable as signal to refresh
|
||||
sbObjectToSoftbody(ob);
|
||||
|
||||
sb= ob->soft;
|
||||
|
||||
|
||||
@@ -419,7 +419,7 @@ extern Object workob;
|
||||
#define OB_SB_EDGES 4
|
||||
#define OB_SB_QUADS 8
|
||||
#define OB_SB_POSTDEF 16
|
||||
|
||||
#define OB_SB_REDO 32
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -59,10 +59,11 @@
|
||||
#include "DNA_view3d_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_displist.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "BIF_graphics.h"
|
||||
#include "BIF_interface.h"
|
||||
@@ -930,6 +931,8 @@ void weight_paint(void)
|
||||
}
|
||||
|
||||
makeDispList(ob);
|
||||
// this flag is event for softbody to refresh weightpaint values
|
||||
if(ob->soft) ob->softflag |= OB_SB_REDO;
|
||||
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user