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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/alembic/intern/alembic_capi.cc')
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc120
1 files changed, 16 insertions, 104 deletions
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index d057cc341f6..3cc549350ea 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -22,19 +22,9 @@
#include "../ABC_alembic.h"
-#ifdef WITH_ALEMBIC_HDF5
-# include <Alembic/AbcCoreHDF5/All.h>
-#endif
-
-#include <Alembic/AbcCoreOgawa/All.h>
#include <Alembic/AbcMaterial/IMaterial.h>
-#include <fstream>
-
-#ifdef WIN32
-# include "utfconv.h"
-#endif
-
+#include "abc_archive.h"
#include "abc_camera.h"
#include "abc_curves.h"
#include "abc_hair.h"
@@ -83,13 +73,10 @@ extern "C" {
using Alembic::Abc::Int32ArraySamplePtr;
using Alembic::Abc::ObjectHeader;
-using Alembic::AbcGeom::ErrorHandler;
-using Alembic::AbcGeom::Exception;
using Alembic::AbcGeom::MetaData;
using Alembic::AbcGeom::P3fArraySamplePtr;
using Alembic::AbcGeom::kWrapExisting;
-using Alembic::AbcGeom::IArchive;
using Alembic::AbcGeom::ICamera;
using Alembic::AbcGeom::ICurves;
using Alembic::AbcGeom::ICurvesSchema;
@@ -115,95 +102,16 @@ using Alembic::AbcGeom::V3fArraySamplePtr;
using Alembic::AbcMaterial::IMaterial;
-static IArchive open_archive(const std::string &filename,
- const std::vector<std::istream *> &input_streams,
- bool &is_hdf5)
-{
- try {
- is_hdf5 = false;
- Alembic::AbcCoreOgawa::ReadArchive archive_reader(input_streams);
-
- return IArchive(archive_reader(filename),
- kWrapExisting,
- ErrorHandler::kThrowPolicy);
- }
- catch (const Exception &e) {
- std::cerr << e.what() << '\n';
-
-#ifdef WITH_ALEMBIC_HDF5
- try {
- is_hdf5 = true;
- Alembic::AbcCoreAbstract::ReadArraySampleCachePtr cache_ptr;
-
- return IArchive(Alembic::AbcCoreHDF5::ReadArchive(),
- filename.c_str(), ErrorHandler::kThrowPolicy,
- cache_ptr);
- }
- catch (const Exception &) {
- std::cerr << e.what() << '\n';
- return IArchive();
- }
-#else
- return IArchive();
-#endif
- }
-
- return IArchive();
-}
-
-/* Wrapper around an archive to be able to use streams so that unicode paths
- * work on Windows (T49112), and to make sure the input stream remains valid as
- * long as the archive is open. */
-class ArchiveWrapper {
- IArchive m_archive;
- std::ifstream m_infile;
- std::vector<std::istream *> m_streams;
-
-public:
- explicit ArchiveWrapper(const char *filename)
- {
-#ifdef WIN32
- UTF16_ENCODE(filename);
- std::wstring wstr(filename_16);
- m_infile.open(wstr.c_str(), std::ios::in | std::ios::binary);
- UTF16_UN_ENCODE(filename);
-#else
- m_infile.open(filename, std::ios::in | std::ios::binary);
-#endif
-
- m_streams.push_back(&m_infile);
-
- bool is_hdf5;
- m_archive = open_archive(filename, m_streams, is_hdf5);
-
- /* We can't open an HDF5 file from a stream, so close it. */
- if (is_hdf5) {
- m_infile.close();
- m_streams.clear();
- }
- }
-
- bool valid() const
- {
- return m_archive.valid();
- }
-
- IObject getTop()
- {
- return m_archive.getTop();
- }
-};
-
struct AbcArchiveHandle {
int unused;
};
-ABC_INLINE ArchiveWrapper *archive_from_handle(AbcArchiveHandle *handle)
+ABC_INLINE ArchiveReader *archive_from_handle(AbcArchiveHandle *handle)
{
- return reinterpret_cast<ArchiveWrapper *>(handle);
+ return reinterpret_cast<ArchiveReader *>(handle);
}
-ABC_INLINE AbcArchiveHandle *handle_from_archive(ArchiveWrapper *archive)
+ABC_INLINE AbcArchiveHandle *handle_from_archive(ArchiveReader *archive)
{
return reinterpret_cast<AbcArchiveHandle *>(archive);
}
@@ -301,7 +209,7 @@ static void gather_objects_paths(const IObject &object, ListBase *object_paths)
AbcArchiveHandle *ABC_create_handle(const char *filename, ListBase *object_paths)
{
- ArchiveWrapper *archive = new ArchiveWrapper(filename);
+ ArchiveReader *archive = new ArchiveReader(filename);
if (!archive->valid()) {
delete archive;
@@ -443,6 +351,9 @@ void ABC_export(
job->settings.export_ogawa = (params->compression_type == ABC_ARCHIVE_OGAWA);
job->settings.pack_uv = params->packuv;
job->settings.global_scale = params->global_scale;
+ job->settings.triangulate = params->triangulate;
+ job->settings.quad_method = params->quad_method;
+ job->settings.ngon_method = params->ngon_method;
if (job->settings.frame_start > job->settings.frame_end) {
std::swap(job->settings.frame_start, job->settings.frame_end);
@@ -599,10 +510,6 @@ struct ImportJobData {
ABC_INLINE bool is_mesh_and_strands(const IObject &object)
{
- if (object.getNumChildren() != 2) {
- return false;
- }
-
bool has_mesh = false;
bool has_curve = false;
@@ -624,6 +531,9 @@ ABC_INLINE bool is_mesh_and_strands(const IObject &object)
else if (ICurves::matches(md)) {
has_curve = true;
}
+ else if (IPoints::matches(md)) {
+ has_curve = true;
+ }
}
return has_mesh && has_curve;
@@ -637,7 +547,7 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
data->do_update = do_update;
data->progress = progress;
- ArchiveWrapper *archive = new ArchiveWrapper(data->filename);
+ ArchiveReader *archive = new ArchiveReader(data->filename);
if (!archive->valid()) {
delete archive;
@@ -865,7 +775,7 @@ void ABC_import(bContext *C, const char *filepath, float scale, bool is_sequence
void ABC_get_transform(AbcArchiveHandle *handle, Object *ob, const char *object_path, float r_mat[4][4], float time, float scale)
{
- ArchiveWrapper *archive = archive_from_handle(handle);
+ ArchiveReader *archive = archive_from_handle(handle);
if (!archive || !archive->valid()) {
return;
@@ -988,6 +898,7 @@ static DerivedMesh *read_mesh_sample(DerivedMesh *dm, const IObject &iobject, co
}
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
+ config.time = time;
bool do_normals = false;
read_mesh_sample(&settings, schema, sample_sel, config, do_normals);
@@ -1042,6 +953,7 @@ static DerivedMesh *read_subd_sample(DerivedMesh *dm, const IObject &iobject, co
/* Only read point data when streaming meshes, unless we need to create new ones. */
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
+ config.time = time;
read_subd_sample(&settings, schema, sample_sel, config);
if (new_dm) {
@@ -1141,7 +1053,7 @@ DerivedMesh *ABC_read_mesh(AbcArchiveHandle *handle,
const char **err_str,
int read_flag)
{
- ArchiveWrapper *archive = archive_from_handle(handle);
+ ArchiveReader *archive = archive_from_handle(handle);
if (!archive || !archive->valid()) {
*err_str = "Invalid archive!";