[Bf-blender-cvs] [2a184f3d2b6] blender2.8: Object Mode: use eval_ctx for paint & object

Campbell Barton noreply at git.blender.org
Tue Feb 6 08:01:22 CET 2018


Commit: 2a184f3d2b6cc180fedd0c93c266d847f7d27936
Author: Campbell Barton
Date:   Tue Feb 6 17:53:19 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB2a184f3d2b6cc180fedd0c93c266d847f7d27936

Object Mode: use eval_ctx for paint & object

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

M	source/blender/editors/mesh/mesh_data.c
M	source/blender/editors/mesh/mesh_navmesh.c
M	source/blender/editors/mesh/meshtools.c
M	source/blender/editors/object/object_bake_api.c
M	source/blender/editors/object/object_facemap_ops.c
M	source/blender/editors/object/object_modifier.c
M	source/blender/editors/object/object_ops.c
M	source/blender/editors/object/object_select.c
M	source/blender/editors/object/object_shapekey.c
M	source/blender/editors/object/object_transform.c
M	source/blender/editors/render/render_shading.c
M	source/blender/editors/sculpt_paint/paint_curve.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/sculpt_paint/paint_ops.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
M	source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

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

diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 218b97d3ede..efaf9a69e9c 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -506,13 +506,16 @@ static int layers_poll(bContext *C)
 
 static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
+	EvaluationContext eval_ctx;
+	CTX_data_eval_ctx(C, &eval_ctx);
+
 	Object *ob = ED_object_context(C);
 	Mesh *me = ob->data;
 
 	if (ED_mesh_uv_texture_add(me, NULL, true) == -1)
 		return OPERATOR_CANCELLED;
 
-	if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+	if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) {
 		Scene *scene = CTX_data_scene(C);
 		BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
 		WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
@@ -622,13 +625,16 @@ void MESH_OT_drop_named_image(wmOperatorType *ot)
 
 static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
 {
+	EvaluationContext eval_ctx;
+	CTX_data_eval_ctx(C, &eval_ctx);
+
 	Object *ob = ED_object_context(C);
 	Mesh *me = ob->data;
 
 	if (!ED_mesh_uv_texture_remove_active(me))
 		return OPERATOR_CANCELLED;
 
-	if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+	if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) {
 		Scene *scene = CTX_data_scene(C);
 		BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
 		WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
@@ -742,13 +748,16 @@ static int mesh_customdata_mask_clear_poll(bContext *C)
 {
 	Object *ob = ED_object_context(C);
 	if (ob && ob->type == OB_MESH) {
-		Mesh *me = ob->data;
+		EvaluationContext eval_ctx;
+		CTX_data_eval_ctx(C, &eval_ctx);
+
 
 		/* special case - can't run this if we're in sculpt mode */
-		if (ob->mode & OB_MODE_SCULPT) {
+		if (eval_ctx.object_mode & OB_MODE_SCULPT) {
 			return false;
 		}
 
+		Mesh *me = ob->data;
 		if (!ID_IS_LINKED(me)) {
 			CustomData *data = GET_CD_DATA(me, vdata);
 			if (CustomData_has_layer(data, CD_PAINT_MASK)) {
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
index bd2ad21d51c..aaa06951ec6 100644
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ b/source/blender/editors/mesh/mesh_navmesh.c
@@ -662,8 +662,10 @@ void MESH_OT_navmesh_face_add(struct wmOperatorType *ot)
 
 static int navmesh_obmode_data_poll(bContext *C)
 {
+	EvaluationContext eval_ctx;
+	CTX_data_eval_ctx(C, &eval_ctx);
 	Object *ob = ED_object_active_context(C);
-	if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
+	if (ob && (eval_ctx.object_mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
 		Mesh *me = ob->data;
 		return CustomData_has_layer(&me->pdata, CD_RECAST);
 	}
@@ -672,8 +674,10 @@ static int navmesh_obmode_data_poll(bContext *C)
 
 static int navmesh_obmode_poll(bContext *C)
 {
+	EvaluationContext eval_ctx;
+	CTX_data_eval_ctx(C, &eval_ctx);
 	Object *ob = ED_object_active_context(C);
-	if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
+	if (ob && (eval_ctx.object_mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) {
 		return true;
 	}
 	return false;
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 842b62be028..d0d43c4b3dd 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -1340,17 +1340,17 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
 
 MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve)
 {
-	if (ob->mode & OB_MODE_EDIT && ob->type == OB_MESH && ob->defbase.first) {
+	if (ob->type == OB_MESH && ob->defbase.first) {
 		Mesh *me = ob->data;
-		BMesh *bm = me->edit_btmesh->bm;
-		const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
-
-		if (cd_dvert_offset != -1) {
-			BMVert *eve = BM_mesh_active_vert_get(bm);
-
-			if (eve) {
-				if (r_eve) *r_eve = eve;
-				return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
+		if (me->edit_btmesh != NULL) {
+			BMesh *bm = me->edit_btmesh->bm;
+			const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
+			if (cd_dvert_offset != -1) {
+				BMVert *eve = BM_mesh_active_vert_get(bm);
+				if (eve) {
+					if (r_eve) *r_eve = eve;
+					return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
+				}
 			}
 		}
 	}
@@ -1375,7 +1375,8 @@ MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index)
 MDeformVert *ED_mesh_active_dvert_get_only(Object *ob)
 {
 	if (ob->type == OB_MESH) {
-		if (ob->mode & OB_MODE_EDIT) {
+		Mesh *me = ob->data;
+		if (me->edit_btmesh != NULL) {
 			return ED_mesh_active_dvert_get_em(ob, NULL);
 		}
 		else {
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 0174a307c16..37d6efa7746 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -623,8 +623,9 @@ static size_t initialize_internal_images(BakeImages *bake_images, ReportList *re
 /* create new mesh with edit mode changes and modifiers applied */
 static Mesh *bake_mesh_new_from_object(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *ob)
 {
-	if (ob->mode & OB_MODE_EDIT)
+	if (eval_ctx->object_mode & OB_MODE_EDIT) {
 		ED_object_editmode_load(ob);
+	}
 
 	Mesh *me = BKE_mesh_new_from_object(eval_ctx, bmain, scene, ob, 1, 2, 0, 0);
 	if (me->flag & ME_AUTOSMOOTH) {
diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c
index 857446ac6b0..87c1f5a10c2 100644
--- a/source/blender/editors/object/object_facemap_ops.c
+++ b/source/blender/editors/object/object_facemap_ops.c
@@ -173,7 +173,14 @@ static int face_map_supported_edit_mode_poll(bContext *C)
 {
 	Object *ob = ED_object_context(C);
 	ID *data = (ob) ? ob->data : NULL;
-	return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib && ob->mode == OB_MODE_EDIT);
+	if (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib) {
+		EvaluationContext eval_ctx;
+		CTX_data_eval_ctx(C, &eval_ctx);
+		if (eval_ctx.object_mode == OB_MODE_EDIT) {
+			return true;
+		}
+	}
+	return false;
 }
 
 static int face_map_add_exec(bContext *C, wmOperator *UNUSED(op))
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index ca58a60806c..0687287bd20 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -677,6 +677,8 @@ static int modifier_apply_obdata(ReportList *reports, const bContext *C, Scene *
 
 int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md, int mode)
 {
+	EvaluationContext eval_ctx;
+	CTX_data_eval_ctx(C, &eval_ctx);
 	int prev_mode;
 
 	if (scene->obedit) {
@@ -687,7 +689,7 @@ int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scen
 		BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data");
 		return 0;
 	}
-	else if ((ob->mode & OB_MODE_SCULPT) &&
+	else if ((eval_ctx.object_mode & OB_MODE_SCULPT) &&
 	         (find_multires_modifier_before(scene, md)) &&
 	         (modifier_isSameTopology(md) == false))
 	{
@@ -881,11 +883,13 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type)
 
 static int modifier_remove_exec(bContext *C, wmOperator *op)
 {
+	EvaluationContext eval_ctx;
+	CTX_data_eval_ctx(C, &eval_ctx);
 	Main *bmain = CTX_data_main(C);
 	ViewLayer *view_layer = CTX_data_view_layer(C);
 	Object *ob = ED_object_active_context(C);
 	ModifierData *md = edit_modifier_property_get(op, ob, 0);
-	int mode_orig = ob->mode;
+	int mode_orig = eval_ctx.object_mode;
 	
 	if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
 		return OPERATOR_CANCELLED;
@@ -893,11 +897,13 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
 	WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
 
 	/* if cloth/softbody was removed, particle mode could be cleared */
-	if (mode_orig & OB_MODE_PARTICLE_EDIT)
-		if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0)
-			if (view_layer->basact && view_layer->basact->object == ob)
+	if (mode_orig & OB_MODE_PARTICLE_EDIT) {
+		if ((eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) == 0) {
+			if (view_layer->basact && view_layer->basact->object == ob) {
 				WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
-	
+			}
+		}
+	}
 	return OPERATOR_FINISHED;
 }
 
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 9c321f5cb79..2aa2451b834 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -47,6 +47,8 @@
 #include "ED_screen.h"
 #include "ED_object.h"
 
+#include "DEG_depsgraph.h"
+
 #include "object_intern.h"
 
 
@@ -290,8 +292,11 @@ void ED_operatormacros_object(void)
 
 static int object_mode_poll(bContext *C)
 {
+	EvaluationContext eval_ctx;
+	CTX_data_eval_ctx(C, &eval_ctx);
+
 	Object *ob = CTX_data_active_object(C);
-	return (!ob || ob->mode == OB_MODE_OBJECT);
+	return (!ob || eval_ctx.object_mode == OB_MODE_OBJECT);
 }
 
 void ED_keymap_object(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index b20fe9a004c..d5a719515f8 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -64,6 +64,8 @@
 #include "BKE_library.h"
 #include "BKE_deform.h"
 
+#include "DEG_depsgraph.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -138,13 +140,14 @@ static int objects_selectable_poll(bContext *C)
 {
 	/* we don't check for linked scenes here, selection is
 	 * still allowed then for inspection of scene */
-	Object *obact = CTX_data_active_object(C);
-
-	if (CTX_data_edit_object(C))
+	if (CTX_data_edit_object(C)) {
 		return 0;
-	if (obact && obact->mode)
+	}
+	EvaluationContext eval_ctx;
+	CTX_data_eval_ctx(C, &eval_ctx);
+	if (eval_ctx.object_mode) {
 		return 0;
-	
+	}
 	return 1;
 }
 
diff --git a/source/blender/editors/object/object_shapekey.c b/source/b

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list