[Bf-blender-cvs] [cd48d4576ba] blender2.8: Depsgraph: Add proper API functions for CustomDataMask dependencies.

Alexander Gavrilov noreply at git.blender.org
Sun Oct 14 19:53:04 CEST 2018


Commit: cd48d4576bab3bf8d78c686433975cfee944f292
Author: Alexander Gavrilov
Date:   Sun Oct 14 19:59:27 2018 +0300
Branches: blender2.8
https://developer.blender.org/rBcd48d4576bab3bf8d78c686433975cfee944f292

Depsgraph: Add proper API functions for CustomDataMask dependencies.

There were a few copies of the same few lines in depsgraph build code,
so it seems to be logical to introduce a function for it, and make it
accessible from C code for completeness.

As an example, register the mask needs of the Data Transfer modifier.

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

M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_datatransfer.c

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

diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 24850c45d3a..4975f18f4ce 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -53,6 +53,8 @@ struct ViewLayer;
 extern "C" {
 #endif
 
+#include "BLI_sys_types.h"
+
 /* Graph Building -------------------------------- */
 
 /* Build depsgraph for the given scene, and dump results in given
@@ -139,6 +141,11 @@ void DEG_add_object_relation(struct DepsNodeHandle *node,
                              struct Object *object,
                              eDepsObjectComponentType component,
                              const char *description);
+void DEG_add_object_customdata_relation(struct DepsNodeHandle *node,
+                             struct Object *object,
+                             eDepsObjectComponentType component,
+                             uint64_t customdata_mask,
+                             const char *description);
 void DEG_add_bone_relation(struct DepsNodeHandle *handle,
                            struct Object *object,
                            const char *bone_name,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 65c9cabe9ef..56c2f32b387 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -274,6 +274,17 @@ bool DepsgraphRelationBuilder::has_node(const OperationKey &key) const
 	return find_node(key) != NULL;
 }
 
+void DepsgraphRelationBuilder::add_customdata_mask(const ComponentKey &key, uint64_t mask)
+{
+	if (mask != 0) {
+		OperationDepsNode *node = find_operation_node(key);
+
+		if (node != NULL) {
+			node->customdata_mask |= mask;
+		}
+	}
+}
+
 DepsRelation *DepsgraphRelationBuilder::add_time_relation(
         TimeSourceDepsNode *timesrc,
         DepsNode *node_to,
@@ -760,10 +771,7 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object)
 			add_relation(parent_key, ob_key, "Vertex Parent");
 
 			/* XXX not sure what this is for or how you could be done properly - lukas */
-			OperationDepsNode *parent_node = find_operation_node(parent_key);
-			if (parent_node != NULL) {
-				parent_node->customdata_mask |= CD_MASK_ORIGINDEX;
-			}
+			add_customdata_mask(parent_key, CD_MASK_ORIGINDEX);
 
 			ComponentKey transform_key(&object->parent->id, DEG_NODE_TYPE_TRANSFORM);
 			add_relation(transform_key, ob_key, "Vertex Parent TFM");
@@ -974,10 +982,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
 					ComponentKey target_key(&ct->tar->id, DEG_NODE_TYPE_GEOMETRY);
 					add_relation(target_key, constraint_op_key, cti->name);
 					if (ct->tar->type == OB_MESH) {
-						OperationDepsNode *node2 = find_operation_node(target_key);
-						if (node2 != NULL) {
-							node2->customdata_mask |= CD_MASK_MDEFORMVERT;
-						}
+						add_customdata_mask(target_key, CD_MASK_MDEFORMVERT);
 					}
 				}
 				else if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 5d283c25c7c..d3c7b0ebfaf 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -200,6 +200,8 @@ struct DepsgraphRelationBuilder
 	                                       const char *description,
 	                                       bool check_unique = false);
 
+	void add_customdata_mask(const ComponentKey &key, uint64_t mask);
+
 	void build_id(ID *id);
 	void build_layer_collections(ListBase *lb);
 	void build_view_layer(Scene *scene, ViewLayer *view_layer);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index c57962a8ed1..90df53d438f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -129,10 +129,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
 			add_relation(target_key, solver_key, con->name);
 
 			if (data->tar->type == OB_MESH) {
-				OperationDepsNode *node2 = find_operation_node(target_key);
-				if (node2 != NULL) {
-					node2->customdata_mask |= CD_MASK_MDEFORMVERT;
-				}
+				add_customdata_mask(target_key, CD_MASK_MDEFORMVERT);
 			}
 		}
 		else {
@@ -164,10 +161,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
 			add_relation(target_key, solver_key, con->name);
 
 			if (data->poletar->type == OB_MESH) {
-				OperationDepsNode *node2 = find_operation_node(target_key);
-				if (node2 != NULL) {
-					node2->customdata_mask |= CD_MASK_MDEFORMVERT;
-				}
+				add_customdata_mask(target_key, CD_MASK_MDEFORMVERT);
 			}
 		}
 		else {
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 1425c1bc453..957ca1a4275 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -131,6 +131,23 @@ void DEG_add_object_relation(DepsNodeHandle *handle,
 	                                              description);
 }
 
+void DEG_add_object_customdata_relation(DepsNodeHandle *handle,
+                             Object *object,
+                             eDepsObjectComponentType component,
+                             uint64_t customdata_mask,
+                             const char *description)
+{
+	DEG::eDepsNode_Type type = deg_build_object_component_type(component);
+	DEG::ComponentKey comp_key(&object->id, type);
+	DEG::DepsNodeHandle *deg_handle = get_handle(handle);
+	deg_handle->builder->add_node_handle_relation(comp_key,
+	                                              deg_handle,
+	                                              description);
+	if (object->type == OB_MESH) {
+		deg_handle->builder->add_customdata_mask(comp_key, customdata_mask);
+	}
+}
+
 void DEG_add_object_cache_relation(DepsNodeHandle *handle,
                                    CacheFile *cache_file,
                                    eDepsObjectComponentType component,
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 4f366fa36c4..200fa9335de 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -836,7 +836,7 @@ static void rna_DataTransferModifier_use_data_update(Main *bmain, Scene *scene,
 		dtmd->data_types &= ~DT_TYPE_POLY_ALL;
 	}
 
-	rna_Modifier_update(bmain, scene, ptr);
+	rna_Modifier_dependency_update(bmain, scene, ptr);
 }
 
 static void rna_DataTransferModifier_data_types_update(Main *bmain, Scene *scene, PointerRNA *ptr)
@@ -857,7 +857,7 @@ static void rna_DataTransferModifier_data_types_update(Main *bmain, Scene *scene
 		dtmd->flags |= MOD_DATATRANSFER_USE_POLY;
 	}
 
-	rna_Modifier_update(bmain, scene, ptr);
+	rna_Modifier_dependency_update(bmain, scene, ptr);
 }
 
 static void rna_DataTransferModifier_verts_data_types_set(struct PointerRNA *ptr, int value)
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index ac45ce8732d..6c99b5d95b3 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -129,7 +129,9 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
 {
 	DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
 	if (dtmd->ob_source != NULL) {
-		DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, "DataTransfer Modifier");
+		CustomDataMask mask = BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types);
+
+		DEG_add_object_customdata_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, mask, "DataTransfer Modifier");
 	}
 }



More information about the Bf-blender-cvs mailing list