[Bf-blender-cvs] [a6b9fc6] alembic: Use depsgraph tagging and notifiers to enforce dupli cache updates in the viewport.
Lukas Tönne
noreply at git.blender.org
Fri Apr 10 12:35:15 CEST 2015
Commit: a6b9fc6f22754569b1413fc6f53cca1ce70eea61
Author: Lukas Tönne
Date: Fri Apr 10 12:34:25 2015 +0200
Branches: alembic
https://developer.blender.org/rBa6b9fc6f22754569b1413fc6f53cca1ce70eea61
Use depsgraph tagging and notifiers to enforce dupli cache updates
in the viewport.
===================================================================
M source/blender/blenkernel/intern/cache_library.c
M source/blender/blenkernel/intern/depsgraph.c
M source/blender/makesrna/intern/rna_cache_library.c
===================================================================
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index e8f5149..089fc90 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -308,6 +308,23 @@ void BKE_cache_archive_output_path(CacheLibrary *cachelib, char *result, int max
BKE_cache_archive_path_ex(cachelib->output_filepath, cachelib->id.lib, cachelib->id.name+2, result, max);
}
+static bool has_active_cache(CacheLibrary *cachelib)
+{
+ const bool is_baking = cachelib->flag & CACHE_LIBRARY_BAKING;
+
+ /* don't read results from output archive when baking */
+ if (!is_baking) {
+ if (cachelib->display_mode == CACHE_LIBRARY_DISPLAY_RESULT) {
+ return true;
+ }
+ }
+
+ if (cachelib->source_mode == CACHE_LIBRARY_SOURCE_CACHE) {
+ return true;
+ }
+
+ return false;
+}
static struct PTCReaderArchive *find_active_cache(Scene *scene, CacheLibrary *cachelib)
{
@@ -421,36 +438,15 @@ bool BKE_cache_read_dupli_object(CacheLibrary *cachelib, DupliObjectData *data,
void BKE_cache_library_dag_recalc_tag(EvaluationContext *eval_ctx, Main *bmain)
{
- UNUSED_VARS(eval_ctx, bmain);
-#if 0
- eCacheLibrary_EvalMode eval_mode = (eval_ctx->mode == DAG_EVAL_RENDER) ? CACHE_LIBRARY_EVAL_RENDER : CACHE_LIBRARY_EVAL_REALTIME;
CacheLibrary *cachelib;
+ eCacheLibrary_EvalMode eval_mode = (eval_ctx->mode == DAG_EVAL_RENDER) ? CACHE_LIBRARY_EVAL_RENDER : CACHE_LIBRARY_EVAL_REALTIME;
- FOREACH_CACHELIB_READ(bmain, cachelib, eval_mode) {
- if (cachelib->flag & CACHE_LIBRARY_READ) {
- CacheItem *item;
-
- // TODO tag group instance objects or so?
-
- for (item = cachelib->items.first; item; item = item->next) {
- if (item->ob && (item->flag & CACHE_ITEM_ENABLED)) {
-
- switch (item->type) {
- case CACHE_TYPE_OBJECT:
- DAG_id_tag_update(&item->ob->id, OB_RECALC_OB | OB_RECALC_TIME);
- break;
- case CACHE_TYPE_DERIVED_MESH:
- case CACHE_TYPE_PARTICLES:
- case CACHE_TYPE_HAIR:
- case CACHE_TYPE_HAIR_PATHS:
- DAG_id_tag_update(&item->ob->id, OB_RECALC_DATA | OB_RECALC_TIME);
- break;
- }
- }
- }
+ for (cachelib = bmain->cache_library.first; cachelib; cachelib = cachelib->id.next) {
+ if (cachelib->eval_mode & eval_mode) {
+ if (has_active_cache(cachelib))
+ DAG_id_tag_update(&cachelib->id, OB_RECALC_DATA | OB_RECALC_TIME);
}
}
-#endif
}
/* ========================================================================= */
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 7ce49a0..8350525 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2593,6 +2593,21 @@ static void dag_id_flush_update(Main *bmain, Scene *sce, ID *id)
}
}
}
+
+ /* set flags based on CacheLibrary */
+ if (idtype == ID_CL) {
+ for (obt = bmain->object.first; obt; obt = obt->id.next) {
+ if (!(ob && obt == ob) && ((ID *)obt->cache_library == id)) {
+ obt->flag |= (OB_RECALC_OB | OB_RECALC_DATA);
+ lib_id_recalc_tag(bmain, &obt->id);
+ lib_id_recalc_data_tag(bmain, &obt->id);
+
+ /* invalidate dupli cache */
+ if (obt->dup_cache)
+ obt->dup_cache->flag |= DUPCACHE_FLAG_DIRTY;
+ }
+ }
+ }
/* camera's matrix is used to orient reconstructed stuff,
* so it should happen tracking-related constraints recalculation
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index 565a162..a35878b 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -80,8 +80,11 @@ EnumPropertyItem cache_modifier_type_items[] = {
/* ========================================================================= */
-static void rna_CacheLibrary_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+static void rna_CacheLibrary_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
+ CacheLibrary *cachelib = ptr->data;
+ DAG_id_tag_update(&cachelib->id, OB_RECALC_DATA);
+ WM_main_add_notifier(NC_WINDOW, NULL);
}
/* ========================================================================= */
More information about the Bf-blender-cvs
mailing list