diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/BIF_transform.h | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 80 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 52 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 21 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 11 |
6 files changed, 70 insertions, 101 deletions
diff --git a/source/blender/editors/include/BIF_transform.h b/source/blender/editors/include/BIF_transform.h index 02e931f4198..fbcec8eaadb 100644 --- a/source/blender/editors/include/BIF_transform.h +++ b/source/blender/editors/include/BIF_transform.h @@ -71,8 +71,7 @@ enum { TFM_BAKE_TIME, TFM_BEVEL, TFM_BWEIGHT, - TFM_ALIGN, - TFM_NODE_TRANSLATE + TFM_ALIGN } TfmModesInputFlags; /* TRANSFORM CONTEXTS */ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e513a4fcbbc..5d10a07231b 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -220,6 +220,17 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy) vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy) / (divy); vec[2]= 0.0f; } + 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; + } } void projectIntView(TransInfo *t, float *vec, int *adr) @@ -550,8 +561,6 @@ static char *transform_to_undostr(TransInfo *t) return "Key Time"; case TFM_MIRROR: return "Mirror"; - case TFM_NODE_TRANSLATE: - return "Node Translate"; } return "Transform"; } @@ -1080,13 +1089,8 @@ void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) case TFM_ALIGN: initAlign(t); break; - case TFM_NODE_TRANSLATE: - initNodeTranslate(t); - break; } - - - + RNA_float_get_array(op->ptr, "values", values); /* overwrite initial values if operator supplied a non-null vector */ @@ -1135,12 +1139,7 @@ int transformEnd(bContext *C, TransInfo *t) if(t->state == TRANS_CANCEL) { exit_code = OPERATOR_CANCELLED; - - /* TRANSFORM_FIX_ME fix jesty's node stuff, shouldn't be exceptional at this level */ - if(t->spacetype == SPACE_NODE) - restoreTransNodes(t); - else - restoreTransObjects(t); // calls recalcData() + restoreTransObjects(t); // calls recalcData() } else { @@ -2953,7 +2952,7 @@ int Translation(TransInfo *t, short mval[2]) applyTranslation(t, t->values); - /* evil hack - redo translation if cliiping needeed */ + /* evil hack - redo translation if clipping needed */ if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 0)) applyTranslation(t, t->values); @@ -4584,54 +4583,3 @@ void NDofTransform() } #endif } - -/* *** Node translation *** */ - -void initNodeTranslate(TransInfo *t) -{ - t->mode = TFM_NODE_TRANSLATE; - t->transform = NodeTranslate; - - 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[1] = t->snap[2] = 1.0f; -} - -static void applyNodeTranslate(TransInfo *t) -{ - TransData2D *td = t->data2d; - int i; - - for (i = 0 ; i < t->total; i++, td++) { - td->loc2d[0]= td->loc[0]+t->values[0]; - td->loc2d[1]= td->loc[1]+t->values[1]; - } -} - -int NodeTranslate(TransInfo *t, short mval[2]) -{ - View2D *v2d = &t->ar->v2d; - float cval[2], sval[2]; - - /* calculate translation amount from mouse movement - in 'node-grid space' */ - UI_view2d_region_to_view(v2d, mval[0], mval[1], &cval[0], &cval[1]); - UI_view2d_region_to_view(v2d, t->imval[0], t->imval[1], &sval[0], &sval[1]); - - t->values[0] = cval[0] - sval[0]; - t->values[1] = cval[1] - sval[1]; - - applyNodeTranslate(t); - - recalcData(t); - - viewRedrawForce(t); - - return 1; -} diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 078109a0a1f..806afa8e624 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -433,9 +433,6 @@ int Mirror(TransInfo *t, short mval[2]); void initAlign(TransInfo *t); int Align(TransInfo *t, short mval[2]); -void initNodeTranslate(TransInfo *t); -int NodeTranslate(TransInfo *t, short mval[2]); - /*********************** transform_conversions.c ********** */ struct ListBase; void flushTransGPactionData(TransInfo *t); @@ -443,6 +440,7 @@ void flushTransIpoData(TransInfo *t); void flushTransUVs(TransInfo *t); void flushTransParticles(TransInfo *t); int clipUVTransform(TransInfo *t, float *vec, int resize); +void flushTransNodes(TransInfo *t); /*********************** exported from transform_manipulator.c ********** */ void draw_manipulator_ext(struct ScrArea *sa, int type, char axis, int col, float vec[3], float mat[][3]); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 8d73c808745..6b9c635779f 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2279,6 +2279,19 @@ static void createTransEditVerts(bContext *C, TransInfo *t) MEM_freeN(defmats); } +/* *** NODE EDITOR *** */ +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]; + td->loc2d[1]= td->loc[1]; + } +} + /* ********************* UV ****************** */ static void UVsToTransData(TransData *td, TransData2D *td2d, float *uv, int selected) @@ -4108,28 +4121,43 @@ static void createTransObject(bContext *C, TransInfo *t) } /* transcribe given node into TransData2D for Transforming */ -static void NodeToTransData(bContext *C, TransInfo *t, TransData2D *td, bNode *node) +static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) +// static void NodeToTransData(bContext *C, TransInfo *t, TransData2D *td, bNode *node) { - /* Note: since locx and locy come after each other in bNode struct, this works */ - td->loc2d = &node->locx; - - /* initial location */ - td->loc[0]= node->locx; - td->loc[1]= node->locy; + td2d->loc[0] = node->locx; /* hold original location */ + td2d->loc[1] = node->locy; + td2d->loc[2] = 0.0f; + td2d->loc2d = &node->locx; /* current location */ + + td->flag = 0; + td->loc = td2d->loc; + VECCOPY(td->center, td->loc); + VECCOPY(td->iloc, td->loc); + + 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.0; + + Mat3One(td->mtx); + Mat3One(td->smtx); } void createTransNodeData(bContext *C, TransInfo *t) { - TransData2D *td; - int i= 0; + TransData *td; + TransData2D *td2d; CTX_DATA_COUNT(C, selected_nodes, t->total) - td = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransNode"); + 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(C, t, td, selnode); - td++; + NodeToTransData(td++, td2d++, selnode); CTX_DATA_END } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index e817b069034..d1993a79bf6 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -575,7 +575,10 @@ void recalcData(TransInfo *t) flushTransParticles(t); } #endif - if (t->obedit) { + if (t->spacetype==SPACE_NODE) { + flushTransNodes(t); + } + else if (t->obedit) { if (t->obedit->type == OB_MESH) { if(t->spacetype==SPACE_IMAGE) { flushTransUVs(t); @@ -918,20 +921,6 @@ static void restoreElement(TransData *td) { } } -static void restoreNode(TransData2D *td) -{ - td->loc2d[0]= td->loc[0]; - td->loc2d[1]= td->loc[1]; -} - -void restoreTransNodes(TransInfo *t) -{ - TransData2D *td; - for (td = t->data2d; td < t->data2d + t->total; td++) { - restoreNode(td); - } -} - void restoreTransObjects(TransInfo *t) { TransData *td; @@ -1185,8 +1174,6 @@ void calculatePropRatio(TransInfo *t) int i; float dist; short connected = t->flag & T_PROP_CONNECTED; - - if (t->spacetype == SPACE_NODE) return; if (t->flag & T_PROP_EDIT) { for(i = 0 ; i < t->total; i++, td++) { diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 35d1f45bf33..e15fd3780ea 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -201,9 +201,18 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key km= WM_keymap_add_item(keymap, "TFM_OT_transform", TKEY, KM_PRESS, 0, 0); RNA_int_set(km->ptr, "mode", TFM_TIME_SLIDE); + break; + case SPACE_NODE: km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_NODE_TRANSLATE); + RNA_int_set(km->ptr, "mode", TFM_TRANSLATION); + + km = WM_keymap_add_item(keymap, "TFM_OT_transform", RKEY, KM_PRESS, 0, 0); + RNA_int_set(km->ptr, "mode", TFM_ROTATION); + + km = WM_keymap_add_item(keymap, "TFM_OT_transform", SKEY, KM_PRESS, 0, 0); + RNA_int_set(km->ptr, "mode", TFM_RESIZE); + break; default: break; } |