Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-04-18 10:12:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-04-18 10:16:15 +0300
commit7d055da327b9555f76035075ce4e228d31f04df4 (patch)
tree1baf55c36ba068acf764febed0a8ddf4bedca438 /source/blender/editors
parent33ba170f5c2fc3b8b26b895b092a86ebd85d3e13 (diff)
Move transform orientation to scene
This was stored in the workspace, selected from the view. Move both to scene since custom orientations are closely related to your scene data.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_transform.h2
-rw-r--r--source/blender/editors/screen/workspace_edit.c4
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c2
-rw-r--r--source/blender/editors/transform/transform.c19
-rw-r--r--source/blender/editors/transform/transform_generics.c11
-rw-r--r--source/blender/editors/transform/transform_manipulator.c11
-rw-r--r--source/blender/editors/transform/transform_ops.c20
-rw-r--r--source/blender/editors/transform/transform_orientations.c41
9 files changed, 52 insertions, 60 deletions
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 536f9c22dcd..a6bed6c1ee6 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -130,7 +130,7 @@ void BIF_createTransformOrientation(struct bContext *C, struct ReportList *repor
const char *name, const bool use_view,
const bool activate, const bool overwrite);
void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
-void BIF_selectTransformOrientationValue(struct View3D *v3d, int orientation);
+void BIF_selectTransformOrientationValue(struct Scene *scene, int orientation);
void ED_getTransformOrientationMatrix(const struct bContext *C, float orientation_mat[3][3], const short around);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index ace3f17542e..b4aea54c66d 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -225,10 +225,6 @@ WorkSpace *ED_workspace_duplicate(
bmain, workspace_old->id.name + 2, scene,
BKE_workspace_view_layer_get(workspace_old, scene),
&workspace_old->view_render);
- ListBase *transform_orientations_old = BKE_workspace_transform_orientations_get(workspace_old);
- ListBase *transform_orientations_new = BKE_workspace_transform_orientations_get(workspace_new);
-
- BLI_duplicatelist(transform_orientations_new, transform_orientations_old);
workspace_new->tool = workspace_old->tool;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 9234c8c3d77..5a5d1df3a08 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -348,7 +348,7 @@ static SpaceLink *view3d_new(const bContext *C)
v3d->twflag |= U.manipulator_flag & V3D_MANIPULATOR_DRAW;
v3d->twtype = V3D_MANIP_TRANSLATE;
v3d->around = V3D_AROUND_CENTER_MEAN;
- v3d->custom_orientation_index = -1;
+ scene->orientation_index_custom = -1;
v3d->bundle_size = 0.2f;
v3d->bundle_drawtype = OB_PLAINAXES;
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 3ed6c87b750..1f47f44f2f6 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -333,7 +333,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
if (v3d->twflag & V3D_MANIPULATOR_DRAW) {
uiItemR(row, &v3dptr, "transform_manipulators", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
}
- uiItemR(row, &v3dptr, "transform_orientation", 0, "", ICON_NONE);
+ uiItemR(row, &sceneptr, "transform_orientation", 0, "", ICON_NONE);
}
if (obedit == NULL && v3d->localvd == NULL) {
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 3752d7f6c26..b6d794a7812 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -62,6 +62,7 @@
#include "BKE_constraint.h"
#include "BKE_particle.h"
#include "BKE_unit.h"
+#include "BKE_scene.h"
#include "BKE_mask.h"
#include "BKE_report.h"
#include "BKE_workspace.h"
@@ -2009,13 +2010,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
!RNA_property_is_set(op->ptr, prop))
{
- View3D *v3d = t->view;
-
- v3d->twmode = t->current_orientation;
-
- BLI_assert(((v3d->custom_orientation_index == -1) && (t->custom_orientation == NULL)) ||
- (BKE_workspace_transform_orientation_get_index(
- CTX_wm_workspace(C), t->custom_orientation) == v3d->custom_orientation_index));
+ t->scene->orientation_type = t->current_orientation;
+ BLI_assert(((t->scene->orientation_index_custom == -1) && (t->custom_orientation == NULL)) ||
+ (BKE_scene_transform_orientation_get_index(
+ t->scene, t->custom_orientation) == t->scene->orientation_index_custom));
}
}
}
@@ -2040,12 +2038,11 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->current_orientation;
if (orientation == V3D_MANIP_CUSTOM) {
- WorkSpace *workspace = CTX_wm_workspace(C);
- const int custom_orientation_index = BKE_workspace_transform_orientation_get_index(
- workspace, t->custom_orientation);
+ const int orientation_index_custom = BKE_scene_transform_orientation_get_index(
+ t->scene, t->custom_orientation);
/* Maybe we need a t->con.custom_orientation? Seems like it would always match t->custom_orientation. */
- orientation = V3D_MANIP_CUSTOM + custom_orientation_index;
+ orientation = V3D_MANIP_CUSTOM + orientation_index_custom;
BLI_assert(orientation >= V3D_MANIP_CUSTOM);
}
RNA_enum_set(op->ptr, "constraint_orientation", orientation);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 8f369aea0c8..2fdb34e125a 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -83,6 +83,7 @@
#include "BKE_mask.h"
#include "BKE_workspace.h"
#include "BKE_layer.h"
+#include "BKE_scene.h"
#include "DEG_depsgraph.h"
@@ -1328,9 +1329,9 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->around = V3D_AROUND_CURSOR;
}
- t->current_orientation = v3d->twmode;
- t->custom_orientation = BKE_workspace_transform_orientation_find(
- CTX_wm_workspace(C), v3d->custom_orientation_index);
+ t->current_orientation = t->scene->orientation_type;
+ t->custom_orientation = BKE_scene_transform_orientation_find(
+ t->scene, t->scene->orientation_index_custom);
/* exceptional case */
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
@@ -1429,8 +1430,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
orientation = V3D_MANIP_GLOBAL;
}
else {
- custom_orientation = BKE_workspace_transform_orientation_find(
- CTX_wm_workspace(C), orientation - V3D_MANIP_CUSTOM);
+ custom_orientation = BKE_scene_transform_orientation_find(
+ t->scene, orientation - V3D_MANIP_CUSTOM);
orientation = V3D_MANIP_CUSTOM;
}
}
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 8944817baca..6fb9ed862ab 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -59,6 +59,7 @@
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
#include "BKE_gpencil.h"
+#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "BIF_gl.h"
@@ -619,7 +620,7 @@ static int calc_manipulator_stats(
* if we could check 'totsel' now, this should be skipped with no selection. */
if (ob && !is_gp_edit) {
- switch (v3d->twmode) {
+ switch (scene->orientation_type) {
case V3D_MANIP_GLOBAL:
{
@@ -672,8 +673,8 @@ static int calc_manipulator_stats(
}
case V3D_MANIP_CUSTOM:
{
- TransformOrientation *custom_orientation = BKE_workspace_transform_orientation_find(
- CTX_wm_workspace(C), v3d->custom_orientation_index);
+ TransformOrientation *custom_orientation = BKE_scene_transform_orientation_find(
+ scene, scene->orientation_index_custom);
float mat[3][3];
if (applyTransformOrientation(custom_orientation, mat, NULL)) {
@@ -1133,9 +1134,9 @@ static void manipulator_xform_message_subscribe(
RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &space_ptr);
{
- extern PropertyRNA rna_SpaceView3D_transform_orientation;
+ extern PropertyRNA rna_Scene_transform_orientation;
const PropertyRNA *props[] = {
- &rna_SpaceView3D_transform_orientation,
+ &rna_Scene_transform_orientation,
};
for (int i = 0; i < ARRAY_SIZE(props); i++) {
WM_msg_subscribe_rna(mbus, &space_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__);
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index d5d25888ec8..6f31f5311bc 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -160,12 +160,12 @@ const EnumPropertyItem rna_enum_transform_mode_types[] =
static int select_orientation_exec(bContext *C, wmOperator *op)
{
- View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
int orientation = RNA_enum_get(op->ptr, "orientation");
- BIF_selectTransformOrientationValue(v3d, orientation);
-
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ BIF_selectTransformOrientationValue(scene, orientation);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
return OPERATOR_FINISHED;
}
@@ -206,12 +206,10 @@ static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot)
static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op))
{
- View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
+ BIF_removeTransformOrientationIndex(C, scene->orientation_index_custom);
- BIF_removeTransformOrientationIndex(C, v3d->custom_orientation_index);
-
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
- WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
return OPERATOR_FINISHED;
}
@@ -223,12 +221,12 @@ static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent
static int delete_orientation_poll(bContext *C)
{
- View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
if (ED_operator_areaactive(C) == 0)
return 0;
- return (v3d->twmode >= V3D_MANIP_CUSTOM) && (v3d->custom_orientation_index != -1);
+ return (scene->orientation_type >= V3D_MANIP_CUSTOM) && (scene->orientation_index_custom != -1);
}
static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot)
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 7b3f91b81da..9e6f4847b5b 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -53,6 +53,7 @@
#include "BKE_report.h"
#include "BKE_main.h"
#include "BKE_screen.h"
+#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "BLT_translation.h"
@@ -65,16 +66,15 @@
void BIF_clearTransformOrientation(bContext *C)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
- ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace);
+ Scene *scene = CTX_data_scene(C);
+ ListBase *transform_orientations = &scene->transform_spaces;
View3D *v3d = CTX_wm_view3d(C);
BLI_freelistN(transform_orientations);
-
- // Need to loop over all view3d
- if (v3d && v3d->twmode == V3D_MANIP_CUSTOM) {
- v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
- v3d->custom_orientation_index = -1;
+
+ if (v3d && scene->orientation_type == V3D_MANIP_CUSTOM) {
+ scene->orientation_type = V3D_MANIP_GLOBAL; /* fallback to global */
+ scene->orientation_index_custom = -1;
}
}
@@ -323,8 +323,8 @@ TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3],
const char *name, const bool overwrite)
{
TransformOrientation *ts = NULL;
- WorkSpace *workspace = CTX_wm_workspace(C);
- ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace);
+ Scene *scene = CTX_data_scene(C);
+ ListBase *transform_orientations = &scene->transform_spaces;
char name_unique[sizeof(ts->name)];
if (overwrite) {
@@ -351,24 +351,24 @@ TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3],
void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target)
{
- BKE_workspace_transform_orientation_remove(CTX_wm_workspace(C), target);
+ BKE_scene_transform_orientation_remove(CTX_data_scene(C), target);
}
void BIF_removeTransformOrientationIndex(bContext *C, int index)
{
- TransformOrientation *target = BKE_workspace_transform_orientation_find(CTX_wm_workspace(C), index);
+ TransformOrientation *target = BKE_scene_transform_orientation_find(CTX_data_scene(C), index);
BIF_removeTransformOrientation(C, target);
}
void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target)
{
- int index = BKE_workspace_transform_orientation_get_index(CTX_wm_workspace(C), target);
- View3D *v3d = CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
+ int index = BKE_scene_transform_orientation_get_index(scene, target);
BLI_assert(index != -1);
- v3d->twmode = V3D_MANIP_CUSTOM;
- v3d->custom_orientation_index = index;
+ scene->orientation_type = V3D_MANIP_CUSTOM;
+ scene->orientation_index_custom = index;
}
/**
@@ -377,18 +377,17 @@ void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target)
* \param orientation: If this is #V3D_MANIP_CUSTOM or greater, the custom transform orientation
* with index \a orientation - #V3D_MANIP_CUSTOM gets activated.
*/
-void BIF_selectTransformOrientationValue(View3D *v3d, int orientation)
+void BIF_selectTransformOrientationValue(Scene *scene, int orientation)
{
const bool is_custom = orientation >= V3D_MANIP_CUSTOM;
-
- v3d->twmode = is_custom ? V3D_MANIP_CUSTOM : orientation;
- v3d->custom_orientation_index = is_custom ? (orientation - V3D_MANIP_CUSTOM) : -1;
+ scene->orientation_type = is_custom ? V3D_MANIP_CUSTOM : orientation;
+ scene->orientation_index_custom = is_custom ? (orientation - V3D_MANIP_CUSTOM) : -1;
}
int BIF_countTransformOrientation(const bContext *C)
{
- WorkSpace *workspace = CTX_wm_workspace(C);
- ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace);
+ Scene *scene = CTX_data_scene(C);
+ ListBase *transform_orientations = &scene->transform_spaces;
return BLI_listbase_count(transform_orientations);
}