diff --git a/code/BlenderCustomData.cpp b/code/BlenderCustomData.cpp index 7f518b782..dd9032e50 100644 --- a/code/BlenderCustomData.cpp +++ b/code/BlenderCustomData.cpp @@ -4,8 +4,7 @@ #include namespace Assimp { - namespace Blender - { + namespace Blender { /** * @brief read/convert of Structure array to memory */ @@ -84,8 +83,7 @@ namespace Assimp { /** * @brief describes the size of data and the read function to be used for single CustomerData.type */ - struct CustomDataTypeDescription - { + struct CustomDataTypeDescription { PRead Read; ///< function to read one CustomData type element PAlloc Alloc; ///< function to allocate n type elements }; @@ -114,8 +112,7 @@ namespace Assimp { * other (like CD_ORCO, ...) uses arrays of rawtypes or even arrays of Structures * use a special readfunction for that cases */ - CustomDataTypeDescriptions customDataTypeDescriptions = - { + CustomDataTypeDescriptions customDataTypeDescriptions = { DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MVert), DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, @@ -165,21 +162,17 @@ namespace Assimp { }; - bool isValidCustomDataType(const int cdtype) - { + bool isValidCustomDataType(const int cdtype) { return cdtype >= 0 && cdtype < CD_NUMTYPES; } - bool readCustomData(std::shared_ptr &out, const CustomDataType cdtype, const size_t cnt, const FileDatabase &db) - { - if (!isValidCustomDataType(cdtype)) - { + bool readCustomData(std::shared_ptr &out, const CustomDataType cdtype, const size_t cnt, const FileDatabase &db) { + if (!isValidCustomDataType(cdtype)) { throw Error((Formatter::format(), "CustomData.type ", cdtype, " out of index")); } const CustomDataTypeDescription cdtd = customDataTypeDescriptions[cdtype]; - if (cdtd.Read && cdtd.Alloc) - { + if (cdtd.Read && cdtd.Alloc) { // allocate cnt elements and parse them from file out.reset(cdtd.Alloc(cnt)); return cdtd.Read(out.get(), cnt, db); @@ -187,23 +180,18 @@ namespace Assimp { return false; } - std::shared_ptr getCustomDataLayer(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) - { - for (auto it = customdata.layers.begin(); it != customdata.layers.end(); ++it) - { - if (it->get()->type == cdtype && name == it->get()->name) - { + std::shared_ptr getCustomDataLayer(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) { + for (auto it = customdata.layers.begin(); it != customdata.layers.end(); ++it) { + if (it->get()->type == cdtype && name == it->get()->name) { return *it; } } return nullptr; } - const void * getCustomDataLayerData(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) - { + const void * getCustomDataLayerData(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) { const std::shared_ptr pLayer = getCustomDataLayer(customdata, cdtype, name); - if (pLayer && pLayer->data) - { + if (pLayer && pLayer->data) { return pLayer->data.get(); } return nullptr; diff --git a/code/BlenderCustomData.h b/code/BlenderCustomData.h index b6f3641f1..782403bdd 100644 --- a/code/BlenderCustomData.h +++ b/code/BlenderCustomData.h @@ -5,11 +5,9 @@ #include namespace Assimp { - namespace Blender - { + namespace Blender { /* CustomData.type from Blender (2.79b) */ - enum CustomDataType - { + enum CustomDataType { CD_AUTO_FROM_NAME = -1, CD_MVERT = 0, #ifdef DNA_DEPRECATED diff --git a/code/BlenderDNA.inl b/code/BlenderDNA.inl index ae48a5896..5e54d04bd 100644 --- a/code/BlenderDNA.inl +++ b/code/BlenderDNA.inl @@ -310,10 +310,8 @@ void Structure :: ReadField(T& out, const char* name, const FileDatabase& db) co //-------------------------------------------------------------------------------- // field parsing for raw untyped data (like CustomDataLayer.data) template -bool Structure::ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const char* name, const FileDatabase& db) const -{ - if (!isValidCustomDataType(cdtype)) - { +bool Structure::ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const char* name, const FileDatabase& db) const { + if (!isValidCustomDataType(cdtype)) { ASSIMP_LOG_ERROR("given rawtype out of index"); return false; } @@ -322,13 +320,11 @@ bool Structure::ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const c Pointer ptrval; const Field* f; - try - { + try { f = &(*this)[name]; // sanity check, should never happen if the genblenddna script is right - if (!(f->flags & FieldFlag_Pointer)) - { + if (!(f->flags & FieldFlag_Pointer)) { throw Error((Formatter::format(), "Field `", name, "` of structure `", this->name, "` ought to be a pointer")); } @@ -338,15 +334,13 @@ bool Structure::ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const c // actually it is meaningless on which Structure the Convert is called // because the `Pointer` argument triggers a special implementation. } - catch (const Error& e) - { + catch (const Error& e) { _defaultInitializer()(out, e.what()); out.reset(); } bool readOk = true; - if (ptrval.val) - { + if (ptrval.val) { // get block for ptr const FileBlockHead* block = LocateFileBlockForAddress(ptrval, db); db.reader->SetCurrentPos(block->start + static_cast((ptrval.val - block->address.val))); @@ -366,21 +360,18 @@ bool Structure::ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const c //-------------------------------------------------------------------------------- template class TOUT, typename T> -bool Structure::ReadFieldPtrVector(vector>&out, const char* name, const FileDatabase& db) const -{ +bool Structure::ReadFieldPtrVector(vector>&out, const char* name, const FileDatabase& db) const { out.clear(); const StreamReaderAny::pos old = db.reader->GetCurrentPos(); Pointer ptrval; const Field* f; - try - { + try { f = &(*this)[name]; // sanity check, should never happen if the genblenddna script is right - if (!(f->flags & FieldFlag_Pointer)) - { + if (!(f->flags & FieldFlag_Pointer)) { throw Error((Formatter::format(), "Field `", name, "` of structure `", this->name, "` ought to be a pointer")); } @@ -390,16 +381,14 @@ bool Structure::ReadFieldPtrVector(vector>&out, const char* name, const // actually it is meaningless on which Structure the Convert is called // because the `Pointer` argument triggers a special implementation. } - catch (const Error& e) - { + catch (const Error& e) { _defaultInitializer()(out, e.what()); out.clear(); return false; } - if (ptrval.val) - { + if (ptrval.val) { // find the file block the pointer is pointing to const FileBlockHead* block = LocateFileBlockForAddress(ptrval, db); db.reader->SetCurrentPos(block->start + static_cast((ptrval.val - block->address.val))); @@ -407,8 +396,7 @@ bool Structure::ReadFieldPtrVector(vector>&out, const char* name, const // I really ought to improve StreamReader to work with 64 bit indices exclusively. const Structure& s = db.dna[f->type]; - for (size_t i = 0; i < block->num; ++i) - { + for (size_t i = 0; i < block->num; ++i) { TOUT p(new T); s.Convert(*p, db); out.push_back(p); diff --git a/code/BlenderLoader.cpp b/code/BlenderLoader.cpp index 2ecc62152..a463808cf 100644 --- a/code/BlenderLoader.cpp +++ b/code/BlenderLoader.cpp @@ -1031,20 +1031,16 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co typedef std::map MaterialTextureUVMappings; MaterialTextureUVMappings matTexUvMappings; const uint32_t maxMat = static_cast(mesh->mat.size()); - for (uint32_t m = 0; m < maxMat; ++m) - { + for (uint32_t m = 0; m < maxMat; ++m) { // get material by index const std::shared_ptr pMat = mesh->mat[m]; TextureUVMapping texuv; const uint32_t maxTex = sizeof(pMat->mtex) / sizeof(pMat->mtex[0]); - for (uint32_t t = 0; t < maxTex; ++t) - { - if (pMat->mtex[t] && pMat->mtex[t]->uvname[0]) - { + for (uint32_t t = 0; t < maxTex; ++t) { + if (pMat->mtex[t] && pMat->mtex[t]->uvname[0]) { // get the CustomData layer for given uvname and correct type const MLoopUV *pLoop = static_cast(getCustomDataLayerData(mesh->ldata, CD_MLOOPUV, pMat->mtex[t]->uvname)); - if (pLoop) - { + if (pLoop) { texuv.insert(std::make_pair(t, pLoop)); } } @@ -1114,8 +1110,7 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co } // only update written mNumVertices in last loop // TODO why must the numVertices be incremented here? - if (m == itMatTexUvMapping->second.size() - 1) - { + if (m == itMatTexUvMapping->second.size() - 1) { out->mNumVertices += j; } } diff --git a/code/BlenderScene.h b/code/BlenderScene.h index 129386094..6343b1c35 100644 --- a/code/BlenderScene.h +++ b/code/BlenderScene.h @@ -389,8 +389,7 @@ CustomDataLayer 104 char name 32 64 void *data 96 8 */ -struct CustomDataLayer : ElemBase -{ +struct CustomDataLayer : ElemBase { int type; int offset; int flag; @@ -430,8 +429,7 @@ CustomData 208 BLI_mempool *pool 192 8 CustomDataExternal *external 200 8 */ -struct CustomData : ElemBase -{ +struct CustomData : ElemBase { vector > layers; int typemap[42]; // CD_NUMTYPES int pad_i1;