Commit: 535984a848865c07a39610b32a53432d1a078c59
Author: Campbell Barton
Date:   Thu Nov 29 12:49:02 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB535984a848865c07a39610b32a53432d1a078c59

Cleanup: simplify transform orientation cycling

Remove dummy first index, store a pointer to the user orientation
instead of having it store twice (which could get out of sync).

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

M       source/blender/editors/transform/transform.c
M       source/blender/editors/transform/transform.h
M       source/blender/editors/transform/transform_generics.c

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

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 97834f064f4..b5abb2ba5c2 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -994,8 +994,9 @@ static void transform_event_xyz_constraint(TransInfo *t, 
short key_type, char cm
                else if (!edit_2d) {
                        if (cmode != axis) {
                                /* First press, constraint to an axis. */
-                               t->orientation.index = 1;
-                               const short orientation = 
t->orientation.types[t->orientation.index];
+                               t->orientation.index = 0;
+                               const short *orientation_ptr = 
t->orientation.types[t->orientation.index];
+                               const short  orientation = orientation_ptr ? 
*orientation_ptr : V3D_MANIP_GLOBAL;
                                if (is_plane == false) {
                                        setUserConstraint(t, orientation, 
constraint_axis, msg2);
                                }
@@ -1011,7 +1012,8 @@ static void transform_event_xyz_constraint(TransInfo *t, 
short key_type, char cm
                                        stopConstraint(t);
                                }
                                else {
-                                       const short orientation = 
t->orientation.types[t->orientation.index];
+                                       const short *orientation_ptr = 
t->orientation.types[t->orientation.index];
+                                       const short  orientation = 
orientation_ptr ? *orientation_ptr : V3D_MANIP_GLOBAL;
                                        if (is_plane == false) {
                                                setUserConstraint(t, 
orientation, constraint_axis, msg2);
                                        }
diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index 8101833a609..5dff9f9f30a 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -503,11 +503,10 @@ typedef struct TransInfo {
        /*************** NEW STUFF *********************/
        short           launch_event;   /* event type used to launch transform 
*/
 
-       /* Always: 'orientation_types[orientation_index]' */
        struct {
                short           user;
                short           index;
-               short           types[3];
+               short           *types[2];
                /* this gets used when current_orientation is V3D_MANIP_CUSTOM 
*/
                TransformOrientation *custom;
        } orientation;
diff --git a/source/blender/editors/transform/transform_generics.c 
b/source/blender/editors/transform/transform_generics.c
index ba5b81ae641..ff3d52d7ddb 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1399,6 +1399,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
                t->orientation.custom = BKE_scene_transform_orientation_find(
                        t->scene, t->scene->orientation_index_custom);
 
+               t->orientation.index = 0;
+               ARRAY_SET_ITEMS(
+                               t->orientation.types,
+                               &t->orientation.user,
+                               /* V3D_MANIP_GLOBAL */
+                               NULL);
+
                /* exceptional case */
                if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
                        if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, 
TFM_TRACKBALL)) {
@@ -1513,13 +1520,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
                t->orientation.custom = custom_orientation;
        }
 
-       t->orientation.index = 0;
-       ARRAY_SET_ITEMS(
-               t->orientation.types,
-               V3D_MANIP_GLOBAL,  /* Value isn't used (first index is no 
constraint). */
-               t->orientation.user,
-               V3D_MANIP_GLOBAL);
-
        if (op && ((prop = RNA_struct_find_property(op->ptr, 
"release_confirm")) &&
                   RNA_property_is_set(op->ptr, prop)))
        {

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

Reply via email to