[Bf-blender-cvs] [c4922d7] alembic_basic_io: Make new depsgraph aware of CacheFiles.

Kévin Dietrich noreply at git.blender.org
Fri Jul 8 05:57:32 CEST 2016


Commit: c4922d78419b039a81aa12e6df09ed660a10c973
Author: Kévin Dietrich
Date:   Fri Jul 8 05:56:57 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rBc4922d78419b039a81aa12e6df09ed660a10c973

Make new depsgraph aware of CacheFiles.

This adds a new component type in the depsgraph for cache file
evaluation. The cache file itself is not evaluated, rather it is for
evaluating objects depending on the cache file (through modifiers and
such).

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

M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.h
M	source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/depsgraph/intern/depsgraph_types.h
M	source/blender/depsgraph/intern/nodes/deg_node_component.cc
M	source/blender/depsgraph/intern/nodes/deg_node_component.h
M	source/blender/makesrna/intern/rna_cachefile.c
M	source/blender/modifiers/intern/MOD_meshsequencecache.c

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

diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 49b648c..0209e94 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -79,6 +79,7 @@ void DEG_scene_graph_free(struct Scene *scene);
  */
 struct DepsNodeHandle;
 
+struct CacheFile;
 struct Object;
 
 typedef enum eDepsSceneComponentType {
@@ -100,11 +101,13 @@ typedef enum eDepsObjectComponentType {
 	
 	DEG_OB_COMP_EVAL_PARTICLES,    /* Particle Systems Component */
 	DEG_OB_COMP_SHADING,           /* Material Shading Component */
+	DEG_OB_COMP_CACHE,             /* Cache Component */
 } eDepsObjectComponentType;
 
 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);
+void DEG_add_object_cache_relation(struct DepsNodeHandle *handle, struct CacheFile *cache_file, eDepsObjectComponentType component, const char *description);
 
 /* TODO(sergey): Remove once all geometry update is granular. */
 void DEG_add_special_eval_flag(struct Depsgraph *graph, struct ID *id, short flag);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 74a5be9..01fd306 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -46,6 +46,7 @@ extern "C" {
 #include "DNA_action_types.h"
 #include "DNA_anim_types.h"
 #include "DNA_armature_types.h"
+#include "DNA_cachefile_types.h"
 #include "DNA_camera_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_curve_types.h"
@@ -338,6 +339,14 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene)
 	if (scene->gpd) {
 		build_gpencil(scene->gpd);
 	}
+
+	/* cache files */
+	for (CacheFile *cachefile = static_cast<CacheFile *>(bmain->cachefiles.first);
+	     cachefile;
+	     cachefile = static_cast<CacheFile *>(cachefile->id.next))
+	{
+		build_cachefile(cachefile);
+	}
 }
 
 void DepsgraphNodeBuilder::build_group(Scene *scene,
@@ -1263,4 +1272,18 @@ void DepsgraphNodeBuilder::build_gpencil(bGPdata *gpd)
 	build_animdata(gpd_id);
 }
 
+void DepsgraphNodeBuilder::build_cachefile(CacheFile *cache_file)
+{
+	ID *cache_file_id = &cache_file->id;
+
+	add_component_node(cache_file_id, DEPSNODE_TYPE_CACHE);
+
+	add_operation_node(cache_file_id, DEPSNODE_TYPE_CACHE,
+	                   DEPSOP_TYPE_EXEC, NULL,
+	                   DEG_OPCODE_PLACEHOLDER, "Cache File Update");
+
+	add_id_node(cache_file_id);
+	build_animdata(cache_file_id);
+}
+
 }  // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 6ee0b84..f378f07 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -33,6 +33,7 @@
 #include "intern/depsgraph_types.h"
 
 struct Base;
+struct CacheFile;
 struct bGPdata;
 struct ListBase;
 struct GHash;
@@ -144,6 +145,7 @@ struct DepsgraphNodeBuilder {
 	void build_world(World *world);
 	void build_compositor(Scene *scene);
 	void build_gpencil(bGPdata *gpd);
+	void build_cachefile(CacheFile *cache_file);
 
 protected:
 	Main *m_bmain;
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
index 5ce84ee..2ec7650 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
@@ -90,6 +90,7 @@ static const int deg_debug_node_type_color_map[][2] = {
     {DEPSNODE_TYPE_GEOMETRY,     8},
     {DEPSNODE_TYPE_SEQUENCER,    9},
     {DEPSNODE_TYPE_SHADING,      10},
+    {DEPSNODE_TYPE_CACHE,        11},
     {-1,                         0}
 };
 #endif
@@ -401,6 +402,7 @@ static void deg_debug_graphviz_node(const DebugContext &ctx,
 		case DEPSNODE_TYPE_EVAL_POSE:
 		case DEPSNODE_TYPE_BONE:
 		case DEPSNODE_TYPE_SHADING:
+		case DEPSNODE_TYPE_CACHE:
 		case DEPSNODE_TYPE_EVAL_PARTICLES:
 		{
 			ComponentDepsNode *comp_node = (ComponentDepsNode *)node;
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index b1271c3..ae830da 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -33,6 +33,7 @@
 #include "MEM_guardedalloc.h"
 
 extern "C" {
+#include "DNA_cachefile_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
@@ -89,6 +90,7 @@ static DEG::eDepsNode_Type deg_build_object_component_type(
 		case DEG_OB_COMP_BONE:              return DEG::DEPSNODE_TYPE_BONE;
 		case DEG_OB_COMP_EVAL_PARTICLES:    return DEG::DEPSNODE_TYPE_EVAL_PARTICLES;
 		case DEG_OB_COMP_SHADING:           return DEG::DEPSNODE_TYPE_SHADING;
+		case DEG_OB_COMP_CACHE:             return DEG::DEPSNODE_TYPE_CACHE;
 	}
 	return DEG::DEPSNODE_TYPE_UNDEFINED;
 }
@@ -126,6 +128,20 @@ void DEG_add_object_relation(DepsNodeHandle *handle,
 	                                              description);
 }
 
+void DEG_add_object_cache_relation(DepsNodeHandle *handle,
+                                   CacheFile *cache_file,
+                                   eDepsObjectComponentType component,
+                                   const char *description)
+{
+	DEG::eDepsNode_Type type = deg_build_object_component_type(component);
+	DEG::ComponentKey comp_key(&cache_file->id, type);
+	DEG::DepsNodeHandle *deg_handle = get_handle(handle);
+	deg_handle->builder->add_node_handle_relation(comp_key,
+	                                              deg_handle,
+	                                              DEG::DEPSREL_TYPE_CACHE,
+	                                              description);
+}
+
 void DEG_add_bone_relation(DepsNodeHandle *handle,
                            Object *ob,
                            const char *bone_name,
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index 7516ccb..effd34a 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -133,6 +133,8 @@ typedef enum eDepsNode_Type {
 	DEPSNODE_TYPE_EVAL_PARTICLES   = 23,
 	/* Material Shading Component */
 	DEPSNODE_TYPE_SHADING          = 24,
+	/* Cache Component */
+	DEPSNODE_TYPE_CACHE            = 25,
 } eDepsNode_Type;
 
 /* Identifiers for common operations (as an enum). */
@@ -330,6 +332,9 @@ typedef enum eDepsRelation_Type {
 
 	/* relationship is used to trigger editor/screen updates */
 	DEPSREL_TYPE_UPDATE_UI,
+
+	/* cache dependency */
+	DEPSREL_TYPE_CACHE,
 } eDepsRelation_Type;
 
 }  // namespace DEG
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
index 6ac45c9..3669e25 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
@@ -366,6 +366,11 @@ static DepsNodeFactoryImpl<ParticlesComponentDepsNode> DNTI_EVAL_PARTICLES;
 DEG_DEPSNODE_DEFINE(ShadingComponentDepsNode, DEPSNODE_TYPE_SHADING, "Shading Component");
 static DepsNodeFactoryImpl<ShadingComponentDepsNode> DNTI_SHADING;
 
+/* Cache Component Defines ============================ */
+
+DEG_DEPSNODE_DEFINE(CacheComponentDepsNode, DEPSNODE_TYPE_CACHE, "Cache Component");
+static DepsNodeFactoryImpl<CacheComponentDepsNode> DNTI_CACHE;
+
 
 /* Node Types Register =================================== */
 
@@ -383,6 +388,8 @@ void deg_register_component_depsnodes()
 
 	deg_register_node_typeinfo(&DNTI_EVAL_PARTICLES);
 	deg_register_node_typeinfo(&DNTI_SHADING);
+
+	deg_register_node_typeinfo(&DNTI_CACHE);
 }
 
 }  // namespace DEG
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index 6f62d91..9a0f551 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -209,6 +209,10 @@ struct ShadingComponentDepsNode : public ComponentDepsNode {
 	DEG_DEPSNODE_DECLARE;
 };
 
+struct CacheComponentDepsNode : public ComponentDepsNode {
+	DEG_DEPSNODE_DECLARE;
+};
+
 
 void deg_register_component_depsnodes();
 
diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c
index 6ddfa22..a01af80 100644
--- a/source/blender/makesrna/intern/rna_cachefile.c
+++ b/source/blender/makesrna/intern/rna_cachefile.c
@@ -35,18 +35,32 @@
 #ifdef RNA_RUNTIME
 
 #include "BKE_cachefile.h"
+#include "BKE_depsgraph.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
 
 #ifdef WITH_ALEMBIC
 #  include "../../../alembic/ABC_alembic.h"
 #endif
 
+static void rna_CacheFile_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+	CacheFile *cache_file = (CacheFile *)ptr->data;
+
+	DAG_id_tag_update(&cache_file->id, 0);
+	WM_main_add_notifier(NC_SCENE | ND_FRAME, scene);
+
+	UNUSED_VARS(bmain);
+}
+
 static void rna_CacheFile_update_handle(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
 	CacheFile *cache_file = (CacheFile *)ptr->data;
 
 	BKE_cachefile_load(cache_file, bmain->name);
 
-	UNUSED_VARS(scene);
+	rna_CacheFile_update(bmain, scene, ptr);
 }
 
 #else
@@ -64,7 +78,7 @@ static void rna_def_cachefile(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_ui_text(prop, "Sequence", "Whether the cache is separated in a series of files");
-	RNA_def_property_update(prop, 0, NULL);
+	RNA_def_property_update(prop, 0, "rna_CacheFile_update");
 
 	/* ----------------- For Scene time ------------------- */
 
@@ -72,14 +86,14 @@ static void rna_def_cachefile(BlenderRNA *brna)
 	RNA_def_pro

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list