diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2019-11-19 14:45:43 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2019-11-20 12:26:59 +0300 |
commit | 66bec8c25d0a93c160227e640b53f79cb71666cf (patch) | |
tree | 43eaa3997d57ed213ab0604bb611b99ffdf330d7 /source/blender/alembic/intern | |
parent | dfdbb237bb51543492aa3a9b2cbc6948cd36ef47 (diff) |
Alembic: clean up exporter metadata code
The Alembic file metadata object was created in one place, a bit of
metadata was added, then it was passed along with other properties which
were then injected as metadata in another function. This is now cleaned up.
No functional changes.
Diffstat (limited to 'source/blender/alembic/intern')
-rw-r--r-- | source/blender/alembic/intern/abc_archive.cc | 27 | ||||
-rw-r--r-- | source/blender/alembic/intern/abc_archive.h | 9 | ||||
-rw-r--r-- | source/blender/alembic/intern/abc_exporter.cc | 18 |
3 files changed, 26 insertions, 28 deletions
diff --git a/source/blender/alembic/intern/abc_archive.cc b/source/blender/alembic/intern/abc_archive.cc index bb527c23b20..15e7efad1c3 100644 --- a/source/blender/alembic/intern/abc_archive.cc +++ b/source/blender/alembic/intern/abc_archive.cc @@ -28,6 +28,8 @@ extern "C" { #include "BLI_path_util.h" #include "BLI_string.h" + +#include "DNA_scene_types.h" } #ifdef WIN32 @@ -147,12 +149,15 @@ Alembic::Abc::IObject ArchiveReader::getTop() static OArchive create_archive(std::ostream *ostream, const std::string &filename, const std::string &scene_name, - Alembic::Abc::MetaData &md, + double scene_fps, bool ogawa) { - md.set(Alembic::Abc::kApplicationNameKey, "Blender"); - md.set(Alembic::Abc::kUserDescriptionKey, scene_name); - md.set("blender_version", versionstr); + Alembic::Abc::MetaData abc_metadata; + + abc_metadata.set(Alembic::Abc::kApplicationNameKey, "Blender"); + abc_metadata.set(Alembic::Abc::kUserDescriptionKey, scene_name); + abc_metadata.set("blender_version", versionstr); + abc_metadata.set("FramesPerTimeUnit", std::to_string(scene_fps)); time_t raw_time; time(&raw_time); @@ -169,13 +174,13 @@ static OArchive create_archive(std::ostream *ostream, buffer[buffer_len - 1] = '\0'; } - md.set(Alembic::Abc::kDateWrittenKey, buffer); + abc_metadata.set(Alembic::Abc::kDateWrittenKey, buffer); ErrorHandler::Policy policy = ErrorHandler::kThrowPolicy; #ifdef WITH_ALEMBIC_HDF5 if (!ogawa) { - return OArchive(Alembic::AbcCoreHDF5::WriteArchive(), filename, md, policy); + return OArchive(Alembic::AbcCoreHDF5::WriteArchive(), filename, abc_metadata, policy); } #else static_cast<void>(filename); @@ -183,13 +188,13 @@ static OArchive create_archive(std::ostream *ostream, #endif Alembic::AbcCoreOgawa::WriteArchive archive_writer; - return OArchive(archive_writer(ostream, md), kWrapExisting, policy); + return OArchive(archive_writer(ostream, abc_metadata), kWrapExisting, policy); } ArchiveWriter::ArchiveWriter(const char *filename, - const char *scene, - bool do_ogawa, - Alembic::Abc::MetaData &md) + const std::string &abc_scene_name, + const Scene *scene, + bool do_ogawa) { /* Use stream to support unicode character paths on Windows. */ if (do_ogawa) { @@ -203,7 +208,7 @@ ArchiveWriter::ArchiveWriter(const char *filename, #endif } - m_archive = create_archive(&m_outfile, filename, scene, md, do_ogawa); + m_archive = create_archive(&m_outfile, filename, abc_scene_name, FPS, do_ogawa); } OArchive &ArchiveWriter::archive() diff --git a/source/blender/alembic/intern/abc_archive.h b/source/blender/alembic/intern/abc_archive.h index a64de742cdf..32b1b72747f 100644 --- a/source/blender/alembic/intern/abc_archive.h +++ b/source/blender/alembic/intern/abc_archive.h @@ -35,6 +35,7 @@ #include <fstream> struct Main; +struct Scene; /* Wrappers around input and output archives. The goal is to be able to use * streams so that unicode paths work on Windows (T49112), and to make sure that @@ -68,10 +69,10 @@ class ArchiveWriter { Alembic::Abc::OArchive m_archive; public: - explicit ArchiveWriter(const char *filename, - const char *scene, - bool do_ogawa, - Alembic::Abc::MetaData &md); + ArchiveWriter(const char *filename, + const std::string &abc_scene_name, + const Scene *scene, + bool do_ogawa); Alembic::Abc::OArchive &archive(); }; diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc index a69178281ff..cbc8fd769b7 100644 --- a/source/blender/alembic/intern/abc_exporter.cc +++ b/source/blender/alembic/intern/abc_exporter.cc @@ -266,27 +266,19 @@ void AbcExporter::getFrameSet(unsigned int nr_of_samples, std::set<double> &fram void AbcExporter::operator()(short *do_update, float *progress, bool *was_canceled) { - std::string scene_name; + std::string abc_scene_name; if (m_bmain->name[0] != '\0') { char scene_file_name[FILE_MAX]; BLI_strncpy(scene_file_name, m_bmain->name, FILE_MAX); - scene_name = scene_file_name; + abc_scene_name = scene_file_name; } else { - scene_name = "untitled"; + abc_scene_name = "untitled"; } - Scene *scene = m_settings.scene; - const double fps = FPS; - char buf[16]; - snprintf(buf, 15, "%f", fps); - const std::string str_fps = buf; - - Alembic::AbcCoreAbstract::MetaData md; - md.set("FramesPerTimeUnit", str_fps); - - m_writer = new ArchiveWriter(m_filename, scene_name.c_str(), m_settings.export_ogawa, md); + m_writer = new ArchiveWriter( + m_filename, abc_scene_name, m_settings.scene, m_settings.export_ogawa); /* Create time samplings for transforms and shapes. */ |