diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2015-03-20 17:40:51 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-03-20 17:40:51 +0300 |
commit | b01037b81d0969b977d136b59572d78c4015e6f4 (patch) | |
tree | 96bd8b7de0feb0a7724cfc802e2f26f977334ca3 | |
parent | e84b0d456f963faf1cb0c3c180fa851e2cb6b070 (diff) |
Take cache library items into account when baking caches.
This means we don't bluntly store all the data in a group, but use the
selection from the cache library. It also helps to avoid issues with
object visibility which is not yet stored in the cache.
-rw-r--r-- | source/blender/editors/io/io_cache_library.c | 2 | ||||
-rw-r--r-- | source/blender/pointcache/PTC_api.cpp | 4 | ||||
-rw-r--r-- | source/blender/pointcache/PTC_api.h | 2 | ||||
-rw-r--r-- | source/blender/pointcache/alembic/abc_group.cpp | 18 | ||||
-rw-r--r-- | source/blender/pointcache/alembic/abc_group.h | 4 | ||||
-rw-r--r-- | source/blender/pointcache/alembic/abc_object.cpp | 21 | ||||
-rw-r--r-- | source/blender/pointcache/alembic/abc_object.h | 4 | ||||
-rw-r--r-- | source/blender/pointcache/alembic/alembic.cpp | 6 | ||||
-rw-r--r-- | source/blender/pointcache/intern/ptc_types.h | 4 |
9 files changed, 46 insertions, 19 deletions
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c index 7ea59e17e7b..c1be8cb0ef4 100644 --- a/source/blender/editors/io/io_cache_library.c +++ b/source/blender/editors/io/io_cache_library.c @@ -268,7 +268,7 @@ static void cache_library_bake_do(CacheLibraryBakeJob *data, short *stop, short if ((*stop) || (G.is_break)) return; - data->writer = PTC_writer_dupligroup(data->group->id.name, &data->eval_ctx, scene, data->group); + data->writer = PTC_writer_dupligroup(data->group->id.name, &data->eval_ctx, scene, data->group, data->cachelib); PTC_writer_init(data->writer, data->archive); /* XXX where to get this from? */ diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp index 69fa21a48e1..30ac05af645 100644 --- a/source/blender/pointcache/PTC_api.cpp +++ b/source/blender/pointcache/PTC_api.cpp @@ -213,9 +213,9 @@ char *PTC_get_archive_info(PTCReaderArchive *_archive) } -PTCWriter *PTC_writer_dupligroup(const char *name, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Group *group) +PTCWriter *PTC_writer_dupligroup(const char *name, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Group *group, struct CacheLibrary *cachelib) { - return (PTCWriter *)PTC::Factory::alembic->create_writer_dupligroup(name, eval_ctx, scene, group); + return (PTCWriter *)PTC::Factory::alembic->create_writer_dupligroup(name, eval_ctx, scene, group, cachelib); } PTCReader *PTC_reader_duplicache(const char *name, struct Group *group, struct DupliCache *dupcache) diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h index 88542e01580..03063c08478 100644 --- a/source/blender/pointcache/PTC_api.h +++ b/source/blender/pointcache/PTC_api.h @@ -87,7 +87,7 @@ PTCReadSampleResult PTC_test_sample(struct PTCReader *reader, float frame); char *PTC_get_archive_info(struct PTCReaderArchive *archive); -struct PTCWriter *PTC_writer_dupligroup(const char *name, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Group *group); +struct PTCWriter *PTC_writer_dupligroup(const char *name, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Group *group, struct CacheLibrary *cachelib); struct PTCReader *PTC_reader_duplicache(const char *name, struct Group *group, struct DupliCache *dupcache); struct PTCReader *PTC_reader_duplicache_object(const char *name, struct Object *ob, struct DupliObjectData *data); diff --git a/source/blender/pointcache/alembic/abc_group.cpp b/source/blender/pointcache/alembic/abc_group.cpp index 8722f402054..1f137fb941a 100644 --- a/source/blender/pointcache/alembic/abc_group.cpp +++ b/source/blender/pointcache/alembic/abc_group.cpp @@ -34,6 +34,7 @@ extern "C" { #include "DNA_object_types.h" #include "BKE_anim.h" +#include "BKE_cache_library.h" #include "BKE_global.h" #include "BKE_group.h" #include "BKE_library.h" @@ -100,10 +101,11 @@ PTCReadSampleResult AbcGroupReader::read_sample(float frame) /* ========================================================================= */ -AbcDupligroupWriter::AbcDupligroupWriter(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group) : +AbcDupligroupWriter::AbcDupligroupWriter(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group, CacheLibrary *cachelib) : GroupWriter(group, name), m_eval_ctx(eval_ctx), - m_scene(scene) + m_scene(scene), + m_cachelib(cachelib) { } @@ -123,11 +125,21 @@ void AbcDupligroupWriter::init_abc() m_abc_group = abc_archive()->add_id_object<OObject>((ID *)m_group); } +static bool do_cache_type(CacheLibrary *cachelib, Object *ob, int type, int index=-1) +{ + CacheItem *item = BKE_cache_library_find_item(cachelib, ob, type, index); + return item && (item->flag & CACHE_ITEM_ENABLED); +} + void AbcDupligroupWriter::write_sample_object(Object *ob) { AbcWriter *ob_writer = find_id_writer((ID *)ob); if (!ob_writer) { - ob_writer = new AbcObjectWriter(ob->id.name, m_scene, ob); + bool do_mesh = do_cache_type(m_cachelib, ob, CACHE_TYPE_DERIVED_MESH); +// bool do_hair = do_cache_type(m_cachelib, ob, CACHE_TYPE_HAIR, ); // TODO + bool do_hair = false; + + ob_writer = new AbcObjectWriter(ob->id.name, m_scene, ob, do_mesh, do_hair); ob_writer->init(abc_archive()); m_id_writers.insert(IDWriterPair((ID *)ob, ob_writer)); } diff --git a/source/blender/pointcache/alembic/abc_group.h b/source/blender/pointcache/alembic/abc_group.h index 5818eba26ff..688f1c5e94e 100644 --- a/source/blender/pointcache/alembic/abc_group.h +++ b/source/blender/pointcache/alembic/abc_group.h @@ -25,6 +25,7 @@ #include "abc_schema.h" #include "abc_writer.h" +struct CacheLibrary; struct DupliCache; struct DupliObject; struct DupliObjectData; @@ -69,7 +70,7 @@ public: typedef std::map<ID*, AbcWriter*> IDWriterMap; typedef std::pair<ID*, AbcWriter*> IDWriterPair; - AbcDupligroupWriter(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group); + AbcDupligroupWriter(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group, CacheLibrary *cachelib); ~AbcDupligroupWriter(); void init_abc(); @@ -83,6 +84,7 @@ public: private: EvaluationContext *m_eval_ctx; Scene *m_scene; + CacheLibrary *m_cachelib; Abc::OObject m_abc_group; ObjectWriterList m_object_writers; diff --git a/source/blender/pointcache/alembic/abc_object.cpp b/source/blender/pointcache/alembic/abc_object.cpp index 3a36fb2a644..a188a135054 100644 --- a/source/blender/pointcache/alembic/abc_object.cpp +++ b/source/blender/pointcache/alembic/abc_object.cpp @@ -31,12 +31,15 @@ namespace PTC { using namespace Abc; using namespace AbcGeom; -AbcObjectWriter::AbcObjectWriter(const std::string &name, Scene *scene, Object *ob) : +AbcObjectWriter::AbcObjectWriter(const std::string &name, Scene *scene, Object *ob, bool do_mesh, bool do_hair) : ObjectWriter(ob, name), m_scene(scene), m_final_dm(NULL), - m_dm_writer("mesh", ob, &m_final_dm) + m_dm_writer("mesh", ob, &m_final_dm), + m_do_mesh(do_mesh), + m_do_hair(do_hair) { + m_do_mesh &= m_ob->type == OB_MESH; } void AbcObjectWriter::init_abc() @@ -46,9 +49,15 @@ void AbcObjectWriter::init_abc() m_abc_object = abc_archive()->add_id_object<OObject>((ID *)m_ob); - /* XXX not nice */ - m_dm_writer.init(abc_archive()); - m_dm_writer.init_abc(m_abc_object); + if (m_do_mesh) { + /* XXX not nice */ + m_dm_writer.init(abc_archive()); + m_dm_writer.init_abc(m_abc_object); + } + + if (m_do_hair) { + /* TODO */ + } } #if 0 @@ -67,7 +76,7 @@ void AbcObjectWriter::write_sample() if (!m_abc_object) return; - if (m_ob->type == OB_MESH) { + if (m_do_mesh) { if (abc_archive()->use_render()) { m_final_dm = mesh_create_derived_render(m_scene, m_ob, CD_MASK_BAREMESH); diff --git a/source/blender/pointcache/alembic/abc_object.h b/source/blender/pointcache/alembic/abc_object.h index 3624b523a16..3b65f46ab6e 100644 --- a/source/blender/pointcache/alembic/abc_object.h +++ b/source/blender/pointcache/alembic/abc_object.h @@ -39,7 +39,7 @@ namespace PTC { class AbcObjectWriter : public ObjectWriter, public AbcWriter { public: - AbcObjectWriter(const std::string &name, Scene *scene, Object *ob); + AbcObjectWriter(const std::string &name, Scene *scene, Object *ob, bool do_mesh, bool do_hair); void init_abc(); #if 0 @@ -54,6 +54,8 @@ private: Abc::OObject m_abc_object; AbcDerivedMeshWriter m_dm_writer; + + bool m_do_mesh, m_do_hair; }; class AbcObjectReader : public ObjectReader, public AbcReader { diff --git a/source/blender/pointcache/alembic/alembic.cpp b/source/blender/pointcache/alembic/alembic.cpp index 0acb9e33929..1781835cc16 100644 --- a/source/blender/pointcache/alembic/alembic.cpp +++ b/source/blender/pointcache/alembic/alembic.cpp @@ -49,7 +49,7 @@ class AbcFactory : public Factory { Writer *create_writer_object(const std::string &name, Scene *scene, Object *ob) { - return new AbcObjectWriter(name, scene, ob); + return new AbcObjectWriter(name, scene, ob, true, true); } Reader *create_reader_object(const std::string &name, Object *ob) @@ -152,9 +152,9 @@ class AbcFactory : public Factory { } - Writer *create_writer_dupligroup(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group) + Writer *create_writer_dupligroup(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group, CacheLibrary *cachelib) { - return new AbcDupligroupWriter(name, eval_ctx, scene, group); + return new AbcDupligroupWriter(name, eval_ctx, scene, group, cachelib); } Reader *create_reader_duplicache(const std::string &name, Group *group, DupliCache *dupcache) diff --git a/source/blender/pointcache/intern/ptc_types.h b/source/blender/pointcache/intern/ptc_types.h index 856b63f09ab..aa2d8d08cb4 100644 --- a/source/blender/pointcache/intern/ptc_types.h +++ b/source/blender/pointcache/intern/ptc_types.h @@ -30,6 +30,8 @@ extern "C" { #include "DNA_particle_types.h" } +struct CacheLibrary; + namespace PTC { class ClothWriter { @@ -226,7 +228,7 @@ struct Factory { virtual Writer *create_writer_cache_modifier_realtime(const std::string &name, Object *ob, CacheModifierData *cmd) = 0; virtual Writer *create_writer_cache_modifier_render(const std::string &name, Scene *scene, Object *ob, CacheModifierData *cmd) = 0; - virtual Writer *create_writer_dupligroup(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group) = 0; + virtual Writer *create_writer_dupligroup(const std::string &name, EvaluationContext *eval_ctx, Scene *scene, Group *group, CacheLibrary *cachelib) = 0; virtual Reader *create_reader_duplicache(const std::string &name, Group *group, DupliCache *dupcache) = 0; virtual Reader *create_reader_duplicache_object(const std::string &name, Object *ob, DupliObjectData *data) = 0; |