[Bf-blender-cvs] [ef11113399e] blender2.8: Object Mode: use eval_ctx mode in transform code

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


Commit: ef11113399e3273ee647b3710b346356a2b5f8f0
Author: Campbell Barton
Date:   Tue Feb 6 16:34:11 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBef11113399e3273ee647b3710b346356a2b5f8f0

Object Mode: use eval_ctx mode in transform code

This adds EvaluationContext into TransInfo

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

M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/transform/transform_orientations.c
M	source/blender/editors/transform/transform_snap.c
M	source/blender/editors/transform/transform_snap_object.c

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

diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 4ad66c0a9a5..1d67a0b3adf 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -41,6 +41,8 @@
 
 #include "DNA_listBase.h"
 
+#include "DEG_depsgraph.h"
+
 /* ************************** Types ***************************** */
 
 struct Depsgraph;
@@ -465,6 +467,7 @@ typedef struct TransInfo {
 
 	bool		remove_on_cancel; /* remove elements if operator is canceled */
 
+	EvaluationContext eval_ctx;
 	void		*view;
 	struct bContext *context; /* Only valid (non null) during an operator called function. */
 	struct ScrArea	*sa;
@@ -649,7 +652,8 @@ void restoreBones(TransInfo *t);
 
 #define MANIPULATOR_AXIS_LINE_WIDTH 2.0f
 
-bool gimbal_axis(struct Object *ob, float gmat[3][3]); /* return 0 when no gimbal for selection */
+/* return 0 when no gimbal for selection */
+bool gimbal_axis(struct Object *ob, float gmat[3][3], const short object_mode);
 
 /*********************** TransData Creation and General Handling *********** */
 void createTransData(struct bContext *C, TransInfo *t);
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 6c55967fc8f..ecc02ef7abc 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -998,10 +998,13 @@ static short pose_grab_with_ik(Object *ob)
 	Bone *bonec;
 	short tot_ik = 0;
 
-	if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0)
+	if ((ob == NULL) || (ob->pose == NULL))
 		return 0;
 
 	arm = ob->data;
+	if ((arm->flag & ARM_POSEMODE) == 0) {
+		return 0;
+	}
 
 	/* Rule: allow multiple Bones (but they must be selected, and only one ik-solver per chain should get added) */
 	for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -2049,9 +2052,7 @@ void flushTransParticles(TransInfo *t)
 			point->flag |= PEP_EDIT_RECALC;
 	}
 
-	EvaluationContext eval_ctx;
-	CTX_data_eval_ctx(t->context, &eval_ctx);
-	PE_update_object(&eval_ctx, scene, view_layer, OBACT(view_layer), 1);
+	PE_update_object(&t->eval_ctx, scene, view_layer, OBACT(view_layer), 1);
 }
 
 /* ********************* mesh ****************** */
@@ -2463,7 +2464,6 @@ static void createTransEditVerts(TransInfo *t)
 {
 	TransData *tob = NULL;
 	TransDataExtension *tx = NULL;
-	EvaluationContext eval_ctx;
 	BMEditMesh *em = BKE_editmesh_from_object(t->obedit);
 	Mesh *me = t->obedit->data;
 	BMesh *bm = em->bm;
@@ -2482,11 +2482,6 @@ static void createTransEditVerts(TransInfo *t)
 	int island_info_tot;
 	int *island_vert_map = NULL;
 
-	DEG_evaluation_context_init_from_scene(
-	        &eval_ctx,
-	        t->scene, t->view_layer, t->engine_type, t->obedit->mode,
-	        DAG_EVAL_VIEWPORT);
-
 	/* Even for translation this is needed because of island-orientation, see: T51651. */
 	const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
 	/* Original index of our connected vertex when connected distances are calculated.
@@ -2570,7 +2565,7 @@ static void createTransEditVerts(TransInfo *t)
 		if (modifiers_isCorrectableDeformed(t->scene, t->obedit)) {
 			/* check if we can use deform matrices for modifier from the
 			 * start up to stack, they are more accurate than quats */
-			totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(&eval_ctx, t->scene, t->obedit, em, &defmats, &defcos);
+			totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(&t->eval_ctx, t->scene, t->obedit, em, &defmats, &defcos);
 		}
 
 		/* if we still have more modifiers, also do crazyspace
@@ -2583,7 +2578,7 @@ static void createTransEditVerts(TransInfo *t)
 		if (totleft > 0)
 #endif
 		{
-			mappedcos = BKE_crazyspace_get_mapped_editverts(&eval_ctx, t->scene, t->obedit);
+			mappedcos = BKE_crazyspace_get_mapped_editverts(&t->eval_ctx, t->scene, t->obedit);
 			quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats");
 			BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !prop_mode);
 			if (mappedcos)
@@ -5409,9 +5404,6 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
 	Scene *scene = t->scene;
 	bool constinv;
 	bool skip_invert = false;
-	EvaluationContext eval_ctx;
-
-	CTX_data_eval_ctx(t->context, &eval_ctx);
 
 	if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
 		float rot[3][3], scale[3];
@@ -5459,11 +5451,11 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
 
 	if (skip_invert == false && constinv == false) {
 		ob->transflag |= OB_NO_CONSTRAINTS;  /* BKE_object_where_is_calc_time checks this */
-		BKE_object_where_is_calc(&eval_ctx, t->scene, ob);
+		BKE_object_where_is_calc(&t->eval_ctx, t->scene, ob);
 		ob->transflag &= ~OB_NO_CONSTRAINTS;
 	}
 	else
-		BKE_object_where_is_calc(&eval_ctx, t->scene, ob);
+		BKE_object_where_is_calc(&t->eval_ctx, t->scene, ob);
 
 	td->ob = ob;
 
@@ -6104,14 +6096,11 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
  * */
 void special_aftertrans_update(bContext *C, TransInfo *t)
 {
-	EvaluationContext eval_ctx;
 	Object *ob;
 //	short redrawipo=0, resetslowpar=1;
 	const bool canceled = (t->state == TRANS_CANCEL);
 	const bool duplicate = (t->mode == TFM_TIME_DUPLICATE);
 
-	CTX_data_eval_ctx(C, &eval_ctx);
-	
 	/* early out when nothing happened */
 	if (t->total == 0 || t->mode == TFM_DUMMY)
 		return;
@@ -6450,7 +6439,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
 			 * we need to update the pose otherwise no updates get called during
 			 * transform and the auto-ik is not applied. see [#26164] */
 			struct Object *pose_ob = t->poseobj;
-			BKE_pose_where_is(&eval_ctx, t->scene, pose_ob);
+			BKE_pose_where_is(&t->eval_ctx, t->scene, pose_ob);
 		}
 
 		/* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */
@@ -6494,7 +6483,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
 	}
 	else if ((t->view_layer->basact) &&
 	         (ob = t->view_layer->basact->object) &&
-	         (ob->mode & OB_MODE_PARTICLE_EDIT) &&
+	         (t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) &&
 	         PE_get_current(t->scene, t->view_layer, ob))
 	{
 		/* do nothing */
@@ -8232,26 +8221,30 @@ void createTransData(bContext *C, TransInfo *t)
 			t->poseobj = ob;    /* <- tsk tsk, this is going to give issues one day */
 		}
 	}
-	else if (ob && (ob->mode & OB_MODE_POSE)) {
+	else if (ob && (t->eval_ctx.object_mode & OB_MODE_POSE)) {
 		// XXX this is currently limited to active armature only...
 		// XXX active-layer checking isn't done as that should probably be checked through context instead
 		createTransPose(t, ob);
 	}
-	else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) {
+	else if (ob && (t->eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) {
 		/* important that ob_armature can be set even when its not selected [#23412]
 		 * lines below just check is also visible */
 		Object *ob_armature = modifiers_isDeformedByArmature(ob);
-		if (ob_armature && ob_armature->mode & OB_MODE_POSE) {
-			Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
-			if (base_arm) {
-				if (BASE_VISIBLE(base_arm)) {
-					createTransPose(t, ob_armature);
+		if (ob_armature) {
+			const bArmature *arm = ob_armature->data;
+			if (arm->flag & ARM_POSEMODE) {
+				Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
+				if (base_arm) {
+					if (BASE_VISIBLE(base_arm)) {
+						createTransPose(t, ob_armature);
+					}
 				}
 			}
-			
 		}
 	}
-	else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, view_layer, ob))) {
+	else if (ob && (t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) &&
+	         PE_start_edit(PE_get_current(scene, view_layer, ob)))
+	{
 		createTransParticleVerts(C, t);
 		t->flag |= T_POINTS;
 
@@ -8261,7 +8254,7 @@ void createTransData(bContext *C, TransInfo *t)
 			sort_trans_data_dist(t);
 		}
 	}
-	else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
+	else if (ob && (t->eval_ctx.object_mode & OB_MODE_ALL_PAINT)) {
 		if ((t->options & CTX_PAINT_CURVE) && !ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN)) {
 			t->flag |= T_POINTS | T_2D_EDIT;
 			createTransPaintCurveVerts(C, t);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 1aa4513e99b..bd4acbe72cf 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -904,7 +904,9 @@ static void recalcData_objects(TransInfo *t)
 		else
 			BKE_pose_where_is(&eval_ctx, t->scene, ob);
 	}
-	else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, t->view_layer, base->object)) {
+	else if (base && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) &&
+	         PE_get_current(t->scene, t->view_layer, base->object))
+	{
 		if (t->state != TRANS_CANCEL) {
 			applyProject(t);
 		}
@@ -1115,6 +1117,8 @@ static int initTransInfo_edit_pet_to_flag(const int proportional)
  */
 void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
 {
+	EvaluationContext eval_ctx;
+	CTX_data_eval_ctx(C, &eval_ctx);
 	Depsgraph *depsgraph = CTX_data_depsgraph(C);
 	Scene *sce = CTX_data_scene(C);
 	ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -1266,7 +1270,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 			}
 		}
 
-		if (ob && ob->mode & OB_MODE_ALL_PAINT) {
+		if (ob && eval_ctx.object_mode & OB_MODE_ALL_PAINT) {
 			Paint *p = BKE_paint_get_active_from_context(C);
 			if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) {
 				t->options |= CTX_PAINT_CURVE;
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 0643687c29a..556f47d86a7 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -63,6 +63,8 @@
 
 #include "BIF_gl.h"
 
+#inc

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list