[Bf-blender-cvs] [d138d7d] depsgraph_refactor: Depsgraph: Don't use smart templated ID pointer casts

Sergey Sharybin noreply at git.blender.org
Wed Nov 5 19:35:58 CET 2014


Commit: d138d7d6641ba5e4d2b56c2ec54898e698c82721
Author: Sergey Sharybin
Date:   Wed Nov 5 19:20:42 2014 +0100
Branches: depsgraph_refactor
https://developer.blender.org/rBd138d7d6641ba5e4d2b56c2ec54898e698c82721

Depsgraph: Don't use smart templated ID pointer casts

Replace smart templated functions which used to cast ID pointers
with explicit id struct member usage.

This makes code easier to follow and understand what exactly is
going on, don't introduce overhead into code. Plus it's helps
with debugging by skipping entering all that internal template
methods things.

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

M	source/blender/depsgraph/CMakeLists.txt
M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/depsgraph/intern/depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M	source/blender/depsgraph/intern/depsgraph_build_relations.cpp
M	source/blender/depsgraph/util/depsgraph_util_id.h
M	source/blender/depsgraph/util/depsgraph_util_rna.h
D	source/blender/depsgraph/util/depsgraph_util_type_traits.h

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

diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index db1bbeb..c395b62 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -81,7 +81,6 @@ set(SRC
 	util/depsgraph_util_string.h
 	util/depsgraph_util_task.h
 	util/depsgraph_util_task.cpp
-	util/depsgraph_util_type_traits.h
 )
 
 TEST_UNORDERED_MAP_SUPPORT()
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index ef17195..4a06739 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -133,14 +133,14 @@ static eDepsNode_Type deg_build_object_component_type(eDepsObjectComponentType c
 void DEG_add_scene_relation(DepsNodeHandle *handle, struct Scene *scene, eDepsSceneComponentType component, const char *description)
 {
 	eDepsNode_Type type = deg_build_scene_component_type(component);
-	ComponentKey comp_key(scene, type);
+	ComponentKey comp_key(&scene->id, type);
 	handle->builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_GEOMETRY_EVAL, string(description));
 }
 
 void DEG_add_object_relation(DepsNodeHandle *handle, struct Object *ob, eDepsObjectComponentType component, const char *description)
 {
 	eDepsNode_Type type = deg_build_object_component_type(component);
-	ComponentKey comp_key(ob, type);
+	ComponentKey comp_key(&ob->id, type);
 	handle->builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_GEOMETRY_EVAL, string(description));
 }
 
@@ -162,13 +162,13 @@ RootDepsNode *DepsgraphNodeBuilder::add_root_node()
 	return m_graph->add_root_node();
 }
 
-IDDepsNode *DepsgraphNodeBuilder::add_id_node(IDPtr id)
+IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
 {
 	const char *idtype_name = BKE_idcode_to_name(GS(id->name));
 	return m_graph->add_id_node(id, string_format("%s [%s]", id->name+2, idtype_name));
 }
 
-TimeSourceDepsNode *DepsgraphNodeBuilder::add_time_source(IDPtr id)
+TimeSourceDepsNode *DepsgraphNodeBuilder::add_time_source(ID *id)
 {
 	/* determine which node to attach timesource to */
 	if (id) {
@@ -209,7 +209,7 @@ TimeSourceDepsNode *DepsgraphNodeBuilder::add_time_source(IDPtr id)
 	return NULL;
 }
 
-ComponentDepsNode *DepsgraphNodeBuilder::add_component_node(IDPtr id, eDepsNode_Type comp_type, const string &comp_name)
+ComponentDepsNode *DepsgraphNodeBuilder::add_component_node(ID *id, eDepsNode_Type comp_type, const string &comp_name)
 {
 	IDDepsNode *id_node = add_id_node(id);
 	ComponentDepsNode *comp_node = id_node->add_component(comp_type, comp_name);
@@ -225,7 +225,7 @@ OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ComponentDepsNode *c
 	return op_node;
 }
 
-OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(IDPtr id, eDepsNode_Type comp_type, const string &comp_name,
+OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ID *id, eDepsNode_Type comp_type, const string &comp_name,
                                                             eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description)
 {
 	ComponentDepsNode *comp_node = add_component_node(id, comp_type, comp_name);
@@ -299,7 +299,7 @@ void DepsgraphNodeBuilder::verify_entry_exit_operations()
 /* ************************************************* */
 /* Relations Builder */
 
-RNAPathKey::RNAPathKey(IDPtr id, const string &path) :
+RNAPathKey::RNAPathKey(ID *id, const string &path) :
     id(id)
 {
 	/* create ID pointer for root of path lookup */
@@ -311,7 +311,7 @@ RNAPathKey::RNAPathKey(IDPtr id, const string &path) :
 	}
 }
 
-RNAPathKey::RNAPathKey(IDPtr id, const PointerRNA &ptr, PropertyRNA *prop) :
+RNAPathKey::RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop) :
     id(id),
     ptr(ptr),
     prop(prop)
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index b527085..3ac9753 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -107,16 +107,16 @@ struct DepsgraphNodeBuilder {
 	~DepsgraphNodeBuilder();
 	
 	RootDepsNode *add_root_node();
-	IDDepsNode *add_id_node(IDPtr id);
-	TimeSourceDepsNode *add_time_source(IDPtr id);
+	IDDepsNode *add_id_node(ID *id);
+	TimeSourceDepsNode *add_time_source(ID *id);
 	
-	ComponentDepsNode *add_component_node(IDPtr id, eDepsNode_Type comp_type, const string &comp_name = "");
+	ComponentDepsNode *add_component_node(ID *id, eDepsNode_Type comp_type, const string &comp_name = "");
 	
 	OperationDepsNode *add_operation_node(ComponentDepsNode *comp_node,
 	                                      eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description);
-	OperationDepsNode *add_operation_node(IDPtr id, eDepsNode_Type comp_type, const string &comp_name,
+	OperationDepsNode *add_operation_node(ID *id, eDepsNode_Type comp_type, const string &comp_name,
 	                                      eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description);
-	OperationDepsNode *add_operation_node(IDPtr id, eDepsNode_Type comp_type,
+	OperationDepsNode *add_operation_node(ID *id, eDepsNode_Type comp_type,
 	                                      eDepsOperation_Type optype, DepsEvalOperationCb op, const string &description)
 	{
 		return add_operation_node(id, comp_type, "", optype, op, description);
@@ -133,8 +133,8 @@ struct DepsgraphNodeBuilder {
 	void build_pose_constraints(Object *ob, bPoseChannel *pchan);
 	void build_rigidbody(Scene *scene);
 	void build_particles(Object *ob);
-	void build_animdata(IDPtr id);
-	OperationDepsNode *build_driver(IDPtr id, FCurve *fcurve);
+	void build_animdata(ID *id);
+	OperationDepsNode *build_driver(ID *id, FCurve *fcurve);
 	void build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con);
 	void build_splineik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con);
 	void build_rig(Object *ob);
@@ -165,17 +165,17 @@ struct RootKey
 struct TimeSourceKey
 {
 	TimeSourceKey() : id(NULL) {}
-	TimeSourceKey(IDPtr id) : id(id) {}
+	TimeSourceKey(ID *id) : id(id) {}
 	
-	IDPtr id;
+	ID *id;
 };
 
 struct ComponentKey
 {
 	ComponentKey() : id(NULL), type(DEPSNODE_TYPE_UNDEFINED), name("") {}
-	ComponentKey(IDPtr id, eDepsNode_Type type, const string &name = "") : id(id), type(type), name(name) {}
+	ComponentKey(ID *id, eDepsNode_Type type, const string &name = "") : id(id), type(type), name(name) {}
 	
-	IDPtr id;
+	ID *id;
 	eDepsNode_Type type;
 	string name;
 };
@@ -183,14 +183,14 @@ struct ComponentKey
 struct OperationKey
 {
 	OperationKey() : id(NULL), component_type(DEPSNODE_TYPE_UNDEFINED), component_name(""), name("") {}
-	OperationKey(IDPtr id, eDepsNode_Type component_type, const string &name) :
+	OperationKey(ID *id, eDepsNode_Type component_type, const string &name) :
 	    id(id), component_type(component_type), component_name(""), name(name)
 	{}
-	OperationKey(IDPtr id, eDepsNode_Type component_type, const string &component_name, const string &name) :
+	OperationKey(ID *id, eDepsNode_Type component_type, const string &component_name, const string &name) :
 	    id(id), component_type(component_type), component_name(component_name), name(name)
 	{}
 	
-	IDPtr id;
+	ID *id;
 	eDepsNode_Type component_type;
 	string component_name;
 	string name;
@@ -198,9 +198,9 @@ struct OperationKey
 
 struct RNAPathKey
 {
-	RNAPathKey(IDPtr id, const string &path);
-	RNAPathKey(IDPtr id, const PointerRNA &ptr, PropertyRNA *prop);
-	IDPtr id;
+	RNAPathKey(ID *id, const string &path);
+	RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop);
+	ID *id;
 	PointerRNA ptr;
 	PropertyRNA *prop;
 };
@@ -219,23 +219,23 @@ struct DepsgraphRelationBuilder {
 	void build_scene(Scene *scene);
 	void build_object(Scene *scene, Object *ob);
 	void build_object_parent(Object *ob);
-	void build_constraints(Scene *scene, IDPtr id, eDepsNode_Type component_type, const string &component_subdata, ListBase *constraints);
-	void build_animdata(IDPtr id);
-	void build_driver(IDPtr id, FCurve *fcurve);
+	void build_constraints(Scene *scene, ID *id, eDepsNode_Type component_type, const string &component_subdata, ListBase *constraints);
+	void build_animdata(ID *id);
+	void build_driver(ID *id, FCurve *fcurve);
 	void build_world(Scene *scene, World *world);
 	void build_rigidbody(Scene *scene);
 	void build_particles(Scene *scene, Object *ob);
 	void build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con);
 	void build_splineik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con);
 	void build_rig(Scene *scene, Object *ob);
-	void build_shapekeys(IDPtr obdata, Key *key);
+	void build_shapekeys(ID *obdata, Key *key);
 	void build_obdata_geom(Scene *scene, Object *ob);
 	void build_camera(Object *ob);
 	void build_lamp(Object *ob);
-	void build_nodetree(IDPtr owner, bNodeTree *ntree);
-	void build_material(IDPtr owner, Material *ma);
-	void build_texture(IDPtr owner, Tex *tex);
-	void build_texture_stack(IDPtr owner, MTex **texture_stack);
+	void build_nodetree(ID *owner, bNodeTree *ntree);
+	void build_material(ID *owner, Material *ma);
+	void build_texture(ID *owner, Tex *tex);
+	void build_texture_stack(ID *owner, MTex **texture_stack);
 	void build_compositor(Scene *scene);
 	
 protected:
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index 18a3362..6d69bb1 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -107,7 +107,7 @@ extern "C" {
 void DepsgraphNodeBuilder::build_scene(Scene *scene)
 {
 	/* timesource */
-	add_time_source(scene);
+	add_time_source(&scene->id);
 	
 	/* build subgraph for set, and link this in... */
 	// XXX: depending on how this goes, that scene itself could probably store its
@@ -135,17 +135,17 @@ void DepsgraphNodeBuilder::build_scene(Scene *scene)
 		 *       modifications...
 		 */
 		if (ob->dup_group) {
-			id_tag_set(ob->dup_group);
+			id_tag_set(&ob->dup_group->id);
 		}
 	}
 	
 	/* tagged groups */
 	for (Group *group = (Group *)m_bmain->group.first; group; 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list