diff options
author | Martin Poirier <theeth@yahoo.com> | 2010-01-04 23:49:42 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2010-01-04 23:49:42 +0300 |
commit | 05258297356fc2366506ac5dacc3feb74dcbba35 (patch) | |
tree | 01b62c502525b0f673230875ce5b7c604e05e685 /source/blender/editors/transform | |
parent | a325b8b3b9c68b0c554ce91211280c640b50e981 (diff) |
transform:
Rotation operator now saves axis of rotation (when not using a constraint). Better for operator redo and tweak (would use a Z axis because of matrix init)
Also fix crash in Translation operator redo and tweak (rv3d is not always available).
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform.c | 35 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 13 |
3 files changed, 39 insertions, 11 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 7de2006a35c..e8e7e323496 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1384,6 +1384,11 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) RNA_float_set(op->ptr, "proportional_size", t->prop_size); } + if (RNA_struct_find_property(op->ptr, "axis")) + { + RNA_float_set_array(op->ptr, "axis", t->axis); + } + if (RNA_struct_find_property(op->ptr, "mirror")) { RNA_boolean_set(op->ptr, "mirror", t->flag & T_MIRROR); @@ -1577,6 +1582,13 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->flag |= T_AUTOVALUES; } + /* Transformation axis from operator */ + if (RNA_struct_find_property(op->ptr, "axis") && RNA_property_is_set(op->ptr, "axis")) + { + RNA_float_get_array(op->ptr, "axis", t->axis); + normalize_v3(t->axis); + } + /* Constraint init from operator */ if (RNA_struct_find_property(op->ptr, "constraint_axis") && RNA_property_is_set(op->ptr, "constraint_axis")) { @@ -2662,6 +2674,10 @@ void initRotation(TransInfo *t) if (t->flag & T_2D_EDIT) t->flag |= T_NO_CONSTRAINT; + + VECCOPY(t->axis, t->viewinv[2]); + mul_v3_fl(t->axis, -1.0f); + normalize_v3(t->axis); } static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short around) { @@ -2906,13 +2922,8 @@ int Rotation(TransInfo *t, short mval[2]) float final; - float axis[3]; float mat[3][3]; - VECCOPY(axis, t->viewinv[2]); - mul_v3_fl(axis, -1.0f); - normalize_v3(axis); - final = t->values[0]; applyNDofInput(&t->ndof, &final); @@ -2920,7 +2931,7 @@ int Rotation(TransInfo *t, short mval[2]) snapGrid(t, &final); if (t->con.applyRot) { - t->con.applyRot(t, NULL, axis, &final); + t->con.applyRot(t, NULL, t->axis, &final); } applySnapping(t, &final); @@ -2947,13 +2958,13 @@ int Rotation(TransInfo *t, short mval[2]) sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext); } - vec_rot_to_mat3( mat,axis, final); + vec_rot_to_mat3( mat, t->axis, final); // TRANSFORM_FIX_ME // t->values[0] = final; // used in manipulator // copy_m3_m3(t->mat, mat); // used in manipulator - applyRotation(t, final, axis); + applyRotation(t, final, t->axis); recalcData(t); @@ -3085,9 +3096,11 @@ void initTranslation(TransInfo *t) if(t->spacetype == SPACE_VIEW3D) { RegionView3D *rv3d = t->ar->regiondata; - t->snap[0] = 0.0f; - t->snap[1] = rv3d->gridview * 1.0f; - t->snap[2] = t->snap[1] * 0.1f; + if (rv3d) { + t->snap[0] = 0.0f; + t->snap[1] = rv3d->gridview * 1.0f; + t->snap[2] = t->snap[1] * 0.1f; + } } else if(t->spacetype == SPACE_IMAGE) { t->snap[0] = 0.0f; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 72d970c967a..fd4f67f4f27 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -315,6 +315,8 @@ typedef struct TransInfo { float values[4]; float auto_values[4]; + float axis[3]; + void *view; struct ScrArea *sa; struct ARegion *ar; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 4c118aa2625..1ef0bdb0e05 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -385,6 +385,15 @@ void Properties_Proportional(struct wmOperatorType *ot) RNA_def_float(ot->srna, "proportional_size", 1, 0, FLT_MAX, "Proportional Size", "", 0, 100); } +void Properties_Axis(struct wmOperatorType *ot) +{ + PropertyRNA *prop; + + prop= RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Axis", "The axis around which the transformation occurs."); +} + void Properties_Snapping(struct wmOperatorType *ot, short fullsnap, short align) { RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", ""); @@ -504,6 +513,8 @@ void TRANSFORM_OT_rotate(struct wmOperatorType *ot) RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2); + Properties_Axis(ot); + Properties_Proportional(ot); RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", ""); @@ -757,6 +768,8 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot) RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX); + Properties_Axis(ot); + Properties_Proportional(ot); RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", ""); |