Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2009-07-12 06:01:13 +0400
committerMartin Poirier <theeth@yahoo.com>2009-07-12 06:01:13 +0400
commit8b9bb47a3faf753cb0ca2ec0e9c6a741c7af31c2 (patch)
treeb3057453770db9d237c9b204c192bec07fd91e90 /source/blender/editors/transform
parent42469ba1e51c639c3fd317b812c486913d803fde (diff)
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.
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r--source/blender/editors/transform/transform.c1197
-rw-r--r--source/blender/editors/transform/transform.h30
-rw-r--r--source/blender/editors/transform/transform_constraints.c207
-rw-r--r--source/blender/editors/transform/transform_conversions.c1236
-rw-r--r--source/blender/editors/transform/transform_generics.c316
-rw-r--r--source/blender/editors/transform/transform_manipulator.c84
6 files changed, 1445 insertions, 1625 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 016400e0fa9..888a15e2534 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -123,7 +123,7 @@ void setTransformViewMatrices(TransInfo *t)
{
if(t->spacetype==SPACE_VIEW3D && t->ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = t->ar->regiondata;
-
+
Mat4CpyMat4(t->viewmat, rv3d->viewmat);
Mat4CpyMat4(t->viewinv, rv3d->viewinv);
Mat4CpyMat4(t->persmat, rv3d->persmat);
@@ -137,7 +137,7 @@ void setTransformViewMatrices(TransInfo *t)
Mat4One(t->persinv);
t->persp = V3D_ORTHO;
}
-
+
calculateCenter2D(t);
}
@@ -152,12 +152,12 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
else if(t->spacetype==SPACE_IMAGE) {
View2D *v2d = t->view;
float divx, divy, aspx, aspy;
-
+
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
-
+
divx= v2d->mask.xmax-v2d->mask.xmin;
divy= v2d->mask.ymax-v2d->mask.ymin;
-
+
vec[0]= aspx*(v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
vec[1]= aspy*(v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
vec[2]= 0.0f;
@@ -165,10 +165,10 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
View2D *v2d = t->view;
float divx, divy;
-
+
divx= v2d->mask.xmax-v2d->mask.xmin;
divy= v2d->mask.ymax-v2d->mask.ymin;
-
+
vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx) / (divx);
vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy) / (divy);
vec[2]= 0.0f;
@@ -176,10 +176,10 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
else if(t->spacetype==SPACE_NODE) {
View2D *v2d = &t->ar->v2d;
float divx, divy;
-
+
divx= v2d->mask.xmax-v2d->mask.xmin;
divy= v2d->mask.ymax-v2d->mask.ymin;
-
+
vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
vec[2]= 0.0f;
@@ -205,23 +205,23 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
}
else if(t->spacetype==SPACE_IMAGE) {
float aspx, aspy, v[2];
-
+
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
v[0]= vec[0]/aspx;
v[1]= vec[1]/aspy;
-
+
UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
}
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
int out[2] = {0, 0};
-
- UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
+
+ UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
adr[0]= out[0];
adr[1]= out[1];
}
else if(t->spacetype==SPACE_SEQ) { /* XXX not tested yet, but should work */
int out[2] = {0, 0};
-
+
UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
adr[0]= out[0];
adr[1]= out[1];
@@ -236,14 +236,14 @@ void projectFloatView(TransInfo *t, float *vec, float *adr)
}
else if(t->spacetype==SPACE_IMAGE) {
int a[2];
-
+
projectIntView(t, vec, a);
adr[0]= a[0];
adr[1]= a[1];
}
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
int a[2];
-
+
projectIntView(t, vec, a);
adr[0]= a[0];
adr[1]= a[1];
@@ -296,7 +296,7 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
{
if (t->spacetype == SPACE_VIEW3D)
{
- /* Do we need more refined tags? */
+ /* Do we need more refined tags? */
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
}
else if (t->spacetype == SPACE_ACTION) {
@@ -334,7 +334,7 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
static void viewRedrawPost(TransInfo *t)
{
ED_area_headerprint(t->sa, NULL);
-
+
#if 0 // TRANSFORM_FIX_ME
if(t->spacetype==SPACE_VIEW3D) {
allqueue(REDRAWBUTSOBJECT, 0);
@@ -365,7 +365,7 @@ void BIF_selectOrientation() {
char *str_menu = BIF_menustringTransformOrientation("Orientation");
val= pupmenu(str_menu);
MEM_freeN(str_menu);
-
+
if(val >= 0) {
G.vd->twmode = val;
}
@@ -381,18 +381,18 @@ static void view_editmove(unsigned short event)
/* Ctrl: Scroll right */
/* Alt-Shift: Rotate up */
/* Alt-Ctrl: Rotate right */
-
+
/* only work in 3D window for now
* In the end, will have to send to event to a 2D window handler instead
*/
if (Trans.flag & T_2D_EDIT)
return;
-
+
switch(event) {
case WHEELUPMOUSE:
-
+
if( G.qual & LR_SHIFTKEY ) {
- if( G.qual & LR_ALTKEY ) {
+ if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD2);
G.qual |= LR_SHIFTKEY;
@@ -400,23 +400,23 @@ static void view_editmove(unsigned short event)
persptoetsen(PAD2);
}
} else if( G.qual & LR_CTRLKEY ) {
- if( G.qual & LR_ALTKEY ) {
+ if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD4);
G.qual |= LR_CTRLKEY;
} else {
persptoetsen(PAD4);
}
- } else if(U.uiflag & USER_WHEELZOOMDIR)
+ } else if(U.uiflag & USER_WHEELZOOMDIR)
persptoetsen(PADMINUS);
else
persptoetsen(PADPLUSKEY);
-
+
refresh = 1;
break;
case WHEELDOWNMOUSE:
if( G.qual & LR_SHIFTKEY ) {
- if( G.qual & LR_ALTKEY ) {
+ if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD8);
G.qual |= LR_SHIFTKEY;
@@ -424,18 +424,18 @@ static void view_editmove(unsigned short event)
persptoetsen(PAD8);
}
} else if( G.qual & LR_CTRLKEY ) {
- if( G.qual & LR_ALTKEY ) {
+ if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD6);
G.qual |= LR_CTRLKEY;
} else {
persptoetsen(PAD6);
}
- } else if(U.uiflag & USER_WHEELZOOMDIR)
+ } else if(U.uiflag & USER_WHEELZOOMDIR)
persptoetsen(PADPLUSKEY);
else
persptoetsen(PADMINUS);
-
+
refresh = 1;
break;
}
@@ -500,19 +500,19 @@ void transformEvent(TransInfo *t, wmEvent *event)
{
float mati[3][3] = {{1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}};
char cmode = constraintModeToChar(t);
-
+
t->redraw |= handleMouseInput(t, &t->mouse, event);
if (event->type == MOUSEMOVE)
{
t->mval[0] = event->x - t->ar->winrct.xmin;
t->mval[1] = event->y - t->ar->winrct.ymin;
-
+
t->redraw = 1;
-
+
applyMouseInput(t, &t->mouse, t->mval, t->values);
}
-
+
if (event->val) {
switch (event->type){
/* enforce redraw of transform when modifiers are used */
@@ -521,7 +521,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
t->modifiers |= MOD_SNAP_GEARS;
t->redraw = 1;
break;
-
+
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
t->modifiers |= MOD_CONSTRAINT_PLANE;
@@ -532,7 +532,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
if ((t->spacetype==SPACE_VIEW3D) && event->alt) {
#if 0 // TRANSFORM_FIX_ME
short mval[2];
-
+
getmouseco_sc(mval);
BIF_selectOrientation();
calc_manipulator_stats(curarea);
@@ -544,7 +544,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
t->state = TRANS_CONFIRM;
}
break;
-
+
case MIDDLEMOUSE:
if ((t->flag & T_NO_CONSTRAINT)==0) {
/* exception for switching to dolly, or trackball, in camera view */
@@ -577,19 +577,16 @@ void transformEvent(TransInfo *t, wmEvent *event)
}
break;
case ESCKEY:
- case RIGHTMOUSE:
- printf("cancelled\n");
t->state = TRANS_CANCEL;
break;
- case LEFTMOUSE:
case PADENTER:
case RETKEY:
t->state = TRANS_CONFIRM;
break;
case GKEY:
/* only switch when... */
- if( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
- resetTransRestrictions(t);
+ if( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
+ resetTransRestrictions(t);
restoreTransObjects(t);
initTranslation(t);
initSnapping(t, NULL); // need to reinit after mode change
@@ -598,8 +595,8 @@ void transformEvent(TransInfo *t, wmEvent *event)
break;
case SKEY:
/* only switch when... */
- if( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
- resetTransRestrictions(t);
+ if( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
+ resetTransRestrictions(t);
restoreTransObjects(t);
initResize(t);
initSnapping(t, NULL); // need to reinit after mode change
@@ -609,9 +606,9 @@ void transformEvent(TransInfo *t, wmEvent *event)
case RKEY:
/* only switch when... */
if( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
-
- resetTransRestrictions(t);
-
+
+ resetTransRestrictions(t);
+
if (t->mode == TFM_ROTATION) {
restoreTransObjects(t);
initTrackball(t);
@@ -771,10 +768,10 @@ void transformEvent(TransInfo *t, wmEvent *event)
// viewmoveNDOF(1);
// break;
}
-
+
// Numerical input events
t->redraw |= handleNumInput(&(t->num), event);
-
+
// NDof input events
switch(handleNDofInput(&(t->ndof), event))
{
@@ -789,7 +786,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
if (t->options & CTX_NDOF)
{
/* Cancel on pure NDOF transform */
- t->state = TRANS_CANCEL;
+ t->state = TRANS_CANCEL;
}
else
{
@@ -807,16 +804,22 @@ void transformEvent(TransInfo *t, wmEvent *event)
case NDOF_REFRESH:
t->redraw = 1;
break;
-
+
}
-
+
// Snapping events
t->redraw |= handleSnapping(t, event);
-
+
//arrows_move_cursor(event->type);
}
else {
switch (event->type){
+ case RIGHTMOUSE:
+ t->state = TRANS_CANCEL;
+ break;
+ case LEFTMOUSE:
+ t->state = TRANS_CONFIRM;
+ break;
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
t->modifiers &= ~MOD_CONSTRAINT_PLANE;
@@ -826,7 +829,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
case LEFTCTRLKEY:
case RIGHTCTRLKEY:
t->modifiers &= ~MOD_SNAP_GEARS;
- /* no redraw on release modifier keys! this makes sure you can assign the 'grid' still
+ /* no redraw on release modifier keys! this makes sure you can assign the 'grid' still
after releasing modifer key */
//t->redraw = 1;
break;
@@ -837,15 +840,15 @@ void transformEvent(TransInfo *t, wmEvent *event)
t->redraw = 1;
}
break;
- case LEFTMOUSE:
- case RIGHTMOUSE:
- if(WM_modal_tweak_exit(event, t->event_type))
-// if (t->options & CTX_TWEAK)
- t->state = TRANS_CONFIRM;
- break;
+// case LEFTMOUSE:
+// case RIGHTMOUSE:
+// if(WM_modal_tweak_exit(event, t->event_type))
+//// if (t->options & CTX_TWEAK)
+// t->state = TRANS_CONFIRM;
+// break;
}
}
-
+
// Per transform event, if present
if (t->handleEvent)
t->redraw |= t->handleEvent(t, event);
@@ -859,7 +862,7 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float
t->state = TRANS_RUNNING;
t->options = CTX_NONE;
-
+
t->mode = TFM_DUMMY;
initTransInfo(C, t, NULL, event); // internal data, mouse, vectors
@@ -873,10 +876,10 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float
}
else {
success = 1;
-
+
calculateCenter(t);
-
- // Copy center from constraint center. Transform center can be local
+
+ // Copy center from constraint center. Transform center can be local
VECCOPY(vec, t->con.center);
}
@@ -884,9 +887,9 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float
/* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
special_aftertrans_update(t);
-
+
MEM_freeN(t);
-
+
return success;
}
@@ -905,28 +908,28 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size)
length = -length;
size = -size;
case RIGHT:
- glBegin(GL_LINES);
- glVertex2s( offset, 0);
- glVertex2s( offset + length, 0);
- glVertex2s( offset + length, 0);
- glVertex2s( offset + length - size, -size);
- glVertex2s( offset + length, 0);
+ glBegin(GL_LINES);
+ glVertex2s( offset, 0);
+ glVertex2s( offset + length, 0);
+ glVertex2s( offset + length, 0);
+ glVertex2s( offset + length - size, -size);
+ glVertex2s( offset + length, 0);
glVertex2s( offset + length - size, size);
- glEnd();
+ glEnd();
break;
case DOWN:
offset = -offset;
length = -length;
size = -size;
case UP:
- glBegin(GL_LINES);
- glVertex2s( 0, offset);
- glVertex2s( 0, offset + length);
- glVertex2s( 0, offset + length);
- glVertex2s(-size, offset + length - size);
- glVertex2s( 0, offset + length);
+ glBegin(GL_LINES);
+ glVertex2s( 0, offset);
+ glVertex2s( 0, offset + length);
+ glVertex2s( 0, offset + length);
+ glVertex2s(-size, offset + length - size);
+ glVertex2s( 0, offset + length);
glVertex2s( size, offset + length - size);
- glEnd();
+ glEnd();
break;
}
}
@@ -938,22 +941,22 @@ static void drawArrowHead(ArrowDirection d, short size)
case LEFT:
size = -size;
case RIGHT:
- glBegin(GL_LINES);
- glVertex2s( 0, 0);
- glVertex2s( -size, -size);
- glVertex2s( 0, 0);
+ glBegin(GL_LINES);
+ glVertex2s( 0, 0);
+ glVertex2s( -size, -size);
+ glVertex2s( 0, 0);
glVertex2s( -size, size);
- glEnd();
+ glEnd();
break;
case DOWN:
size = -size;
case UP:
- glBegin(GL_LINES);
- glVertex2s( 0, 0);
- glVertex2s(-size, -size);
- glVertex2s( 0, 0);
+ glBegin(GL_LINES);
+ glVertex2s( 0, 0);
+ glVertex2s(-size, -size);
+ glVertex2s( 0, 0);
glVertex2s( size, -size);
- glEnd();
+ glEnd();
break;
}
}
@@ -962,15 +965,15 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
{
float delta = (angle_end - angle_start) / segments;
float angle;
-
+
glBegin(GL_LINE_STRIP);
-
+
for( angle = angle_start; angle < angle_end; angle += delta)
{
glVertex2f( cosf(angle) * size, sinf(angle) * size);
}
glVertex2f( cosf(angle_end) * size, sinf(angle_end) * size);
-
+
glEnd();
}
@@ -979,7 +982,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
if (t->helpline != HLP_NONE && !(t->flag & T_USES_MANIPULATOR))
{
float vecrot[3], cent[2];
-
+
VECCOPY(vecrot, t->center);
if(t->flag & T_EDIT) {
Object *ob= t->obedit;
@@ -989,9 +992,9 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
Object *ob=t->poseobj;
if(ob) Mat4MulVecfl(ob->obmat, vecrot);
}
-
+
projectFloatView(t, vecrot, cent); // no overflow in extreme cases
-
+
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
@@ -1000,16 +1003,16 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
glPushMatrix();
ED_region_pixelspace(t->ar);
-
+
switch(t->helpline)
{
case HLP_SPRING:
UI_ThemeColor(TH_WIRE);
-
+
setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2sv(t->mval);
- glVertex2fv(cent);
+ glBegin(GL_LINE_STRIP);
+ glVertex2sv(t->mval);
+ glVertex2fv(cent);
glEnd();
glTranslatef(t->mval[0], t->mval[1], 0);
@@ -1037,7 +1040,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
glTranslatef(t->mval[0], t->mval[1], 0);
glLineWidth(3.0);
- glBegin(GL_LINES);
+ glBegin(GL_LINES);
drawArrow(UP, 5, 10, 5);
drawArrow(DOWN, 5, 10, 5);
glLineWidth(1.0);
@@ -1050,27 +1053,27 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
float delta_angle = MIN2(15 / dist, M_PI/4);
float spacing_angle = MIN2(5 / dist, M_PI/12);
UI_ThemeColor(TH_WIRE);
-
+
setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2sv(t->mval);
- glVertex2fv(cent);
+ glBegin(GL_LINE_STRIP);
+ glVertex2sv(t->mval);
+ glVertex2fv(cent);
glEnd();
-
+
glTranslatef(cent[0], cent[1], 0);
-
+
setlinestyle(0);
glLineWidth(3.0);
drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
-
+
glPushMatrix();
glTranslatef(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
glRotatef(180 / M_PI * (angle - delta_angle), 0, 0, 1);
-
+
drawArrowHead(DOWN, 5);
-
+
glPopMatrix();
glTranslatef(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
@@ -1085,32 +1088,32 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
{
char col[3], col2[3];
UI_GetThemeColor3ubv(TH_GRID, col);
-
+
glTranslatef(t->mval[0], t->mval[1], 0);
-
+
glLineWidth(3.0);
-
+
UI_make_axis_color(col, col2, 'x');
glColor3ubv((GLubyte *)col2);
-
+
drawArrow(RIGHT, 5, 10, 5);
drawArrow(LEFT, 5, 10, 5);
-
+
UI_make_axis_color(col, col2, 'y');
glColor3ubv((GLubyte *)col2);
-
+
drawArrow(UP, 5, 10, 5);
drawArrow(DOWN, 5, 10, 5);
glLineWidth(1.0);
break;
}
}
-
+
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
-
+
glEnable(GL_DEPTH_TEST);
}
}
@@ -1118,7 +1121,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
void drawTransform(const struct bContext *C, struct ARegion *ar, void *arg)
{
TransInfo *t = arg;
-
+
drawConstraint(C, t);
drawPropCircle(C, t);
drawSnapping(C, t);
@@ -1164,7 +1167,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
{
RNA_boolean_set(op->ptr, "mirror", t->flag & T_MIRROR);
}
-
+
if (RNA_struct_find_property(op->ptr, "constraint_axis"))
{
RNA_int_set(op->ptr, "constraint_orientation", t->current_orientation);
@@ -1194,7 +1197,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if(t->spacetype == SPACE_VIEW3D)
{
View3D *v3d = t->view;
-
+
v3d->twmode = t->current_orientation;
}
}
@@ -1209,7 +1212,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
t->state = TRANS_RUNNING;
t->options = options;
-
+
t->mode = mode;
if (!initTransInfo(C, t, op, event)) // internal data, mouse, vectors
@@ -1221,7 +1224,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
{
//calc_manipulator_stats(curarea);
initTransformOrientation(C, t);
-
+
t->draw_handle = ED_region_draw_cb_activate(t->ar->type, drawTransform, t, REGION_DRAW_POST);
}
else if(t->spacetype == SPACE_IMAGE) {
@@ -1244,10 +1247,10 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
/* EVIL2: we gave as argument also texture space context bit... was cleared */
/* EVIL3: extend mode for animation editors also switches modes... but is best way to avoid duplicate code */
mode = t->mode;
-
+
calculatePropRatio(t);
calculateCenter(t);
-
+
initMouseInput(t, &t->mouse, t->center2d, t->imval);
switch (mode) {
@@ -1311,11 +1314,11 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
case TFM_TIME_SCALE:
initTimeScale(t);
break;
- case TFM_TIME_EXTEND:
+ case TFM_TIME_EXTEND:
/* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
* Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
* (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
- * depending on which editor this was called from
+ * depending on which editor this was called from
*/
if ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)
initTranslation(t);
@@ -1369,11 +1372,11 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
if (constraint_axis[2]) {
t->con.mode |= CON_AXIS2;
}
-
- setUserConstraint(t, t->con.mode, "%s");
+
+ setUserConstraint(t, t->con.mode, "%s");
}
}
-
+
return 1;
}
@@ -1392,7 +1395,7 @@ void transformApply(bContext *C, TransInfo *t)
t->redraw = 0;
}
- /* If auto confirm is on, break after one pass */
+ /* If auto confirm is on, break after one pass */
if (t->options & CTX_AUTOCONFIRM)
{
t->state = TRANS_CONFIRM;
@@ -1409,7 +1412,7 @@ void transformApply(bContext *C, TransInfo *t)
int transformEnd(bContext *C, TransInfo *t)
{
int exit_code = OPERATOR_RUNNING_MODAL;
-
+
if (t->state != TRANS_RUNNING)
{
/* handle restoring objects */
@@ -1422,16 +1425,16 @@ int transformEnd(bContext *C, TransInfo *t)
{
exit_code = OPERATOR_FINISHED;
}
-
+
/* free data */
postTrans(t);
-
+
/* aftertrans does insert keyframes, and clears base flags, doesnt read transdata */
special_aftertrans_update(t);
-
+
/* send events out for redraws */
viewRedrawPost(t);
-
+
/* Undo as last, certainly after special_trans_update! */
if(t->state == TRANS_CANCEL) {
@@ -1445,7 +1448,7 @@ int transformEnd(bContext *C, TransInfo *t)
viewRedrawForce(C, t);
}
-
+
return exit_code;
}
@@ -1454,14 +1457,14 @@ int transformEnd(bContext *C, TransInfo *t)
void initManipulator(int mode)
{
printf("init manipulator mode %d\n", mode);
-
+
#if 0 // TRANSFORM_FIX_ME
Trans.state = TRANS_RUNNING;
Trans.options = CTX_NONE;
-
+
Trans.mode = mode;
-
+
/* automatic switch to scaling bone envelopes */
if(mode==TFM_RESIZE && t->obedit && t->obedit->type==OB_ARMATURE) {
bArmature *arm= t->obedit->data;
@@ -1482,7 +1485,7 @@ void initManipulator(int mode)
/* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */
/* EVIL2: we gave as argument also texture space context bit... was cleared */
mode = Trans.mode;
-
+
calculatePropRatio(&Trans);
calculateCenter(&Trans);
@@ -1505,7 +1508,7 @@ void initManipulator(int mode)
#endif
}
-void ManipulatorTransform()
+void ManipulatorTransform()
{
#if 0 // TRANSFORM_FIX_ME
int mouse_moved = 0;
@@ -1518,9 +1521,9 @@ void ManipulatorTransform()
Trans.redraw = 1; /* initial draw */
while (Trans.state == TRANS_RUNNING) {
-
+
getmouseco_areawin(mval);
-
+
if (mval[0] != pmval[0] || mval[1] != pmval[1]) {
Trans.redraw = 1;
}
@@ -1534,7 +1537,7 @@ void ManipulatorTransform()
}
Trans.redraw = 0;
}
-
+
/* essential for idling subloop */
if( qtest()==0) PIL_sleep_ms(2);
@@ -1559,9 +1562,9 @@ void ManipulatorTransform()
Trans.flag |= T_SHIFT_MOD;
Trans.redraw = 1;
}
- else Trans.flag &= ~T_SHIFT_MOD;
+ else Trans.flag &= ~T_SHIFT_MOD;
break;
-
+
case ESCKEY:
case RIGHTMOUSE:
Trans.state = TRANS_CANCEL;
@@ -1619,23 +1622,23 @@ void ManipulatorTransform()
Trans.redraw= 1;
break;
}
-
+
// Numerical input events
Trans.redraw |= handleNumInput(&(Trans.num), event);
}
}
}
-
+
if(Trans.state == TRANS_CANCEL) {
restoreTransObjects(&Trans);
}
-
+
/* free data, reset vars */
postTrans(&Trans);
-
+
/* aftertrans does insert ipos and action channels, and clears base flags */
special_aftertrans_update(&Trans);
-
+
/* send events out for redraws */
viewRedrawPost(&Trans);
@@ -1681,21 +1684,21 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
{
/* quaternions get limited with euler... */
/* this function only does the delta rotation */
-
+
if(protectflag) {
float eul[3], oldeul[3], quat1[4];
-
+
QUATCOPY(quat1, quat);
QuatToEul(quat, eul);
QuatToEul(oldquat, oldeul);
-
+
if(protectflag & OB_LOCK_ROTX)
eul[0]= oldeul[0];
if(protectflag & OB_LOCK_ROTY)
eul[1]= oldeul[1];
if(protectflag & OB_LOCK_ROTZ)
eul[2]= oldeul[2];
-
+
EulToQuat(eul, quat);
/* quaternions flip w sign to accumulate rotations correctly */
if( (quat1[0]<0.0f && quat[0]>0.0f) || (quat1[0]>0.0f && quat[0]<0.0f) ) {
@@ -1712,8 +1715,8 @@ static void constraintTransLim(TransInfo *t, TransData *td)
bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
bConstraintOb cob;
bConstraint *con;
-
- /* Make a temporary bConstraintOb for using these limit constraints
+
+ /* Make a temporary bConstraintOb for using these limit constraints
* - they only care that cob->matrix is correctly set ;-)
* - current space should be local
*/
@@ -1728,22 +1731,22 @@ static void constraintTransLim(TransInfo *t, TransData *td)
else {
VECCOPY(cob.matrix[3], td->loc);
}
-
+
/* Evaluate valid constraints */
for (con= td->con; con; con= con->next) {
float tmat[4][4];
-
+
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* only use it if it's tagged for this purpose (and the right type) */
if (con->type == CONSTRAINT_TYPE_LOCLIMIT) {
bLocLimitConstraint *data= con->data;
-
- if ((data->flag2 & LIMIT_TRANSFORM)==0)
+
+ if ((data->flag2 & LIMIT_TRANSFORM)==0)
continue;
-
+
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1754,10 +1757,10 @@ static void constraintTransLim(TransInfo *t, TransData *td)
/* skip... incompatable spacetype */
continue;
}
-
+
/* do constraint */
cti->evaluate_constraint(con, &cob, NULL);
-
+
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1766,7 +1769,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
}
}
}
-
+
/* copy results from cob->matrix */
if (td->tdi) {
TransDataIpokey *tdi= td->tdi;
@@ -1786,8 +1789,8 @@ static void constraintRotLim(TransInfo *t, TransData *td)
bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_ROTLIMIT);
bConstraintOb cob;
bConstraint *con;
-
- /* Make a temporary bConstraintOb for using these limit constraints
+
+ /* Make a temporary bConstraintOb for using these limit constraints
* - they only care that cob->matrix is correctly set ;-)
* - current space should be local
*/
@@ -1803,11 +1806,11 @@ static void constraintRotLim(TransInfo *t, TransData *td)
/* ipo-keys eulers */
TransDataIpokey *tdi= td->tdi;
float eul[3];
-
+
eul[0]= tdi->rotx[0];
eul[1]= tdi->roty[0];
eul[2]= tdi->rotz[0];
-
+
EulToMat4(eul, cob.matrix);
}
else {
@@ -1817,22 +1820,22 @@ static void constraintRotLim(TransInfo *t, TransData *td)
else
return;
}
-
+
/* Evaluate valid constraints */
for (con= td->con; con; con= con->next) {
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* we're only interested in Limit-Rotation constraints */
if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
bRotLimitConstraint *data= con->data;
float tmat[4][4];
-
+
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM)==0)
+ if ((data->flag2 & LIMIT_TRANSFORM)==0)
continue;
-
+
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1843,10 +1846,10 @@ static void constraintRotLim(TransInfo *t, TransData *td)
/* skip... incompatable spacetype */
continue;
}
-
+
/* do constraint */
cti->evaluate_constraint(con, &cob, NULL);
-
+
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1855,7 +1858,7 @@ static void constraintRotLim(TransInfo *t, TransData *td)
}
}
}
-
+
/* copy results from cob->matrix */
if (td->flag & TD_USEQUAT) {
/* quats */
@@ -1865,9 +1868,9 @@ static void constraintRotLim(TransInfo *t, TransData *td)
/* ipo-keys eulers */
TransDataIpokey *tdi= td->tdi;
float eul[3];
-
+
Mat4ToEul(cob.matrix, eul);
-
+
tdi->rotx[0]= eul[0];
tdi->roty[0]= eul[1];
tdi->rotz[0]= eul[2];
@@ -1885,8 +1888,8 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_SIZELIMIT);
bConstraintOb cob;
bConstraint *con;
-
- /* Make a temporary bConstraintOb for using these limit constraints
+
+ /* Make a temporary bConstraintOb for using these limit constraints
* - they only care that cob->matrix is correctly set ;-)
* - current space should be local
*/
@@ -1894,12 +1897,12 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
if (td->tdi) {
TransDataIpokey *tdi= td->tdi;
float size[3];
-
+
size[0]= tdi->sizex[0];
size[1]= tdi->sizey[0];
size[2]= tdi->sizez[0];
SizeToMat4(size, cob.matrix);
- }
+ }
else if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
return; // TODO: fix this case
@@ -1908,25 +1911,25 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
return;
-
+
SizeToMat4(td->ext->size, cob.matrix);
}
-
+
/* Evaluate valid constraints */
for (con= td->con; con; con= con->next) {
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* we're only interested in Limit-Scale constraints */
if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
bSizeLimitConstraint *data= con->data;
float tmat[4][4];
-
+
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM)==0)
+ if ((data->flag2 & LIMIT_TRANSFORM)==0)
continue;
-
+
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1937,10 +1940,10 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* skip... incompatable spacetype */
continue;
}
-
+
/* do constraint */
cti->evaluate_constraint(con, &cob, NULL);
-
+
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1949,18 +1952,18 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
}
}
}
-
+
/* copy results from cob->matrix */
if (td->tdi) {
TransDataIpokey *tdi= td->tdi;
float size[3];
-
+
Mat4ToSize(cob.matrix, size);
-
+
tdi->sizex[0]= size[0];
tdi->sizey[0]= size[1];
tdi->sizez[0]= size[2];
- }
+ }
else if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
return; // TODO: fix this case
@@ -1969,7 +1972,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
return;
-
+
Mat4ToSize(cob.matrix, td->ext->size);
}
}
@@ -1977,15 +1980,15 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* ************************** WARP *************************** */
-void initWarp(TransInfo *t)
+void initWarp(TransInfo *t)
{
float max[3], min[3];
int i;
-
+
t->mode = TFM_WARP;
t->transform = Warp;
t->handleEvent = handleEventWarp;
-
+
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
t->idx_max = 0;
@@ -1993,9 +1996,9 @@ void initWarp(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = 5.0f;
t->snap[2] = 1.0f;
-
+
t->flag |= T_NO_CONSTRAINT;
-
+
/* we need min/max in view space */
for(i = 0; i < t->total; i++) {
float center[3];
@@ -2010,11 +2013,11 @@ void initWarp(TransInfo *t)
VECCOPY(min, center);
}
}
-
+
t->center[0]= (min[0]+max[0])/2.0f;
t->center[1]= (min[1]+max[1])/2.0f;
t->center[2]= (min[2]+max[2])/2.0f;
-
+
if (max[0] == min[0]) max[0] += 0.1; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */
t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */
}
@@ -2022,7 +2025,7 @@ void initWarp(TransInfo *t)
int handleEventWarp(TransInfo *t, wmEvent *event)
{
int status = 0;
-
+
if (event->type == MIDDLEMOUSE && event->val)
{
// Use customData pointer to signal warp direction
@@ -2030,10 +2033,10 @@ int handleEventWarp(TransInfo *t, wmEvent *event)
t->customData = (void*)1;
else
t->customData = 0;
-
+
status = 1;
}
-
+
return status;
}
@@ -2043,7 +2046,7 @@ int Warp(TransInfo *t, short mval[2])
float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3], gcursor[3];
int i;
char str[50];
-
+
curs= give_cursor(t->scene, t->view);
/*
* gcursor is the one used for helpline.
@@ -2056,7 +2059,7 @@ int Warp(TransInfo *t, short mval[2])
* into account if in Edit mode.
*/
VECCOPY(cursor, curs);
- VECCOPY(gcursor, cursor);
+ VECCOPY(gcursor, cursor);
if (t->flag & T_EDIT) {
VecSubf(cursor, cursor, t->obedit->obmat[3]);
VecSubf(gcursor, gcursor, t->obedit->obmat[3]);
@@ -2067,7 +2070,7 @@ int Warp(TransInfo *t, short mval[2])
/* amount of degrees for warp */
circumfac = 360.0f * t->values[0];
-
+
if (t->customData) /* non-null value indicates reversed input */
{
circumfac *= -1;
@@ -2075,22 +2078,22 @@ int Warp(TransInfo *t, short mval[2])
snapGrid(t, &circumfac);
applyNumInput(&t->num, &circumfac);
-
+
/* header print for NumInput */
if (hasNumInput(&t->num)) {
char c[20];
-
+
outputNumInput(&(t->num), c);
-
+
sprintf(str, "Warp: %s", c);
}
else {
/* default header print */
sprintf(str, "Warp: %.3f", circumfac);
}
-
+
circumfac*= (float)(-M_PI/360.0);
-
+
for(i = 0; i < t->total; i++, td++) {
float loc[3];
if (td->flag & TD_NOACTION)
@@ -2098,65 +2101,65 @@ int Warp(TransInfo *t, short mval[2])
if (td->flag & TD_SKIP)
continue;
-
+
/* translate point to center, rotate in such a way that outline==distance */
VECCOPY(vec, td->iloc);
Mat3MulVecfl(td->mtx, vec);
Mat4MulVecfl(t->viewmat, vec);
VecSubf(vec, vec, t->viewmat[3]);
-
+
dist= vec[0]-cursor[0];
-
+
/* t->val is X dimension projected boundbox */
- phi0= (circumfac*dist/t->val);
-
+ phi0= (circumfac*dist/t->val);
+
vec[1]= (vec[1]-cursor[1]);
-
+
co= (float)cos(phi0);
si= (float)sin(phi0);
loc[0]= -si*vec[1]+cursor[0];
loc[1]= co*vec[1]+cursor[1];
loc[2]= vec[2];
-
+
Mat4MulVecfl(t->viewinv, loc);
VecSubf(loc, loc, t->viewinv[3]);
Mat3MulVecfl(td->smtx, loc);
-
+
VecSubf(loc, loc, td->iloc);
VecMulf(loc, td->factor);
VecAddf(td->loc, td->iloc, loc);
}
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
/* ************************** SHEAR *************************** */
-void initShear(TransInfo *t)
+void initShear(TransInfo *t)
{
t->mode = TFM_SHEAR;
t->transform = Shear;
t->handleEvent = handleEventShear;
-
+
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
int handleEventShear(TransInfo *t, wmEvent *event)
{
int status = 0;
-
+
if (event->type == MIDDLEMOUSE && event->val)
{
// Use customData pointer to signal Shear direction
@@ -2170,15 +2173,15 @@ int handleEventShear(TransInfo *t, wmEvent *event)
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
t->customData = 0;
}
-
+
status = 1;
}
-
+
return status;
}
-int Shear(TransInfo *t, short mval[2])
+int Shear(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float vec[3];
@@ -2208,18 +2211,18 @@ int Shear(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "Shear: %.3f %s", value, t->proptext);
}
-
+
Mat3One(smat);
-
+
// Custom data signals shear direction
if (t->customData == 0)
smat[1][0] = value;
else
smat[0][1] = value;
-
+
Mat3MulMat3(tmat, smat, persmat);
Mat3MulMat3(totmat, persinv, tmat);
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -2256,13 +2259,13 @@ int Shear(TransInfo *t, short mval[2])
/* ************************** RESIZE *************************** */
-void initResize(TransInfo *t)
+void initResize(TransInfo *t)
{
t->mode = TFM_RESIZE;
t->transform = Resize;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
-
+
t->flag |= T_NULL_ONE;
t->num.flag |= NUM_NULL_ONE;
t->num.flag |= NUM_AFFECT_ALL;
@@ -2270,7 +2273,7 @@ void initResize(TransInfo *t)
t->flag |= T_NO_ZERO;
t->num.flag |= NUM_NO_ZERO;
}
-
+
t->idx_max = 2;
t->num.idx_max = 2;
t->snap[0] = 0.0f;
@@ -2316,18 +2319,18 @@ static void headerResize(TransInfo *t, float vec[3], char *str) {
static void TransMat3ToSize( float mat[][3], float smat[][3], float *size)
{
float vec[3];
-
+
VecCopyf(vec, mat[0]);
size[0]= Normalize(vec);
VecCopyf(vec, mat[1]);
size[1]= Normalize(vec);
VecCopyf(vec, mat[2]);
size[2]= Normalize(vec);
-
+
/* first tried with dotproduct... but the sign flip is crucial */
- if( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0];
- if( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1];
- if( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2];
+ if( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0];
+ if( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1];
+ if( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2];
}
@@ -2353,7 +2356,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
VECCOPY(center, td->center);
}
else if (t->flag & T_EDIT) {
-
+
if(t->around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
VECCOPY(center, td->center);
}
@@ -2371,7 +2374,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
if (td->ext) {
float fsize[3];
-
+
if (t->flag & (T_OBJECT|T_TEXTURE|T_POSE)) {
float obsizemat[3][3];
// Reorient the size mat to fit the oriented object.
@@ -2383,28 +2386,28 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
else {
Mat3ToSize(tmat, fsize);
}
-
+
protectedSizeBits(td->protectflag, fsize);
-
+
if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't resize objects itself
/* handle ipokeys? */
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
/* calculate delta size (equal for size and dsize) */
-
+
vec[0]= (tdi->oldsize[0])*(fsize[0] -1.0f) * td->factor;
vec[1]= (tdi->oldsize[1])*(fsize[1] -1.0f) * td->factor;
vec[2]= (tdi->oldsize[2])*(fsize[2] -1.0f) * td->factor;
-
+
add_tdi_poin(tdi->sizex, tdi->oldsize, vec[0]);
add_tdi_poin(tdi->sizey, tdi->oldsize+1, vec[1]);
add_tdi_poin(tdi->sizez, tdi->oldsize+2, vec[2]);
-
- }
+
+ }
else if((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)){
/* scale val and reset size */
*td->val = td->ival * fsize[0] * td->factor;
-
+
td->ext->size[0] = td->ext->isize[0];
td->ext->size[1] = td->ext->isize[1];
td->ext->size[2] = td->ext->isize[2];
@@ -2413,16 +2416,16 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
*td->val = td->ival;
-
+
td->ext->size[0] = td->ext->isize[0] * (fsize[0]) * td->factor;
td->ext->size[1] = td->ext->isize[1] * (fsize[1]) * td->factor;
td->ext->size[2] = td->ext->isize[2] * (fsize[2]) * td->factor;
}
}
-
+
constraintSizeLim(t, td);
}
-
+
/* For individual element center, Editmode need to use iloc */
if (t->flag & T_POINTS)
VecSubf(vec, td->iloc, center);
@@ -2452,11 +2455,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
add_tdi_poin(tdi->locz, tdi->oldloc+2, vec[2]);
}
else VecAddf(td->loc, td->iloc, vec);
-
+
constraintTransLim(t, td);
}
-int Resize(TransInfo *t, short mval[2])
+int Resize(TransInfo *t, short mval[2])
{
TransData *td;
float size[3], mat[3][3];
@@ -2473,7 +2476,7 @@ int Resize(TransInfo *t, short mval[2])
{
ratio = t->values[0];
}
-
+
size[0] = size[1] = size[2] = ratio;
snapGrid(t, size);
@@ -2499,7 +2502,7 @@ int Resize(TransInfo *t, short mval[2])
}
Mat3CpyMat3(t->mat, mat); // used in manipulator
-
+
headerResize(t, size, str);
for(i = 0, td=t->data; i < t->total; i++, td++) {
@@ -2508,7 +2511,7 @@ int Resize(TransInfo *t, short mval[2])
if (td->flag & TD_SKIP)
continue;
-
+
ElementResize(t, td, mat);
}
@@ -2532,14 +2535,14 @@ int Resize(TransInfo *t, short mval[2])
/* ************************** TOSPHERE *************************** */
-void initToSphere(TransInfo *t)
+void initToSphere(TransInfo *t)
{
TransData *td = t->data;
int i;
t->mode = TFM_TOSPHERE;
t->transform = ToSphere;
-
+
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
t->idx_max = 0;
@@ -2547,10 +2550,10 @@ void initToSphere(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->num.flag |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
t->flag |= T_NO_CONSTRAINT;
-
+
// Calculate average radius
for(i = 0 ; i < t->total; i++, td++) {
t->val += VecLenf(t->center, td->iloc);
@@ -2559,7 +2562,7 @@ void initToSphere(TransInfo *t)
t->val /= (float)t->total;
}
-int ToSphere(TransInfo *t, short mval[2])
+int ToSphere(TransInfo *t, short mval[2])
{
float vec[3];
float ratio, radius;
@@ -2590,8 +2593,8 @@ int ToSphere(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "To Sphere: %.4f %s", ratio, t->proptext);
}
-
-
+
+
for(i = 0 ; i < t->total; i++, td++) {
float tratio;
if (td->flag & TD_NOACTION)
@@ -2610,7 +2613,7 @@ int ToSphere(TransInfo *t, short mval[2])
VecAddf(td->loc, t->center, vec);
}
-
+
recalcData(t);
@@ -2622,23 +2625,23 @@ int ToSphere(TransInfo *t, short mval[2])
/* ************************** ROTATION *************************** */
-void initRotation(TransInfo *t)
+void initRotation(TransInfo *t)
{
t->mode = TFM_ROTATION;
t->transform = Rotation;
-
+
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
-
+
t->ndof.axis = 16;
/* Scale down and flip input for rotation */
t->ndof.factor[0] = -0.2f;
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = (float)((5.0/180)*M_PI);
t->snap[2] = t->snap[1] * 0.2f;
-
+
if (t->flag & T_2D_EDIT)
t->flag |= T_NO_CONSTRAINT;
}
@@ -2647,7 +2650,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
float vec[3], totmat[3][3], smat[3][3];
float eul[3], fmat[3][3], quat[4];
float *center = t->center;
-
+
/* local constraint shouldn't alter center */
if (around == V3D_LOCAL) {
if (t->flag & (T_OBJECT|T_POSE)) {
@@ -2660,14 +2663,14 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
}
}
}
-
+
if (t->flag & T_POINTS) {
Mat3MulMat3(totmat, mat, td->mtx);
Mat3MulMat3(smat, td->smtx, totmat);
-
+
VecSubf(vec, td->iloc, center);
Mat3MulVecfl(smat, vec);
-
+
VecAddf(td->loc, vec, center);
VecSubf(vec,td->loc,td->iloc);
@@ -2677,10 +2680,10 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
if(td->flag & TD_USEQUAT) {
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
Mat3ToQuat(fmat, quat); // Actual transform
-
+
if(td->ext->quat){
QuatMul(td->ext->quat, quat, td->ext->iquat);
-
+
/* is there a reason not to have this here? -jahka */
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
}
@@ -2688,11 +2691,11 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
}
/**
* HACK WARNING
- *
+ *
* This is some VERY ugly special case to deal with pose mode.
- *
+ *
* The problem is that mtx and smtx include each bone orientation.
- *
+ *
* That is needed to rotate each bone properly, HOWEVER, to calculate
* the translation component, we only need the actual armature object's
* matrix (and inverse). That is not all though. Once the proper translation
@@ -2701,65 +2704,65 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
else if (t->flag & T_POSE) {
float pmtx[3][3], imtx[3][3];
- // Extract and invert armature object matrix
+ // Extract and invert armature object matrix
Mat3CpyMat4(pmtx, t->poseobj->obmat);
Mat3Inv(imtx, pmtx);
-
+
if ((td->flag & TD_NO_LOC) == 0)
{
VecSubf(vec, td->center, center);
-
+
Mat3MulVecfl(pmtx, vec); // To Global space
Mat3MulVecfl(mat, vec); // Applying rotation
Mat3MulVecfl(imtx, vec); // To Local space
-
+
VecAddf(vec, vec, center);
/* vec now is the location where the object has to be */
-
+
VecSubf(vec, vec, td->center); // Translation needed from the initial location
-
+
Mat3MulVecfl(pmtx, vec); // To Global space
Mat3MulVecfl(td->smtx, vec);// To Pose space
-
+
protectedTransBits(td->protectflag, vec);
-
+
VecAddf(td->loc, td->iloc, vec);
-
+
constraintTransLim(t, td);
}
-
+
/* rotation */
if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
/* euler or quaternion? */
if (td->flag & TD_USEQUAT) {
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
-
+
Mat3ToQuat(fmat, quat); // Actual transform
-
+
QuatMul(td->ext->quat, quat, td->ext->iquat);
/* this function works on end result */
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
}
else {
float eulmat[3][3];
-
+
Mat3MulMat3(totmat, mat, td->mtx);
Mat3MulMat3(smat, td->smtx, totmat);
-
+
/* calculate the total rotatation in eulers */
VECCOPY(eul, td->ext->irot);
EulToMat3(eul, eulmat);
-
+
/* mat = transform, obmat = bone rotation */
Mat3MulMat3(fmat, smat, eulmat);
-
+
Mat3ToCompatibleEul(fmat, eul, td->ext->rot);
-
+
/* and apply (to end result only) */
protectedRotateBits(td->protectflag, eul, td->ext->irot);
VECCOPY(td->ext->rot, eul);
}
-
+
constraintRotLim(t, td);
}
}
@@ -2773,9 +2776,9 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* vec now is the location where the object has to be */
VecSubf(vec, vec, td->center);
Mat3MulVecfl(td->smtx, vec);
-
+
protectedTransBits(td->protectflag, vec);
-
+
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
add_tdi_poin(tdi->locx, tdi->oldloc, vec[0]);
@@ -2784,8 +2787,8 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
}
else VecAddf(td->loc, td->iloc, vec);
}
-
-
+
+
constraintTransLim(t, td);
/* rotation */
@@ -2794,34 +2797,34 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
if (td->flag & TD_USEQUAT) {
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
Mat3ToQuat(fmat, quat); // Actual transform
-
+
QuatMul(td->ext->quat, quat, td->ext->iquat);
/* this function works on end result */
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
}
else {
float obmat[3][3];
-
+
/* are there ipo keys? */
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
float current_rot[3];
float rot[3];
-
+
/* current IPO value for compatible euler */
current_rot[0] = (tdi->rotx) ? tdi->rotx[0] : 0.0f;
current_rot[1] = (tdi->roty) ? tdi->roty[0] : 0.0f;
current_rot[2] = (tdi->rotz) ? tdi->rotz[0] : 0.0f;
VecMulf(current_rot, (float)(M_PI_2 / 9.0));
-
+
/* calculate the total rotatation in eulers */
VecAddf(eul, td->ext->irot, td->ext->drot);
EulToMat3(eul, obmat);
/* mat = transform, obmat = object rotation */
Mat3MulMat3(fmat, mat, obmat);
-
+
Mat3ToCompatibleEul(fmat, eul, current_rot);
-
+
/* correct back for delta rot */
if(tdi->flag & TOB_IPODROT) {
VecSubf(rot, eul, td->ext->irot);
@@ -2829,12 +2832,12 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
else {
VecSubf(rot, eul, td->ext->drot);
}
-
+
VecMulf(rot, (float)(9.0/M_PI_2));
VecSubf(rot, rot, tdi->oldrot);
-
+
protectedRotateBits(td->protectflag, rot, tdi->oldrot);
-
+
add_tdi_poin(tdi->rotx, tdi->oldrot, rot[0]);
add_tdi_poin(tdi->roty, tdi->oldrot+1, rot[1]);
add_tdi_poin(tdi->rotz, tdi->oldrot+2, rot[2]);
@@ -2842,37 +2845,37 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
else {
Mat3MulMat3(totmat, mat, td->mtx);
Mat3MulMat3(smat, td->smtx, totmat);
-
+
/* calculate the total rotatation in eulers */
VecAddf(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */
EulToMat3(eul, obmat);
/* mat = transform, obmat = object rotation */
Mat3MulMat3(fmat, smat, obmat);
-
+
Mat3ToCompatibleEul(fmat, eul, td->ext->rot);
-
+
/* correct back for delta rot */
VecSubf(eul, eul, td->ext->drot);
-
+
/* and apply */
protectedRotateBits(td->protectflag, eul, td->ext->irot);
VECCOPY(td->ext->rot, eul);
}
}
-
+
constraintRotLim(t, td);
}
}
}
-static void applyRotation(TransInfo *t, float angle, float axis[3])
+static void applyRotation(TransInfo *t, float angle, float axis[3])
{
TransData *td = t->data;
float mat[3][3];
int i;
VecRotToMat3(axis, angle, mat);
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
@@ -2880,7 +2883,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
if (td->flag & TD_SKIP)
continue;
-
+
if (t->con.applyRot) {
t->con.applyRot(t, td, axis, NULL);
VecRotToMat3(axis, angle * td->factor, mat);
@@ -2893,7 +2896,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
}
}
-int Rotation(TransInfo *t, short mval[2])
+int Rotation(TransInfo *t, short mval[2])
{
char str[64];
@@ -2909,13 +2912,13 @@ int Rotation(TransInfo *t, short mval[2])
final = t->values[0];
applyNDofInput(&t->ndof, &final);
-
+
snapGrid(t, &final);
if (t->con.applyRot) {
t->con.applyRot(t, NULL, axis, &final);
}
-
+
applySnapping(t, &final);
if (hasNumInput(&t->num)) {
@@ -2930,7 +2933,7 @@ int Rotation(TransInfo *t, short mval[2])
/* Clamp between -180 and 180 */
while (final >= 180.0)
final -= 360.0;
-
+
while (final <= -180.0)
final += 360.0;
@@ -2945,9 +2948,9 @@ int Rotation(TransInfo *t, short mval[2])
// TRANSFORM_FIX_ME
// t->values[0] = final; // used in manipulator
// Mat3CpyMat3(t->mat, mat); // used in manipulator
-
+
applyRotation(t, final, axis);
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -2958,13 +2961,13 @@ int Rotation(TransInfo *t, short mval[2])
/* ************************** TRACKBALL *************************** */
-void initTrackball(TransInfo *t)
+void initTrackball(TransInfo *t)
{
t->mode = TFM_TRACKBALL;
t->transform = Trackball;
-
+
initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL);
-
+
t->ndof.axis = 40;
/* Scale down input for rotation */
t->ndof.factor[0] = 0.2f;
@@ -2975,7 +2978,7 @@ void initTrackball(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = (float)((5.0/180)*M_PI);
t->snap[2] = t->snap[1] * 0.2f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
@@ -2987,7 +2990,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
VecRotToMat3(axis1, angles[0], smat);
VecRotToMat3(axis2, angles[1], totmat);
-
+
Mat3MulMat3(mat, smat, totmat);
for(i = 0 ; i < t->total; i++, td++) {
@@ -2996,46 +2999,46 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
if (td->flag & TD_SKIP)
continue;
-
+
if (t->flag & T_PROP_EDIT) {
VecRotToMat3(axis1, td->factor * angles[0], smat);
VecRotToMat3(axis2, td->factor * angles[1], totmat);
-
+
Mat3MulMat3(mat, smat, totmat);
}
-
+
ElementRotation(t, td, mat, t->around);
}
}
-int Trackball(TransInfo *t, short mval[2])
+int Trackball(TransInfo *t, short mval[2])
{
char str[128];
float axis1[3], axis2[3];
float mat[3][3], totmat[3][3], smat[3][3];
float phi[2];
-
+
VECCOPY(axis1, t->persinv[0]);
VECCOPY(axis2, t->persinv[1]);
Normalize(axis1);
Normalize(axis2);
-
+
phi[0] = t->values[0];
phi[1] = t->values[1];
-
+
applyNDofInput(&t->ndof, phi);
-
+
snapGrid(t, phi);
-
+
if (hasNumInput(&t->num)) {
char c[40];
-
+
applyNumInput(&t->num, phi);
-
+
outputNumInput(&(t->num), c);
-
+
sprintf(str, "Trackball: %s %s %s", &c[0], &c[20], t->proptext);
-
+
phi[0] *= (float)(M_PI / 180.0);
phi[1] *= (float)(M_PI / 180.0);
}
@@ -3045,34 +3048,34 @@ int Trackball(TransInfo *t, short mval[2])
VecRotToMat3(axis1, phi[0], smat);
VecRotToMat3(axis2, phi[1], totmat);
-
+
Mat3MulMat3(mat, smat, totmat);
-
+
// TRANSFORM_FIX_ME
//Mat3CpyMat3(t->mat, mat); // used in manipulator
-
+
applyTrackball(t, axis1, axis2, phi);
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
/* ************************** TRANSLATION *************************** */
-
-void initTranslation(TransInfo *t)
+
+void initTranslation(TransInfo *t)
{
t->mode = TFM_TRANSLATION;
t->transform = Translation;
-
+
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
t->idx_max = (t->flag & T_2D_EDIT)? 1: 2;
t->num.flag = 0;
t->num.idx_max = t->idx_max;
-
+
t->ndof.axis = (t->flag & T_2D_EDIT)? 1|2: 1|2|4;
if(t->spacetype == SPACE_VIEW3D) {
@@ -3098,7 +3101,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
char distvec[20];
char autoik[20];
float dist;
-
+
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
dist = VecLength(t->num.val);
@@ -3119,10 +3122,10 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
sprintf(distvec, "%.4e", dist);
else
sprintf(distvec, "%.4f", dist);
-
+
if(t->flag & T_AUTOIK) {
short chainlen= t->settings->autoik_chainlen;
-
+
if(chainlen)
sprintf(autoik, "AutoIK-Len: %d", chainlen);
else
@@ -3159,10 +3162,10 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
-
+
if (td->flag & TD_SKIP)
continue;
-
+
/* handle snapping rotation before doing the translation */
if (usingSnappingNormal(t))
{
@@ -3173,22 +3176,22 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
float quat[4];
float mat[3][3];
float angle;
-
+
Crossf(axis, original_normal, t->tsnap.snapNormal);
angle = saacos(Inpf(original_normal, t->tsnap.snapNormal));
-
+
AxisAngleToQuat(quat, axis, angle);
-
+
QuatToMat3(quat, mat);
-
+
ElementRotation(t, td, mat, V3D_LOCAL);
}
else
{
float mat[3][3];
-
+
Mat3One(mat);
-
+
ElementRotation(t, td, mat, V3D_LOCAL);
}
}
@@ -3200,12 +3203,12 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
else {
VECCOPY(tvec, vec);
}
-
+
Mat3MulVecfl(td->smtx, tvec);
VecMulf(tvec, td->factor);
-
+
protectedTransBits(td->protectflag, tvec);
-
+
/* transdata ipokey */
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
@@ -3214,17 +3217,17 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
add_tdi_poin(tdi->locz, tdi->oldloc+2, tvec[2]);
}
else VecAddf(td->loc, td->iloc, tvec);
-
+
constraintTransLim(t, td);
}
}
/* uses t->vec to store actual translation in */
-int Translation(TransInfo *t, short mval[2])
+int Translation(TransInfo *t, short mval[2])
{
float tvec[3];
char str[250];
-
+
if (t->con.mode & CON_APPLY) {
float pvec[3] = {0.0f, 0.0f, 0.0f};
applySnapping(t, t->values);
@@ -3240,11 +3243,11 @@ int Translation(TransInfo *t, short mval[2])
{
removeAspectRatio(t, t->values);
}
-
+
applySnapping(t, t->values);
headerTranslation(t, t->values, str);
}
-
+
applyTranslation(t, t->values);
/* evil hack - redo translation if clipping needed */
@@ -3260,7 +3263,7 @@ int Translation(TransInfo *t, short mval[2])
/* ************************** SHRINK/FATTEN *************************** */
-void initShrinkFatten(TransInfo *t)
+void initShrinkFatten(TransInfo *t)
{
// If not in mesh edit mode, fallback to Resize
if (t->obedit==NULL || t->obedit->type != OB_MESH) {
@@ -3269,22 +3272,22 @@ void initShrinkFatten(TransInfo *t)
else {
t->mode = TFM_SHRINKFATTEN;
t->transform = ShrinkFatten;
-
+
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 1.0f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
}
-int ShrinkFatten(TransInfo *t, short mval[2])
+int ShrinkFatten(TransInfo *t, short mval[2])
{
float vec[3];
float distance;
@@ -3310,8 +3313,8 @@ int ShrinkFatten(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "Shrink/Fatten: %.4f %s", distance, t->proptext);
}
-
-
+
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3335,11 +3338,11 @@ int ShrinkFatten(TransInfo *t, short mval[2])
/* ************************** TILT *************************** */
-void initTilt(TransInfo *t)
+void initTilt(TransInfo *t)
{
t->mode = TFM_TILT;
t->transform = Tilt;
-
+
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
t->ndof.axis = 16;
@@ -3351,13 +3354,13 @@ void initTilt(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = (float)((5.0/180)*M_PI);
t->snap[2] = t->snap[1] * 0.2f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int Tilt(TransInfo *t, short mval[2])
+int Tilt(TransInfo *t, short mval[2])
{
TransData *td = t->data;
int i;
@@ -3366,7 +3369,7 @@ int Tilt(TransInfo *t, short mval[2])
float final;
final = t->values[0];
-
+
applyNDofInput(&t->ndof, &final);
snapGrid(t, &final);
@@ -3412,72 +3415,72 @@ void initCurveShrinkFatten(TransInfo *t)
{
t->mode = TFM_CURVE_SHRINKFATTEN;
t->transform = CurveShrinkFatten;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int CurveShrinkFatten(TransInfo *t, short mval[2])
+int CurveShrinkFatten(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float ratio;
int i;
char str[50];
-
+
ratio = t->values[0];
-
+
snapGrid(t, &ratio);
-
+
applyNumInput(&t->num, &ratio);
-
+
/* header print for NumInput */
if (hasNumInput(&t->num)) {
char c[20];
-
+
outputNumInput(&(t->num), c);
sprintf(str, "Shrink/Fatten: %s", c);
}
else {
sprintf(str, "Shrink/Fatten: %3f", ratio);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
if(td->val) {
//*td->val= ratio;
*td->val= td->ival*ratio;
if (*td->val <= 0.0f) *td->val = 0.0001f;
}
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
/* ************************** PUSH/PULL *************************** */
-void initPushPull(TransInfo *t)
+void initPushPull(TransInfo *t)
{
t->mode = TFM_PUSHPULL;
t->transform = PushPull;
-
+
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
-
+
t->ndof.axis = 4;
/* Flip direction */
t->ndof.factor[0] = -1.0f;
@@ -3490,7 +3493,7 @@ void initPushPull(TransInfo *t)
}
-int PushPull(TransInfo *t, short mval[2])
+int PushPull(TransInfo *t, short mval[2])
{
float vec[3], axis[3];
float distance;
@@ -3499,7 +3502,7 @@ int PushPull(TransInfo *t, short mval[2])
TransData *td = t->data;
distance = t->values[0];
-
+
applyNDofInput(&t->ndof, &distance);
snapGrid(t, &distance);
@@ -3518,11 +3521,11 @@ int PushPull(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "Push/Pull: %.4f%s %s", distance, t->con.text, t->proptext);
}
-
+
if (t->con.applyRot && t->con.mode & CON_APPLY) {
t->con.applyRot(t, NULL, axis, NULL);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3558,11 +3561,11 @@ int PushPull(TransInfo *t, short mval[2])
/* ************************** BEVEL **************************** */
-void initBevel(TransInfo *t)
+void initBevel(TransInfo *t)
{
t->transform = Bevel;
t->handleEvent = handleEventBevel;
-
+
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
t->mode = TFM_BEVEL;
@@ -3631,7 +3634,7 @@ int Bevel(TransInfo *t, short mval[2])
mode = (G.editBMesh->options & BME_BEVEL_VERT) ? "verts only" : "normal";
distance = t->values[0] / 4; /* 4 just seemed a nice value to me, nothing special */
-
+
distance = fabs(distance);
snapGrid(t, &distance);
@@ -3650,7 +3653,7 @@ int Bevel(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "Bevel - Dist: %.4f, Mode: %s (MMB to toggle))", distance, mode);
}
-
+
if (distance < 0) distance = -distance;
for(i = 0 ; i < t->total; i++, td++) {
if (td->axismtx[1][0] > 0 && distance > td->axismtx[1][0]) {
@@ -3671,23 +3674,23 @@ int Bevel(TransInfo *t, short mval[2])
/* ************************** BEVEL WEIGHT *************************** */
-void initBevelWeight(TransInfo *t)
+void initBevelWeight(TransInfo *t)
{
t->mode = TFM_BWEIGHT;
t->transform = BevelWeight;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int BevelWeight(TransInfo *t, short mval[2])
+int BevelWeight(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float weight;
@@ -3721,7 +3724,7 @@ int BevelWeight(TransInfo *t, short mval[2])
else
sprintf(str, "Bevel Weight: %.3f %s", weight, t->proptext);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3742,23 +3745,23 @@ int BevelWeight(TransInfo *t, short mval[2])
/* ************************** CREASE *************************** */
-void initCrease(TransInfo *t)
+void initCrease(TransInfo *t)
{
t->mode = TFM_CREASE;
t->transform = Crease;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int Crease(TransInfo *t, short mval[2])
+int Crease(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float crease;
@@ -3792,7 +3795,7 @@ int Crease(TransInfo *t, short mval[2])
else
sprintf(str, "Crease: %.3f %s", crease, t->proptext);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3820,9 +3823,9 @@ void initBoneSize(TransInfo *t)
{
t->mode = TFM_BONESIZE;
t->transform = BoneSize;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
-
+
t->idx_max = 2;
t->num.idx_max = 2;
t->num.flag |= NUM_NULL_ONE;
@@ -3846,7 +3849,7 @@ static void headerBoneSize(TransInfo *t, float vec[3], char *str) {
if (t->con.mode & CON_APPLY) {
if (t->num.idx_max == 0)
sprintf(str, "ScaleB: %s%s %s", &tvec[0], t->con.text, t->proptext);
- else
+ else
sprintf(str, "ScaleB: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
}
else {
@@ -3854,18 +3857,18 @@ static void headerBoneSize(TransInfo *t, float vec[3], char *str) {
}
}
-static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
+static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
{
float tmat[3][3], smat[3][3], oldy;
float sizemat[3][3];
-
+
Mat3MulMat3(smat, mat, td->mtx);
Mat3MulMat3(tmat, td->smtx, smat);
-
+
if (t->con.applySize) {
t->con.applySize(t, td, tmat);
}
-
+
/* we've tucked the scale in loc */
oldy= td->iloc[1];
SizeToMat3(td->iloc, sizemat);
@@ -3874,14 +3877,14 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
td->loc[1]= oldy;
}
-int BoneSize(TransInfo *t, short mval[2])
+int BoneSize(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float size[3], mat[3][3];
float ratio;
int i;
char str[60];
-
+
// TRANSFORM_FIX_ME MOVE TO MOUSE INPUT
/* for manipulator, center handle, the scaling can't be done relative to center */
if( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0)
@@ -3892,40 +3895,40 @@ int BoneSize(TransInfo *t, short mval[2])
{
ratio = t->values[0];
}
-
+
size[0] = size[1] = size[2] = ratio;
-
+
snapGrid(t, size);
-
+
if (hasNumInput(&t->num)) {
applyNumInput(&t->num, size);
constraintNumInput(t, size);
}
-
+
SizeToMat3(size, mat);
-
+
if (t->con.applySize) {
t->con.applySize(t, NULL, mat);
}
-
+
Mat3CpyMat3(t->mat, mat); // used in manipulator
-
+
headerBoneSize(t, size, str);
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
ElementBoneSize(t, td, mat);
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
@@ -3936,9 +3939,9 @@ void initBoneEnvelope(TransInfo *t)
{
t->mode = TFM_BONE_ENVELOPE;
t->transform = BoneEnvelope;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
@@ -3948,37 +3951,37 @@ void initBoneEnvelope(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
}
-int BoneEnvelope(TransInfo *t, short mval[2])
+int BoneEnvelope(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float ratio;
int i;
char str[50];
-
+
ratio = t->values[0];
-
+
snapGrid(t, &ratio);
-
+
applyNumInput(&t->num, &ratio);
-
+
/* header print for NumInput */
if (hasNumInput(&t->num)) {
char c[20];
-
+
outputNumInput(&(t->num), c);
sprintf(str, "Envelope: %s", c);
}
else {
sprintf(str, "Envelope: %3f", ratio);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
if (td->val) {
/* if the old/original value was 0.0f, then just use ratio */
if (td->ival)
@@ -3987,11 +3990,11 @@ int BoneEnvelope(TransInfo *t, short mval[2])
*td->val= ratio;
}
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
@@ -4002,7 +4005,7 @@ void initBoneRoll(TransInfo *t)
{
t->mode = TFM_BONE_ROLL;
t->transform = BoneRoll;
-
+
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
t->idx_max = 0;
@@ -4010,11 +4013,11 @@ void initBoneRoll(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = (float)((5.0/180)*M_PI);
t->snap[2] = t->snap[1] * 0.2f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int BoneRoll(TransInfo *t, short mval[2])
+int BoneRoll(TransInfo *t, short mval[2])
{
TransData *td = t->data;
int i;
@@ -4040,18 +4043,18 @@ int BoneRoll(TransInfo *t, short mval[2])
else {
sprintf(str, "Roll: %.2f", 180.0*final/M_PI);
}
-
+
/* set roll values */
- for (i = 0; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
*(td->val) = td->ival - final;
}
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -4061,11 +4064,11 @@ int BoneRoll(TransInfo *t, short mval[2])
/* ************************** BAKE TIME ******************* */
-void initBakeTime(TransInfo *t)
+void initBakeTime(TransInfo *t)
{
t->transform = BakeTime;
initMouseInputMode(t, &t->mouse, INPUT_NONE);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
@@ -4073,15 +4076,15 @@ void initBakeTime(TransInfo *t)
t->snap[2] = t->snap[1] * 0.1f;
}
-int BakeTime(TransInfo *t, short mval[2])
+int BakeTime(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float time;
int i;
char str[50];
-
+
float fac = 0.1f;
-
+
if(t->mouse.precision) {
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
time= (float)(t->center2d[0] - t->mouse.precision_mval[0]) * fac;
@@ -4113,7 +4116,7 @@ int BakeTime(TransInfo *t, short mval[2])
else
sprintf(str, "Time: %.3f %s", time, t->proptext);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4137,7 +4140,7 @@ int BakeTime(TransInfo *t, short mval[2])
/* ************************** MIRROR *************************** */
-void initMirror(TransInfo *t)
+void initMirror(TransInfo *t)
{
t->transform = Mirror;
initMouseInputMode(t, &t->mouse, INPUT_NONE);
@@ -4148,7 +4151,7 @@ void initMirror(TransInfo *t)
}
}
-int Mirror(TransInfo *t, short mval[2])
+int Mirror(TransInfo *t, short mval[2])
{
TransData *td;
float size[3], mat[3][3];
@@ -4164,47 +4167,47 @@ int Mirror(TransInfo *t, short mval[2])
/* if an axis has been selected */
if (t->con.mode & CON_APPLY) {
size[0] = size[1] = size[2] = -1;
-
+
SizeToMat3(size, mat);
-
+
if (t->con.applySize) {
t->con.applySize(t, NULL, mat);
}
-
+
sprintf(str, "Mirror%s", t->con.text);
-
+
for(i = 0, td=t->data; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
-
+
if (td->flag & TD_SKIP)
continue;
-
+
ElementResize(t, td, mat);
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
}
else
{
size[0] = size[1] = size[2] = 1;
-
+
SizeToMat3(size, mat);
-
+
for(i = 0, td=t->data; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
-
+
if (td->flag & TD_SKIP)
continue;
-
+
ElementResize(t, td, mat);
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, "Select a mirror axis (X, Y, Z)");
}
@@ -4213,12 +4216,12 @@ int Mirror(TransInfo *t, short mval[2])
/* ************************** ALIGN *************************** */
-void initAlign(TransInfo *t)
+void initAlign(TransInfo *t)
{
t->flag |= T_NO_CONSTRAINT;
-
+
t->transform = Align;
-
+
initMouseInputMode(t, &t->mouse, INPUT_NONE);
}
@@ -4234,13 +4237,13 @@ int Align(TransInfo *t, short mval[2])
for(i = 0 ; i < t->total; i++, td++)
{
float mat[3][3], invmat[3][3];
-
+
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
/* around local centers */
if (t->flag & (T_OBJECT|T_POSE)) {
VECCOPY(t->center, td->center);
@@ -4252,19 +4255,19 @@ int Align(TransInfo *t, short mval[2])
}
Mat3Inv(invmat, td->axismtx);
-
- Mat3MulMat3(mat, t->spacemtx, invmat);
+
+ Mat3MulMat3(mat, t->spacemtx, invmat);
ElementRotation(t, td, mat, t->around);
}
/* restoring original center */
VECCOPY(t->center, center);
-
+
recalcData(t);
ED_area_headerprint(t->sa, "Align");
-
+
return 1;
}
@@ -4273,37 +4276,37 @@ int Align(TransInfo *t, short mval[2])
/* ---------------- Special Helpers for Various Settings ------------- */
-/* This function returns the snapping 'mode' for Animation Editors only
+/* This function returns the snapping 'mode' for Animation Editors only
* We cannot use the standard snapping due to NLA-strip scaling complexities.
*/
// XXX these modifier checks should be keymappable
static short getAnimEdit_SnapMode(TransInfo *t)
{
short autosnap= SACTSNAP_OFF;
-
+
/* currently, some of these are only for the action editor */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-
+
if (saction)
autosnap= saction->autosnap;
}
else if (t->spacetype == SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
-
+
if (sipo)
autosnap= sipo->autosnap;
}
else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
-
+
if (snla)
autosnap= snla->autosnap;
}
else {
// TRANSFORM_FIX_ME This needs to use proper defines for t->modifiers
// // FIXME: this still toggles the modes...
-// if (ctrl)
+// if (ctrl)
// autosnap= SACTSNAP_STEP;
// else if (shift)
// autosnap= SACTSNAP_FRAME;
@@ -4312,38 +4315,38 @@ static short getAnimEdit_SnapMode(TransInfo *t)
// else
autosnap= SACTSNAP_OFF;
}
-
+
return autosnap;
}
/* This function is used for testing if an Animation Editor is displaying
* its data in frames or seconds (and the data needing to be edited as such).
- * Returns 1 if in seconds, 0 if in frames
+ * Returns 1 if in seconds, 0 if in frames
*/
static short getAnimEdit_DrawTime(TransInfo *t)
{
short drawtime;
-
+
/* currently, some of these are only for the action editor */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-
+
drawtime = (saction->flag & SACTION_DRAWTIME)? 1 : 0;
}
else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
-
+
drawtime = (snla->flag & SNLA_DRAWTIME)? 1 : 0;
}
else {
drawtime = 0;
}
-
+
return drawtime;
-}
+}
-/* This function is used by Animation Editor specific transform functions to do
+/* This function is used by Animation Editor specific transform functions to do
* the Snap Keyframe to Nearest Frame/Marker
*/
static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, short autosnap)
@@ -4354,19 +4357,19 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, sho
const short doTime= getAnimEdit_DrawTime(t);
const double secf= FPS;
double val;
-
+
/* convert frame to nla-action time (if needed) */
- if (adt)
+ if (adt)
val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
else
val= *(td->val);
-
+
/* do the snapping to nearest frame/second */
if (doTime)
val= (float)( floor((val/secf) + 0.5f) * secf );
else
val= (float)( floor(val+0.5f) );
-
+
/* convert frame out of nla-action time */
if (adt)
*(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
@@ -4376,17 +4379,17 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, sho
/* snap key to nearest marker? */
else if (autosnap == SACTSNAP_MARKER) {
float val;
-
+
/* convert frame to nla-action time (if needed) */
- if (adt)
+ if (adt)
val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
else
val= *(td->val);
-
+
/* snap to nearest marker */
// TODO: need some more careful checks for where data comes from
val= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val);
-
+
/* convert frame out of nla-action time */
if (adt)
*(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
@@ -4397,27 +4400,27 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, sho
/* ----------------- Translation ----------------------- */
-void initTimeTranslate(TransInfo *t)
+void initTimeTranslate(TransInfo *t)
{
t->mode = TFM_TIME_TRANSLATE;
t->transform = TimeTranslate;
-
+
initMouseInputMode(t, &t->mouse, INPUT_NONE);
/* num-input has max of (n-1) */
t->idx_max = 0;
t->num.flag = 0;
t->num.idx_max = t->idx_max;
-
+
/* initialise snap like for everything else */
- t->snap[0] = 0.0f;
+ t->snap[0] = 0.0f;
t->snap[1] = t->snap[2] = 1.0f;
}
-static void headerTimeTranslate(TransInfo *t, char *str)
+static void headerTimeTranslate(TransInfo *t, char *str)
{
char tvec[60];
-
+
/* if numeric input is active, use results from that, otherwise apply snapping to result */
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
@@ -4428,7 +4431,7 @@ static void headerTimeTranslate(TransInfo *t, char *str)
const short doTime = getAnimEdit_DrawTime(t);
const double secf= FPS;
float val = t->values[0];
-
+
/* apply snapping + frame->seconds conversions */
if (autosnap == SACTSNAP_STEP) {
if (doTime)
@@ -4440,86 +4443,86 @@ static void headerTimeTranslate(TransInfo *t, char *str)
if (doTime)
val= val / secf;
}
-
+
sprintf(&tvec[0], "%.4f", val);
}
-
+
sprintf(str, "DeltaX: %s", &tvec[0]);
}
-static void applyTimeTranslate(TransInfo *t, float sval)
+static void applyTimeTranslate(TransInfo *t, float sval)
{
TransData *td = t->data;
Scene *scene = t->scene;
int i;
-
+
const short doTime= getAnimEdit_DrawTime(t);
const double secf= FPS;
-
+
const short autosnap= getAnimEdit_SnapMode(t);
-
+
float deltax, val;
-
+
/* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
for (i = 0 ; i < t->total; i++, td++) {
/* it is assumed that td->extra is a pointer to the AnimData,
- * whose active action is where this keyframe comes from
+ * whose active action is where this keyframe comes from
* (this is only valid when not in NLA)
*/
AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
-
+
/* check if any need to apply nla-mapping */
if (adt) {
deltax = t->values[0];
-
+
if (autosnap == SACTSNAP_STEP) {
- if (doTime)
+ if (doTime)
deltax= (float)( floor((deltax/secf) + 0.5f) * secf );
else
deltax= (float)( floor(deltax + 0.5f) );
}
-
+
val = BKE_nla_tweakedit_remap(adt, td->ival, NLATIME_CONVERT_MAP);
val += deltax;
*(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
}
else {
deltax = val = t->values[0];
-
+
if (autosnap == SACTSNAP_STEP) {
if (doTime)
val= (float)( floor((deltax/secf) + 0.5f) * secf );
else
val= (float)( floor(val + 0.5f) );
}
-
+
*(td->val) = td->ival + val;
}
-
+
/* apply nearest snapping */
doAnimEdit_SnapFrame(t, td, adt, autosnap);
}
}
-int TimeTranslate(TransInfo *t, short mval[2])
+int TimeTranslate(TransInfo *t, short mval[2])
{
View2D *v2d = (View2D *)t->view;
float cval[2], sval[2];
char str[200];
-
+
/* calculate translation amount from mouse movement - in 'time-grid space' */
UI_view2d_region_to_view(v2d, mval[0], mval[0], &cval[0], &cval[1]);
UI_view2d_region_to_view(v2d, t->imval[0], t->imval[0], &sval[0], &sval[1]);
-
+
/* we only need to calculate effect for time (applyTimeTranslate only needs that) */
t->values[0] = cval[0] - sval[0];
-
+
/* handle numeric-input stuff */
t->vec[0] = t->values[0];
applyNumInput(&t->num, &t->vec[0]);
t->values[0] = t->vec[0];
headerTimeTranslate(t, str);
-
+
applyTimeTranslate(t, sval[0]);
recalcData(t);
@@ -4531,36 +4534,36 @@ int TimeTranslate(TransInfo *t, short mval[2])
/* ----------------- Time Slide ----------------------- */
-void initTimeSlide(TransInfo *t)
+void initTimeSlide(TransInfo *t)
{
/* this tool is only really available in the Action Editor... */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-
+
/* set flag for drawing stuff */
saction->flag |= SACTION_MOVING;
}
-
+
t->mode = TFM_TIME_SLIDE;
t->transform = TimeSlide;
t->flag |= T_FREE_CUSTOMDATA;
-
+
initMouseInputMode(t, &t->mouse, INPUT_NONE);
/* num-input has max of (n-1) */
t->idx_max = 0;
t->num.flag = 0;
t->num.idx_max = t->idx_max;
-
+
/* initialise snap like for everything else */
- t->snap[0] = 0.0f;
+ t->snap[0] = 0.0f;
t->snap[1] = t->snap[2] = 1.0f;
}
-static void headerTimeSlide(TransInfo *t, float sval, char *str)
+static void headerTimeSlide(TransInfo *t, float sval, char *str)
{
char tvec[60];
-
+
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
}
@@ -4569,50 +4572,50 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str)
float maxx= *((float *)(t->customData) + 1);
float cval= t->values[0];
float val;
-
+
val= 2.0f*(cval-sval) / (maxx-minx);
CLAMP(val, -1.0f, 1.0f);
-
+
sprintf(&tvec[0], "%.4f", val);
}
-
+
sprintf(str, "TimeSlide: %s", &tvec[0]);
}
-static void applyTimeSlide(TransInfo *t, float sval)
+static void applyTimeSlide(TransInfo *t, float sval)
{
TransData *td = t->data;
int i;
-
+
float minx= *((float *)(t->customData));
float maxx= *((float *)(t->customData) + 1);
-
+
/* set value for drawing black line */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
float cvalf = t->values[0];
-
+
saction->timeslide= cvalf;
}
-
+
/* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
for (i = 0 ; i < t->total; i++, td++) {
/* it is assumed that td->extra is a pointer to the AnimData,
- * whose active action is where this keyframe comes from
+ * whose active action is where this keyframe comes from
* (this is only valid when not in NLA)
*/
AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
float cval = t->values[0];
-
+
/* apply NLA-mapping to necessary values */
if (adt)
cval= BKE_nla_tweakedit_remap(adt, cval, NLATIME_CONVERT_UNMAP);
-
+
/* only apply to data if in range */
if ((sval > minx) && (sval < maxx)) {
float cvalc= CLAMPIS(cval, minx, maxx);
float timefac;
-
+
/* left half? */
if (td->ival < sval) {
timefac= (sval - td->ival) / (sval - minx);
@@ -4626,26 +4629,26 @@ static void applyTimeSlide(TransInfo *t, float sval)
}
}
-int TimeSlide(TransInfo *t, short mval[2])
+int TimeSlide(TransInfo *t, short mval[2])
{
View2D *v2d = (View2D *)t->view;
float cval[2], sval[2];
float minx= *((float *)(t->customData));
float maxx= *((float *)(t->customData) + 1);
char str[200];
-
+
/* calculate mouse co-ordinates */
UI_view2d_region_to_view(v2d, mval[0], mval[0], &cval[0], &cval[1]);
UI_view2d_region_to_view(v2d, t->imval[0], t->imval[0], &sval[0], &sval[1]);
-
+
/* t->values[0] stores cval[0], which is the current mouse-pointer location (in frames) */
t->values[0] = cval[0];
-
+
/* handle numeric-input stuff */
t->vec[0] = 2.0f*(cval[0]-sval[0]) / (maxx-minx);
applyNumInput(&t->num, &t->vec[0]);
t->values[0] = (maxx-minx) * t->vec[0] / 2.0 + sval[0];
-
+
headerTimeSlide(t, sval[0], str);
applyTimeSlide(t, sval[0]);
@@ -4658,35 +4661,35 @@ int TimeSlide(TransInfo *t, short mval[2])
/* ----------------- Scaling ----------------------- */
-void initTimeScale(TransInfo *t)
+void initTimeScale(TransInfo *t)
{
t->mode = TFM_TIME_SCALE;
t->transform = TimeScale;
-
+
initMouseInputMode(t, &t->mouse, INPUT_NONE);
t->helpline = HLP_SPRING; /* set manually because we don't use a predefined input */
t->flag |= T_NULL_ONE;
t->num.flag |= NUM_NULL_ONE;
-
+
/* num-input has max of (n-1) */
t->idx_max = 0;
t->num.flag = 0;
t->num.idx_max = t->idx_max;
-
+
/* initialise snap like for everything else */
- t->snap[0] = 0.0f;
+ t->snap[0] = 0.0f;
t->snap[1] = t->snap[2] = 1.0f;
}
static void headerTimeScale(TransInfo *t, char *str) {
char tvec[60];
-
+
if (hasNumInput(&t->num))
outputNumInput(&(t->num), tvec);
else
sprintf(&tvec[0], "%.4f", t->values[0]);
-
+
sprintf(str, "ScaleX: %s", &tvec[0]);
}
@@ -4694,63 +4697,63 @@ static void applyTimeScale(TransInfo *t) {
Scene *scene = t->scene;
TransData *td = t->data;
int i;
-
+
const short autosnap= getAnimEdit_SnapMode(t);
const short doTime= getAnimEdit_DrawTime(t);
const double secf= FPS;
-
-
+
+
for (i = 0 ; i < t->total; i++, td++) {
/* it is assumed that td->extra is a pointer to the AnimData,
- * whose active action is where this keyframe comes from
+ * whose active action is where this keyframe comes from
* (this is only valid when not in NLA)
*/
AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
float startx= CFRA;
float fac= t->values[0];
-
+
if (autosnap == SACTSNAP_STEP) {
if (doTime)
fac= (float)( floor(fac/secf + 0.5f) * secf );
else
fac= (float)( floor(fac + 0.5f) );
}
-
+
/* check if any need to apply nla-mapping */
if (adt)
startx= BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
-
+
/* now, calculate the new value */
*(td->val) = td->ival - startx;
*(td->val) *= fac;
*(td->val) += startx;
-
+
/* apply nearest snapping */
doAnimEdit_SnapFrame(t, td, adt, autosnap);
}
}
-int TimeScale(TransInfo *t, short mval[2])
+int TimeScale(TransInfo *t, short mval[2])
{
float cval, sval;
float deltax, startx;
float width= 0.0f;
char str[200];
-
+
sval= t->imval[0];
cval= mval[0];
-
+
/* calculate scaling factor */
startx= sval-(width/2+(t->ar->winx)/2);
deltax= cval-(width/2+(t->ar->winx)/2);
t->values[0] = deltax / startx;
-
+
/* handle numeric-input stuff */
t->vec[0] = t->values[0];
applyNumInput(&t->num, &t->vec[0]);
t->values[0] = t->vec[0];
headerTimeScale(t, str);
-
+
applyTimeScale(t);
recalcData(t);
@@ -4789,7 +4792,7 @@ void NDofTransform()
maxval = val;
}
}
-
+
switch(axis)
{
case -1:
@@ -4810,7 +4813,7 @@ void NDofTransform()
default:
printf("ndof: what we are doing here ?");
}
-
+
if (mode != 0)
{
initTransform(mode, CTX_NDOF);
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 74cf1df1fa5..ed825886a05 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -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);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 7f47bfd25af..158ea98c090 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -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,20 +682,9 @@ 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);
+ glPopMatrix();
}
- else
- center[0] = center[1] = center[2] = 0.0f;
}
static void drawObjectConstraint(TransInfo *t) {
@@ -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
*/
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 47f9159d87f..60d209ae2db 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -216,7 +216,7 @@ void sort_trans_data_dist(TransInfo *t) {
qsort_trans_data(t, start, t->data + t->total - 1);
}
-static void sort_trans_data(TransInfo *t)
+static void sort_trans_data(TransInfo *t)
{
TransData *sel, *unsel;
TransData temp;
@@ -252,16 +252,16 @@ static void set_prop_dist(TransInfo *t, short with_dist)
int a;
for(a=0, tob= t->data; a<t->total; a++, tob++) {
-
+
tob->rdist= 0.0f; // init, it was mallocced
-
+
if((tob->flag & TD_SELECTED)==0) {
TransData *td;
int i;
float dist, vec[3];
tob->rdist = -1.0f; // signal for next loop
-
+
for (i = 0, td= t->data; i < t->total; i++, td++) {
if(td->flag & TD_SELECTED) {
VecSubf(vec, tob->center, td->center);
@@ -279,7 +279,7 @@ static void set_prop_dist(TransInfo *t, short with_dist)
if (with_dist) {
tob->dist = tob->rdist;
}
- }
+ }
}
}
@@ -294,9 +294,9 @@ static void createTransTexspace(bContext *C, TransInfo *t)
Object *ob;
ID *id;
int *texflag;
-
+
ob = OBACT;
-
+
if (ob == NULL) { // Shouldn't logically happen, but still...
t->total = 0;
return;
@@ -311,20 +311,20 @@ static void createTransTexspace(bContext *C, TransInfo *t)
t->total = 1;
td= t->data= MEM_callocN(sizeof(TransData), "TransTexspace");
td->ext= t->ext= MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
-
+
td->flag= TD_SELECTED;
VECCOPY(td->center, ob->obmat[3]);
td->ob = ob;
-
+
Mat3CpyMat4(td->mtx, ob->obmat);
Mat3CpyMat4(td->axismtx, ob->obmat);
Mat3Ortho(td->axismtx);
Mat3Inv(td->smtx, td->mtx);
-
+
if (give_obdata_texspace(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) {
*texflag &= ~AUTOSPACE;
}
-
+
VECCOPY(td->iloc, td->loc);
VECCOPY(td->ext->irot, td->ext->rot);
VECCOPY(td->ext->isize, td->ext->size);
@@ -371,7 +371,7 @@ static void createTransEdge(bContext *C, TransInfo *t) {
td->loc= NULL;
if (eed->f & SELECT)
td->flag= TD_SELECTED;
- else
+ else
td->flag= 0;
@@ -400,14 +400,14 @@ static void createTransEdge(bContext *C, TransInfo *t) {
static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan)
{
bConstraint *con= pchan->constraints.first;
-
+
for(;con; con= con->next) {
if(con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0)) {
bKinematicConstraint *data= con->data;
-
- if(data->tar==NULL)
+
+ if(data->tar==NULL)
return data;
- if(data->tar->type==OB_ARMATURE && data->subtarget[0]==0)
+ if(data->tar->type==OB_ARMATURE && data->subtarget[0]==0)
return data;
}
}
@@ -419,67 +419,67 @@ static short apply_targetless_ik(Object *ob)
bPoseChannel *pchan, *parchan, *chanlist[256];
bKinematicConstraint *data;
int segcount, apply= 0;
-
+
/* now we got a difficult situation... we have to find the
- target-less IK pchans, and apply transformation to the all
+ target-less IK pchans, and apply transformation to the all
pchans that were in the chain */
-
+
for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
data= has_targetless_ik(pchan);
if(data && (data->flag & CONSTRAINT_IK_AUTO)) {
-
+
/* fill the array with the bones of the chain (armature.c does same, keep it synced) */
segcount= 0;
-
+
/* exclude tip from chain? */
if(!(data->flag & CONSTRAINT_IK_TIP))
parchan= pchan->parent;
else
parchan= pchan;
-
+
/* Find the chain's root & count the segments needed */
for (; parchan; parchan=parchan->parent){
chanlist[segcount]= parchan;
segcount++;
-
+
if(segcount==data->rootbone || segcount>255) break; // 255 is weak
}
for(;segcount;segcount--) {
Bone *bone;
float rmat[4][4], tmat[4][4], imat[4][4];
-
+
/* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK */
/* we put in channel the entire result of rmat= (channel * constraint * IK) */
/* pose_mat(b) = pose_mat(b-1) * offs_bone * rmat */
/* rmat = pose_mat(b) * inv( pose_mat(b-1) * offs_bone ) */
-
+
parchan= chanlist[segcount-1];
bone= parchan->bone;
bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */
-
+
if(parchan->parent) {
Bone *parbone= parchan->parent->bone;
float offs_bone[4][4];
-
+
/* offs_bone = yoffs(b-1) + root(b) + bonemat(b) */
Mat4CpyMat3(offs_bone, bone->bone_mat);
-
+
/* The bone's root offset (is in the parent's coordinate system) */
VECCOPY(offs_bone[3], bone->head);
-
+
/* Get the length translation of parent (length along y axis) */
offs_bone[3][1]+= parbone->length;
-
+
/* pose_mat(b-1) * offs_bone */
if(parchan->bone->flag & BONE_HINGE) {
/* the rotation of the parent restposition */
Mat4CpyMat4(rmat, parbone->arm_mat); /* rmat used as temp */
-
+
/* the location of actual parent transform */
VECCOPY(rmat[3], offs_bone[3]);
offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
Mat4MulVecfl(parchan->parent->pose_mat, rmat[3]);
-
+
Mat4MulMat4(tmat, offs_bone, rmat);
}
else if(parchan->bone->flag & BONE_NO_SCALE) {
@@ -488,7 +488,7 @@ static short apply_targetless_ik(Object *ob)
}
else
Mat4MulMat4(tmat, offs_bone, parchan->parent->pose_mat);
-
+
Mat4Invert(imat, tmat);
}
else {
@@ -499,16 +499,16 @@ static short apply_targetless_ik(Object *ob)
}
/* result matrix */
Mat4MulMat4(rmat, parchan->pose_mat, imat);
-
+
/* apply and decompose, doesn't work for constraints or non-uniform scale well */
{
float rmat3[3][3], qmat[3][3], imat[3][3], smat[3][3];
-
+
Mat3CpyMat4(rmat3, rmat);
-
+
/* quaternion */
Mat3ToQuat(rmat3, parchan->quat);
-
+
/* for size, remove rotation */
/* causes problems with some constraints (so apply only if needed) */
if (data->flag & CONSTRAINT_IK_STRETCH) {
@@ -517,19 +517,19 @@ static short apply_targetless_ik(Object *ob)
Mat3MulMat3(smat, rmat3, imat);
Mat3ToSize(smat, parchan->size);
}
-
+
/* causes problems with some constraints (e.g. childof), so disable this */
/* as it is IK shouldn't affect location directly */
/* VECCOPY(parchan->loc, rmat[3]); */
}
-
+
}
-
+
apply= 1;
data->flag &= ~CONSTRAINT_IK_AUTO;
}
- }
-
+ }
+
return apply;
}
@@ -542,7 +542,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
VECCOPY(vec, pchan->pose_mat[3]);
VECCOPY(td->center, vec);
-
+
td->ob = ob;
td->flag = TD_SELECTED;
if (pchan->rotmode == PCHAN_ROT_QUAT)
@@ -553,43 +553,43 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
{
td->flag |= TD_NOCENTER;
}
-
+
if (bone->flag & BONE_TRANSFORM_CHILD)
{
td->flag |= TD_NOCENTER;
td->flag |= TD_NO_LOC;
}
-
+
td->protectflag= pchan->protectflag;
-
+
td->loc = pchan->loc;
VECCOPY(td->iloc, pchan->loc);
-
+
td->ext->size= pchan->size;
VECCOPY(td->ext->isize, pchan->size);
-
+
if (pchan->rotmode) {
td->ext->rot= pchan->eul;
td->ext->quat= NULL;
-
+
VECCOPY(td->ext->irot, pchan->eul);
}
else {
td->ext->rot= NULL;
td->ext->quat= pchan->quat;
-
+
QUATCOPY(td->ext->iquat, pchan->quat);
}
/* proper way to get parent transform + own transform + constraints transform */
Mat3CpyMat4(omat, ob->obmat);
-
- if (pchan->parent) {
- if(pchan->bone->flag & BONE_HINGE)
- Mat3CpyMat4(pmat, pchan->parent->bone->arm_mat);
- else
+
+ if (pchan->parent) {
+ if(pchan->bone->flag & BONE_HINGE)
+ Mat3CpyMat4(pmat, pchan->parent->bone->arm_mat);
+ else
Mat3CpyMat4(pmat, pchan->parent->pose_mat);
-
+
if (constraints_list_needinv(t, &pchan->constraints)) {
Mat3CpyMat4(tmat, pchan->constinv);
Mat3Inv(cmat, tmat);
@@ -604,20 +604,20 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
Mat3Inv(cmat, tmat);
Mat3MulSerie(td->mtx, pchan->bone->bone_mat, omat, cmat, 0,0,0,0,0); // dang mulserie swaps args
}
- else
- Mat3MulMat3(td->mtx, omat, pchan->bone->bone_mat); // Mat3MulMat3 has swapped args!
+ else
+ Mat3MulMat3(td->mtx, omat, pchan->bone->bone_mat); // Mat3MulMat3 has swapped args!
}
-
+
Mat3Inv(td->smtx, td->mtx);
-
+
/* for axismat we use bone's own transform */
Mat3CpyMat4(pmat, pchan->pose_mat);
Mat3MulMat3(td->axismtx, omat, pmat);
Mat3Ortho(td->axismtx);
-
+
if (t->mode==TFM_BONESIZE) {
bArmature *arm= t->poseobj->data;
-
+
if(arm->drawtype==ARM_ENVELOPE) {
td->loc= NULL;
td->val= &bone->dist;
@@ -630,7 +630,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
td->val= NULL;
}
}
-
+
/* in this case we can do target-less IK grabbing */
if (t->mode==TFM_TRANSLATION) {
bKinematicConstraint *data= has_targetless_ik(pchan);
@@ -644,27 +644,27 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
td->loc = data->grabtarget;
VECCOPY(td->iloc, td->loc);
data->flag |= CONSTRAINT_IK_AUTO;
-
+
/* only object matrix correction */
Mat3CpyMat3 (td->mtx, omat);
Mat3Inv (td->smtx, td->mtx);
}
}
-
+
/* store reference to first constraint */
td->con= pchan->constraints.first;
}
-static void bone_children_clear_transflag(TransInfo *t, ListBase *lb)
+static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
{
Bone *bone= lb->first;
-
+
for(;bone;bone= bone->next) {
if((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED))
{
bone->flag |= BONE_HINGE_CHILD_TRANSFORM;
}
- else if (bone->flag & BONE_TRANSFORM && (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL) && t->around == V3D_LOCAL)
+ else if (bone->flag & BONE_TRANSFORM && (mode == TFM_ROTATION || mode == TFM_TRACKBALL) && around == V3D_LOCAL)
{
bone->flag |= BONE_TRANSFORM_CHILD;
}
@@ -673,69 +673,73 @@ static void bone_children_clear_transflag(TransInfo *t, ListBase *lb)
bone->flag &= ~BONE_TRANSFORM;
}
- bone_children_clear_transflag(t, &bone->childbase);
+ bone_children_clear_transflag(mode, around, &bone->childbase);
}
}
/* sets transform flags in the bones, returns total */
-static void set_pose_transflags(TransInfo *t, Object *ob)
+int count_set_pose_transflags(int *out_mode, short around, Object *ob)
{
bArmature *arm= ob->data;
bPoseChannel *pchan;
Bone *bone;
- int hastranslation;
-
- t->total= 0;
-
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- bone= pchan->bone;
+ int mode = *out_mode;
+ int hastranslation = 0;
+ int total = 0;
+
+ for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ bone = pchan->bone;
if(bone->layer & arm->layer) {
if(bone->flag & BONE_SELECTED)
bone->flag |= BONE_TRANSFORM;
else
bone->flag &= ~BONE_TRANSFORM;
-
+
bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM;
bone->flag &= ~BONE_TRANSFORM_CHILD;
}
}
-
+
/* make sure no bone can be transformed when a parent is transformed */
/* since pchans are depsgraph sorted, the parents are in beginning of list */
- if(t->mode!=TFM_BONESIZE) {
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- bone= pchan->bone;
+ if(mode != TFM_BONESIZE) {
+ for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ bone = pchan->bone;
if(bone->flag & BONE_TRANSFORM)
- bone_children_clear_transflag(t, &bone->childbase);
+ bone_children_clear_transflag(mode, around, &bone->childbase);
}
- }
+ }
/* now count, and check if we have autoIK or have to switch from translate to rotate */
- hastranslation= 0;
+ hastranslation = 0;
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- bone= pchan->bone;
+ for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ bone = pchan->bone;
if(bone->flag & BONE_TRANSFORM) {
- t->total++;
-
- if(t->mode==TFM_TRANSLATION) {
+ total++;
+
+ if(mode == TFM_TRANSLATION) {
if( has_targetless_ik(pchan)==NULL ) {
if(pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) {
if(pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM)
- hastranslation= 1;
+ hastranslation = 1;
}
else if((pchan->protectflag & OB_LOCK_LOC)!=OB_LOCK_LOC)
- hastranslation= 1;
+ hastranslation = 1;
}
else
- hastranslation= 1;
+ hastranslation = 1;
}
}
}
/* if there are no translatable bones, do rotation */
- if(t->mode==TFM_TRANSLATION && !hastranslation)
- t->mode= TFM_ROTATION;
+ if(mode == TFM_TRANSLATION && !hastranslation)
+ {
+ *out_mode = TFM_ROTATION;
+ }
+
+ return total;
}
@@ -745,16 +749,16 @@ static void set_pose_transflags(TransInfo *t, Object *ob)
static void pchan_autoik_adjust (bPoseChannel *pchan, short chainlen)
{
bConstraint *con;
-
+
/* don't bother to search if no valid constraints */
if ((pchan->constflag & (PCHAN_HAS_IK|PCHAN_HAS_TARGET))==0)
return;
-
+
/* check if pchan has ik-constraint */
for (con= pchan->constraints.first; con; con= con->next) {
if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0)) {
bKinematicConstraint *data= con->data;
-
+
/* only accept if a temporary one (for auto-ik) */
if (data->flag & CONSTRAINT_IK_TEMP) {
/* chainlen is new chainlen, but is limited by maximum chainlen */
@@ -772,7 +776,7 @@ void transform_autoik_update (TransInfo *t, short mode)
{
short *chainlen= &t->settings->autoik_chainlen;
bPoseChannel *pchan;
-
+
/* mode determines what change to apply to chainlen */
if (mode == 1) {
/* mode=1 is from WHEELMOUSEDOWN... increases len */
@@ -782,15 +786,15 @@ void transform_autoik_update (TransInfo *t, short mode)
/* mode==-1 is from WHEELMOUSEUP... decreases len */
if (*chainlen > 0) (*chainlen)--;
}
-
+
/* sanity checks (don't assume t->poseobj is set, or that it is an armature) */
if (ELEM(NULL, t->poseobj, t->poseobj->pose))
return;
-
+
/* apply to all pose-channels */
for (pchan=t->poseobj->pose->chanbase.first; pchan; pchan=pchan->next) {
pchan_autoik_adjust(pchan, *chainlen);
- }
+ }
}
/* frees temporal IKs */
@@ -799,11 +803,11 @@ static void pose_grab_with_ik_clear(Object *ob)
bKinematicConstraint *data;
bPoseChannel *pchan;
bConstraint *con, *next;
-
+
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
/* clear all temporary lock flags */
pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP|BONE_IK_NO_YDOF_TEMP|BONE_IK_NO_ZDOF_TEMP);
-
+
pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_TARGET);
/* remove all temporary IK-constraints added */
for (con= pchan->constraints.first; con; con= next) {
@@ -830,11 +834,11 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
bKinematicConstraint *data;
bConstraint *con;
bConstraint *targetless = 0;
-
+
/* Sanity check */
- if (pchan == NULL)
+ if (pchan == NULL)
return 0;
-
+
/* Rule: not if there's already an IK on this channel */
for (con= pchan->constraints.first; con; con= con->next) {
if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
@@ -851,7 +855,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
return 0;
}
}
-
+
con = add_new_constraint(CONSTRAINT_TYPE_KINEMATIC);
BLI_addtail(&pchan->constraints, con);
pchan->constflag |= (PCHAN_HAS_IK|PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */
@@ -864,22 +868,22 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
data->flag |= CONSTRAINT_IK_TEMP|CONSTRAINT_IK_AUTO;
VECCOPY(data->grabtarget, pchan->pose_tail);
data->rootbone= 1;
-
+
/* we include only a connected chain */
while ((pchan) && (pchan->bone->flag & BONE_CONNECTED)) {
/* here, we set ik-settings for bone from pchan->protectflag */
if (pchan->protectflag & OB_LOCK_ROTX) pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
if (pchan->protectflag & OB_LOCK_ROTY) pchan->ikflag |= BONE_IK_NO_YDOF_TEMP;
if (pchan->protectflag & OB_LOCK_ROTZ) pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP;
-
+
/* now we count this pchan as being included */
data->rootbone++;
pchan= pchan->parent;
}
-
+
/* make a copy of maximum chain-length */
data->max_rootbone= data->rootbone;
-
+
return 1;
}
@@ -901,7 +905,7 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone)
if (pchan)
added+= pose_grab_with_ik_add(pchan);
}
-
+
return added;
}
@@ -912,12 +916,12 @@ static short pose_grab_with_ik(Object *ob)
bPoseChannel *pchan, *parent;
Bone *bonec;
short tot_ik= 0;
-
+
if ((ob==NULL) || (ob->pose==NULL) || (ob->flag & OB_POSEMODE)==0)
return 0;
-
+
arm = ob->data;
-
+
/* Rule: allow multiple Bones (but they must be selected, and only one ik-solver per chain should get added) */
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if (pchan->bone->layer & arm->layer) {
@@ -930,7 +934,7 @@ static short pose_grab_with_ik(Object *ob)
}
if ((pchan->bone->flag & BONE_CONNECTED)==0 && (bonec == NULL))
continue;
-
+
/* rule: if selected Bone is not a root bone, it gets a temporal IK */
if (pchan->parent) {
/* only adds if there's no IK yet (and no parent bone was selected) */
@@ -948,9 +952,9 @@ static short pose_grab_with_ik(Object *ob)
}
}
}
-
+
return (tot_ik) ? 1 : 0;
-}
+}
/* only called with pose mode active object now */
@@ -962,13 +966,13 @@ static void createTransPose(bContext *C, TransInfo *t, Object *ob)
TransDataExtension *tdx;
short ik_on= 0;
int i;
-
+
t->total= 0;
-
+
/* check validity of state */
arm= get_armature(ob);
if ((arm==NULL) || (ob->pose==NULL)) return;
-
+
if (arm->flag & ARM_RESTPOS) {
if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE)==0) {
// XXX use transform operator reports
@@ -982,15 +986,15 @@ static void createTransPose(bContext *C, TransInfo *t, Object *ob)
ik_on= pose_grab_with_ik(ob);
if (ik_on) t->flag |= T_AUTOIK;
}
-
+
/* set flags and count total (warning, can change transform to rotate) */
- set_pose_transflags(t, ob);
-
- if(t->total==0) return;
+ t->total = count_set_pose_transflags(&t->mode, t->around, ob);
+
+ 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");
@@ -998,8 +1002,8 @@ static void createTransPose(bContext *C, TransInfo *t, Object *ob)
td->ext= tdx;
td->tdi = NULL;
td->val = NULL;
- }
-
+ }
+
/* use pose channels to fill trans data */
td= t->data;
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
@@ -1008,12 +1012,12 @@ static void createTransPose(bContext *C, TransInfo *t, Object *ob)
td++;
}
}
-
+
if(td != (t->data+t->total)) {
// XXX use transform operator reports
// BKE_report(op->reports, RPT_DEBUG, "Bone selection count error.");
}
-
+
/* initialise initial auto=ik chainlen's? */
if (ik_on) transform_autoik_update(t, 0);
}
@@ -1054,16 +1058,16 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
}
if (!t->total) return;
-
+
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransEditBone");
-
+
for (ebo = edbo->first; ebo; ebo = ebo->next)
{
ebo->oldlength = ebo->length; // length==0.0 on extrude, used for scaling radius of bone points
-
+
if(ebo->layer & arm->layer) {
if (t->mode==TFM_BONE_ENVELOPE)
{
@@ -1071,17 +1075,17 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
{
td->val= &ebo->rad_head;
td->ival= *td->val;
-
+
VECCOPY (td->center, ebo->head);
td->flag= TD_SELECTED;
-
+
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
-
+
td->loc = NULL;
td->ext = NULL;
td->tdi = NULL;
-
+
td++;
}
if (ebo->flag & BONE_TIPSEL)
@@ -1090,17 +1094,17 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
td->ival= *td->val;
VECCOPY (td->center, ebo->tail);
td->flag= TD_SELECTED;
-
+
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
-
+
td->loc = NULL;
td->ext = NULL;
td->tdi = NULL;
-
+
td++;
}
-
+
}
else if (t->mode==TFM_BONESIZE)
{
@@ -1120,19 +1124,19 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
}
VECCOPY (td->center, ebo->head);
td->flag= TD_SELECTED;
-
+
/* use local bone matrix */
- VecSubf(delta, ebo->tail, ebo->head);
+ VecSubf(delta, ebo->tail, ebo->head);
vec_roll_to_mat3(delta, ebo->roll, bonemat);
Mat3MulMat3(td->mtx, mtx, bonemat);
Mat3Inv(td->smtx, td->mtx);
-
+
Mat3CpyMat3(td->axismtx, td->mtx);
Mat3Ortho(td->axismtx);
td->ext = NULL;
td->tdi = NULL;
-
+
td++;
}
}
@@ -1143,13 +1147,13 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
td->loc= NULL;
td->val= &(ebo->roll);
td->ival= ebo->roll;
-
+
VECCOPY (td->center, ebo->head);
td->flag= TD_SELECTED;
td->ext = NULL;
td->tdi = NULL;
-
+
td++;
}
}
@@ -1167,7 +1171,7 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
- VecSubf(delta, ebo->tail, ebo->head);
+ VecSubf(delta, ebo->tail, ebo->head);
vec_roll_to_mat3(delta, ebo->roll, td->axismtx);
if ((ebo->flag & BONE_ROOTSEL) == 0)
@@ -1193,7 +1197,7 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
- VecSubf(delta, ebo->tail, ebo->head);
+ VecSubf(delta, ebo->tail, ebo->head);
vec_roll_to_mat3(delta, ebo->roll, td->axismtx);
td->extra = ebo; /* to fix roll */
@@ -1230,16 +1234,16 @@ static void createTransMBallVerts(bContext *C, TransInfo *t)
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
- if(propmode) t->total = count;
+
+ if(propmode) t->total = count;
else t->total = countsel;
-
+
td = t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(MBall EditMode)");
tx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "MetaElement_TransExtension");
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
-
+
for(ml= editelems.first; ml; ml= ml->next) {
if(propmode || (ml->flag & SELECT)) {
td->loc= &ml->x;
@@ -1357,7 +1361,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
/* to be sure */
if(cu->editnurb==NULL) return;
-
+
/* count total of vertices, check identical as in 2nd loop for making transdata! */
for(nu= cu->editnurb->first; nu; nu= nu->next) {
if((nu->type & 7)==CU_BEZIER) {
@@ -1386,14 +1390,14 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
}
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
- if(propmode) t->total = count;
+
+ if(propmode) t->total = count;
else t->total = countsel;
t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Curve EditMode)");
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
-
+
td = t->data;
for(nu= cu->editnurb->first; nu; nu= nu->next) {
if((nu->type & 7)==CU_BEZIER) {
@@ -1402,7 +1406,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
for(a=0, bezt= nu->bezt; a<nu->pntsu; a++, bezt++) {
if(bezt->hide==0) {
TransDataCurveHandleFlags *hdata = NULL;
-
+
if( propmode ||
((bezt->f2 & SELECT) && (G.f & G_HIDDENHANDLES)) ||
((bezt->f1 & SELECT) && (G.f & G_HIDDENHANDLES)==0)
@@ -1420,7 +1424,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
td->ext = NULL;
td->tdi = NULL;
td->val = NULL;
-
+
hdata = initTransDataCurveHandes(td, bezt);
Mat3CpyMat3(td->smtx, smtx);
@@ -1430,7 +1434,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
count++;
tail++;
}
-
+
/* This is the Curve Point, the other two are handles */
if(propmode || (bezt->f2 & SELECT)) {
VECCOPY(td->iloc, bezt->vec[1]);
@@ -1440,7 +1444,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
else td->flag= 0;
td->ext = NULL;
td->tdi = NULL;
-
+
if (t->mode==TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */
td->val = &(bezt->radius);
td->ival = bezt->radius;
@@ -1453,13 +1457,13 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
-
+
if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0)
/* If the middle is selected but the sides arnt, this is needed */
if (hdata==NULL) { /* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandes(td, bezt);
}
-
+
td++;
count++;
tail++;
@@ -1485,7 +1489,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
if (hdata==NULL) { /* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandes(td, bezt);
}
-
+
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
@@ -1501,7 +1505,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
}
if (propmode && head != tail)
calc_distanceCurveVerts(head, tail-1);
-
+
/* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandes
* but for now just dont change handle types */
if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0)
@@ -1520,7 +1524,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
else td->flag= 0;
td->ext = NULL;
td->tdi = NULL;
-
+
if (t->mode==TFM_CURVE_SHRINKFATTEN || t->mode==TFM_RESIZE) {
td->val = &(bp->radius);
td->ival = bp->radius;
@@ -1569,14 +1573,14 @@ static void createTransLatticeVerts(bContext *C, TransInfo *t)
}
bp++;
}
-
+
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
- if(propmode) t->total = count;
+
+ if(propmode) t->total = count;
else t->total = countsel;
t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Lattice EditMode)");
-
+
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
@@ -1654,10 +1658,10 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
pa->flag |= PARS_TRANSFORM;
}
}
-
+
/* note: in prop mode we need at least 1 selected */
if (hasselected==0) return;
-
+
t->total = count;
td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Particle Mode)");
@@ -1795,13 +1799,13 @@ static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *v
/* Floodfill routine */
/*
- At worst this is n*n of complexity where n is number of edges
+ At worst this is n*n of complexity where n is number of edges
Best case would be n if the list is ordered perfectly.
Estimate is n log n in average (so not too bad)
*/
while(done) {
done= 0;
-
+
for(eed= em->edges.first; eed; eed= eed->next) {
if(eed->h==0) {
EditVert *v1= eed->v1, *v2= eed->v2;
@@ -1882,7 +1886,7 @@ static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *v
static void get_face_center(float *cent, EditMesh *em, EditVert *eve)
{
EditFace *efa;
-
+
for(efa= em->faces.first; efa; efa= efa->next)
if(efa->f & SELECT)
if(efa->v1==eve || efa->v2==eve || efa->v3==eve || efa->v4==eve)
@@ -1901,7 +1905,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, EditMesh *em, EditVert
// td->loc = key->co;
//else
td->loc = eve->co;
-
+
VECCOPY(td->center, td->loc);
if(t->around==V3D_LOCAL && (em->selectmode & SCE_SELECT_FACE))
get_face_center(td->center, em, eve);
@@ -1931,7 +1935,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, EditMesh *em, EditVert
static void make_vertexcos__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
{
float *vec = userData;
-
+
vec+= 3*index;
VECCOPY(vec, co);
}
@@ -1940,14 +1944,14 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
{
ModifierData *md;
int disabled = 0;
-
+
for(md=ob->modifiers.first; md; md=md->next)
if(md->type==eModifierType_Subsurf)
if(md->mode & eModifierMode_OnCage) {
md->mode ^= eModifierMode_DisableTemporary;
disabled= 1;
}
-
+
return disabled;
}
@@ -1969,12 +1973,12 @@ static float *get_crazy_mapped_editverts(TransInfo *t)
vertexcos= MEM_mallocN(3*sizeof(float)*me->edit_mesh->totvert, "vertexcos map");
dm->foreachMappedVert(dm, make_vertexcos__mapFunc, vertexcos);
-
+
dm->release(dm);
-
+
/* set back the flag, no new cage needs to be built, transform does it */
modifiers_disable_subsurf_temporary(t->obedit);
-
+
return vertexcos;
}
@@ -1983,15 +1987,15 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3,
{
float vecu[3], vecv[3];
float q1[4], q2[4];
-
+
TAN_MAKE_VEC(vecu, v1, v2);
TAN_MAKE_VEC(vecv, v1, v3);
triatoquat(v1, vecu, vecv, q1);
-
+
TAN_MAKE_VEC(vecu, def1, def2);
TAN_MAKE_VEC(vecv, def1, def3);
triatoquat(def1, vecu, vecv, q2);
-
+
QuatSub(quat, q2, q1);
}
#undef TAN_MAKE_VEC
@@ -2002,16 +2006,16 @@ static void set_crazyspace_quats(EditMesh *em, float *origcos, float *mappedcos,
EditFace *efa;
float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4;
intptr_t index= 0;
-
+
/* two abused locations in vertices */
for(eve= em->verts.first; eve; eve= eve->next, index++) {
eve->tmp.p = NULL;
eve->prev= (EditVert *)index;
}
-
+
/* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
for(efa= em->faces.first; efa; efa= efa->next) {
-
+
/* retrieve mapped coordinates */
v1= mappedcos + 3*(intptr_t)(efa->v1->prev);
v2= mappedcos + 3*(intptr_t)(efa->v2->prev);
@@ -2026,7 +2030,7 @@ static void set_crazyspace_quats(EditMesh *em, float *origcos, float *mappedcos,
efa->v2->tmp.p= (void*)quats;
quats+= 4;
}
-
+
if(efa->v4) {
v4= mappedcos + 3*(intptr_t)(efa->v4->prev);
co4= (origcos)? origcos + 3*(intptr_t)(efa->v4->prev): efa->v4->co;
@@ -2114,7 +2118,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
// transform now requires awareness for select mode, so we tag the f1 flags in verts
if(ts->selectmode & SCE_SELECT_VERTEX) {
for(eve= em->verts.first; eve; eve= eve->next) {
- if(eve->h==0 && (eve->f & SELECT))
+ if(eve->h==0 && (eve->f & SELECT))
eve->f1= SELECT;
else
eve->f1= 0;
@@ -2138,7 +2142,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
}
}
-
+
/* now we can count */
for(eve= em->verts.first; eve; eve= eve->next) {
if(eve->h==0) {
@@ -2146,10 +2150,10 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
if(propmode) count++;
}
}
-
+
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
+
/* check active */
if (em->selected.last) {
EditSelection *ese = em->selected.last;
@@ -2158,22 +2162,22 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
}
-
+
if(propmode) {
- t->total = count;
-
+ t->total = count;
+
/* allocating scratch arrays */
vectors = (float *)MEM_mallocN(t->total * 3 * sizeof(float), "scratch vectors");
nears = (EditVert**)MEM_mallocN(t->total * sizeof(EditVert*), "scratch nears");
}
else t->total = countsel;
tob= t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Mesh EditMode)");
-
+
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
if(propmode) editmesh_set_connectivity_distance(em, t->total, vectors, nears);
-
+
/* detect CrazySpace [tm] */
if(propmode==0) {
if(modifiers_getCageIndex(t->obedit, NULL)>=0) {
@@ -2198,7 +2202,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
}
}
-
+
/* find out which half we do */
if(mirror) {
for (eve=em->verts.first; eve; eve=eve->next) {
@@ -2209,18 +2213,18 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
}
}
-
+
for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) {
if(eve->h==0) {
if(propmode || eve->f1) {
VertsToTransData(t, tob, em, eve);
-
+
/* selected */
if(eve->f1) tob->flag |= TD_SELECTED;
-
+
/* active */
if(eve == eve_act) tob->flag |= TD_ACTIVE;
-
+
if(propmode) {
if (eve->f2) {
float vec[3];
@@ -2233,11 +2237,11 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
tob->dist = MAXFLOAT;
}
}
-
+
/* CrazySpace */
if(defmats || (quats && eve->tmp.p)) {
float mat[3][3], imat[3][3], qmat[3][3];
-
+
/* use both or either quat and defmat correction */
if(quats && eve->tmp.f) {
QuatToMat3(eve->tmp.p, qmat);
@@ -2252,7 +2256,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
Mat3MulMat3(mat, mtx, defmats[a]);
Mat3Inv(imat, mat);
-
+
Mat3CpyMat3(tob->smtx, imat);
Mat3CpyMat3(tob->mtx, mat);
}
@@ -2260,7 +2264,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
Mat3CpyMat3(tob->smtx, smtx);
Mat3CpyMat3(tob->mtx, mtx);
}
-
+
/* Mirror? */
if( (mirror>0 && tob->iloc[0]>0.0f) || (mirror<0 && tob->iloc[0]<0.0f)) {
EditVert *vmir= editmesh_get_x_mirror_vert(t->obedit, em, tob->iloc); /* initializes octree on first call */
@@ -2268,7 +2272,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
tob++;
}
- }
+ }
}
if (propmode) {
MEM_freeN(vectors);
@@ -2286,7 +2290,7 @@ void flushTransNodes(TransInfo *t)
{
int a;
TransData2D *td;
-
+
/* flush to 2d vector from internally used 3d vector */
for(a=0, td= t->data2d; a<t->total; a++, td++) {
td->loc2d[0]= td->loc[0];
@@ -2304,7 +2308,7 @@ void flushTransSeq(TransInfo *t)
TransDataSeq *tdsq= NULL;
Sequence *seq;
-
+
/* prevent updating the same seq twice
* if the transdata order is changed this will mess up
@@ -2322,7 +2326,7 @@ void flushTransSeq(TransInfo *t)
case SELECT:
if (seq->type != SEQ_META && seq_tx_test(seq)) /* for meta's, their children move */
seq->start= new_frame - tdsq->start_offset;
-
+
if (seq->depth==0) {
seq->machine= (int)(td2d->loc[1] + 0.5f);
CLAMP(seq->machine, 1, MAXSEQ);
@@ -2346,7 +2350,7 @@ void flushTransSeq(TransInfo *t)
* children are ALWAYS transformed first
* so we dont need to do this in another loop. */
calc_sequence(seq);
-
+
/* test overlap, displayes red outline */
seq->flag &= ~SEQ_OVERLAP;
if( seq_test_overlap(seqbasep, seq) ) {
@@ -2423,7 +2427,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
EditMesh *em = ((Mesh *)t->obedit->data)->edit_mesh;
EditFace *efa;
-
+
if(!ED_uvedit_test(t->obedit)) return;
/* count */
@@ -2432,10 +2436,10 @@ static void createTransUVs(bContext *C, TransInfo *t)
if(uvedit_face_visible(scene, ima, efa, tf)) {
efa->tmp.p = tf;
-
- if (uvedit_uv_selected(scene, efa, tf, 0)) countsel++;
- if (uvedit_uv_selected(scene, efa, tf, 1)) countsel++;
- if (uvedit_uv_selected(scene, efa, tf, 2)) countsel++;
+
+ if (uvedit_uv_selected(scene, efa, tf, 0)) countsel++;
+ if (uvedit_uv_selected(scene, efa, tf, 1)) countsel++;
+ if (uvedit_uv_selected(scene, efa, tf, 2)) countsel++;
if (efa->v4 && uvedit_uv_selected(scene, efa, tf, 3)) countsel++;
if(propmode)
count += (efa->v4)? 4: 3;
@@ -2443,10 +2447,10 @@ static void createTransUVs(bContext *C, TransInfo *t)
efa->tmp.p = NULL;
}
}
-
+
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
+
t->total= (propmode)? count: countsel;
t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(UV Editing)");
/* for each 2d uv coord a 3d vector is allocated, so that they can be
@@ -2458,7 +2462,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
td= t->data;
td2d= t->data2d;
-
+
for (efa= em->faces.first; efa; efa= efa->next) {
if ((tf=(MTFace *)efa->tmp.p)) {
if (propmode) {
@@ -2475,7 +2479,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
}
}
}
-
+
if (sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_begin(t->scene, t->obedit);
}
@@ -2496,7 +2500,7 @@ void flushTransUVs(TransInfo *t)
for(a=0, td= t->data2d; a<t->total; a++, td++) {
td->loc2d[0]= td->loc[0]*invx;
td->loc2d[1]= td->loc[1]*invy;
-
+
if((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL)) {
td->loc2d[0]= (float)floor(width*td->loc2d[0] + 0.5f)/width;
td->loc2d[1]= (float)floor(height*td->loc2d[1] + 0.5f)/height;
@@ -2547,7 +2551,7 @@ int clipUVTransform(TransInfo *t, float *vec, int resize)
vec[1] -= max[1]-aspy;
else
clipy= 0;
- }
+ }
return (clipx || clipy);
}
@@ -2559,7 +2563,7 @@ static short FrameOnMouseSide(char side, float frame, float cframe)
{
/* both sides, so it doesn't matter */
if (side == 'B') return 1;
-
+
/* only on the named side */
if (side == 'R')
return (frame >= cframe) ? 1 : 0;
@@ -2574,28 +2578,28 @@ static void createTransNlaData(bContext *C, TransInfo *t)
Scene *scene= CTX_data_scene(C);
TransData *td = NULL;
TransDataNla *tdn = NULL;
-
+
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
int count=0;
char side;
-
+
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
-
+
/* filter data */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* which side of the current frame should be allowed */
if (t->mode == TFM_TIME_EXTEND) {
/* only side on which mouse is gets transformed */
float xmouse, ymouse;
-
+
UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
}
@@ -2603,15 +2607,15 @@ static void createTransNlaData(bContext *C, TransInfo *t)
/* normal transform - both sides of current frame are considered */
side = 'B';
}
-
+
/* loop 1: count how many strips are selected (consider each strip as 2 points) */
for (ale= anim_data.first; ale; ale= ale->next) {
NlaTrack *nlt= (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* make some meta-strips for chains of selected strips */
BKE_nlastrips_make_metas(&nlt->strips, 1);
-
+
/* only consider selected strips */
for (strip= nlt->strips.first; strip; strip= strip->next) {
// TODO: we can make strips have handles later on...
@@ -2624,29 +2628,29 @@ static void createTransNlaData(bContext *C, TransInfo *t)
}
}
}
-
+
/* stop if trying to build list if nothing selected */
if (count == 0) {
/* cleanup temp list */
BLI_freelistN(&anim_data);
return;
}
-
+
/* allocate memory for data */
t->total= count;
-
+
t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(NLA Editor)");
td= t->data;
t->customData= MEM_callocN(t->total*sizeof(TransDataNla), "TransDataNla (NLA Editor)");
tdn= t->customData;
-
+
/* loop 2: build transdata array */
for (ale= anim_data.first; ale; ale= ale->next) {
/* only if a real NLA-track */
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt= (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* only consider selected strips */
for (strip= nlt->strips.first; strip; strip= strip->next) {
// TODO: we can make strips have handles later on...
@@ -2663,44 +2667,44 @@ static void createTransNlaData(bContext *C, TransInfo *t)
* cases, there will need to be 1 of these tdn elements in the array skipped...
*/
float center[3], yval;
-
+
/* firstly, init tdn settings */
tdn->oldTrack= tdn->nlt= nlt;
tdn->strip= strip;
tdn->trackIndex= BLI_findindex(&nlt->strips, strip);
-
+
yval= (float)(tdn->trackIndex * NLACHANNEL_STEP);
-
+
tdn->h1[0]= strip->start;
tdn->h1[1]= yval;
tdn->h2[0]= strip->end;
tdn->h2[1]= yval;
-
+
center[0]= (float)CFRA;
center[1]= yval;
center[2]= 0.0f;
-
+
/* set td's based on which handles are applicable */
- if (FrameOnMouseSide(side, strip->start, (float)CFRA))
+ if (FrameOnMouseSide(side, strip->start, (float)CFRA))
{
/* just set tdn to assume that it only has one handle for now */
tdn->handle= -1;
-
+
/* now, link the transform data up to this data */
if (t->mode == TFM_TRANSLATION) {
td->loc= tdn->h1;
VECCOPY(td->iloc, tdn->h1);
-
+
/* store all the other gunk that is required by transform */
VECCOPY(td->center, center);
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
-
+
td->ext= NULL; td->tdi= NULL; td->val= NULL;
-
+
td->flag |= TD_SELECTED;
td->dist= 0.0f;
-
+
Mat3One(td->mtx);
Mat3One(td->smtx);
}
@@ -2708,30 +2712,30 @@ static void createTransNlaData(bContext *C, TransInfo *t)
td->val= &tdn->h1[0];
td->ival= tdn->h1[0];
}
-
+
td->extra= tdn;
td++;
}
- if (FrameOnMouseSide(side, strip->end, (float)CFRA))
- {
+ if (FrameOnMouseSide(side, strip->end, (float)CFRA))
+ {
/* if tdn is already holding the start handle, then we're doing both, otherwise, only end */
tdn->handle= (tdn->handle) ? 2 : 1;
-
+
/* now, link the transform data up to this data */
if (t->mode == TFM_TRANSLATION) {
td->loc= tdn->h2;
VECCOPY(td->iloc, tdn->h2);
-
+
/* store all the other gunk that is required by transform */
VECCOPY(td->center, center);
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
-
+
td->ext= NULL; td->tdi= NULL; td->val= NULL;
-
+
td->flag |= TD_SELECTED;
td->dist= 0.0f;
-
+
Mat3One(td->mtx);
Mat3One(td->smtx);
}
@@ -2739,12 +2743,12 @@ static void createTransNlaData(bContext *C, TransInfo *t)
td->val= &tdn->h2[0];
td->ival= tdn->h2[0];
}
-
+
td->extra= tdn;
td++;
}
-
- /* if both handles were used, skip the next tdn (i.e. leave it blank) since the counting code is dumb...
+
+ /* if both handles were used, skip the next tdn (i.e. leave it blank) since the counting code is dumb...
* otherwise, just advance to the next one...
*/
if (tdn->handle == 2)
@@ -2756,7 +2760,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
}
}
}
-
+
/* cleanup temp list */
BLI_freelistN(&anim_data);
}
@@ -2772,25 +2776,25 @@ static void createTransNlaData(bContext *C, TransInfo *t)
static void posttrans_gpd_clean (bGPdata *gpd)
{
bGPDlayer *gpl;
-
+
for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
ListBase sel_buffer = {NULL, NULL};
bGPDframe *gpf, *gpfn;
bGPDframe *gfs, *gfsn;
-
- /* loop 1: loop through and isolate selected gp-frames to buffer
+
+ /* loop 1: loop through and isolate selected gp-frames to buffer
* (these need to be sorted as they are isolated)
*/
for (gpf= gpl->frames.first; gpf; gpf= gpfn) {
short added= 0;
gpfn= gpf->next;
-
+
if (gpf->flag & GP_FRAME_SELECT) {
BLI_remlink(&gpl->frames, gpf);
-
+
/* find place to add them in buffer
* - go backwards as most frames will still be in order,
- * so doing it this way will be faster
+ * so doing it this way will be faster
*/
for (gfs= sel_buffer.last; gfs; gfs= gfs->prev) {
/* if current (gpf) occurs after this one in buffer, add! */
@@ -2804,27 +2808,27 @@ static void posttrans_gpd_clean (bGPdata *gpd)
BLI_addhead(&sel_buffer, gpf);
}
}
-
+
/* error checking: it is unlikely, but may be possible to have none selected */
if (sel_buffer.first == NULL)
continue;
-
+
/* if all were selected (i.e. gpl->frames is empty), then just transfer sel-buf over */
if (gpl->frames.first == NULL) {
gpl->frames.first= sel_buffer.first;
gpl->frames.last= sel_buffer.last;
-
+
continue;
}
-
+
/* loop 2: remove duplicates of frames in buffers */
for (gpf= gpl->frames.first; gpf && sel_buffer.first; gpf= gpfn) {
gpfn= gpf->next;
-
+
/* loop through sel_buffer, emptying stuff from front of buffer if ok */
for (gfs= sel_buffer.first; gfs && gpf; gfs= gfsn) {
gfsn= gfs->next;
-
+
/* if this buffer frame needs to go before current, add it! */
if (gfs->framenum < gpf->framenum) {
/* transfer buffer frame to frames list (before current) */
@@ -2836,18 +2840,18 @@ static void posttrans_gpd_clean (bGPdata *gpd)
/* transfer buffer frame to frames list (before current) */
BLI_remlink(&sel_buffer, gfs);
BLI_insertlinkbefore(&gpl->frames, gpf, gfs);
-
+
/* get rid of current frame */
// TRANSFORM_FIX_ME
//gpencil_layer_delframe(gpl, gpf);
}
}
}
-
+
/* if anything is still in buffer, append to end */
for (gfs= sel_buffer.first; gfs; gfs= gfsn) {
gfsn= gfs->next;
-
+
BLI_remlink(&sel_buffer, gfs);
BLI_addtail(&gpl->frames, gfs);
}
@@ -2862,36 +2866,36 @@ static void posttrans_fcurve_clean (FCurve *fcu)
{
float *selcache; /* cache for frame numbers of selected frames (icu->totvert*sizeof(float)) */
int len, index, i; /* number of frames in cache, item index */
-
+
/* allocate memory for the cache */
// TODO: investigate using GHash for this instead?
- if (fcu->totvert == 0)
+ if (fcu->totvert == 0)
return;
selcache= MEM_callocN(sizeof(float)*fcu->totvert, "FCurveSelFrameNums");
len= 0;
index= 0;
-
- /* We do 2 loops, 1 for marking keyframes for deletion, one for deleting
- * as there is no guarantee what order the keyframes are exactly, even though
+
+ /* We do 2 loops, 1 for marking keyframes for deletion, one for deleting
+ * as there is no guarantee what order the keyframes are exactly, even though
* they have been sorted by time.
*/
-
+
/* Loop 1: find selected keyframes */
for (i = 0; i < fcu->totvert; i++) {
BezTriple *bezt= &fcu->bezt[i];
-
+
if (BEZSELECTED(bezt)) {
selcache[index]= bezt->vec[1][0];
index++;
len++;
}
}
-
+
/* Loop 2: delete unselected keyframes on the same frames (if any keyframes were found) */
if (len) {
for (i = 0; i < fcu->totvert; i++) {
BezTriple *bezt= &fcu->bezt[i];
-
+
if (BEZSELECTED(bezt) == 0) {
/* check beztriple should be removed according to cache */
for (index= 0; index < len; index++) {
@@ -2904,10 +2908,10 @@ static void posttrans_fcurve_clean (FCurve *fcu)
}
}
}
-
+
testhandles_fcurve(fcu);
}
-
+
/* free cache */
MEM_freeN(selcache);
}
@@ -2916,33 +2920,33 @@ static void posttrans_fcurve_clean (FCurve *fcu)
/* Called by special_aftertrans_update to make sure selected keyframes replace
* any other keyframes which may reside on that frame (that is not selected).
- * remake_action_ipos should have already been called
+ * remake_action_ipos should have already been called
*/
static void posttrans_action_clean (bAnimContext *ac, bAction *act)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, act, ANIMCONT_ACTION);
-
- /* loop through relevant data, removing keyframes from the ipo-blocks that were attached
- * - all keyframes are converted in/out of global time
+
+ /* loop through relevant data, removing keyframes from the ipo-blocks that were attached
+ * - all keyframes are converted in/out of global time
*/
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
-
+
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
posttrans_fcurve_clean(ale->key_data);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- else
+ else
posttrans_fcurve_clean(ale->key_data);
}
-
+
/* free temp data */
BLI_freelistN(&anim_data);
}
@@ -2954,23 +2958,23 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra)
{
BezTriple *bezt;
int i, count = 0;
-
+
if (ELEM(NULL, fcu, fcu->bezt))
return count;
-
+
/* only include points that occur on the right side of cfra */
for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (bezt->f2 & SELECT) {
/* fully select the other two keys */
bezt->f1 |= SELECT;
bezt->f3 |= SELECT;
-
+
/* increment by 3, as there are 3 points (3 * x-coordinates) that need transform */
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra))
count += 3;
}
}
-
+
return count;
}
@@ -2980,10 +2984,10 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
{
bGPDframe *gpf;
int count = 0;
-
+
if (gpl == NULL)
return count;
-
+
/* only include points that occur on the right side of cfra */
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
@@ -2991,7 +2995,7 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
count++;
}
}
-
+
return count;
}
#endif
@@ -3002,9 +3006,9 @@ static void TimeToTransData(TransData *td, float *time, AnimData *adt)
/* memory is calloc'ed, so that should zero everything nicely for us */
td->val = time;
td->ival = *(time);
-
- /* store the AnimData where this keyframe exists as a keyframe of the
- * active action as td->extra.
+
+ /* store the AnimData where this keyframe exists as a keyframe of the
+ * active action as td->extra.
*/
td->extra= adt;
}
@@ -3014,16 +3018,16 @@ static void TimeToTransData(TransData *td, float *time, AnimData *adt)
* overwrite the existing ones... i.e. td = IcuToTransData(td, icu, ob, side, cfra);
*
* The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
- * on the named side are used.
+ * on the named side are used.
*/
static TransData *FCurveToTransData(TransData *td, FCurve *fcu, AnimData *adt, char side, float cfra)
{
BezTriple *bezt;
int i;
-
+
if (fcu == NULL)
return td;
-
+
for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* only add selected keyframes (for now, proportional edit is not enabled) */
if (BEZSELECTED(bezt)) {
@@ -3032,16 +3036,16 @@ static TransData *FCurveToTransData(TransData *td, FCurve *fcu, AnimData *adt, c
/* each control point needs to be added separetely */
TimeToTransData(td, bezt->vec[0], adt);
td++;
-
+
TimeToTransData(td, bezt->vec[1], adt);
td++;
-
+
TimeToTransData(td, bezt->vec[2], adt);
td++;
}
- }
+ }
}
-
+
return td;
}
@@ -3056,17 +3060,17 @@ void flushTransGPactionData (TransInfo *t)
{
tGPFtransdata *tfd;
int i;
-
+
/* find the first one to start from */
if (t->mode == TFM_TIME_SLIDE)
tfd= (tGPFtransdata *)( (float *)(t->customData) + 2 );
else
tfd= (tGPFtransdata *)(t->customData);
-
+
/* flush data! */
for (i = 0; i < t->total; i++, tfd++) {
*(tfd->sdata)= (int)floor(tfd->val + 0.5);
- }
+ }
}
/* This function advances the address to which td points to, so it must return
@@ -3074,14 +3078,14 @@ void flushTransGPactionData (TransInfo *t)
* overwrite the existing ones... i.e. td = GPLayerToTransData(td, ipo, ob, side, cfra);
*
* The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
- * on the named side are used.
+ * on the named side are used.
*/
#if 0
static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, char side, float cfra)
{
bGPDframe *gpf;
int count= 0;
-
+
/* check for select frames on right side of current frame */
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
@@ -3089,10 +3093,10 @@ static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl
/* memory is calloc'ed, so that should zero everything nicely for us */
td->val= &tfd->val;
td->ival= (float)gpf->framenum;
-
+
tfd->val= (float)gpf->framenum;
tfd->sdata= &gpf->framenum;
-
+
/* advance td now */
td++;
tfd++;
@@ -3100,7 +3104,7 @@ static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl
}
}
}
-
+
return count;
}
#endif
@@ -3110,32 +3114,32 @@ static void createTransActionData(bContext *C, TransInfo *t)
Scene *scene= CTX_data_scene(C);
TransData *td = NULL;
tGPFtransdata *tfd = NULL;
-
+
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
int count=0;
float cfra;
char side;
-
+
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
-
+
/* filter data */
if (ac.datatype == ANIMCONT_GPENCIL)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
else
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* which side of the current frame should be allowed */
if (t->mode == TFM_TIME_EXTEND) {
/* only side on which mouse is gets transformed */
float xmouse, ymouse;
-
+
UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
}
@@ -3143,38 +3147,38 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* normal transform - both sides of current frame are considered */
side = 'B';
}
-
+
/* loop 1: fully select ipo-keys and count how many BezTriples are selected */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
-
+
/* convert current-frame to action-time (slightly less accurate, espcially under
- * higher scaling ratios, but is faster than converting all points)
+ * higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
cfra = (float)CFRA;
-
+
//if (ale->type == ANIMTYPE_GPLAYER)
// count += count_gplayer_frames(ale->data, side, cfra);
//else
count += count_fcurve_keys(ale->key_data, side, cfra);
}
-
+
/* stop if trying to build list if nothing selected */
if (count == 0) {
/* cleanup temp list */
BLI_freelistN(&anim_data);
return;
}
-
+
/* allocate memory for data */
t->total= count;
-
+
t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(Action Editor)");
td= t->data;
-
+
if (ac.datatype == ANIMCONT_GPENCIL) {
if (t->mode == TFM_TIME_SLIDE) {
t->customData= MEM_callocN((sizeof(float)*2)+(sizeof(tGPFtransdata)*count), "TimeSlide + tGPFtransdata");
@@ -3187,13 +3191,13 @@ static void createTransActionData(bContext *C, TransInfo *t)
}
else if (t->mode == TFM_TIME_SLIDE)
t->customData= MEM_callocN(sizeof(float)*2, "TimeSlide Min/Max");
-
+
/* loop 2: build transdata array */
for (ale= anim_data.first; ale; ale= ale->next) {
//if (ale->type == ANIMTYPE_GPLAYER) {
// bGPDlayer *gpl= (bGPDlayer *)ale->data;
// int i;
- //
+ //
// i = GPLayerToTransData(td, tfd, gpl, side, cfra);
// td += i;
// tfd += i;
@@ -3201,38 +3205,38 @@ static void createTransActionData(bContext *C, TransInfo *t)
//else {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
-
+
/* convert current-frame to action-time (slightly less accurate, espcially under
- * higher scaling ratios, but is faster than converting all points)
+ * higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
cfra = (float)CFRA;
-
+
td= FCurveToTransData(td, fcu, adt, side, cfra);
//}
}
-
+
/* check if we're supposed to be setting minx/maxx for TimeSlide */
if (t->mode == TFM_TIME_SLIDE) {
float min=999999999.0f, max=-999999999.0f;
int i;
-
+
td= (t->data + 1);
for (i=1; i < count; i+=3, td+=3) {
if (min > *(td->val)) min= *(td->val);
if (max < *(td->val)) max= *(td->val);
}
-
- /* minx/maxx values used by TimeSlide are stored as a
+
+ /* minx/maxx values used by TimeSlide are stored as a
* calloced 2-float array in t->customData. This gets freed
- * in postTrans (T_FREE_CUSTOMDATA).
+ * in postTrans (T_FREE_CUSTOMDATA).
*/
*((float *)(t->customData)) = min;
*((float *)(t->customData) + 1) = max;
}
-
+
/* cleanup temp list */
BLI_freelistN(&anim_data);
}
@@ -3250,18 +3254,18 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
* Due to NLA mapping, we apply NLA mapping to some of the verts here,
* and then that mapping will be undone after transform is done.
*/
-
+
if (adt) {
td2d->loc[0] = BKE_nla_tweakedit_remap(adt, loc[0], NLATIME_CONVERT_UNMAP);
td2d->loc[1] = loc[1];
td2d->loc[2] = 0.0f;
td2d->loc2d = loc;
-
+
td->loc = td2d->loc;
td->center[0] = BKE_nla_tweakedit_remap(adt, cent[0], NLATIME_CONVERT_UNMAP);
td->center[1] = cent[1];
td->center[2] = 0.0f;
-
+
VECCOPY(td->iloc, td->loc);
}
else {
@@ -3269,7 +3273,7 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
td2d->loc[1] = loc[1];
td2d->loc[2] = 0.0f;
td2d->loc2d = loc;
-
+
td->loc = td2d->loc;
VECCOPY(td->center, cent);
VECCOPY(td->iloc, td->loc);
@@ -3279,7 +3283,7 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
td->axismtx[2][2] = 1.0f;
td->ext= NULL; td->tdi= NULL; td->val= NULL;
-
+
/* store AnimData info in td->extra, for applying mapping when flushing */
td->extra= adt;
@@ -3289,49 +3293,49 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
}
else
td->dist= MAXFLOAT;
-
- if (ishandle)
+
+ if (ishandle)
td->flag |= TD_NOTIMESNAP;
if (intvals)
td->flag |= TD_INTVALUES;
-
+
Mat3One(td->mtx);
Mat3One(td->smtx);
-}
+}
static void createTransGraphEditData(bContext *C, TransInfo *t)
{
Scene *scene= CTX_data_scene(C);
ARegion *ar= CTX_wm_region(C);
View2D *v2d= &ar->v2d;
-
+
TransData *td = NULL;
TransData2D *td2d = NULL;
-
+
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
BezTriple *bezt, *prevbezt;
int count=0, i;
float cfra;
char side;
-
+
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
-
+
/* filter data */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* which side of the current frame should be allowed */
// XXX we still want this mode, but how to get this using standard transform too?
if (t->mode == TFM_TIME_EXTEND) {
/* only side on which mouse is gets transformed */
float xmouse, ymouse;
-
+
UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
}
@@ -3339,20 +3343,20 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
/* normal transform - both sides of current frame are considered */
side = 'B';
}
-
+
/* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
-
+
/* convert current-frame to action-time (slightly less accurate, espcially under
- * higher scaling ratios, but is faster than converting all points)
+ * higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
cfra = (float)CFRA;
-
+
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
if (fcu->bezt) {
for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
@@ -3380,47 +3384,47 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
}
}
-
+
/* stop if trying to build list if nothing selected */
if (count == 0) {
/* cleanup temp list */
BLI_freelistN(&anim_data);
return;
}
-
+
/* allocate memory for data */
t->total= count;
-
+
t->data= MEM_callocN(t->total*sizeof(TransData), "TransData (Graph Editor)");
/* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */
t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "TransData2D (Graph Editor)");
-
+
td= t->data;
td2d= t->data2d;
-
+
/* loop 2: build transdata arrays */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
short intvals= (fcu->flag & FCURVE_INT_VALUES);
-
+
/* convert current-frame to action-time (slightly less accurate, espcially under
- * higher scaling ratios, but is faster than converting all points)
+ * higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
cfra = (float)CFRA;
-
+
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
bezt= fcu->bezt;
prevbezt= NULL;
-
+
for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) {
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
TransDataCurveHandleFlags *hdata = NULL;
short h1=1, h2=1;
-
+
/* only include handles if selected, and interpolaton mode uses beztriples */
if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) {
if (bezt->f1 & SELECT) {
@@ -3439,7 +3443,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
else
h2= 0;
}
-
+
/* only include main vert if selected */
if (bezt->f2 & SELECT) {
/* if scaling around individuals centers, do no include keyframes */
@@ -3449,13 +3453,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (hdata == NULL)
hdata = initTransDataCurveHandes(td, bezt);
}
-
+
bezt_to_transdata(td++, td2d++, adt, bezt->vec[1], bezt->vec[1], 1, 0, intvals);
}
-
- /* special hack (must be done after initTransDataCurveHandes(), as that stores handle settings to restore...):
- * - Check if we've got entire BezTriple selected and we're scaling/rotating that point,
- * then check if we're using auto-handles.
+
+ /* special hack (must be done after initTransDataCurveHandes(), as that stores handle settings to restore...):
+ * - Check if we've got entire BezTriple selected and we're scaling/rotating that point,
+ * then check if we're using auto-handles.
* - If so, change them auto-handles to aligned handles so that handles get affected too
*/
if ((bezt->h1 == HD_AUTO) && (bezt->h2 == HD_AUTO) && ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) {
@@ -3467,11 +3471,11 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
}
}
-
+
/* Sets handles based on the selection */
- testhandles_fcurve(fcu);
+ testhandles_fcurve(fcu);
}
-
+
/* cleanup temp list */
BLI_freelistN(&anim_data);
}
@@ -3498,23 +3502,23 @@ static BeztMap *bezt_to_beztmaps (BezTriple *bezts, int totvert)
BezTriple *prevbezt= NULL;
BeztMap *bezm, *bezms;
int i;
-
+
/* allocate memory for this array */
if (totvert==0 || bezts==NULL)
return NULL;
bezm= bezms= MEM_callocN(sizeof(BeztMap)*totvert, "BeztMaps");
-
+
/* assign beztriples to beztmaps */
for (i=0; i < totvert; i++, bezm++, prevbezt=bezt, bezt++) {
bezm->bezt= bezt;
-
+
bezm->oldIndex= i;
bezm->newIndex= i;
-
+
bezm->pipo= (prevbezt) ? prevbezt->ipo : bezt->ipo;
bezm->cipo= bezt->ipo;
}
-
+
return bezms;
}
@@ -3523,11 +3527,11 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert)
{
BeztMap *bezm;
int i, ok= 1;
-
+
/* keep repeating the process until nothing is out of place anymore */
while (ok) {
ok= 0;
-
+
bezm= bezms;
i= totvert;
while (i--) {
@@ -3536,18 +3540,18 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert)
if (bezm->bezt->vec[1][0] > (bezm+1)->bezt->vec[1][0]) {
bezm->newIndex++;
(bezm+1)->newIndex--;
-
+
SWAP(BeztMap, *bezm, *(bezm+1));
-
+
ok= 1;
}
}
-
+
/* do we need to check if the handles need to be swapped?
* optimisation: this only needs to be performed in the first loop
*/
if (bezm->swapHs == 0) {
- if ( (bezm->bezt->vec[0][0] > bezm->bezt->vec[1][0]) &&
+ if ( (bezm->bezt->vec[0][0] > bezm->bezt->vec[1][0]) &&
(bezm->bezt->vec[2][0] < bezm->bezt->vec[1][0]) )
{
/* handles need to be swapped */
@@ -3558,9 +3562,9 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert)
bezm->swapHs = -1;
}
}
-
+
bezm++;
- }
+ }
}
}
@@ -3572,24 +3576,24 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv
TransData2D *td;
int i, j;
char *adjusted;
-
- /* dynamically allocate an array of chars to mark whether an TransData's
+
+ /* dynamically allocate an array of chars to mark whether an TransData's
* pointers have been fixed already, so that we don't override ones that are
* already done
*/
adjusted= MEM_callocN(t->total, "beztmap_adjusted_map");
-
+
/* for each beztmap item, find if it is used anywhere */
bezm= bezms;
for (i= 0; i < totvert; i++, bezm++) {
- /* loop through transdata, testing if we have a hit
+ /* loop through transdata, testing if we have a hit
* for the handles (vec[0]/vec[2]), we must also check if they need to be swapped...
*/
td= t->data2d;
for (j= 0; j < t->total; j++, td++) {
/* skip item if already marked */
if (adjusted[j] != 0) continue;
-
+
/* only selected verts */
if (bezm->pipo == BEZT_IPO_BEZ) {
if (bezm->bezt->f1 & SELECT) {
@@ -3620,42 +3624,42 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv
}
}
}
-
+
}
-
+
/* free temp memory used for 'adjusted' array */
MEM_freeN(adjusted);
}
-/* This function is called by recalcData during the Transform loop to recalculate
+/* This function is called by recalcData during the Transform loop to recalculate
* the handles of curves and sort the keyframes so that the curves draw correctly.
* It is only called if some keyframes have moved out of order.
*
- * anim_data is the list of channels (F-Curves) retrieved already containing the
+ * anim_data is the list of channels (F-Curves) retrieved already containing the
* channels to work on. It should not be freed here as it may still need to be used.
*/
void remake_graph_transdata (TransInfo *t, ListBase *anim_data)
{
bAnimListElem *ale;
-
+
/* sort and reassign verts */
for (ale= anim_data->first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
-
+
if (fcu->bezt) {
BeztMap *bezm;
-
+
/* adjust transform-data pointers */
bezm= bezt_to_beztmaps(fcu->bezt, fcu->totvert);
sort_time_beztmaps(bezm, fcu->totvert);
beztmap_to_data(t, fcu, bezm, fcu->totvert);
-
+
/* free mapping stuff */
MEM_freeN(bezm);
-
+
/* re-sort actual beztriples (perhaps this could be done using the beztmaps to save time?) */
sort_time_fcurve(fcu);
-
+
/* make sure handles are all set correctly */
testhandles_fcurve(fcu);
}
@@ -3663,7 +3667,7 @@ void remake_graph_transdata (TransInfo *t, ListBase *anim_data)
}
/* this function is called on recalcData to apply the transforms applied
- * to the transdata on to the actual keyframe data
+ * to the transdata on to the actual keyframe data
*/
void flushTransGraphData(TransInfo *t)
{
@@ -3673,13 +3677,13 @@ void flushTransGraphData(TransInfo *t)
Scene *scene= t->scene;
double secf= FPS;
int a;
-
+
/* flush to 2d vector from internally used 3d vector */
for (a=0, td= t->data, td2d=t->data2d; a<t->total; a++, td++, td2d++) {
AnimData *adt= (AnimData *)td->extra; /* pointers to relevant AnimData blocks are stored in the td->extra pointers */
-
- /* handle snapping for time values
- * - we should still be in NLA-mapping timespace
+
+ /* handle snapping for time values
+ * - we should still be in NLA-mapping timespace
* - only apply to keyframes (but never to handles)
*/
if ((td->flag & TD_NOTIMESNAP)==0) {
@@ -3690,19 +3694,19 @@ void flushTransGraphData(TransInfo *t)
else
td2d->loc[0]= (float)( floor(td2d->loc[0]+0.5f) );
break;
-
+
case SACTSNAP_MARKER: /* snap to nearest marker */
td2d->loc[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, td2d->loc[0]);
break;
}
}
-
+
/* we need to unapply the nla-scaling from the time in some situations */
if (adt)
td2d->loc2d[0]= BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
else
td2d->loc2d[0]= td2d->loc[0];
-
+
/* if int-values only, truncate to integers */
if (td->flag & TD_INTVALUES)
td2d->loc2d[1]= (float)((int)td2d->loc[1]);
@@ -3739,13 +3743,13 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
TransDataIpokey *tdi= td->tdi;
BezTriple *bezt;
int a, delta= 0;
-
+
td->val= NULL; // is read on ESC
-
+
for(a=0; a<OB_TOTIPO; a++) {
if(ik->data[a]) {
bezt= ik->data[a];
-
+
switch( ob_ar[a] ) {
case OB_LOC_X:
case OB_DLOC_X:
@@ -3756,7 +3760,7 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
case OB_LOC_Z:
case OB_DLOC_Z:
tdi->locz= &(bezt->vec[1][1]); break;
-
+
case OB_DROT_X:
delta= 1;
case OB_ROT_X:
@@ -3769,7 +3773,7 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
delta= 1;
case OB_ROT_Z:
tdi->rotz= &(bezt->vec[1][1]); break;
-
+
case OB_SIZE_X:
case OB_DSIZE_X:
tdi->sizex= &(bezt->vec[1][1]); break;
@@ -3778,26 +3782,26 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
tdi->sizey= &(bezt->vec[1][1]); break;
case OB_SIZE_Z:
case OB_DSIZE_Z:
- tdi->sizez= &(bezt->vec[1][1]); break;
- }
+ tdi->sizez= &(bezt->vec[1][1]); break;
+ }
}
}
-
+
/* oldvals for e.g. undo */
if(tdi->locx) set_tdi_old(tdi->oldloc, tdi->locx);
if(tdi->locy) set_tdi_old(tdi->oldloc+1, tdi->locy);
if(tdi->locz) set_tdi_old(tdi->oldloc+2, tdi->locz);
-
+
/* remember, for mapping curves ('1'=10 degrees) */
if(tdi->rotx) set_tdi_old(tdi->oldrot, tdi->rotx);
if(tdi->roty) set_tdi_old(tdi->oldrot+1, tdi->roty);
if(tdi->rotz) set_tdi_old(tdi->oldrot+2, tdi->rotz);
-
+
/* this is not allowed to be dsize! */
if(tdi->sizex) set_tdi_old(tdi->oldsize, tdi->sizex);
if(tdi->sizey) set_tdi_old(tdi->oldsize+1, tdi->sizey);
if(tdi->sizez) set_tdi_old(tdi->oldsize+2, tdi->sizez);
-
+
tdi->flag= TOB_IPO;
if(delta) tdi->flag |= TOB_IPODROT;
}
@@ -3814,8 +3818,8 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
static short constraints_list_needinv(TransInfo *t, ListBase *list)
{
bConstraint *con;
-
- /* loop through constraints, checking if there's one of the mentioned
+
+ /* loop through constraints, checking if there's one of the mentioned
* constraints needing special crazyspace corrections
*/
if (list) {
@@ -3827,19 +3831,19 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list)
if (con->type == CONSTRAINT_TYPE_CHILDOF) return 1;
if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) return 1;
if (con->type == CONSTRAINT_TYPE_CLAMPTO) return 1;
-
+
/* constraints that require this only under special conditions */
if (con->type == CONSTRAINT_TYPE_ROTLIKE) {
/* CopyRot constraint only does this when rotating, and offset is on */
bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data;
-
+
if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION))
return 1;
}
}
}
}
-
+
/* no appropriate candidates found */
return 0;
}
@@ -3871,13 +3875,13 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
*flag= 0;
}
else if (seq->type ==SEQ_META) {
-
+
/* for meta's we only ever need to extend their children, no matter what depth
* just check the meta's are in the bounds */
if (t->frame_side=='R' && right <= cfra) *recursive= 0;
else if (t->frame_side=='L' && left >= cfra) *recursive= 0;
else *recursive= 1;
-
+
*count= 0;
*flag= 0;
}
@@ -4001,15 +4005,15 @@ static TransData *SeqToTransData(TransInfo *t, TransData *td, TransData2D *td2d,
td2d->loc[2] = 0.0f;
td2d->loc2d = NULL;
-
+
tdsq->seq= seq;
/* Use instead of seq->flag for nested strips and other
* cases where the selection may need to be modified */
tdsq->flag= flag;
tdsq->sel_flag= sel_flag;
-
-
+
+
td->extra= (void *)tdsq; /* allow us to update the strip from here */
td->flag = 0;
@@ -4031,7 +4035,7 @@ static TransData *SeqToTransData(TransInfo *t, TransData *td, TransData2D *td2d,
/* Time Transform (extend) */
td->val= td2d->loc;
td->ival= td2d->loc[0];
-
+
return td;
}
@@ -4040,15 +4044,15 @@ static int SeqToTransData_Recursive(TransInfo *t, ListBase *seqbase, TransData *
Sequence *seq;
int recursive, count, flag;
int tot= 0;
-
+
for (seq= seqbase->first; seq; seq= seq->next) {
SeqTransInfo(t, seq, &recursive, &count, &flag);
-
+
/* add children first so recalculating metastrips does nested strips first */
if (recursive) {
int tot_children= SeqToTransData_Recursive(t, &seq->seqbase, td, td2d, tdsq);
-
+
td= td + tot_children;
td2d= td2d + tot_children;
tdsq= tdsq + tot_children;
@@ -4081,7 +4085,7 @@ static int SeqToTransData_Recursive(TransInfo *t, ListBase *seqbase, TransData *
static void createTransSeqData(bContext *C, TransInfo *t)
{
-
+
View2D *v2d= UI_view2d_fromcontext(C);
Scene *scene= CTX_data_scene(C);
Editing *ed= seq_give_editing(t->scene, FALSE);
@@ -4119,12 +4123,12 @@ static void createTransSeqData(bContext *C, TransInfo *t)
if (count == 0) {
return;
}
-
+
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransSeq TransData");
td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransSeq TransData2D");
tdsq = t->customData= MEM_callocN(t->total*sizeof(TransDataSeq), "TransSeq TransDataSeq");
-
+
/* loop 2: build transdata array */
SeqToTransData_Recursive(t, ed->seqbasep, td, td2d, tdsq);
@@ -4132,7 +4136,7 @@ static void createTransSeqData(bContext *C, TransInfo *t)
/* transcribe given object into TransData for Transforming */
-static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *ob)
+static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *ob)
{
Scene *scene = CTX_data_scene(C);
Object *track;
@@ -4146,35 +4150,35 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *
Mat3Ortho(td->axismtx);
td->con= ob->constraints.first;
-
- /* hack: tempolarily disable tracking and/or constraints when getting
+
+ /* hack: tempolarily disable tracking and/or constraints when getting
* object matrix, if tracking is on, or if constraints don't need
* inverse correction to stop it from screwing up space conversion
* matrix later
*/
constinv = constraints_list_needinv(t, &ob->constraints);
-
+
/* disable constraints inversion for dummy pass */
if (t->mode == TFM_DUMMY)
skip_invert = 1;
-
+
if (skip_invert == 0 && (ob->track || constinv==0)) {
track= ob->track;
ob->track= NULL;
-
+
if (constinv == 0) {
fakecons.first = ob->constraints.first;
fakecons.last = ob->constraints.last;
ob->constraints.first = ob->constraints.last = NULL;
}
-
+
where_is_object(t->scene, ob);
-
+
if (constinv == 0) {
ob->constraints.first = fakecons.first;
ob->constraints.last = fakecons.last;
}
-
+
ob->track= track;
}
else
@@ -4184,23 +4188,23 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *
td->loc = ob->loc;
VECCOPY(td->iloc, td->loc);
-
+
td->ext->rot = ob->rot;
VECCOPY(td->ext->irot, ob->rot);
VECCOPY(td->ext->drot, ob->drot);
-
+
td->ext->size = ob->size;
VECCOPY(td->ext->isize, ob->size);
VECCOPY(td->ext->dsize, ob->dsize);
VECCOPY(td->center, ob->obmat[3]);
-
+
Mat4CpyMat4(td->ext->obmat, ob->obmat);
/* is there a need to set the global<->data space conversion matrices? */
if (ob->parent || constinv) {
float totmat[3][3], obinv[3][3];
-
+
/* Get the effect of parenting, and/or certain constraints.
* NOTE: some Constraints, and also Tracking should never get this
* done, as it doesn't work well.
@@ -4216,7 +4220,7 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *
Mat3One(td->smtx);
Mat3One(td->mtx);
}
-
+
/* set active flag */
if (ob == OBACT)
{
@@ -4231,39 +4235,39 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t)
{
Scene *sce = CTX_data_scene(C);
View3D *v3d = t->view;
-
+
/*
if Base selected and has parent selected:
base->flag= BA_WAS_SEL
*/
Base *base;
-
+
/* don't do it if we're not actually going to recalculate anything */
if(t->mode == TFM_DUMMY)
return;
/* makes sure base flags and object flags are identical */
copy_baseflags(t->scene);
-
+
/* handle pending update events, otherwise they got copied below */
for (base= sce->base.first; base; base= base->next) {
- if(base->object->recalc)
+ if(base->object->recalc)
object_handle_update(t->scene, base->object);
}
-
+
for (base= sce->base.first; base; base= base->next) {
base->flag &= ~BA_WAS_SEL;
-
+
if(TESTBASELIB(v3d, base)) {
Object *ob= base->object;
Object *parsel= ob->parent;
-
+
/* if parent selected, deselect */
while(parsel) {
if(parsel->flag & SELECT) break;
parsel= parsel->parent;
}
-
+
if(parsel)
{
if ((t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL) && t->around == V3D_LOCAL)
@@ -4283,7 +4287,7 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t)
/* all recalc flags get flushed to all layers, so a layer flip later on works fine */
DAG_scene_flush_update(t->scene, -1, 0);
-
+
/* and we store them temporal in base (only used for transform code) */
/* this because after doing updates, the object->recalc is cleared */
for (base= sce->base.first; base; base= base->next) {
@@ -4298,7 +4302,7 @@ static void clear_trans_object_base_flags(TransInfo *t)
{
Scene *sce = t->scene;
Base *base;
-
+
for (base= sce->base.first; base; base = base->next)
{
if(base->flag & BA_WAS_SEL)
@@ -4313,34 +4317,34 @@ static void clear_trans_object_base_flags(TransInfo *t)
short autokeyframe_cfra_can_key(Scene *scene, Object *ob)
{
float cfra= (float)CFRA; // XXX for now, this will do
-
+
/* only filter if auto-key mode requires this */
if (IS_AUTOKEY_ON(scene) == 0)
return 0;
- else if (IS_AUTOKEY_MODE(scene, NORMAL))
+ else if (IS_AUTOKEY_MODE(scene, NORMAL))
return 1;
- else
+ else
return id_frame_has_keyframe(&ob->id, cfra, ANIMFILTER_KEYS_LOCAL);
}
-/* auto-keyframing feature - for objects
- * tmode: should be a transform mode
+/* auto-keyframing feature - for objects
+ * tmode: should be a transform mode
*/
void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
{
ID *id= &ob->id;
FCurve *fcu;
-
+
if (autokeyframe_cfra_can_key(scene, ob)) {
AnimData *adt= ob->adt;
float cfra= (float)CFRA; // xxx this will do for now
short flag = 0;
-
+
if (IS_AUTOKEY_FLAG(INSERTNEEDED))
flag |= INSERTKEY_NEEDED;
if (IS_AUTOKEY_FLAG(AUTOMATKEY))
flag |= INSERTKEY_MATRIX;
-
+
if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
/* only key on available channels */
if (adt && adt->action) {
@@ -4352,7 +4356,7 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
}
else if (IS_AUTOKEY_FLAG(INSERTNEEDED)) {
short doLoc=0, doRot=0, doScale=0;
-
+
/* filter the conditions when this happens (assume that curarea->spacetype==SPACE_VIE3D) */
if (tmode == TFM_TRANSLATION) {
doLoc = 1;
@@ -4363,9 +4367,9 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
doLoc = 1;
}
else if (v3d->around == V3D_CURSOR)
- doLoc = 1;
-
- if ((v3d->flag & V3D_ALIGN)==0)
+ doLoc = 1;
+
+ if ((v3d->flag & V3D_ALIGN)==0)
doRot = 1;
}
else if (tmode == TFM_RESIZE) {
@@ -4374,12 +4378,12 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
doLoc = 1;
}
else if (v3d->around == V3D_CURSOR)
- doLoc = 1;
-
+ doLoc = 1;
+
if ((v3d->flag & V3D_ALIGN)==0)
doScale = 1;
}
-
+
// TODO: the group names here are temporary...
// TODO: should this be made to use the builtin KeyingSets instead?
if (doLoc) {
@@ -4404,22 +4408,22 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
insert_keyframe(id, NULL, "Object Transform", "location", 0, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "location", 1, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "location", 2, cfra, flag);
-
+
insert_keyframe(id, NULL, "Object Transform", "rotation", 0, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "rotation", 1, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "rotation", 2, cfra, flag);
-
+
insert_keyframe(id, NULL, "Object Transform", "scale", 0, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "scale", 1, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "scale", 2, cfra, flag);
}
-
+
// XXX todo... find a way to send notifiers from here...
}
}
-/* auto-keyframing feature - for poses/pose-channels
- * tmode: should be a transform mode
+/* auto-keyframing feature - for poses/pose-channels
+ * tmode: should be a transform mode
* targetless_ik: has targetless ik been done on any channels?
*/
void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode, short targetless_ik)
@@ -4431,13 +4435,13 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
bPose *pose= ob->pose;
bPoseChannel *pchan;
FCurve *fcu;
-
+
if (autokeyframe_cfra_can_key(scene, ob)) {
float cfra= (float)CFRA;
short flag= 0;
char buf[512];
-
- /* flag is initialised from UserPref keyframing settings
+
+ /* flag is initialised from UserPref keyframing settings
* - special exception for targetless IK - INSERTKEY_MATRIX keyframes should get
* visual keyframes even if flag not set, as it's not that useful otherwise
* (for quick animation recording)
@@ -4446,12 +4450,12 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
flag |= INSERTKEY_MATRIX;
if (IS_AUTOKEY_FLAG(INSERTNEEDED))
flag |= INSERTKEY_NEEDED;
-
+
for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
if (pchan->bone->flag & BONE_TRANSFORM) {
/* clear any 'unkeyed' flag it may have */
pchan->bone->flag &= ~BONE_UNKEYED;
-
+
/* only insert into available channels? */
if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
if (act) {
@@ -4462,29 +4466,29 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
/* only insert keyframe if needed? */
else if (IS_AUTOKEY_FLAG(INSERTNEEDED)) {
short doLoc=0, doRot=0, doScale=0;
-
+
/* filter the conditions when this happens (assume that curarea->spacetype==SPACE_VIE3D) */
if (tmode == TFM_TRANSLATION) {
- if (targetless_ik)
+ if (targetless_ik)
doRot= 1;
- else
+ else
doLoc = 1;
}
else if (tmode == TFM_ROTATION) {
if (ELEM(v3d->around, V3D_CURSOR, V3D_ACTIVE))
doLoc = 1;
-
- if ((v3d->flag & V3D_ALIGN)==0)
+
+ if ((v3d->flag & V3D_ALIGN)==0)
doRot = 1;
}
else if (tmode == TFM_RESIZE) {
if (ELEM(v3d->around, V3D_CURSOR, V3D_ACTIVE))
doLoc = 1;
-
+
if ((v3d->flag & V3D_ALIGN)==0)
doScale = 1;
}
-
+
if (doLoc) {
sprintf(buf, "pose.pose_channels[\"%s\"].location", pchan->name);
insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag);
@@ -4519,7 +4523,7 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag);
insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag);
insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag);
-
+
if (pchan->rotmode == PCHAN_ROT_QUAT) {
sprintf(buf, "pose.pose_channels[\"%s\"].rotation", pchan->name);
insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag);
@@ -4533,7 +4537,7 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag);
insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag);
}
-
+
sprintf(buf, "pose.pose_channels[\"%s\"].scale", pchan->name);
insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag);
insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag);
@@ -4541,15 +4545,15 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
}
}
}
-
+
// XXX todo... figure out way to get appropriate notifiers sent
-
+
/* do the bone paths */
#if 0 // TRANSFORM_FIX_ME
if (arm->pathflag & ARM_PATH_ACFRA) {
pose_clear_paths(ob);
pose_recalculate_paths(ob);
- }
+ }
#endif
}
else {
@@ -4573,7 +4577,7 @@ void special_aftertrans_update(TransInfo *t)
// short redrawipo=0, resetslowpar=1;
int cancelled= (t->state == TRANS_CANCEL);
short duplicate= (t->undostr && strstr(t->undostr, "Duplicate")) ? 1 : 0;
-
+
if (t->spacetype==SPACE_VIEW3D) {
if (t->obedit) {
if (cancelled==0) {
@@ -4596,7 +4600,7 @@ void special_aftertrans_update(TransInfo *t)
#if 0 // TRANSFORM_FIX_ME, Would prefer to use this since the array takes into
// account what where transforming (with extend, locked strips etc)
// But at the moment t->data is freed in postTrans so for now re-shuffeling selected strips works ok. - Campbell
-
+
int a;
TransData *td= t->data;
@@ -4621,7 +4625,7 @@ void special_aftertrans_update(TransInfo *t)
for(seq= seqbasep->first; seq; seq= seq->next) {
max_machine = MAX2(max_machine, seq->machine);
}
-
+
for (machine = 0; machine <= max_machine; machine++)
{
for(seq= seqbasep->first; seq; seq= seq->next) {
@@ -4631,7 +4635,7 @@ void special_aftertrans_update(TransInfo *t)
}
}
#endif
-
+
for(seq= seqbasep->first; seq; seq= seq->next) {
/* We might want to build a list of effects that need to be updated during transform */
if(seq->type & SEQ_EFFECT) {
@@ -4643,7 +4647,7 @@ void special_aftertrans_update(TransInfo *t)
sort_seq(t->scene);
}
-
+
if (t->customData)
MEM_freeN(t->customData);
if (t->data)
@@ -4653,39 +4657,39 @@ void special_aftertrans_update(TransInfo *t)
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
Scene *scene;
bAnimContext ac;
-
+
/* 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;
ob= 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;
-
+
if (ANIM_animdata_context_getdata(&ac) == 0)
return;
-
+
if (ac.datatype == ANIMCONT_DOPESHEET) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
-
+
/* get channels to work on */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* these should all be ipo-blocks */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
-
- if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
+
+ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
posttrans_fcurve_clean(fcu);
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
}
@@ -4693,7 +4697,7 @@ void special_aftertrans_update(TransInfo *t)
posttrans_fcurve_clean(fcu);
}
}
-
+
/* free temp memory */
BLI_freelistN(&anim_data);
}
@@ -4702,15 +4706,15 @@ void special_aftertrans_update(TransInfo *t)
// fixme... some of this stuff is not good
if (ob) {
ob->ctime= -1234567.0f;
-
+
if (ob->pose || ob_get_key(ob))
DAG_object_flush_update(scene, ob, OB_RECALC);
else
DAG_object_flush_update(scene, ob, OB_RECALC_OB);
}
-
+
/* Do curve cleanups? */
- if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
+ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
posttrans_action_clean(&ac, (bAction *)ac.data);
@@ -4720,16 +4724,16 @@ void special_aftertrans_update(TransInfo *t)
#if 0 // XXX old animation system
/* fix up the Ipocurves and redraw stuff */
Key *key= (Key *)ac.data;
-
+
if (key->ipo) {
- if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
+ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
posttrans_ipo_clean(key->ipo);
}
}
#endif // XXX old animation system
-
+
DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
}
#if 0 // XXX future of this is still not clear
@@ -4739,23 +4743,23 @@ void special_aftertrans_update(TransInfo *t)
{
bScreen *sc= (bScreen *)ac.data;
ScrArea *sa;
-
+
/* BAD... we need to loop over all screen areas for current screen...
- * - sync this with actdata_filter_gpencil() in editaction.c
+ * - sync this with actdata_filter_gpencil() in editaction.c
*/
for (sa= sc->areabase.first; sa; sa= sa->next) {
bGPdata *gpd= gpencil_data_getactive(sa);
-
- if (gpd)
+
+ if (gpd)
posttrans_gpd_clean(gpd);
}
}
}
#endif // XXX future of this is still not clear
-
+
/* make sure all F-Curves are set correctly */
ANIM_editkeyframes_refresh(&ac);
-
+
/* clear flag that was set for time-slide drawing */
saction->flag &= ~SACTION_MOVING;
}
@@ -4763,40 +4767,40 @@ void special_aftertrans_update(TransInfo *t)
SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
Scene *scene;
bAnimContext ac;
-
+
/* 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;
ob= 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;
-
+
if (ANIM_animdata_context_getdata(&ac) == 0)
return;
-
- if (ac.datatype)
+
+ if (ac.datatype)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
-
+
/* get channels to work on */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* these should all be ipo-blocks */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
-
- if ( (sipo->flag & SIPO_NOTRANSKEYCULL)==0 &&
+
+ if ( (sipo->flag & SIPO_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
posttrans_fcurve_clean(fcu);
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
}
@@ -4804,55 +4808,55 @@ void special_aftertrans_update(TransInfo *t)
posttrans_fcurve_clean(fcu);
}
}
-
+
/* free temp memory */
BLI_freelistN(&anim_data);
}
-
+
/* make sure all F-Curves are set correctly */
ANIM_editkeyframes_refresh(&ac);
}
else if (t->spacetype == SPACE_NLA) {
Scene *scene;
bAnimContext ac;
-
+
/* 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;
ob= 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;
-
+
if (ANIM_animdata_context_getdata(&ac) == 0)
return;
-
- if (ac.datatype)
+
+ if (ac.datatype)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NLATRACKS);
-
+
/* get channels to work on */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale= anim_data.first; ale; ale= ale->next) {
NlaTrack *nlt= (NlaTrack *)ale->data;
-
+
/* make sure strips are in order again */
BKE_nlatrack_sort_strips(nlt);
-
+
/* remove the temp metas */
BKE_nlastrips_clear_metas(&nlt->strips, 0, 1);
}
-
+
/* free temp memory */
BLI_freelistN(&anim_data);
}
-
+
// XXX check on the calls below... we need some of these sanity checks
//synchronize_action_strips();
//ANIM_editkeyframes_refresh(&ac);
@@ -4861,7 +4865,7 @@ void special_aftertrans_update(TransInfo *t)
// TRANSFORM_FIX_ME
// if (t->mode==TFM_BONESIZE || t->mode==TFM_BONE_ENVELOPE)
// allqueue(REDRAWBUTSEDIT, 0);
-
+
if (t->obedit->type == OB_MESH)
{
EditMesh *em = ((Mesh *)t->obedit->data)->edit_mesh;
@@ -4874,11 +4878,11 @@ void special_aftertrans_update(TransInfo *t)
bPose *pose;
bPoseChannel *pchan;
short targetless_ik= 0;
-
+
ob= t->poseobj;
arm= ob->data;
pose= ob->pose;
-
+
/* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
if (!cancelled && t->mode==TFM_TRANSLATION)
targetless_ik= apply_targetless_ik(ob);
@@ -4889,10 +4893,10 @@ void special_aftertrans_update(TransInfo *t)
if(data) data->flag &= ~CONSTRAINT_IK_AUTO;
}
}
-
+
if (t->mode==TFM_TRANSLATION)
pose_grab_with_ik_clear(ob);
-
+
/* automatic inserting of keys and unkeyed tagging - only if transform wasn't cancelled (or TFM_DUMMY) */
if (!cancelled && (t->mode != TFM_DUMMY)) {
autokeyframe_pose_cb_func(t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
@@ -4903,26 +4907,26 @@ void special_aftertrans_update(TransInfo *t)
DAG_object_flush_update(t->scene, ob, OB_RECALC_DATA);
ob->recalc= 0; // is set on OK position already by recalcData()
}
- else
+ else
DAG_object_flush_update(t->scene, ob, OB_RECALC_DATA);
-
+
//if (t->mode==TFM_BONESIZE || t->mode==TFM_BONE_ENVELOPE)
// allqueue(REDRAWBUTSEDIT, 0);
-
+
}
else if(G.f & G_PARTICLEEDIT) {
;
}
- else {
+ else {
/* Objects */
// XXX ideally, this would go through context iterators, but we don't have context iterator access here,
// so we make do with old data + access styles...
Scene *scene= t->scene;
Base *base;
-
+
for (base= FIRSTBASE; base; base= base->next) {
ob= base->object;
-
+
if (base->flag & SELECT && (t->mode != TFM_DUMMY)) {
/* pointcache refresh */
if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH))
@@ -4933,14 +4937,14 @@ void special_aftertrans_update(TransInfo *t)
/* autokey though, probably needed is an anim sys override? */
/* Please remove if some other solution is found. -jahka */
DAG_object_flush_update(scene, ob, OB_RECALC_OB);
-
+
/* Set autokey if necessary */
if (!cancelled)
autokeyframe_ob_cb_func(t->scene, (View3D *)t->view, ob, t->mode);
}
}
}
-
+
clear_trans_object_base_flags(t);
#if 0 // TRANSFORM_FIX_ME
@@ -4949,10 +4953,10 @@ void special_aftertrans_update(TransInfo *t)
allqueue(REDRAWACTION, 0);
allqueue(REDRAWIPO, 0);
}
-
+
if(resetslowpar)
reset_slowparents();
-
+
/* note; should actually only be done for all objects when a lamp is moved... (ton) */
if(t->spacetype==SPACE_VIEW3D && G.vd->drawtype == OB_SHADED)
reshadeall_displist();
@@ -4965,10 +4969,10 @@ static void createTransObject(bContext *C, TransInfo *t)
TransDataExtension *tx;
// IpoKey *ik;
// ListBase elems;
-
+
set_trans_object_base_flags(C, t);
- /* count */
+ /* count */
CTX_DATA_BEGIN(C, Object*, ob, selected_objects)
{
#if 0 // TRANSFORM_FIX_ME
@@ -4976,12 +4980,12 @@ static void createTransObject(bContext *C, TransInfo *t)
if ((ob->id.lib == 0) && (ob->ipo) && (ob->ipo->showkey) && (ob->ipoflag & OB_DRAWKEY)) {
elems.first= elems.last= NULL;
make_ipokey_transform(ob, &elems, 1); /* '1' only selected keys */
-
+
pushdata(&elems, sizeof(ListBase));
-
+
for(ik= elems.first; ik; ik= ik->next)
t->total++;
-
+
if(elems.first==NULL)
t->total++;
}
@@ -4997,24 +5001,24 @@ static void createTransObject(bContext *C, TransInfo *t)
clear_trans_object_base_flags(t);
return;
}
-
+
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransOb");
tx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "TransObExtension");
CTX_DATA_BEGIN(C, Base*, base, selected_bases)
{
Object *ob= base->object;
-
+
td->flag = TD_SELECTED;
td->protectflag= ob->protectflag;
td->ext = tx;
-
+
if (base->flag & BA_TRANSFORM_CHILD)
{
td->flag |= TD_NOCENTER;
td->flag |= TD_NO_LOC;
}
-
+
/* select linked objects, but skip them later */
if (ob->id.lib != 0) {
td->flag |= TD_SKIP;
@@ -5024,55 +5028,55 @@ static void createTransObject(bContext *C, TransInfo *t)
// TRANSFORM_FIX_ME
#if 0
if((ob->id.lib == 0) && (ob->ipo) && (ob->ipo->showkey) && (ob->ipoflag & OB_DRAWKEY)) {
-
+
popfirst(&elems); // bring back pushed listbase
-
+
if(elems.first) {
int cfraont;
int ipoflag;
-
+
base->flag |= BA_DO_IPO+BA_WAS_SEL;
base->flag &= ~SELECT;
-
+
cfraont= CFRA;
set_no_parent_ipo(1);
ipoflag= ob->ipoflag;
ob->ipoflag &= ~OB_OFFS_OB;
-
+
/*
* This is really EVIL code that pushes down Object values
* (loc, dloc, orig, size, dsize, rot, drot)
* */
-
+
pushdata((void*)ob->loc, 7 * 3 * sizeof(float)); // tsk! tsk!
-
+
for(ik= elems.first; ik; ik= ik->next) {
-
+
/* weak... this doesn't correct for floating values, giving small errors */
CFRA= (int)(ik->val/t->scene->r.framelen);
-
+
do_ob_ipo(ob);
ObjectToTransData(C, t, td, ob); // does where_is_object()
-
+
td->flag= TD_SELECTED;
-
+
td->tdi= MEM_callocN(sizeof(TransDataIpokey), "TransDataIpokey");
/* also does tdi->flag and oldvals, needs to be after ob_to_transob()! */
ipokey_to_transdata(ik, td);
-
+
td++;
tx++;
if(ik->next) td->ext= tx; // prevent corrupting mem!
}
free_ipokey(&elems);
-
+
poplast(ob->loc);
set_no_parent_ipo(0);
-
+
CFRA= cfraont;
ob->ipoflag= ipoflag;
-
- where_is_object(t->scene, ob); // restore
+
+ where_is_object(t->scene, ob); // restore
}
else {
ObjectToTransData(C, t, td, ob);
@@ -5096,7 +5100,7 @@ static void createTransObject(bContext *C, TransInfo *t)
/* transcribe given node into TransData2D for Transforming */
static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
-// static void NodeToTransData(bContext *C, TransInfo *t, TransData2D *td, bNode *node)
+// static void NodeToTransData(bContext *C, TransInfo *t, TransData2D *td, bNode *node)
{
td2d->loc[0] = node->locx; /* hold original location */
td2d->loc[1] = node->locy;
@@ -5124,22 +5128,22 @@ void createTransNodeData(bContext *C, TransInfo *t)
{
TransData *td;
TransData2D *td2d;
-
+
t->total= CTX_DATA_COUNT(C, selected_nodes);
-
+
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransNode TransData");
td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransNode TransData2D");
-
+
CTX_DATA_BEGIN(C, bNode *, selnode, selected_nodes)
NodeToTransData(td++, td2d++, selnode);
CTX_DATA_END
}
-void createTransData(bContext *C, TransInfo *t)
+void createTransData(bContext *C, TransInfo *t)
{
Scene *scene = CTX_data_scene(C);
Object *ob = OBACT;
-
+
if (t->options == CTX_TEXTURE) {
t->flag |= T_TEXTURE;
createTransTexspace(C, t);
@@ -5183,7 +5187,7 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->spacetype == SPACE_IPO) {
t->flag |= T_POINTS|T_2D_EDIT;
createTransGraphEditData(C, t);
-#if 0
+#if 0
if (t->data && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
@@ -5203,7 +5207,7 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->obedit) {
t->ext = NULL;
if (t->obedit->type == OB_MESH) {
- createTransEditVerts(C, t);
+ createTransEditVerts(C, t);
}
else if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
createTransCurveVerts(C, t);
@@ -5217,7 +5221,7 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->obedit->type==OB_ARMATURE) {
t->flag &= ~T_PROP_EDIT;
createTransArmatureVerts(C, t);
- }
+ }
else {
printf("edit type not implemented!\n");
}
@@ -5236,7 +5240,7 @@ void createTransData(bContext *C, TransInfo *t)
}
t->flag |= T_EDIT|T_POINTS;
-
+
/* exception... hackish, we want bonesize to use bone orientation matrix (ton) */
if(t->mode==TFM_BONESIZE) {
t->flag &= ~(T_EDIT|T_POINTS);
@@ -5245,7 +5249,7 @@ void createTransData(bContext *C, TransInfo *t)
}
}
else if (ob && (ob->flag & OB_POSEMODE)) {
- // XXX this is currently limited to active armature only...
+ // XXX this is currently limited to active armature only...
// XXX active-layer checking isn't done as that should probably be checked through context instead
createTransPose(C, t, ob);
}
@@ -5279,7 +5283,7 @@ void createTransData(bContext *C, TransInfo *t)
t->flag &= ~T_PROP_EDIT; /* no proportional edit in object mode */
createTransObject(C, t);
t->flag |= T_OBJECT;
-
+
if (t->ar->regiontype == RGN_TYPE_WINDOW)
{
View3D *v3d = t->view;
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 3415c266cf1..af56079727f 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -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 */
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 7c71e89f948..c656b097cb9 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -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 {