[Bf-blender-cvs] [1d32a23] alembic: Added transient DupliCache data baking modifiers/simulations and writing into the output cache archive.
Lukas Tönne
noreply at git.blender.org
Wed Apr 1 10:00:38 CEST 2015
Commit: 1d32a23c78713376b37d2866483b3a9deedb4210
Author: Lukas Tönne
Date: Tue Mar 31 18:06:48 2015 +0200
Branches: alembic
https://developer.blender.org/rB1d32a23c78713376b37d2866483b3a9deedb4210
Added transient DupliCache data baking modifiers/simulations and
writing into the output cache archive.
===================================================================
M source/blender/blenkernel/BKE_anim.h
M source/blender/blenkernel/BKE_cache_library.h
M source/blender/blenkernel/intern/cache_library.c
M source/blender/blenkernel/intern/object_dupli.c
M source/blender/editors/io/io_cache_library.c
M source/blender/makesdna/DNA_cache_library_types.h
M source/blender/makesrna/intern/rna_main_api.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index 4824c33..52cf217 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -90,8 +90,9 @@ void BKE_dupli_object_data_clear(struct DupliObjectData *data);
void BKE_dupli_object_data_set_mesh(struct DupliObjectData *data, struct DerivedMesh *dm);
void BKE_dupli_object_data_add_strands(struct DupliObjectData *data, struct Strands *strands);
+void BKE_dupli_cache_free(struct DupliCache *dupcache);
+struct DupliCache *BKE_dupli_cache_new(void);
struct DupliObjectData *BKE_dupli_cache_add_object(struct DupliCache *dupcache, struct Object *ob);
-
void BKE_dupli_cache_add_instance(struct DupliCache *dupcache, float obmat[4][4], struct DupliObjectData *data);
typedef struct DupliExtraData {
diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index feb7cff..09a9a24 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -83,35 +83,31 @@ void BKE_cache_archive_output_path(struct CacheLibrary *cachelib, char *result,
void BKE_cache_library_dag_recalc_tag(struct EvaluationContext *eval_ctx, struct Main *bmain);
-bool BKE_cache_read_dupli_cache(struct Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
- struct Group *dupgroup, struct DupliCache *dupcache, struct CacheLibrary *cachelib);
-bool BKE_cache_read_dupli_object(struct Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
- struct Object *ob, struct DupliObjectData *data, struct CacheLibrary *cachelib);
+bool BKE_cache_read_dupli_cache(struct CacheLibrary *cachelib, struct DupliCache *dupcache,
+ struct Scene *scene, struct Group *dupgroup, float frame, eCacheLibrary_EvalMode eval_mode);
+bool BKE_cache_read_dupli_object(struct CacheLibrary *cachelib, struct DupliObjectData *data,
+ struct Scene *scene, struct Object *ob, float frame, eCacheLibrary_EvalMode eval_mode);
+
+void BKE_cache_process_dupli_cache(struct CacheLibrary *cachelib, struct DupliCache *dupcache,
+ struct Scene *scene, struct Group *dupgroup, float frame_prev, float frame, eCacheLibrary_EvalMode eval_mode);
/* ========================================================================= */
typedef void (*CacheModifier_IDWalkFunc)(void *userdata, struct CacheLibrary *cachelib, struct CacheModifier *md, struct ID **id_ptr);
-typedef struct CacheBakeContext {
- struct CacheLibrary *cachelib;
- struct CacheModifier *md;
-
+typedef struct CacheProcessContext {
struct Main *bmain;
struct Scene *scene;
- int startframe, endframe;
+ struct CacheLibrary *cachelib;
struct Group *group;
-
- short *stop;
- short *do_update;
- float *progress;
-} CacheBakeContext;
+} CacheProcessContext;
typedef void (*CacheModifier_InitFunc)(struct CacheModifier *md);
typedef void (*CacheModifier_FreeFunc)(struct CacheModifier *md);
typedef void (*CacheModifier_CopyFunc)(struct CacheModifier *md, struct CacheModifier *target);
typedef void (*CacheModifier_ForeachIDLinkFunc)(struct CacheModifier *md, struct CacheLibrary *cachelib,
CacheModifier_IDWalkFunc walk, void *userData);
-typedef void (*CacheModifier_BakeFunc)(struct CacheModifier *md, struct CacheLibrary *cachelib, CacheBakeContext *ctx);
+typedef void (*CacheModifier_ProcessFunc)(struct CacheModifier *md, struct CacheProcessContext *ctx, struct DupliCache *dupcache, int frame, int frame_prev);
typedef struct CacheModifierTypeInfo {
/* The user visible name for this modifier */
@@ -142,7 +138,7 @@ typedef struct CacheModifierTypeInfo {
CacheModifier_ForeachIDLinkFunc foreachIDLink;
/* Process data and write results to the modifier's output archive */
- CacheModifier_BakeFunc bake;
+ CacheModifier_ProcessFunc process;
/********************* Optional functions *********************/
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 376e46c..518d284 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -334,10 +334,15 @@ static struct PTCReaderArchive *find_active_cache(Scene *scene, CacheLibrary *ca
char filename[FILE_MAX];
struct PTCReaderArchive *archive = NULL;
- if (cachelib->display_mode == CACHE_LIBRARY_DISPLAY_RESULT) {
- /* try using the output cache */
- BKE_cache_archive_output_path(cachelib, filename, sizeof(filename));
- archive = PTC_open_reader_archive(scene, filename);
+ 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) {
+ /* try using the output cache */
+ BKE_cache_archive_output_path(cachelib, filename, sizeof(filename));
+ archive = PTC_open_reader_archive(scene, filename);
+ }
}
if (!archive && cachelib->source_mode == CACHE_LIBRARY_SOURCE_CACHE) {
@@ -348,8 +353,8 @@ static struct PTCReaderArchive *find_active_cache(Scene *scene, CacheLibrary *ca
return archive;
}
-bool BKE_cache_read_dupli_cache(Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
- struct Group *dupgroup, struct DupliCache *dupcache, CacheLibrary *cachelib)
+bool BKE_cache_read_dupli_cache(CacheLibrary *cachelib, DupliCache *dupcache,
+ Scene *scene, Group *dupgroup, float frame, eCacheLibrary_EvalMode eval_mode)
{
struct PTCReaderArchive *archive;
struct PTCReader *reader;
@@ -368,6 +373,7 @@ bool BKE_cache_read_dupli_cache(Scene *scene, float frame, eCacheLibrary_EvalMod
if (!archive)
return false;
+ // TODO duplicache reader should only overwrite data that is not sequentially generated by modifiers (simulations) ...
reader = PTC_reader_duplicache(dupgroup->id.name, dupgroup, dupcache);
PTC_reader_init(reader, archive);
@@ -379,8 +385,8 @@ bool BKE_cache_read_dupli_cache(Scene *scene, float frame, eCacheLibrary_EvalMod
return (dupcache->result != CACHE_READ_SAMPLE_INVALID);
}
-bool BKE_cache_read_dupli_object(Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
- struct Object *ob, struct DupliObjectData *data, CacheLibrary *cachelib)
+bool BKE_cache_read_dupli_object(CacheLibrary *cachelib, DupliObjectData *data,
+ Scene *scene, Object *ob, float frame, eCacheLibrary_EvalMode eval_mode)
{
struct PTCReaderArchive *archive;
struct PTCReader *reader;
@@ -555,6 +561,25 @@ void BKE_cache_modifier_foreachIDLink(struct CacheLibrary *cachelib, struct Cach
mti->foreachIDLink(md, cachelib, walk, userdata);
}
+void BKE_cache_process_dupli_cache(CacheLibrary *cachelib, DupliCache *dupcache,
+ Scene *scene, Group *dupgroup, float frame_prev, float frame, eCacheLibrary_EvalMode UNUSED(eval_mode))
+{
+ CacheProcessContext ctx;
+ CacheModifier *md;
+
+ ctx.bmain = G.main;
+ ctx.scene = scene;
+ ctx.cachelib = cachelib;
+ ctx.group = dupgroup;
+
+ for (md = cachelib->modifiers.first; md; md = md->next) {
+ CacheModifierTypeInfo *mti = cache_modifier_type_get(md->type);
+
+ if (mti->process)
+ mti->process(md, &ctx, dupcache, frame, frame_prev);
+ }
+}
+
/* ------------------------------------------------------------------------- */
static void hairsim_init(HairSimCacheModifier *UNUSED(md))
@@ -565,12 +590,7 @@ static void hairsim_copy(HairSimCacheModifier *UNUSED(md), HairSimCacheModifier
{
}
-static void hairsim_bake_do(CacheBakeContext *ctx, short *stop, short *do_update, float *progress,
- struct PTCWriterArchive *archive, EvaluationContext *eval_ctx)
-{
-}
-
-static void hairsim_bake(HairSimCacheModifier *hsmd, CacheLibrary *cachelib, CacheBakeContext *ctx)
+static void hairsim_process(HairSimCacheModifier *hsmd, CacheProcessContext *ctx, DupliCache *dupcache, int frame, int frame_prev)
{
}
@@ -581,7 +601,7 @@ CacheModifierTypeInfo cacheModifierType_HairSimulation = {
/* copy */ (CacheModifier_CopyFunc)hairsim_copy,
/* foreachIDLink */ (CacheModifier_ForeachIDLinkFunc)NULL,
- /* bake */ (CacheModifier_BakeFunc)hairsim_bake,
+ /* process */ (CacheModifier_ProcessFunc)hairsim_process,
/* init */ (CacheModifier_InitFunc)hairsim_init,
/* free */ (CacheModifier_FreeFunc)NULL,
};
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index ee5e37c..ac3621d 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1421,7 +1421,7 @@ static void dupli_cache_clear(DupliCache *dupcache)
BLI_ghash_clear(dupcache->ghash, NULL, (GHashValFreeFP)dupli_object_data_free);
}
-static void dupli_cache_free(DupliCache *dupcache)
+void BKE_dupli_cache_free(DupliCache *dupcache)
{
dupli_cache_clear(dupcache);
@@ -1429,7 +1429,7 @@ static void dupli_cache_free(DupliCache *dupcache)
MEM_freeN(dupcache);
}
-static DupliCache *dupli_cache_new(void)
+DupliCache *BKE_dupli_cache_new(void)
{
DupliCache *dupcache = MEM_callocN(sizeof(DupliCache), "dupli object cache");
@@ -1480,11 +1480,14 @@ void BKE_object_dupli_cache_update(Scene *scene, Object *ob, EvaluationContext *
dupli_cache_clear(ob->dup_cache);
}
else {
- ob->dup_cache = dupli_cache_new();
+ ob->dup_cache = BKE_dupli_cache_new();
}
- /* TODO at this point we could apply animation offset */
- BKE_cache_read_dupli_cache(scene, frame, eval_mode, ob->dup_group, ob->dup_cache, ob->cache_library);
+ /* skip reading when the cachelib is baking, avoids unnecessary memory allocation */
+ if (!(ob->cache_library->flag & CACHE_LIBRARY_BAKING)) {
+ /* TODO at this point we could apply animation offset */
+ BKE_cache_read_dupli_cache(ob->cache_library, ob->d
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list