Changeset View
Changeset View
Standalone View
Standalone View
source/blender/alembic/intern/abc_mesh.cc
| Show First 20 Lines • Show All 1,125 Lines • ▼ Show 20 Lines | bool AbcMeshReader::accepts_object_type( | ||||
| if (ob->type != OB_MESH) { | if (ob->type != OB_MESH) { | ||||
| *err_str = "Object type mismatch, Alembic object path points to PolyMesh."; | *err_str = "Object type mismatch, Alembic object path points to PolyMesh."; | ||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool AbcMeshReader::topology_changed(Mesh *existing_mesh, const ISampleSelector &sample_sel) | |||||
| { | |||||
| IPolyMeshSchema::Sample sample; | |||||
| try { | |||||
| sample = m_schema.getValue(sample_sel); | |||||
| } | |||||
| catch (Alembic::Util::Exception &ex) { | |||||
| printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n", | |||||
| m_iobject.getFullName().c_str(), | |||||
| m_schema.getName().c_str(), | |||||
| sample_sel.getRequestedTime(), | |||||
| ex.what()); | |||||
| // A similar error in read_mesh() would just return existing_mesh. | |||||
| return false; | |||||
| } | |||||
| const P3fArraySamplePtr &positions = sample.getPositions(); | |||||
| const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices(); | |||||
| const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts(); | |||||
| return positions->size() != existing_mesh->totvert || | |||||
| face_counts->size() != existing_mesh->totpoly || | |||||
| face_indices->size() != existing_mesh->totloop; | |||||
brecht: Strictly speaking you have to compare the `mpoly` array to be sure, you can have different… | |||||
| } | |||||
| Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh, | Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh, | ||||
| const ISampleSelector &sample_sel, | const ISampleSelector &sample_sel, | ||||
| int read_flag, | int read_flag, | ||||
| const char **err_str) | const char **err_str) | ||||
| { | { | ||||
| IPolyMeshSchema::Sample sample; | IPolyMeshSchema::Sample sample; | ||||
| try { | try { | ||||
| sample = m_schema.getValue(sample_sel); | sample = m_schema.getValue(sample_sel); | ||||
| Show All 15 Lines | Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh, | ||||
| const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts(); | const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts(); | ||||
| Mesh *new_mesh = NULL; | Mesh *new_mesh = NULL; | ||||
| /* Only read point data when streaming meshes, unless we need to create new ones. */ | /* Only read point data when streaming meshes, unless we need to create new ones. */ | ||||
| ImportSettings settings; | ImportSettings settings; | ||||
| settings.read_flag |= read_flag; | settings.read_flag |= read_flag; | ||||
| bool topology_changed = positions->size() != existing_mesh->totvert || | if (topology_changed(existing_mesh, sample_sel)) { | ||||
| face_counts->size() != existing_mesh->totpoly || | |||||
| face_indices->size() != existing_mesh->totloop; | |||||
| if (topology_changed) { | |||||
| new_mesh = BKE_mesh_new_nomain_from_template( | new_mesh = BKE_mesh_new_nomain_from_template( | ||||
| existing_mesh, positions->size(), 0, 0, face_indices->size(), face_counts->size()); | existing_mesh, positions->size(), 0, 0, face_indices->size(), face_counts->size()); | ||||
| settings.read_flag |= MOD_MESHSEQ_READ_ALL; | settings.read_flag |= MOD_MESHSEQ_READ_ALL; | ||||
| /* XXX fixme after 2.80; mesh->flag isn't copied by BKE_mesh_new_nomain_from_template() */ | /* XXX fixme after 2.80; mesh->flag isn't copied by BKE_mesh_new_nomain_from_template() */ | ||||
| new_mesh->flag |= (existing_mesh->flag & ME_AUTOSMOOTH); | new_mesh->flag |= (existing_mesh->flag & ME_AUTOSMOOTH); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 302 Lines • Show Last 20 Lines | |||||
Strictly speaking you have to compare the mpoly array to be sure, you can have different topology with same number of vertices and polygons.
But this is existing code so don't think it's a blocker for this fix.