New! When weight-painting a Mesh, and select a Bone, you can use transform

options on the Bone (G, R, S). The manipulator doesn't show btw.
Is usful to get immediate feedback on how painted weights behave with Bones.

Martin; I had to change the T_POSE behaviour in code a bit... it now
stores in TransInfo the actual posed armature being transformed. Maybe,
some day, we'll get mixed posechannel/object transform? Not much required
at the moment though. :)
This commit is contained in:
Ton Roosendaal
2005-08-16 10:17:02 +00:00
parent f1609dde11
commit b45ecb43ef
6 changed files with 72 additions and 41 deletions

View File

@@ -40,6 +40,7 @@
struct TransInfo;
struct TransData;
struct NumInput;
struct Object;
typedef struct NumInput {
short idx;
@@ -156,6 +157,8 @@ typedef struct TransInfo {
char *undostr; /* if set, uses this string for undo */
float spacemtx[3][3]; /* orientation matrix of the current space */
char spacename[32]; /* name of the current space */
struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */
} TransInfo;
@@ -264,7 +267,7 @@ int calc_manipulator_stats(struct ScrArea *sa);
void createTransData(TransInfo *t);
void sort_trans_data_dist(TransInfo *t);
void add_tdi_poin(float *poin, float *old, float delta);
void special_aftertrans_update(short canceled);
void special_aftertrans_update(TransInfo *t);
/*********************** Constraints *****************************/

View File

@@ -2989,11 +2989,11 @@ static void editing_panel_mesh_paint(void)
if(uiNewPanel(curarea, block, "Paint", "Editing", 640, 0, 318, 204)==0) return;
if(G.f & ( G_WEIGHTPAINT))
{
if(G.f & G_WEIGHTPAINT) {
Object *ob;
ob= OBACT;
if(ob==NULL) return;
if(ob==NULL) return;
uiBlockBeginAlign(block);
uiDefButF(block, NUMSLI, REDRAWVIEW3D, "Weight:",2010,160,400,19, &editbutvweight, 0, 1, 10, 0, "Sets the current vertex group's bone deformation strength");
@@ -3012,9 +3012,9 @@ static void editing_panel_mesh_paint(void)
uiDefButF(block, NUMSLI, 0, "Size ", 2010,80,400,19, &Gvp.size, 2.0, 64.0, 0, 0, "The size of the brush");
uiBlockEndAlign(block);
if(ob){
uiBlockBeginAlign(block);
uiDefButBitC(block, TOG, OB_DRAWWIRE, REDRAWVIEW3D, "Wire", 2010,40,194,29, &ob->dtx, 0, 0, 0, 0, "Displays the active object's wireframe in shaded drawing modes");
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
uiDefButBitC(block, TOG, OB_DRAWWIRE, REDRAWVIEW3D, "Wire", 2010,40,194,29, &ob->dtx, 0, 0, 0, 0, "Displays the active object's wireframe in shaded drawing modes");
uiBlockEndAlign(block);
}
}
else{

View File

@@ -1266,10 +1266,14 @@ void mouse_select(void)
}
if(has_bones && basact) {
if( do_pose_selectbuffer(basact, buffer, hits) ) { // bone found
if( do_pose_selectbuffer(basact, buffer, hits) ) { // then bone is found
/* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */
if(G.f & G_WEIGHTPAINT) {
/* we make the armature selected */
basact->flag|= SELECT;
basact->object->flag= basact->flag;
/* prevent activating */
basact= NULL;
}
}

View File

@@ -100,16 +100,21 @@ float MatSpace[3][3];
/* bad frontbuffer call... because it is used in transform after force_draw() */
static void helpline(float *vec, int local)
static void helpline(TransInfo *t, float *vec)
{
float vecrot[3], cent[2];
short mval[2];
VECCOPY(vecrot, vec);
if(local) {
Object *ob= OBACT;
if(t->flag & T_EDIT) {
Object *ob=G.obedit;
if(ob) Mat4MulVecfl(ob->obmat, vecrot);
}
else if(t->flag & T_POSE) {
Object *ob=t->poseobj;
if(ob) Mat4MulVecfl(ob->obmat, vecrot);
}
getmouseco_areawin(mval);
project_float(vecrot, cent); // no overflow in extreme cases
if(cent[0]!=3200.0f) {
@@ -616,11 +621,11 @@ void Transform()
}
Trans.undostr= NULL;
/* free data, reset vars */
/* free data */
postTrans(&Trans);
/* aftertrans does insert ipos and action channels, and clears base flags */
special_aftertrans_update((short)(Trans.state == TRANS_CANCEL));
/* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
special_aftertrans_update(&Trans);
/* send events out for redraws */
allqueue(REDRAWVIEW3D, 0);
@@ -774,7 +779,7 @@ void ManipulatorTransform()
postTrans(&Trans);
/* aftertrans does insert ipos and action channels, and clears base flags */
special_aftertrans_update((short)(Trans.state == TRANS_CANCEL));
special_aftertrans_update(&Trans);
/* send events out for redraws */
allqueue(REDRAWVIEW3D, 0);
@@ -914,7 +919,7 @@ int Warp(TransInfo *t, short mval[2])
force_draw(0);
helpline(gcursor, t->flag & (T_EDIT|T_POSE));
helpline(t, gcursor);
return 1;
}
@@ -998,7 +1003,7 @@ int Shear(TransInfo *t, short mval[2])
force_draw(0);
helpline (t->center, t->flag & (T_EDIT|T_POSE));
helpline (t, t->center);
return 1;
}
@@ -1250,7 +1255,7 @@ int Resize(TransInfo *t, short mval[2])
force_draw(0);
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center, t->flag & (T_EDIT|T_POSE));
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
return 1;
}
@@ -1344,7 +1349,7 @@ int ToSphere(TransInfo *t, short mval[2])
force_draw(0);
helpline (t->center, t->flag & (T_EDIT|T_POSE));
helpline (t, t->center);
return 1;
}
@@ -1582,7 +1587,7 @@ int Rotation(TransInfo *t, short mval[2])
force_draw(0);
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center, t->flag & (T_EDIT|T_POSE));
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
return 1;
}
@@ -1684,7 +1689,7 @@ int Trackball(TransInfo *t, short mval[2])
force_draw(0);
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center, t->flag & (T_EDIT|T_POSE));
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
return 1;
}
@@ -1961,7 +1966,7 @@ int Tilt(TransInfo *t, short mval[2])
force_draw(0);
helpline (t->center, t->flag & (T_EDIT|T_POSE));
helpline (t, t->center);
return 1;
}
@@ -2133,7 +2138,7 @@ int Crease(TransInfo *t, short mval[2])
force_draw(0);
helpline (t->center, t->flag & (T_EDIT|T_POSE));
helpline (t, t->center);
return 1;
}
@@ -2331,7 +2336,7 @@ int BoneSize(TransInfo *t, short mval[2])
force_draw(0);
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center, t->flag & (T_EDIT|T_POSE));
if(!(t->flag & T_USES_MANIPULATOR)) helpline (t, t->center);
return 1;
}

View File

@@ -454,9 +454,8 @@ static int add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tra
}
/* only called with pose mode active object now */
static void createTransPose(TransInfo *t)
static void createTransPose(Object *ob, TransInfo *t)
{
Object *ob= OBACT;
bArmature *arm;
bPoseChannel *pchan;
TransData *td;
@@ -482,6 +481,9 @@ static void createTransPose(TransInfo *t)
}
if(t->total==0) return;
t->flag |= T_POSE;
t->poseobj= ob; // we also allow non-active objects to be transformed, in weightpaint
/* init trans data */
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransPoseBone");
tdx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "TransPoseBoneExt");
@@ -1353,19 +1355,24 @@ static void clear_trans_object_base_flags(void)
}
/* inserting keys, refresh ipo-keys, softbody, redraw events... (ton) */
void special_aftertrans_update(short cancelled)
/* note; transdata has been freed already! */
void special_aftertrans_update(TransInfo *t)
{
Object *ob= OBACT;
Object *ob;
Base *base;
int redrawipo=0;
int cancelled= (t->state == TRANS_CANCEL);
if(G.obedit); // nothing
else if (ob && (ob->flag & OB_POSEMODE)) {
bArmature *arm= ob->data;
else if( (t->flag & T_POSE) && t->poseobj) {
bArmature *arm;
bAction *act;
bPose *pose;
bPoseChannel *pchan;
ob= t->poseobj;
arm= ob->data;
if(cancelled) /* if cancelled we do the update always */
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
else if(G.flags & G_RECORDKEYS) {
@@ -1636,8 +1643,21 @@ void createTransData(TransInfo *t)
}
}
else if (ob && (ob->flag & OB_POSEMODE)) {
t->flag |= T_POSE;
createTransPose(t);
createTransPose(OBACT, t);
}
else if (G.f & G_WEIGHTPAINT) {
/* exception, we look for the one selected armature */
Base *base;
for(base=FIRSTBASE; base; base= base->next) {
if(TESTBASELIB(base)) {
if(base->object->type==OB_ARMATURE)
if(base->object->flag & OB_POSEMODE)
break;
}
}
if(base) {
createTransPose(base->object, t);
}
}
else {
createTransObject(t);

View File

@@ -142,7 +142,6 @@ static void transform_armature_mirror_update(void)
/* called for objects updating while transform acts, once per redraw */
void recalcData(TransInfo *t)
{
Object *ob= OBACT;
if (G.obedit) {
if (G.obedit->type == OB_MESH) {
@@ -191,7 +190,8 @@ void recalcData(TransInfo *t)
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); /* sets recalc flags */
}
}
else if(ob && (ob->flag & OB_POSEMODE)) {
else if( (t->flag & T_POSE) && t->poseobj) {
Object *ob= t->poseobj;
bArmature *arm= ob->data;
/* old optimize trick... this enforces to bypass the depgraph */
@@ -302,10 +302,9 @@ void drawLine(float *center, float *dir, char axis, short options)
void initTrans (TransInfo *t)
{
Object *ob= OBACT;
/* moving: is shown in drawobject() (transform color) */
if(G.obedit || (ob && (ob->flag & OB_POSEMODE)) ) G.moving= G_TRANSFORM_EDIT;
if(G.obedit || (t->flag & T_POSE) ) G.moving= G_TRANSFORM_EDIT;
else G.moving= G_TRANSFORM_OBJ;
t->data = NULL;
@@ -497,7 +496,7 @@ void calculateCenterCursor(TransInfo *t)
VECCOPY(t->center, cursor);
if(t->flag & (T_EDIT|T_POSE)) {
Object *ob= G.obedit?G.obedit:OBACT;
Object *ob= G.obedit?G.obedit:t->poseobj;
float mat[3][3], imat[3][3];
float vec[3];
@@ -535,7 +534,7 @@ void calculateCenterMedian(TransInfo *t)
VECCOPY(t->center, partial);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= G.obedit?G.obedit:OBACT;
Object *ob= G.obedit?G.obedit:t->poseobj;
float vec[3];
VECCOPY(vec, t->center);
@@ -574,7 +573,7 @@ void calculateCenterBound(TransInfo *t)
VecMulf(t->center, 0.5);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= G.obedit?G.obedit:OBACT;
Object *ob= G.obedit?G.obedit:t->poseobj;
float vec[3];
VECCOPY(vec, t->center);
@@ -618,7 +617,7 @@ void calculateCenter(TransInfo *t)
/* setting constraint center */
VECCOPY(t->con.center, t->center);
if(t->flag & (T_EDIT|T_POSE)) {
Object *ob= G.obedit?G.obedit:OBACT;
Object *ob= G.obedit?G.obedit:t->poseobj;
Mat4MulVecfl(ob->obmat, t->con.center);
}