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-19 22:58:21 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-03-26 16:13:40 +0300
commit1ad78297ca5092c808a37fd06c5731fcae77f6cc (patch)
tree632e61a6adb49ccc3af461ef8863b1c2c4146166 /source
parentb8c29051f97c7c0225fd07d8be87796ab2ca0d79 (diff)
Combined storage of render and realtime data in caches.
Caches now create 2 new roots below the main 'top' object of Alembic: root and root_render for realtime and render data respectively. This makes it easy to switch the whole archive to either of the modes during baking and for constructing dupli caches. Alternatively individual objects could store hires versions of their data. This would also be more efficient if the cache contains many simple objects which don't have 2 different variants. However, such design decisions are difficult to make at this point and the implementation can be modifier later.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/io/io_cache_library.c2
-rw-r--r--source/blender/pointcache/PTC_api.cpp12
-rw-r--r--source/blender/pointcache/PTC_api.h2
-rw-r--r--source/blender/pointcache/alembic/abc_group.cpp4
-rw-r--r--source/blender/pointcache/alembic/abc_particles.cpp2
-rw-r--r--source/blender/pointcache/alembic/abc_reader.cpp31
-rw-r--r--source/blender/pointcache/alembic/abc_reader.h11
-rw-r--r--source/blender/pointcache/alembic/abc_writer.cpp38
-rw-r--r--source/blender/pointcache/alembic/abc_writer.h23
-rw-r--r--source/blender/pointcache/intern/reader.h2
-rw-r--r--source/blender/pointcache/intern/writer.h2
11 files changed, 93 insertions, 36 deletions
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index cbb72f4b6d4..7ea59e17e7b 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -305,11 +305,13 @@ static void cache_library_bake_startjob(void *customdata, short *stop, short *do
if (data->cachelib->eval_mode & CACHE_LIBRARY_EVAL_REALTIME) {
data->eval_ctx.mode = DAG_EVAL_VIEWPORT;
+ PTC_writer_archive_use_render(data->archive, false);
cache_library_bake_do(data, stop, do_update, progress);
}
if (data->cachelib->eval_mode & CACHE_LIBRARY_EVAL_RENDER) {
data->eval_ctx.mode = DAG_EVAL_RENDER;
+ PTC_writer_archive_use_render(data->archive, true);
cache_library_bake_do(data, stop, do_update, progress);
}
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 647daebda87..2c18b774633 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -106,6 +106,12 @@ void PTC_close_writer_archive(PTCWriterArchive *_archive)
delete archive;
}
+void PTC_writer_archive_use_render(PTCWriterArchive *_archive, bool enable)
+{
+ PTC::WriterArchive *archive = (PTC::WriterArchive *)_archive;
+ archive->use_render(enable);
+}
+
PTCReaderArchive *PTC_open_reader_archive(Scene *scene, const char *path)
{
return (PTCReaderArchive *)PTC::Factory::alembic->open_reader_archive(scene, path, NULL);
@@ -117,6 +123,12 @@ void PTC_close_reader_archive(PTCReaderArchive *_archive)
delete archive;
}
+void PTC_reader_archive_use_render(PTCReaderArchive *_archive, bool enable)
+{
+ PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+ archive->use_render(enable);
+}
+
void PTC_writer_init(PTCWriter *_writer, PTCWriterArchive *_archive)
{
PTC::Writer *writer = (PTC::Writer *)_writer;
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index 48d4a94133a..fc260ace644 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -65,9 +65,11 @@ const char *PTC_get_default_archive_extension(void);
struct PTCWriterArchive *PTC_open_writer_archive(struct Scene *scene, const char *path);
void PTC_close_writer_archive(struct PTCWriterArchive *archive);
+void PTC_writer_archive_use_render(struct PTCWriterArchive *archive, bool enable);
struct PTCReaderArchive *PTC_open_reader_archive(struct Scene *scene, const char *path);
void PTC_close_reader_archive(struct PTCReaderArchive *archive);
+void PTC_reader_archive_use_render(struct PTCReaderArchive *archive, bool enable);
void PTC_writer_init(struct PTCWriter *writer, struct PTCWriterArchive *archive);
void PTC_writer_create_refs(struct PTCWriter *writer);
diff --git a/source/blender/pointcache/alembic/abc_group.cpp b/source/blender/pointcache/alembic/abc_group.cpp
index 406e4e9790f..4ab90636dea 100644
--- a/source/blender/pointcache/alembic/abc_group.cpp
+++ b/source/blender/pointcache/alembic/abc_group.cpp
@@ -73,7 +73,7 @@ void AbcGroupWriter::create_refs()
void AbcGroupWriter::write_sample()
{
- if (!abc_archive()->archive)
+ if (!m_abc_object)
return;
}
@@ -284,7 +284,7 @@ PTCReadSampleResult AbcDupligroupReader::read_sample(float frame)
{
ISampleSelector ss = abc_archive()->get_frame_sample_selector(frame);
- IObject abc_top = abc_archive()->archive.getTop();
+ IObject abc_top = abc_archive()->root();
IObject abc_group = abc_archive()->get_id_object((ID *)m_group);
if (!abc_group)
return PTC_READ_SAMPLE_INVALID;
diff --git a/source/blender/pointcache/alembic/abc_particles.cpp b/source/blender/pointcache/alembic/abc_particles.cpp
index b1dae9ff32a..105c5dcbb86 100644
--- a/source/blender/pointcache/alembic/abc_particles.cpp
+++ b/source/blender/pointcache/alembic/abc_particles.cpp
@@ -53,7 +53,7 @@ void AbcParticlesWriter::init_abc(OObject parent)
void AbcParticlesWriter::write_sample()
{
- if (!abc_archive()->archive)
+ if (!m_points)
return;
OPointsSchema &schema = m_points.getSchema();
diff --git a/source/blender/pointcache/alembic/abc_reader.cpp b/source/blender/pointcache/alembic/abc_reader.cpp
index 732440c4891..9f9f126b7a8 100644
--- a/source/blender/pointcache/alembic/abc_reader.cpp
+++ b/source/blender/pointcache/alembic/abc_reader.cpp
@@ -51,38 +51,49 @@ AbcReaderArchive *AbcReaderArchive::open(Scene *scene, const std::string &filena
AbcReaderArchive::AbcReaderArchive(Scene *scene, ErrorHandler *error_handler, IArchive abc_archive) :
FrameMapper(scene),
- archive(abc_archive),
- m_error_handler(error_handler)
+ m_error_handler(error_handler),
+ m_use_render(false),
+ m_abc_archive(abc_archive)
{
+ m_abc_root = IObject(m_abc_archive.getTop(), "root");
+ m_abc_root_render = IObject(m_abc_archive.getTop(), "root_render");
}
AbcReaderArchive::~AbcReaderArchive()
{
}
+Abc::IObject AbcReaderArchive::root()
+{
+ if (m_use_render)
+ return m_abc_root_render;
+ else
+ return m_abc_root;
+}
+
IObject AbcReaderArchive::get_id_object(ID *id)
{
- if (!archive)
+ if (!m_abc_archive)
return IObject();
- IObject root = archive.getTop();
+ IObject root = this->root();
return root.getChild(id->name);
}
bool AbcReaderArchive::has_id_object(ID *id)
{
- if (!archive)
+ if (!m_abc_archive)
return false;
- IObject root = archive.getTop();
+ IObject root = this->root();
return root.getChild(id->name).valid();
}
bool AbcReaderArchive::get_frame_range(int &start_frame, int &end_frame)
{
- if (archive) {
+ if (m_abc_archive) {
double start_time, end_time;
- GetArchiveStartAndEndTime(archive, start_time, end_time);
+ GetArchiveStartAndEndTime(m_abc_archive, start_time, end_time);
start_frame = (int)time_to_frame(start_time);
end_frame = (int)time_to_frame(end_time);
return true;
@@ -95,8 +106,8 @@ bool AbcReaderArchive::get_frame_range(int &start_frame, int &end_frame)
std::string AbcReaderArchive::get_info()
{
- if (archive)
- return abc_archive_info(archive);
+ if (m_abc_archive)
+ return abc_archive_info(m_abc_archive);
else
return "";
}
diff --git a/source/blender/pointcache/alembic/abc_reader.h b/source/blender/pointcache/alembic/abc_reader.h
index fd15f82ce49..6208a89796f 100644
--- a/source/blender/pointcache/alembic/abc_reader.h
+++ b/source/blender/pointcache/alembic/abc_reader.h
@@ -44,6 +44,10 @@ public:
static AbcReaderArchive *open(Scene *scene, const std::string &filename, ErrorHandler *error_handler);
+ void use_render(bool enable) { m_use_render = enable; }
+
+ Abc::IObject root();
+
Abc::IObject get_id_object(ID *id);
bool has_id_object(ID *id);
@@ -52,13 +56,16 @@ public:
std::string get_info();
- Abc::IArchive archive;
-
protected:
AbcReaderArchive(Scene *scene, ErrorHandler *error_handler, Abc::IArchive abc_archive);
protected:
ErrorHandler *m_error_handler;
+ bool m_use_render;
+
+ Abc::IArchive m_abc_archive;
+ Abc::IObject m_abc_root;
+ Abc::IObject m_abc_root_render;
};
class AbcReader : public Reader {
diff --git a/source/blender/pointcache/alembic/abc_writer.cpp b/source/blender/pointcache/alembic/abc_writer.cpp
index e5612b3eff7..6daba4421a7 100644
--- a/source/blender/pointcache/alembic/abc_writer.cpp
+++ b/source/blender/pointcache/alembic/abc_writer.cpp
@@ -61,13 +61,17 @@ AbcWriterArchive *AbcWriterArchive::open(Scene *scene, const std::string &filena
AbcWriterArchive::AbcWriterArchive(Scene *scene, ErrorHandler *error_handler, OArchive abc_archive) :
FrameMapper(scene),
- archive(abc_archive),
- m_error_handler(error_handler)
+ m_error_handler(error_handler),
+ m_use_render(false),
+ m_abc_archive(abc_archive)
{
- if (archive) {
+ if (m_abc_archive) {
chrono_t cycle_time = this->seconds_per_frame();
chrono_t start_time = this->start_time();
- m_frame_sampling = archive.addTimeSampling(TimeSampling(cycle_time, start_time));
+ m_frame_sampling = m_abc_archive.addTimeSampling(TimeSampling(cycle_time, start_time));
+
+ m_abc_root = OObject(m_abc_archive.getTop(), "root");
+ m_abc_root_render = OObject(m_abc_archive.getTop(), "root_render");
}
}
@@ -77,37 +81,45 @@ AbcWriterArchive::~AbcWriterArchive()
OObject AbcWriterArchive::get_id_object(ID *id)
{
- if (!archive)
+ if (!m_abc_archive)
return OObject();
- ObjectWriterPtr root = archive.getTop().getPtr();
+ ObjectWriterPtr root_ptr = root().getPtr();
- ObjectWriterPtr child = root->getChild(id->name);
+ ObjectWriterPtr child = root_ptr->getChild(id->name);
if (child)
return OObject(child, kWrapExisting);
else {
- const ObjectHeader *child_header = root->getChildHeader(id->name);
+ const ObjectHeader *child_header = root_ptr->getChildHeader(id->name);
if (child_header)
- return OObject(root->createChild(*child_header), kWrapExisting);
+ return OObject(root_ptr->createChild(*child_header), kWrapExisting);
else {
return OObject();
}
}
}
+OObject AbcWriterArchive::root()
+{
+ if (m_use_render)
+ return m_abc_root_render;
+ else
+ return m_abc_root;
+}
+
bool AbcWriterArchive::has_id_object(ID *id)
{
- if (!archive)
+ if (!m_abc_archive)
return false;
- ObjectWriterPtr root = archive.getTop().getPtr();
+ ObjectWriterPtr root_ptr = root().getPtr();
- return root->getChildHeader(id->name) != NULL;
+ return root_ptr->getChildHeader(id->name) != NULL;
}
TimeSamplingPtr AbcWriterArchive::frame_sampling()
{
- return archive.getTimeSampling(m_frame_sampling);
+ return m_abc_archive.getTimeSampling(m_frame_sampling);
}
} /* namespace PTC */
diff --git a/source/blender/pointcache/alembic/abc_writer.h b/source/blender/pointcache/alembic/abc_writer.h
index 4531d8dd27d..f8bdbf26e13 100644
--- a/source/blender/pointcache/alembic/abc_writer.h
+++ b/source/blender/pointcache/alembic/abc_writer.h
@@ -48,6 +48,10 @@ public:
static AbcWriterArchive *open(Scene *scene, const std::string &filename, ErrorHandler *error_handler);
+ void use_render(bool enable) { m_use_render = enable; }
+
+ Abc::OObject root();
+
Abc::OObject get_id_object(ID *id);
bool has_id_object(ID *id);
@@ -57,14 +61,17 @@ public:
uint32_t frame_sampling_index() const { return m_frame_sampling; }
Abc::TimeSamplingPtr frame_sampling();
- Abc::OArchive archive;
-
protected:
AbcWriterArchive(Scene *scene, ErrorHandler *error_handler, Abc::OArchive abc_archive);
protected:
ErrorHandler *m_error_handler;
uint32_t m_frame_sampling;
+ bool m_use_render;
+
+ Abc::OArchive m_abc_archive;
+ Abc::OObject m_abc_root;
+ Abc::OObject m_abc_root_render;
};
class AbcWriter : public Writer {
@@ -95,20 +102,20 @@ OObjectT AbcWriterArchive::add_id_object(ID *id)
{
using namespace Abc;
- if (!archive)
+ if (!m_abc_archive)
return OObjectT();
- ObjectWriterPtr root = archive.getTop().getPtr();
+ ObjectWriterPtr root_ptr = this->root().getPtr();
- ObjectWriterPtr child = root->getChild(id->name);
+ ObjectWriterPtr child = root_ptr->getChild(id->name);
if (child)
return OObjectT(child, kWrapExisting);
else {
- const ObjectHeader *child_header = root->getChildHeader(id->name);
+ const ObjectHeader *child_header = root_ptr->getChildHeader(id->name);
if (child_header)
- return OObjectT(root->createChild(*child_header), kWrapExisting);
+ return OObjectT(root_ptr->createChild(*child_header), kWrapExisting);
else {
- return OObjectT(root, id->name, frame_sampling_index());
+ return OObjectT(root_ptr, id->name, frame_sampling_index());
}
}
}
diff --git a/source/blender/pointcache/intern/reader.h b/source/blender/pointcache/intern/reader.h
index 0c6005b0785..41948878efe 100644
--- a/source/blender/pointcache/intern/reader.h
+++ b/source/blender/pointcache/intern/reader.h
@@ -33,6 +33,8 @@ class ReaderArchive {
public:
virtual ~ReaderArchive() {}
+ virtual void use_render(bool enable) = 0;
+
virtual bool get_frame_range(int &start_frame, int &end_frame) = 0;
virtual std::string get_info() = 0;
};
diff --git a/source/blender/pointcache/intern/writer.h b/source/blender/pointcache/intern/writer.h
index 65a472fd3c3..008c391bffc 100644
--- a/source/blender/pointcache/intern/writer.h
+++ b/source/blender/pointcache/intern/writer.h
@@ -30,6 +30,8 @@ namespace PTC {
class WriterArchive {
public:
virtual ~WriterArchive() {}
+
+ virtual void use_render(bool enable) = 0;
};
class Writer {