Page MenuHome

Cursor transform
ActivePublic

Authored by Campbell Barton (campbellbarton) on Jul 4 2014, 11:13 PM.
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 41ff9b8..e7805ad 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -98,6 +98,7 @@ enum TfmMode {
#define CTX_NDOF (1 << 5)
#define CTX_MOVIECLIP (1 << 6)
#define CTX_MASK (1 << 7)
+#define CTX_CURSOR (1 << 8)
/* Standalone call to get the transformation center corresponding to the current situation
* returns 1 if successful, 0 otherwise (usually means there's no selection)
@@ -145,6 +146,7 @@ int BIF_countTransformOrientation(const struct bContext *C);
#define P_CORRECT_UV (1 << 8)
#define P_NO_DEFAULTS (1 << 10)
#define P_NO_TEXSPACE (1 << 11)
+#define P_CURSOR (1 << 12)
void Transform_Properties(struct wmOperatorType *ot, int flags);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index e3260db..8d425d2 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4435,7 +4435,7 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
}
}
-static void view3d_cursor3d_update(bContext *C, const int *mval)
+static void view3d_cursor3d_update(bContext *C, const int mval[2])
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -4468,8 +4468,14 @@ static int view3d_cursor3d_modal(bContext *C, wmOperator *op, const wmEvent *eve
switch (event->type) {
case MOUSEMOVE:
- view3d_cursor3d_update(C, event->mval);
- break;
+ {
+ PointerRNA ptr;
+ WM_operator_properties_create(&ptr, "TRANSFORM_OT_translate");
+ RNA_boolean_set(&ptr, "use_cursor", true);
+ WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, &ptr);
+
+ return OPERATOR_FINISHED;
+ }
case LEFTMOUSE:
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 32ba4ba..2a259f7 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1457,6 +1457,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
break;
+ case LEFTMOUSE: /* XXX!!! - ONLY FOR TESTING */
+ t->state = TRANS_CONFIRM;
+ handled = true;
case LEFTALTKEY:
case RIGHTALTKEY:
if (ELEM(t->spacetype, SPACE_SEQ, SPACE_VIEW3D)) {
@@ -1833,8 +1836,6 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg)
{
TransInfo *t = arg;
- Scene *scene = t->scene;
- Object *ob = OBACT;
/* draw autokeyframing hint in the corner
* - only draw if enabled (advanced users may be distracted/annoyed),
@@ -1844,6 +1845,9 @@ static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, vo
if ((U.autokey_flag & AUTOKEY_FLAG_NOWARNING) == 0) {
if (ar == t->ar) {
if (t->flag & (T_OBJECT | T_POSE)) {
+ Scene *scene = t->scene;
+ Object *ob = OBACT;
+
if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) {
drawAutoKeyWarning(t, ar);
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index ab0d977..b69198a 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -317,6 +317,47 @@ static void createTransTexspace(TransInfo *t)
copy_v3_v3(td->ext->isize, td->ext->size);
}
+static void createTransCursor(TransInfo *t)
+{
+ Scene *scene = t->scene;
+ TransData *td;
+ View3D *v3d = t->view;
+ float *cursor;
+ Object *ob;
+
+ ob = OBACT;
+
+ if (t->spacetype != SPACE_VIEW3D) {
+ t->total = 0;
+ return;
+ }
+
+ ob = OBACT;
+ cursor = ED_view3d_cursor3d_get(scene, v3d);
+
+ t->total = 1;
+ td = t->data = MEM_callocN(sizeof(TransData), "TransTexspace");
+ td->ext = t->ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
+
+ td->flag = TD_SELECTED;
+ copy_v3_v3(td->center, cursor);
+
+ if (ob) {
+ unit_m3(td->mtx);
+ copy_m3_m4(td->axismtx, ob->obmat);
+ normalize_m3(td->axismtx);
+ pseudoinverse_m3_m3(td->smtx, td->mtx, PSEUDOINVERSE_EPSILON);
+ }
+ else {
+ unit_m3(td->mtx);
+ unit_m3(td->axismtx);
+ unit_m3(td->smtx);
+ }
+
+ td->loc = cursor;
+ copy_v3_v3(td->iloc, td->loc);
+}
+
/* ********************* edge (for crease) ***** */
static void createTransEdge(TransInfo *t)
@@ -5430,7 +5471,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* early out when nothing happened */
if (t->total == 0 || t->mode == TFM_DUMMY)
return;
-
+
+ if (t->options & CTX_CURSOR)
+ return;
+
if (t->spacetype == SPACE_VIEW3D) {
if (t->obedit) {
if (canceled == 0) {
@@ -6967,7 +7011,10 @@ void createTransData(bContext *C, TransInfo *t)
Object *ob = OBACT;
/* if tests must match recalcData for correct updates */
- if (t->options & CTX_TEXTURE) {
+ if (t->options & CTX_CURSOR) {
+ createTransCursor(t);
+ }
+ else if (t->options & CTX_TEXTURE) {
t->flag |= T_TEXTURE;
createTransTexspace(t);
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 6eb8821..3212811 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -956,7 +956,10 @@ static void recalcData_sequencer(TransInfo *t)
void recalcData(TransInfo *t)
{
/* if tests must match createTransData for correct updates */
- if (t->options & CTX_TEXTURE) {
+ if (t->options & CTX_CURSOR) {
+ /* pass */
+ }
+ else if (t->options & CTX_TEXTURE) {
recalcData_objects(t);
}
else if (t->options & CTX_EDGE) {
@@ -1138,6 +1141,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
+ if (op && (prop = RNA_struct_find_property(op->ptr, "use_cursor")) && RNA_property_is_set(op->ptr, prop)) {
+ if (RNA_property_boolean_get(op->ptr, prop)) {
+ t->options |= CTX_CURSOR;
+ }
+ }
+
/* Assign the space type, some exceptions for running in different mode */
if (sa == NULL) {
/* background mode */
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 7bdbbf7..905654c 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -556,6 +556,10 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
/*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
//RNA_def_property_flag(prop, PROP_HIDDEN);
}
+
+ if (flags & P_CURSOR) {
+ RNA_def_boolean(ot->srna, "use_cursor", 0, "Cursor", "");
+ }
}
static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
@@ -575,7 +579,7 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
- Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS);
+ Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS | P_CURSOR);
}
static void TRANSFORM_OT_resize(struct wmOperatorType *ot)

Event Timeline

Campbell Barton (campbellbarton) changed the title of this paste from untitled to Cursor transform.
Campbell Barton (campbellbarton) updated the paste's language from autodetect to diff.