[Bf-blender-cvs] [46fc0bb87eb] blender2.8: Move custom transform orientations to workspace

Julian Eisel noreply at git.blender.org
Thu Jun 1 20:47:01 CEST 2017


Commit: 46fc0bb87ebda166d08b23cbcca799acb2c54158
Author: Julian Eisel
Date:   Thu Jun 1 20:41:18 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB46fc0bb87ebda166d08b23cbcca799acb2c54158

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).

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

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/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_constraints.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_screen_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
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 645a99d592f..6ff344fea38 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -42,6 +42,7 @@ struct Panel;
 struct Scene;
 struct ScrArea;
 struct SpaceType;
+struct TransformOrientation;
 struct View3D;
 struct bContext;
 struct bContextDataResult;
@@ -53,6 +54,7 @@ struct wmManipulatorMap;
 struct wmNotifier;
 struct wmWindow;
 struct wmWindowManager;
+struct WorkSpace;
 struct GPUFXSettings;
 
 #include "BLI_compiler_attrs.h"
@@ -309,8 +311,9 @@ unsigned int BKE_screen_view3d_layer_all(const struct bScreen *sc) ATTR_WARN_UNU
 
 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_view3d_twmode_remove(struct View3D *v3d, const int i);
-void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, struct Scene *scene, const int i);
+void BKE_screen_transform_orientation_remove(
+        const struct bScreen *screen, const struct WorkSpace *workspace,
+        const struct TransformOrientation *orientation) ATTR_NONNULL();
 void BKE_screen_gpu_fx_validate(struct GPUFXSettings *fx_settings);
 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 e7eaf72dd15..5595c874e27 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -28,6 +28,7 @@
 #include "BLI_compiler_attrs.h"
 
 struct bScreen;
+struct TransformOrientation;
 
 typedef struct WorkSpace WorkSpace;
 typedef struct WorkSpaceInstanceHook WorkSpaceInstanceHook;
@@ -66,11 +67,18 @@ void BKE_workspace_layout_remove(
 /* -------------------------------------------------------------------- */
 /* General Utils */
 
+void BKE_workspace_transform_orientation_remove(
+        WorkSpace *workspace, struct TransformOrientation *orientation) ATTR_NONNULL();
+struct TransformOrientation *BKE_workspace_transform_orientation_find(
+        const WorkSpace *workspace, const int index) ATTR_NONNULL();
+int BKE_workspace_transform_orientation_get_index(
+        const WorkSpace *workspace, const struct TransformOrientation *orientation) ATTR_NONNULL();
+
 WorkSpaceLayout *BKE_workspace_layout_find(
         const WorkSpace *workspace, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
 WorkSpaceLayout *BKE_workspace_layout_find_global(
         const struct Main *bmain, const struct bScreen *screen,
-        WorkSpace **r_workspace) ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
+        WorkSpace **r_workspace) ATTR_NONNULL(1, 2);
 
 WorkSpaceLayout *BKE_workspace_layout_iter_circular(
         const WorkSpace *workspace, WorkSpaceLayout *start,
@@ -95,6 +103,7 @@ enum ObjectMode BKE_workspace_object_mode_get(const WorkSpace *workspace) GETTER
 #ifdef USE_WORKSPACE_MODE
 void            BKE_workspace_object_mode_set(WorkSpace *workspace, const enum ObjectMode mode) SETTER_ATTRS;
 #endif
+struct ListBase *BKE_workspace_transform_orientations_get(WorkSpace *workspace) GETTER_ATTRS;
 struct SceneLayer *BKE_workspace_render_layer_get(const WorkSpace *workspace) GETTER_ATTRS;
 void               BKE_workspace_render_layer_set(WorkSpace *workspace, struct SceneLayer *layer) SETTER_ATTRS;
 struct ListBase *BKE_workspace_layouts_get(WorkSpace *workspace) GETTER_ATTRS;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 92f5dade0a5..235d606ff3e 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -261,7 +261,6 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
 			scen->rigidbody_world = BKE_rigidbody_world_copy(sce->rigidbody_world);
 
 		BLI_duplicatelist(&(scen->markers), &(sce->markers));
-		BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces));
 		BLI_duplicatelist(&(scen->r.layers), &(sce->r.layers));
 		BLI_duplicatelist(&(scen->r.views), &(sce->r.views));
 		BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets));
@@ -534,10 +533,9 @@ void BKE_scene_free(Scene *sce)
 	}
 
 	BLI_freelistN(&sce->markers);
-	BLI_freelistN(&sce->transform_spaces);
 	BLI_freelistN(&sce->r.layers);
 	BLI_freelistN(&sce->r.views);
-	
+
 	if (sce->toolsettings) {
 		if (sce->toolsettings->vpaint) {
 			BKE_paint_free(&sce->toolsettings->vpaint->paint);
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index b1f8f574b7e..91d675535f3 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -53,6 +53,7 @@
 #include "BKE_icons.h"
 #include "BKE_idprop.h"
 #include "BKE_screen.h"
+#include "BKE_workspace.h"
 
 /* ************ Spacetype/regiontype handling ************** */
 
@@ -611,33 +612,20 @@ void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene)
 	}
 }
 
-/* XXX apply D2687 */
-void BKE_screen_view3d_twmode_remove(View3D *v3d, const int i)
+void BKE_screen_transform_orientation_remove(
+        const bScreen *screen, const WorkSpace *workspace, const TransformOrientation *orientation)
 {
-	const int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
-	if (selected_index == i) {
-		v3d->twmode = V3D_MANIP_GLOBAL;
-	}
-	else if (selected_index > i) {
-		v3d->twmode--;
-	}
-}
+	const int orientation_index = BKE_workspace_transform_orientation_get_index(workspace, orientation);
 
-/* XXX apply D2687 */
-void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, Scene *scene, const int i)
-{
-	bScreen *sc;
+	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;
 
-	for (sc = screen_lb->first; sc; sc = sc->id.next) {
-		if (sc->scene == scene) {
-			ScrArea *sa;
-			for (sa = sc->areabase.first; sa; sa = sa->next) {
-				SpaceLink *sl;
-				for (sl = sa->spacedata.first; sl; sl = sl->next) {
-					if (sl->spacetype == SPACE_VIEW3D) {
-						View3D *v3d = (View3D *)sl;
-						BKE_screen_view3d_twmode_remove(v3d, i);
-					}
+				if (v3d->custom_orientation_index == orientation_index) {
+					/* could also use orientation_index-- */
+					v3d->twmode = V3D_MANIP_GLOBAL;
+					v3d->custom_orientation_index = -1;
 				}
 			}
 		}
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 8afad317dce..82fface7d06 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -35,6 +35,7 @@
 #include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_screen.h"
 #include "BKE_workspace.h"
 
 #include "DNA_object_types.h"
@@ -150,6 +151,7 @@ void BKE_workspace_free(WorkSpace *workspace)
 		workspace_relation_remove(&workspace->hook_layout_relations, relation);
 	}
 	BLI_freelistN(&workspace->layouts);
+	BLI_freelistN(&workspace->transform_orientations);
 }
 
 void BKE_workspace_remove(Main *bmain, WorkSpace *workspace)
@@ -223,6 +225,31 @@ void BKE_workspace_layout_remove(
 /* -------------------------------------------------------------------- */
 /* General Utils */
 
+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)
 {
@@ -240,6 +267,7 @@ WorkSpaceLayout *BKE_workspace_layout_find(
 
 /**
  * Find the layout for \a screen without knowing which workspace to look in.
+ * Can also be used to find the workspace that contains \a screen.
  *
  * \param r_workspace: Optionally return the workspace that contains the looked up layout (if found).
  */
@@ -353,6 +381,11 @@ void BKE_workspace_object_mode_set(WorkSpace *workspace, const ObjectMode mode)
 }
 #endif
 
+ListBase *BKE_workspace_transform_orientations_get(WorkSpace *workspace)
+{
+	return &workspace->transform_orientations;
+}
+
 SceneLayer *BKE_workspace_render_layer_get(const WorkSpace *workspace)
 {
 	return workspace->render_layer;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 966cbce62db..8e89c61d9f7 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2820,6 +2820,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
 {
 	link_list(fd, BKE_workspace_layouts_get(workspace));
 	link_list(fd, &workspace->hook_layout_relations);
+	link_list(fd, BKE_workspace_transform_orientations_get(workspace));
 
 	for (WorkSpaceDataRelation *relation = workspace->hook_layout_relations.first;
 	     relation;
@@ -2835,7 +2836,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
 		BKE_workspace_render_layer_set(workspace, NULL);
 	}
 
-	/* Same issue/fix as in direct_link_scene_update_screen_data: Can't read workspace data
+	/* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data
 	 * when reading windows, so have to update windows after/whe

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list