TFM_BAKE_TIME,
TFM_BEVEL,
TFM_BWEIGHT,
- TFM_ALIGN,
- TFM_NODE_TRANSLATE
+ TFM_ALIGN
} TfmModesInputFlags;
/* TRANSFORM CONTEXTS */
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)
return "Key Time";
case TFM_MIRROR:
return "Mirror";
- case TFM_NODE_TRANSLATE:
- return "Node Translate";
}
return "Transform";
}
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 */
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
{
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);
}
#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;
-}
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);
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]);
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)
}
/* 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
}
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);
}
}
-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;
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++) {
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;
}