diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-06-01 21:41:18 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-06-01 21:46:18 +0300 |
commit | 46fc0bb87ebda166d08b23cbcca799acb2c54158 (patch) | |
tree | 1566d535d93c4fb81b962cdbc1346ca8242460f2 /source/blender/editors/transform/transform_generics.c | |
parent | 7f564d74f9edaaa41ce27c6e854869096f70b4da (diff) |
Move custom transform orientations to workspace
This commit moves the list of transform orientations from scenes to workspaces.
Main reasons for this are:
* Transform orientations are UI data and should not be stored in the scene.
* Introducion of workspaces caused some (expected) glitches with transform orientations. Mainly when removing one.
* Improves code.
More technically speaking, this commit does:
* Move list of custom transform orientations from Scene to WorkSpace struct.
* Store active transform orientation index separate from View3D.twmode (twmode can only be set to preprocessor defined values now).
* Display custom transform orientation name in header when transforming in it (used to show "global" which isn't really correct).
Diffstat (limited to 'source/blender/editors/transform/transform_generics.c')
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 0009ae13117..adff98cc99b 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -83,6 +83,7 @@ #include "BKE_tracking.h" #include "BKE_mask.h" #include "BKE_utildefines.h" +#include "BKE_workspace.h" #include "ED_anim_api.h" #include "ED_armature.h" @@ -1242,6 +1243,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } t->current_orientation = v3d->twmode; + t->custom_orientation = BKE_workspace_transform_orientation_find( + CTX_wm_workspace(C), v3d->custom_orientation_index); /* exceptional case */ if (t->around == V3D_AROUND_LOCAL_ORIGINS) { @@ -1332,13 +1335,24 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve 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); + short orientation = RNA_property_enum_get(op->ptr, prop); + TransformOrientation *custom_orientation = NULL; - if (t->current_orientation >= V3D_MANIP_CUSTOM + BIF_countTransformOrientation(C)) { - t->current_orientation = V3D_MANIP_GLOBAL; + if (orientation >= V3D_MANIP_CUSTOM) { + if (orientation >= V3D_MANIP_CUSTOM + BIF_countTransformOrientation(C)) { + orientation = V3D_MANIP_GLOBAL; + } + else { + custom_orientation = BKE_workspace_transform_orientation_find( + CTX_wm_workspace(C), orientation - V3D_MANIP_CUSTOM); + orientation = V3D_MANIP_CUSTOM; + } } + + t->current_orientation = orientation; + t->custom_orientation = custom_orientation; } - + if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) && RNA_property_is_set(op->ptr, prop))) { |