Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2015-03-17 11:36:43 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-03-26 16:13:38 +0300
commit26b58bd1510ee0773b6373df9f160b7170e1b98c (patch)
treec8d25f4742e625976fd67b0da6c8d24cba5bfcbd /source
parent124e00bf8ae4d31da645f816e2db6875c6d9b632 (diff)
Enable frame updates of duplicache through use of an invalidation flag.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_anim.h2
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c4
-rw-r--r--source/blender/blenkernel/intern/object.c2
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c35
-rw-r--r--source/blender/editors/io/io_cache_library.c2
-rw-r--r--source/blender/makesdna/DNA_object_types.h8
6 files changed, 30 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index 3f6ae7927a6..04cb2b00887 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -78,7 +78,7 @@ struct ListBase *group_duplilist(struct EvaluationContext *eval_ctx, struct Scen
void free_object_duplilist(struct ListBase *lb);
int count_duplilist(struct Object *ob);
-void BKE_object_dupli_cache_update(struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx);
+void BKE_object_dupli_cache_update(struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, float frame);
void BKE_object_dupli_cache_clear(struct Object *ob);
void BKE_object_dupli_cache_free(struct Object *ob);
bool BKE_object_dupli_cache_contains(struct Object *ob, struct Object *other);
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 0451c2239ac..c9b906ee6a0 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2137,6 +2137,10 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
}
}
+ /* invalidate dupli cache */
+ if (ob->dup_cache)
+ ob->dup_cache->flag |= DUPCACHE_FLAG_DIRTY;
+
if (ob->recalc & OB_RECALC_OB)
lib_id_recalc_tag(bmain, &ob->id);
if (ob->recalc & OB_RECALC_DATA)
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 6f535180245..a72e6455371 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3216,8 +3216,6 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
}
/* quick cache removed */
-
- BKE_object_dupli_cache_update(scene, ob, eval_ctx);
}
ob->recalc &= ~OB_RECALC_ALL;
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 558f810ca0c..388be0ce429 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1227,17 +1227,9 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
/* Returns a list of DupliObject */
ListBase *object_duplilist_ex(EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update)
{
- /* XXX Warning: this could potentially lead to a lot of unnecessary cache reading!
- * In the future proper depsgraph integration of dupli cache updates would be desirable.
- */
-#if 0
if (update) {
- if (G.debug & G_DEBUG)
- printf("Update dupli cache for object '%s'\n", ob->id.name+2);
-
- BKE_object_dupli_cache_update(scene, ob, eval_ctx);
+ BKE_object_dupli_cache_update(scene, ob, eval_ctx, (float)scene->r.cfra);
}
-#endif
if (ob->dup_cache) {
/* Note: duplis in the cache don't have the main duplicator obmat applied.
@@ -1400,7 +1392,7 @@ static DupliObject *dupli_cache_add_object(DupliCache *dupcache)
/* ------------------------------------------------------------------------- */
-void BKE_object_dupli_cache_update(Scene *scene, Object *ob, EvaluationContext *eval_ctx)
+void BKE_object_dupli_cache_update(Scene *scene, Object *ob, EvaluationContext *eval_ctx, float frame)
{
const eCacheLibrary_EvalMode eval_mode = eval_ctx->mode == DAG_EVAL_RENDER ? CACHE_LIBRARY_EVAL_RENDER : CACHE_LIBRARY_EVAL_VIEWPORT;
Main *bmain = G.main;
@@ -1409,18 +1401,25 @@ void BKE_object_dupli_cache_update(Scene *scene, Object *ob, EvaluationContext *
if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group &&
BKE_cache_test_dupligroup(bmain, eval_mode, ob->dup_group)) {
- if (ob->dup_cache) {
- dupli_cache_clear(ob->dup_cache);
+ if (ob->dup_cache && !(ob->dup_cache->flag & DUPCACHE_FLAG_DIRTY)) {
+ /* skip if cache is valid */
}
else {
- ob->dup_cache = dupli_cache_new();
- }
-
- {
- /* TODO at this point we could apply animation offset */
- float frame = (float)scene->r.cfra;
+ if (G.debug & G_DEBUG)
+ printf("Update dupli cache for object '%s'\n", ob->id.name+2);
+ if (ob->dup_cache) {
+ dupli_cache_clear(ob->dup_cache);
+ }
+ else {
+ ob->dup_cache = dupli_cache_new();
+ }
+
+ /* TODO at this point we could apply animation offset */
BKE_cache_read_dupligroup(bmain, scene, frame, eval_mode, ob->dup_group, ob->dup_cache);
+
+ ob->dup_cache->flag &= ~DUPCACHE_FLAG_DIRTY;
+ ob->dup_cache->cfra = frame;
}
}
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index 094f9b1a66e..faf1d6a64d3 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -602,7 +602,7 @@ static int cache_library_rebuild_dupligroup_exec(bContext *C, wmOperator *UNUSED
eval_ctx.mode = DAG_EVAL_VIEWPORT;
- BKE_object_dupli_cache_update(scene, ob, &eval_ctx);
+ BKE_object_dupli_cache_update(scene, ob, &eval_ctx, (float)scene->r.cfra);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 6bfba0ab0fe..215cb8d04cf 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -345,11 +345,17 @@ typedef struct DupliObjectData {
} DupliObjectData;
typedef struct DupliCache {
- struct GHash *ghash;
+ int flag;
+ float cfra; /* frame for which the cache was constructed */
+ struct GHash *ghash;
ListBase duplilist;
} DupliCache;
+typedef enum eDupliCache_Flag {
+ DUPCACHE_FLAG_DIRTY = (1 << 0), /* cache requires update */
+} eDupliCache_Flag;
+
/* **************** OBJECT ********************* */
/* used many places... should be specialized */