[Bf-blender-cvs] [9e4dc72] depsgraph_refactor: Ported build functions for textures, materials and node trees.
Lukas Tönne
noreply at git.blender.org
Wed Apr 9 16:49:27 CEST 2014
Commit: 9e4dc7239484d98c43a9eb6601dae637e411d579
Author: Lukas Tönne
Date: Wed Apr 9 16:43:19 2014 +0200
https://developer.blender.org/rB9e4dc7239484d98c43a9eb6601dae637e411d579
Ported build functions for textures, materials and node trees.
===================================================================
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
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 6ceb52b..65ab0c8 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -38,8 +38,12 @@ struct ID;
struct FCurve;
struct Group;
struct Main;
+struct Material;
+struct MTex;
+struct bNodeTree;
struct Object;
struct Scene;
+struct Tex;
struct World;
struct Depsgraph;
@@ -70,6 +74,10 @@ struct DepsgraphNodeBuilder {
void build_rigidbody(Scene *scene);
void build_animdata(IDDepsNode *id_node);
OperationDepsNode *build_driver(ComponentDepsNode *adt_node, FCurve *fcurve);
+ void build_nodetree(IDDepsNode *owner_node, bNodeTree *ntree);
+ void build_material(IDDepsNode *owner_node, Material *ma);
+ void build_texture(IDDepsNode *owner_node, Tex *tex);
+ void build_texture_stack(IDDepsNode *owner_node, MTex **texture_stack);
void build_world(World *world);
void build_compositor(Scene *scene);
@@ -134,6 +142,10 @@ struct DepsgraphRelationBuilder {
void build_animdata(IDPtr id);
void build_driver(IDPtr id, FCurve *fcurve);
void build_world(Scene *scene, World *world);
+ 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_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 2c71480..7d802df 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -371,16 +371,104 @@ void DepsgraphNodeBuilder::build_world(World *world)
/* TODO: other settings? */
/* textures */
-// deg_build_texture_stack_graph(graph, scene, owner_component, wo->mtex);
+ build_texture_stack(world_node, world->mtex);
/* world's nodetree */
if (world->nodetree) {
-// deg_build_nodetree_graph(graph, scene, owner_component, wo->nodetree);
+ build_nodetree(world_node, world->nodetree);
}
id_tag_clear(world);
}
+void DepsgraphNodeBuilder::build_nodetree(IDDepsNode *owner_node, bNodeTree *ntree)
+{
+ if (!ntree)
+ return;
+
+ /* nodetree itself */
+ IDDepsNode *ntree_node = add_id_node(ntree);
+
+ build_animdata(ntree_node);
+
+ /* nodetree's nodes... */
+ for (bNode *bnode = (bNode *)ntree->nodes.first; bnode; bnode = bnode->next) {
+ if (bnode->id) {
+ if (GS(bnode->id->name) == ID_MA) {
+ build_material(owner_node, (Material *)bnode->id);
+ }
+ else if (bnode->type == ID_TE) {
+ build_texture(owner_node, (Tex *)bnode->id);
+ }
+ else if (bnode->type == NODE_GROUP) {
+ build_nodetree(owner_node, (bNodeTree *)bnode->id);
+ }
+ }
+ }
+
+ // TODO: link from nodetree to owner_component?
+}
+
+/* Recursively build graph for material */
+void DepsgraphNodeBuilder::build_material(IDDepsNode *owner_node, Material *ma)
+{
+ /* Prevent infinite recursion by checking (and tagging the material) as having been visited
+ * already. This assumes ma->id.flag & LIB_DOIT isn't set by anything else
+ * in the meantime... [#32017]
+ */
+ if (id_is_tagged(ma))
+ return;
+ id_tag_set(ma);
+
+ /* material itself */
+ IDDepsNode *ma_node = add_id_node(ma);
+
+ build_animdata(ma_node);
+
+ /* textures */
+ build_texture_stack(owner_node, ma->mtex);
+
+ /* material's nodetree */
+ build_nodetree(owner_node, ma->nodetree);
+
+ id_tag_clear(ma);
+}
+
+/* Texture-stack attached to some shading datablock */
+void DepsgraphNodeBuilder::build_texture_stack(IDDepsNode *owner_node, MTex **texture_stack)
+{
+ int i;
+
+ /* for now assume that all texture-stacks have same number of max items */
+ for (i = 0; i < MAX_MTEX; i++) {
+ MTex *mtex = texture_stack[i];
+ if (mtex)
+ build_texture(owner_node, mtex->tex);
+ }
+}
+
+/* Recursively build graph for texture */
+void DepsgraphNodeBuilder::build_texture(IDDepsNode *owner_node, Tex *tex)
+{
+ /* Prevent infinite recursion by checking (and tagging the texture) as having been visited
+ * already. This assumes tex->id.flag & LIB_DOIT isn't set by anything else
+ * in the meantime... [#32017]
+ */
+ if (id_is_tagged(tex))
+ return;
+ id_tag_set(tex);
+
+ IDDepsNode *tex_node = add_id_node(tex);
+
+ /* texture itself */
+ build_animdata(tex_node);
+
+ /* texture's nodetree */
+ build_nodetree(owner_node, tex->nodetree);
+
+ id_tag_clear(tex);
+}
+
void DepsgraphNodeBuilder::build_compositor(Scene *scene)
{
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index 6b731f8..acc5501 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -462,16 +462,94 @@ void DepsgraphRelationBuilder::build_world(Scene *scene, World *world)
/* TODO: other settings? */
/* textures */
-// deg_build_texture_stack_graph(graph, scene, owner_component, wo->mtex);
+ build_texture_stack(world, world->mtex);
/* world's nodetree */
- if (world->nodetree) {
-// deg_build_nodetree_graph(graph, scene, owner_component, wo->nodetree);
- }
+ build_nodetree(world, world->nodetree);
id_tag_clear(world);
}
+void DepsgraphRelationBuilder::build_nodetree(IDPtr owner, bNodeTree *ntree)
+{
+ if (!ntree)
+ return;
+
+ build_animdata(ntree);
+
+ /* nodetree's nodes... */
+ for (bNode *bnode = (bNode *)ntree->nodes.first; bnode; bnode = bnode->next) {
+ if (bnode->id) {
+ if (GS(bnode->id->name) == ID_MA) {
+ build_material(owner, (Material *)bnode->id);
+ }
+ else if (bnode->type == ID_TE) {
+ build_texture(owner, (Tex *)bnode->id);
+ }
+ else if (bnode->type == NODE_GROUP) {
+ build_nodetree(owner, (bNodeTree *)bnode->id);
+ }
+ }
+ }
+
+ // TODO: link from nodetree to owner_component?
+}
+
+/* Recursively build graph for material */
+void DepsgraphRelationBuilder::build_material(IDPtr owner, Material *ma)
+{
+ /* Prevent infinite recursion by checking (and tagging the material) as having been visited
+ * already. This assumes ma->id.flag & LIB_DOIT isn't set by anything else
+ * in the meantime... [#32017]
+ */
+ if (id_is_tagged(ma))
+ return;
+ id_tag_set(ma);
+
+ build_animdata(ma);
+
+ /* textures */
+ build_texture_stack(owner, ma->mtex);
+
+ /* material's nodetree */
+ build_nodetree(owner, ma->nodetree);
+
+ id_tag_clear(ma);
+}
+
+/* Recursively build graph for texture */
+void DepsgraphRelationBuilder::build_texture(IDPtr owner, Tex *tex)
+{
+ /* Prevent infinite recursion by checking (and tagging the texture) as having been visited
+ * already. This assumes tex->id.flag & LIB_DOIT isn't set by anything else
+ * in the meantime... [#32017]
+ */
+ if (id_is_tagged(tex))
+ return;
+ id_tag_set(tex);
+
+ /* texture itself */
+ build_animdata(tex);
+
+ /* texture's nodetree */
+ build_nodetree(owner, tex->nodetree);
+
+ id_tag_clear(tex);
+}
+
+/* Texture-stack attached to some shading datablock */
+void DepsgraphRelationBuilder::build_texture_stack(IDPtr owner, MTex **texture_stack)
+{
+ int i;
+
+ /* for now assume that all texture-stacks have same number of max items */
+ for (i = 0; i < MAX_MTEX; i++) {
+ MTex *mtex = texture_stack[i];
+ if (mtex)
+ build_texture(owner, mtex->tex);
+ }
+}
+
void DepsgraphRelationBuilder::build_compositor(Scene *scene)
{
More information about the Bf-blender-cvs
mailing list