[Bf-blender-cvs] [599f6c791af] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Mon Dec 3 08:08:43 CET 2018


Commit: 599f6c791af723894c995850e4590ecf6a23f6ab
Author: Campbell Barton
Date:   Mon Dec 3 18:01:19 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB599f6c791af723894c995850e4590ecf6a23f6ab

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/editors/object/object_modes.c
index 10c7fcfeba1,04d6ad641ed..4c625a4d33c
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@@ -180,106 -140,31 +180,107 @@@ void ED_object_mode_toggle(bContext *C
  /* Wrapper for operator  */
  void ED_object_mode_set(bContext *C, eObjectMode mode)
  {
 -#if 0
 +	wmWindowManager *wm = CTX_wm_manager(C);
 +	wm->op_undo_depth++;
 +	/* needed so we don't do undo pushes. */
 +	ED_object_mode_generic_enter(C, mode);
 +	wm->op_undo_depth--;
 +}
 +
 +void ED_object_mode_exit(bContext *C)
 +{
 +	Depsgraph *depsgraph = CTX_data_depsgraph(C);
 +	struct Main *bmain = CTX_data_main(C);
 +	Scene *scene = CTX_data_scene(C);
 +	ViewLayer *view_layer = CTX_data_view_layer(C);
 +	FOREACH_OBJECT_BEGIN(view_layer, ob)
 +	{
 +		if (ob->mode & OB_MODE_ALL_MODE_DATA) {
 +			ED_object_mode_generic_exit(bmain, depsgraph, scene, ob);
 +		}
 +	}
 +	FOREACH_OBJECT_END;
 +}
 +
 +/** \} */
 +
 +/* -------------------------------------------------------------------- */
 +/** \name Generic Mode Enter/Exit
 + *
 + * Supports exiting a mode without it being in the current context.
 + * This could be done for entering modes too if it's needed.
 + *
 + * \{ */
 +
 +bool ED_object_mode_generic_enter(
 +        struct bContext *C, eObjectMode object_mode)
 +{
- 	Object *ob = CTX_data_active_object(C);
++	ViewLayer *view_layer = CTX_data_view_layer(C);
++	Object *ob = OBACT(view_layer);
 +	if (ob == NULL) {
 +		return (object_mode == OB_MODE_OBJECT);
 +	}
 +	if (ob->mode == object_mode) {
 +		return true;
 +	}
  	wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_mode_set", false);
  	PointerRNA ptr;
 -
  	WM_operator_properties_create_ptr(&ptr, ot);
 -	RNA_enum_set(&ptr, "mode", mode);
 -	RNA_boolean_set(&ptr, "toggle", false);
 -	WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &ptr);
 +	RNA_enum_set(&ptr, "mode", object_mode);
 +	WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr);
  	WM_operator_properties_free(&ptr);
 -#else
 -	Scene *scene = CTX_data_scene(C);
 -	Object *ob = OBACT;
 -	if (ob == NULL) {
 -		return;
 +	return (ob->mode == object_mode);
 +}
 +
 +/**
 + * Use for changing works-paces or changing active object.
 + * Caller can check #OB_MODE_ALL_MODE_DATA to test if this needs to be run.
 + */
 +static bool ed_object_mode_generic_exit_ex(
 +        struct Main *bmain,
 +        struct Depsgraph *depsgraph,
 +        struct Scene *scene, struct Object *ob,
 +        bool only_test)
 +{
 +	BLI_assert((bmain == NULL) == only_test);
 +	if (ob->mode & OB_MODE_EDIT) {
 +		if (BKE_object_is_in_editmode(ob)) {
 +			if (only_test) {
 +				return true;
 +			}
 +			ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA);
 +		}
  	}
 -	if (ob->mode == mode) {
 -		/* pass */
 +	else if (ob->mode & OB_MODE_VERTEX_PAINT) {
 +		if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_VERTEX_PAINT)) {
 +			if (only_test) {
 +				return true;
 +			}
 +			ED_object_vpaintmode_exit_ex(ob);
 +		}
 +	}
 +	else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
 +		if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_WEIGHT_PAINT)) {
 +			if (only_test) {
 +				return true;
 +			}
 +			ED_object_wpaintmode_exit_ex(ob);
 +		}
  	}
 -	else if (mode != OB_MODE_OBJECT) {
 -		if (ob && (ob->mode & mode) == 0) {
 -			/* needed so we don't do undo pushes. */
 -			wmWindowManager *wm = CTX_wm_manager(C);
 -			wm->op_undo_depth++;
 -			ED_object_mode_toggle(C, mode);
 -			wm->op_undo_depth--;
 +	else if (ob->mode & OB_MODE_SCULPT) {
 +		if (ob->sculpt && (ob->sculpt->mode_type == OB_MODE_SCULPT)) {
 +			if (only_test) {
 +				return true;
 +			}
 +			ED_object_sculptmode_exit_ex(depsgraph, scene, ob);
 +		}
 +	}
 +	else if (ob->mode & OB_MODE_POSE) {
 +		if (ob->pose != NULL) {
 +			if (only_test) {
 +				return true;
 +			}
 +			ED_object_posemode_exit_ex(bmain, ob);
  		}
  	}
  	else {
diff --cc source/blender/editors/sculpt_paint/sculpt.c
index ef4f9a9c7bf,afee44c3dcc..d1232fca976
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@@ -5753,9 -5728,8 +5753,10 @@@ void ED_object_sculptmode_enter(struct 
  {
  	Main *bmain = CTX_data_main(C);
  	Scene *scene = CTX_data_scene(C);
- 	Object *ob = CTX_data_active_object(C);
 -	Object *ob = OBACT;
 -	ED_object_sculptmode_enter_ex(bmain, scene, ob, reports);
++	ViewLayer *view_layer = CTX_data_view_layer(C);
++	Object *ob = OBACT(view_layer);
 +	Depsgraph *depsgraph = CTX_data_depsgraph(C);
 +	ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, reports);
  }
  
  void ED_object_sculptmode_exit_ex(
@@@ -5808,20 -5780,16 +5809,22 @@@
  
  void ED_object_sculptmode_exit(bContext *C)
  {
 +	Depsgraph *depsgraph = CTX_data_depsgraph(C);
  	Scene *scene = CTX_data_scene(C);
- 	Object *ob = CTX_data_active_object(C);
 -	Object *ob = OBACT;
 -	ED_object_sculptmode_exit_ex(scene, ob);
++	ViewLayer *view_layer = CTX_data_view_layer(C);
++	Object *ob = OBACT(view_layer);
 +	ED_object_sculptmode_exit_ex(depsgraph, scene, ob);
  }
  
  static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
  {
 +	struct wmMsgBus *mbus = CTX_wm_message_bus(C);
  	Main *bmain = CTX_data_main(C);
 +	Depsgraph *depsgraph = CTX_data_depsgraph_on_load(C);
  	Scene *scene = CTX_data_scene(C);
 -	Object *ob = OBACT;
 +	ToolSettings *ts = scene->toolsettings;
- 	Object *ob = CTX_data_active_object(C);
++	ViewLayer *view_layer = CTX_data_view_layer(C);
++	Object *ob = OBACT(view_layer);
  	const int mode_flag = OB_MODE_SCULPT;
  	const bool is_mode_set = (ob->mode & mode_flag) != 0;
  
diff --cc source/blender/editors/sculpt_paint/sculpt_undo.c
index d79c6b81fd7,aab3e009a9d..92b4613bcea
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@@ -137,14 -135,12 +137,15 @@@ static bool sculpt_undo_restore_deforme
  	}
  }
  
 -static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNode *unode)
 +static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode)
  {
  	Scene *scene = CTX_data_scene(C);
 -	Object *ob = OBACT;
 -	Sculpt *sd = scene->toolsettings->sculpt;
 +	Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- 	Object *ob = CTX_data_active_object(C);
++	ViewLayer *view_layer = CTX_data_view_layer(C);
++	Object *ob = OBACT(view_layer);
 +	Depsgraph *depsgraph = CTX_data_depsgraph(C);
  	SculptSession *ss = ob->sculpt;
 +	SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
  	MVert *mvert;
  	int *index;
  
@@@ -255,12 -251,12 +256,13 @@@
  }
  
  static bool sculpt_undo_restore_hidden(
 -        bContext *C, DerivedMesh *dm,
 +        bContext *C,
          SculptUndoNode *unode)
  {
- 	Object *ob = CTX_data_active_object(C);
 -	Scene *scene = CTX_data_scene(C);
 -	Object *ob = OBACT;
++	ViewLayer *view_layer = CTX_data_view_layer(C);
++	Object *ob = OBACT(view_layer);
  	SculptSession *ss = ob->sculpt;
 +	SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
  	int i;
  
  	if (unode->maxvert) {
@@@ -289,11 -285,11 +291,12 @@@
  	return 1;
  }
  
 -static bool sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNode *unode)
 +static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
  {
- 	Object *ob = CTX_data_active_object(C);
 -	Scene *scene = CTX_data_scene(C);
 -	Object *ob = OBACT;
++	ViewLayer *view_layer = CTX_data_view_layer(C);
++	Object *ob = OBACT(view_layer);
  	SculptSession *ss = ob->sculpt;
 +	SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
  	MVert *mvert;
  	float *vmask;
  	int *index, i, j;
@@@ -477,10 -473,9 +480,11 @@@ static void sculpt_undo_restore_list(bC
  {
  	Scene *scene = CTX_data_scene(C);
  	Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- 	Object *ob = CTX_data_active_object(C);
 -	Object *ob = OBACT;
 -	DerivedMesh *dm;
++	ViewLayer *view_layer = CTX_data_view_layer(C);
++	Object *ob = OBACT(view_layer);
 +	Depsgraph *depsgraph = CTX_data_depsgraph(C);
  	SculptSession *ss = ob->sculpt;
 +	SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
  	SculptUndoNode *unode;
  	bool update = false, rebuild = false;
  	bool need_mask = false;
@@@ -640,7 -639,8 +644,9 @@@ static void sculpt_undo_free_list(ListB
  #if 0
  static bool sculpt_undo_cleanup(bContext *C, ListBase *lb)
  {
- 	Object *ob = CTX_data_active_object(C);
+ 	Scene *scene = CTX_data_scene(C);
 -	Object *ob = OBACT;
++	ViewLayer *view_layer = CTX_data_view_layer(C);
++	Object *ob = OBACT(view_layer);
  	SculptUndoNode *unode;
  
  	unode = lb->first;
@@@ -1021,7 -1018,8 +1027,8 @@@ static bool sculpt_undosys_poll(bContex
  {
  	ScrArea *sa = CTX_wm_area(C);
  	if (sa && (sa->spacetype == SPACE_VIEW3D)) {
- 		Object *obact = CTX_data_active_object(C);
 -		Scene *scene = CTX_data_scene(C);
 -		Object *obact = OBACT;
++		ViewLayer *view_layer = CTX_data_view_layer(C);
++		Object *obact = OBACT(view_layer);
  		if (obact && (obact->mode & OB_MODE_SCULPT)) {
  			return true;
  		}



More information about the Bf-blender-cvs mailing list