diff options
author | makowalski <makowalski@nvidia.com> | 2021-03-03 17:52:50 +0300 |
---|---|---|
committer | makowalski <makowalski@nvidia.com> | 2021-03-03 17:52:50 +0300 |
commit | 03d200aae7de953921bfe4ca6a6618193e531fbb (patch) | |
tree | 7dcd230488d5c801f1956528d9787d0287609e4a /source/blender | |
parent | 8b9275d4330d6721e46f02dc0e0f41c585f2807a (diff) |
Formatting fixes.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/BLI_mmap.c | 2 | ||||
-rw-r--r-- | source/blender/editors/io/io_usd.c | 20 | ||||
-rw-r--r-- | source/blender/editors/io/io_usd.h | 1 | ||||
-rw-r--r-- | source/blender/io/alembic/ABC_alembic.h | 4 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_capi.cc | 44 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_geom.cc | 2 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_instance.cc | 60 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_instance.h | 23 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_mesh.cc | 3 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_stage.cc | 13 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_stage.h | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_cachefile_types.h | 10 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_customdata_types.h | 12 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_tracking_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 4 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_meshsequencecache.c | 110 |
17 files changed, 159 insertions, 159 deletions
diff --git a/source/blender/blenlib/intern/BLI_mmap.c b/source/blender/blenlib/intern/BLI_mmap.c index f0b13183c68..210312456d9 100644 --- a/source/blender/blenlib/intern/BLI_mmap.c +++ b/source/blender/blenlib/intern/BLI_mmap.c @@ -29,8 +29,8 @@ #include <string.h> #ifndef WIN32 -# include <stdlib.h> # include <signal.h> +# include <stdlib.h> # include <sys/mman.h> // for mmap # include <unistd.h> // for read close #else diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c index a1f2d14b606..671e05e54b5 100644 --- a/source/blender/editors/io/io_usd.c +++ b/source/blender/editors/io/io_usd.c @@ -22,9 +22,9 @@ */ #ifdef WITH_USD -# include <string.h> -# include "DNA_space_types.h" # include "DNA_modifier_types.h" +# include "DNA_space_types.h" +# include <string.h> # include "BKE_context.h" # include "BKE_main.h" @@ -546,7 +546,7 @@ void WM_OT_usd_import(struct wmOperatorType *ot) "Import Instance Proxies", "If enabled, USD instances will be traversed with instance proxies, " "creating a unique Blender object for each instance. Note that " - "this option is ignored if the Instancing option is also checked" ); + "this option is ignored if the Instancing option is also checked"); RNA_def_boolean(ot->srna, "import_visible_only", @@ -584,15 +584,15 @@ void WM_OT_usd_import(struct wmOperatorType *ot) RNA_def_boolean(ot->srna, "import_proxy", true, "Proxy", "When checked, import proxy geometry"); RNA_def_boolean( - ot->srna, "import_render", true, "Render", "When checked, import final render geometry"); + ot->srna, "import_render", true, "Render", "When checked, import final render geometry"); RNA_def_boolean( - ot->srna, - "use_instancing", - false, - "Instancing", - "When checked, USD scenegraph instances are imported as collection instances in Blender. " - "(Note that point instancers are not yet handled by this option.)"); + ot->srna, + "use_instancing", + false, + "Instancing", + "When checked, USD scenegraph instances are imported as collection instances in Blender. " + "(Note that point instancers are not yet handled by this option.)"); } #endif /* WITH_USD */ diff --git a/source/blender/editors/io/io_usd.h b/source/blender/editors/io/io_usd.h index 24de748285c..7424cc0df32 100644 --- a/source/blender/editors/io/io_usd.h +++ b/source/blender/editors/io/io_usd.h @@ -28,4 +28,3 @@ struct wmOperatorType; void WM_OT_usd_export(struct wmOperatorType *ot); void WM_OT_usd_import(struct wmOperatorType *ot); - diff --git a/source/blender/io/alembic/ABC_alembic.h b/source/blender/io/alembic/ABC_alembic.h index 9432e54346f..6faf763f8a5 100644 --- a/source/blender/io/alembic/ABC_alembic.h +++ b/source/blender/io/alembic/ABC_alembic.h @@ -98,8 +98,8 @@ bool ABC_import(struct bContext *C, bool as_background_job); CacheArchiveHandle *ABC_create_handle(struct Main *bmain, - const char *filename, - struct ListBase *object_paths); + const char *filename, + struct ListBase *object_paths); void ABC_free_handle(CacheArchiveHandle *handle); diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc index dd4ca6e28da..7f8775c570b 100644 --- a/source/blender/io/usd/intern/usd_capi.cc +++ b/source/blender/io/usd/intern/usd_capi.cc @@ -135,11 +135,11 @@ static Collection *create_collection(Main *bmain, Collection *parent, const char } /* Set the instance collection on the given instance reader. -* The collection is assigned from the given map based on -* the prototype (maser) prim path. */ + * The collection is assigned from the given map based on + * the prototype (maser) prim path. */ static void set_instance_collection( - USDInstanceReader *instance_reader, - const std::map<pxr::SdfPath, Collection *> &proto_collection_map) + USDInstanceReader *instance_reader, + const std::map<pxr::SdfPath, Collection *> &proto_collection_map) { if (!instance_reader) { return; @@ -154,17 +154,16 @@ static void set_instance_collection( } else { std::cerr << "WARNING: Couldn't find prototype collection for " << instance_reader->prim_path() - << std::endl; + << std::endl; } } /* Create instance collections for the USD instance readers. */ -static void create_proto_collections( - Main *bmain, - ViewLayer *view_layer, - Collection *parent_collection, - const USDStageReader::ProtoReaderMap &proto_readers, - const std::vector<USDPrimReader *> &readers) +static void create_proto_collections(Main *bmain, + ViewLayer *view_layer, + Collection *parent_collection, + const USDStageReader::ProtoReaderMap &proto_readers, + const std::vector<USDPrimReader *> &readers) { Collection *all_protos_collection = create_collection(bmain, parent_collection, "prototypes"); @@ -179,10 +178,10 @@ static void create_proto_collections( // std::replace(proto_collection_name.begin(), proto_collection_name.end(), '/', '_'); Collection *proto_collection = create_collection( - bmain, all_protos_collection, proto_collection_name.c_str()); + bmain, all_protos_collection, proto_collection_name.c_str()); LayerCollection *proto_lc = BKE_layer_collection_first_from_scene_collection(view_layer, - proto_collection); + proto_collection); if (proto_lc) { proto_lc->flag |= LAYER_COLLECTION_HIDE; } @@ -211,11 +210,11 @@ static void create_proto_collections( for (const auto &pair : proto_readers) { std::map<pxr::SdfPath, Collection *>::const_iterator it = proto_collection_map.find( - pair.first); + pair.first); if (it == proto_collection_map.end()) { std::cerr << "WARNING: Couldn't find collection when adding objects for prototype " - << pair.first << std::endl; + << pair.first << std::endl; continue; } @@ -232,9 +231,9 @@ static void create_proto_collections( DEG_id_tag_update(&coll->id, ID_RECALC_COPY_ON_WRITE); DEG_id_tag_update_ex(bmain, - &ob->id, - ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION | - ID_RECALC_BASE_FLAGS); + &ob->id, + ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION | + ID_RECALC_BASE_FLAGS); } } } @@ -582,7 +581,7 @@ static void import_startjob(void *customdata, short *stop, short *do_update, flo } /* TODO(makowalski): Here and below, should we call - * readObjectData() with the actual time? */ + * readObjectData() with the actual time? */ reader->readObjectData(data->bmain, 0.0); Object *ob = reader->object(); @@ -678,7 +677,7 @@ static void import_endjob(void *customdata) if (data->archive && !data->archive->proto_readers().empty()) { create_proto_collections( - data->bmain, view_layer, lc->collection, data->archive->proto_readers(), data->readers); + data->bmain, view_layer, lc->collection, data->archive->proto_readers(), data->readers); } for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) { @@ -923,7 +922,10 @@ void USD_free_handle(USDStageHandle *handle) delete archive; } -void USD_get_transform(struct CacheReader *reader, float r_mat_world[4][4], float time, float scale) +void USD_get_transform(struct CacheReader *reader, + float r_mat_world[4][4], + float time, + float scale) { if (!reader) { return; diff --git a/source/blender/io/usd/intern/usd_reader_geom.cc b/source/blender/io/usd/intern/usd_reader_geom.cc index c23b7db338b..bd4394c9192 100644 --- a/source/blender/io/usd/intern/usd_reader_geom.cc +++ b/source/blender/io/usd/intern/usd_reader_geom.cc @@ -107,5 +107,5 @@ void USDGeomReader::addSubdivModifier() ModifierData *md = BKE_modifier_new(eModifierType_Subsurf); BLI_addtail(&m_object->modifiers, md); - //SubsurfModifierData *subd = reinterpret_cast<SubsurfModifierData *>(md); + // SubsurfModifierData *subd = reinterpret_cast<SubsurfModifierData *>(md); } diff --git a/source/blender/io/usd/intern/usd_reader_instance.cc b/source/blender/io/usd/intern/usd_reader_instance.cc index bb0ac3c1e2b..5ed32956898 100644 --- a/source/blender/io/usd/intern/usd_reader_instance.cc +++ b/source/blender/io/usd/intern/usd_reader_instance.cc @@ -26,40 +26,40 @@ namespace blender::io::usd { - USDInstanceReader::USDInstanceReader(pxr::UsdStageRefPtr stage, - const pxr::UsdPrim &object, - const USDImportParams &import_params, - ImportSettings &settings) - : USDXformReader(stage, object, import_params, settings) - { - } +USDInstanceReader::USDInstanceReader(pxr::UsdStageRefPtr stage, + const pxr::UsdPrim &object, + const USDImportParams &import_params, + ImportSettings &settings) + : USDXformReader(stage, object, import_params, settings) +{ +} - bool USDInstanceReader::valid() const - { - return m_prim.IsValid() && m_prim.IsInstance(); - } +bool USDInstanceReader::valid() const +{ + return m_prim.IsValid() && m_prim.IsInstance(); +} - void USDInstanceReader::createObject(Main *bmain, double motionSampleTime) - { - this->m_object = BKE_object_add_only_object(bmain, OB_EMPTY, m_name.c_str()); - this->m_object->data = nullptr; - this->m_object->transflag |= OB_DUPLICOLLECTION; - } +void USDInstanceReader::createObject(Main *bmain, double motionSampleTime) +{ + this->m_object = BKE_object_add_only_object(bmain, OB_EMPTY, m_name.c_str()); + this->m_object->data = nullptr; + this->m_object->transflag |= OB_DUPLICOLLECTION; +} - void USDInstanceReader::set_instance_collection(Collection *coll) - { - if (coll && this->m_object) { - this->m_object->instance_collection = coll; - } - } +void USDInstanceReader::set_instance_collection(Collection *coll) +{ + if (coll && this->m_object) { + this->m_object->instance_collection = coll; + } +} - pxr::SdfPath USDInstanceReader::proto_path() const - { - if (pxr::UsdPrim master = m_prim.GetMaster()) { - return master.GetPath(); - } +pxr::SdfPath USDInstanceReader::proto_path() const +{ + if (pxr::UsdPrim master = m_prim.GetMaster()) { + return master.GetPath(); + } - return pxr::SdfPath(); - } + return pxr::SdfPath(); +} } // namespace blender::io::usd diff --git a/source/blender/io/usd/intern/usd_reader_instance.h b/source/blender/io/usd/intern/usd_reader_instance.h index ce5c7ce6a83..034ccd8a8dd 100644 --- a/source/blender/io/usd/intern/usd_reader_instance.h +++ b/source/blender/io/usd/intern/usd_reader_instance.h @@ -28,22 +28,21 @@ namespace blender::io::usd { /* Wraps the UsdGeomXform schema. Creates a Blender Empty object. */ - class USDInstanceReader : public USDXformReader { +class USDInstanceReader : public USDXformReader { - public: - USDInstanceReader(pxr::UsdStageRefPtr stage, - const pxr::UsdPrim &object, - const USDImportParams &import_params, - ImportSettings &settings); + public: + USDInstanceReader(pxr::UsdStageRefPtr stage, + const pxr::UsdPrim &object, + const USDImportParams &import_params, + ImportSettings &settings); - bool valid() const override; + bool valid() const override; - void createObject(Main *bmain, double motionSampleTime) override; + void createObject(Main *bmain, double motionSampleTime) override; - void set_instance_collection(Collection *coll); + void set_instance_collection(Collection *coll); - pxr::SdfPath proto_path() const; - - }; + pxr::SdfPath proto_path() const; +}; } // namespace blender::io::usd diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index b57959ce6b2..1a4f9149316 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -569,7 +569,7 @@ void USDMeshReader::process_normals_uniform(Mesh *mesh) } float(*lnors)[3] = static_cast<float(*)[3]>( - MEM_malloc_arrayN(mesh->totloop, sizeof(float[3]), "USD::FaceNormals")); + MEM_malloc_arrayN(mesh->totloop, sizeof(float[3]), "USD::FaceNormals")); MPoly *mpoly = mesh->mpoly; @@ -589,7 +589,6 @@ void USDMeshReader::process_normals_uniform(Mesh *mesh) MEM_freeN(lnors); } - void USDMeshReader::read_mesh_sample(const std::string &iobject_full_name, ImportSettings *settings, Mesh *mesh, diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc b/source/blender/io/usd/intern/usd_reader_stage.cc index e27862e4cf3..5424c410a07 100644 --- a/source/blender/io/usd/intern/usd_reader_stage.cc +++ b/source/blender/io/usd/intern/usd_reader_stage.cc @@ -72,11 +72,9 @@ bool USDStageReader::valid() const return true; } - /* Returns true if the given prim should be excluded from the * traversal because it's invisible. */ -bool _prune_by_visibility(const pxr::UsdGeomImageable &imageable, - const USDImportParams ¶ms) +bool _prune_by_visibility(const pxr::UsdGeomImageable &imageable, const USDImportParams ¶ms) { if (imageable && params.import_visible_only) { if (pxr::UsdAttribute visibility_attr = imageable.GetVisibilityAttr()) { @@ -94,21 +92,19 @@ bool _prune_by_visibility(const pxr::UsdGeomImageable &imageable, return false; } - /* Returns true if the given prim should be excluded from the * traversal because it has a purpose which was not requested * by the user; e.g., the prim represents guide geometry and * the import_guide parameter is toggled off. */ -bool _prune_by_purpose(const pxr::UsdGeomImageable &imageable, - const USDImportParams ¶ms) +bool _prune_by_purpose(const pxr::UsdGeomImageable &imageable, const USDImportParams ¶ms) { if (imageable && !(params.import_guide && params.import_proxy && params.import_render)) { if (pxr::UsdAttribute purpose_attr = imageable.GetPurposeAttr()) { pxr::TfToken purpose; purpose_attr.Get(&purpose); if ((!params.import_guide && purpose == pxr::UsdGeomTokens->guide) || - (!params.import_proxy && purpose == pxr::UsdGeomTokens->proxy) || - (!params.import_render && purpose == pxr::UsdGeomTokens->render)) { + (!params.import_proxy && purpose == pxr::UsdGeomTokens->proxy) || + (!params.import_render && purpose == pxr::UsdGeomTokens->render)) { return true; } } @@ -255,4 +251,3 @@ void USDStageReader::clear_proto_readers(bool decref) } } // Namespace blender::io::usd - diff --git a/source/blender/io/usd/intern/usd_reader_stage.h b/source/blender/io/usd/intern/usd_reader_stage.h index a9502cee574..bd4a7fb85b9 100644 --- a/source/blender/io/usd/intern/usd_reader_stage.h +++ b/source/blender/io/usd/intern/usd_reader_stage.h @@ -95,7 +95,10 @@ class USDStageReader { void clear_proto_readers(bool decref); - const ProtoReaderMap &proto_readers() const { return m_proto_readers; }; + const ProtoReaderMap &proto_readers() const + { + return m_proto_readers; + }; }; }; // namespace blender::io::usd diff --git a/source/blender/makesdna/DNA_cachefile_types.h b/source/blender/makesdna/DNA_cachefile_types.h index 19c00d0d80a..e4209461a46 100644 --- a/source/blender/makesdna/DNA_cachefile_types.h +++ b/source/blender/makesdna/DNA_cachefile_types.h @@ -33,12 +33,12 @@ struct GSet; /* CacheFile::type */ enum { - #ifdef WITH_ALEMBIC +#ifdef WITH_ALEMBIC CACHEFILE_TYPE_ALEMBIC = 1, - #endif - #ifdef WITH_USD +#endif +#ifdef WITH_USD CACHEFILE_TYPE_USD = 2, - #endif +#endif CACHE_FILE_TYPE_INVALID = 0, }; @@ -98,7 +98,7 @@ typedef struct CacheFile { /** Animation flag. */ short flag; short draw_flag; /* UNUSED */ - + char type; char _pad[2]; diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 97689fc8d39..deb5f3393d5 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -157,13 +157,13 @@ typedef enum CustomDataType { CD_PROP_FLOAT2 = 49, CD_PROP_BOOL = 50, - - CD_VALUE_FLOAT = 51, - CD_VALUE_INT = 52, - CD_VALUE_F3 = 53, - CD_VALUE_I3 = 54, - CD_VELOCITY = 55, + CD_VALUE_FLOAT = 51, + CD_VALUE_INT = 52, + CD_VALUE_F3 = 53, + CD_VALUE_I3 = 54, + + CD_VELOCITY = 55, CD_NUMTYPES = 56, } CustomDataType; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index f665eea61df..88471fede76 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -2157,8 +2157,8 @@ enum { * the mesh topology changes, but this heuristic sometimes fails. In these cases, users can * disable interpolation with this flag. */ MOD_MESHSEQ_INTERPOLATE_VERTICES = (1 << 4), - MOD_MESHSEQ_READ_ATTR = (1 << 5), - MOD_MESHSEQ_READ_VELS = (1 << 6), + MOD_MESHSEQ_READ_ATTR = (1 << 5), + MOD_MESHSEQ_READ_VELS = (1 << 6), }; // USD Import re-added attr and vel. We are unsure as to why they were removed // They are necessary for full USD Import of data diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 908b06da2ce..c1e1ea2e185 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -522,7 +522,6 @@ typedef enum eTrackFrameMatch { TRACK_MATCH_PREVIOS_FRAME = 1, } eTrackFrameMatch; - /* MovieTrackingSettings->motion_flag */ enum { TRACKING_MOTION_TRIPOD = (1 << 0), diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 8a4c707e39c..e59a974e336 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -6135,8 +6135,8 @@ static void rna_def_modifier_meshseqcache(BlenderRNA *brna) {MOD_MESHSEQ_READ_POLY, "POLY", 0, "Faces", ""}, {MOD_MESHSEQ_READ_UV, "UV", 0, "UV", ""}, {MOD_MESHSEQ_READ_COLOR, "COLOR", 0, "Color", ""}, - {MOD_MESHSEQ_READ_ATTR, "ATTR", 0, "Attributes", ""}, - {MOD_MESHSEQ_READ_VELS, "VELS", 0, "Velocities", ""}, + {MOD_MESHSEQ_READ_ATTR, "ATTR", 0, "Attributes", ""}, + {MOD_MESHSEQ_READ_VELS, "VELS", 0, "Velocities", ""}, {0, NULL, 0, NULL, NULL}, }; // USD Import re-added these. We are unsure as to why they were removed diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c index e75e1f0278d..0ce7dfd2e28 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.c +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c @@ -141,67 +141,70 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * # ifdef WITH_ALEMBIC case CACHEFILE_TYPE_ALEMBIC: - if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) { - STRNCPY(mcmd->reader_object_path, mcmd->object_path); - BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path); - if (!mcmd->reader) { - BKE_modifier_set_error( - ctx->object, md, "Could not create Alembic reader for file %s", cache_file->filepath); - return mesh; - } - } + if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) { + STRNCPY(mcmd->reader_object_path, mcmd->object_path); + BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path); + if (!mcmd->reader) { + BKE_modifier_set_error(ctx->object, + md, + "Could not create Alembic reader for file %s", + cache_file->filepath); + return mesh; + } + } - /* If this invocation is for the ORCO mesh, and the mesh in Alembic hasn't changed topology, we - * must return the mesh as-is instead of deforming it. */ - if (ctx->flag & MOD_APPLY_ORCO && - !ABC_mesh_topology_changed(mcmd->reader, ctx->object, mesh, time, &err_str)) { - return mesh; - } + /* If this invocation is for the ORCO mesh, and the mesh in Alembic hasn't changed topology, + * we must return the mesh as-is instead of deforming it. */ + if (ctx->flag & MOD_APPLY_ORCO && + !ABC_mesh_topology_changed(mcmd->reader, ctx->object, mesh, time, &err_str)) { + return mesh; + } - if (me != NULL) { - MVert *mvert = mesh->mvert; - MEdge *medge = mesh->medge; - MPoly *mpoly = mesh->mpoly; - - /* TODO(sybren+bastien): possibly check relevant custom data layers (UV/color depending on - * flags) and duplicate those too. */ - if ((me->mvert == mvert) || (me->medge == medge) || (me->mpoly == mpoly)) { - /* We need to duplicate data here, otherwise we'll modify org mesh, see T51701. */ - mesh = (Mesh *)BKE_id_copy_ex(NULL, - &mesh->id, - NULL, - LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT | - LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW); - } - } + if (me != NULL) { + MVert *mvert = mesh->mvert; + MEdge *medge = mesh->medge; + MPoly *mpoly = mesh->mpoly; - Mesh *result = ABC_read_mesh(mcmd->reader, ctx->object, mesh, time, &err_str, mcmd->read_flag); + /* TODO(sybren+bastien): possibly check relevant custom data layers (UV/color depending on + * flags) and duplicate those too. */ + if ((me->mvert == mvert) || (me->medge == medge) || (me->mpoly == mpoly)) { + /* We need to duplicate data here, otherwise we'll modify org mesh, see T51701. */ + mesh = (Mesh *)BKE_id_copy_ex(NULL, + &mesh->id, + NULL, + LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT | + LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW); + } + } - mcmd->velocity_delta = 1.0f; - if (mcmd->cache_file->velocity_unit == CACHEFILE_VELOCITY_UNIT_SECOND) { - mcmd->velocity_delta /= FPS; - } + Mesh *result = ABC_read_mesh( + mcmd->reader, ctx->object, mesh, time, &err_str, mcmd->read_flag); - mcmd->last_lookup_time = time; + mcmd->velocity_delta = 1.0f; + if (mcmd->cache_file->velocity_unit == CACHEFILE_VELOCITY_UNIT_SECOND) { + mcmd->velocity_delta /= FPS; + } - if (result != NULL) { - mcmd->num_vertices = result->totvert; - } + mcmd->last_lookup_time = time; - if (err_str) { - BKE_modifier_set_error(ctx->object, md, "%s", err_str); - } + if (result != NULL) { + mcmd->num_vertices = result->totvert; + } - if (!ELEM(result, NULL, mesh) && (mesh != org_mesh)) { - BKE_id_free(NULL, mesh); - mesh = org_mesh; - } + if (err_str) { + BKE_modifier_set_error(ctx->object, md, "%s", err_str); + } - if (!result) { - result = mesh; - } - return result; - break; + if (!ELEM(result, NULL, mesh) && (mesh != org_mesh)) { + BKE_id_free(NULL, mesh); + mesh = org_mesh; + } + + if (!result) { + result = mesh; + } + return result; + break; # endif # ifdef WITH_USD case CACHEFILE_TYPE_USD: @@ -210,7 +213,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path); if (!mcmd->reader) { printf("Could not create usd reader\n"); - BKE_modifier_set_error(ctx->object, md, "Could not create USD reader for file %s", cache_file->filepath); + BKE_modifier_set_error( + ctx->object, md, "Could not create USD reader for file %s", cache_file->filepath); return mesh; } } |