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.
This commit is contained in:
2009-01-10 19:45:48 +00:00
parent 1beef956ca
commit 6ab86a7572
4 changed files with 46 additions and 21 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)