From 0359ded94621a4bbba6a021ee5d62314916f6bd2 Mon Sep 17 00:00:00 2001 From: Alexandr Arutjunov Date: Fri, 7 Oct 2016 16:40:51 +0300 Subject: [PATCH 01/10] [F] Checking directive name with start from symbol 'm'. And checking argument of 'mtllib'. --- code/ObjFileParser.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 49dce5108..9b13eea6f 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -182,10 +182,15 @@ void ObjFileParser::parseFile() case 'm': // Parse a material library or merging group ('mg') { - if (*(m_DataIt + 1) == 'g') + std::string name; + + getName(m_DataIt, m_DataItEnd, name); + if (name == "mg") getGroupNumberAndResolution(); - else + else if(name == "mtllib") getMaterialLib(); + else + goto pf_skip_line; } break; @@ -209,6 +214,8 @@ void ObjFileParser::parseFile() default: { +pf_skip_line: + m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } break; @@ -625,6 +632,10 @@ void ObjFileParser::getMaterialLib() // Check for existence const std::string strMatName(pStart, &(*m_DataIt)); std::string absName; + + // Check if directive is valid. + if(!strMatName.length()) throw DeadlyImportError("File name of the material is absent."); + if ( m_pIO->StackSize() > 0 ) { std::string path = m_pIO->CurrentDirectory(); if ( '/' != *path.rbegin() ) { From b8380700366469542462266ee3f833d45a34801b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 9 Oct 2016 01:32:31 +0200 Subject: [PATCH 02/10] Update setup script. --- packaging/windows-innosetup/script.iss | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packaging/windows-innosetup/script.iss b/packaging/windows-innosetup/script.iss index a4bc0bf78..d8e0d082a 100644 --- a/packaging/windows-innosetup/script.iss +++ b/packaging/windows-innosetup/script.iss @@ -2,7 +2,7 @@ [Setup] AppName=Open Asset Import Library - SDK -AppVerName=Open Asset Import Library - SDK (v2.0) +AppVerName=Open Asset Import Library - SDK (v3.3.1) DefaultDirName={pf}\Assimp DefaultGroupName=Assimp UninstallDisplayIcon={app}\bin\x86\assimp.exe @@ -12,9 +12,9 @@ SetupIconFile=..\..\tools\shared\assimp_tools_icon.ico WizardImageFile=compiler:WizModernImage-IS.BMP WizardSmallImageFile=compiler:WizModernSmallImage-IS.BMP LicenseFile=License.rtf -OutputBaseFileName=assimp-sdk-2.0-setup -VersionInfoVersion=2.0.0.0 -VersionInfoTextVersion=2.0 +OutputBaseFileName=assimp-sdk-3.3.1-setup +VersionInfoVersion=3.3.1.0 +VersionInfoTextVersion=3.3.1 VersionInfoCompany=Assimp Development Team ArchitecturesInstallIn64BitMode=x64 @@ -38,8 +38,8 @@ Name: "assimp_net"; Description: "C#/.NET Bindings"; Types: full ;Name: "vc9"; Description: "VC9 project files"; Types: full [Run] -Filename: "{app}\stub\vcredist_x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2008 SP1 redistributable package (32 Bit)"; Check: not IsWin64 -Filename: "{app}\stub\vcredist_x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2008 SP1 redistributable package (64 Bit)"; Check: IsWin64 +Filename: "{app}\stub\vcredist_x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2012 SP1 redistributable package (32 Bit)"; Check: not IsWin64 +Filename: "{app}\stub\vcredist_x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2012 SP1 redistributable package (64 Bit)"; Check: IsWin64 [Files] From 1c78f1be0366a8df2b231d341dcf974a7a22efc6 Mon Sep 17 00:00:00 2001 From: Sergey Kosarevsky Date: Mon, 10 Oct 2016 17:58:06 +0200 Subject: [PATCH 03/10] Fixed: unzip.h was still included even if the D3MF importer is disabled --- code/D3MFImporter.cpp | 8 ++++---- code/D3MFOpcPackage.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/code/D3MFImporter.cpp b/code/D3MFImporter.cpp index 045138be1..32b87003a 100644 --- a/code/D3MFImporter.cpp +++ b/code/D3MFImporter.cpp @@ -44,8 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include -#include "irrXMLWrapper.h" #include "StringComparison.h" #include "StringUtils.h" @@ -61,10 +59,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "D3MFOpcPackage.h" - #ifndef ASSIMP_BUILD_NO_3MF_IMPORTER +#include "D3MFOpcPackage.h" +#include +#include "irrXMLWrapper.h" + namespace Assimp { namespace D3MF { diff --git a/code/D3MFOpcPackage.cpp b/code/D3MFOpcPackage.cpp index f01ca7e0f..2e63a346e 100644 --- a/code/D3MFOpcPackage.cpp +++ b/code/D3MFOpcPackage.cpp @@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "D3MFOpcPackage.h" #include "Exceptional.h" -#include #include #include #include @@ -57,6 +56,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_3MF_IMPORTER +#include + namespace Assimp { namespace D3MF { From 96a64a353ae814cc5d9ca10ec977f246a1def80c Mon Sep 17 00:00:00 2001 From: amit512 Date: Tue, 11 Oct 2016 13:04:41 +0300 Subject: [PATCH 04/10] fix bug when reading strings in quote in MD5 models --- code/MD5Parser.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/code/MD5Parser.cpp b/code/MD5Parser.cpp index df666751b..9379deab1 100644 --- a/code/MD5Parser.cpp +++ b/code/MD5Parser.cpp @@ -195,7 +195,7 @@ bool MD5Parser::ParseSection(Section& out) #define AI_MD5_SKIP_SPACES() if(!SkipSpaces(&sz)) \ MD5Parser::ReportWarning("Unexpected end of line",elem.iLineNumber); - // read a triple float in brackets: (1.0 1.0 1.0) + // read a triple float in brackets: (1.0 1.0 1.0) #define AI_MD5_READ_TRIPLE(vec) \ AI_MD5_SKIP_SPACES(); \ if ('(' != *sz++) \ @@ -210,7 +210,7 @@ bool MD5Parser::ParseSection(Section& out) if (')' != *sz++) \ MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber); - // parse a string, enclosed in quotation marks or not + // parse a string, enclosed in quotation marks or not #define AI_MD5_PARSE_STRING(out) \ bool bQuota = (*sz == '\"'); \ const char* szStart = sz; \ @@ -228,6 +228,15 @@ bool MD5Parser::ParseSection(Section& out) ::memcpy(out.data,szStart,out.length); \ out.data[out.length] = '\0'; + // parse a string, enclosed in quotation marks +#define AI_MD5_PARSE_STRING_IN_QUOTATION(out) \ + while('\"'!=*sz)++sz; \ + const char* szStart = ++sz; \ + while('\"'!=*sz)++sz; \ + const char* szEnd = (sz++); \ + out.length = (size_t)(szEnd - szStart); \ + ::memcpy(out.data,szStart,out.length); \ + out.data[out.length] = '\0'; // ------------------------------------------------------------------------------------------------ // .MD5MESH parsing function MD5MeshParser::MD5MeshParser(SectionList& mSections) @@ -247,9 +256,9 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections) for (const auto & elem : (*iter).mElements){ mJoints.push_back(BoneDesc()); BoneDesc& desc = mJoints.back(); - + const char* sz = elem.szStart; - AI_MD5_PARSE_STRING(desc.mName); + AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName); AI_MD5_SKIP_SPACES(); // negative values, at least -1, is allowed here @@ -269,7 +278,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections) // shader attribute if (TokenMatch(sz,"shader",6)) { AI_MD5_SKIP_SPACES(); - AI_MD5_PARSE_STRING(desc.mShader); + AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mShader); } // numverts attribute else if (TokenMatch(sz,"numverts",8)) { @@ -362,7 +371,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) AnimBoneDesc& desc = mAnimatedBones.back(); const char* sz = elem.szStart; - AI_MD5_PARSE_STRING(desc.mName); + AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName); AI_MD5_SKIP_SPACES(); // parent index - negative values are allowed (at least -1) From 3b6ffc3ef57b82a5de17b281a5ea1ffbcff44166 Mon Sep 17 00:00:00 2001 From: Eshed Date: Sat, 15 Oct 2016 03:52:50 +0300 Subject: [PATCH 05/10] fix mingw build (mingw supports stat64 nowadays) --- code/DefaultIOStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/DefaultIOStream.cpp b/code/DefaultIOStream.cpp index e9da3ff70..11bad9b64 100644 --- a/code/DefaultIOStream.cpp +++ b/code/DefaultIOStream.cpp @@ -120,7 +120,7 @@ size_t DefaultIOStream::FileSize() const // // See here for details: // https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file -#if defined _WIN32 && !defined __GNUC__ +#if defined _WIN32 struct __stat64 fileStat; int err = _stat64( mFilename.c_str(), &fileStat ); if (0 != err) From b90669c45e98d9770b6c040a035db9ee5278e22f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 15 Oct 2016 20:36:51 +0200 Subject: [PATCH 06/10] C++11: Replace std::to_string by assimp-specific implementation. --- code/X3DImporter.cpp | 1 + code/X3DImporter_Postprocess.cpp | 21 +++++++++++---------- code/glTFAsset.inl | 3 +-- code/glTFImporter.cpp | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/code/X3DImporter.cpp b/code/X3DImporter.cpp index 024eedb28..8c9f75f8b 100644 --- a/code/X3DImporter.cpp +++ b/code/X3DImporter.cpp @@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "X3DImporter.hpp" #include "X3DImporter_Macro.hpp" +#include "StringUtils.h" // Header files, Assimp. #include "DefaultIOSystem.h" diff --git a/code/X3DImporter_Postprocess.cpp b/code/X3DImporter_Postprocess.cpp index 37acb0fe8..95f40ef9f 100644 --- a/code/X3DImporter_Postprocess.cpp +++ b/code/X3DImporter_Postprocess.cpp @@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Header files, Assimp. #include "StandardShapes.h" +#include "StringUtils.h" // Header files, stdlib. #include @@ -296,7 +297,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) MeshGeometry_AddTexCoord(**pMesh, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); else - throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of ElevationGrid: " + std::to_string((*ch_it)->Type) + "."); + throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of ElevationGrid: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) return;// mesh is build, nothing to do anymore. @@ -333,7 +334,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); else - throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedFaceSet: " + std::to_string((*ch_it)->Type) + "."); + throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedFaceSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) return;// mesh is build, nothing to do anymore. @@ -401,7 +402,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); else throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedTriangleSet or IndexedTriangleFanSet, or \ - IndexedTriangleStripSet: " + std::to_string((*ch_it)->Type) + "."); + IndexedTriangleStripSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) return;// mesh is build, nothing to do anymore. @@ -451,7 +452,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) {} // skip because already read when mesh created. else - throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of PointSet: " + std::to_string((*ch_it)->Type) + "."); + throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of PointSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) return;// mesh is build, nothing to do anymore. @@ -480,7 +481,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) {} // skip because already read when mesh created. else - throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of LineSet: " + std::to_string((*ch_it)->Type) + "."); + throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of LineSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) return;// mesh is build, nothing to do anymore. @@ -514,7 +515,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); else - throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeFanSet: " + std::to_string((*ch_it)->Type) + "."); + throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeFanSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) return;// mesh is build, nothing to do anymore. @@ -557,7 +558,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); else - throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeSet: " + std::to_string((*ch_it)->Type) + "."); + throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) return;// mesh is build, nothing to do anymore. @@ -591,13 +592,13 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate) MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value); else - throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TriangleStripSet: " + std::to_string((*ch_it)->Type) + "."); + throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TriangleStripSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) return;// mesh is build, nothing to do anymore. }// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleStripSet) - throw DeadlyImportError("Postprocess_BuildMesh. Unknown mesh type: " + std::to_string(pNodeElement.Type) + "."); + throw DeadlyImportError("Postprocess_BuildMesh. Unknown mesh type: " + to_string(pNodeElement.Type) + "."); } void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list& pSceneMeshList, @@ -659,7 +660,7 @@ void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeEle } else if(!PostprocessHelper_ElementIsMetadata((*it)->Type))// skip metadata { - throw DeadlyImportError("Postprocess_BuildNode. Unknown type: " + std::to_string((*it)->Type) + "."); + throw DeadlyImportError("Postprocess_BuildNode. Unknown type: " + to_string((*it)->Type) + "."); } }// for(std::list::const_iterator it = chit_begin; it != chit_end; it++) diff --git a/code/glTFAsset.inl b/code/glTFAsset.inl index 4b2f72969..fcaf4235d 100644 --- a/code/glTFAsset.inl +++ b/code/glTFAsset.inl @@ -1003,8 +1003,7 @@ Ref buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer); { // size = number_of_elements * components_per_element * size_of_component. See float attributes note. size_t tval = ifs.GetNIntAttribute(idx); - - switch(ifs.GetIntAttributeType(idx)) + switch( ifs.GetIntAttributeType( idx ) ) { default: throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + std::to_string(ifs.GetIntAttributeType(idx))); diff --git a/code/glTFImporter.cpp b/code/glTFImporter.cpp index 288cfd883..4867a9e09 100644 --- a/code/glTFImporter.cpp +++ b/code/glTFImporter.cpp @@ -41,8 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER #include "glTFImporter.h" - #include "StringComparison.h" +#include "StringUtils.h" #include #include @@ -285,7 +285,7 @@ void glTFImporter::ImportMeshes(glTF::Asset& r) else #endif { - throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + std::to_string(cur_ext->Type) + + throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + to_string(cur_ext->Type) + "\"), only Open3DGC is supported."); } } From e0dde73018eeee2bf530c0b3178971976261003c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 15 Oct 2016 21:25:16 +0200 Subject: [PATCH 07/10] C++11-combat: replace more std::to_string by assimp-specific to_string --- code/X3DImporter.cpp | 104 +++++++++++++++++++------------ code/X3DImporter_Light.cpp | 10 +-- code/X3DImporter_Postprocess.cpp | 4 +- code/XFileParser.cpp | 2 +- code/glTFAsset.inl | 20 +++--- code/glTFAssetWriter.inl | 2 +- code/glTFExporter.cpp | 35 +++++------ 7 files changed, 99 insertions(+), 78 deletions(-) diff --git a/code/X3DImporter.cpp b/code/X3DImporter.cpp index 8c9f75f8b..a552af169 100644 --- a/code/X3DImporter.cpp +++ b/code/X3DImporter.cpp @@ -56,11 +56,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -namespace Assimp -{ +namespace Assimp { /// \var aiImporterDesc X3DImporter::Description -/// Conastant which hold importer description +/// Constant which holds the importer description const aiImporterDesc X3DImporter::Description = { "Extensible 3D(X3D) Importer", "smalcom", @@ -88,7 +87,7 @@ void X3DImporter::Clear() X3DImporter::~X3DImporter() { - if(mReader != nullptr) delete mReader; + delete mReader; // Clear() is accounting if data already is deleted. So, just check again if all data is deleted. Clear(); } @@ -115,13 +114,16 @@ bool X3DImporter::FindNodeElement_FromRoot(const std::string& pID, const CX3DImp bool X3DImporter::FindNodeElement_FromNode(CX3DImporter_NodeElement* pStartNode, const std::string& pID, const CX3DImporter_NodeElement::EType pType, CX3DImporter_NodeElement** pElement) { -bool found = false;// flag: true - if requested element is found. + bool found = false;// flag: true - if requested element is found. // Check if pStartNode - this is the element, we are looking for. if((pStartNode->Type == pType) && (pStartNode->ID == pID)) { found = true; - if(pElement != nullptr) *pElement = pStartNode; + if ( pElement != nullptr ) + { + *pElement = pStartNode; + } goto fne_fn_end; }// if((pStartNode->Type() == pType) && (pStartNode->ID() == pID)) @@ -130,7 +132,10 @@ bool found = false;// flag: true - if requested element is found. for(std::list::iterator ch_it = pStartNode->Child.begin(); ch_it != pStartNode->Child.end(); ch_it++) { found = FindNodeElement_FromNode(*ch_it, pID, pType, pElement); - if(found) break; + if ( found ) + { + break; + } }// for(std::list::iterator ch_it = it->Child.begin(); ch_it != it->Child.end(); ch_it++) fne_fn_end: @@ -151,7 +156,6 @@ bool X3DImporter::FindNodeElement(const std::string& pID, const CX3DImporter_Nod if(((CX3DImporter_NodeElement_Group*)tnd)->Static) { static_search = true;// Flag found, stop walking up. Node with static flag will holded in tnd variable. - break; } } @@ -160,10 +164,14 @@ bool X3DImporter::FindNodeElement(const std::string& pID, const CX3DImporter_Nod }// while(tnd != nullptr) // at now call appropriate search function. - if(static_search) - return FindNodeElement_FromNode(tnd, pID, pType, pElement); - else - return FindNodeElement_FromRoot(pID, pType, pElement); + if ( static_search ) + { + return FindNodeElement_FromNode( tnd, pID, pType, pElement ); + } + else + { + return FindNodeElement_FromRoot( pID, pType, pElement ); + } } /*********************************************************************************************************************************************/ @@ -969,8 +977,8 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list& // check indices array count. if(pColorIdx.size() < pCoordIdx.size()) { - throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + std::to_string(pColorIdx.size()) + - ") can not be less than Coords inidces count(" + std::to_string(pCoordIdx.size()) + ")."); + throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + to_string(pColorIdx.size()) + + ") can not be less than Coords inidces count(" + to_string(pCoordIdx.size()) + ")."); } // create list with colors for every vertex. col_tgt_arr.resize(pMesh.mNumVertices); for(std::list::const_iterator colidx_it = pColorIdx.begin(), coordidx_it = pCoordIdx.begin(); colidx_it != pColorIdx.end(); colidx_it++, coordidx_it++) { - if(*colidx_it == (-1)) continue;// skip faces delimiter - if((unsigned int)(*coordidx_it) > pMesh.mNumVertices) throw DeadlyImportError("MeshGeometry_AddColor2. Coordinate idx is out of range."); - if((unsigned int)*colidx_it > pMesh.mNumVertices) throw DeadlyImportError("MeshGeometry_AddColor2. Color idx is out of range."); + if ( *colidx_it == ( -1 ) ) + { + continue;// skip faces delimiter + } + if ( ( unsigned int ) ( *coordidx_it ) > pMesh.mNumVertices ) + { + throw DeadlyImportError( "MeshGeometry_AddColor2. Coordinate idx is out of range." ); + } + if ( ( unsigned int ) *colidx_it > pMesh.mNumVertices ) + { + throw DeadlyImportError( "MeshGeometry_AddColor2. Color idx is out of range." ); + } col_tgt_arr[*coordidx_it] = col_arr_copy[*colidx_it]; } @@ -1063,7 +1083,10 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list& } // create list with colors for every vertex. col_tgt_arr.resize(pMesh.mNumVertices); - for(size_t i = 0; i < pMesh.mNumVertices; i++) col_tgt_arr[i] = col_arr_copy[i]; + for ( size_t i = 0; i < pMesh.mNumVertices; i++ ) + { + col_tgt_arr[ i ] = col_arr_copy[ i ]; + } }// if(pColorIdx.size() > 0) else }// if(pColorPerVertex) else @@ -1149,8 +1172,8 @@ void X3DImporter::MeshGeometry_AddNormal(aiMesh& pMesh, const std::list for(size_t i = 0; (i < pMesh.mNumVertices) && (i < tind.size()); i++) { if(tind[i] >= norm_arr_copy.size()) - throw DeadlyImportError("MeshGeometry_AddNormal. Normal index(" + std::to_string(tind[i]) + - ") is out of range. Normals count: " + std::to_string(norm_arr_copy.size()) + "."); + throw DeadlyImportError("MeshGeometry_AddNormal. Normal index(" + to_string(tind[i]) + + ") is out of range. Normals count: " + to_string(norm_arr_copy.size()) + "."); pMesh.mNormals[i] = norm_arr_copy[tind[i]]; } @@ -1289,10 +1312,8 @@ void X3DImporter::MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::list& pCoordIdx, const std::list& pVertices) const { - aiMesh* tmesh( nullptr ); std::vector faces; unsigned int prim_type = 0; - size_t ts; // create faces array from input string with vertices indices. GeometryHelper_CoordIdxStr2FacesArr(pCoordIdx, faces, prim_type); @@ -1304,8 +1325,8 @@ aiMesh* X3DImporter::GeometryHelper_MakeMesh(const std::list& pCoordIdx // // Create new mesh and copy geometry data. // - tmesh = new aiMesh; - ts = faces.size(); + aiMesh *tmesh = new aiMesh; + size_t ts = faces.size(); // faces tmesh->mFaces = new aiFace[ts]; tmesh->mNumFaces = ts; @@ -1458,7 +1479,7 @@ void X3DImporter::ParseNode_Head() { XML_CheckNode_MustBeEmpty(); - // adding metada from as MetaString from + // adding metadata from as MetaString from CX3DImporter_NodeElement_MetaString* ms = new CX3DImporter_NodeElement_MetaString(NodeElement_Cur); ms->Name = mReader->getAttributeValueSafe("name"); @@ -1467,8 +1488,10 @@ void X3DImporter::ParseNode_Head() { ms->Value.push_back(mReader->getAttributeValueSafe("content")); NodeElement_List.push_back(ms); - if(NodeElement_Cur != nullptr) NodeElement_Cur->Child.push_back(ms); - + if ( NodeElement_Cur != nullptr ) + { + NodeElement_Cur->Child.push_back( ms ); + } } }// if(XML_CheckNode_NameEqual("meta")) }// if(mReader->getNodeType() == irr::io::EXN_ELEMENT) @@ -1477,14 +1500,15 @@ void X3DImporter::ParseNode_Head() if(XML_CheckNode_NameEqual("head")) { close_found = true; - break; } }// if(mReader->getNodeType() == irr::io::EXN_ELEMENT) else }// while(mReader->read()) - if(!close_found) Throw_CloseNotFound("head"); - + if ( !close_found ) + { + Throw_CloseNotFound( "head" ); + } } void X3DImporter::ParseNode_Scene() @@ -1502,10 +1526,10 @@ auto GroupCounter_Decrease = [&](size_t& pCounter, const char* pGroupName) -> vo pCounter--; }; -const char* GroupName_Group = "Group"; -const char* GroupName_StaticGroup = "StaticGroup"; -const char* GroupName_Transform = "Transform"; -const char* GroupName_Switch = "Switch"; +static const char* GroupName_Group = "Group"; +static const char* GroupName_StaticGroup = "StaticGroup"; +static const char* GroupName_Transform = "Transform"; +static const char* GroupName_Switch = "Switch"; bool close_found = false; size_t counter_group = 0; @@ -1551,7 +1575,7 @@ size_t counter_switch = 0; if(mReader->isEmptyElement()) GroupCounter_Decrease(counter_switch, GroupName_Switch); } else if(XML_CheckNode_NameEqual("DirectionalLight")) - { + { ParseNode_Lighting_DirectionalLight(); } else if(XML_CheckNode_NameEqual("PointLight")) diff --git a/code/X3DImporter_Light.cpp b/code/X3DImporter_Light.cpp index 1816696d1..54f56e76e 100644 --- a/code/X3DImporter_Light.cpp +++ b/code/X3DImporter_Light.cpp @@ -46,9 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "X3DImporter.hpp" #include "X3DImporter_Macro.hpp" +#include "StringUtils.h" -namespace Assimp -{ +namespace Assimp { // ID = def; else - ne->ID = "DirectionalLight_" + std::to_string((size_t)ne);// make random name + ne->ID = "DirectionalLight_" + to_string((size_t)ne);// make random name ((CX3DImporter_NodeElement_Light*)ne)->AmbientIntensity = ambientIntensity; ((CX3DImporter_NodeElement_Light*)ne)->Color = color; @@ -178,7 +178,7 @@ void X3DImporter::ParseNode_Lighting_PointLight() // Assimp want a node with name similar to a light. "Why? I don't no." ) ParseHelper_Group_Begin(false); // make random name - if(ne->ID.empty()) ne->ID = "PointLight_" + std::to_string((size_t)ne); + if(ne->ID.empty()) ne->ID = "PointLight_" + to_string((size_t)ne); NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element. ParseHelper_Node_Exit(); @@ -268,7 +268,7 @@ void X3DImporter::ParseNode_Lighting_SpotLight() // Assimp want a node with name similar to a light. "Why? I don't no." ) ParseHelper_Group_Begin(false); // make random name - if(ne->ID.empty()) ne->ID = "SpotLight_" + std::to_string((size_t)ne); + if(ne->ID.empty()) ne->ID = "SpotLight_" + to_string((size_t)ne); NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element. ParseHelper_Node_Exit(); diff --git a/code/X3DImporter_Postprocess.cpp b/code/X3DImporter_Postprocess.cpp index 95f40ef9f..c3ac102dd 100644 --- a/code/X3DImporter_Postprocess.cpp +++ b/code/X3DImporter_Postprocess.cpp @@ -175,7 +175,7 @@ void X3DImporter::Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeEl break; default: - throw DeadlyImportError("Postprocess_BuildLight. Unknown type of light: " + std::to_string(pNodeElement.Type) + "."); + throw DeadlyImportError("Postprocess_BuildLight. Unknown type of light: " + to_string(pNodeElement.Type) + "."); } pSceneLightList.push_back(new_light); @@ -364,7 +364,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate) {} // skip because already read when mesh created. else - throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedLineSet: " + std::to_string((*ch_it)->Type) + "."); + throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedLineSet: " + to_string((*ch_it)->Type) + "."); }// for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) return;// mesh is build, nothing to do anymore. diff --git a/code/XFileParser.cpp b/code/XFileParser.cpp index 7c47ae7fd..83d017d92 100644 --- a/code/XFileParser.cpp +++ b/code/XFileParser.cpp @@ -731,7 +731,7 @@ void XFileParser::ParseDataObjectMaterial( Material* pMaterial) std::string matName; readHeadOfDataObject( &matName); if( matName.empty()) - matName = std::string( "material") + std::to_string( mLineNumber ); + matName = std::string( "material") + to_string( mLineNumber ); pMaterial->mName = matName; pMaterial->mIsReference = false; diff --git a/code/glTFAsset.inl b/code/glTFAsset.inl index fcaf4235d..a7afb3424 100644 --- a/code/glTFAsset.inl +++ b/code/glTFAsset.inl @@ -292,14 +292,14 @@ inline void Buffer::Read(Value& obj, Asset& r) this->mData.reset(data); if (statedLength > 0 && this->byteLength != statedLength) { - throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + std::to_string(statedLength) + - " bytes, but found " + std::to_string(dataURI.dataLength)); + throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + to_string(statedLength) + + " bytes, but found " + to_string(dataURI.dataLength)); } } else { // assume raw data if (statedLength != dataURI.dataLength) { - throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + std::to_string(statedLength) + - " bytes, but found " + std::to_string(dataURI.dataLength)); + throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + to_string(statedLength) + + " bytes, but found " + to_string(dataURI.dataLength)); } this->mData.reset(new uint8_t[dataURI.dataLength]); @@ -991,7 +991,7 @@ Ref buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer); break; default: - throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of float attribute: " + std::to_string(ifs.GetFloatAttributeType(idx))); + throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of float attribute: " + to_string(ifs.GetFloatAttributeType(idx))); } tval *= ifs.GetFloatAttributeDim(idx) * sizeof(o3dgc::Real);// After checking count of objects we can get size of array. @@ -1006,7 +1006,7 @@ Ref buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer); switch( ifs.GetIntAttributeType( idx ) ) { default: - throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + std::to_string(ifs.GetIntAttributeType(idx))); + throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + to_string(ifs.GetIntAttributeType(idx))); } tval *= ifs.GetIntAttributeDim(idx) * sizeof(long);// See float attributes note. @@ -1045,7 +1045,7 @@ Ref buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer); break; default: - throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of float attribute: " + std::to_string(ifs.GetFloatAttributeType(idx))); + throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of float attribute: " + to_string(ifs.GetFloatAttributeType(idx))); } } @@ -1055,7 +1055,7 @@ Ref buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer); { // ifs.SetIntAttribute(idx, (long* const)(decoded_data + get_buf_offset(primitives[0].attributes.joint))); default: - throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + std::to_string(ifs.GetIntAttributeType(idx))); + throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + to_string(ifs.GetIntAttributeType(idx))); } } @@ -1620,6 +1620,4 @@ namespace Util { } -} - - +} // ns glTF diff --git a/code/glTFAssetWriter.inl b/code/glTFAssetWriter.inl index 312213096..0e7a71eb5 100644 --- a/code/glTFAssetWriter.inl +++ b/code/glTFAssetWriter.inl @@ -65,7 +65,7 @@ namespace glTF { inline Value& MakeValue(Value& val, const std::vector & r, MemoryPoolAllocator<>& al) { val.SetArray(); val.Reserve(r.size(), al); - for (int i = 0; i < r.size(); ++i) { + for (unsigned int i = 0; i < r.size(); ++i) { val.PushBack(r[i], al); } return val; diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index 90c74f30e..2db050b81 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -204,30 +204,29 @@ inline Ref ExportData(Asset& a, std::string& meshName, Ref& bu // calculate min and max values { // Allocate and initialize with large values. - float float_MAX = 10000000000000; - for (int i = 0 ; i < numCompsOut ; i++) { + float float_MAX = 10000000000000.0f; + for (unsigned int i = 0 ; i < numCompsOut ; i++) { acc->min.push_back( float_MAX); acc->max.push_back(-float_MAX); } // Search and set extreme values. float valueTmp; - for (int i = 0 ; i < count ; i++) { - for (int j = 0 ; j < numCompsOut ; j++) { + for (unsigned int i = 0 ; i < count ; i++) { + for (unsigned int j = 0 ; j < numCompsOut ; j++) { + if (numCompsOut == 1) { + valueTmp = static_cast(data)[i]; + } else { + valueTmp = static_cast(data)[i][j]; + } - if (numCompsOut == 1) { - valueTmp = static_cast(data)[i]; - } else { - valueTmp = static_cast(data)[i][j]; + if (valueTmp < acc->min[j]) { + acc->min[j] = valueTmp; + } + if (valueTmp > acc->max[j]) { + acc->max[j] = valueTmp; + } } - - if (valueTmp < acc->min[j]) { - acc->min[j] = valueTmp; - } - if (valueTmp > acc->max[j]) { - acc->max[j] = valueTmp; - } - } } } @@ -449,7 +448,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aim, Ref& meshRef, RefmName =====> skinRef->jointNames // Find the node with id = mName. Ref nodeRef = mAsset.nodes.Get(aib->mName.C_Str()); - nodeRef->jointName = "joint_" + std::to_string(idx_bone); + nodeRef->jointName = "joint_" + to_string(idx_bone); skinRef->jointNames.push_back(nodeRef); // Identity Matrix =====> skinRef->bindShapeMatrix @@ -840,7 +839,7 @@ void glTFExporter::ExportAnimations() // It appears that assimp stores this type of animation as multiple animations. // where each aiNodeAnim in mChannels animates a specific node. - std::string name = nameAnim + "_" + std::to_string(channelIndex); + std::string name = nameAnim + "_" + to_string(channelIndex); name = mAsset->FindUniqueID(name, "animation"); Ref animRef = mAsset->animations.Create(name); From 7681089abc66712e844c01220918690d75c8941d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 15 Oct 2016 21:30:02 +0200 Subject: [PATCH 08/10] C++11-Combat: last replacements of std::to_string. --- code/StringUtils.h | 3 ++- code/X3DExporter.cpp | 1 + code/X3DImporter.cpp | 16 ++++++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/code/StringUtils.h b/code/StringUtils.h index 99352ebfb..15f7db2e7 100644 --- a/code/StringUtils.h +++ b/code/StringUtils.h @@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include @@ -103,7 +104,7 @@ float ai_strtof( const char *begin, const char *end ) { std::string token( begin, len ); val = static_cast< float >( ::atof( token.c_str() ) ); } - + return val; } diff --git a/code/X3DExporter.cpp b/code/X3DExporter.cpp index 05128880f..cb6a6740f 100644 --- a/code/X3DExporter.cpp +++ b/code/X3DExporter.cpp @@ -10,6 +10,7 @@ // Header files, Assimp. #include "Exceptional.h" +#include "StringUtils.h" #include #include diff --git a/code/X3DImporter.cpp b/code/X3DImporter.cpp index a552af169..878017dd4 100644 --- a/code/X3DImporter.cpp +++ b/code/X3DImporter.cpp @@ -795,7 +795,7 @@ void X3DImporter::GeometryHelper_Make_Arc2D(const float pStartAngle, const float { Throw_ArgOutOfRange( "GeometryHelper_Make_Arc2D.pStartAngle" ); } - if ( ( pEndAngle < -AI_MATH_TWO_PI_F ) || ( pEndAngle > AI_MATH_TWO_PI_F ) ) + if ( ( pEndAngle < -AI_MATH_TWO_PI_F ) || ( pEndAngle > AI_MATH_TWO_PI_F ) ) { Throw_ArgOutOfRange( "GeometryHelper_Make_Arc2D.pEndAngle" ); } @@ -1078,8 +1078,8 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list& // check indices array count. if(pColors.size() < pMesh.mNumVertices) { - throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Vertices count(" + - std::to_string(pMesh.mNumVertices) + ")."); + throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + to_string(pColors.size()) + ") can not be less than Vertices count(" + + to_string(pMesh.mNumVertices) + ")."); } // create list with colors for every vertex. col_tgt_arr.resize(pMesh.mNumVertices); @@ -1096,8 +1096,8 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list& // check indices array count. if(pColorIdx.size() < pMesh.mNumFaces) { - throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + std::to_string(pColorIdx.size()) + - ") can not be less than Faces count(" + std::to_string(pMesh.mNumFaces) + ")."); + throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + to_string(pColorIdx.size()) + + ") can not be less than Faces count(" + to_string(pMesh.mNumFaces) + ")."); } // create list with colors for every vertex using faces indices. col_tgt_arr.resize(pMesh.mNumFaces); @@ -1116,8 +1116,8 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list& // check indices array count. if(pColors.size() < pMesh.mNumFaces) { - throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Faces count(" + - std::to_string(pMesh.mNumFaces) + ")."); + throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + to_string(pColors.size()) + ") can not be less than Faces count(" + + to_string(pMesh.mNumFaces) + ")."); } // create list with colors for every vertex using faces indices. col_tgt_arr.resize(pMesh.mNumFaces); @@ -1273,7 +1273,7 @@ void X3DImporter::MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::list Date: Sat, 15 Oct 2016 21:45:09 +0200 Subject: [PATCH 09/10] OpenGEXImporter: fix compiler warning. --- code/OpenGEXImporter.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index 3ce53c481..1a4d511c4 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -124,7 +124,7 @@ namespace Grammar { MaterialToken, ColorToken, ParamToken, - TextureToken, + TextureToken, AttenToken }; @@ -237,7 +237,7 @@ OpenGEXImporter::VertexContainer::~VertexContainer() { delete[] m_vertices; delete[] m_colors; delete[] m_normals; - + for(auto &texcoords : m_textureCoords) { delete [] texcoords; } @@ -413,7 +413,7 @@ void OpenGEXImporter::handleNodes( DDLNode *node, aiScene *pScene ) { case Grammar::ColorToken: handleColorNode( *it, pScene ); break; - + case Grammar::ParamToken: handleParamNode( *it, pScene ); break; @@ -479,7 +479,7 @@ void OpenGEXImporter::handleNameNode( DDLNode *node, aiScene *pScene ) { } const std::string name( val->getString() ); - if( m_tokenType == Grammar::GeometryNodeToken || m_tokenType == Grammar::LightNodeToken + if( m_tokenType == Grammar::GeometryNodeToken || m_tokenType == Grammar::LightNodeToken || m_tokenType == Grammar::CameraNodeToken ) { m_currentNode->mName.Set( name.c_str() ); } else if( m_tokenType == Grammar::MaterialToken ) { @@ -515,7 +515,7 @@ void OpenGEXImporter::handleObjectRefNode( DDLNode *node, aiScene *pScene ) { std::vector objRefNames; getRefNames( node, objRefNames ); - + // when we are dealing with a geometry node prepare the mesh cache if ( m_tokenType == Grammar::GeometryNodeToken ) { m_currentNode->mNumMeshes = objRefNames.size(); @@ -596,7 +596,7 @@ void OpenGEXImporter::handleGeometryObject( DDLNode *node, aiScene *pScene ) { //------------------------------------------------------------------------------------------------ void OpenGEXImporter::handleCameraObject( ODDLParser::DDLNode *node, aiScene *pScene ) { // parameters will be parsed normally in the tree, so just go for it - + handleNodes( node, pScene ); } @@ -757,7 +757,6 @@ static void fillColor4( aiColor4D *col4, Value *vals ) { ai_assert( nullptr != col4 ); ai_assert( nullptr != vals ); - float r( 0.0f ), g( 0.0f ), b( 0.0f ), a ( 1.0f ); Value *next( vals ); col4->r = next->getFloat(); next = next->m_next; @@ -1169,7 +1168,7 @@ void OpenGEXImporter::pushNode( aiNode *node, aiScene *pScene ) { if ( nullptr == node ) { return; } - + ChildInfo *info( nullptr ); if( m_nodeStack.empty() ) { node->mParent = pScene->mRootNode; From 5cb4df80ada8957e3f8b50a85344e6b7acbda67c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 15 Oct 2016 21:45:58 +0200 Subject: [PATCH 10/10] C++11-combat: hopefully the last std::to_string to replace. --- code/AMFImporter_Postprocess.cpp | 3 ++- code/ColladaExporter.cpp | 7 ++++--- code/ColladaExporter.h | 6 +++++- code/ColladaParser.cpp | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/code/AMFImporter_Postprocess.cpp b/code/AMFImporter_Postprocess.cpp index 8b4816efb..69aad1a66 100644 --- a/code/AMFImporter_Postprocess.cpp +++ b/code/AMFImporter_Postprocess.cpp @@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Header files, Assimp. #include "SceneCombiner.h" #include "StandardShapes.h" +#include "StringUtils.h" // Header files, stdlib. #include @@ -950,7 +951,7 @@ nl_clean_loop: pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; for(const SPP_Texture& tex_convd: mTexture_Converted) { - const aiString texture_id(AI_EMBEDDED_TEXNAME_PREFIX + std::to_string(idx)); + const aiString texture_id(AI_EMBEDDED_TEXNAME_PREFIX + to_string(idx)); const int mode = aiTextureOp_Multiply; const int repeat = tex_convd.Tiled ? 1 : 0; diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 48629ce05..a3bbc56ae 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fast_atof.h" #include "SceneCombiner.h" #include "DefaultIOSystem.h" +#include "StringUtils.h" #include "XMLTools.h" #include #include @@ -637,7 +638,7 @@ void ColladaExporter::WriteMaterials() aiString name; if( mat->Get( AI_MATKEY_NAME, name) != aiReturn_SUCCESS ) name = "mat"; - materials[a].name = std::string( "m") + std::to_string(a) + name.C_Str(); + materials[a].name = std::string( "m") + to_string(a) + name.C_Str(); for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) { if( !isalnum_C( *it ) ) { *it = '_'; @@ -813,7 +814,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) { if( mesh->HasTextureCoords( a) ) { - WriteFloatArray( idstr + "-tex" + std::to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2, + WriteFloatArray( idstr + "-tex" + to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2, (ai_real*) mesh->mTextureCoords[a], mesh->mNumVertices); } } @@ -822,7 +823,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { if( mesh->HasVertexColors( a) ) - WriteFloatArray( idstr + "-color" + std::to_string(a), FloatType_Color, (ai_real*) mesh->mColors[a], mesh->mNumVertices); + WriteFloatArray( idstr + "-color" + to_string(a), FloatType_Color, (ai_real*) mesh->mColors[a], mesh->mNumVertices); } // assemble vertex structure diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h index ffb841b0e..e8bd9b71f 100644 --- a/code/ColladaExporter.h +++ b/code/ColladaExporter.h @@ -53,6 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include "StringUtils.h" + struct aiScene; struct aiNode; @@ -122,7 +124,9 @@ protected: void PopTag() { ai_assert( startstr.length() > 1); startstr.erase( startstr.length() - 2); } /// Creates a mesh ID for the given mesh - std::string GetMeshId( size_t pIndex) const { return std::string( "meshId" ) + std::to_string(pIndex); } + std::string GetMeshId( size_t pIndex) const { + return std::string( "meshId" ) + to_string(pIndex); + } public: /// Stringstream to write all output into diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 4fb30675f..aaccfad40 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -300,7 +300,7 @@ void ColladaParser::ReadAnimationClipLibrary() else if (indexID >= 0) animName = mReader->getAttributeValue(indexID); else - animName = std::string("animation_") + std::to_string(mAnimationClipLibrary.size()); + animName = std::string("animation_") + to_string(mAnimationClipLibrary.size()); std::pair > clip;