Cleaning up manipulator code a bit

Made transform confirm or cancel on mouse up. More inline with button clicking and better for tablets.

Add operator params to make sure Rip and Extrude turn off PET and Mirror correctly.

Note: sorry for all the whitespace changes, I need to reconfigure this editor not to do autocleanup.
This commit is contained in:
Martin Poirier 2009-07-12 02:01:13 +00:00
parent 42469ba1e5
commit 8b9bb47a3f
8 changed files with 2657 additions and 2838 deletions

@ -1,5 +1,5 @@
/**
* $Id: ED_transform.h 21450 2009-07-09 02:45:48Z theeth $
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@ -119,12 +119,16 @@ struct EnumPropertyItem *BIF_enumTransformOrientation(struct bContext *C);
char * BIF_menustringTransformOrientation(const struct bContext *C, char *title); /* the returned value was allocated and needs to be freed after use */
int BIF_countTransformOrientation(const struct bContext *C);
void BIF_getPropCenter(float *center);
void BIF_TransformSetUndo(char *str);
void BIF_selectOrientation(void);
/* to be able to add operator properties to other operators */
void Properties_Proportional(struct wmOperatorType *ot);
void Properties_Snapping(struct wmOperatorType *ot, short align);
void Properties_Constraints(struct wmOperatorType *ot);
/* view3d manipulators */
void initManipulator(int mode);
void ManipulatorTransform();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -71,7 +71,7 @@ typedef struct NumInput {
/*
The ctrl value has different meaning:
0 : No value has been typed
otherwise, |value| - 1 is where the cursor is located after the period
Positive : number is positive
Negative : number is negative
@ -100,7 +100,7 @@ typedef struct TransCon {
float mtx[3][3]; /* Matrix of the Constraint space */
float imtx[3][3]; /* Inverse Matrix of the Constraint space */
float pmtx[3][3]; /* Projection Constraint Matrix (same as imtx with some axis == 0) */
float center[3]; /* transformation center to define where to draw the view widget
float center[3]; /* transformation center to define where to draw the view widget
ALWAYS in global space. Unlike the transformation center */
short imval[2]; /* initial mouse value for visual calculation */
/* the one in TransInfo is not garanty to stay the same (Rotates change it) */
@ -138,7 +138,7 @@ typedef struct TransDataExtension {
float iquat[4]; /* Initial rotation quaternion */
float *size; /* Size of the data to transform (Faculative) */
float isize[3]; /* Initial size */
float obmat[4][4]; /* Object matrix */
float obmat[4][4]; /* Object matrix */
} TransDataExtension;
typedef struct TransData2D {
@ -158,7 +158,7 @@ typedef struct TransDataSeq {
int flag; /* a copy of seq->flag that may be modified for nested strips */
short start_offset; /* use this so we can have transform data at the strips start, but apply correctly to the start frame */
short sel_flag; /* one of SELECT, SEQ_LEFTSEL and SEQ_RIGHTSEL */
} TransDataSeq;
/* for NLA transform (stored in td->extra pointer) */
@ -200,9 +200,9 @@ typedef struct TransData {
typedef struct MouseInput {
void (*apply)(struct TransInfo *, struct MouseInput *, short [2], float [3]);
short imval[2]; /* initial mouse position */
char precision;
char precision;
short precision_mval[2]; /* mouse position when precision key was pressed */
int center[2];
float factor;
@ -239,7 +239,7 @@ typedef struct TransInfo {
short idx_max; /* maximum index on the input vector */
float snap[3]; /* Snapping Gears */
char frame_side; /* Mouse side of the cfra, 'L', 'R' or 'B' */
float viewmat[4][4]; /* copy from G.vd, prevents feedback, */
float viewinv[4][4]; /* and to make sure we don't have to */
float persmat[4][4]; /* access G.vd from other space types */
@ -248,16 +248,16 @@ typedef struct TransInfo {
short around;
char spacetype; /* spacetype where transforming is */
char helpline; /* helpline modes (not to be confused with hotline) */
float vec[3]; /* translation, to show for widget */
float mat[3][3]; /* rot/rescale, to show for widget */
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 */
void *customData; /* Per Transform custom data */
/*************** NEW STUFF *********************/
@ -303,7 +303,7 @@ typedef struct TransInfo {
#define T_POSE (1 << 2)
#define T_TEXTURE (1 << 3)
#define T_CAMERA (1 << 4)
// trans on points, having no rotation/scale
// trans on points, having no rotation/scale
#define T_POINTS (1 << 6)
// for manipulator exceptions, like scaling using center point, drawing help lines
#define T_USES_MANIPULATOR (1 << 7)
@ -319,7 +319,7 @@ typedef struct TransInfo {
#define T_V3D_ALIGN (1 << 14)
/* for 2d views like uv or ipo */
#define T_2D_EDIT (1 << 15)
#define T_2D_EDIT (1 << 15)
#define T_CLIP_UV (1 << 16)
#define T_FREE_CUSTOMDATA (1 << 17)
@ -507,6 +507,8 @@ void special_aftertrans_update(TransInfo *t);
void transform_autoik_update(TransInfo *t, short mode);
int count_set_pose_transflags(int *out_mode, short around, struct Object *ob);
/* auto-keying stuff used by special_aftertrans_update */
short autokeyframe_cfra_can_key(struct Scene *scene, struct Object *ob);
void autokeyframe_ob_cb_func(struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode);
@ -607,8 +609,6 @@ void calculatePropRatio(TransInfo *t);
void getViewVector(TransInfo *t, float coord[3], float vec[3]);
TransInfo * BIF_GetTransInfo(void);
/*********************** NumInput ********************************/
void initNumInput(NumInput *n);

@ -183,7 +183,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
VECCOPY(vec, t->auto_values);
constraintAutoValues(t, vec);
}
if (t->con.mode & CON_AXIS0) {
pvec[i++] = vec[0];
}
@ -199,10 +199,10 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3]) {
float norm[3], vec[3], factor;
if(in[0]==0.0f && in[1]==0.0f && in[2]==0.0f)
return;
/* For when view is parallel to constraint... will cause NaNs otherwise
So we take vertical motion in 3D space and apply it to the
constraint axis. Nice for camera grab + MMB */
@ -212,30 +212,30 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
/* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */
if(factor<0.0f) factor*= -factor;
else factor*= factor;
VECCOPY(out, axis);
Normalize(out);
VecMulf(out, -factor); /* -factor makes move down going backwards */
}
else {
float cb[3], ab[3];
VECCOPY(out, axis);
/* Get view vector on axis to define a plane */
VecAddf(vec, t->con.center, in);
getViewVector(t, vec, norm);
Crossf(vec, norm, axis);
/* Project input vector on the plane passing on axis */
Projf(vec, in, vec);
VecSubf(vec, in, vec);
/* intersect the two lines: axis and norm */
Crossf(cb, vec, norm);
Crossf(ab, axis, norm);
VecMulf(out, Inpf(cb, ab) / Inpf(ab, ab));
}
}
@ -262,7 +262,7 @@ static void planeProjection(TransInfo *t, float in[3], float out[3]) {
/*
* Generic callback for constant spacial constraints applied to linear motion
*
*
* The IN vector in projected into the constrained space and then further
* projected along the view vector.
* (in perspective mode, the view vector is relative to the position on screen)
@ -274,7 +274,7 @@ static void applyAxisConstraintVec(TransInfo *t, TransData *td, float in[3], flo
VECCOPY(out, in);
if (!td && t->con.mode & CON_APPLY) {
Mat3MulVecfl(t->con.pmtx, out);
// With snap, a projection is alright, no need to correct for view alignment
if ((t->tsnap.status & SNAP_ON) == 0) {
if (getConstraintSpaceDimension(t) == 2) {
@ -284,7 +284,7 @@ static void applyAxisConstraintVec(TransInfo *t, TransData *td, float in[3], flo
}
else if (getConstraintSpaceDimension(t) == 1) {
float c[3];
if (t->con.mode & CON_AXIS0) {
VECCOPY(c, t->con.mtx[0]);
}
@ -303,7 +303,7 @@ static void applyAxisConstraintVec(TransInfo *t, TransData *td, float in[3], flo
/*
* Generic callback for object based spacial constraints applied to linear motion
*
*
* At first, the following is applied to the first data in the array
* The IN vector in projected into the constrained space and then further
* projected along the view vector.
@ -360,7 +360,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], f
/*
* Generic callback for constant spacial constraints applied to resize motion
*
*
*
*/
@ -386,7 +386,7 @@ static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3
/*
* Callback for object based spacial constraints applied to resize motion
*
*
*
*/
@ -415,7 +415,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3]
/*
* Generic callback for constant spacial constraints applied to rotations
*
*
* The rotation axis is copied into VEC.
*
* In the case of single axis constraints, the rotation axis is directly the one constrained to.
@ -457,7 +457,7 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl
/*
* Callback for object based spacial constraints applied to rotations
*
*
* The rotation axis is copied into VEC.
*
* In the case of single axis constraints, the rotation axis is directly the one constrained to.
@ -473,7 +473,7 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3],
{
if (t->con.mode & CON_APPLY) {
int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
/* on setup call, use first object */
if (td == NULL) {
td= t->data;
@ -585,128 +585,6 @@ void setUserConstraint(TransInfo *t, int mode, const char ftext[]) {
t->con.mode |= CON_USER;
}
/*--------------------- EXTERNAL SETUP CALLS ------------------*/
void BIF_setLocalLockConstraint(char axis, char *text) {
TransInfo *t = BIF_GetTransInfo();
if (t->total == 0) {
return;
}
switch (axis) {
case 'x':
setLocalConstraint(t, (CON_AXIS1|CON_AXIS2), text);
break;
case 'y':
setLocalConstraint(t, (CON_AXIS0|CON_AXIS2), text);
break;
case 'z':
setLocalConstraint(t, (CON_AXIS0|CON_AXIS1), text);
break;
}
}
void BIF_setLocalAxisConstraint(char axis, char *text) {
TransInfo *t = BIF_GetTransInfo();
if (t->total == 0) {
return;
}
switch (axis) {
case 'X':
setLocalConstraint(t, CON_AXIS0, text);
break;
case 'Y':
setLocalConstraint(t, CON_AXIS1, text);
break;
case 'Z':
setLocalConstraint(t, CON_AXIS2, text);
break;
}
}
/* text is optional, for header print */
void BIF_setSingleAxisConstraint(float vec[3], char *text) {
TransInfo *t = BIF_GetTransInfo();
float space[3][3], v[3];
if (t->total == 0) {
return;
}
VECCOPY(space[0], vec);
v[0] = vec[2];
v[1] = vec[0];
v[2] = vec[1];
Crossf(space[1], vec, v);
Crossf(space[2], vec, space[1]);
Mat3Ortho(space);
Mat3CpyMat3(t->con.mtx, space);
t->con.mode = CON_AXIS0;
getConstraintMatrix(t);
startConstraint(t);
/* start copying with an offset of 1, to reserve a spot for the SPACE char */
if(text)
{
strncpy(t->con.text+1, text, 48); /* 50 in struct */
}
else
{
t->con.text[1] = '\0'; /* No text */
}
t->con.drawExtra = NULL;
t->con.applyVec = applyAxisConstraintVec;
t->con.applySize = applyAxisConstraintSize;
t->con.applyRot = applyAxisConstraintRot;
t->redraw = 1;
}
void BIF_setDualAxisConstraint(float vec1[3], float vec2[3], char *text) {
TransInfo *t = BIF_GetTransInfo();
float space[3][3];
if (t->total == 0) {
return;
}
VECCOPY(space[0], vec1);
VECCOPY(space[1], vec2);
Crossf(space[2], space[0], space[1]);
Mat3Ortho(space);
Mat3CpyMat3(t->con.mtx, space);
t->con.mode = CON_AXIS0|CON_AXIS1;
getConstraintMatrix(t);
startConstraint(t);
/* start copying with an offset of 1, to reserve a spot for the SPACE char */
if(text)
{
strncpy(t->con.text+1, text, 48); /* 50 in struct */
}
else
{
t->con.text[1] = '\0'; /* No text */
}
t->con.drawExtra = NULL;
t->con.applyVec = applyAxisConstraintVec;
t->con.applySize = applyAxisConstraintSize;
t->con.applyRot = applyAxisConstraintRot;
t->redraw = 1;
}
/*----------------- DRAWING CONSTRAINTS -------------------*/
void drawConstraint(const struct bContext *C, TransInfo *t)
@ -721,10 +599,10 @@ void drawConstraint(const struct bContext *C, TransInfo *t)
return;
if (t->flag & T_NO_CONSTRAINT)
return;
/* nasty exception for Z constraint in camera view */
// TRANSFORM_FIX_ME
// if((t->flag & T_OBJECT) && G.vd->camera==OBACT && G.vd->persp==V3D_CAMOB)
// if((t->flag & T_OBJECT) && G.vd->camera==OBACT && G.vd->persp==V3D_CAMOB)
// return;
if (tc->drawExtra) {
@ -742,17 +620,17 @@ void drawConstraint(const struct bContext *C, TransInfo *t)
drawLine(t, tc->center, tc->mtx[2], 'z', 0);
glColor3ubv((GLubyte *)col2);
glDisable(GL_DEPTH_TEST);
setlinestyle(1);
glBegin(GL_LINE_STRIP);
glVertex3fv(tc->center);
glVertex3fv(vec);
glBegin(GL_LINE_STRIP);
glVertex3fv(tc->center);
glVertex3fv(vec);
glEnd();
setlinestyle(0);
// TRANSFORM_FIX_ME
//if(G.vd->zbuf)
glEnable(GL_DEPTH_TEST);
glEnable(GL_DEPTH_TEST);
}
if (tc->mode & CON_AXIS0) {
@ -775,7 +653,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
float tmat[4][4], imat[4][4];
UI_ThemeColor(TH_GRID);
if(t->spacetype == SPACE_VIEW3D && rv3d != NULL)
{
Mat4CpyMat4(tmat, rv3d->viewmat);
@ -804,22 +682,11 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
set_inverted_drawing(1);
drawcircball(GL_LINE_LOOP, t->center, t->prop_size, imat);
set_inverted_drawing(0);
glPopMatrix();
}
}
void BIF_getPropCenter(float *center)
{
TransInfo *t = BIF_GetTransInfo();
if (t && t->flag & T_PROP_EDIT) {
VECCOPY(center, t->center);
}
else
center[0] = center[1] = center[2] = 0.0f;
}
static void drawObjectConstraint(TransInfo *t) {
int i;
TransData * td = t->data;
@ -839,7 +706,7 @@ static void drawObjectConstraint(TransInfo *t) {
if (t->con.mode & CON_AXIS2) {
drawLine(t, td->ob->obmat[3], td->axismtx[2], 'z', DRAWLIGHT);
}
td++;
for(i=1;i<t->total;i++,td++) {
@ -954,12 +821,12 @@ static void setNearestAxis3d(TransInfo *t)
float mvec[3], axis[3], proj[3];
float len[3];
int i, icoord[2];
/* calculate mouse movement */
mvec[0] = (float)(t->mval[0] - t->con.imval[0]);
mvec[1] = (float)(t->mval[1] - t->con.imval[1]);
mvec[2] = 0.0f;
/* we need to correct axis length for the current zoomlevel of view,
this to prevent projected values to be clipped behind the camera
and to overflow the short integers.
@ -972,12 +839,12 @@ static void setNearestAxis3d(TransInfo *t)
for (i = 0; i<3; i++) {
VECCOPY(axis, t->con.mtx[i]);
VecMulf(axis, zfac);
/* now we can project to get window coordinate */
VecAddf(axis, axis, t->con.center);
projectIntView(t, axis, icoord);
axis[0] = (float)(icoord[0] - t->center2d[0]);
axis[1] = (float)(icoord[1] - t->center2d[1]);
axis[2] = 0.0f;
@ -1034,13 +901,13 @@ void setNearestAxis(TransInfo *t)
/* constraint setting - depends on spacetype */
if (t->spacetype == SPACE_VIEW3D) {
/* 3d-view */
setNearestAxis3d(t);
setNearestAxis3d(t);
}
else {
/* assume that this means a 2D-Editor */
setNearestAxis2d(t);
}
getConstraintMatrix(t);
}
@ -1083,7 +950,7 @@ int isLockConstraint(TransInfo *t) {
/*
* Returns the dimension of the constraint space.
*
*
* For that reason, the flags always needs to be set to properly evaluate here,
* even if they aren't actually used in the callback function. (Which could happen
* for weird constraints not yet designed. Along a path for example.)
@ -1107,7 +974,7 @@ int getConstraintSpaceDimension(TransInfo *t)
Someone willing to do it criptically could do the following instead:
return t->con & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
Based on the assumptions that the axis flags are one after the other and start at 1
*/
}

File diff suppressed because it is too large Load Diff

@ -154,8 +154,8 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
for (; md; md=md->next) {
if (md->type==eModifierType_Mirror) {
MirrorModifierData *mmd = (MirrorModifierData*) md;
MirrorModifierData *mmd = (MirrorModifierData*) md;
if(mmd->flag & MOD_MIR_CLIPPING) {
axis = 0;
if(mmd->flag & MOD_MIR_AXIS_X) {
@ -174,7 +174,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
float mtx[4][4], imtx[4][4];
int i;
TransData *td = t->data;
if (mmd->mirror_ob) {
float obinv[4][4];
@ -191,10 +191,10 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
break;
if (td->loc==NULL)
break;
if (td->flag & TD_SKIP)
continue;
VecCopyf(loc, td->loc);
VecCopyf(iloc, td->iloc);
@ -205,22 +205,22 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
clip = 0;
if(axis & 1) {
if(fabs(iloc[0])<=tolerance[0] ||
if(fabs(iloc[0])<=tolerance[0] ||
loc[0]*iloc[0]<0.0f) {
loc[0]= 0.0f;
clip = 1;
}
}
if(axis & 2) {
if(fabs(iloc[1])<=tolerance[1] ||
if(fabs(iloc[1])<=tolerance[1] ||
loc[1]*iloc[1]<0.0f) {
loc[1]= 0.0f;
clip = 1;
}
}
if(axis & 4) {
if(fabs(iloc[2])<=tolerance[2] ||
if(fabs(iloc[2])<=tolerance[2] ||
loc[2]*iloc[2]<0.0f) {
loc[2]= 0.0f;
clip = 1;
@ -246,7 +246,7 @@ static void editmesh_apply_to_mirror(TransInfo *t)
TransData *td = t->data;
EditVert *eve;
int i;
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@ -254,14 +254,14 @@ static void editmesh_apply_to_mirror(TransInfo *t)
break;
if (td->flag & TD_SKIP)
continue;
eve = td->extra;
if(eve) {
eve->co[0]= -td->loc[0];
eve->co[1]= td->loc[1];
eve->co[2]= td->loc[2];
}
}
}
}
}
/* called for updating while transform acts, once per redraw */
@ -269,7 +269,7 @@ void recalcData(TransInfo *t)
{
Scene *scene = t->scene;
Base *base;
if (t->obedit) {
}
else if(G.f & G_PARTICLEEDIT) {
@ -284,56 +284,56 @@ void recalcData(TransInfo *t)
else if (t->spacetype == SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
Scene *scene;
ListBase anim_data = {NULL, NULL};
bAnimContext ac;
int filter;
bAnimListElem *ale;
int dosort = 0;
/* initialise relevant anim-context 'context' data from TransInfo data */
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
memset(&ac, 0, sizeof(bAnimContext));
scene= ac.scene= t->scene;
ac.obact= OBACT;
ac.sa= t->sa;
ac.ar= t->ar;
ac.spacetype= (t->sa)? t->sa->spacetype : 0;
ac.regiontype= (t->ar)? t->ar->regiontype : 0;
ANIM_animdata_context_getdata(&ac);
/* do the flush first */
flushTransGraphData(t);
/* get curves to check if a re-sort is needed */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* now test if there is a need to re-sort */
for (ale= anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
/* watch it: if the time is wrong: do not correct handles yet */
if (test_time_fcurve(fcu))
dosort++;
else
calchandles_fcurve(fcu);
}
/* do resort and other updates? */
if (dosort) remake_graph_transdata(t, &anim_data);
//if (sipo->showkey) update_ipokey_val();
/* now free temp channels */
BLI_freelistN(&anim_data);
/* update realtime - not working? */
if (sipo->lock) {
}
}
else if (t->spacetype == SPACE_NLA) {
@ -342,8 +342,8 @@ void recalcData(TransInfo *t)
Scene *scene= t->scene;
double secf= FPS;
int i;
/* for each strip we've got, perform some additional validation of the values that got set before
/* for each strip we've got, perform some additional validation of the values that got set before
* using RNA to set the value (which does some special operations when setting these values to make
* sure that everything works ok)
*/
@ -352,43 +352,43 @@ void recalcData(TransInfo *t)
PointerRNA strip_ptr;
short pExceeded, nExceeded, iter;
int delta_y1, delta_y2;
/* if this tdn has no handles, that means it is just a dummy that should be skipped */
if (tdn->handle == 0)
continue;
/* if cancelling transform, just write the values without validating, then move on */
if (t->state == TRANS_CANCEL) {
/* clear the values by directly overwriting the originals, but also need to restore
/* clear the values by directly overwriting the originals, but also need to restore
* endpoints of neighboring transition-strips
*/
/* start */
strip->start= tdn->h1[0];
if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
strip->prev->end= tdn->h1[0];
/* end */
strip->end= tdn->h2[0];
if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION))
strip->next->start= tdn->h2[0];
/* flush transforms to child strips (since this should be a meta) */
BKE_nlameta_flush_transforms(strip);
/* restore to original track (if needed) */
if (tdn->oldTrack != tdn->nlt) {
/* just append to end of list for now, since strips get sorted in special_aftertrans_update() */
BLI_remlink(&tdn->nlt->strips, strip);
BLI_addtail(&tdn->oldTrack->strips, strip);
}
continue;
}
/* firstly, check if the proposed transform locations would overlap with any neighbouring strips
/* firstly, check if the proposed transform locations would overlap with any neighbouring strips
* (barring transitions) which are absolute barriers since they are not being moved
*
* this is done as a iterative procedure (done 5 times max for now)
@ -396,10 +396,10 @@ void recalcData(TransInfo *t)
for (iter=0; iter < 5; iter++) {
pExceeded= ((strip->prev) && (strip->prev->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h1[0] < strip->prev->end));
nExceeded= ((strip->next) && (strip->next->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h2[0] > strip->next->start));
if ((pExceeded && nExceeded) || (iter == 4) ) {
/* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise)
* - simply crop strip to fit within the bounds of the strips bounding it
/* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise)
* - simply crop strip to fit within the bounds of the strips bounding it
* - if there were no neighbours, clear the transforms (make it default to the strip's current values)
*/
if (strip->prev && strip->next) {
@ -414,21 +414,21 @@ void recalcData(TransInfo *t)
else if (nExceeded) {
/* move backwards */
float offset= tdn->h2[0] - strip->next->start;
tdn->h1[0] -= offset;
tdn->h2[0] -= offset;
}
else if (pExceeded) {
/* more forwards */
float offset= strip->prev->end - tdn->h1[0];
tdn->h1[0] += offset;
tdn->h2[0] += offset;
}
else /* all is fine and well */
break;
}
/* handle auto-snapping */
switch (snla->autosnap) {
case SACTSNAP_FRAME: /* snap to nearest frame/time */
@ -441,36 +441,36 @@ void recalcData(TransInfo *t)
tdn->h2[0]= (float)( floor(tdn->h2[0]+0.5f) );
}
break;
case SACTSNAP_MARKER: /* snap to nearest marker */
tdn->h1[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]);
tdn->h2[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h2[0]);
break;
}
/* use RNA to write the values... */
// TODO: do we need to write in 2 passes to make sure that no truncation goes on?
RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
RNA_float_set(&strip_ptr, "start_frame", tdn->h1[0]);
RNA_float_set(&strip_ptr, "end_frame", tdn->h2[0]);
/* flush transforms to child strips (since this should be a meta) */
BKE_nlameta_flush_transforms(strip);
/* now, check if we need to try and move track
/* now, check if we need to try and move track
* - we need to calculate both, as only one may have been altered by transform if only 1 handle moved
*/
delta_y1= ((int)tdn->h1[1] / NLACHANNEL_STEP - tdn->trackIndex);
delta_y2= ((int)tdn->h2[1] / NLACHANNEL_STEP - tdn->trackIndex);
if (delta_y1 || delta_y2) {
NlaTrack *track;
int delta = (delta_y2) ? delta_y2 : delta_y1;
int n;
/* move in the requested direction, checking at each layer if there's space for strip to pass through,
/* move in the requested direction, checking at each layer if there's space for strip to pass through,
* stopping on the last track available or that we're able to fit in
*/
if (delta > 0) {
@ -480,7 +480,7 @@ void recalcData(TransInfo *t)
/* move strip to this track */
BLI_remlink(&tdn->nlt->strips, strip);
BKE_nlatrack_add_strip(track, strip);
tdn->nlt= track;
tdn->trackIndex += (n + 1); /* + 1, since n==0 would mean that we didn't change track */
}
@ -491,14 +491,14 @@ void recalcData(TransInfo *t)
else {
/* make delta 'positive' before using it, since we now know to go backwards */
delta= -delta;
for (track=tdn->nlt->prev, n=0; (track) && (n < delta); track=track->prev, n++) {
/* check if space in this track for the strip */
if (BKE_nlatrack_has_space(track, strip->start, strip->end)) {
/* move strip to this track */
BLI_remlink(&tdn->nlt->strips, strip);
BKE_nlatrack_add_strip(track, strip);
tdn->nlt= track;
tdn->trackIndex -= (n - 1); /* - 1, since n==0 would mean that we didn't change track */
}
@ -513,9 +513,9 @@ void recalcData(TransInfo *t)
if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
Curve *cu= t->obedit->data;
Nurb *nu= cu->editnurb->first;
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
if (t->state == TRANS_CANCEL) {
while(nu) {
calchandlesNurb(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
@ -535,7 +535,7 @@ void recalcData(TransInfo *t)
else if(t->obedit->type==OB_LATTICE) {
Lattice *la= t->obedit->data;
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
if(la->editlatt->flag & LT_OUTSIDE) outside_lattice(la->editlatt);
}
else if (t->obedit->type == OB_MESH) {
@ -545,7 +545,7 @@ void recalcData(TransInfo *t)
flushTransUVs(t);
if(sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_re_solve();
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA);
} else {
EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh;
@ -560,9 +560,9 @@ void recalcData(TransInfo *t)
}
if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR))
editmesh_apply_to_mirror(t);
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
recalc_editnormals(em);
}
}
@ -572,10 +572,10 @@ void recalcData(TransInfo *t)
EditBone *ebo;
TransData *td = t->data;
int i;
/* Ensure all bones are correctly adjusted */
for (ebo = edbo->first; ebo; ebo = ebo->next){
if ((ebo->flag & BONE_CONNECTED) && ebo->parent){
/* If this bone has a parent tip that has been moved */
if (ebo->parent->flag & BONE_TIPSEL){
@ -588,7 +588,7 @@ void recalcData(TransInfo *t)
if(t->mode==TFM_BONE_ENVELOPE) ebo->parent->rad_tail= ebo->rad_head;
}
}
/* on extrude bones, oldlength==0.0f, so we scale radius of points */
ebo->length= VecLenf(ebo->head, ebo->tail);
if(ebo->oldlength==0.0f) {
@ -608,8 +608,8 @@ void recalcData(TransInfo *t)
ebo->oldlength= ebo->length;
}
}
if (t->mode != TFM_BONE_ROLL)
{
/* fix roll */
@ -619,10 +619,10 @@ void recalcData(TransInfo *t)
{
float vec[3], up_axis[3];
float qrot[4];
ebo = td->extra;
VECCOPY(up_axis, td->axismtx[2]);
if (t->mode != TFM_ROTATION)
{
VecSubf(vec, ebo->tail, ebo->head);
@ -634,15 +634,15 @@ void recalcData(TransInfo *t)
{
Mat3MulVecfl(t->mat, up_axis);
}
ebo->roll = ED_rollBoneToVector(ebo, up_axis);
}
}
}
if(arm->flag & ARM_MIRROR_EDIT)
if(arm->flag & ARM_MIRROR_EDIT)
transform_armature_mirror_update(t->obedit);
}
else
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
@ -650,7 +650,7 @@ void recalcData(TransInfo *t)
else if( (t->flag & T_POSE) && t->poseobj) {
Object *ob= t->poseobj;
bArmature *arm= ob->data;
/* if animtimer is running, and the object already has animation data,
* check if the auto-record feature means that we should record 'samples'
* (i.e. uneditable animation values)
@ -661,7 +661,7 @@ void recalcData(TransInfo *t)
short targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
autokeyframe_pose_cb_func(t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
}
/* old optimize trick... this enforces to bypass the depgraph */
if (!(arm->flag & ARM_DELAYDEFORM)) {
DAG_object_flush_update(scene, ob, OB_RECALC_DATA); /* sets recalc flags */
@ -672,13 +672,13 @@ void recalcData(TransInfo *t)
else {
for(base= FIRSTBASE; base; base= base->next) {
Object *ob= base->object;
/* this flag is from depgraph, was stored in initialize phase, handled in drawview.c */
if(base->flag & BA_HAS_RECALC_OB)
ob->recalc |= OB_RECALC_OB;
if(base->flag & BA_HAS_RECALC_DATA)
ob->recalc |= OB_RECALC_DATA;
/* if object/base is selected */
if ((base->flag & SELECT) || (ob->flag & SELECT)) {
/* if animtimer is running, and the object already has animation data,
@ -691,13 +691,13 @@ void recalcData(TransInfo *t)
autokeyframe_ob_cb_func(t->scene, (View3D *)t->view, ob, t->mode);
}
}
/* proxy exception */
if(ob->proxy)
ob->proxy->recalc |= ob->recalc;
if(ob->proxy_group)
group_tag_recalc(ob->proxy_group->dup_group);
}
}
}
/* update shaded drawmode while transform */
@ -709,22 +709,22 @@ void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
{
float v1[3], v2[3], v3[3];
char col[3], col2[3];
if (t->spacetype == SPACE_VIEW3D)
{
View3D *v3d = t->view;
glPushMatrix();
//if(t->obedit) glLoadMatrixf(t->obedit->obmat); // sets opengl viewing
VecCopyf(v3, dir);
VecMulf(v3, v3d->far);
VecSubf(v2, center, v3);
VecAddf(v1, center, v3);
if (options & DRAWLIGHT) {
col[0] = col[1] = col[2] = 220;
}
@ -733,13 +733,13 @@ void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
}
UI_make_axis_color(col, col2, axis);
glColor3ubv((GLubyte *)col2);
setlinestyle(0);
glBegin(GL_LINE_STRIP);
glVertex3fv(v1);
glVertex3fv(v2);
glBegin(GL_LINE_STRIP);
glVertex3fv(v1);
glVertex3fv(v2);
glEnd();
glPopMatrix();
}
}
@ -756,13 +756,13 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
ARegion *ar = CTX_wm_region(C);
ScrArea *sa = CTX_wm_area(C);
Object *obedit = CTX_data_edit_object(C);
/* moving: is shown in drawobject() (transform color) */
// TRANSFORM_FIX_ME
// TRANSFORM_FIX_ME
// if(obedit || (t->flag & T_POSE) ) G.moving= G_TRANSFORM_EDIT;
// else if(G.f & G_PARTICLEEDIT) G.moving= G_TRANSFORM_PARTICLE;
// else G.moving= G_TRANSFORM_OBJ;
t->scene = sce;
t->sa = sa;
t->ar = ar;
@ -775,14 +775,14 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->helpline = HLP_NONE;
t->flag = 0;
t->redraw = 1; /* redraw first time */
if (event)
{
t->imval[0] = event->x - t->ar->winrct.xmin;
t->imval[1] = event->y - t->ar->winrct.ymin;
t->event_type = event->type;
}
else
@ -790,7 +790,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->imval[0] = 0;
t->imval[1] = 0;
}
t->con.imval[0] = t->imval[0];
t->con.imval[1] = t->imval[1];
@ -807,21 +807,21 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->vec[0] =
t->vec[1] =
t->vec[2] = 0.0f;
t->center[0] =
t->center[1] =
t->center[2] = 0.0f;
Mat3One(t->mat);
t->spacetype = sa->spacetype;
if(t->spacetype == SPACE_VIEW3D)
{
View3D *v3d = sa->spacedata.first;
t->view = v3d;
t->animtimer= CTX_wm_screen(C)->animtimer;
if(v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;
t->around = v3d->around;
@ -850,7 +850,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
{
// XXX for now, get View2D from the active region
t->view = &ar->v2d;
t->around = V3D_CENTER;
}
@ -886,7 +886,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
{
if ((t->options & CTX_NO_PET) == 0 && (ts->proportional)) {
t->flag |= T_PROP_EDIT;
if(ts->proportional == 2)
t->flag |= T_PROP_CONNECTED; // yes i know, has to become define
}
@ -900,7 +900,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
{
t->prop_size = ts->proportional_size;
}
if (op && RNA_struct_find_property(op->ptr, "proportional_editing_falloff") && RNA_property_is_set(op->ptr, "proportional_editing_falloff"))
{
t->prop_mode = RNA_enum_get(op->ptr, "proportional_editing_falloff");
@ -919,12 +919,12 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
setTransformViewMatrices(t);
initNumInput(&t->num);
initNDofInput(&t->ndof);
return 1;
}
/* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */
void postTrans (TransInfo *t)
void postTrans (TransInfo *t)
{
TransData *td;
@ -932,7 +932,7 @@ void postTrans (TransInfo *t)
{
ED_region_draw_cb_exit(t->ar->type, t->draw_handle);
}
/* postTrans can be called when nothing is selected, so data is NULL already */
if (t->data) {
int a;
@ -940,7 +940,7 @@ void postTrans (TransInfo *t)
/* since ipokeys are optional on objects, we mallocced them per trans-data */
for(a=0, td= t->data; a<t->total; a++, td++) {
if(td->tdi) MEM_freeN(td->tdi);
if (td->flag & TD_BEZTRIPLE) MEM_freeN(td->hdata);
if (td->flag & TD_BEZTRIPLE) MEM_freeN(td->hdata);
}
MEM_freeN(t->data);
}
@ -965,7 +965,7 @@ void postTrans (TransInfo *t)
void applyTransObjects(TransInfo *t)
{
TransData *td;
for (td = t->data; td < t->data + t->total; td++) {
VECCOPY(td->iloc, td->loc);
if (td->ext->rot) {
@ -974,9 +974,9 @@ void applyTransObjects(TransInfo *t)
if (td->ext->size) {
VECCOPY(td->ext->isize, td->ext->size);
}
}
}
recalcData(t);
}
}
/* helper for below */
static void restore_ipokey(float *poin, float *old)
@ -1009,15 +1009,15 @@ static void restoreElement(TransData *td) {
}
}
}
if (td->flag & TD_BEZTRIPLE) {
*(td->hdata->h1) = td->hdata->ih1;
*(td->hdata->h2) = td->hdata->ih2;
}
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
restore_ipokey(tdi->locx, tdi->oldloc);
restore_ipokey(tdi->locy, tdi->oldloc+1);
restore_ipokey(tdi->locz, tdi->oldloc+2);
@ -1025,7 +1025,7 @@ static void restoreElement(TransData *td) {
restore_ipokey(tdi->rotx, tdi->oldrot);
restore_ipokey(tdi->roty, tdi->oldrot+1);
restore_ipokey(tdi->rotz, tdi->oldrot+2);
restore_ipokey(tdi->sizex, tdi->oldsize);
restore_ipokey(tdi->sizey, tdi->oldsize+1);
restore_ipokey(tdi->sizez, tdi->oldsize+2);
@ -1035,13 +1035,13 @@ static void restoreElement(TransData *td) {
void restoreTransObjects(TransInfo *t)
{
TransData *td;
for (td = t->data; td < t->data + t->total; td++) {
restoreElement(td);
}
Mat3One(t->mat);
recalcData(t);
}
@ -1050,7 +1050,7 @@ void calculateCenter2D(TransInfo *t)
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
float vec[3];
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
projectIntView(t, vec, t->center2d);
@ -1071,13 +1071,13 @@ void calculateCenterCursor(TransInfo *t)
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob = t->obedit?t->obedit:t->poseobj;
float mat[3][3], imat[3][3];
VecSubf(t->center, t->center, ob->obmat[3]);
Mat3CpyMat4(mat, ob->obmat);
Mat3Inv(imat, mat);
Mat3MulVecfl(imat, t->center);
}
calculateCenter2D(t);
}
@ -1085,13 +1085,13 @@ void calculateCenterCursor2D(TransInfo *t)
{
View2D *v2d= t->view;
float aspx=1.0, aspy=1.0;
if(t->spacetype==SPACE_IMAGE) /* only space supported right now but may change */
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
if (v2d) {
t->center[0] = v2d->cursor[0] * aspx;
t->center[1] = v2d->cursor[1] * aspy;
t->center[0] = v2d->cursor[0] * aspx;
t->center[1] = v2d->cursor[1] * aspy;
}
calculateCenter2D(t);
@ -1102,7 +1102,7 @@ void calculateCenterMedian(TransInfo *t)
float partial[3] = {0.0f, 0.0f, 0.0f};
int total = 0;
int i;
for(i = 0; i < t->total; i++) {
if (t->data[i].flag & TD_SELECTED) {
if (!(t->data[i].flag & TD_NOCENTER))
@ -1112,8 +1112,8 @@ void calculateCenterMedian(TransInfo *t)
}
}
else {
/*
All the selected elements are at the head of the array
/*
All the selected elements are at the head of the array
which means we can stop when it finds unselected data
*/
break;
@ -1138,8 +1138,8 @@ void calculateCenterBound(TransInfo *t)
MinMax3(min, max, t->data[i].center);
}
else {
/*
All the selected elements are at the head of the array
/*
All the selected elements are at the head of the array
which means we can stop when it finds unselected data
*/
break;
@ -1156,7 +1156,7 @@ void calculateCenterBound(TransInfo *t)
calculateCenter2D(t);
}
void calculateCenter(TransInfo *t)
void calculateCenter(TransInfo *t)
{
switch(t->around) {
case V3D_CENTER:
@ -1188,7 +1188,7 @@ void calculateCenter(TransInfo *t)
break;
} /* END EDIT MODE ACTIVE ELEMENT */
#endif
calculateCenterMedian(t);
if((t->flag & (T_EDIT|T_POSE))==0)
{
@ -1200,7 +1200,7 @@ void calculateCenter(TransInfo *t)
projectIntView(t, t->center, t->center2d);
}
}
}
}
@ -1220,21 +1220,21 @@ void calculateCenter(TransInfo *t)
View3D *v3d = t->view;
Scene *scene = t->scene;
RegionView3D *rv3d = t->ar->regiondata;
if(v3d->camera == OBACT && rv3d->persp==V3D_CAMOB)
{
float axis[3];
/* persinv is nasty, use viewinv instead, always right */
VECCOPY(axis, t->viewinv[2]);
Normalize(axis);
/* 6.0 = 6 grid units */
axis[0]= t->center[0]- 6.0f*axis[0];
axis[1]= t->center[1]- 6.0f*axis[1];
axis[2]= t->center[2]- 6.0f*axis[2];
projectIntView(t, axis, t->center2d);
/* rotate only needs correct 2d center, grab needs initgrabz() value */
if(t->mode==TFM_TRANSLATION)
{
@ -1243,7 +1243,7 @@ void calculateCenter(TransInfo *t)
}
}
}
}
}
if(t->spacetype==SPACE_VIEW3D)
{
@ -1251,14 +1251,14 @@ void calculateCenter(TransInfo *t)
if(t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
float vec[3];
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
initgrabz(t->ar->regiondata, vec[0], vec[1], vec[2]);
}
else {
initgrabz(t->ar->regiondata, t->center[0], t->center[1], t->center[2]);
}
}
}
}
@ -1268,18 +1268,18 @@ void calculatePropRatio(TransInfo *t)
int i;
float dist;
short connected = t->flag & T_PROP_CONNECTED;
if (t->flag & T_PROP_EDIT) {
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_SELECTED) {
td->factor = 1.0f;
}
else if ((connected &&
else if ((connected &&
(td->flag & TD_NOTCONNECTED || td->dist > t->prop_size))
||
(connected == 0 &&
td->rdist > t->prop_size)) {
/*
/*
The elements are sorted according to their dist member in the array,
that means we can stop when it finds one element outside of the propsize.
*/
@ -1291,7 +1291,7 @@ void calculatePropRatio(TransInfo *t)
/* Use rdist for falloff calculations, it is the real distance */
td->flag &= ~TD_NOACTION;
dist= (t->prop_size-td->rdist)/t->prop_size;
/*
* Clamp to positive numbers.
* Certain corner cases with connectivity and individual centers
@ -1299,7 +1299,7 @@ void calculatePropRatio(TransInfo *t)
*/
if (dist < 0.0f)
dist = 0.0f;
switch(t->prop_mode) {
case PROP_SHARP:
td->factor= dist*dist;
@ -1362,27 +1362,19 @@ void calculatePropRatio(TransInfo *t)
}
}
/* XXX only to make manipulators run now */
TransInfo *BIF_GetTransInfo()
{
static struct TransInfo trans;
memset(&trans, 0, sizeof(struct TransInfo));
return &trans;
}
float get_drawsize(ARegion *ar, float *co)
{
RegionView3D *rv3d= ar->regiondata;
float size, vec[3], len1, len2;
/* size calculus, depending ortho/persp settings, like initgrabz() */
size= rv3d->persmat[0][3]*co[0]+ rv3d->persmat[1][3]*co[1]+ rv3d->persmat[2][3]*co[2]+ rv3d->persmat[3][3];
VECCOPY(vec, rv3d->persinv[0]);
len1= Normalize(vec);
VECCOPY(vec, rv3d->persinv[1]);
len2= Normalize(vec);
size*= 0.01f*(len1>len2?len1:len2);
/* correct for window size to make widgets appear fixed size */

@ -174,37 +174,10 @@ static void stats_editbone(View3D *v3d, EditBone *ebo)
protectflag_to_drawflags(OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE, &v3d->twdrawflag);
}
/* only counts the parent selection, and tags transform flag */
/* bad call... should re-use method from transform_conversion once */
static void count_bone_select(TransInfo *t, bArmature *arm, ListBase *lb, int do_it)
{
Bone *bone;
int do_next;
for(bone= lb->first; bone; bone= bone->next) {
bone->flag &= ~BONE_TRANSFORM;
do_next= do_it;
if(do_it) {
if(bone->layer & arm->layer) {
if (bone->flag & BONE_SELECTED) {
/* We don't let connected children get "grabbed" */
if ( (t->mode!=TFM_TRANSLATION) || (bone->flag & BONE_CONNECTED)==0 ) {
bone->flag |= BONE_TRANSFORM;
t->total++;
do_next= 0; // no transform on children if one parent bone is selected
}
}
}
}
count_bone_select(t, arm, &bone->childbase, do_next);
}
}
/* centroid, boundbox, of selection */
/* returns total items selected */
int calc_manipulator_stats(const bContext *C)
{
TransInfo *t= BIF_GetTransInfo(); // XXX
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
Scene *scene= CTX_data_scene(C);
@ -369,17 +342,12 @@ int calc_manipulator_stats(const bContext *C)
else if(ob && (ob->flag & OB_POSEMODE)) {
bArmature *arm = ob->data;
bPoseChannel *pchan;
int mode;
int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed
if((ob->lay & v3d->lay)==0) return 0;
mode = t->mode;
t->mode = TFM_ROTATION; // mislead counting bones... bah
totsel = count_set_pose_transflags(&mode, 0, ob);
/* count total, we use same method as transform will do */
t->total= 0;
count_bone_select(t, arm, &arm->bonebase, 1);
totsel = t->total;
if(totsel) {
/* use channels to get stats */
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
@ -391,8 +359,6 @@ int calc_manipulator_stats(const bContext *C)
Mat4MulVecfl(ob->obmat, scene->twmin);
Mat4MulVecfl(ob->obmat, scene->twmax);
}
/* restore, mode can be TFM_INIT */
t->mode = mode;
}
else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE)) {
;
@ -446,17 +412,12 @@ int calc_manipulator_stats(const bContext *C)
if(ob && totsel) {
switch(v3d->twmode) {
case V3D_MANIP_GLOBAL:
strcpy(t->spacename, "global");
break;
case V3D_MANIP_NORMAL:
if(obedit || ob->flag & OB_POSEMODE) {
float mat[3][3];
int type;
strcpy(t->spacename, "normal");
type = getTransformOrientation(C, normal, plane, (v3d->around == V3D_ACTIVE));
switch (type)
@ -499,7 +460,6 @@ int calc_manipulator_stats(const bContext *C)
}
/* no break we define 'normal' as 'local' in Object mode */
case V3D_MANIP_LOCAL:
strcpy(t->spacename, "local");
Mat4CpyMat4(rv3d->twmat, ob->obmat);
Mat4Ortho(rv3d->twmat);
break;
@ -507,14 +467,13 @@ int calc_manipulator_stats(const bContext *C)
case V3D_MANIP_VIEW:
{
float mat[3][3];
strcpy(t->spacename, "view");
Mat3CpyMat4(mat, rv3d->viewinv);
Mat3Ortho(mat);
Mat4CpyMat3(rv3d->twmat, mat);
}
break;
default: /* V3D_MANIP_CUSTOM */
applyTransformOrientation(C, t);
// XXX applyTransformOrientation(C, t);
break;
}
@ -710,7 +669,6 @@ static void draw_manipulator_axes(View3D *v3d, int colcode, int flagx, int flagy
/* only called while G.moving */
static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int drawflags)
{
TransInfo *t= BIF_GetTransInfo(); // XXX
GLUquadricObj *qobj;
float size, phi, startphi, vec[3], svec[3], matt[4][4], cross[3], tmat[3][3];
int arcs= (G.rt!=2);
@ -726,7 +684,7 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d
/* we need both [4][4] transforms, t->mat seems to be premul, not post for mat[][4] */
Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
Mat4MulMat34(matt, t->mat, rv3d->twmat);
// XXX Mat4MulMat34(matt, t->mat, rv3d->twmat);
/* Screen aligned view rot circle */
if(drawflags & MAN_ROT_V) {
@ -735,15 +693,15 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d
glPushMatrix();
size= screen_aligned(rv3d, rv3d->twmat);
vec[0]= (float)(t->con.imval[0] - t->center2d[0]);
vec[1]= (float)(t->con.imval[1] - t->center2d[1]);
vec[0]= 0; // XXX (float)(t->con.imval[0] - t->center2d[0]);
vec[1]= 0; // XXX (float)(t->con.imval[1] - t->center2d[1]);
vec[2]= 0.0f;
Normalize(vec);
startphi= saacos( vec[1] );
if(vec[0]<0.0) startphi= -startphi;
phi= (float)fmod(180.0*t->val/M_PI, 360.0);
phi= 0; // XXX (float)fmod(180.0*t->val/M_PI, 360.0);
if(phi > 180.0) phi-= 360.0;
else if(phi<-180.0) phi+= 360.0;
@ -755,8 +713,8 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d
float imat[3][3], ivmat[3][3];
/* try to get the start rotation */
svec[0]= (float)(t->con.imval[0] - t->center2d[0]);
svec[1]= (float)(t->con.imval[1] - t->center2d[1]);
svec[0]= 0; // XXX (float)(t->con.imval[0] - t->center2d[0]);
svec[1]= 0; // XXX (float)(t->con.imval[1] - t->center2d[1]);
svec[2]= 0.0f;
/* screen aligned vec transform back to manipulator space */
@ -848,7 +806,6 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d
static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo)
{
TransInfo *t= BIF_GetTransInfo(); // XXX
GLUquadricObj *qobj;
double plane[4];
float size, vec[3], unitmat[4][4];
@ -900,8 +857,8 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if(moving) {
float vec[3];
vec[0]= (float)(t->imval[0] - t->center2d[0]);
vec[1]= (float)(t->imval[1] - t->center2d[1]);
vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]);
vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]);
vec[2]= 0.0f;
Normalize(vec);
VecMulf(vec, 1.2f*size);
@ -917,7 +874,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if(moving) {
float matt[4][4];
Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
Mat4MulMat34(matt, t->mat, rv3d->twmat);
// XXX Mat4MulMat34(matt, t->mat, rv3d->twmat);
wmMultMatrix(matt);
glFrontFace( is_mat4_flipped(matt)?GL_CW:GL_CCW);
}
@ -1121,7 +1078,6 @@ static void drawsolidcube(float size)
static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode)
{
TransInfo *t= BIF_GetTransInfo(); // XXX
float cywid= 0.25f*0.01f*(float)U.tw_handlesize;
float cusize= cywid*0.75f, dz;
@ -1153,7 +1109,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
float matt[4][4];
Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
Mat4MulMat34(matt, t->mat, rv3d->twmat);
// XXX Mat4MulMat34(matt, t->mat, rv3d->twmat);
wmMultMatrix(matt);
glFrontFace( is_mat4_flipped(matt)?GL_CW:GL_CCW);
}
@ -1238,7 +1194,6 @@ static void draw_cylinder(GLUquadricObj *qobj, float len, float width)
static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode)
{
TransInfo *t= BIF_GetTransInfo(); // XXX
GLUquadricObj *qobj;
float cylen= 0.01f*(float)U.tw_handlesize;
float cywid= 0.25f*cylen, dz, size;
@ -1248,7 +1203,7 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int movi
/* when called while moving in mixed mode, do not draw when... */
if((drawflags & MAN_TRANS_C)==0) return;
if(moving) glTranslatef(t->vec[0], t->vec[1], t->vec[2]);
// XXX if(moving) glTranslatef(t->vec[0], t->vec[1], t->vec[2]);
glDisable(GL_DEPTH_TEST);
qobj= gluNewQuadric();
@ -1314,7 +1269,6 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int movi
static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode)
{
TransInfo *t= BIF_GetTransInfo(); // XXX
GLUquadricObj *qobj;
float size;
float cylen= 0.01f*(float)U.tw_handlesize;
@ -1342,8 +1296,8 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
if(moving) {
float vec[3];
vec[0]= (float)(t->imval[0] - t->center2d[0]);
vec[1]= (float)(t->imval[1] - t->center2d[1]);
vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]);
vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]);
vec[2]= 0.0f;
Normalize(vec);
VecMulf(vec, 1.2f*size);
@ -1359,9 +1313,9 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
if(moving) {
float matt[4][4];
Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
if (t->flag & T_USES_MANIPULATOR) {
Mat4MulMat34(matt, t->mat, rv3d->twmat);
}
// XXX if (t->flag & T_USES_MANIPULATOR) {
// XXX Mat4MulMat34(matt, t->mat, rv3d->twmat);
// XXX }
wmMultMatrix(matt);
}
else {