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).
This commit is contained in:
parent
27cccaeccd
commit
535984a848
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue