diff options
author | Martin Poirier <theeth@yahoo.com> | 2009-01-10 22:45:48 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2009-01-10 22:45:48 +0300 |
commit | 6ab86a7572435c3df0a3c613bca8a3d0566e39e7 (patch) | |
tree | ff9e11a63df9ca96f03548c16fa7e4e3dd55f2f4 /source | |
parent | 1beef956ca96c76e3ee7d6ba80d0c88e2b92b258 (diff) |
2.5
Transform operator replay support for constraints.
Code isn't nice, will have to split some properties to separate what's part of the "saved data" from operator arguments.
Diffstat (limited to 'source')
4 files changed, 46 insertions, 21 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 164d101ebb6..ffd5d425194 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -710,9 +710,9 @@ void transformEvent(TransInfo *t, wmEvent *event) stopConstraint(t); } else { - if (event->keymodifier == 0) + if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setUserConstraint(t, (CON_AXIS0), "along %s X"); - else if (event->keymodifier == KM_SHIFT) + else if (t->modifiers & MOD_CONSTRAINT_PLANE) setUserConstraint(t, (CON_AXIS1|CON_AXIS2), "locking %s X"); } } @@ -722,9 +722,9 @@ void transformEvent(TransInfo *t, wmEvent *event) setConstraint(t, mati, (CON_AXIS0), "along X axis"); } else { - if (event->keymodifier == 0) + if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setConstraint(t, mati, (CON_AXIS0), "along global X"); - else if (event->keymodifier == KM_SHIFT) + else if (t->modifiers & MOD_CONSTRAINT_PLANE) setConstraint(t, mati, (CON_AXIS1|CON_AXIS2), "locking global X"); } } @@ -742,9 +742,9 @@ void transformEvent(TransInfo *t, wmEvent *event) stopConstraint(t); } else { - if (event->keymodifier == 0) + if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setUserConstraint(t, (CON_AXIS1), "along %s Y"); - else if (event->keymodifier == KM_SHIFT) + else if (t->modifiers & MOD_CONSTRAINT_PLANE) setUserConstraint(t, (CON_AXIS0|CON_AXIS2), "locking %s Y"); } } @@ -754,9 +754,9 @@ void transformEvent(TransInfo *t, wmEvent *event) setConstraint(t, mati, (CON_AXIS1), "along Y axis"); } else { - if (event->keymodifier == 0) + if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setConstraint(t, mati, (CON_AXIS1), "along global Y"); - else if (event->keymodifier == KM_SHIFT) + else if (t->modifiers & MOD_CONSTRAINT_PLANE) setConstraint(t, mati, (CON_AXIS0|CON_AXIS2), "locking global Y"); } } @@ -770,16 +770,16 @@ void transformEvent(TransInfo *t, wmEvent *event) stopConstraint(t); } else { - if (event->keymodifier == 0) + if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setUserConstraint(t, (CON_AXIS2), "along %s Z"); - else if ((event->keymodifier == KM_SHIFT) && ((t->flag & T_2D_EDIT)==0)) + else if ((t->modifiers & MOD_CONSTRAINT_PLANE) && ((t->flag & T_2D_EDIT)==0)) setUserConstraint(t, (CON_AXIS0|CON_AXIS1), "locking %s Z"); } } else if ((t->flag & T_2D_EDIT)==0) { - if (event->keymodifier == 0) + if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setConstraint(t, mati, (CON_AXIS2), "along global Z"); - else if (event->keymodifier == KM_SHIFT) + else if (t->modifiers & MOD_CONSTRAINT_PLANE) setConstraint(t, mati, (CON_AXIS0|CON_AXIS1), "locking global Z"); } t->redraw = 1; @@ -963,9 +963,16 @@ void drawTransform(const struct bContext *C, struct ARegion *ar, void *arg) void saveTransform(bContext *C, TransInfo *t, wmOperator *op) { + short twmode= (t->spacetype==SPACE_VIEW3D)? ((View3D*)t->view)->twmode: V3D_MANIP_GLOBAL; + RNA_int_set(op->ptr, "mode", t->mode); RNA_int_set(op->ptr, "options", t->options); RNA_float_set_array(op->ptr, "values", t->values); + + + RNA_int_set(op->ptr, "constraint_mode", t->con.mode); + RNA_int_set(op->ptr, "constraint_orientation", twmode); + RNA_float_set_array(op->ptr, "constraint_matrix", (float*)t->con.mtx); } void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) @@ -1105,6 +1112,19 @@ void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) QUATCOPY(t->values, values); /* vec-4 */ } + /* Constraint init from operator */ + { + t->con.mode = RNA_int_get(op->ptr, "constraint_mode"); + + if (t->con.mode & CON_APPLY) + { + //int options = RNA_int_get(op->ptr, "options"); + RNA_float_get_array(op->ptr, "constraint_matrix", (float*)t->spacemtx); + + setUserConstraint(t, t->con.mode, "%s"); + } + + } } void transformApply(bContext *C, TransInfo *t) diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 0270cf06956..bebf8ccc0e6 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -525,12 +525,13 @@ void setUserConstraint(TransInfo *t, int mode, const char ftext[]) { switch(twmode) { case V3D_MANIP_GLOBAL: - /* - sprintf(text, ftext, "global"); - Mat3One(mtx); - setConstraint(t, mtx, mode, text); + { + float mtx[3][3]; + sprintf(text, ftext, "global"); + Mat3One(mtx); + setConstraint(t, mtx, mode, text); + } break; - */ case V3D_MANIP_LOCAL: sprintf(text, ftext, "local"); setLocalConstraint(t, mode, text); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 6fd7de6d92c..8a27fae5a06 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -763,8 +763,6 @@ void postTrans (TransInfo *t) { TransData *td; - stopConstraint(t); - if (t->draw_handle) { ED_region_draw_cb_exit(t->ar->type, t->draw_handle); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index a810f66af06..6e48de9bc00 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -108,8 +108,6 @@ static int transform_exec(bContext *C, wmOperator *op) transformEnd(C, t); - //ED_region_tag_redraw(CTX_wm_region(C)); - transformops_exit(C, op); return OPERATOR_FINISHED; @@ -138,6 +136,7 @@ void TFM_OT_transform(struct wmOperatorType *ot) { PropertyRNA *prop; static float value[4] = {0, 0, 0}; + static float mtx[3][3] = {{1, 0, 0},{0, 1, 0},{0, 0, 1}}; /* identifiers */ ot->name = "Transform"; @@ -157,6 +156,13 @@ void TFM_OT_transform(struct wmOperatorType *ot) prop = RNA_def_property(ot->srna, "values", PROP_FLOAT, PROP_VECTOR); RNA_def_property_array(prop, 4); RNA_def_property_float_array_default(prop, value); + + RNA_def_property(ot->srna, "constraint_orientation", PROP_INT, PROP_NONE); + RNA_def_property(ot->srna, "constraint_mode", PROP_INT, PROP_NONE); + + prop = RNA_def_property(ot->srna, "constraint_matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_array(prop, 9); + RNA_def_property_float_array_default(prop, mtx); } void transform_operatortypes(void) |