diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-04-26 17:50:29 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-04-26 17:50:29 +0300 |
commit | dc27d31a2100c3272d0dbf293b24131eacaab962 (patch) | |
tree | 1b5349dbad4e520e0c6b874795ed63211f5f95ed /source/blender/alembic | |
parent | 7517cf6bbb989286f9a65b70ceae2e277e111e58 (diff) | |
parent | 6ed15c5a41130b55cb57a43a8a9470a91d38c3d5 (diff) |
Merge commit 'master@6ed15c5a41130b55cb57a43a8a9470a91d38c3d5' into blender2.8
# Conflicts:
# source/blender/alembic/intern/abc_exporter.cc
Diffstat (limited to 'source/blender/alembic')
-rw-r--r-- | source/blender/alembic/ABC_alembic.h | 1 | ||||
-rw-r--r-- | source/blender/alembic/intern/abc_archive.cc | 2 | ||||
-rw-r--r-- | source/blender/alembic/intern/abc_exporter.cc | 7 | ||||
-rw-r--r-- | source/blender/alembic/intern/abc_hair.cc | 30 | ||||
-rw-r--r-- | source/blender/alembic/intern/abc_object.cc | 1 | ||||
-rw-r--r-- | source/blender/alembic/intern/alembic_capi.cc | 32 |
6 files changed, 55 insertions, 18 deletions
diff --git a/source/blender/alembic/ABC_alembic.h b/source/blender/alembic/ABC_alembic.h index 6b698e5ec66..6228ae60c56 100644 --- a/source/blender/alembic/ABC_alembic.h +++ b/source/blender/alembic/ABC_alembic.h @@ -121,6 +121,7 @@ struct DerivedMesh *ABC_read_mesh(struct CacheReader *reader, const char **err_str, int flags); +void CacheReader_incref(struct CacheReader *reader); void CacheReader_free(struct CacheReader *reader); struct CacheReader *CacheReader_open_alembic_object(struct AbcArchiveHandle *handle, diff --git a/source/blender/alembic/intern/abc_archive.cc b/source/blender/alembic/intern/abc_archive.cc index cdbda0ace69..194a8224c62 100644 --- a/source/blender/alembic/intern/abc_archive.cc +++ b/source/blender/alembic/intern/abc_archive.cc @@ -68,7 +68,7 @@ static IArchive open_archive(const std::string &filename, #else /* Inspect the file to see whether it's really a HDF5 file. */ char header[4]; /* char(0x89) + "HDF" */ - std::ifstream the_file(filename, std::ios::in | std::ios::binary); + std::ifstream the_file(filename.c_str(), std::ios::in | std::ios::binary); if (!the_file) { std::cerr << "Unable to open " << filename << std::endl; } diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc index dd65613e223..2c2d0b598e9 100644 --- a/source/blender/alembic/intern/abc_exporter.cc +++ b/source/blender/alembic/intern/abc_exporter.cc @@ -108,7 +108,7 @@ static bool object_is_smoke_sim(Object *ob) return false; } -static bool object_is_shape(Object *ob) +static bool object_type_is_exportable(Object *ob) { switch (ob->type) { case OB_MESH: @@ -117,6 +117,7 @@ static bool object_is_shape(Object *ob) } return true; + case OB_EMPTY: case OB_CURVE: case OB_SURF: case OB_CAMERA: @@ -387,7 +388,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O return; } - if (object_is_shape(ob)) { + if (object_type_is_exportable(ob)) { createTransformWriter(ob, parent, dupliObParent); } @@ -557,7 +558,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent) { Object *ob = ob_base->object; - if (!object_is_shape(ob)) { + if (!object_type_is_exportable(ob)) { return; } diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc index 9a974273a46..2d42c532c9b 100644 --- a/source/blender/alembic/intern/abc_hair.cc +++ b/source/blender/alembic/intern/abc_hair.cc @@ -241,7 +241,6 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm, invert_m4_m4_safe(inv_mat, m_object->obmat); MTFace *mtface = static_cast<MTFace *>(CustomData_get_layer(&dm->faceData, CD_MTFACE)); - MFace *mface = dm->getTessFaceArray(dm); MVert *mverts = dm->getVertArray(dm); ParticleCacheKey **cache = m_psys->childcache; @@ -253,12 +252,25 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm, path = cache[p]; if (part->from == PART_FROM_FACE) { - const int num = pc->num; + if (part->childtype == PART_CHILD_PARTICLES || !mtface) { + /* Face index is unknown for these particles, so just take info + * from the parent. */ + uv_values.push_back(uv_values[pc->parent]); + norm_values.push_back(norm_values[pc->parent]); + } + else { + const int num = pc->num; + if (num < 0) { + ABC_LOG(m_settings.logger) + << "Warning, child particle of hair system " << m_psys->name + << " has unknown face index of geometry of "<< (m_object->id.name + 2) + << ", skipping child hair." << std::endl; + continue; + } - MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, num, CD_MFACE)); - MTFace *tface = mtface + num; + MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, num, CD_MFACE)); + MTFace *tface = mtface + num; - if (mface && mtface) { float r_uv[2], tmpnor[3], mapfw[4], vec[3]; psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv); @@ -270,6 +282,14 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm, norm_values.push_back(Imath::V3f(tmpnor[0], tmpnor[2], -tmpnor[1])); } } + else { + ABC_LOG(m_settings.logger) + << "Unknown particle type " << part->from + << " for child hair of system " << m_psys->name + << std::endl; + uv_values.push_back(uv_values[pc->parent]); + norm_values.push_back(norm_values[pc->parent]); + } int steps = path->segments + 1; hvertices.push_back(steps); diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc index ce0f9225228..28a4d185014 100644 --- a/source/blender/alembic/intern/abc_object.cc +++ b/source/blender/alembic/intern/abc_object.cc @@ -369,4 +369,5 @@ void AbcObjectReader::incref() void AbcObjectReader::decref() { --m_refcount; + BLI_assert(m_refcount >= 0); } diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index 4aa4b8d548f..61b18c7112f 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -175,7 +175,7 @@ static bool gather_objects_paths(const IObject &object, ListBase *object_paths) void *abc_path_void = MEM_callocN(sizeof(AlembicObjectPath), "AlembicObjectPath"); AlembicObjectPath *abc_path = static_cast<AlembicObjectPath *>(abc_path_void); - BLI_strncpy(abc_path->path, object.getFullName().c_str(), PATH_MAX); + BLI_strncpy(abc_path->path, object.getFullName().c_str(), sizeof(abc_path->path)); BLI_addtail(object_paths, abc_path); } @@ -377,6 +377,7 @@ bool ABC_export( std::swap(job->settings.frame_start, job->settings.frame_end); } + bool export_ok = false; if (as_background_job) { wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), @@ -399,9 +400,12 @@ bool ABC_export( export_startjob(job, &stop, &do_update, &progress); export_endjob(job); + export_ok = job->export_ok; + + MEM_freeN(job); } - return job->export_ok; + return export_ok; } /* ********************** Import file ********************** */ @@ -560,7 +564,7 @@ static std::pair<bool, AbcObjectReader *> visit_object( AlembicObjectPath *abc_path = static_cast<AlembicObjectPath *>( MEM_callocN(sizeof(AlembicObjectPath), "AlembicObjectPath")); - BLI_strncpy(abc_path->path, full_name.c_str(), PATH_MAX); + BLI_strncpy(abc_path->path, full_name.c_str(), sizeof(abc_path->path)); BLI_addtail(&settings.cache_file->object_paths, abc_path); /* We can now assign this reader as parent for our children. */ @@ -903,13 +907,14 @@ bool ABC_import(bContext *C, const char *filepath, float scale, bool is_sequence G.is_break = false; + bool import_ok = false; if (as_background_job) { wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), - CTX_wm_window(C), - job->scene, - "Alembic Import", - WM_JOB_PROGRESS, - WM_JOB_TYPE_ALEMBIC); + CTX_wm_window(C), + job->scene, + "Alembic Import", + WM_JOB_PROGRESS, + WM_JOB_TYPE_ALEMBIC); /* setup job */ WM_jobs_customdata_set(wm_job, job, import_freejob); @@ -925,9 +930,12 @@ bool ABC_import(bContext *C, const char *filepath, float scale, bool is_sequence import_startjob(job, &stop, &do_update, &progress); import_endjob(job); + import_ok = job->import_ok; + + import_freejob(job); } - return job->import_ok; + return import_ok; } /* ************************************************************************** */ @@ -1012,6 +1020,12 @@ void CacheReader_free(CacheReader *reader) } } +void CacheReader_incref(CacheReader *reader) +{ + AbcObjectReader *abc_reader = reinterpret_cast<AbcObjectReader *>(reader); + abc_reader->incref(); +} + CacheReader *CacheReader_open_alembic_object(AbcArchiveHandle *handle, CacheReader *reader, Object *object, const char *object_path) { if (object_path[0] == '\0') { |