[Bf-blender-cvs] [d736d80] object_nodes: Use C callbacks for implementation of DepsNodeHandle.

Lukas Tönne noreply at git.blender.org
Wed Dec 16 13:26:33 CET 2015


Commit: d736d8073b8775bb8e4166241c4206af88eaabd7
Author: Lukas Tönne
Date:   Wed Dec 16 09:01:20 2015 +0100
Branches: object_nodes
https://developer.blender.org/rBd736d8073b8775bb8e4166241c4206af88eaabd7

Use C callbacks for implementation of DepsNodeHandle.

This makes it possible to create generic dependency functions to
handle dependencies in various ways, using the same reporting callback.
Currently used for depsgraph building in 2 passes (nodes & relations).

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

M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/depsgraph/intern/depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cc
M	source/blender/depsgraph/intern/depsgraph_build_relations.cc
M	source/blender/depsgraph/intern/depsgraph_types.h

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

diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 6e4f430..7f879e2 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -78,15 +78,6 @@ void DEG_scene_graph_free(struct Scene *scene);
 
 /* Add Dependencies  ----------------------------- */
 
-/* Handle for components to define their dependencies from callbacks.
- * This is generated by the depsgraph and passed to dependency callbacks
- * as a symbolic reference to the current DepsNode.
- * All relations will be defined in reference to that node.
- */
-struct DepsNodeHandle;
-
-struct Object;
-
 typedef enum eDepsSceneComponentType {
 	DEG_SCENE_COMP_PARAMETERS,     /* Parameters Component - Default when nothing else fits (i.e. just SDNA property setting) */
 	DEG_SCENE_COMP_ANIMATION,      /* Animation Component */                 // XXX: merge in with parameters?
@@ -116,6 +107,20 @@ typedef enum eDepsNodeTreeComponentType {
 	DEG_NTREE_COMP_PARAMETERS,    /* Parameters Component - Default when nothing else fits (i.e. just SDNA property setting) */
 } eDepsNodeTreeComponentType;
 
+/* Handle for components to define their dependencies from callbacks.
+ * This is generated by the depsgraph and passed to dependency callbacks
+ * as a symbolic reference to the current DepsNode.
+ * All relations will be defined in reference to that node.
+ */
+struct DepsNodeHandle
+{
+	void (*add_scene_relation)(struct DepsNodeHandle *node, struct Scene *scene, eDepsSceneComponentType component, const char *description);
+	void (*add_object_relation)(struct DepsNodeHandle *node, struct Object *ob, eDepsObjectComponentType component, const char *description);
+	void (*add_bone_relation)(struct DepsNodeHandle *handle, struct Object *ob, const char *bone_name, eDepsObjectComponentType component, const char *description);
+	void (*add_texture_relation)(struct DepsNodeHandle *handle, struct Tex *tex, eDepsTextureComponentType component, const char *description);
+	void (*add_nodetree_relation)(struct DepsNodeHandle *handle, struct bNodeTree *ntree, eDepsNodeTreeComponentType component, const char *description);
+};
+
 void DEG_add_scene_relation(struct DepsNodeHandle *node, struct Scene *scene, eDepsSceneComponentType component, const char *description);
 void DEG_add_object_relation(struct DepsNodeHandle *node, struct Object *ob, eDepsObjectComponentType component, const char *description);
 void DEG_add_bone_relation(struct DepsNodeHandle *handle, struct Object *ob, const char *bone_name, eDepsObjectComponentType component, const char *description);
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 2a403f1..47f589e 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -105,103 +105,36 @@ extern "C" {
 /* ****************** */
 /* External Build API */
 
-static eDepsNode_Type deg_build_scene_component_type(eDepsSceneComponentType component)
-{
-	switch (component) {
-		case DEG_SCENE_COMP_PARAMETERS:     return DEPSNODE_TYPE_PARAMETERS;
-		case DEG_SCENE_COMP_ANIMATION:      return DEPSNODE_TYPE_ANIMATION;
-		case DEG_SCENE_COMP_SEQUENCER:      return DEPSNODE_TYPE_SEQUENCER;
-	}
-	return DEPSNODE_TYPE_UNDEFINED;
-}
-
-static eDepsNode_Type deg_build_object_component_type(eDepsObjectComponentType component)
-{
-	switch (component) {
-		case DEG_OB_COMP_PARAMETERS:        return DEPSNODE_TYPE_PARAMETERS;
-		case DEG_OB_COMP_PROXY:             return DEPSNODE_TYPE_PROXY;
-		case DEG_OB_COMP_ANIMATION:         return DEPSNODE_TYPE_ANIMATION;
-		case DEG_OB_COMP_TRANSFORM:         return DEPSNODE_TYPE_TRANSFORM;
-		case DEG_OB_COMP_GEOMETRY:          return DEPSNODE_TYPE_GEOMETRY;
-		case DEG_OB_COMP_EVAL_POSE:         return DEPSNODE_TYPE_EVAL_POSE;
-		case DEG_OB_COMP_BONE:              return DEPSNODE_TYPE_BONE;
-		case DEG_OB_COMP_EVAL_PARTICLES:    return DEPSNODE_TYPE_EVAL_PARTICLES;
-		case DEG_OB_COMP_SHADING:           return DEPSNODE_TYPE_SHADING;
-	}
-	return DEPSNODE_TYPE_UNDEFINED;
-}
-
-static eDepsNode_Type deg_build_texture_component_type(eDepsTextureComponentType component)
-{
-	switch (component) {
-		case DEG_TEX_COMP_PARAMETERS:          return DEPSNODE_TYPE_PARAMETERS;
-	}
-	return DEPSNODE_TYPE_UNDEFINED;
-}
-
-static eDepsNode_Type deg_build_nodetree_component_type(eDepsNodeTreeComponentType component)
-{
-	switch (component) {
-		case DEG_NTREE_COMP_PARAMETERS:     return DEPSNODE_TYPE_PARAMETERS;
-	}
-	return DEPSNODE_TYPE_UNDEFINED;
-}
-
 void DEG_add_scene_relation(DepsNodeHandle *handle, struct Scene *scene, eDepsSceneComponentType component, const char *description)
 {
-	if (handle->relation_builder) {
-		eDepsNode_Type type = deg_build_scene_component_type(component);
-		ComponentKey comp_key(&scene->id, type);
-		handle->relation_builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_GEOMETRY_EVAL, description);
-	}
+	if (handle->add_scene_relation)
+		handle->add_scene_relation(handle, scene, component, description);
 }
 
 void DEG_add_object_relation(DepsNodeHandle *handle, struct Object *ob, eDepsObjectComponentType component, const char *description)
 {
-	if (handle->relation_builder) {
-		eDepsNode_Type type = deg_build_object_component_type(component);
-		ComponentKey comp_key(&ob->id, type);
-		handle->relation_builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_GEOMETRY_EVAL, description);
-	}
+	if (handle->add_object_relation)
+		handle->add_object_relation(handle, ob, component, description);
 }
 
 void DEG_add_bone_relation(DepsNodeHandle *handle, struct Object *ob, const char *bone_name, eDepsObjectComponentType component, const char *description)
 {
-	if (handle->relation_builder) {
-		eDepsNode_Type type = deg_build_object_component_type(component);
-		ComponentKey comp_key(&ob->id, type, bone_name);
-		
-		// XXX: "Geometry Eval" might not always be true, but this only gets called from modifier building now
-		handle->relation_builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_GEOMETRY_EVAL, description);
-	}
+	if (handle->add_bone_relation)
+		handle->add_bone_relation(handle, ob, bone_name, component, description);
 }
 
 void DEG_add_texture_relation(DepsNodeHandle *handle, struct Tex *tex, eDepsTextureComponentType component, const char *description)
 {
-	if (handle->node_builder) {
-		handle->node_builder->build_texture(NULL, tex);
-	}
-	if (handle->relation_builder) {
-		eDepsNode_Type type = deg_build_texture_component_type(component);
-		ComponentKey comp_key(&tex->id, type);
-		handle->relation_builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_STANDARD, description);
-	}
+	if (handle->add_texture_relation)
+		handle->add_texture_relation(handle, tex, component, description);
 }
 
 void DEG_add_nodetree_relation(DepsNodeHandle *handle, struct bNodeTree *ntree, eDepsNodeTreeComponentType component, const char *description)
 {
-	if (handle->node_builder) {
-		handle->node_builder->build_nodetree(NULL, ntree);
-	}
-	if (handle->relation_builder) {
-		eDepsNode_Type type = deg_build_nodetree_component_type(component);
-		ComponentKey comp_key(&ntree->id, type);
-		
-		handle->relation_builder->build_nodetree(NULL, ntree);
-		
-		handle->relation_builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_STANDARD, description);
-	}
+	if (handle->add_nodetree_relation)
+		handle->add_nodetree_relation(handle, ntree, component, description);
 }
+
 void DEG_add_special_eval_flag(Depsgraph *graph, ID *id, short flag)
 {
 	if (graph == NULL) {
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index aac99ef..8358c07 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -127,9 +127,6 @@ struct DepsgraphNodeBuilder {
 	void build_compositor(Scene *scene);
 	void build_gpencil(bGPdata *gpd);
 
-protected:
-	DepsNodeHandle create_node_handle();
-
 private:
 	Main *m_bmain;
 	Depsgraph *m_graph;
@@ -256,8 +253,8 @@ struct DepsgraphRelationBuilder
 	                  eDepsRelation_Type type, const char *description);
 
 	template <typename KeyType>
-	void add_node_handle_relation(const KeyType &key_from, const DepsNodeHandle *handle,
-	                              eDepsRelation_Type type, const char *description);
+	void add_node_relation(const KeyType &key_from, DepsNode *node,
+	                       eDepsRelation_Type type, const char *description);
 
 	void build_scene(Main *bmain, Scene *scene);
 	void build_group(Main *bmain, Scene *scene, Object *object, Group *group);
@@ -297,40 +294,12 @@ protected:
 	void add_operation_relation(OperationDepsNode *node_from, OperationDepsNode *node_to,
 	                            eDepsRelation_Type type, const char *description);
 
-	template <typename KeyType>
-	DepsNodeHandle create_node_handle(const KeyType &key, const string &default_name = "");
-
 	bool needs_animdata_node(ID *id);
 
 private:
 	Depsgraph *m_graph;
 };
 
-struct DepsNodeHandle
-{
-	DepsNodeHandle(DepsgraphNodeBuilder *builder) :
-	    node_builder(builder),
-	    relation_builder(NULL),
-	    node(NULL),
-	    default_name("")
-	{
-	}
-	
-	DepsNodeHandle(DepsgraphRelationBuilder *builder, OperationDepsNode *node, const string &default_name = "") :
-	    node_builder(NULL),
-	    relation_builder(builder),
-	    node(node),
-	    default_name(default_name)
-	{
-		BLI_assert(node != NULL);
-	}
-
-	DepsgraphNodeBuilder *node_builder;
-	DepsgraphRelationBuilder *relation_builder;
-	OperationDepsNode *node;
-	const string &default_name;
-};
-
 /* Utilities for Builders ----------------------------------------------------- */
 
 /* Get unique identifier for FCurves and Drivers */
@@ -390,14 +359,14 @@ void DepsgraphRelationBuilder::add_relation(const TimeSourceKey &key_from,
 }
 
 template <typename KeyType>
-void DepsgraphRelationBuilder::add_node_handle_relation(const KeyType &key_from,
-                                                        const DepsNodeHandle *handle,
-                                           

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list