From 4535e37fc65d57f7848d6b1bce08f400e52fa7c5 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 11 Nov 2023 21:13:47 +0100 Subject: [PATCH] Fix namespaces. --- code/AssetLib/3DS/3DSConverter.cpp | 10 +++-- code/AssetLib/3DS/3DSExporter.h | 6 +-- code/AssetLib/3DS/3DSLoader.cpp | 4 +- code/AssetLib/3MF/D3MFImporter.cpp | 4 -- code/AssetLib/3MF/D3MFImporter.h | 4 +- code/AssetLib/3MF/D3MFOpcPackage.cpp | 10 ++--- code/AssetLib/3MF/XmlSerializer.cpp | 6 +-- code/AssetLib/AC/ACLoader.cpp | 4 +- code/AssetLib/ASE/ASELoader.cpp | 4 +- code/AssetLib/ASE/ASEParser.cpp | 4 +- code/AssetLib/B3D/B3DImporter.cpp | 20 +++++----- code/AssetLib/BVH/BVHLoader.cpp | 48 +++++++++++------------ code/AssetLib/COB/COBLoader.cpp | 4 +- code/AssetLib/SMD/SMDLoader.cpp | 6 ++- code/AssetLib/STL/STLLoader.cpp | 41 +++++++++---------- code/AssetLib/Terragen/TerragenLoader.cpp | 10 ++--- code/AssetLib/Terragen/TerragenLoader.h | 2 +- code/AssetLib/Unreal/UnrealLoader.cpp | 14 ++++--- code/AssetLib/X/XFileImporter.cpp | 2 +- code/AssetLib/XGL/XGLLoader.cpp | 12 +++++- code/AssetLib/XGL/XGLLoader.h | 2 + include/assimp/vector3.h | 2 + 22 files changed, 121 insertions(+), 98 deletions(-) diff --git a/code/AssetLib/3DS/3DSConverter.cpp b/code/AssetLib/3DS/3DSConverter.cpp index b4f625b76..b99e9f798 100644 --- a/code/AssetLib/3DS/3DSConverter.cpp +++ b/code/AssetLib/3DS/3DSConverter.cpp @@ -52,9 +52,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace Assimp; +namespace Assimp { -static const unsigned int NotSet = 0xcdcdcdcd; +static constexpr unsigned int NotSet = 0xcdcdcdcd; // ------------------------------------------------------------------------------------------------ // Setup final material indices, generae a default material if necessary @@ -68,7 +68,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() { unsigned int idx(NotSet); for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) { std::string s = mScene->mMaterials[i].mName; - for (char & it : s) { + for (char &it : s) { it = static_cast(::tolower(static_cast(it))); } @@ -262,7 +262,7 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material &oldMat, unsigned int iWire = 1; mat.AddProperty((int *)&iWire, 1, AI_MATKEY_ENABLE_WIREFRAME); } - [[fallthrough]]; + [[fallthrough]]; case D3DS::Discreet3DS::Gouraud: eShading = aiShadingMode_Gouraud; @@ -805,4 +805,6 @@ void Discreet3DSImporter::ConvertScene(aiScene *pcOut) { } } +} // namespace Assimp + #endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER diff --git a/code/AssetLib/3DS/3DSExporter.h b/code/AssetLib/3DS/3DSExporter.h index 82ec3512f..66e91e10d 100644 --- a/code/AssetLib/3DS/3DSExporter.h +++ b/code/AssetLib/3DS/3DSExporter.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2022, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -57,8 +56,7 @@ struct aiNode; struct aiMaterial; struct aiMesh; -namespace Assimp -{ +namespace Assimp { // ------------------------------------------------------------------------------------------------ /** @@ -88,7 +86,7 @@ private: std::map trafos; - typedef std::multimap MeshesByNodeMap; + using MeshesByNodeMap = std::multimap; MeshesByNodeMap meshes; }; diff --git a/code/AssetLib/3DS/3DSLoader.cpp b/code/AssetLib/3DS/3DSLoader.cpp index bec77ff23..a2dcc32ac 100644 --- a/code/AssetLib/3DS/3DSLoader.cpp +++ b/code/AssetLib/3DS/3DSLoader.cpp @@ -54,7 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace Assimp; +namespace Assimp { static constexpr aiImporterDesc desc = { "Discreet 3DS Importer", @@ -1335,4 +1335,6 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D *out, bool acceptPercent) { (void)bGamma; } +} // namespace Assimp + #endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER diff --git a/code/AssetLib/3MF/D3MFImporter.cpp b/code/AssetLib/3MF/D3MFImporter.cpp index add33bb79..e8529064c 100644 --- a/code/AssetLib/3MF/D3MFImporter.cpp +++ b/code/AssetLib/3MF/D3MFImporter.cpp @@ -81,10 +81,6 @@ static constexpr aiImporterDesc desc = { "3mf" }; -D3MFImporter::D3MFImporter() = default; - -D3MFImporter::~D3MFImporter() = default; - bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool /*checkSig*/) const { if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) { return false; diff --git a/code/AssetLib/3MF/D3MFImporter.h b/code/AssetLib/3MF/D3MFImporter.h index a39ae790f..9ae68acb0 100644 --- a/code/AssetLib/3MF/D3MFImporter.h +++ b/code/AssetLib/3MF/D3MFImporter.h @@ -56,10 +56,10 @@ namespace Assimp { class D3MFImporter : public BaseImporter { public: /// @brief The default class constructor. - D3MFImporter(); + D3MFImporter() = default; /// @brief The class destructor. - ~D3MFImporter() override; + ~D3MFImporter() override = default; /// @brief Performs the data format detection. /// @param pFile The filename to check. diff --git a/code/AssetLib/3MF/D3MFOpcPackage.cpp b/code/AssetLib/3MF/D3MFOpcPackage.cpp index 934305d49..a173b1c6a 100644 --- a/code/AssetLib/3MF/D3MFOpcPackage.cpp +++ b/code/AssetLib/3MF/D3MFOpcPackage.cpp @@ -68,7 +68,7 @@ using OpcPackageRelationshipPtr = std::shared_ptr; class OpcPackageRelationshipReader { public: OpcPackageRelationshipReader(XmlParser &parser) : - m_relationShips() { + mRelations() { XmlNode root = parser.getRootNode(); ParseRootNode(root); } @@ -108,13 +108,13 @@ public: relPtr->type = currentNode.attribute(XmlTag::RELS_ATTRIB_TYPE).as_string(); relPtr->target = currentNode.attribute(XmlTag::RELS_ATTRIB_TARGET).as_string(); if (validateRels(relPtr)) { - m_relationShips.push_back(relPtr); + mRelations.push_back(relPtr); } } } } - std::vector m_relationShips; + std::vector mRelations; }; static bool IsEmbeddedTexture( const std::string &filename ) { @@ -217,11 +217,11 @@ std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream *stream) { OpcPackageRelationshipReader reader(xmlParser); - auto itr = std::find_if(reader.m_relationShips.begin(), reader.m_relationShips.end(), [](const OpcPackageRelationshipPtr &rel) { + auto itr = std::find_if(reader.mRelations.begin(), reader.mRelations.end(), [](const OpcPackageRelationshipPtr &rel) { return rel->type == XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE; }); - if (itr == reader.m_relationShips.end()) { + if (itr == reader.mRelations.end()) { throw DeadlyImportError("Cannot find ", XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE); } diff --git a/code/AssetLib/3MF/XmlSerializer.cpp b/code/AssetLib/3MF/XmlSerializer.cpp index c77111728..5fcdc0ccc 100644 --- a/code/AssetLib/3MF/XmlSerializer.cpp +++ b/code/AssetLib/3MF/XmlSerializer.cpp @@ -49,12 +49,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { namespace D3MF { -static const int IdNotSet = -1; +static constexpr int IdNotSet = -1; namespace { -static const size_t ColRGBA_Len = 9; -static const size_t ColRGB_Len = 7; +static constexpr size_t ColRGBA_Len = 9; +static constexpr size_t ColRGB_Len = 7; // format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1) bool validateColorString(const char *color) { diff --git a/code/AssetLib/AC/ACLoader.cpp b/code/AssetLib/AC/ACLoader.cpp index 4c6c48737..1bb77c441 100644 --- a/code/AssetLib/AC/ACLoader.cpp +++ b/code/AssetLib/AC/ACLoader.cpp @@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace Assimp; +namespace Assimp { static constexpr aiImporterDesc desc = { "AC3D Importer", @@ -862,4 +862,6 @@ void AC3DImporter::InternReadFile(const std::string &pFile, } } +} // namespace Assimp + #endif //!defined ASSIMP_BUILD_NO_AC_IMPORTER diff --git a/code/AssetLib/ASE/ASELoader.cpp b/code/AssetLib/ASE/ASELoader.cpp index db34b8ac4..94e213fb3 100644 --- a/code/AssetLib/ASE/ASELoader.cpp +++ b/code/AssetLib/ASE/ASELoader.cpp @@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // utilities #include -using namespace Assimp; +namespace Assimp { using namespace Assimp::ASE; static constexpr aiImporterDesc desc = { @@ -1262,6 +1262,8 @@ bool ASEImporter::GenerateNormals(ASE::Mesh &mesh) { return false; } +} + #endif // ASSIMP_BUILD_NO_3DS_IMPORTER #endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER diff --git a/code/AssetLib/ASE/ASEParser.cpp b/code/AssetLib/ASE/ASEParser.cpp index c43eb42ff..90f462598 100644 --- a/code/AssetLib/ASE/ASEParser.cpp +++ b/code/AssetLib/ASE/ASEParser.cpp @@ -53,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace Assimp; +namespace Assimp { using namespace Assimp::ASE; // ------------------------------------------------------------------------------------------------ @@ -1864,6 +1864,8 @@ void Parser::ParseLV4MeshLong(unsigned int &iOut) { iOut = strtoul10(filePtr, &filePtr); } +} + #endif // ASSIMP_BUILD_NO_3DS_IMPORTER #endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER diff --git a/code/AssetLib/B3D/B3DImporter.cpp b/code/AssetLib/B3D/B3DImporter.cpp index 6e0b8a85b..670f3de53 100644 --- a/code/AssetLib/B3D/B3DImporter.cpp +++ b/code/AssetLib/B3D/B3DImporter.cpp @@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -using namespace Assimp; +namespace Assimp { using namespace std; static constexpr aiImporterDesc desc = { @@ -79,9 +79,9 @@ static constexpr aiImporterDesc desc = { #pragma warning(disable : 4018) #endif -//#define DEBUG_B3D +// #define DEBUG_B3D -template +template void DeleteAllBarePointers(std::vector &x) { for (auto p : x) { delete p; @@ -329,7 +329,7 @@ void B3DImporter::ReadBRUS() { mat->AddProperty(&i, 1, AI_MATKEY_TWOSIDED); } - //Textures + // Textures for (int i = 0; i < n_texs; ++i) { int texid = ReadInt(); if (texid < -1 || (texid >= 0 && texid >= static_cast(_textures.size()))) { @@ -372,7 +372,7 @@ void B3DImporter::ReadVRTS() { } if (_vflags & 2) { - ReadQuat(); //skip v 4bytes... + ReadQuat(); // skip v 4bytes... } for (int j = 0; j < _tcsets; ++j) { @@ -704,22 +704,22 @@ void B3DImporter::ReadBB3D(aiScene *scene) { } } - //nodes + // nodes scene->mRootNode = _nodes[0]; _nodes.clear(); // node ownership now belongs to scene - //material + // material if (!_materials.size()) { _materials.emplace_back(std::unique_ptr(new aiMaterial)); } scene->mNumMaterials = static_cast(_materials.size()); scene->mMaterials = unique_to_array(_materials); - //meshes + // meshes scene->mNumMeshes = static_cast(_meshes.size()); scene->mMeshes = unique_to_array(_meshes); - //animations + // animations if (_animations.size() == 1 && _nodeAnims.size()) { aiAnimation *anim = _animations.back().get(); @@ -738,4 +738,6 @@ void B3DImporter::ReadBB3D(aiScene *scene) { flip.Execute(scene); } +} // namespace Assimp + #endif // !! ASSIMP_BUILD_NO_B3D_IMPORTER diff --git a/code/AssetLib/BVH/BVHLoader.cpp b/code/AssetLib/BVH/BVHLoader.cpp index 990eef8c7..4d2cfde15 100644 --- a/code/AssetLib/BVH/BVHLoader.cpp +++ b/code/AssetLib/BVH/BVHLoader.cpp @@ -55,7 +55,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace Assimp; +namespace Assimp { + using namespace Assimp::Formatter; static constexpr aiImporterDesc desc = { @@ -73,8 +74,8 @@ static constexpr aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Aborts the file reading with an exception -template -AI_WONT_RETURN void BVHLoader::ThrowException(T&&... args) { +template +AI_WONT_RETURN void BVHLoader::ThrowException(T &&...args) { throw DeadlyImportError(mFileName, ":", mLine, " - ", args...); } @@ -426,7 +427,7 @@ void BVHLoader::CreateAnimation(aiScene *pScene) { nodeAnim->mNodeName.Set(nodeName); std::map channelMap; - //Build map of channels + // Build map of channels for (unsigned int channel = 0; channel < node.mChannels.size(); ++channel) { channelMap[node.mChannels[channel]] = channel; } @@ -441,7 +442,7 @@ void BVHLoader::CreateAnimation(aiScene *pScene) { // Now compute all translations for (BVHLoader::ChannelType channel = Channel_PositionX; channel <= Channel_PositionZ; channel = (BVHLoader::ChannelType)(channel + 1)) { - //Find channel in node + // Find channel in node std::map::iterator mapIter = channelMap.find(channel); if (mapIter == channelMap.end()) @@ -485,30 +486,27 @@ void BVHLoader::CreateAnimation(aiScene *pScene) { for (unsigned int fr = 0; fr < mAnimNumFrames; ++fr) { aiMatrix4x4 temp; aiMatrix3x3 rotMatrix; - for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++ channelIdx) { - switch (node.mChannels[channelIdx]) { - case Channel_RotationX: - { + for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++channelIdx) { + switch (node.mChannels[channelIdx]) { + case Channel_RotationX: { const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; - aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp); - } - break; - case Channel_RotationY: - { + aiMatrix4x4::RotationX(angle, temp); + rotMatrix *= aiMatrix3x3(temp); + } break; + case Channel_RotationY: { const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; - aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp); - } - break; - case Channel_RotationZ: - { + aiMatrix4x4::RotationY(angle, temp); + rotMatrix *= aiMatrix3x3(temp); + } break; + case Channel_RotationZ: { const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; - aiMatrix4x4::RotationZ( angle, temp); rotMatrix *= aiMatrix3x3( temp); - } - break; + aiMatrix4x4::RotationZ(angle, temp); + rotMatrix *= aiMatrix3x3(temp); + } break; default: break; - } - } + } + } rotkey->mTime = double(fr); rotkey->mValue = aiQuaternion(rotMatrix); ++rotkey; @@ -525,4 +523,6 @@ void BVHLoader::CreateAnimation(aiScene *pScene) { } } +} // namespace Assimp + #endif // !! ASSIMP_BUILD_NO_BVH_IMPORTER diff --git a/code/AssetLib/COB/COBLoader.cpp b/code/AssetLib/COB/COBLoader.cpp index dc0199263..9a6e32f6d 100644 --- a/code/AssetLib/COB/COBLoader.cpp +++ b/code/AssetLib/COB/COBLoader.cpp @@ -61,7 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -using namespace Assimp; +namespace Assimp { using namespace Assimp::COB; using namespace Assimp::Formatter; @@ -1164,4 +1164,6 @@ void COBImporter::ReadUnit_Binary(COB::Scene &out, StreamReaderLE &reader, const ASSIMP_LOG_WARN("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist"); } +} + #endif // ASSIMP_BUILD_NO_COB_IMPORTER diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index 9af871cee..4b63dd9d0 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -64,9 +64,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define strtok_s strtok_r #endif -using namespace Assimp; +namespace Assimp { -static const aiImporterDesc desc = { +static constexpr aiImporterDesc desc = { "Valve SMD Importer", "", "", @@ -1077,4 +1077,6 @@ void SMDImporter::ParseVertex(const char* szCurrent, SMDI_PARSE_RETURN; } +} + #endif // !! ASSIMP_BUILD_NO_SMD_IMPORTER diff --git a/code/AssetLib/STL/STLLoader.cpp b/code/AssetLib/STL/STLLoader.cpp index 9c0fb4f59..269ee1467 100644 --- a/code/AssetLib/STL/STLLoader.cpp +++ b/code/AssetLib/STL/STLLoader.cpp @@ -52,11 +52,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace Assimp; +namespace Assimp { namespace { -static const aiImporterDesc desc = { +static constexpr aiImporterDesc desc = { "Stereolithography (STL) Importer", "", "", @@ -129,7 +129,7 @@ STLImporter::STLImporter() : mBuffer(), mFileSize(0), mScene() { - // empty + // empty } // ------------------------------------------------------------------------------------------------ @@ -250,13 +250,13 @@ void STLImporter::LoadASCIIFile(aiNode *root) { sz += 5; // skip the "solid" SkipSpaces(&sz); const char *szMe = sz; - while (!::IsSpaceOrNewLine(*sz)) { + while (!IsSpaceOrNewLine(*sz)) { sz++; } size_t temp = (size_t)(sz - szMe); // setup the name of the node - if ( temp ) { + if (temp) { if (temp >= MAXLEN) { throw DeadlyImportError("STL: Node name too long"); } @@ -303,7 +303,7 @@ void STLImporter::LoadASCIIFile(aiNode *root) { normalBuffer.emplace_back(vn); normalBuffer.emplace_back(vn); } - } else if (!strncmp(sz, "vertex", 6) && ::IsSpaceOrNewLine(*(sz + 6))) { // vertex 1.50000 1.50000 0.00000 + } else if (!strncmp(sz, "vertex", 6) && IsSpaceOrNewLine(*(sz + 6))) { // vertex 1.50000 1.50000 0.00000 if (faceVertexCounter >= 3) { ASSIMP_LOG_ERROR("STL: a facet with more than 3 vertices has been found"); ++sz; @@ -325,14 +325,14 @@ void STLImporter::LoadASCIIFile(aiNode *root) { } else if (!::strncmp(sz, "endsolid", 8)) { do { ++sz; - } while (!::IsLineEnd(*sz)); + } while (!IsLineEnd(*sz)); SkipSpacesAndLineEnd(&sz); // finished! break; } else { // else skip the whole identifier do { ++sz; - } while (!::IsSpaceOrNewLine(*sz)); + } while (!IsSpaceOrNewLine(*sz)); } } @@ -349,14 +349,14 @@ void STLImporter::LoadASCIIFile(aiNode *root) { throw DeadlyImportError("Normal buffer size does not match position buffer size"); } - // only process positionbuffer when filled, else exception when accessing with index operator + // only process position buffer when filled, else exception when accessing with index operator // see line 353: only warning is triggered - // see line 373(now): access to empty positionbuffer with index operator forced exception + // see line 373(now): access to empty position buffer with index operator forced exception if (!positionBuffer.empty()) { pMesh->mNumFaces = static_cast(positionBuffer.size() / 3); pMesh->mNumVertices = static_cast(positionBuffer.size()); pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; - for (size_t i=0; imNumVertices; ++i ) { + for (size_t i = 0; i < pMesh->mNumVertices; ++i) { pMesh->mVertices[i].x = positionBuffer[i].x; pMesh->mVertices[i].y = positionBuffer[i].y; pMesh->mVertices[i].z = positionBuffer[i].z; @@ -366,7 +366,7 @@ void STLImporter::LoadASCIIFile(aiNode *root) { // also only process normalBuffer when filled, else exception when accessing with index operator if (!normalBuffer.empty()) { pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; - for (size_t i=0; imNumVertices; ++i ) { + for (size_t i = 0; i < pMesh->mNumVertices; ++i) { pMesh->mNormals[i].x = normalBuffer[i].x; pMesh->mNormals[i].y = normalBuffer[i].y; pMesh->mNormals[i].z = normalBuffer[i].z; @@ -450,9 +450,8 @@ bool STLImporter::LoadBinaryFile() { aiVector3D *vp = pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; aiVector3D *vn = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; - typedef aiVector3t aiVector3F; - aiVector3F *theVec; - aiVector3F theVec3F; + aiVector3f *theVec; + aiVector3f theVec3F; for (unsigned int i = 0; i < pMesh->mNumFaces; ++i) { // NOTE: Blender sometimes writes empty normals ... this is not @@ -460,8 +459,8 @@ bool STLImporter::LoadBinaryFile() { // There's one normal for the face in the STL; use it three times // for vertex normals - theVec = (aiVector3F *)sz; - ::memcpy(&theVec3F, theVec, sizeof(aiVector3F)); + theVec = (aiVector3f *)sz; + ::memcpy(&theVec3F, theVec, sizeof(aiVector3f)); vn->x = theVec3F.x; vn->y = theVec3F.y; vn->z = theVec3F.z; @@ -471,7 +470,7 @@ bool STLImporter::LoadBinaryFile() { vn += 3; // vertex 1 - ::memcpy(&theVec3F, theVec, sizeof(aiVector3F)); + ::memcpy(&theVec3F, theVec, sizeof(aiVector3f)); vp->x = theVec3F.x; vp->y = theVec3F.y; vp->z = theVec3F.z; @@ -479,7 +478,7 @@ bool STLImporter::LoadBinaryFile() { ++vp; // vertex 2 - ::memcpy(&theVec3F, theVec, sizeof(aiVector3F)); + ::memcpy(&theVec3F, theVec, sizeof(aiVector3f)); vp->x = theVec3F.x; vp->y = theVec3F.y; vp->z = theVec3F.z; @@ -487,7 +486,7 @@ bool STLImporter::LoadBinaryFile() { ++vp; // vertex 3 - ::memcpy(&theVec3F, theVec, sizeof(aiVector3F)); + ::memcpy(&theVec3F, theVec, sizeof(aiVector3f)); vp->x = theVec3F.x; vp->y = theVec3F.y; vp->z = theVec3F.z; @@ -570,4 +569,6 @@ void STLImporter::pushMeshesToNode(std::vector &meshIndices, aiNod meshIndices.clear(); } +} // namespace Assimp + #endif // !! ASSIMP_BUILD_NO_STL_IMPORTER diff --git a/code/AssetLib/Terragen/TerragenLoader.cpp b/code/AssetLib/Terragen/TerragenLoader.cpp index 738ad8e27..b1870414c 100644 --- a/code/AssetLib/Terragen/TerragenLoader.cpp +++ b/code/AssetLib/Terragen/TerragenLoader.cpp @@ -51,9 +51,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace Assimp; +namespace Assimp { -static const aiImporterDesc desc = { +static constexpr aiImporterDesc desc = { "Terragen Heightmap Importer", "", "", @@ -73,10 +73,6 @@ TerragenImporter::TerragenImporter() : // empty } -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -TerragenImporter::~TerragenImporter() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { @@ -244,4 +240,6 @@ void TerragenImporter::InternReadFile(const std::string &pFile, pScene->mFlags |= AI_SCENE_FLAGS_TERRAIN; } +} // namespace Assimp + #endif // !! ASSIMP_BUILD_NO_TERRAGEN_IMPORTER diff --git a/code/AssetLib/Terragen/TerragenLoader.h b/code/AssetLib/Terragen/TerragenLoader.h index cb9ff9166..0c7b686e9 100644 --- a/code/AssetLib/Terragen/TerragenLoader.h +++ b/code/AssetLib/Terragen/TerragenLoader.h @@ -73,7 +73,7 @@ namespace Assimp { class TerragenImporter : public BaseImporter { public: TerragenImporter(); - ~TerragenImporter() override; + ~TerragenImporter() override = default; // ------------------------------------------------------------------- bool CanRead(const std::string &pFile, IOSystem *pIOHandler, diff --git a/code/AssetLib/Unreal/UnrealLoader.cpp b/code/AssetLib/Unreal/UnrealLoader.cpp index 7d7b4dc76..5f622da42 100644 --- a/code/AssetLib/Unreal/UnrealLoader.cpp +++ b/code/AssetLib/Unreal/UnrealLoader.cpp @@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace Assimp; +namespace Assimp { namespace Unreal { @@ -178,7 +178,7 @@ UnrealImporter::~UnrealImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool UnrealImporter::CanRead(const std::string & filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const { +bool UnrealImporter::CanRead(const std::string &filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const { return SimpleExtensionCheck(filename, "3d", "uc"); } @@ -336,12 +336,12 @@ void UnrealImporter::InternReadFile(const std::string &pFile, tempTextures.emplace_back(); std::pair &me = tempTextures.back(); for (; !IsLineEnd(*data); ++data) { - if (!::ASSIMP_strincmp(data, "NAME=", 5)) { + if (!ASSIMP_strincmp(data, "NAME=", 5)) { const char *d = data += 5; for (; !IsSpaceOrNewLine(*data); ++data) ; me.first = std::string(d, (size_t)(data - d)); - } else if (!::ASSIMP_strincmp(data, "FILE=", 5)) { + } else if (!ASSIMP_strincmp(data, "FILE=", 5)) { const char *d = data += 5; for (; !IsSpaceOrNewLine(*data); ++data) ; @@ -363,10 +363,10 @@ void UnrealImporter::InternReadFile(const std::string &pFile, std::pair &me = textures.back(); for (; !IsLineEnd(*data); ++data) { - if (!::ASSIMP_strincmp(data, "NUM=", 4)) { + if (!ASSIMP_strincmp(data, "NUM=", 4)) { data += 4; me.first = strtoul10(data, &data); - } else if (!::ASSIMP_strincmp(data, "TEXTURE=", 8)) { + } else if (!ASSIMP_strincmp(data, "TEXTURE=", 8)) { data += 8; const char *d = data; for (; !IsSpaceOrNewLine(*data); ++data) @@ -516,4 +516,6 @@ void UnrealImporter::InternReadFile(const std::string &pFile, flipper.Execute(pScene); } +} // namespace Assimp + #endif // !! ASSIMP_BUILD_NO_3D_IMPORTER diff --git a/code/AssetLib/X/XFileImporter.cpp b/code/AssetLib/X/XFileImporter.cpp index 271812859..00f44b34b 100644 --- a/code/AssetLib/X/XFileImporter.cpp +++ b/code/AssetLib/X/XFileImporter.cpp @@ -61,7 +61,7 @@ namespace Assimp { using namespace Assimp::Formatter; -static const aiImporterDesc desc = { +static constexpr aiImporterDesc desc = { "Direct3D XFile Importer", "", "", diff --git a/code/AssetLib/XGL/XGLLoader.cpp b/code/AssetLib/XGL/XGLLoader.cpp index 4c66d33b4..9efd5d628 100644 --- a/code/AssetLib/XGL/XGLLoader.cpp +++ b/code/AssetLib/XGL/XGLLoader.cpp @@ -78,7 +78,7 @@ XGLImporter::XGLImporter() : mXmlParser(nullptr), m_scene(nullptr) { // ------------------------------------------------------------------------------------------------ XGLImporter::~XGLImporter() { - delete mXmlParser; + clear(); } // ------------------------------------------------------------------------------------------------ @@ -94,7 +94,8 @@ const aiImporterDesc *XGLImporter::GetInfo() const { // ------------------------------------------------------------------------------------------------ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { - #ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL + clear(); +#ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL std::vector uncompressed; #endif @@ -165,6 +166,13 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy scope.dismiss(); } +// ------------------------------------------------------------------------------------------------ +void XGLImporter::clear() { + delete mXmlParser; + mXmlParser = nullptr; +} + + // ------------------------------------------------------------------------------------------------ void XGLImporter::ReadWorld(XmlNode &node, TempScope &scope) { for (XmlNode ¤tNode : node.children()) { diff --git a/code/AssetLib/XGL/XGLLoader.h b/code/AssetLib/XGL/XGLLoader.h index 2f0f14200..f620561d1 100644 --- a/code/AssetLib/XGL/XGLLoader.h +++ b/code/AssetLib/XGL/XGLLoader.h @@ -81,6 +81,8 @@ public: bool checkSig) const override; protected: + void clear(); + // ------------------------------------------------------------------- /** Return importer meta information. * See #BaseImporter::GetInfo for the details */ diff --git a/include/assimp/vector3.h b/include/assimp/vector3.h index 5d0962b6a..eb940e7f9 100644 --- a/include/assimp/vector3.h +++ b/include/assimp/vector3.h @@ -151,6 +151,8 @@ public: typedef aiVector3t aiVector3D; +typedef aiVector3t aiVector3f; +typedef aiVector3t aiVector3d; #else