From cb657e4c13f9ee9a8fd6eaf3f657c8a1abc8cb46 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 13 Dec 2021 18:06:23 +0100 Subject: [PATCH] Use correct XmlParser-methods and add some missing casts --- code/AssetLib/X3D/X3DImporter_Geometry3D.cpp | 2 +- code/AssetLib/glTF2/glTF2Exporter.cpp | 2 +- code/AssetLib/glTF2/glTF2Exporter.h | 3 +++ include/assimp/material.inl | 2 +- test/unit/utMaterialSystem.cpp | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/X3D/X3DImporter_Geometry3D.cpp b/code/AssetLib/X3D/X3DImporter_Geometry3D.cpp index 2db62dc64..b9fc2a4d8 100644 --- a/code/AssetLib/X3D/X3DImporter_Geometry3D.cpp +++ b/code/AssetLib/X3D/X3DImporter_Geometry3D.cpp @@ -879,7 +879,7 @@ void X3DImporter::readSphere(XmlNode &node) { X3DNodeElementBase *ne(nullptr); MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use); - XmlParser::getFloatAttribute(node, "radius", radius); + XmlParser::getRealAttribute(node, "radius", radius); XmlParser::getBoolAttribute(node, "solid", solid); // if "USE" defined then find already defined element. diff --git a/code/AssetLib/glTF2/glTF2Exporter.cpp b/code/AssetLib/glTF2/glTF2Exporter.cpp index e5c8b4530..606a4a919 100644 --- a/code/AssetLib/glTF2/glTF2Exporter.cpp +++ b/code/AssetLib/glTF2/glTF2Exporter.cpp @@ -1410,7 +1410,7 @@ void glTF2Exporter::ExportMetadata() { } } -inline Ref GetSamplerInputRef(Asset &asset, std::string &animId, Ref &buffer, std::vector ×) { +inline Ref GetSamplerInputRef(Asset &asset, std::string &animId, Ref &buffer, std::vector ×) { return ExportData(asset, animId, buffer, (unsigned int)times.size(), ×[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT); } diff --git a/code/AssetLib/glTF2/glTF2Exporter.h b/code/AssetLib/glTF2/glTF2Exporter.h index 6d70d915e..d328f8a80 100644 --- a/code/AssetLib/glTF2/glTF2Exporter.h +++ b/code/AssetLib/glTF2/glTF2Exporter.h @@ -66,7 +66,9 @@ class Ref; } namespace glTF2 { + class Asset; + struct TexProperty; struct TextureInfo; struct NormalTextureInfo; @@ -84,6 +86,7 @@ struct MaterialIOR; typedef float(vec2)[2]; typedef float(vec3)[3]; typedef float(vec4)[4]; + } // namespace glTF2 namespace Assimp { diff --git a/include/assimp/material.inl b/include/assimp/material.inl index 693785c3c..27f17ec28 100644 --- a/include/assimp/material.inl +++ b/include/assimp/material.inl @@ -105,7 +105,7 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type, return AI_FAILURE; } - iNum = std::min((size_t)iNum,prop->mDataLength / sizeof(Type)); + iNum = (unsigned int)std::min((size_t)iNum,prop->mDataLength / sizeof(Type)); ::memcpy(pOut,prop->mData,iNum * sizeof(Type)); if (pMax) { *pMax = iNum; diff --git a/test/unit/utMaterialSystem.cpp b/test/unit/utMaterialSystem.cpp index 8db014d9c..6f1be1608 100644 --- a/test/unit/utMaterialSystem.cpp +++ b/test/unit/utMaterialSystem.cpp @@ -73,7 +73,7 @@ TEST_F(MaterialSystemTest, testFloatArrayProperty) { pf[0] = pf[1] = pf[2] = pf[3] = 12.0f; EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2", 0, 0, pf, &pMax)); - EXPECT_EQ(sizeof(pf) / sizeof(float), pMax); + EXPECT_EQ(sizeof(pf) / sizeof(float), static_cast(pMax)); EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3]); }