Commit: a2b80d4c4878315cf453e1c374fba91f06d120a7
Author: Campbell Barton
Date:   Wed Sep 9 02:05:10 2015 +1000
Branches: master
https://developer.blender.org/rBa2b80d4c4878315cf453e1c374fba91f06d120a7

Fix T46003: Scale w/ script ignores axis-align

===================================================================

M       source/blender/editors/include/ED_transform.h
M       source/blender/editors/space_view3d/view3d_edit.c
M       source/blender/editors/transform/transform.c
M       source/blender/editors/transform/transform.h
M       source/blender/editors/transform/transform_generics.c
M       source/blender/editors/transform/transform_manipulator.c
M       source/blender/editors/transform/transform_orientations.c

===================================================================

diff --git a/source/blender/editors/include/ED_transform.h 
b/source/blender/editors/include/ED_transform.h
index 732e67a..b14ba45 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -127,7 +127,7 @@ void BIF_createTransformOrientation(struct bContext *C, 
struct ReportList *repor
 void BIF_selectTransformOrientation(struct bContext *C, struct 
TransformOrientation *ts);
 void BIF_selectTransformOrientationValue(struct bContext *C, int orientation);
 
-void ED_getTransformOrientationMatrix(const struct bContext *C, float 
orientation_mat[3][3], const bool activeOnly);
+void ED_getTransformOrientationMatrix(const struct bContext *C, float 
orientation_mat[3][3], const short around);
 
 int BIF_countTransformOrientation(const struct bContext *C);
 
diff --git a/source/blender/editors/space_view3d/view3d_edit.c 
b/source/blender/editors/space_view3d/view3d_edit.c
index a14d3ea..2295986 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -3769,7 +3769,7 @@ static void axis_set_view(bContext *C, View3D *v3d, 
ARegion *ar,
                        float twmat[3][3];
 
                        /* same as transform manipulator when normal is set */
-                       ED_getTransformOrientationMatrix(C, twmat, true);
+                       ED_getTransformOrientationMatrix(C, twmat, V3D_ACTIVE);
 
                        mat3_to_quat(obact_quat, twmat);
                        invert_qt(obact_quat);
diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 3cc5380..d8000f0 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2075,47 +2075,41 @@ bool initTransform(bContext *C, TransInfo *t, 
wmOperator *op, const wmEvent *eve
                t->launch_event = LEFTMOUSE;
        }
 
+       unit_m3(t->spacemtx);
+
        initTransInfo(C, t, op, event);
+       initTransformOrientation(C, t);
 
        if (t->spacetype == SPACE_VIEW3D) {
-               initTransformOrientation(C, t);
-
                t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, 
drawTransformApply, t, REGION_DRAW_PRE_VIEW);
                t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, 
drawTransformView, t, REGION_DRAW_POST_VIEW);
                t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, 
drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
                t->draw_handle_cursor = 
WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
        }
        else if (t->spacetype == SPACE_IMAGE) {
-               unit_m3(t->spacemtx);
                t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, 
drawTransformView, t, REGION_DRAW_POST_VIEW);
                //t->draw_handle_pixel = 
ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, 
REGION_DRAW_POST_PIXEL);
                t->draw_handle_cursor = 
WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
        }
        else if (t->spacetype == SPACE_CLIP) {
-               unit_m3(t->spacemtx);
                t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, 
drawTransformView, t, REGION_DRAW_POST_VIEW);
                t->draw_handle_cursor = 
WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
        }
        else if (t->spacetype == SPACE_NODE) {
-               unit_m3(t->spacemtx);
                /*t->draw_handle_apply = 
ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, 
REGION_DRAW_PRE_VIEW);*/
                t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, 
drawTransformView, t, REGION_DRAW_POST_VIEW);
                t->draw_handle_cursor = 
WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
        }
        else if (t->spacetype == SPACE_IPO) {
-               unit_m3(t->spacemtx);
                t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, 
drawTransformView, t, REGION_DRAW_POST_VIEW);
                //t->draw_handle_pixel = 
ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, 
REGION_DRAW_POST_PIXEL);
                t->draw_handle_cursor = 
WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
        }
        else if (t->spacetype == SPACE_ACTION) {
-               unit_m3(t->spacemtx);
                t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, 
drawTransformView, t, REGION_DRAW_POST_VIEW);
                //t->draw_handle_pixel = 
ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, 
REGION_DRAW_POST_PIXEL);
                t->draw_handle_cursor = 
WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
        }
-       else
-               unit_m3(t->spacemtx);
 
        createTransData(C, t);          // make TransData structs from selection
 
diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index cdd260b..aab0656 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -727,7 +727,7 @@ bool createSpaceNormalTangent(float mat[3][3], const float 
normal[3], const floa
 
 struct TransformOrientation *addMatrixSpace(struct bContext *C, float 
mat[3][3],
                                             const char *name, const bool 
overwrite);
-bool applyTransformOrientation(const struct bContext *C, float mat[3][3], char 
r_name[64]);
+bool applyTransformOrientation(const struct bContext *C, float mat[3][3], char 
r_name[64], int index);
 
 #define ORIENTATION_NONE       0
 #define ORIENTATION_NORMAL     1
@@ -735,7 +735,8 @@ bool applyTransformOrientation(const struct bContext *C, 
float mat[3][3], char r
 #define ORIENTATION_EDGE       3
 #define ORIENTATION_FACE       4
 
-int getTransformOrientation(const struct bContext *C, float normal[3], float 
plane[3], const bool activeOnly);
+int getTransformOrientation_ex(const struct bContext *C, float normal[3], 
float plane[3], const short around);
+int getTransformOrientation(const struct bContext *C, float normal[3], float 
plane[3]);
 
 void freeEdgeSlideTempFaces(EdgeSlideData *sld);
 void freeEdgeSlideVerts(TransInfo *t);
diff --git a/source/blender/editors/transform/transform_generics.c 
b/source/blender/editors/transform/transform_generics.c
index 74dbc09..1693fcb 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1207,18 +1207,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
                        t->around = V3D_CURSOR;
                }
 
-               if (op && ((prop = RNA_struct_find_property(op->ptr, 
"constraint_orientation")) &&
-                          RNA_property_is_set(op->ptr, prop)))
-               {
-                       t->current_orientation = RNA_property_enum_get(op->ptr, 
prop);
-
-                       if (t->current_orientation >= V3D_MANIP_CUSTOM + 
BIF_countTransformOrientation(C)) {
-                               t->current_orientation = V3D_MANIP_GLOBAL;
-                       }
-               }
-               else {
-                       t->current_orientation = v3d->twmode;
-               }
+               t->current_orientation = v3d->twmode;
 
                /* exceptional case */
                if (t->around == V3D_LOCAL) {
@@ -1305,6 +1294,16 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
                }
                t->around = V3D_CENTER;
        }
+
+       if (op && ((prop = RNA_struct_find_property(op->ptr, 
"constraint_orientation")) &&
+                  RNA_property_is_set(op->ptr, prop)))
+       {
+               t->current_orientation = RNA_property_enum_get(op->ptr, prop);
+
+               if (t->current_orientation >= V3D_MANIP_CUSTOM + 
BIF_countTransformOrientation(C)) {
+                       t->current_orientation = V3D_MANIP_GLOBAL;
+               }
+       }
        
        if (op && ((prop = RNA_struct_find_property(op->ptr, 
"release_confirm")) &&
                   RNA_property_is_set(op->ptr, prop)))
diff --git a/source/blender/editors/transform/transform_manipulator.c 
b/source/blender/editors/transform/transform_manipulator.c
index acc6108..374a0c3 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -568,7 +568,7 @@ static int calc_manipulator_stats(const bContext *C)
                        {
                                if (obedit || ob->mode & OB_MODE_POSE) {
                                        float mat[3][3];
-                                       ED_getTransformOrientationMatrix(C, 
mat, (v3d->around == V3D_ACTIVE));
+                                       ED_getTransformOrientationMatrix(C, 
mat, v3d->around);
                                        copy_m4_m3(rv3d->twmat, mat);
                                        break;
                                }
@@ -583,7 +583,7 @@ static int calc_manipulator_stats(const bContext *C)
                                         * and users who select many bones will 
understand whats going on and what local means
                                         * when they start transforming */
                                        float mat[3][3];
-                                       ED_getTransformOrientationMatrix(C, 
mat, (v3d->around == V3D_ACTIVE));
+                                       ED_getTransformOrientationMatrix(C, 
mat, v3d->around);
                                        copy_m4_m3(rv3d->twmat, mat);
                                        break;
                                }
@@ -602,7 +602,7 @@ static int calc_manipulator_stats(const bContext *C)
                        default: /* V3D_MANIP_CUSTOM */
                        {
                                float mat[3][3];
-                               if (applyTransformOrientation(C, mat, NULL)) {
+                               if (applyTransformOrientation(C, mat, NULL, 
v3d->twmode - V3D_MANIP_CUSTOM)) {
                                        copy_m4_m3(rv3d->twmat, mat);
                                }
                                break;
diff --git a/source/blender/editors/transform/transform_orientations.c 
b/source/blender/editors/transform/transform_orientations.c
index bab6bfd..c91666b 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_countTransf

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to