[Bf-blender-cvs] [c963488b5e2] master: Pose Mode: pass object to mode enter/exit

Campbell Barton noreply at git.blender.org
Wed Apr 11 09:21:49 CEST 2018


Commit: c963488b5e25b906ff72cbaabdcc76cbfbc77172
Author: Campbell Barton
Date:   Wed Apr 11 09:20:29 2018 +0200
Branches: master
https://developer.blender.org/rBc963488b5e25b906ff72cbaabdcc76cbfbc77172

Pose Mode: pass object to mode enter/exit

Also add lower level mode exit function

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

M	source/blender/editors/armature/pose_edit.c
M	source/blender/editors/include/ED_armature.h
M	source/blender/editors/object/object_edit.c
M	source/blender/editors/space_outliner/outliner_select.c

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

diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index f1ae006f958..d0c467b2d2c 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -81,9 +81,8 @@ Object *ED_pose_object_from_context(bContext *C)
 }
 
 /* This function is used to process the necessary updates for */
-bool ED_object_posemode_enter_ex(Base *base)
+bool ED_object_posemode_enter_ex(Object *ob)
 {
-	Object *ob = base->object;
 	BLI_assert(!ID_IS_LINKED(ob));
 	bool ok = false;
 	
@@ -100,30 +99,37 @@ bool ED_object_posemode_enter_ex(Base *base)
 
 	return ok;
 }
-bool ED_object_posemode_enter(bContext *C, Base *base)
+bool ED_object_posemode_enter(bContext *C, Object *ob)
 {
 	ReportList *reports = CTX_wm_reports(C);
-	if (ID_IS_LINKED(base->object)) {
+	if (ID_IS_LINKED(ob)) {
 		BKE_report(reports, RPT_WARNING, "Cannot pose libdata");
 		return false;
 	}
-	bool ok = ED_object_posemode_enter_ex(base);
+	bool ok = ED_object_posemode_enter_ex(ob);
 	if (ok) {
 		WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL);
 	}
 	return ok;
 }
 
-void ED_object_posemode_exit(bContext *C, Base *base)
+bool ED_object_posemode_exit_ex(Object *ob)
 {
-	if (base) {
-		Object *ob = base->object;
-		
+	bool ok = false;
+	if (ob) {
 		ob->restore_mode = ob->mode;
 		ob->mode &= ~OB_MODE_POSE;
-		
+		ok = true;
+	}
+	return ok;
+}
+bool ED_object_posemode_exit(bContext *C, Object *ob)
+{
+	bool ok = ED_object_posemode_exit_ex(ob);
+	if (ok) {
 		WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
 	}
+	return ok;
 }
 
 /* if a selected or active bone is protected, throw error (oonly if warn == 1) and return 1 */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 2089f81b0d7..ae54dd802ee 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -195,9 +195,10 @@ void ED_armature_ebone_listbase_free(struct ListBase *lb);
 void ED_armature_ebone_listbase_copy(struct ListBase *lb_dst, struct ListBase *lb_src);
 
 /* poseobject.c */
-void ED_object_posemode_exit(struct bContext *C, struct Base *base);
-bool ED_object_posemode_enter_ex(struct Base *base);
-bool ED_object_posemode_enter(struct bContext *C, struct Base *base);
+bool ED_object_posemode_exit_ex(struct Object *ob);
+bool ED_object_posemode_exit(struct bContext *C, struct Object *ob);
+bool ED_object_posemode_enter_ex(struct Object *ob);
+bool ED_object_posemode_enter(struct bContext *C, struct Object *ob);
 void ED_pose_de_selectall(struct Object *ob, int select_mode, const bool ignore_visibility);
 void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
 void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 0eda9668c47..844ed168157 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -718,10 +718,10 @@ static int posemode_exec(bContext *C, wmOperator *op)
 		}
 
 		if (is_mode_set) {
-			ED_object_posemode_exit(C, base);
+			ED_object_posemode_exit(C, ob);
 		}
 		else {
-			ED_object_posemode_enter(C, base);
+			ED_object_posemode_enter(C, ob);
 		}
 		
 		return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index ec234f0c08b..27c96bd0232 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -714,13 +714,16 @@ static eOLDrawState tree_element_active_pose(
 	}
 
 	if (set != OL_SETSEL_NONE) {
-		if (scene->obedit)
+		if (scene->obedit) {
 			ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO);
+		}
 		
-		if (ob->mode & OB_MODE_POSE)
-			ED_object_posemode_exit(C, base);
-		else 
-			ED_object_posemode_enter(C, base);
+		if (ob->mode & OB_MODE_POSE) {
+			ED_object_posemode_exit(C, ob);
+		}
+		else {
+			ED_object_posemode_enter(C, ob);
+		}
 	}
 	else {
 		if (ob->mode & OB_MODE_POSE) {



More information about the Bf-blender-cvs mailing list