diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-08 19:05:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-08 19:05:10 +0300 |
commit | a2b80d4c4878315cf453e1c374fba91f06d120a7 (patch) | |
tree | 6855f2d2bbab434b96c5a6bf6500ddc856a22543 /source/blender/editors/transform/transform_orientations.c | |
parent | 91264cfdd05722422f77599f22d28aa093af7c1e (diff) |
Fix T46003: Scale w/ script ignores axis-align
Diffstat (limited to 'source/blender/editors/transform/transform_orientations.c')
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index bab6bfd611f..c91666be8f6 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -36,6 +36,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "BLI_math.h" @@ -144,7 +145,7 @@ static TransformOrientation *createBoneSpace(bContext *C, ReportList *reports, float mat[3][3]; float normal[3], plane[3]; - getTransformOrientation(C, normal, plane, 0); + getTransformOrientation(C, normal, plane); if (createSpaceNormalTangent(mat, normal, plane) == 0) { BKE_reports_prepend(reports, "Cannot use zero-length bone"); @@ -164,7 +165,7 @@ static TransformOrientation *createCurveSpace(bContext *C, ReportList *reports, float mat[3][3]; float normal[3], plane[3]; - getTransformOrientation(C, normal, plane, 0); + getTransformOrientation(C, normal, plane); if (createSpaceNormalTangent(mat, normal, plane) == 0) { BKE_reports_prepend(reports, "Cannot use zero-length curve"); @@ -186,7 +187,7 @@ static TransformOrientation *createMeshSpace(bContext *C, ReportList *reports, float normal[3], plane[3]; int type; - type = getTransformOrientation(C, normal, plane, 0); + type = getTransformOrientation(C, normal, plane); switch (type) { case ORIENTATION_VERT: @@ -390,15 +391,12 @@ int BIF_countTransformOrientation(const bContext *C) return BLI_listbase_count(transform_spaces); } -bool applyTransformOrientation(const bContext *C, float mat[3][3], char *r_name) +bool applyTransformOrientation(const bContext *C, float mat[3][3], char *r_name, int index) { - View3D *v3d = CTX_wm_view3d(C); - int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM); - ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces; - TransformOrientation *ts = BLI_findlink(transform_spaces, selected_index); + const TransformOrientation *ts = BLI_findlink(transform_spaces, index); - BLI_assert(selected_index >= 0); + BLI_assert(index >= 0); if (ts) { if (r_name) { @@ -442,7 +440,6 @@ static int count_bone_select(bArmature *arm, ListBase *lb, const bool do_it) void initTransformOrientation(bContext *C, TransInfo *t) { - View3D *v3d = CTX_wm_view3d(C); Object *ob = CTX_data_active_object(C); Object *obedit = CTX_data_active_object(C); @@ -462,7 +459,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) case V3D_MANIP_NORMAL: if (obedit || (ob && ob->mode & OB_MODE_POSE)) { BLI_strncpy(t->spacename, IFACE_("normal"), sizeof(t->spacename)); - ED_getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE)); + ED_getTransformOrientationMatrix(C, t->spacemtx, t->around); break; } /* fall-through */ /* we define 'normal' as 'local' in Object mode */ @@ -480,7 +477,9 @@ void initTransformOrientation(bContext *C, TransInfo *t) break; case V3D_MANIP_VIEW: - if (t->ar->regiontype == RGN_TYPE_WINDOW) { + if ((t->spacetype == SPACE_VIEW3D) && + (t->ar->regiontype == RGN_TYPE_WINDOW)) + { RegionView3D *rv3d = t->ar->regiondata; float mat[3][3]; @@ -494,7 +493,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) } break; default: /* V3D_MANIP_CUSTOM */ - if (applyTransformOrientation(C, t->spacemtx, t->spacename)) { + if (applyTransformOrientation(C, t->spacemtx, t->spacename, t->current_orientation - V3D_MANIP_CUSTOM)) { /* pass */ } else { @@ -585,14 +584,14 @@ static unsigned int bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const } #endif -int getTransformOrientation(const bContext *C, float normal[3], float plane[3], const bool activeOnly) +int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3], const short around) { Scene *scene = CTX_data_scene(C); - View3D *v3d = CTX_wm_view3d(C); Object *obedit = CTX_data_edit_object(C); Base *base; Object *ob = OBACT; int result = ORIENTATION_NONE; + const bool activeOnly = (around == V3D_ACTIVE); zero_v3(normal); zero_v3(plane); @@ -855,7 +854,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], /* exception */ if (flag) { float tvec[3]; - if ((v3d->around == V3D_LOCAL) || + if ((around == V3D_LOCAL) || ELEM(flag, SEL_F2, SEL_F1 | SEL_F3, SEL_F1 | SEL_F2 | SEL_F3)) { BKE_nurb_bezt_calc_normal(nu, bezt, tvec); @@ -1017,6 +1016,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], } else { /* we need the one selected object, if its not active */ + View3D *v3d = CTX_wm_view3d(C); ob = OBACT; if (ob && (ob->flag & SELECT)) { /* pass */ @@ -1042,14 +1042,22 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], return result; } -void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[3][3], const bool activeOnly) +int getTransformOrientation(const bContext *C, float normal[3], float plane[3]) +{ + /* dummy value, not V3D_ACTIVE and not V3D_LOCAL */ + short around = V3D_CENTER; + + getTransformOrientation_ex(C, normal, plane, around); +} + +void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[3][3], const short around) { float normal[3] = {0.0, 0.0, 0.0}; float plane[3] = {0.0, 0.0, 0.0}; int type; - type = getTransformOrientation(C, normal, plane, activeOnly); + type = getTransformOrientation_ex(C, normal, plane, around); switch (type) { case ORIENTATION_NORMAL: |