[Bf-blender-cvs] [f21259c] temp_depsgraph_split_ubereval: Further split of the object derived mesh update into mesh vs. editmesh operations.

Lukas Tönne noreply at git.blender.org
Wed Sep 23 19:31:41 CEST 2015


Commit: f21259c3233ec4795975afb45e9d99fb4d529586
Author: Lukas Tönne
Date:   Wed Sep 23 08:53:49 2015 +0200
Branches: temp_depsgraph_split_ubereval
https://developer.blender.org/rBf21259c3233ec4795975afb45e9d99fb4d529586

Further split of the object derived mesh update into mesh vs. editmesh operations.

Mesh and editmesh are calculated in separate functions. In order to get to a point
where splitting into individual modifiers makes sense, the first step is to have
two separate operations for these.

Note that changing edit mode does not rebuild the depsgraph, so we cannot selectively
add only one or the other at build time. Instead both operations are added, but only
one of them is actually executed. Currently this uses an internal test for the edit
mesh, but could later be controlled on the depsgraph level based on active branches.

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

M	source/blender/blenkernel/BKE_DerivedMesh.h
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cc
M	source/blender/depsgraph/intern/depsgraph_build_relations.cc
M	source/blender/depsgraph/intern/depsnode_opcodes.h

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

diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index e6d5b89..ea04793 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -97,6 +97,7 @@ struct ColorBand;
 struct GPUVertexAttribs;
 struct GPUDrawObject;
 struct PBVH;
+struct EvaluationContext;
 
 /* number of sub-elements each mesh element has (for interpolation) */
 #define SUB_ELEMS_VERT 0
@@ -729,6 +730,9 @@ void makeDerivedMesh(
         struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
         CustomDataMask dataMask, const bool build_shapekey_layers);
 
+void BKE_object_eval_mesh(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+void BKE_object_eval_editmesh(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
+
 void weight_to_rgb(float r_rgb[3], const float weight);
 /** Update the weight MCOL preview layer.
  * If weights are NULL, use object's active vgroup(s).
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 40d449b..e286a78 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -207,7 +207,6 @@ void BKE_object_eval_data_ready(struct EvaluationContext *eval_ctx,
                                 struct Object *ob);
 
 void BKE_object_handle_data_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
-void BKE_object_eval_mesh(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
 void BKE_object_eval_armature(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
 void BKE_object_eval_mball(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
 void BKE_object_eval_curve(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index c48e5cf..b5349bd 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -50,6 +50,7 @@
 #include "BLI_linklist.h"
 
 #include "BKE_cdderivedmesh.h"
+#include "BKE_depsgraph.h"
 #include "BKE_editmesh.h"
 #include "BKE_key.h"
 #include "BKE_material.h"
@@ -2668,6 +2669,52 @@ void makeDerivedMesh(
 	}
 }
 
+void BKE_object_eval_mesh(EvaluationContext *eval_ctx,
+                          Scene *scene,
+                          Object *ob)
+{
+	BMEditMesh *em = (ob == scene->obedit) ? BKE_editmesh_from_object(ob) : NULL;
+	
+	if (!em) {
+		bool need_mapping;
+		CustomDataMask data_mask = scene->customdata_mask | CD_MASK_BAREMESH;
+		data_mask |= object_get_datamask(scene, ob, &need_mapping);
+#ifdef WITH_FREESTYLE
+		/* make sure Freestyle edge/face marks appear in DM for render (see T40315) */
+		if (eval_ctx->mode != DAG_EVAL_VIEWPORT) {
+			data_mask |= CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
+		}
+#else
+		UNUSED_VARS(eval_ctx);
+#endif
+		
+		mesh_build_data(scene, ob, data_mask, false, need_mapping);
+	}
+}
+
+void BKE_object_eval_editmesh(EvaluationContext *eval_ctx,
+                              Scene *scene,
+                              Object *ob)
+{
+	BMEditMesh *em = (ob == scene->obedit) ? BKE_editmesh_from_object(ob) : NULL;
+
+	if (em) {
+		bool need_mapping;
+		CustomDataMask data_mask = scene->customdata_mask | CD_MASK_BAREMESH;
+		data_mask |= object_get_datamask(scene, ob, &need_mapping);
+#ifdef WITH_FREESTYLE
+		/* make sure Freestyle edge/face marks appear in DM for render (see T40315) */
+		if (eval_ctx->mode != DAG_EVAL_VIEWPORT) {
+			data_mask |= CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
+		}
+#else
+		UNUSED_VARS(eval_ctx);
+#endif
+		
+		editbmesh_build_data(scene, ob, em, data_mask);
+	}
+}
+
 /***/
 
 DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dataMask)
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index ff66c29..6812a96 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -156,24 +156,6 @@ void BKE_object_eval_modifier(struct EvaluationContext *eval_ctx,
 	(void) md;  /* Ignored. */
 }
 
-void BKE_object_eval_mesh(EvaluationContext *eval_ctx,
-                                        Scene *scene,
-                                        Object *ob)
-{
-	BMEditMesh *em = (ob == scene->obedit) ? BKE_editmesh_from_object(ob) : NULL;
-	uint64_t data_mask = scene->customdata_mask | CD_MASK_BAREMESH;
-#ifdef WITH_FREESTYLE
-	/* make sure Freestyle edge/face marks appear in DM for render (see T40315) */
-	if (eval_ctx->mode != DAG_EVAL_VIEWPORT) {
-		data_mask |= CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
-	}
-#else
-	UNUSED_VARS(eval_ctx);
-#endif
-	
-	makeDerivedMesh(scene, ob, em, data_mask, false);
-}
-
 void BKE_object_eval_armature(EvaluationContext *UNUSED(eval_ctx),
                                             Scene *scene,
                                             Object *ob)
@@ -323,9 +305,12 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
 
 	/* includes all keys and modifiers */
 	switch (ob->type) {
-		case OB_MESH:
+		case OB_MESH: {
+			/* note: only one of these will run, based on edit object */
+			BKE_object_eval_editmesh(eval_ctx, scene, ob);
 			BKE_object_eval_mesh(eval_ctx, scene, ob);
 			break;
+		}
 		case OB_ARMATURE:
 			BKE_object_eval_armature(eval_ctx, scene, ob);
 			break;
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cc b/source/blender/depsgraph/intern/depsgraph_build_nodes.cc
index 03c7a54..03b6f22 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cc
@@ -69,6 +69,8 @@ extern "C" {
 #include "BKE_constraint.h"
 #include "BKE_curve.h"
 #include "BKE_depsgraph.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_editmesh.h"
 #include "BKE_effect.h"
 #include "BKE_fcurve.h"
 #include "BKE_idcode.h"
@@ -909,11 +911,18 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
 	ID *obdata = (ID *)ob->data;
 
 	switch (ob->type) {
-		case OB_MESH:
+		case OB_MESH: {
+			/* editmesh is unknown at depsgraph build time,
+			 * only one of these nodes will be evaluated.
+			 */
 			add_operation_node(&ob->id, DEPSNODE_TYPE_GEOMETRY,
 			                   DEPSOP_TYPE_EXEC, function_bind(BKE_object_eval_mesh, _1, scene, ob),
 			                   DEG_OPCODE_GEOMETRY_DATA_MESH);
+			add_operation_node(&ob->id, DEPSNODE_TYPE_GEOMETRY,
+			                   DEPSOP_TYPE_EXEC, function_bind(BKE_object_eval_editmesh, _1, scene, ob),
+			                   DEG_OPCODE_GEOMETRY_DATA_EDITMESH);
 			break;
+		}
 		case OB_ARMATURE:
 			/* XXX pose nodes are built in build_object() - should clarify what happens where for such object data */
 			break;
@@ -941,6 +950,10 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
 			break;
 	}
 
+	add_operation_node(&ob->id, DEPSNODE_TYPE_GEOMETRY,
+	                   DEPSOP_TYPE_EXEC, NULL,
+	                   DEG_OPCODE_PLACEHOLDER, "Data Update Done");
+
 	if (ob != scene->obedit && ob->particlesystem.first) {
 		add_operation_node(&ob->id, DEPSNODE_TYPE_GEOMETRY,
 		                   DEPSOP_TYPE_EXEC, function_bind(BKE_object_eval_particles, _1, scene, ob),
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cc b/source/blender/depsgraph/intern/depsgraph_build_relations.cc
index b6a2c79..d182aab 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cc
@@ -1602,28 +1602,45 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje
 		tail_key = geom_init_key;
 	}
 	
-	OperationKey obdata_update_key;
+	OperationKey obdata_update_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Data Update Done");
+	
 	switch (ob->type) {
-		case OB_MESH:
-			obdata_update_key = OperationKey(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_DATA_MESH);
+		case OB_MESH: {
+			OperationKey update_mesh(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_DATA_MESH);
+			OperationKey update_editmesh(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_DATA_EDITMESH);
+			add_relation(tail_key, update_mesh, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
+			add_relation(tail_key, update_editmesh, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
+			add_relation(update_mesh, obdata_update_key, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
+			add_relation(update_editmesh, obdata_update_key, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
 			break;
-		case OB_MBALL:
-			obdata_update_key = OperationKey(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_DATA_MBALL);
+		}
+		case OB_MBALL: {
+			OperationKey update_mball(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_DATA_MBALL);
+			add_relation(tail_key, update_mball, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
+			add_relation(update_mball, obdata_update_key, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
 			break;
+		}
 		case OB_CURVE:
 		case OB_SURF:
-		case OB_FONT:
-			obdata_update_key = OperationKey(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_DATA_CURVE);
+		case OB_FONT: {
+			OperationKey update_curve(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_DATA_CURVE);
+			add_relation(tail_key, update_curve, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
+			add_relation(update_curve, obdata_update_key, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
 			break;
-		case OB_LATTICE:
-			obdata_update_key = OperationKey(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_DATA_LATTICE);
+		}
+		case OB_LATTICE: {
+			OperationKey update_lattice(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_DATA_LATTICE);
+			add_relation(tail_key, update_lattice, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
+			add_relation(update_lattice, obdata_update_key, DEPSREL_TYPE_OPERATION, "Object Geometry Data Update");
 			b

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list