[Bf-blender-cvs] [1794f829769] temp-workspace_active_object: Initial code for setting the active object via workspace

Julian Eisel noreply at git.blender.org
Sat Dec 2 03:20:15 CET 2017


Commit: 1794f829769d02e4a3a48e47c4f0a0e37b37e020
Author: Julian Eisel
Date:   Thu Nov 30 16:46:47 2017 +0100
Branches: temp-workspace_active_object
https://developer.blender.org/rB1794f829769d02e4a3a48e47c4f0a0e37b37e020

Initial code for setting the active object via workspace

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

M	source/blender/blenkernel/BKE_workspace.h
M	source/blender/blenkernel/intern/workspace.c
M	source/blender/editors/object/object_hook.c
M	source/blender/editors/object/object_select.c

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

diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 2a35f0d2cae..9ee31947842 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -103,6 +103,7 @@ enum eObjectMode BKE_workspace_object_mode_get(const struct WorkSpace *workspace
 void            BKE_workspace_object_mode_set(struct WorkSpace *workspace, const enum eObjectMode mode) SETTER_ATTRS;
 #endif
 struct Base *BKE_workspace_active_base_get(const struct WorkSpace *workspace) GETTER_ATTRS;
+void BKE_workspace_active_base_set(struct WorkSpace *workspace, struct Base *base) SETTER_ATTRS;
 struct Object *BKE_workspace_active_object_get(const struct WorkSpace *workspace);
 struct ListBase *BKE_workspace_transform_orientations_get(struct WorkSpace *workspace) GETTER_ATTRS;
 struct ViewLayer *BKE_workspace_view_layer_get(const struct WorkSpace *workspace) GETTER_ATTRS;
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 6a95d2a6b4d..f3db41f0669 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -404,6 +404,10 @@ Base *BKE_workspace_active_base_get(const WorkSpace *workspace)
 {
 	return workspace->view_layer->basact;
 }
+void BKE_workspace_active_base_set(WorkSpace *workspace, Base *base)
+{
+	workspace->view_layer->basact = base;
+}
 
 Object *BKE_workspace_active_object_get(const WorkSpace *workspace)
 {
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 93546b1bd5d..b86f773a4ff 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -56,6 +56,7 @@
 #include "BKE_scene.h"
 #include "BKE_deform.h"
 #include "BKE_editmesh.h"
+#include "BKE_workspace.h"
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.h"
@@ -448,7 +449,9 @@ static int hook_op_edit_poll(bContext *C)
 	return 0;
 }
 
-static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit)
+static Object *add_hook_object_new(
+        Main *bmain, Scene *scene, ViewLayer *view_layer,
+        WorkSpace *workspace, Object *obedit)
 {
 	Base *base, *basedit;
 	Object *ob;
@@ -462,7 +465,7 @@ static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_la
 	
 	/* icky, BKE_object_add sets new base as active.
 	 * so set it back to the original edit object */
-	view_layer->basact = basedit;
+	BKE_workspace_active_base_set(workspace, basedit);
 
 	return ob;
 }
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 47e63cb43e5..006620d3be8 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -118,14 +118,13 @@ void ED_object_base_select(Base *base, eObjectSelect_Mode mode)
  */
 void ED_object_base_activate(bContext *C, Base *base)
 {
-	ViewLayer *view_layer = CTX_data_view_layer(C);
-	view_layer->basact = base;
+	WorkSpace *workspace = CTX_wm_workspace(C);
+
+	BKE_workspace_active_base_set(workspace, base);
 
 	if (base) {
-#ifdef USE_WORKSPACE_MODE
-		WorkSpace *workspace = CTX_wm_workspace(C);
-		BKE_workspace_object_mode_set(workspace, base->object->mode);
-#endif
+		/* TODO */
+		ViewLayer *view_layer = CTX_data_view_layer(C);
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, view_layer);
 	}
 	else {



More information about the Bf-blender-cvs mailing list