[Bf-blender-cvs] [7d055da327b] blender2.8: Move transform orientation to scene

Campbell Barton noreply at git.blender.org
Wed Apr 18 09:17:08 CEST 2018


Commit: 7d055da327b9555f76035075ce4e228d31f04df4
Author: Campbell Barton
Date:   Wed Apr 18 09:12:44 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB7d055da327b9555f76035075ce4e228d31f04df4

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.

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/BKE_scene.h
M	source/blender/blenkernel/BKE_screen.h
M	source/blender/blenkernel/BKE_workspace.h
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/screen.c
M	source/blender/blenkernel/intern/workspace.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/screen/workspace_edit.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_header.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/transform/transform_ops.c
M	source/blender/editors/transform/transform_orientations.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesdna/DNA_workspace_types.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_workspace.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 48d0451632a..5e022aee0ed 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3734,11 +3734,11 @@ class VIEW3D_PT_transform_orientations(Panel):
     def draw(self, context):
         layout = self.layout
 
-        view = context.space_data
-        orientation = view.current_orientation
+        scene = context.scene
+        orientation = scene.current_orientation
 
         row = layout.row(align=True)
-        row.prop(view, "transform_orientation", text="")
+        row.prop(scene, "transform_orientation", text="")
         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
 
         if orientation:
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index afb77bb5206..8036673cbdf 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -48,6 +48,7 @@ struct ViewLayer;
 struct UnitSettings;
 struct ViewRender;
 struct WorkSpace;
+struct TransformOrientation;
 
 typedef enum eSceneCopyMethod {
 	SCE_COPY_NEW       = 0,
@@ -211,6 +212,13 @@ void BKE_scene_free_depsgraph_hash(struct Scene *scene);
 
 struct Depsgraph *BKE_scene_get_depsgraph(struct Scene *scene, struct ViewLayer *view_layer, bool allocate);
 
+void BKE_scene_transform_orientation_remove(
+        struct Scene *scene, struct TransformOrientation *orientation);
+struct TransformOrientation *BKE_scene_transform_orientation_find(
+        const struct Scene *scene, const int index);
+int BKE_scene_transform_orientation_get_index(
+        const struct Scene *scene, const struct TransformOrientation *orientation);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 984e3fb2a03..ee0fb5f2776 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -325,9 +325,6 @@ void BKE_screen_manipulator_tag_refresh(struct bScreen *sc);
 
 void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
 void BKE_screen_view3d_scene_sync(struct bScreen *sc, struct Scene *scene);
-void BKE_screen_transform_orientation_remove(
-        const struct bScreen *screen, const struct WorkSpace *workspace,
-        const struct TransformOrientation *orientation) ATTR_NONNULL();
 bool BKE_screen_is_fullscreen_area(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 bool BKE_screen_is_used(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index c4de9d134b7..3d28b66dd20 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -62,13 +62,6 @@ void BKE_workspace_view_layer_remove_references(
         const struct Main *bmain,
         const struct ViewLayer *view_layer) ATTR_NONNULL();
 
-void BKE_workspace_transform_orientation_remove(
-        struct WorkSpace *workspace, struct TransformOrientation *orientation) ATTR_NONNULL();
-struct TransformOrientation *BKE_workspace_transform_orientation_find(
-        const struct WorkSpace *workspace, const int index) ATTR_NONNULL();
-int BKE_workspace_transform_orientation_get_index(
-        const struct WorkSpace *workspace, const struct TransformOrientation *orientation) ATTR_NONNULL();
-
 struct WorkSpaceLayout *BKE_workspace_layout_find(
         const struct WorkSpace *workspace, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 struct WorkSpaceLayout *BKE_workspace_layout_find_global(
@@ -96,7 +89,6 @@ void            BKE_workspace_active_screen_set(
         struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct bScreen *screen) SETTER_ATTRS;
 
 struct Base *BKE_workspace_active_base_get(const struct WorkSpace *workspace, const struct Scene *scene);
-struct ListBase *BKE_workspace_transform_orientations_get(struct WorkSpace *workspace) GETTER_ATTRS;
 struct ViewLayer *BKE_workspace_view_layer_get(
         const struct WorkSpace *workspace,
         const struct Scene *scene) GETTER_ATTRS;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index e94a722ca28..e68d1db3e4a 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -272,6 +272,7 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
 	}
 
 	BLI_duplicatelist(&(sce_dst->markers), &(sce_src->markers));
+	BLI_duplicatelist(&(sce_dst->transform_spaces), &(sce_src->transform_spaces));
 	BLI_duplicatelist(&(sce_dst->r.views), &(sce_src->r.views));
 	BKE_keyingsets_copy(&(sce_dst->keyingsets), &(sce_src->keyingsets));
 
@@ -492,6 +493,7 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
 	}
 
 	BLI_freelistN(&sce->markers);
+	BLI_freelistN(&sce->transform_spaces);
 	BLI_freelistN(&sce->r.views);
 	
 	BKE_toolsettings_free(sce->toolsettings);
@@ -835,6 +837,8 @@ void BKE_scene_init(Scene *sce)
 	sce->toolsettings->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
 	sce->toolsettings->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
 
+	sce->orientation_index_custom = -1;
+
 	/* Master Collection */
 	sce->collection = MEM_callocN(sizeof(SceneCollection), "Master Collection");
 	BLI_strncpy(sce->collection->name, "Master Collection", sizeof(sce->collection->name));
@@ -2134,3 +2138,36 @@ Depsgraph *BKE_scene_get_depsgraph(Scene *scene,
 	}
 	return depsgraph;
 }
+
+/* -------------------------------------------------------------------- */
+/** \name Scene Orientation
+ * \{ */
+
+void BKE_scene_transform_orientation_remove(
+        Scene *scene, TransformOrientation *orientation)
+{
+	const int orientation_index = BKE_scene_transform_orientation_get_index(scene, orientation);
+	if (scene->orientation_index_custom == orientation_index) {
+		/* could also use orientation_index-- */
+		scene->orientation_type = V3D_MANIP_GLOBAL;
+		scene->orientation_index_custom = -1;
+	}
+	BLI_freelinkN(&scene->transform_spaces, orientation);
+}
+
+TransformOrientation *BKE_scene_transform_orientation_find(
+        const Scene *scene, const int index)
+{
+	return BLI_findlink(&scene->transform_spaces, index);
+}
+
+/**
+ * \return the index that \a orientation has within \a scene's transform-orientation list or -1 if not found.
+ */
+int BKE_scene_transform_orientation_get_index(
+        const Scene *scene, const TransformOrientation *orientation)
+{
+	return BLI_findindex(&scene->transform_spaces, orientation);
+}
+
+/** \} */
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 35055a59243..8283655503c 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -812,26 +812,6 @@ void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene)
 	}
 }
 
-void BKE_screen_transform_orientation_remove(
-        const bScreen *screen, const WorkSpace *workspace, const TransformOrientation *orientation)
-{
-	const int orientation_index = BKE_workspace_transform_orientation_get_index(workspace, orientation);
-
-	for (ScrArea *area = screen->areabase.first; area; area = area->next) {
-		for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
-			if (sl->spacetype == SPACE_VIEW3D) {
-				View3D *v3d = (View3D *)sl;
-
-				if (v3d->custom_orientation_index == orientation_index) {
-					/* could also use orientation_index-- */
-					v3d->twmode = V3D_MANIP_GLOBAL;
-					v3d->custom_orientation_index = -1;
-				}
-			}
-		}
-	}
-}
-
 /* magic zoom calculation, no idea what
  * it signifies, if you find out, tell me! -zr
  */
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index afceea9dd5f..466848fa6b1 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -171,7 +171,6 @@ void BKE_workspace_free(WorkSpace *workspace)
 
 	BLI_freelistN(&workspace->owner_ids);
 	BLI_freelistN(&workspace->layouts);
-	BLI_freelistN(&workspace->transform_orientations);
 
 	BKE_viewrender_free(&workspace->view_render);
 }
@@ -272,31 +271,6 @@ void BKE_workspace_view_layer_remove_references(
 	}
 }
 
-void BKE_workspace_transform_orientation_remove(
-        WorkSpace *workspace, TransformOrientation *orientation)
-{
-	for (WorkSpaceLayout *layout = workspace->layouts.first; layout; layout = layout->next) {
-		BKE_screen_transform_orientation_remove(BKE_workspace_layout_screen_get(layout), workspace, orientation);
-	}
-
-	BLI_freelinkN(&workspace->transform_orientations, orientation);
-}
-
-TransformOrientation *BKE_workspace_transform_orientation_find(
-        const WorkSpace *workspace, const int index)
-{
-	return BLI_findlink(&workspace->transform_orientations, index);
-}
-
-/**
- * \return the index that \a orientation has within \a workspace's transform-orientation list or -1 if not found.
- */
-int BKE_workspace_transform_orientation_get_index(
-        const WorkSpace *workspace, const TransformOrientation *orientation)
-{
-	return BLI_findindex(&workspace->transform_orientations, orientation);
-}
-
 WorkSpaceLayout *BKE_workspace_layout_find(
         const WorkSpace *workspace, const bScreen *screen)
 {
@@ -423,11 +397,6 @@ Base *BKE_workspace_active_base_get(const WorkSpace *workspace, const Scene *sce
 	return view_layer->basact;
 }
 
-ListBase *BKE_workspace_transform_orientations_get(WorkSpace *workspace)
-{
-	return &workspace->transform_orientations;
-}
-
 ViewLayer *BKE_workspace_view_layer_get(const WorkSpace *workspace, const Scene *scene)
 {
 	return workspace_relation_get_data_matching_parent(&workspace->scene_viewlayer_relations, scene);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b40321f75d1..fdd65add6d1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2902,7 +2902,6 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
 	link_lis

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list