From bad76fd0f18e82279c2812773727fec884b22c9b Mon Sep 17 00:00:00 2001 From: Krishty Date: Mon, 16 Jan 2023 08:18:36 +0100 Subject: [PATCH 1/9] Replace Variables With Literals --- code/AssetLib/Blender/BlenderBMesh.cpp | 3 +-- code/AssetLib/Blender/BlenderLoader.cpp | 3 +-- code/AssetLib/Blender/BlenderTessellator.cpp | 6 ++---- code/AssetLib/C4D/C4DImporter.cpp | 3 +-- code/AssetLib/FBX/FBXImporter.cpp | 3 +-- code/AssetLib/IFC/IFCLoader.cpp | 3 +-- code/AssetLib/XGL/XGLLoader.cpp | 3 +-- 7 files changed, 8 insertions(+), 16 deletions(-) diff --git a/code/AssetLib/Blender/BlenderBMesh.cpp b/code/AssetLib/Blender/BlenderBMesh.cpp index b15da185d..a82e7c678 100644 --- a/code/AssetLib/Blender/BlenderBMesh.cpp +++ b/code/AssetLib/Blender/BlenderBMesh.cpp @@ -52,8 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { template <> const char *LogFunctions::Prefix() { - static auto prefix = "BLEND_BMESH: "; - return prefix; + return "BLEND_BMESH: "; } } // namespace Assimp diff --git a/code/AssetLib/Blender/BlenderLoader.cpp b/code/AssetLib/Blender/BlenderLoader.cpp index f1fb0246d..269c90b96 100644 --- a/code/AssetLib/Blender/BlenderLoader.cpp +++ b/code/AssetLib/Blender/BlenderLoader.cpp @@ -80,8 +80,7 @@ namespace Assimp { template <> const char *LogFunctions::Prefix() { - static auto prefix = "BLEND: "; - return prefix; + return "BLEND: "; } } // namespace Assimp diff --git a/code/AssetLib/Blender/BlenderTessellator.cpp b/code/AssetLib/Blender/BlenderTessellator.cpp index d3ef5ae5e..9c78d0a2a 100644 --- a/code/AssetLib/Blender/BlenderTessellator.cpp +++ b/code/AssetLib/Blender/BlenderTessellator.cpp @@ -62,8 +62,7 @@ namspace Assimp { template< > const char* LogFunctions< BlenderTessellatorGL >::Prefix() { - static auto prefix = "BLEND_TESS_GL: "; - return prefix; + return "BLEND_TESS_GL: "; } } @@ -259,8 +258,7 @@ namespace Assimp { template< > const char* LogFunctions< BlenderTessellatorP2T >::Prefix() { - static auto prefix = "BLEND_TESS_P2T: "; - return prefix; + return "BLEND_TESS_P2T: "; } } diff --git a/code/AssetLib/C4D/C4DImporter.cpp b/code/AssetLib/C4D/C4DImporter.cpp index 06d7a3412..f21ff8602 100644 --- a/code/AssetLib/C4D/C4DImporter.cpp +++ b/code/AssetLib/C4D/C4DImporter.cpp @@ -86,8 +86,7 @@ void GetWriterInfo(int &id, String &appname) { namespace Assimp { template<> const char* LogFunctions::Prefix() { - static auto prefix = "C4D: "; - return prefix; + return "C4D: "; } } diff --git a/code/AssetLib/FBX/FBXImporter.cpp b/code/AssetLib/FBX/FBXImporter.cpp index 7ff194905..7a106d535 100644 --- a/code/AssetLib/FBX/FBXImporter.cpp +++ b/code/AssetLib/FBX/FBXImporter.cpp @@ -62,8 +62,7 @@ namespace Assimp { template <> const char *LogFunctions::Prefix() { - static auto prefix = "FBX: "; - return prefix; + return "FBX: "; } } // namespace Assimp diff --git a/code/AssetLib/IFC/IFCLoader.cpp b/code/AssetLib/IFC/IFCLoader.cpp index 908dc8dfa..ee718681e 100644 --- a/code/AssetLib/IFC/IFCLoader.cpp +++ b/code/AssetLib/IFC/IFCLoader.cpp @@ -73,8 +73,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { template <> const char *LogFunctions::Prefix() { - static auto prefix = "IFC: "; - return prefix; + return "IFC: "; } } // namespace Assimp diff --git a/code/AssetLib/XGL/XGLLoader.cpp b/code/AssetLib/XGL/XGLLoader.cpp index 7cacbca4d..04e303370 100644 --- a/code/AssetLib/XGL/XGLLoader.cpp +++ b/code/AssetLib/XGL/XGLLoader.cpp @@ -65,8 +65,7 @@ namespace Assimp { // this has to be in here because LogFunctions is in ::Assimp template <> const char *LogFunctions::Prefix() { - static auto prefix = "XGL: "; - return prefix; + return "XGL: "; } } // namespace Assimp From 39cbef1e21c2910366e58d28f2d955030e04bac6 Mon Sep 17 00:00:00 2001 From: shimaowo <45767709+shimaowo@users.noreply.github.com> Date: Mon, 16 Jan 2023 11:39:13 -0800 Subject: [PATCH 2/9] Fix: fix incorrect math for calculating the horizontal FOV of a perspective camera in GLTF2 import #4435 --- code/AssetLib/glTF2/glTF2Importer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 7d3a4b9fe..0cf5472d6 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -853,7 +853,7 @@ void glTF2Importer::ImportCameras(glTF2::Asset &r) { if (cam.type == Camera::Perspective) { aicam->mAspect = cam.cameraProperties.perspective.aspectRatio; - aicam->mHorizontalFOV = cam.cameraProperties.perspective.yfov * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect); + aicam->mHorizontalFOV = 2.0f * std::atan(std::tan(cam.cameraProperties.perspective.yfov * 0.5f) * (aicam->mAspect == 0.f) ? 1.f : aicam->mAspect); aicam->mClipPlaneFar = cam.cameraProperties.perspective.zfar; aicam->mClipPlaneNear = cam.cameraProperties.perspective.znear; } else { From 43a062a5d7f867b71e0aed2d2906855ecf473838 Mon Sep 17 00:00:00 2001 From: Krishty Date: Mon, 16 Jan 2023 20:45:00 +0100 Subject: [PATCH 3/9] Remove Stray Semicolon --- code/AssetLib/glTF2/glTF2Importer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 7d3a4b9fe..a6674ccb3 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -185,7 +185,6 @@ static void SetMaterialTextureProperty(std::vector &embeddedTexIdxs, Asset const ai_real rsin(sin(-transform.mRotation)); transform.mTranslation.x = (static_cast(0.5) * transform.mScaling.x) * (-rcos + rsin + 1) + prop.TextureTransformExt_t.offset[0]; transform.mTranslation.y = ((static_cast(0.5) * transform.mScaling.y) * (rsin + rcos - 1)) + 1 - transform.mScaling.y - prop.TextureTransformExt_t.offset[1]; - ; mat->AddProperty(&transform, 1, _AI_MATKEY_UVTRANSFORM_BASE, texType, texSlot); } From 36305cf987788b01c64dcd891584e11cf7c205c0 Mon Sep 17 00:00:00 2001 From: Krishty Date: Mon, 16 Jan 2023 21:47:11 +0100 Subject: [PATCH 4/9] Tidy Up Constructors and Destructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit does not add or remove c’tors or d’tors, so it is *not* ABI-breaking. If a c’tor/d’tor does nothing else than the default behavior, this commit replaces it with “= default”. If an initializer list entry does nothing else than the default behavior, this commit removes it. First and foremost, remove default c’tor calls of base classes (always called by the compiler if no other base c’tor is explicitly called) and c’tor calls of members with complex types (e.g. “std::vector”). In a few instances, user-defined copy c’tors / move c’tors / assignment operators / move assignment operators were replaced with “= default”, too. I only did this if I had a clear understanding of what’s going on. --- code/AssetLib/3DS/3DSHelper.h | 125 ++----------------- code/AssetLib/3MF/3MFTypes.h | 4 +- code/AssetLib/3MF/D3MFExporter.cpp | 2 +- code/AssetLib/AMF/AMFImporter.cpp | 6 +- code/AssetLib/AMF/AMFImporter_Node.hpp | 10 +- code/AssetLib/Blender/BlenderDNA.h | 4 +- code/AssetLib/Blender/BlenderModifier.h | 4 +- code/AssetLib/Blender/BlenderScene.h | 25 ++-- code/AssetLib/Blender/BlenderTessellator.cpp | 4 +- code/AssetLib/C4D/C4DImporter.cpp | 9 +- code/AssetLib/Collada/ColladaLoader.cpp | 9 -- code/AssetLib/DXF/DXFHelper.h | 4 +- code/AssetLib/FBX/FBXExportNode.h | 4 - code/AssetLib/FBX/FBXImporter.cpp | 5 +- code/AssetLib/Irr/IRRMeshLoader.cpp | 6 +- code/AssetLib/Irr/IRRShared.h | 4 +- code/AssetLib/M3D/M3DImporter.h | 2 +- code/AssetLib/OpenGEX/OpenGEXImporter.cpp | 1 - code/AssetLib/Ply/PlyParser.h | 20 +-- code/AssetLib/Q3BSP/Q3BSPFileData.h | 14 +-- code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp | 2 +- code/AssetLib/SMD/SMDLoader.cpp | 1 - code/AssetLib/SMD/SMDLoader.h | 2 +- code/AssetLib/X/XFileHelper.h | 23 +--- code/AssetLib/X/XFileImporter.cpp | 4 +- code/AssetLib/X3D/X3DExporter.hpp | 12 +- code/AssetLib/X3D/X3DImporter_Node.hpp | 8 +- code/AssetLib/glTF/glTFAsset.h | 8 +- code/AssetLib/glTF/glTFImporter.cpp | 2 +- code/AssetLib/glTF2/glTF2Asset.h | 14 +-- code/AssetLib/glTF2/glTF2Importer.cpp | 3 - code/Common/FileSystemFilter.h | 4 +- include/assimp/IOStream.hpp | 4 +- include/assimp/IOStreamBuffer.h | 4 +- include/assimp/IOSystem.hpp | 5 +- include/assimp/LineSplitter.h | 5 +- include/assimp/MemoryIOWrapper.h | 3 +- include/assimp/Profiler.h | 4 +- include/assimp/ProgressHandler.hpp | 8 +- include/assimp/SceneCombiner.h | 8 +- 40 files changed, 63 insertions(+), 323 deletions(-) diff --git a/code/AssetLib/3DS/3DSHelper.h b/code/AssetLib/3DS/3DSHelper.h index dc1098035..06c36bfeb 100644 --- a/code/AssetLib/3DS/3DSHelper.h +++ b/code/AssetLib/3DS/3DSHelper.h @@ -322,7 +322,6 @@ struct Texture { //! Default constructor Texture() AI_NO_EXCEPT : mTextureBlend(0.0f), - mMapName(), mOffsetU(0.0), mOffsetV(0.0), mScaleU(1.0), @@ -334,51 +333,11 @@ struct Texture { mTextureBlend = get_qnan(); } - Texture(const Texture &other) : - mTextureBlend(other.mTextureBlend), - mMapName(other.mMapName), - mOffsetU(other.mOffsetU), - mOffsetV(other.mOffsetV), - mScaleU(other.mScaleU), - mScaleV(other.mScaleV), - mRotation(other.mRotation), - mMapMode(other.mMapMode), - bPrivate(other.bPrivate), - iUVSrc(other.iUVSrc) { - // empty - } + Texture(const Texture &other) = default; - Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(other.mTextureBlend), - mMapName(std::move(other.mMapName)), - mOffsetU(other.mOffsetU), - mOffsetV(other.mOffsetV), - mScaleU(other.mScaleU), - mScaleV(other.mScaleV), - mRotation(other.mRotation), - mMapMode(other.mMapMode), - bPrivate(other.bPrivate), - iUVSrc(other.iUVSrc) { - // empty - } + Texture(Texture &&other) AI_NO_EXCEPT = default; - Texture &operator=(Texture &&other) AI_NO_EXCEPT { - if (this == &other) { - return *this; - } - - mTextureBlend = other.mTextureBlend; - mMapName = std::move(other.mMapName); - mOffsetU = other.mOffsetU; - mOffsetV = other.mOffsetV; - mScaleU = other.mScaleU; - mScaleV = other.mScaleV; - mRotation = other.mRotation; - mMapMode = other.mMapMode; - bPrivate = other.bPrivate; - iUVSrc = other.iUVSrc; - - return *this; - } + Texture &operator=(Texture &&other) AI_NO_EXCEPT = default; //! Specifies the blend factor for the texture ai_real mTextureBlend; @@ -436,83 +395,13 @@ struct Material { // empty } - Material(const Material &other) : - mName(other.mName), - mDiffuse(other.mDiffuse), - mSpecularExponent(other.mSpecularExponent), - mShininessStrength(other.mShininessStrength), - mSpecular(other.mSpecular), - mAmbient(other.mAmbient), - mShading(other.mShading), - mTransparency(other.mTransparency), - sTexDiffuse(other.sTexDiffuse), - sTexOpacity(other.sTexOpacity), - sTexSpecular(other.sTexSpecular), - sTexReflective(other.sTexReflective), - sTexBump(other.sTexBump), - sTexEmissive(other.sTexEmissive), - sTexShininess(other.sTexShininess), - mBumpHeight(other.mBumpHeight), - mEmissive(other.mEmissive), - sTexAmbient(other.sTexAmbient), - mTwoSided(other.mTwoSided) { - // empty - } + Material(const Material &other) = default; - //! Move constructor. This is explicitly written because MSVC doesn't support defaulting it - Material(Material &&other) AI_NO_EXCEPT : mName(std::move(other.mName)), - mDiffuse(other.mDiffuse), - mSpecularExponent(other.mSpecularExponent), - mShininessStrength(other.mShininessStrength), - mSpecular(other.mSpecular), - mAmbient(other.mAmbient), - mShading(other.mShading), - mTransparency(other.mTransparency), - sTexDiffuse(std::move(other.sTexDiffuse)), - sTexOpacity(std::move(other.sTexOpacity)), - sTexSpecular(std::move(other.sTexSpecular)), - sTexReflective(std::move(other.sTexReflective)), - sTexBump(std::move(other.sTexBump)), - sTexEmissive(std::move(other.sTexEmissive)), - sTexShininess(std::move(other.sTexShininess)), - mBumpHeight(other.mBumpHeight), - mEmissive(other.mEmissive), - sTexAmbient(std::move(other.sTexAmbient)), - mTwoSided(other.mTwoSided) { - // empty - } + Material(Material &&other) AI_NO_EXCEPT = default; - Material &operator=(Material &&other) AI_NO_EXCEPT { - if (this == &other) { - return *this; - } + Material &operator=(Material &&other) AI_NO_EXCEPT = default; - mName = std::move(other.mName); - mDiffuse = other.mDiffuse; - mSpecularExponent = other.mSpecularExponent; - mShininessStrength = other.mShininessStrength, - mSpecular = other.mSpecular; - mAmbient = other.mAmbient; - mShading = other.mShading; - mTransparency = other.mTransparency; - sTexDiffuse = std::move(other.sTexDiffuse); - sTexOpacity = std::move(other.sTexOpacity); - sTexSpecular = std::move(other.sTexSpecular); - sTexReflective = std::move(other.sTexReflective); - sTexBump = std::move(other.sTexBump); - sTexEmissive = std::move(other.sTexEmissive); - sTexShininess = std::move(other.sTexShininess); - mBumpHeight = other.mBumpHeight; - mEmissive = other.mEmissive; - sTexAmbient = std::move(other.sTexAmbient); - mTwoSided = other.mTwoSided; - - return *this; - } - - virtual ~Material() { - // empty - } + virtual ~Material() = default; //! Name of the material std::string mName; diff --git a/code/AssetLib/3MF/3MFTypes.h b/code/AssetLib/3MF/3MFTypes.h index 987cdf613..02238ceab 100644 --- a/code/AssetLib/3MF/3MFTypes.h +++ b/code/AssetLib/3MF/3MFTypes.h @@ -69,9 +69,7 @@ public: // empty } - virtual ~Resource() { - // empty - } + virtual ~Resource() = default; virtual ResourceType getType() const { return ResourceType::RT_Unknown; diff --git a/code/AssetLib/3MF/D3MFExporter.cpp b/code/AssetLib/3MF/D3MFExporter.cpp index 42cd991e6..4ba3bbf24 100644 --- a/code/AssetLib/3MF/D3MFExporter.cpp +++ b/code/AssetLib/3MF/D3MFExporter.cpp @@ -83,7 +83,7 @@ void ExportScene3MF(const char *pFile, IOSystem *pIOSystem, const aiScene *pScen namespace D3MF { D3MFExporter::D3MFExporter(const char *pFile, const aiScene *pScene) : - mArchiveName(pFile), m_zipArchive(nullptr), mScene(pScene), mModelOutput(), mRelOutput(), mContentOutput(), mBuildItems(), mRelations() { + mArchiveName(pFile), m_zipArchive(nullptr), mScene(pScene) { // empty } diff --git a/code/AssetLib/AMF/AMFImporter.cpp b/code/AssetLib/AMF/AMFImporter.cpp index b95fdf540..ff581b492 100644 --- a/code/AssetLib/AMF/AMFImporter.cpp +++ b/code/AssetLib/AMF/AMFImporter.cpp @@ -83,11 +83,7 @@ void AMFImporter::Clear() { AMFImporter::AMFImporter() AI_NO_EXCEPT : mNodeElement_Cur(nullptr), - mXmlParser(nullptr), - mUnit(), - mVersion(), - mMaterial_Converted(), - mTexture_Converted() { + mXmlParser(nullptr) { // empty } diff --git a/code/AssetLib/AMF/AMFImporter_Node.hpp b/code/AssetLib/AMF/AMFImporter_Node.hpp index c827533a6..dd27316d3 100644 --- a/code/AssetLib/AMF/AMFImporter_Node.hpp +++ b/code/AssetLib/AMF/AMFImporter_Node.hpp @@ -88,9 +88,7 @@ public: std::list Child; ///< Child elements. public: /// Destructor, virtual.. - virtual ~AMFNodeElementBase() { - // empty - } + virtual ~AMFNodeElementBase() = default; /// Disabled copy constructor and co. AMFNodeElementBase(const AMFNodeElementBase &pNodeElement) = delete; @@ -103,7 +101,7 @@ protected: /// \param [in] pType - element type. /// \param [in] pParent - parent element. AMFNodeElementBase(const EType pType, AMFNodeElementBase *pParent) : - Type(pType), ID(), Parent(pParent), Child() { + Type(pType), Parent(pParent) { // empty } }; // class IAMFImporter_NodeElement @@ -174,7 +172,7 @@ struct AMFColor : public AMFNodeElementBase { /// @brief Constructor. /// @param [in] pParent - pointer to parent node. AMFColor(AMFNodeElementBase *pParent) : - AMFNodeElementBase(ENET_Color, pParent), Composed(false), Color(), Profile() { + AMFNodeElementBase(ENET_Color, pParent), Composed(false), Color() { // empty } }; @@ -270,7 +268,7 @@ struct AMFTexMap : public AMFNodeElementBase { /// Constructor. /// \param [in] pParent - pointer to parent node. AMFTexMap(AMFNodeElementBase *pParent) : - AMFNodeElementBase(ENET_TexMap, pParent), TextureCoordinate{}, TextureID_R(), TextureID_G(), TextureID_B(), TextureID_A() { + AMFNodeElementBase(ENET_TexMap, pParent), TextureCoordinate{} { // empty } }; diff --git a/code/AssetLib/Blender/BlenderDNA.h b/code/AssetLib/Blender/BlenderDNA.h index dcae3198b..494dc4b34 100644 --- a/code/AssetLib/Blender/BlenderDNA.h +++ b/code/AssetLib/Blender/BlenderDNA.h @@ -106,9 +106,7 @@ struct ElemBase { // empty } - virtual ~ElemBase() { - // empty - } + virtual ~ElemBase() = default; /** Type name of the element. The type * string points is the `c_str` of the `name` attribute of the diff --git a/code/AssetLib/Blender/BlenderModifier.h b/code/AssetLib/Blender/BlenderModifier.h index 5af560caf..180a456a1 100644 --- a/code/AssetLib/Blender/BlenderModifier.h +++ b/code/AssetLib/Blender/BlenderModifier.h @@ -62,9 +62,7 @@ public: /** * The class destructor, virtual. */ - virtual ~BlenderModifier() { - // empty - } + virtual ~BlenderModifier() = default; // -------------------- /** diff --git a/code/AssetLib/Blender/BlenderScene.h b/code/AssetLib/Blender/BlenderScene.h index 436e47061..ba7ded909 100644 --- a/code/AssetLib/Blender/BlenderScene.h +++ b/code/AssetLib/Blender/BlenderScene.h @@ -182,7 +182,7 @@ struct MVert : ElemBase { int bweight; MVert() : - ElemBase(), flag(0), mat_nr(0), bweight(0) {} + flag(0), mat_nr(0), bweight(0) {} }; // ------------------------------------------------------------------------------- @@ -417,7 +417,6 @@ struct CustomDataLayer : ElemBase { std::shared_ptr data; // must be converted to real type according type member CustomDataLayer() : - ElemBase(), type(0), offset(0), flag(0), @@ -729,7 +728,7 @@ struct Object : ElemBase { ListBase modifiers; Object() : - ElemBase(), type(Type_EMPTY), parent(nullptr), track(), proxy(), proxy_from(), data() { + type(Type_EMPTY), parent(nullptr) { // empty } }; @@ -741,8 +740,7 @@ struct Base : ElemBase { std::shared_ptr object WARN; Base() : - ElemBase(), prev(nullptr), next(), object() { - // empty + prev(nullptr) { // empty } }; @@ -758,10 +756,7 @@ struct Scene : ElemBase { ListBase base; - Scene() : - ElemBase(), camera(), world(), basact(), master_collection() { - // empty - } + Scene() = default; }; // ------------------------------------------------------------------------------- @@ -791,10 +786,7 @@ struct Image : ElemBase { short gen_x, gen_y, gen_type; - Image() : - ElemBase() { - // empty - } + Image() = default; }; // ------------------------------------------------------------------------------- @@ -884,7 +876,7 @@ struct Tex : ElemBase { //char use_nodes; Tex() : - ElemBase(), imaflag(ImageFlags_INTERPOL), type(Type_CLOUDS), ima() { + imaflag(ImageFlags_INTERPOL), type(Type_CLOUDS) { // empty } }; @@ -976,10 +968,7 @@ struct MTex : ElemBase { //float shadowfac; //float zenupfac, zendownfac, blendfac; - MTex() : - ElemBase() { - // empty - } + MTex() = default; }; } // namespace Blender diff --git a/code/AssetLib/Blender/BlenderTessellator.cpp b/code/AssetLib/Blender/BlenderTessellator.cpp index d3ef5ae5e..40117a974 100644 --- a/code/AssetLib/Blender/BlenderTessellator.cpp +++ b/code/AssetLib/Blender/BlenderTessellator.cpp @@ -81,9 +81,7 @@ BlenderTessellatorGL::BlenderTessellatorGL( BlenderBMeshConverter& converter ): } // ------------------------------------------------------------------------------------------------ -BlenderTessellatorGL::~BlenderTessellatorGL( ) -{ -} +BlenderTessellatorGL::~BlenderTessellatorGL() = default; // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::Tessellate( const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices ) diff --git a/code/AssetLib/C4D/C4DImporter.cpp b/code/AssetLib/C4D/C4DImporter.cpp index 06d7a3412..9a3a72667 100644 --- a/code/AssetLib/C4D/C4DImporter.cpp +++ b/code/AssetLib/C4D/C4DImporter.cpp @@ -106,15 +106,10 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ -C4DImporter::C4DImporter() -: BaseImporter() { - // empty -} +C4DImporter::C4DImporter() = default; // ------------------------------------------------------------------------------------------------ -C4DImporter::~C4DImporter() { - // empty -} +C4DImporter::~C4DImporter() = default; // ------------------------------------------------------------------------------------------------ bool C4DImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const { diff --git a/code/AssetLib/Collada/ColladaLoader.cpp b/code/AssetLib/Collada/ColladaLoader.cpp index 2d578aff3..1280fd0d1 100644 --- a/code/AssetLib/Collada/ColladaLoader.cpp +++ b/code/AssetLib/Collada/ColladaLoader.cpp @@ -92,15 +92,6 @@ inline void AddNodeMetaData(aiNode *node, const std::string &key, const T &value // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer ColladaLoader::ColladaLoader() : - mFileName(), - mMeshIndexByID(), - mMaterialIndexByName(), - mMeshes(), - newMats(), - mCameras(), - mLights(), - mTextures(), - mAnims(), noSkeletonMesh(false), removeEmptyBones(false), ignoreUpDirection(false), diff --git a/code/AssetLib/DXF/DXFHelper.h b/code/AssetLib/DXF/DXFHelper.h index e50c471d2..4d7893cc4 100644 --- a/code/AssetLib/DXF/DXFHelper.h +++ b/code/AssetLib/DXF/DXFHelper.h @@ -65,7 +65,6 @@ public: LineReader(StreamReaderLE& reader) : splitter(reader,false,true) , groupcode( 0 ) - , value() , end() { // empty } @@ -186,8 +185,7 @@ struct InsertBlock { InsertBlock() : pos() , scale(1.f,1.f,1.f) - , angle() - , name() { + , angle() { // empty } diff --git a/code/AssetLib/FBX/FBXExportNode.h b/code/AssetLib/FBX/FBXExportNode.h index 62c06e16b..99644b216 100644 --- a/code/AssetLib/FBX/FBXExportNode.h +++ b/code/AssetLib/FBX/FBXExportNode.h @@ -77,8 +77,6 @@ public: // constructors /// The class constructor with the name. Node(const std::string& n) : name(n) - , properties() - , children() , force_has_children( false ) { // empty } @@ -87,8 +85,6 @@ public: // constructors template Node(const std::string& n, More&&... more) : name(n) - , properties() - , children() , force_has_children(false) { AddProperties(std::forward(more)...); } diff --git a/code/AssetLib/FBX/FBXImporter.cpp b/code/AssetLib/FBX/FBXImporter.cpp index 7ff194905..6a727c3d7 100644 --- a/code/AssetLib/FBX/FBXImporter.cpp +++ b/code/AssetLib/FBX/FBXImporter.cpp @@ -90,10 +90,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by #Importer -FBXImporter::FBXImporter() : - mSettings() { - // empty -} +FBXImporter::FBXImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Irr/IRRMeshLoader.cpp b/code/AssetLib/Irr/IRRMeshLoader.cpp index 9b4faec83..52fb82ff9 100644 --- a/code/AssetLib/Irr/IRRMeshLoader.cpp +++ b/code/AssetLib/Irr/IRRMeshLoader.cpp @@ -71,11 +71,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -IRRMeshImporter::IRRMeshImporter() : - BaseImporter(), - IrrlichtBase() { - // empty -} +IRRMeshImporter::IRRMeshImporter() = default; // ------------------------------------------------------------------------------------------------ // Destructor, private as well diff --git a/code/AssetLib/Irr/IRRShared.h b/code/AssetLib/Irr/IRRShared.h index 90e212d65..ee1309e14 100644 --- a/code/AssetLib/Irr/IRRShared.h +++ b/code/AssetLib/Irr/IRRShared.h @@ -63,9 +63,7 @@ protected: // empty } - ~IrrlichtBase() { - // empty - } + ~IrrlichtBase() = default; /** @brief Data structure for a simple name-value property */ diff --git a/code/AssetLib/M3D/M3DImporter.h b/code/AssetLib/M3D/M3DImporter.h index 5d3fcaa7b..9ca8f9211 100644 --- a/code/AssetLib/M3D/M3DImporter.h +++ b/code/AssetLib/M3D/M3DImporter.h @@ -65,7 +65,7 @@ class M3DImporter : public BaseImporter { public: /// \brief Default constructor M3DImporter(); - ~M3DImporter() override {} + ~M3DImporter() override = default; /// \brief Returns whether the class can handle the format of the given file. /// \remark See BaseImporter::CanRead() for details. diff --git a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp index 2883f9612..1bd981656 100644 --- a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp +++ b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp @@ -261,7 +261,6 @@ OpenGEXImporter::RefInfo::RefInfo(aiNode *node, Type type, std::vector alProperties; @@ -386,10 +381,7 @@ class ElementInstanceList public: //! Default constructor - ElementInstanceList() AI_NO_EXCEPT - : alInstances() { - // empty - } + ElementInstanceList() AI_NO_EXCEPT = default; //! List of all element instances std::vector< ElementInstance > alInstances; @@ -413,11 +405,7 @@ class DOM public: //! Default constructor - DOM() AI_NO_EXCEPT - : alElements() - , alElementData() { - - } + DOM() AI_NO_EXCEPT = default; //! Contains all elements of the file format diff --git a/code/AssetLib/Q3BSP/Q3BSPFileData.h b/code/AssetLib/Q3BSP/Q3BSPFileData.h index 8ccee0b0a..086cf7842 100644 --- a/code/AssetLib/Q3BSP/Q3BSPFileData.h +++ b/code/AssetLib/Q3BSP/Q3BSPFileData.h @@ -169,19 +169,7 @@ struct Q3BSPModel { std::vector m_EntityData; std::string m_ModelName; - Q3BSPModel() : - m_Data(), - m_Lumps(), - m_Vertices(), - m_Faces(), - m_Indices(), - m_Textures(), - m_Lightmaps(), - m_EntityData(), - m_ModelName() - { - // empty - } + Q3BSPModel() = default; ~Q3BSPModel() { for ( unsigned int i=0; i mMeshes; Node() AI_NO_EXCEPT - : mName(), - mTrafoMatrix(), - mParent(nullptr), - mChildren(), - mMeshes() { + : mTrafoMatrix(), + mParent(nullptr) { // empty } explicit Node(Node *pParent) : - mName(), mTrafoMatrix(), mParent(pParent), mChildren(), mMeshes() { + mTrafoMatrix(), mParent(pParent) { // empty } @@ -211,8 +198,6 @@ struct Scene { Scene() AI_NO_EXCEPT : mRootNode(nullptr), - mGlobalMeshes(), - mGlobalMaterials(), mAnimTicksPerSecond(0) { // empty } diff --git a/code/AssetLib/X/XFileImporter.cpp b/code/AssetLib/X/XFileImporter.cpp index 8bd5d9e88..32865e8a8 100644 --- a/code/AssetLib/X/XFileImporter.cpp +++ b/code/AssetLib/X/XFileImporter.cpp @@ -75,9 +75,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -XFileImporter::XFileImporter() : mBuffer() { - // empty -} +XFileImporter::XFileImporter() = default; // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/X3D/X3DExporter.hpp b/code/AssetLib/X3D/X3DExporter.hpp index 7a87821b4..e77aa6877 100644 --- a/code/AssetLib/X3D/X3DExporter.hpp +++ b/code/AssetLib/X3D/X3DExporter.hpp @@ -52,22 +52,14 @@ class X3DExporter { struct SAttribute { const std::string Name; const std::string Value; - SAttribute() : - Name(), - Value() { - // empty - } + SAttribute() = default; SAttribute(const std::string &name, const std::string &value) : Name(name), Value(value) { // empty } - SAttribute(SAttribute &&rhs) AI_NO_EXCEPT : - Name(rhs.Name), - Value(rhs.Value) { - // empty - } + SAttribute(SAttribute &&rhs) AI_NO_EXCEPT = default; }; /***********************************************/ diff --git a/code/AssetLib/X3D/X3DImporter_Node.hpp b/code/AssetLib/X3D/X3DImporter_Node.hpp index 8d33c4b7a..62bf857e4 100644 --- a/code/AssetLib/X3D/X3DImporter_Node.hpp +++ b/code/AssetLib/X3D/X3DImporter_Node.hpp @@ -108,9 +108,7 @@ struct X3DNodeElementBase { std::list Children; X3DElemType Type; - virtual ~X3DNodeElementBase() { - // empty - } + virtual ~X3DNodeElementBase() = default; protected: X3DNodeElementBase(X3DElemType type, X3DNodeElementBase *pParent) : @@ -367,9 +365,7 @@ struct X3DNodeElementMeta : X3DNodeElementBase { std::string Name; ///< Name of metadata object. std::string Reference; - virtual ~X3DNodeElementMeta() { - // empty - } + virtual ~X3DNodeElementMeta() = default; protected: X3DNodeElementMeta(X3DElemType type, X3DNodeElementBase *parent) : diff --git a/code/AssetLib/glTF/glTFAsset.h b/code/AssetLib/glTF/glTFAsset.h index 26ef239cd..955dea40f 100644 --- a/code/AssetLib/glTF/glTFAsset.h +++ b/code/AssetLib/glTF/glTFAsset.h @@ -629,9 +629,7 @@ struct Mesh : public Object { SExtension(const EType pType) : Type(pType) {} - virtual ~SExtension() { - // empty - } + virtual ~SExtension() = default; }; #ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC @@ -657,9 +655,7 @@ struct Mesh : public Object { // empty } - virtual ~SCompression_Open3DGC() { - // empty - } + virtual ~SCompression_Open3DGC() = default; }; #endif diff --git a/code/AssetLib/glTF/glTFImporter.cpp b/code/AssetLib/glTF/glTFImporter.cpp index 3a5b0ef3c..61c11f594 100644 --- a/code/AssetLib/glTF/glTFImporter.cpp +++ b/code/AssetLib/glTF/glTFImporter.cpp @@ -80,7 +80,7 @@ static const aiImporterDesc desc = { }; glTFImporter::glTFImporter() : - BaseImporter(), meshOffsets(), embeddedTexIdxs(), mScene(nullptr) { + mScene(nullptr) { // empty } diff --git a/code/AssetLib/glTF2/glTF2Asset.h b/code/AssetLib/glTF2/glTF2Asset.h index 85af49acf..e8d1d88d1 100644 --- a/code/AssetLib/glTF2/glTF2Asset.h +++ b/code/AssetLib/glTF2/glTF2Asset.h @@ -365,16 +365,7 @@ struct CustomExtension { ~CustomExtension() = default; - CustomExtension(const CustomExtension &other) : - name(other.name), - mStringValue(other.mStringValue), - mDoubleValue(other.mDoubleValue), - mUint64Value(other.mUint64Value), - mInt64Value(other.mInt64Value), - mBoolValue(other.mBoolValue), - mValues(other.mValues) { - // empty - } + CustomExtension(const CustomExtension &other) = default; CustomExtension& operator=(const CustomExtension&) = default; }; @@ -1086,8 +1077,7 @@ struct AssetMetadata { void Read(Document &doc); - AssetMetadata() : - version() {} + AssetMetadata() = default; }; // diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 7d3a4b9fe..d6b65b458 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -96,9 +96,6 @@ static const aiImporterDesc desc = { }; glTF2Importer::glTF2Importer() : - BaseImporter(), - meshOffsets(), - mEmbeddedTexIdxs(), mScene(nullptr) { // empty } diff --git a/code/Common/FileSystemFilter.h b/code/Common/FileSystemFilter.h index 9ab3812e2..d28233ae9 100644 --- a/code/Common/FileSystemFilter.h +++ b/code/Common/FileSystemFilter.h @@ -93,9 +93,7 @@ public: } /** Destructor. */ - ~FileSystemFilter() { - // empty - } + ~FileSystemFilter() = default; // ------------------------------------------------------------------- /** Tests for the existence of a file at the given path. */ diff --git a/include/assimp/IOStream.hpp b/include/assimp/IOStream.hpp index 3b9b3c3f8..12beb0dbb 100644 --- a/include/assimp/IOStream.hpp +++ b/include/assimp/IOStream.hpp @@ -128,9 +128,7 @@ public: // ---------------------------------------------------------------------------------- AI_FORCE_INLINE -IOStream::IOStream() AI_NO_EXCEPT { - // empty -} +IOStream::IOStream() AI_NO_EXCEPT = default; // ---------------------------------------------------------------------------------- AI_FORCE_INLINE diff --git a/include/assimp/IOStreamBuffer.h b/include/assimp/IOStreamBuffer.h index 09ca1c962..b34fc9ee1 100644 --- a/include/assimp/IOStreamBuffer.h +++ b/include/assimp/IOStreamBuffer.h @@ -141,9 +141,7 @@ AI_FORCE_INLINE IOStreamBuffer::IOStreamBuffer(size_t cache) : } template -AI_FORCE_INLINE IOStreamBuffer::~IOStreamBuffer() { - // empty -} +AI_FORCE_INLINE IOStreamBuffer::~IOStreamBuffer() = default; template AI_FORCE_INLINE bool IOStreamBuffer::open(IOStream *stream) { diff --git a/include/assimp/IOSystem.hpp b/include/assimp/IOSystem.hpp index b4531f96a..30f48b81c 100644 --- a/include/assimp/IOSystem.hpp +++ b/include/assimp/IOSystem.hpp @@ -237,10 +237,7 @@ private: }; // ---------------------------------------------------------------------------- -AI_FORCE_INLINE IOSystem::IOSystem() AI_NO_EXCEPT : - m_pathStack() { - // empty -} +AI_FORCE_INLINE IOSystem::IOSystem() AI_NO_EXCEPT = default; // ---------------------------------------------------------------------------- AI_FORCE_INLINE IOSystem::~IOSystem() = default; diff --git a/include/assimp/LineSplitter.h b/include/assimp/LineSplitter.h index a8aa665db..379821f03 100644 --- a/include/assimp/LineSplitter.h +++ b/include/assimp/LineSplitter.h @@ -145,7 +145,6 @@ private: AI_FORCE_INLINE LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_empty_lines, bool trim ) : mIdx(0), - mCur(), mStream(stream), mSwallow(), mSkip_empty_lines(skip_empty_lines), @@ -155,9 +154,7 @@ AI_FORCE_INLINE LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_emp mIdx = 0; } -AI_FORCE_INLINE LineSplitter::~LineSplitter() { - // empty -} +AI_FORCE_INLINE LineSplitter::~LineSplitter() = default; AI_FORCE_INLINE LineSplitter& LineSplitter::operator++() { if (mSwallow) { diff --git a/include/assimp/MemoryIOWrapper.h b/include/assimp/MemoryIOWrapper.h index b4c37763d..0bd3bc108 100644 --- a/include/assimp/MemoryIOWrapper.h +++ b/include/assimp/MemoryIOWrapper.h @@ -162,8 +162,7 @@ public: } /** Destructor. */ - ~MemoryIOSystem() { - } + ~MemoryIOSystem() = default; // ------------------------------------------------------------------- /** Tests for the existence of a file at the given path. */ diff --git a/include/assimp/Profiler.h b/include/assimp/Profiler.h index fe0ffbb10..3b9263b40 100644 --- a/include/assimp/Profiler.h +++ b/include/assimp/Profiler.h @@ -68,9 +68,7 @@ using namespace Formatter; */ class Profiler { public: - Profiler() { - // empty - } + Profiler() = default; /** Start a named timer */ diff --git a/include/assimp/ProgressHandler.hpp b/include/assimp/ProgressHandler.hpp index 1a272bb87..93d881659 100644 --- a/include/assimp/ProgressHandler.hpp +++ b/include/assimp/ProgressHandler.hpp @@ -67,15 +67,11 @@ class ASSIMP_API ProgressHandler { protected: /// @brief Default constructor - ProgressHandler () AI_NO_EXCEPT { - // empty - } + ProgressHandler () AI_NO_EXCEPT = default; public: /// @brief Virtual destructor. - virtual ~ProgressHandler () { - // empty - } + virtual ~ProgressHandler () = default; // ------------------------------------------------------------------- /** @brief Progress callback. diff --git a/include/assimp/SceneCombiner.h b/include/assimp/SceneCombiner.h index 6da38cd15..d6096900c 100644 --- a/include/assimp/SceneCombiner.h +++ b/include/assimp/SceneCombiner.h @@ -191,13 +191,9 @@ struct SceneHelper { */ class ASSIMP_API SceneCombiner { // class cannot be instanced - SceneCombiner() { - // empty - } + SceneCombiner() = delete; - ~SceneCombiner() { - // empty - } + ~SceneCombiner() = delete; public: // ------------------------------------------------------------------- From b298b79a46bb30545dcd82979a5320a9b9b55e27 Mon Sep 17 00:00:00 2001 From: shimaowo <45767709+shimaowo@users.noreply.github.com> Date: Tue, 17 Jan 2023 10:53:41 -0800 Subject: [PATCH 5/9] add missing parens --- code/AssetLib/glTF2/glTF2Importer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 0cf5472d6..94b7ad665 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -853,7 +853,7 @@ void glTF2Importer::ImportCameras(glTF2::Asset &r) { if (cam.type == Camera::Perspective) { aicam->mAspect = cam.cameraProperties.perspective.aspectRatio; - aicam->mHorizontalFOV = 2.0f * std::atan(std::tan(cam.cameraProperties.perspective.yfov * 0.5f) * (aicam->mAspect == 0.f) ? 1.f : aicam->mAspect); + aicam->mHorizontalFOV = 2.0f * std::atan(std::tan(cam.cameraProperties.perspective.yfov * 0.5f) * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect)); aicam->mClipPlaneFar = cam.cameraProperties.perspective.zfar; aicam->mClipPlaneNear = cam.cameraProperties.perspective.znear; } else { From 72f360710a846c45d253ca05090edea8d27095d1 Mon Sep 17 00:00:00 2001 From: Krishty Date: Wed, 18 Jan 2023 00:08:38 +0100 Subject: [PATCH 6/9] =?UTF-8?q?Fix=20MSVC=20Warnings=20With=20=E2=80=9Cemp?= =?UTF-8?q?lace=5Fback()=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several places in the code call `std::vector.emplace_back(0, 0, 0)`. The constructor of `aiVector3D` actually expects arguments of the type `ai_real`, (alias of `float` if compiling without `ASSIMP_DOUBLE_PRECISION`) but the literal `0` is of type `int`. `emplace_back()` does support promotion, but `int` to `float` is a potentially lossy conversion. tl;dr: On warning level 4, MSVC spits out a very deeply nested `warning C4244: 'argument': conversion from '_Ty' to 'TReal', possible loss of data with _Ty=int and TReal=ai_real`. --- code/AssetLib/MMD/MMDImporter.cpp | 2 +- code/AssetLib/X3D/X3DGeoHelper.cpp | 8 ++++---- code/AssetLib/X3D/X3DImporter_Geometry2D.cpp | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/code/AssetLib/MMD/MMDImporter.cpp b/code/AssetLib/MMD/MMDImporter.cpp index 97b04f4eb..0905ce1e0 100644 --- a/code/AssetLib/MMD/MMDImporter.cpp +++ b/code/AssetLib/MMD/MMDImporter.cpp @@ -269,7 +269,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel, dynamic_cast(v->skinning.get()); switch (v->skinning_type) { case pmx::PmxVertexSkinningType::BDEF1: - bone_vertex_map[vsBDEF1_ptr->bone_index].emplace_back(index, 1.0); + bone_vertex_map[vsBDEF1_ptr->bone_index].emplace_back(index, static_cast(1)); break; case pmx::PmxVertexSkinningType::BDEF2: bone_vertex_map[vsBDEF2_ptr->bone_index1].emplace_back(index, vsBDEF2_ptr->bone_weight); diff --git a/code/AssetLib/X3D/X3DGeoHelper.cpp b/code/AssetLib/X3D/X3DGeoHelper.cpp index e89aeb428..0a62ff9b0 100644 --- a/code/AssetLib/X3D/X3DGeoHelper.cpp +++ b/code/AssetLib/X3D/X3DGeoHelper.cpp @@ -193,7 +193,7 @@ void X3DGeoHelper::add_color(aiMesh &pMesh, const std::list &pColors, // create RGBA array from RGB. for (std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it) - tcol.emplace_back((*it).r, (*it).g, (*it).b, 1); + tcol.emplace_back((*it).r, (*it).g, (*it).b, static_cast(1)); // call existing function for adding RGBA colors add_color(pMesh, tcol, pColorPerVertex); @@ -238,7 +238,7 @@ void X3DGeoHelper::add_color(aiMesh &pMesh, const std::vector &pCoordId // create RGBA array from RGB. for (std::list::const_iterator it = pColors.begin(); it != pColors.end(); ++it) { - tcol.emplace_back((*it).r, (*it).g, (*it).b, 1); + tcol.emplace_back((*it).r, (*it).g, (*it).b, static_cast(1)); } // call existing function for adding RGBA colors @@ -440,7 +440,7 @@ void X3DGeoHelper::add_tex_coord(aiMesh &pMesh, const std::vector &pCoo // copy list to array because we are need indexed access to normals. texcoord_arr_copy.reserve(pTexCoords.size()); for (std::list::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) { - texcoord_arr_copy.emplace_back((*it).x, (*it).y, 0); + texcoord_arr_copy.emplace_back((*it).x, (*it).y, static_cast(0)); } if (pTexCoordIdx.size() > 0) { @@ -480,7 +480,7 @@ void X3DGeoHelper::add_tex_coord(aiMesh &pMesh, const std::list &pTe // copy list to array because we are need convert aiVector2D to aiVector3D and also get indexed access as a bonus. tc_arr_copy.reserve(pTexCoords.size()); for (std::list::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) { - tc_arr_copy.emplace_back((*it).x, (*it).y, 0); + tc_arr_copy.emplace_back((*it).x, (*it).y, static_cast(0)); } // copy texture coordinates to mesh diff --git a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp index 653203b4e..8e33decee 100644 --- a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp +++ b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp @@ -151,7 +151,7 @@ void X3DImporter::readArcClose2D(XmlNode &node) { std::list &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias. if ((closureType == "PIE") || (closureType == "\"PIE\"")) - vlist.emplace_back(0, 0, 0); // center point - first radial line + vlist.emplace_back(static_cast(0), static_cast(0), static_cast(0)); // center point - first radial line else if ((closureType != "CHORD") && (closureType != "\"CHORD\"")) Throw_IncorrectAttrValue("ArcClose2D", "closureType"); @@ -323,7 +323,7 @@ void X3DImporter::readPolyline2D(XmlNode &node) { // convert vec2 to vec3 for (std::list::iterator it2 = lineSegments.begin(); it2 != lineSegments.end(); ++it2) - tlist.emplace_back(it2->x, it2->y, 0); + tlist.emplace_back(it2->x, it2->y, static_cast(0)); // convert point set to line set X3DGeoHelper::extend_point_to_line(tlist, ((X3DNodeElementGeometry2D *)ne)->Vertices); @@ -361,7 +361,7 @@ void X3DImporter::readPolypoint2D(XmlNode &node) { // convert vec2 to vec3 for (std::list::iterator it2 = point.begin(); it2 != point.end(); ++it2) { - ((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, 0); + ((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, static_cast(0)); } ((X3DNodeElementGeometry2D *)ne)->NumIndices = 1; @@ -405,10 +405,10 @@ void X3DImporter::readRectangle2D(XmlNode &node) { float y2 = size.y / 2.0f; std::list &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias. - vlist.emplace_back(x2, y1, 0); // 1st point - vlist.emplace_back(x2, y2, 0); // 2nd point - vlist.emplace_back(x1, y2, 0); // 3rd point - vlist.emplace_back(x1, y1, 0); // 4th point + vlist.emplace_back(x2, y1, static_cast(0)); // 1st point + vlist.emplace_back(x2, y2, static_cast(0)); // 2nd point + vlist.emplace_back(x1, y2, static_cast(0)); // 3rd point + vlist.emplace_back(x1, y1, static_cast(0)); // 4th point ((X3DNodeElementGeometry2D *)ne)->Solid = solid; ((X3DNodeElementGeometry2D *)ne)->NumIndices = 4; // check for X3DMetadataObject childs. @@ -449,7 +449,7 @@ void X3DImporter::readTriangleSet2D(XmlNode &node) { // convert vec2 to vec3 for (std::list::iterator it2 = vertices.begin(); it2 != vertices.end(); ++it2) { - ((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, 0); + ((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, static_cast(0)); } ((X3DNodeElementGeometry2D *)ne)->Solid = solid; From eb5d3c51e8987a6c687657503a30481e45a90de1 Mon Sep 17 00:00:00 2001 From: lsnoel <52174215+lsnoel@users.noreply.github.com> Date: Thu, 19 Jan 2023 16:46:29 +0000 Subject: [PATCH 7/9] Correctly consider aiProcess_FlipWindingOrder AND aiProcess_MakeLeftHanded when generating normals --- code/PostProcessing/GenFaceNormalsProcess.cpp | 5 +++-- code/PostProcessing/GenFaceNormalsProcess.h | 1 + code/PostProcessing/GenVertexNormalsProcess.cpp | 5 +++-- code/PostProcessing/GenVertexNormalsProcess.h | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/code/PostProcessing/GenFaceNormalsProcess.cpp b/code/PostProcessing/GenFaceNormalsProcess.cpp index f104b98b6..0edbd9c6f 100644 --- a/code/PostProcessing/GenFaceNormalsProcess.cpp +++ b/code/PostProcessing/GenFaceNormalsProcess.cpp @@ -67,6 +67,7 @@ GenFaceNormalsProcess::~GenFaceNormalsProcess() = default; bool GenFaceNormalsProcess::IsActive(unsigned int pFlags) const { force_ = (pFlags & aiProcess_ForceGenNormals) != 0; flippedWindingOrder_ = (pFlags & aiProcess_FlipWindingOrder) != 0; + leftHanded_ = (pFlags & aiProcess_MakeLeftHanded) != 0; return (pFlags & aiProcess_GenNormals) != 0; } @@ -131,8 +132,8 @@ bool GenFaceNormalsProcess::GenMeshFaceNormals(aiMesh *pMesh) { const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]]; const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]]; const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]]; - if (flippedWindingOrder_) - std::swap( pV2, pV3 ); + if (flippedWindingOrder_ != leftHanded_) // Boolean XOR + std::swap(pV2, pV3); const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe(); for (unsigned int i = 0; i < face.mNumIndices; ++i) { diff --git a/code/PostProcessing/GenFaceNormalsProcess.h b/code/PostProcessing/GenFaceNormalsProcess.h index 586c4902e..c2f157e20 100644 --- a/code/PostProcessing/GenFaceNormalsProcess.h +++ b/code/PostProcessing/GenFaceNormalsProcess.h @@ -81,6 +81,7 @@ private: bool GenMeshFaceNormals(aiMesh* pcMesh); mutable bool force_ = false; mutable bool flippedWindingOrder_ = false; + mutable bool leftHanded_ = false; }; } // end of namespace Assimp diff --git a/code/PostProcessing/GenVertexNormalsProcess.cpp b/code/PostProcessing/GenVertexNormalsProcess.cpp index 0cb2bddb1..e9541c7d9 100644 --- a/code/PostProcessing/GenVertexNormalsProcess.cpp +++ b/code/PostProcessing/GenVertexNormalsProcess.cpp @@ -69,6 +69,7 @@ GenVertexNormalsProcess::~GenVertexNormalsProcess() = default; bool GenVertexNormalsProcess::IsActive(unsigned int pFlags) const { force_ = (pFlags & aiProcess_ForceGenNormals) != 0; flippedWindingOrder_ = (pFlags & aiProcess_FlipWindingOrder) != 0; + leftHanded_ = (pFlags & aiProcess_MakeLeftHanded) != 0; return (pFlags & aiProcess_GenSmoothNormals) != 0; } @@ -141,8 +142,8 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals(aiMesh *pMesh, unsigned int m const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]]; const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]]; const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]]; - if (flippedWindingOrder_) - std::swap( pV2, pV3 ); + if (flippedWindingOrder_ != leftHanded_) // Boolean XOR + std::swap(pV2, pV3); const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe(); for (unsigned int i = 0; i < face.mNumIndices; ++i) { diff --git a/code/PostProcessing/GenVertexNormalsProcess.h b/code/PostProcessing/GenVertexNormalsProcess.h index 0dcae793a..370bf42b1 100644 --- a/code/PostProcessing/GenVertexNormalsProcess.h +++ b/code/PostProcessing/GenVertexNormalsProcess.h @@ -105,6 +105,7 @@ private: ai_real configMaxAngle; mutable bool force_ = false; mutable bool flippedWindingOrder_ = false; + mutable bool leftHanded_ = false; }; } // end of namespace Assimp From 8d1256f472702cc22292abcb8bbd6f15b1edda64 Mon Sep 17 00:00:00 2001 From: lsnoel <52174215+lsnoel@users.noreply.github.com> Date: Fri, 20 Jan 2023 14:55:06 +0000 Subject: [PATCH 8/9] Comments about winding order fix for gen normals --- code/PostProcessing/GenFaceNormalsProcess.cpp | 4 +++- code/PostProcessing/GenVertexNormalsProcess.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/PostProcessing/GenFaceNormalsProcess.cpp b/code/PostProcessing/GenFaceNormalsProcess.cpp index 0edbd9c6f..d3520d4b2 100644 --- a/code/PostProcessing/GenFaceNormalsProcess.cpp +++ b/code/PostProcessing/GenFaceNormalsProcess.cpp @@ -132,7 +132,9 @@ bool GenFaceNormalsProcess::GenMeshFaceNormals(aiMesh *pMesh) { const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]]; const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]]; const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]]; - if (flippedWindingOrder_ != leftHanded_) // Boolean XOR + // Boolean XOR - if either but not both of these flags is set, then the winding order has + // changed and the cross product to calculate the normal needs to be reversed + if (flippedWindingOrder_ != leftHanded_) std::swap(pV2, pV3); const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe(); diff --git a/code/PostProcessing/GenVertexNormalsProcess.cpp b/code/PostProcessing/GenVertexNormalsProcess.cpp index e9541c7d9..5b9033383 100644 --- a/code/PostProcessing/GenVertexNormalsProcess.cpp +++ b/code/PostProcessing/GenVertexNormalsProcess.cpp @@ -142,7 +142,9 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals(aiMesh *pMesh, unsigned int m const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]]; const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]]; const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]]; - if (flippedWindingOrder_ != leftHanded_) // Boolean XOR + // Boolean XOR - if either but not both of these flags is set, then the winding order has + // changed and the cross product to calculate the normal needs to be reversed + if (flippedWindingOrder_ != leftHanded_) std::swap(pV2, pV3); const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe(); From eff13f6a40bb2cac50935bf9764595932373327e Mon Sep 17 00:00:00 2001 From: Steve M Date: Wed, 25 Jan 2023 20:52:25 -0800 Subject: [PATCH 9/9] Update morph mesh documentation now that gltf known to work --- include/assimp/anim.h | 5 ++++- include/assimp/mesh.h | 11 +++++++++-- port/PyAssimp/pyassimp/structs.py | 9 +++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/assimp/anim.h b/include/assimp/anim.h index edb048f50..49f0d5014 100644 --- a/include/assimp/anim.h +++ b/include/assimp/anim.h @@ -198,7 +198,10 @@ struct aiMeshMorphKey { /** The time of this key */ double mTime; - /** The values and weights at the time of this key */ + /** The values and weights at the time of this key + * - mValues: index of attachment mesh to apply weight at the same position in mWeights + * - mWeights: weight to apply to the blend shape index at the same position in mValues + */ unsigned int *mValues; double *mWeights; diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h index 363627464..c2d78a73c 100644 --- a/include/assimp/mesh.h +++ b/include/assimp/mesh.h @@ -737,13 +737,20 @@ struct aiMesh { **/ C_STRUCT aiString mName; - /** The number of attachment meshes. Note! Currently only works with Collada loader. */ + /** The number of attachment meshes. + * Currently known to work with loaders: + * - Collada + * - gltf + */ unsigned int mNumAnimMeshes; /** Attachment meshes for this mesh, for vertex-based animation. * Attachment meshes carry replacement data for some of the * mesh'es vertex components (usually positions, normals). - * Note! Currently only works with Collada loader.*/ + * Currently known to work with loaders: + * - Collada + * - gltf + */ C_STRUCT aiAnimMesh **mAnimMeshes; /** diff --git a/port/PyAssimp/pyassimp/structs.py b/port/PyAssimp/pyassimp/structs.py index e1fba1950..932998025 100644 --- a/port/PyAssimp/pyassimp/structs.py +++ b/port/PyAssimp/pyassimp/structs.py @@ -748,13 +748,18 @@ class Mesh(Structure): # - Vertex animations refer to meshes by their names. ("mName", String), - # The number of attachment meshes. Note! Currently only works with Collada loader. + # The number of attachment meshes. + # Currently known to work with loaders: + # - Collada + # - gltf ("mNumAnimMeshes", c_uint), # Attachment meshes for this mesh, for vertex-based animation. # Attachment meshes carry replacement data for some of the # mesh'es vertex components (usually positions, normals). - # Note! Currently only works with Collada loader. + # Currently known to work with loaders: + # - Collada + # - gltf ("mAnimMeshes", POINTER(POINTER(AnimMesh))), # Method of morphing when animeshes are specified.