[Bf-blender-cvs] [5dea6eacf5e] workspaces: Transform orientations: Make code match blender2.8 as much as possible

Julian Eisel noreply at git.blender.org
Thu May 25 19:30:27 CEST 2017


Commit: 5dea6eacf5e61eac2cc79b97c93b057eb02dbaaa
Author: Julian Eisel
Date:   Thu May 25 01:22:31 2017 +0200
Branches: workspaces
https://developer.blender.org/rB5dea6eacf5e61eac2cc79b97c93b057eb02dbaaa

Transform orientations: Make code match blender2.8 as much as possible

Basically reverts e3c12bb139250b7573b and parts of cbaaeb8d9b6c95.
Decided to keep things close to blender2.8 here, D2687 can apply the
needed changes separately then.
It's okay if removing custom transform orientations behave a bit glitchy
with workspaces, all issues should get fixed with D2687.

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

M	source/blender/blenkernel/BKE_screen.h
M	source/blender/blenkernel/BKE_workspace.h
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/writefile.c
M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/transform/transform.h
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_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 85831e4c2e2..645a99d592f 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -42,7 +42,6 @@ struct Panel;
 struct Scene;
 struct ScrArea;
 struct SpaceType;
-struct TransformOrientation;
 struct View3D;
 struct bContext;
 struct bContextDataResult;
@@ -310,8 +309,8 @@ 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_transform_orientation_remove(const struct bScreen *screen,
-                                             const struct TransformOrientation *orientation) ATTR_NONNULL();
+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_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 08e08168ebd..732ed341af2 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -30,7 +30,6 @@
 struct bScreen;
 struct ListBase;
 struct Main;
-struct TransformOrientation;
 struct WorkSpace;
 struct WorkSpaceDataRelation;
 
@@ -74,10 +73,6 @@ void BKE_workspace_layout_remove(
 		_workspace##_next = ((ID *)_workspace)->next; /* support removing workspace from list */
 #define BKE_WORKSPACE_ITER_END } ((void)0)
 
-void BKE_workspaces_transform_orientation_remove(
-        const struct ListBase *workspaces,
-        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(
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 2082975dcd8..b1f8f574b7e 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -611,17 +611,33 @@ void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene)
 	}
 }
 
-void BKE_screen_transform_orientation_remove(const bScreen *screen, const TransformOrientation *orientation)
+/* XXX apply D2687 */
+void BKE_screen_view3d_twmode_remove(View3D *v3d, const int i)
 {
-	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;
+	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--;
+	}
+}
+
+/* XXX apply D2687 */
+void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, Scene *scene, const int i)
+{
+	bScreen *sc;
 
-				if (v3d->custom_orientation == orientation) {
-					/* could also use v3d->custom_orientation->prev. */
-					v3d->twmode = V3D_MANIP_GLOBAL;
-					v3d->custom_orientation = NULL;
+	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);
+					}
 				}
 			}
 		}
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index f426c6fec3f..526bcba9206 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -35,7 +35,6 @@
 #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"
@@ -231,16 +230,6 @@ void BKE_workspace_layout_remove(
 /* -------------------------------------------------------------------- */
 /* General Utils */
 
-void BKE_workspaces_transform_orientation_remove(
-        const ListBase *workspaces, const TransformOrientation *orientation)
-{
-	BKE_WORKSPACE_ITER_BEGIN (workspace, workspaces->first) {
-		BKE_WORKSPACE_LAYOUT_ITER_BEGIN (layout, workspace->layouts.first) {
-			BKE_screen_transform_orientation_remove(BKE_workspace_layout_screen_get(layout), orientation);
-		} BKE_WORKSPACE_LAYOUT_ITER_END;
-	} BKE_WORKSPACE_ITER_END;
-}
-
 WorkSpaceLayout *BKE_workspace_layout_find(
         const WorkSpace *workspace, const bScreen *screen)
 {
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2b39d6a53c9..10498afc856 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6068,19 +6068,8 @@ static void direct_link_layer_collections(FileData *fd, ListBase *lb)
 	}
 }
 
-/**
- * bScreen data may use pointers to Scene data. We can't read this when reading screens
- * though, so we have to update screens when/after reading scenes. This function should
- * be called during Scene direct linking to update needed pointers within screen data
- * (as in everything visible in the window, not just bScreen).
- *
- * Maybe we could change read order so that screens are read after scene. But guess that
- * would be asking for trouble. Depending on the write/read order sounds ugly anyway,
- * Workspaces already depend on it...
- * -- Julian
- */
 static void direct_link_scene_update_screen_data(
-        FileData *fd, const Scene *scene, const ListBase *workspaces, const ListBase *screens)
+        FileData *fd, const Scene *scene, const ListBase *workspaces)
 {
 	BKE_WORKSPACE_ITER_BEGIN (workspace, workspaces->first) {
 		SceneLayer *layer = newdataadr(fd, BKE_workspace_render_layer_get(workspace));
@@ -6089,20 +6078,6 @@ static void direct_link_scene_update_screen_data(
 			BKE_workspace_render_layer_set(workspace, layer);
 		}
 	} BKE_WORKSPACE_ITER_END;
-
-	for (bScreen *screen = screens->first; screen; screen = screen->id.next) {
-		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) {
-						v3d->custom_orientation = newdataadr(fd, v3d->custom_orientation);
-					}
-				}
-			}
-		}
-	}
 }
 
 static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
@@ -6401,7 +6376,7 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
 	BKE_layer_collection_engine_settings_validate_scene(sce);
 	BKE_scene_layer_engine_settings_validate_scene(sce);
 
-	direct_link_scene_update_screen_data(fd, sce, &bmain->workspaces, &bmain->screen);
+	direct_link_scene_update_screen_data(fd, sce, &bmain->workspaces);
 }
 
 /* ************ READ WM ***************** */
@@ -7371,9 +7346,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
 			if (sl->spacetype == SPACE_VIEW3D) {
 				View3D *v3d= (View3D*) sl;
 				BGpic *bgpic;
-
-				/* v3d->custom_orientation will be updated later, see direct_link_scene_update_screens */
-
+				
 				v3d->flag |= V3D_INVALID_BACKBUF;
 				
 				link_list(fd, &v3d->bgpicbase);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index d2e1daa8543..a4b08666fd7 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2989,9 +2989,6 @@ static void write_screen(WriteData *wd, bScreen *sc)
 				BGpic *bgpic;
 				writestruct(wd, DATA, View3D, 1, v3d);
 
-				/* Don't write data of custom_orientation pointer here, scene already writes it. We only
-				 * have to update the pointer when reading (see direct_link_scene_update_screens) */
-
 				for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
 					writestruct(wd, DATA, BGpic, 1, bgpic);
 				}
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 5a294f43139..376ae8ca567 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -125,6 +125,7 @@ struct ReportList;
 
 void BIF_clearTransformOrientation(struct bContext *C);
 void BIF_removeTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
+void BIF_removeTransformOrientationIndex(struct bContext *C, int index);
 void BIF_createTransformOrientation(struct bContext *C, struct ReportList *reports,
                                     const char *name, const bool use_view,
                                     const bool activate, const bool overwrite);
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 38a1d3fccde..5544b08bbe9 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -788,7 +788,7 @@ bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const floa
 
 struct TransformOrientation *addMatrixSpace(struct bContext *C, float mat[3][3],
                                             const char *name, const bool overwrite);
-bool applyTransformOrientation(const struct TransformOrientation *ts, float r_mat[3][3], char r_name[64]);
+bool applyTransformOrientation(const struct bContext *C, float mat[3][3], char r_name[64], int index);
 
 #define ORIENTATION_NONE	0
 #define ORIENTATION_NORMAL	1
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 6adacb4bf4e..009cb2bac63 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -989,7 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list