Alembic import: port DerivedMesh → Mesh

This commit is contained in:
Sybren A. Stüvel 2018-06-06 11:06:11 +02:00
parent f447411a82
commit 5b0f96f97c
11 changed files with 162 additions and 173 deletions

View File

@ -29,8 +29,8 @@ extern "C" {
struct bContext;
struct CacheReader;
struct DerivedMesh;
struct ListBase;
struct Mesh;
struct Object;
struct Scene;
@ -114,12 +114,13 @@ void ABC_get_transform(struct CacheReader *reader,
float time,
float scale);
struct DerivedMesh *ABC_read_mesh(struct CacheReader *reader,
struct Object *ob,
struct DerivedMesh *dm,
const float time,
const char **err_str,
int flags);
/* Either modifies current_mesh in-place or constructs a new mesh. */
struct Mesh *ABC_read_mesh(struct CacheReader *reader,
struct Object *ob,
struct Mesh *current_mesh,
const float time,
const char **err_str,
int flags);
void CacheReader_incref(struct CacheReader *reader);
void CacheReader_free(struct CacheReader *reader);

View File

@ -37,8 +37,8 @@ extern "C" {
#include "BLI_listbase.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_curve.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "ED_curve.h"
@ -400,16 +400,16 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSele
}
}
/* NOTE: Alembic only stores data about control points, but the DerivedMesh
/* NOTE: Alembic only stores data about control points, but the Mesh
* passed from the cache modifier contains the displist, which has more data
* than the control points, so to avoid corrupting the displist we modify the
* object directly and create a new DerivedMesh from that. Also we might need to
* object directly and create a new Mesh from that. Also we might need to
* create new or delete existing NURBS in the curve.
*/
DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/,
const ISampleSelector &sample_sel,
int /*read_flag*/,
const char ** /*err_str*/)
Mesh *AbcCurveReader::read_mesh(Mesh * /*existing_mesh*/,
const ISampleSelector &sample_sel,
int /*read_flag*/,
const char ** /*err_str*/)
{
const ICurvesSchema::Sample sample = m_curves_schema.getValue(sample_sel);
@ -450,5 +450,5 @@ DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/,
}
}
return CDDM_from_curve(m_object);
return BKE_mesh_new_nomain_from_curve(m_object);
}

View File

@ -60,10 +60,10 @@ public:
const char **err_str) const;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
DerivedMesh *read_derivedmesh(DerivedMesh *dm,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
struct Mesh *read_mesh(struct Mesh *existing_mesh,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
};
/* ************************************************************************** */

View File

@ -873,11 +873,11 @@ ABC_INLINE void read_normals_params(AbcMeshData &abc_data,
}
}
static bool check_smooth_poly_flag(DerivedMesh *dm)
static bool check_smooth_poly_flag(Mesh *mesh)
{
MPoly *mpolys = dm->getPolyArray(dm);
MPoly *mpolys = mesh->mpoly;
for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i) {
for (int i = 0, e = mesh->totpoly; i < e; ++i) {
MPoly &poly = mpolys[i];
if ((poly.flag & ME_SMOOTH) != 0) {
@ -888,11 +888,11 @@ static bool check_smooth_poly_flag(DerivedMesh *dm)
return false;
}
static void set_smooth_poly_flag(DerivedMesh *dm)
static void set_smooth_poly_flag(Mesh *mesh)
{
MPoly *mpolys = dm->getPolyArray(dm);
MPoly *mpolys = mesh->mpoly;
for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i) {
for (int i = 0, e = mesh->totpoly; i < e; ++i) {
MPoly &poly = mpolys[i];
poly.flag |= ME_SMOOTH;
}
@ -900,7 +900,7 @@ static void set_smooth_poly_flag(DerivedMesh *dm)
static void *add_customdata_cb(void *user_data, const char *name, int data_type)
{
DerivedMesh *dm = static_cast<DerivedMesh *>(user_data);
Mesh *mesh = static_cast<Mesh *>(user_data);
CustomDataType cd_data_type = static_cast<CustomDataType>(data_type);
void *cd_ptr;
CustomData *loopdata;
@ -911,7 +911,7 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type)
return NULL;
}
loopdata = dm->getLoopDataLayout(dm);
loopdata = &mesh->ldata;
cd_ptr = CustomData_get_layer_named(loopdata, cd_data_type, name);
if (cd_ptr != NULL) {
/* layer already exists, so just return it. */
@ -920,7 +920,7 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type)
/* create a new layer, taking care to construct the hopefully-soon-to-be-removed
* CD_MTEXPOLY layer too, with the same name. */
numloops = dm->getNumLoops(dm);
numloops = mesh->totloop;
cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT,
NULL, numloops, name);
return cd_ptr;
@ -986,17 +986,19 @@ static void read_mesh_sample(const std::string & iobject_full_name,
}
}
CDStreamConfig get_config(DerivedMesh *dm)
CDStreamConfig get_config(Mesh *mesh)
{
CDStreamConfig config;
config.user_data = dm;
config.mvert = dm->getVertArray(dm);
config.mloop = dm->getLoopArray(dm);
config.mpoly = dm->getPolyArray(dm);
config.totloop = dm->getNumLoops(dm);
config.totpoly = dm->getNumPolys(dm);
config.loopdata = dm->getLoopDataLayout(dm);
BLI_assert(mesh->mvert);
config.user_data = mesh;
config.mvert = mesh->mvert;
config.mloop = mesh->mloop;
config.mpoly = mesh->mpoly;
config.totloop = mesh->totloop;
config.totpoly = mesh->totpoly;
config.loopdata = &mesh->ldata;
config.add_customdata_cb = add_customdata_cb;
return config;
@ -1027,14 +1029,8 @@ void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
m_object->data = mesh;
DerivedMesh *dm = CDDM_from_mesh(mesh);
DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
if (ndm != dm) {
dm->release(dm);
}
DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true);
Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
if (m_settings->validate_meshes) {
BKE_mesh_validate(mesh, false, false);
@ -1064,10 +1060,10 @@ bool AbcMeshReader::accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHe
return true;
}
DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
const ISampleSelector &sample_sel,
int read_flag,
const char **err_str)
Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
const ISampleSelector &sample_sel,
int read_flag,
const char **err_str)
{
const IPolyMeshSchema::Sample sample = m_schema.getValue(sample_sel);
@ -1075,22 +1071,22 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts();
DerivedMesh *new_dm = NULL;
Mesh *new_mesh = NULL;
/* Only read point data when streaming meshes, unless we need to create new ones. */
ImportSettings settings;
settings.read_flag |= read_flag;
bool topology_changed = positions->size() != dm->getNumVerts(dm) ||
face_counts->size() != dm->getNumPolys(dm) ||
face_indices->size() != dm->getNumLoops(dm);
bool topology_changed = positions->size() != existing_mesh->totvert ||
face_counts->size() != existing_mesh->totpoly ||
face_indices->size() != existing_mesh->totloop;
if (topology_changed) {
new_dm = CDDM_from_template(dm,
positions->size(),
0,
0,
face_indices->size(),
face_counts->size());
new_mesh = BKE_mesh_new_nomain_from_template(existing_mesh,
positions->size(),
0,
0,
face_indices->size(),
face_counts->size());
settings.read_flag |= MOD_MESHSEQ_READ_ALL;
}
@ -1098,8 +1094,8 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
/* If the face count changed (e.g. by triangulation), only read points.
* This prevents crash from T49813.
* TODO(kevin): perhaps find a better way to do this? */
if (face_counts->size() != dm->getNumPolys(dm) ||
face_indices->size() != dm->getNumLoops(dm))
if (face_counts->size() != existing_mesh->totpoly ||
face_indices->size() != existing_mesh->totloop)
{
settings.read_flag = MOD_MESHSEQ_READ_VERT;
@ -1110,40 +1106,39 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
}
}
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
config.time = sample_sel.getRequestedTime();
bool do_normals = false;
read_mesh_sample(m_iobject.getFullName(),
&settings, m_schema, sample_sel, config, do_normals);
if (new_dm) {
if (new_mesh) {
/* Check if we had ME_SMOOTH flag set to restore it. */
if (!do_normals && check_smooth_poly_flag(dm)) {
set_smooth_poly_flag(new_dm);
if (!do_normals && check_smooth_poly_flag(existing_mesh)) {
set_smooth_poly_flag(new_mesh);
}
CDDM_calc_normals(new_dm);
CDDM_calc_edges(new_dm);
BKE_mesh_calc_normals(new_mesh);
BKE_mesh_calc_edges(new_mesh, false, false);
/* Here we assume that the number of materials doesn't change, i.e. that
* the material slots that were created when the object was loaded from
* Alembic are still valid now. */
size_t num_polys = new_dm->getNumPolys(new_dm);
size_t num_polys = new_mesh->totpoly;
if (num_polys > 0) {
MPoly *dmpolies = new_dm->getPolyArray(new_dm);
std::map<std::string, int> mat_map;
assign_facesets_to_mpoly(sample_sel, 0, dmpolies, num_polys, mat_map);
assign_facesets_to_mpoly(sample_sel, 0, new_mesh->mpoly, num_polys, mat_map);
}
return new_dm;
return new_mesh;
}
if (do_normals) {
CDDM_calc_normals(dm);
BKE_mesh_calc_normals(existing_mesh);
}
return dm;
return existing_mesh;
}
void AbcMeshReader::assign_facesets_to_mpoly(
@ -1305,14 +1300,8 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
m_object->data = mesh;
DerivedMesh *dm = CDDM_from_mesh(mesh);
DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
if (ndm != dm) {
dm->release(dm);
}
DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true);
Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
const ISubDSchema::Sample sample = m_schema.getValue(sample_sel);
Int32ArraySamplePtr indices = sample.getCreaseIndices();
@ -1344,10 +1333,10 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
}
}
DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
const ISampleSelector &sample_sel,
int read_flag,
const char **err_str)
Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
const ISampleSelector &sample_sel,
int read_flag,
const char **err_str)
{
const ISubDSchema::Sample sample = m_schema.getValue(sample_sel);
@ -1355,18 +1344,18 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts();
DerivedMesh *new_dm = NULL;
Mesh *new_mesh = NULL;
ImportSettings settings;
settings.read_flag |= read_flag;
if (dm->getNumVerts(dm) != positions->size()) {
new_dm = CDDM_from_template(dm,
positions->size(),
0,
0,
face_indices->size(),
face_counts->size());
if (existing_mesh->totvert != positions->size()) {
new_mesh = BKE_mesh_new_nomain_from_template(existing_mesh,
positions->size(),
0,
0,
face_indices->size(),
face_counts->size());
settings.read_flag |= MOD_MESHSEQ_READ_ALL;
}
@ -1374,8 +1363,8 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
/* If the face count changed (e.g. by triangulation), only read points.
* This prevents crash from T49813.
* TODO(kevin): perhaps find a better way to do this? */
if (face_counts->size() != dm->getNumPolys(dm) ||
face_indices->size() != dm->getNumLoops(dm))
if (face_counts->size() != existing_mesh->totpoly ||
face_indices->size() != existing_mesh->totpoly)
{
settings.read_flag = MOD_MESHSEQ_READ_VERT;
@ -1387,22 +1376,22 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm,
}
/* Only read point data when streaming meshes, unless we need to create new ones. */
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
config.time = sample_sel.getRequestedTime();
read_subd_sample(m_iobject.getFullName(),
&settings, m_schema, sample_sel, config);
if (new_dm) {
if (new_mesh) {
/* Check if we had ME_SMOOTH flag set to restore it. */
if (check_smooth_poly_flag(dm)) {
set_smooth_poly_flag(new_dm);
if (check_smooth_poly_flag(existing_mesh)) {
set_smooth_poly_flag(new_mesh);
}
CDDM_calc_normals(new_dm);
CDDM_calc_edges(new_dm);
BKE_mesh_calc_normals(new_mesh);
BKE_mesh_calc_edges(new_mesh, false, false);
return new_dm;
return new_mesh;
}
return dm;
return existing_mesh;
}

View File

@ -106,10 +106,10 @@ public:
const char **err_str) const;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
DerivedMesh *read_derivedmesh(DerivedMesh *dm,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
struct Mesh *read_mesh(struct Mesh *existing_mesh,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
private:
void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start,
@ -136,10 +136,10 @@ public:
const Object *const ob,
const char **err_str) const;
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
DerivedMesh *read_derivedmesh(DerivedMesh *dm,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
struct Mesh *read_mesh(struct Mesh *existing_mesh,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
};
/* ************************************************************************** */
@ -148,6 +148,6 @@ void read_mverts(MVert *mverts,
const Alembic::AbcGeom::P3fArraySamplePtr &positions,
const Alembic::AbcGeom::N3fArraySamplePtr &normals);
CDStreamConfig get_config(DerivedMesh *dm);
CDStreamConfig get_config(struct Mesh *mesh);
#endif /* __ABC_MESH_H__ */

View File

@ -248,12 +248,12 @@ Imath::M44d get_matrix(const IXformSchema &schema, const float time)
return s0.getMatrix();
}
DerivedMesh *AbcObjectReader::read_derivedmesh(DerivedMesh *dm,
const Alembic::Abc::ISampleSelector &UNUSED(sample_sel),
int UNUSED(read_flag),
const char **UNUSED(err_str))
struct Mesh *AbcObjectReader::read_mesh(struct Mesh *existing_mesh,
const Alembic::Abc::ISampleSelector &UNUSED(sample_sel),
int UNUSED(read_flag),
const char **UNUSED(err_str))
{
return dm;
return existing_mesh;
}
void AbcObjectReader::setupObjectTransform(const float time)

View File

@ -124,7 +124,7 @@ static bool has_animations(Schema &schema, ImportSettings *settings)
/* ************************************************************************** */
struct DerivedMesh;
struct Mesh;
using Alembic::AbcCoreAbstract::chrono_t;
@ -180,10 +180,10 @@ public:
virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) = 0;
virtual DerivedMesh *read_derivedmesh(DerivedMesh *dm,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
virtual struct Mesh *read_mesh(struct Mesh *mesh,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
/** Reads the object matrix and sets up an object transform if animated. */
void setupObjectTransform(const float time);

View File

@ -173,15 +173,9 @@ bool AbcPointsReader::accepts_object_type(const Alembic::AbcCoreAbstract::Object
void AbcPointsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
{
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
Mesh *read_mesh = this->read_mesh(mesh, sample_sel, 0, NULL);
DerivedMesh *dm = CDDM_from_mesh(mesh);
DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, 0, NULL);
if (ndm != dm) {
dm->release(dm);
}
DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true);
BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
if (m_settings->validate_meshes) {
BKE_mesh_validate(mesh, false, false);
@ -218,23 +212,23 @@ void read_points_sample(const IPointsSchema &schema,
read_mverts(config.mvert, positions, vnormals);
}
DerivedMesh *AbcPointsReader::read_derivedmesh(DerivedMesh *dm,
const ISampleSelector &sample_sel,
int /*read_flag*/,
const char ** /*err_str*/)
struct Mesh *AbcPointsReader::read_mesh(struct Mesh *existing_mesh,
const ISampleSelector &sample_sel,
int /*read_flag*/,
const char ** /*err_str*/)
{
const IPointsSchema::Sample sample = m_schema.getValue(sample_sel);
const P3fArraySamplePtr &positions = sample.getPositions();
DerivedMesh *new_dm = NULL;
Mesh *new_mesh = NULL;
if (dm->getNumVerts(dm) != positions->size()) {
new_dm = CDDM_new(positions->size(), 0, 0, 0, 0);
if (existing_mesh->totvert != positions->size()) {
new_mesh = BKE_mesh_new_nomain(positions->size(), 0, 0, 0, 0);
}
CDStreamConfig config = get_config(new_dm ? new_dm : dm);
CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
read_points_sample(m_schema, sample_sel, config);
return new_dm ? new_dm : dm;
return new_mesh ? new_mesh : existing_mesh;
}

View File

@ -65,10 +65,10 @@ public:
void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel);
DerivedMesh *read_derivedmesh(DerivedMesh *dm,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
struct Mesh *read_mesh(struct Mesh *existing_mesh,
const Alembic::Abc::ISampleSelector &sample_sel,
int read_flag,
const char **err_str);
};
void read_points_sample(const Alembic::AbcGeom::IPointsSchema &schema,

View File

@ -960,12 +960,12 @@ void ABC_get_transform(CacheReader *reader, float r_mat[4][4], float time, float
/* ************************************************************************** */
DerivedMesh *ABC_read_mesh(CacheReader *reader,
Object *ob,
DerivedMesh *dm,
const float time,
const char **err_str,
int read_flag)
Mesh *ABC_read_mesh(CacheReader *reader,
Object *ob,
Mesh *existing_mesh,
const float time,
const char **err_str,
int read_flag)
{
AbcObjectReader *abc_reader = reinterpret_cast<AbcObjectReader *>(reader);
IObject iobject = abc_reader->iobject();
@ -984,7 +984,7 @@ DerivedMesh *ABC_read_mesh(CacheReader *reader,
/* kFloorIndex is used to be compatible with non-interpolating
* properties; they use the floor. */
ISampleSelector sample_sel(time, ISampleSelector::kFloorIndex);
return abc_reader->read_derivedmesh(dm, sample_sel, read_flag, err_str);
return abc_reader->read_mesh(existing_mesh, sample_sel, read_flag, err_str);
}
/* ************************************************************************** */

View File

@ -31,13 +31,13 @@
#include "DNA_scene_types.h"
#include "BKE_cachefile.h"
#include "BKE_DerivedMesh.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_scene.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
@ -87,19 +87,19 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
return (mcmd->cache_file == NULL) || (mcmd->object_path[0] == '\0');
}
static DerivedMesh *applyModifier(
static Mesh *applyModifier(
ModifierData *md, const ModifierEvalContext *ctx,
DerivedMesh *dm)
Mesh *mesh)
{
#ifdef WITH_ALEMBIC
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md;
/* Only used to check whether we are operating on org data or not... */
Mesh *me = (ctx->object->type == OB_MESH) ? ctx->object->data : NULL;
DerivedMesh *org_dm = dm;
Mesh *org_mesh = mesh;
Scene *scene = md->scene;
const float frame = BKE_scene_frame_get(scene);
Scene *scene = md->scene; /* for FPS macro */
const float frame = DEG_get_ctime(ctx->depsgraph);
const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
const char *err_str = NULL;
@ -114,39 +114,44 @@ static DerivedMesh *applyModifier(
mcmd->object_path);
if (!mcmd->reader) {
modifier_setError(md, "Could not create Alembic reader for file %s", cache_file->filepath);
return dm;
return mesh;
}
}
if (me != NULL) {
MVert *mvert = dm->getVertArray(dm);
MEdge *medge = dm->getEdgeArray(dm);
MPoly *mpoly = dm->getPolyArray(dm);
MVert *mvert = mesh->mvert;
MEdge *medge = mesh->medge;
MPoly *mpoly = mesh->mpoly;
if ((me->mvert == mvert) || (me->medge == medge) || (me->mpoly == mpoly)) {
/* We need to duplicate data here, otherwise we'll modify org mesh, see T51701. */
dm = CDDM_copy(dm);
BKE_id_copy_ex(NULL, &mesh->id, (ID **)&mesh,
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
LIB_ID_COPY_NO_PREVIEW,
false);
}
}
DerivedMesh *result = ABC_read_mesh(mcmd->reader,
ctx->object,
dm,
time,
&err_str,
mcmd->read_flag);
Mesh *result = ABC_read_mesh(mcmd->reader,
ctx->object,
mesh,
time,
&err_str,
mcmd->read_flag);
if (err_str) {
modifier_setError(md, "%s", err_str);
}
if (!ELEM(result, NULL, dm) && (dm != org_dm)) {
dm->release(dm);
dm = org_dm;
if (!ELEM(result, NULL, mesh) && (mesh != org_mesh)) {
BKE_id_free(NULL, mesh);
mesh = org_mesh;
}
return result ? result : dm;
return result ? result : mesh;
#else
return dm;
return mesh;
UNUSED_VARS(ctx, md);
#endif
}
@ -190,14 +195,14 @@ ModifierTypeInfo modifierType_MeshSequenceCache = {
/* deformMatrices_DM */ NULL,
/* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
/* applyModifier_DM */ applyModifier,
/* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
/* applyModifier */ NULL,
/* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,