Explorar el Código

Merge branch 'master' into FindInvalidData

Kim Kulling hace 5 años
padre
commit
ba6af9ff98
Se han modificado 100 ficheros con 5270 adiciones y 5340 borrados
  1. 707 0
      code/AMF/AMFImporter.cpp
  2. 1 1
      code/AssetLib/3DS/3DSExporter.cpp
  3. 25 22
      code/AssetLib/3DS/3DSHelper.h
  4. 4 4
      code/AssetLib/3MF/D3MFImporter.cpp
  5. 52 55
      code/AssetLib/3MF/D3MFOpcPackage.cpp
  6. 1 1
      code/AssetLib/AC/ACLoader.cpp
  7. 3 1
      code/AssetLib/AMF/AMFImporter.cpp
  8. 5 5
      code/AssetLib/ASE/ASEParser.cpp
  9. 94 122
      code/AssetLib/ASE/ASEParser.h
  10. 3 3
      code/AssetLib/Assbin/AssbinFileWriter.cpp
  11. 1 1
      code/AssetLib/Assbin/AssbinLoader.cpp
  12. 1 1
      code/AssetLib/Assxml/AssxmlFileWriter.cpp
  13. 2 2
      code/AssetLib/BVH/BVHLoader.cpp
  14. 6 6
      code/AssetLib/Blender/BlenderDNA.h
  15. 1 1
      code/AssetLib/Blender/BlenderDNA.inl
  16. 240 281
      code/AssetLib/Blender/BlenderLoader.cpp
  17. 2 0
      code/AssetLib/COB/COBLoader.cpp
  18. 1 1
      code/AssetLib/CSM/CSMLoader.cpp
  19. 4 4
      code/AssetLib/Collada/ColladaHelper.h
  20. 12 10
      code/AssetLib/Collada/ColladaLoader.cpp
  21. 13 16
      code/AssetLib/Collada/ColladaParser.cpp
  22. 1 1
      code/AssetLib/Collada/ColladaParser.h
  23. 77 92
      code/AssetLib/FBX/FBXAnimation.cpp
  24. 4 7
      code/AssetLib/FBX/FBXConverter.cpp
  25. 2 2
      code/AssetLib/FBX/FBXConverter.h
  26. 2 2
      code/AssetLib/FBX/FBXDocument.cpp
  27. 6 5
      code/AssetLib/FBX/FBXDocument.h
  28. 3 3
      code/AssetLib/FBX/FBXDocumentUtil.cpp
  29. 1 1
      code/AssetLib/FBX/FBXMeshGeometry.cpp
  30. 3 3
      code/AssetLib/FBX/FBXMeshGeometry.h
  31. 11 11
      code/AssetLib/FBX/FBXParser.cpp
  32. 2 2
      code/AssetLib/FBX/FBXParser.h
  33. 3 3
      code/AssetLib/FBX/FBXProperties.cpp
  34. 1 1
      code/AssetLib/FBX/FBXProperties.h
  35. 2 2
      code/AssetLib/FBX/FBXTokenizer.cpp
  36. 154 180
      code/AssetLib/HMP/HMPLoader.cpp
  37. 3 3
      code/AssetLib/IFC/IFCBoolean.cpp
  38. 5 3
      code/AssetLib/IFC/IFCCurve.cpp
  39. 1 1
      code/AssetLib/IFC/IFCGeometry.cpp
  40. 6 6
      code/AssetLib/IFC/IFCLoader.cpp
  41. 327 327
      code/AssetLib/IFC/IFCReaderGen1_2x3.cpp
  42. 1 1
      code/AssetLib/IFC/IFCUtil.cpp
  43. 1 1
      code/AssetLib/IFC/IFCUtil.h
  44. 365 397
      code/AssetLib/Irr/IRRLoader.cpp
  45. 3 2
      code/AssetLib/Irr/IRRMeshLoader.cpp
  46. 2 2
      code/AssetLib/LWO/LWOAnimation.cpp
  47. 2 2
      code/AssetLib/LWO/LWOAnimation.h
  48. 1 1
      code/AssetLib/LWO/LWOBLoader.cpp
  49. 1 1
      code/AssetLib/LWO/LWOLoader.cpp
  50. 1 1
      code/AssetLib/LWO/LWOLoader.h
  51. 2 2
      code/AssetLib/LWO/LWOMaterial.cpp
  52. 3 3
      code/AssetLib/LWS/LWSLoader.cpp
  53. 13 1
      code/AssetLib/LWS/LWSLoader.h
  54. 4 4
      code/AssetLib/M3D/M3DExporter.cpp
  55. 4 2
      code/AssetLib/M3D/M3DImporter.cpp
  56. 12 12
      code/AssetLib/M3D/M3DMaterials.h
  57. 1 1
      code/AssetLib/M3D/M3DWrapper.cpp
  58. 6 5
      code/AssetLib/MD2/MD2Loader.cpp
  59. 234 271
      code/AssetLib/MD3/MD3Loader.cpp
  60. 87 71
      code/AssetLib/MD5/MD5Loader.cpp
  61. 7 8
      code/AssetLib/MD5/MD5Loader.h
  62. 164 179
      code/AssetLib/MD5/MD5Parser.cpp
  63. 4 4
      code/AssetLib/MDC/MDCLoader.cpp
  64. 4 2
      code/AssetLib/MDL/HalfLife/HL1MDLLoader.h
  65. 23 20
      code/AssetLib/MDL/MDLLoader.cpp
  66. 1 1
      code/AssetLib/MDL/MDLLoader.h
  67. 2 2
      code/AssetLib/MDL/MDLMaterialLoader.cpp
  68. 1 1
      code/AssetLib/MMD/MMDImporter.cpp
  69. 1 1
      code/AssetLib/MMD/MMDPmdParser.h
  70. 1 1
      code/AssetLib/MS3D/MS3DLoader.cpp
  71. 12 12
      code/AssetLib/NFF/NFFLoader.cpp
  72. 3 3
      code/AssetLib/Obj/ObjExporter.cpp
  73. 15 11
      code/AssetLib/Obj/ObjFileData.h
  74. 15 15
      code/AssetLib/Obj/ObjFileImporter.cpp
  75. 3 3
      code/AssetLib/Obj/ObjFileMtlImporter.cpp
  76. 9 8
      code/AssetLib/Obj/ObjFileParser.cpp
  77. 271 368
      code/AssetLib/Ogre/OgreStructs.cpp
  78. 2 2
      code/AssetLib/Ply/PlyExporter.cpp
  79. 4 4
      code/AssetLib/Ply/PlyLoader.cpp
  80. 735 919
      code/AssetLib/Ply/PlyParser.cpp
  81. 224 246
      code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp
  82. 213 257
      code/AssetLib/Q3D/Q3DLoader.cpp
  83. 102 131
      code/AssetLib/Raw/RawLoader.cpp
  84. 180 239
      code/AssetLib/SIB/SIBImporter.cpp
  85. 1 1
      code/AssetLib/SMD/SMDLoader.cpp
  86. 4 4
      code/AssetLib/STEPParser/STEPFileReader.cpp
  87. 2 2
      code/AssetLib/STL/STLExporter.cpp
  88. 2 2
      code/AssetLib/Step/StepExporter.cpp
  89. 8 4
      code/AssetLib/Terragen/TerragenLoader.cpp
  90. 1 1
      code/AssetLib/X/XFileExporter.cpp
  91. 1 1
      code/AssetLib/X/XFileImporter.cpp
  92. 260 339
      code/AssetLib/X/XFileParser.cpp
  93. 1 1
      code/AssetLib/X/XFileParser.h
  94. 2 2
      code/AssetLib/X3D/X3DImporter_Shape.cpp
  95. 193 254
      code/AssetLib/XGL/XGLLoader.cpp
  96. 44 62
      code/AssetLib/XGL/XGLLoader.h
  97. 189 216
      code/AssetLib/glTF/glTFImporter.cpp
  98. 29 41
      code/CApi/AssimpCExport.cpp
  99. 1 1
      code/CApi/CInterfaceIOWrapper.cpp
  100. 1 0
      code/CMakeLists.txt

+ 707 - 0
code/AMF/AMFImporter.cpp

@@ -0,0 +1,707 @@
+/*
+---------------------------------------------------------------------------
+Open Asset Import Library (assimp)
+---------------------------------------------------------------------------
+
+Copyright (c) 2006-2020, assimp team
+
+
+
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the following
+conditions are met:
+
+* Redistributions of source code must retain the above
+copyright notice, this list of conditions and the
+following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the
+following disclaimer in the documentation and/or other
+materials provided with the distribution.
+
+* Neither the name of the assimp team, nor the names of its
+contributors may be used to endorse or promote products
+derived from this software without specific prior
+written permission of the assimp team.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+---------------------------------------------------------------------------
+*/
+
+/// \file AMFImporter.cpp
+/// \brief AMF-format files importer for Assimp: main algorithm implementation.
+/// \date 2016
+/// \author [email protected]
+
+#ifndef ASSIMP_BUILD_NO_AMF_IMPORTER
+
+// Header files, Assimp.
+#include "AMFImporter.hpp"
+#include "AMFImporter_Macro.hpp"
+
+#include <assimp/fast_atof.h>
+#include <assimp/DefaultIOSystem.h>
+
+// Header files, stdlib.
+#include <memory>
+
+namespace Assimp
+{
+
+/// \var aiImporterDesc AMFImporter::Description
+/// Conastant which hold importer description
+const aiImporterDesc AMFImporter::Description = {
+	"Additive manufacturing file format(AMF) Importer",
+	"smalcom",
+	"",
+	"See documentation in source code. Chapter: Limitations.",
+	aiImporterFlags_SupportTextFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental,
+	0,
+	0,
+	0,
+	0,
+	"amf"
+};
+
+void AMFImporter::Clear()
+{
+	mNodeElement_Cur = nullptr;
+	mUnit.clear();
+	mMaterial_Converted.clear();
+	mTexture_Converted.clear();
+	// Delete all elements
+	if(!mNodeElement_List.empty())
+	{
+		for(CAMFImporter_NodeElement* ne: mNodeElement_List) { delete ne; }
+
+		mNodeElement_List.clear();
+	}
+}
+
+AMFImporter::~AMFImporter()
+{
+	if(mReader != nullptr) delete mReader;
+	// Clear() is accounting if data already is deleted. So, just check again if all data is deleted.
+	Clear();
+}
+
+/*********************************************************************************************************************************************/
+/************************************************************ Functions: find set ************************************************************/
+/*********************************************************************************************************************************************/
+
+bool AMFImporter::Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement** pNodeElement) const
+{
+	for(CAMFImporter_NodeElement* ne: mNodeElement_List)
+	{
+		if((ne->ID == pID) && (ne->Type == pType))
+		{
+			if(pNodeElement != nullptr) *pNodeElement = ne;
+
+			return true;
+		}
+	}// for(CAMFImporter_NodeElement* ne: mNodeElement_List)
+
+	return false;
+}
+
+bool AMFImporter::Find_ConvertedNode(const std::string& pID, std::list<aiNode*>& pNodeList, aiNode** pNode) const
+{
+aiString node_name(pID.c_str());
+
+	for(aiNode* node: pNodeList)
+	{
+		if(node->mName == node_name)
+		{
+			if(pNode != nullptr) *pNode = node;
+
+			return true;
+		}
+	}// for(aiNode* node: pNodeList)
+
+	return false;
+}
+
+bool AMFImporter::Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const
+{
+	for(const SPP_Material& mat: mMaterial_Converted)
+	{
+		if(mat.ID == pID)
+		{
+			if(pConvertedMaterial != nullptr) *pConvertedMaterial = &mat;
+
+			return true;
+		}
+	}// for(const SPP_Material& mat: mMaterial_Converted)
+
+	return false;
+}
+
+/*********************************************************************************************************************************************/
+/************************************************************ Functions: throw set ***********************************************************/
+/*********************************************************************************************************************************************/
+
+void AMFImporter::Throw_CloseNotFound(const std::string& pNode)
+{
+	throw DeadlyImportError("Close tag for node <" + pNode + "> not found. Seems file is corrupt.");
+}
+
+void AMFImporter::Throw_IncorrectAttr(const std::string& pAttrName)
+{
+	throw DeadlyImportError("Node <" + std::string(mReader->getNodeName()) + "> has incorrect attribute \"" + pAttrName + "\".");
+}
+
+void AMFImporter::Throw_IncorrectAttrValue(const std::string& pAttrName)
+{
+	throw DeadlyImportError("Attribute \"" + pAttrName + "\" in node <" + std::string(mReader->getNodeName()) + "> has incorrect value.");
+}
+
+void AMFImporter::Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription)
+{
+	throw DeadlyImportError("\"" + pNodeType + "\" node can be used only once in " + mReader->getNodeName() + ". Description: " + pDescription);
+}
+
+void AMFImporter::Throw_ID_NotFound(const std::string& pID) const
+{
+	throw DeadlyImportError("Not found node with name \"" + pID + "\".");
+}
+
+/*********************************************************************************************************************************************/
+/************************************************************* Functions: XML set ************************************************************/
+/*********************************************************************************************************************************************/
+
+void AMFImporter::XML_CheckNode_MustHaveChildren()
+{
+	if(mReader->isEmptyElement()) throw DeadlyImportError(std::string("Node <") + mReader->getNodeName() + "> must have children.");
+}
+
+void AMFImporter::XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName)
+{
+    static const size_t Uns_Skip_Len = 3;
+    const char* Uns_Skip[Uns_Skip_Len] = { "composite", "edge", "normal" };
+
+    static bool skipped_before[Uns_Skip_Len] = { false, false, false };
+
+    std::string nn(mReader->getNodeName());
+    bool found = false;
+    bool close_found = false;
+    size_t sk_idx;
+
+	for(sk_idx = 0; sk_idx < Uns_Skip_Len; sk_idx++)
+	{
+		if(nn != Uns_Skip[sk_idx]) continue;
+
+		found = true;
+		if(mReader->isEmptyElement())
+		{
+			close_found = true;
+
+			goto casu_cres;
+		}
+
+		while(mReader->read())
+		{
+			if((mReader->getNodeType() == irr::io::EXN_ELEMENT_END) && (nn == mReader->getNodeName()))
+			{
+				close_found = true;
+
+				goto casu_cres;
+			}
+		}
+	}// for(sk_idx = 0; sk_idx < Uns_Skip_Len; sk_idx++)
+
+casu_cres:
+
+	if(!found) throw DeadlyImportError("Unknown node \"" + nn + "\" in " + pParentNodeName + ".");
+	if(!close_found) Throw_CloseNotFound(nn);
+
+	if(!skipped_before[sk_idx])
+	{
+		skipped_before[sk_idx] = true;
+        ASSIMP_LOG_WARN_F("Skipping node \"", nn, "\" in ", pParentNodeName, ".");
+	}
+}
+
+bool AMFImporter::XML_SearchNode(const std::string& pNodeName)
+{
+	while(mReader->read())
+	{
+		if((mReader->getNodeType() == irr::io::EXN_ELEMENT) && XML_CheckNode_NameEqual(pNodeName)) return true;
+	}
+
+	return false;
+}
+
+bool AMFImporter::XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx)
+{
+    std::string val(mReader->getAttributeValue(pAttrIdx));
+
+	if((val == "false") || (val == "0"))
+		return false;
+	else if((val == "true") || (val == "1"))
+		return true;
+	else
+		throw DeadlyImportError("Bool attribute value can contain \"false\"/\"0\" or \"true\"/\"1\" not the \"" + val + "\"");
+}
+
+float AMFImporter::XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx)
+{
+    std::string val;
+    float tvalf;
+
+	ParseHelper_FixTruncatedFloatString(mReader->getAttributeValue(pAttrIdx), val);
+	fast_atoreal_move(val.c_str(), tvalf, false);
+
+	return tvalf;
+}
+
+uint32_t AMFImporter::XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx)
+{
+	return strtoul10(mReader->getAttributeValue(pAttrIdx));
+}
+
+float AMFImporter::XML_ReadNode_GetVal_AsFloat()
+{
+    std::string val;
+    float tvalf;
+
+	if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. No data, seems file is corrupt.");
+	if(mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsFloat. Invalid type of XML element, seems file is corrupt.");
+
+	ParseHelper_FixTruncatedFloatString(mReader->getNodeData(), val);
+	fast_atoreal_move(val.c_str(), tvalf, false);
+
+	return tvalf;
+}
+
+uint32_t AMFImporter::XML_ReadNode_GetVal_AsU32()
+{
+	if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. No data, seems file is corrupt.");
+	if(mReader->getNodeType() != irr::io::EXN_TEXT) throw DeadlyImportError("XML_ReadNode_GetVal_AsU32. Invalid type of XML element, seems file is corrupt.");
+
+	return strtoul10(mReader->getNodeData());
+}
+
+void AMFImporter::XML_ReadNode_GetVal_AsString(std::string& pValue)
+{
+	if(!mReader->read()) throw DeadlyImportError("XML_ReadNode_GetVal_AsString. No data, seems file is corrupt.");
+	if(mReader->getNodeType() != irr::io::EXN_TEXT)
+		throw DeadlyImportError("XML_ReadNode_GetVal_AsString. Invalid type of XML element, seems file is corrupt.");
+
+	pValue = mReader->getNodeData();
+}
+
+/*********************************************************************************************************************************************/
+/************************************************************ Functions: parse set ***********************************************************/
+/*********************************************************************************************************************************************/
+
+void AMFImporter::ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode)
+{
+	mNodeElement_Cur->Child.push_back(pNode);// add new element to current element child list.
+	mNodeElement_Cur = pNode;// switch current element to new one.
+}
+
+void AMFImporter::ParseHelper_Node_Exit()
+{
+	// check if we can walk up.
+	if(mNodeElement_Cur != nullptr) mNodeElement_Cur = mNodeElement_Cur->Parent;
+}
+
+void AMFImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString)
+{
+    size_t instr_len;
+
+	pOutString.clear();
+	instr_len = strlen(pInStr);
+	if(!instr_len) return;
+
+	pOutString.reserve(instr_len * 3 / 2);
+	// check and correct floats in format ".x". Must be "x.y".
+	if(pInStr[0] == '.') pOutString.push_back('0');
+
+	pOutString.push_back(pInStr[0]);
+	for(size_t ci = 1; ci < instr_len; ci++)
+	{
+		if((pInStr[ci] == '.') && ((pInStr[ci - 1] == ' ') || (pInStr[ci - 1] == '-') || (pInStr[ci - 1] == '+') || (pInStr[ci - 1] == '\t')))
+		{
+			pOutString.push_back('0');
+			pOutString.push_back('.');
+		}
+		else
+		{
+			pOutString.push_back(pInStr[ci]);
+		}
+	}
+}
+
+static bool ParseHelper_Decode_Base64_IsBase64(const char pChar)
+{
+	return (isalnum(pChar) || (pChar == '+') || (pChar == '/'));
+}
+
+void AMFImporter::ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const
+{
+    // With help from
+    // René Nyffenegger http://www.adp-gmbh.ch/cpp/common/base64.html
+    const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+    uint8_t tidx = 0;
+    uint8_t arr4[4], arr3[3];
+
+	// check input data
+	if(pInputBase64.size() % 4) throw DeadlyImportError("Base64-encoded data must have size multiply of four.");
+	// prepare output place
+	pOutputData.clear();
+	pOutputData.reserve(pInputBase64.size() / 4 * 3);
+
+	for(size_t in_len = pInputBase64.size(), in_idx = 0; (in_len > 0) && (pInputBase64[in_idx] != '='); in_len--)
+	{
+		if(ParseHelper_Decode_Base64_IsBase64(pInputBase64[in_idx]))
+		{
+			arr4[tidx++] = pInputBase64[in_idx++];
+			if(tidx == 4)
+			{
+				for(tidx = 0; tidx < 4; tidx++) arr4[tidx] = (uint8_t)base64_chars.find(arr4[tidx]);
+
+				arr3[0] = (arr4[0] << 2) + ((arr4[1] & 0x30) >> 4);
+				arr3[1] = ((arr4[1] & 0x0F) << 4) + ((arr4[2] & 0x3C) >> 2);
+				arr3[2] = ((arr4[2] & 0x03) << 6) + arr4[3];
+				for(tidx = 0; tidx < 3; tidx++) pOutputData.push_back(arr3[tidx]);
+
+				tidx = 0;
+			}// if(tidx == 4)
+		}// if(ParseHelper_Decode_Base64_IsBase64(pInputBase64[in_idx]))
+		else
+		{
+			in_idx++;
+		}// if(ParseHelper_Decode_Base64_IsBase64(pInputBase64[in_idx])) else
+	}
+
+	if(tidx)
+	{
+		for(uint8_t i = tidx; i < 4; i++) arr4[i] = 0;
+		for(uint8_t i = 0; i < 4; i++) arr4[i] = (uint8_t)(base64_chars.find(arr4[i]));
+
+		arr3[0] = (arr4[0] << 2) + ((arr4[1] & 0x30) >> 4);
+		arr3[1] = ((arr4[1] & 0x0F) << 4) + ((arr4[2] & 0x3C) >> 2);
+		arr3[2] = ((arr4[2] & 0x03) << 6) + arr4[3];
+		for(uint8_t i = 0; i < (tidx - 1); i++) pOutputData.push_back(arr3[i]);
+	}
+}
+
+void AMFImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler)
+{
+    irr::io::IrrXMLReader* OldReader = mReader;// store current XMLreader.
+    std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
+
+	// Check whether we can read from the file
+    if (file.get() == nullptr) {
+        throw DeadlyImportError("Failed to open AMF file " + pFile + ".");
+    }
+
+	// generate a XML reader for it
+	std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));
+	mReader = irr::io::createIrrXMLReader(mIOWrapper.get());
+	if(!mReader) throw DeadlyImportError("Failed to create XML reader for file" + pFile + ".");
+	//
+	// start reading
+	// search for root tag <amf>
+	if(XML_SearchNode("amf"))
+		ParseNode_Root();
+	else
+		throw DeadlyImportError("Root node \"amf\" not found.");
+
+	delete mReader;
+	// restore old XMLreader
+	mReader = OldReader;
+}
+
+// <amf
+// unit="" - The units to be used. May be "inch", "millimeter", "meter", "feet", or "micron".
+// version="" - Version of file format.
+// >
+// </amf>
+// Root XML element.
+// Multi elements - No.
+void AMFImporter::ParseNode_Root()
+{
+    std::string unit, version;
+    CAMFImporter_NodeElement *ne( nullptr );
+
+	// Read attributes for node <amf>.
+	MACRO_ATTRREAD_LOOPBEG;
+		MACRO_ATTRREAD_CHECK_RET("unit", unit, mReader->getAttributeValue);
+		MACRO_ATTRREAD_CHECK_RET("version", version, mReader->getAttributeValue);
+	MACRO_ATTRREAD_LOOPEND_WSKIP;
+
+	// Check attributes
+	if(!mUnit.empty())
+	{
+		if((mUnit != "inch") && (mUnit != "millimeter") && (mUnit != "meter") && (mUnit != "feet") && (mUnit != "micron")) Throw_IncorrectAttrValue("unit");
+	}
+
+	// create root node element.
+	ne = new CAMFImporter_NodeElement_Root(nullptr);
+	mNodeElement_Cur = ne;// set first "current" element
+	// and assign attribute's values
+	((CAMFImporter_NodeElement_Root*)ne)->Unit = unit;
+	((CAMFImporter_NodeElement_Root*)ne)->Version = version;
+
+	// Check for child nodes
+	if(!mReader->isEmptyElement())
+	{
+		MACRO_NODECHECK_LOOPBEGIN("amf");
+			if(XML_CheckNode_NameEqual("object")) { ParseNode_Object(); continue; }
+			if(XML_CheckNode_NameEqual("material")) { ParseNode_Material(); continue; }
+			if(XML_CheckNode_NameEqual("texture")) { ParseNode_Texture(); continue; }
+			if(XML_CheckNode_NameEqual("constellation")) { ParseNode_Constellation(); continue; }
+			if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; }
+		MACRO_NODECHECK_LOOPEND("amf");
+		mNodeElement_Cur = ne;// force restore "current" element
+	}// if(!mReader->isEmptyElement())
+
+	mNodeElement_List.push_back(ne);// add to node element list because its a new object in graph.
+}
+
+// <constellation
+// id="" - The Object ID of the new constellation being defined.
+// >
+// </constellation>
+// A collection of objects or constellations with specific relative locations.
+// Multi elements - Yes.
+// Parent element - <amf>.
+void AMFImporter::ParseNode_Constellation()
+{
+    std::string id;
+    CAMFImporter_NodeElement* ne( nullptr );
+
+	// Read attributes for node <constellation>.
+	MACRO_ATTRREAD_LOOPBEG;
+		MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue);
+	MACRO_ATTRREAD_LOOPEND;
+
+	// create and if needed - define new grouping object.
+	ne = new CAMFImporter_NodeElement_Constellation(mNodeElement_Cur);
+
+	CAMFImporter_NodeElement_Constellation& als = *((CAMFImporter_NodeElement_Constellation*)ne);// alias for convenience
+
+	if(!id.empty()) als.ID = id;
+	// Check for child nodes
+	if(!mReader->isEmptyElement())
+	{
+		ParseHelper_Node_Enter(ne);
+		MACRO_NODECHECK_LOOPBEGIN("constellation");
+			if(XML_CheckNode_NameEqual("instance")) { ParseNode_Instance(); continue; }
+			if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; }
+		MACRO_NODECHECK_LOOPEND("constellation");
+		ParseHelper_Node_Exit();
+	}// if(!mReader->isEmptyElement())
+	else
+	{
+		mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
+	}// if(!mReader->isEmptyElement()) else
+
+	mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
+}
+
+// <instance
+// objectid="" - The Object ID of the new constellation being defined.
+// >
+// </instance>
+// A collection of objects or constellations with specific relative locations.
+// Multi elements - Yes.
+// Parent element - <amf>.
+void AMFImporter::ParseNode_Instance()
+{
+    std::string objectid;
+    CAMFImporter_NodeElement* ne( nullptr );
+
+	// Read attributes for node <constellation>.
+	MACRO_ATTRREAD_LOOPBEG;
+		MACRO_ATTRREAD_CHECK_RET("objectid", objectid, mReader->getAttributeValue);
+	MACRO_ATTRREAD_LOOPEND;
+
+	// used object id must be defined, check that.
+	if(objectid.empty()) throw DeadlyImportError("\"objectid\" in <instance> must be defined.");
+	// create and define new grouping object.
+	ne = new CAMFImporter_NodeElement_Instance(mNodeElement_Cur);
+
+	CAMFImporter_NodeElement_Instance& als = *((CAMFImporter_NodeElement_Instance*)ne);// alias for convenience
+
+	als.ObjectID = objectid;
+	// Check for child nodes
+	if(!mReader->isEmptyElement())
+	{
+		bool read_flag[6] = { false, false, false, false, false, false };
+
+		als.Delta.Set(0, 0, 0);
+		als.Rotation.Set(0, 0, 0);
+		ParseHelper_Node_Enter(ne);
+		MACRO_NODECHECK_LOOPBEGIN("instance");
+			MACRO_NODECHECK_READCOMP_F("deltax", read_flag[0], als.Delta.x);
+			MACRO_NODECHECK_READCOMP_F("deltay", read_flag[1], als.Delta.y);
+			MACRO_NODECHECK_READCOMP_F("deltaz", read_flag[2], als.Delta.z);
+			MACRO_NODECHECK_READCOMP_F("rx", read_flag[3], als.Rotation.x);
+			MACRO_NODECHECK_READCOMP_F("ry", read_flag[4], als.Rotation.y);
+			MACRO_NODECHECK_READCOMP_F("rz", read_flag[5], als.Rotation.z);
+		MACRO_NODECHECK_LOOPEND("instance");
+		ParseHelper_Node_Exit();
+		// also convert degrees to radians.
+		als.Rotation.x = AI_MATH_PI_F * als.Rotation.x / 180.0f;
+		als.Rotation.y = AI_MATH_PI_F * als.Rotation.y / 180.0f;
+		als.Rotation.z = AI_MATH_PI_F * als.Rotation.z / 180.0f;
+	}// if(!mReader->isEmptyElement())
+	else
+	{
+		mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
+	}// if(!mReader->isEmptyElement()) else
+
+	mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
+}
+
+// <object
+// id="" - A unique ObjectID for the new object being defined.
+// >
+// </object>
+// An object definition.
+// Multi elements - Yes.
+// Parent element - <amf>.
+void AMFImporter::ParseNode_Object()
+{
+    std::string id;
+    CAMFImporter_NodeElement* ne( nullptr );
+
+	// Read attributes for node <object>.
+	MACRO_ATTRREAD_LOOPBEG;
+		MACRO_ATTRREAD_CHECK_RET("id", id, mReader->getAttributeValue);
+	MACRO_ATTRREAD_LOOPEND;
+
+	// create and if needed - define new geometry object.
+	ne = new CAMFImporter_NodeElement_Object(mNodeElement_Cur);
+
+	CAMFImporter_NodeElement_Object& als = *((CAMFImporter_NodeElement_Object*)ne);// alias for convenience
+
+	if(!id.empty()) als.ID = id;
+	// Check for child nodes
+	if(!mReader->isEmptyElement())
+	{
+		bool col_read = false;
+
+		ParseHelper_Node_Enter(ne);
+		MACRO_NODECHECK_LOOPBEGIN("object");
+			if(XML_CheckNode_NameEqual("color"))
+			{
+				// Check if color already defined for object.
+				if(col_read) Throw_MoreThanOnceDefined("color", "Only one color can be defined for <object>.");
+				// read data and set flag about it
+				ParseNode_Color();
+				col_read = true;
+
+				continue;
+			}
+
+			if(XML_CheckNode_NameEqual("mesh")) { ParseNode_Mesh(); continue; }
+			if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; }
+		MACRO_NODECHECK_LOOPEND("object");
+		ParseHelper_Node_Exit();
+	}// if(!mReader->isEmptyElement())
+	else
+	{
+		mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
+	}// if(!mReader->isEmptyElement()) else
+
+	mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
+}
+
+// <metadata
+// type="" - The type of the attribute.
+// >
+// </metadata>
+// Specify additional information about an entity.
+// Multi elements - Yes.
+// Parent element - <amf>, <object>, <volume>, <material>, <vertex>.
+//
+// Reserved types are:
+// "Name" - The alphanumeric label of the entity, to be used by the interpreter if interacting with the user.
+// "Description" - A description of the content of the entity
+// "URL" - A link to an external resource relating to the entity
+// "Author" - Specifies the name(s) of the author(s) of the entity
+// "Company" - Specifying the company generating the entity
+// "CAD" - specifies the name of the originating CAD software and version
+// "Revision" - specifies the revision of the entity
+// "Tolerance" - specifies the desired manufacturing tolerance of the entity in entity's unit system
+// "Volume" - specifies the total volume of the entity, in the entity's unit system, to be used for verification (object and volume only)
+void AMFImporter::ParseNode_Metadata()
+{
+    std::string type, value;
+    CAMFImporter_NodeElement* ne( nullptr );
+
+	// read attribute
+	MACRO_ATTRREAD_LOOPBEG;
+		MACRO_ATTRREAD_CHECK_RET("type", type, mReader->getAttributeValue);
+	MACRO_ATTRREAD_LOOPEND;
+	// and value of node.
+	value = mReader->getNodeData();
+	// Create node element and assign read data.
+	ne = new CAMFImporter_NodeElement_Metadata(mNodeElement_Cur);
+	((CAMFImporter_NodeElement_Metadata*)ne)->Type = type;
+	((CAMFImporter_NodeElement_Metadata*)ne)->Value = value;
+	mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
+	mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
+}
+
+/*********************************************************************************************************************************************/
+/******************************************************** Functions: BaseImporter set ********************************************************/
+/*********************************************************************************************************************************************/
+
+bool AMFImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const
+{
+    const std::string extension = GetExtension(pFile);
+
+    if ( extension == "amf" ) {
+        return true;
+    }
+
+	if(!extension.length() || pCheckSig)
+	{
+		const char* tokens[] = { "<amf" };
+
+		return SearchFileHeaderForToken( pIOHandler, pFile, tokens, 1 );
+	}
+
+	return false;
+}
+
+void AMFImporter::GetExtensionList(std::set<std::string>& pExtensionList)
+{
+	pExtensionList.insert("amf");
+}
+
+const aiImporterDesc* AMFImporter::GetInfo () const
+{
+	return &Description;
+}
+
+void AMFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
+{
+	Clear();// delete old graph.
+	ParseFile(pFile, pIOHandler);
+	Postprocess_BuildScene(pScene);
+	// scene graph is ready, exit.
+}
+
+}// namespace Assimp
+
+#endif // !ASSIMP_BUILD_NO_AMF_IMPORTER

+ 1 - 1
code/AssetLib/3DS/3DSExporter.cpp

@@ -367,7 +367,7 @@ void Discreet3DSExporter::WriteTexture(const aiMaterial &mat, aiTextureType type
         aiTextureMapMode_Wrap, aiTextureMapMode_Wrap
     };
     ai_real blend = 1.0;
-    if (mat.GetTexture(type, 0, &path, NULL, NULL, &blend, NULL, map_mode) != AI_SUCCESS || !path.length) {
+    if (mat.GetTexture(type, 0, &path, nullptr, nullptr, &blend, nullptr, map_mode) != AI_SUCCESS || !path.length) {
         return;
     }
 

+ 25 - 22
code/AssetLib/3DS/3DSHelper.h

@@ -462,30 +462,28 @@ struct Material {
             sTexAmbient(other.sTexAmbient),
             mTwoSided(other.mTwoSided) {
         // empty
-
     }
 
     //! 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(std::move(other.mDiffuse)),
-            mSpecularExponent(std::move(other.mSpecularExponent)),
-            mShininessStrength(std::move(other.mShininessStrength)),
-            mSpecular(std::move(other.mSpecular)),
-            mAmbient(std::move(other.mAmbient)),
-            mShading(std::move(other.mShading)),
-            mTransparency(std::move(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(std::move(other.mBumpHeight)),
-            mEmissive(std::move(other.mEmissive)),
-            sTexAmbient(std::move(other.sTexAmbient)),
-            mTwoSided(std::move(other.mTwoSided)) {
+    Material(Material &&other) AI_NO_EXCEPT : mName(std::move(other.mName)),
+                                              mDiffuse(std::move(other.mDiffuse)),
+                                              mSpecularExponent(std::move(other.mSpecularExponent)),
+                                              mShininessStrength(std::move(other.mShininessStrength)),
+                                              mSpecular(std::move(other.mSpecular)),
+                                              mAmbient(std::move(other.mAmbient)),
+                                              mShading(std::move(other.mShading)),
+                                              mTransparency(std::move(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(std::move(other.mBumpHeight)),
+                                              mEmissive(std::move(other.mEmissive)),
+                                              sTexAmbient(std::move(other.sTexAmbient)),
+                                              mTwoSided(std::move(other.mTwoSided)) {
         // empty
     }
 
@@ -615,7 +613,12 @@ struct Node {
     Node() = delete;
 
     explicit Node(const std::string &name) :
-            mParent(NULL), mName(name), mInstanceNumber(0), mHierarchyPos(0), mHierarchyIndex(0), mInstanceCount(1) {
+            mParent(nullptr),
+            mName(name),
+            mInstanceNumber(0),
+            mHierarchyPos(0),
+            mHierarchyIndex(0),
+            mInstanceCount(1) {
         aRotationKeys.reserve(20);
         aPositionKeys.reserve(20);
         aScalingKeys.reserve(20);

+ 4 - 4
code/AssetLib/3MF/D3MFImporter.cpp

@@ -314,19 +314,19 @@ private:
         ++buf;
         comp[1] = *buf;
         ++buf;
-        diffuse.r = static_cast<ai_real>(strtol(comp, NULL, 16)) / ai_real(255.0);
+        diffuse.r = static_cast<ai_real>(strtol(comp, nullptr, 16)) / ai_real(255.0);
 
         comp[0] = *buf;
         ++buf;
         comp[1] = *buf;
         ++buf;
-        diffuse.g = static_cast<ai_real>(strtol(comp, NULL, 16)) / ai_real(255.0);
+        diffuse.g = static_cast<ai_real>(strtol(comp, nullptr, 16)) / ai_real(255.0);
 
         comp[0] = *buf;
         ++buf;
         comp[1] = *buf;
         ++buf;
-        diffuse.b = static_cast<ai_real>(strtol(comp, NULL, 16)) / ai_real(255.0);
+        diffuse.b = static_cast<ai_real>(strtol(comp, nullptr, 16)) / ai_real(255.0);
 
         if (7 == len)
             return true;
@@ -334,7 +334,7 @@ private:
         ++buf;
         comp[1] = *buf;
         ++buf;
-        diffuse.a = static_cast<ai_real>(strtol(comp, NULL, 16)) / ai_real(255.0);
+        diffuse.a = static_cast<ai_real>(strtol(comp, nullptr, 16)) / ai_real(255.0);
 
         return true;
     }

+ 52 - 55
code/AssetLib/3MF/D3MFOpcPackage.cpp

@@ -45,19 +45,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "D3MFOpcPackage.h"
 #include <assimp/Exceptional.h>
 
+#include <assimp/ZipArchiveIOSystem.h>
+#include <assimp/ai_assert.h>
+#include <assimp/DefaultLogger.hpp>
 #include <assimp/IOStream.hpp>
 #include <assimp/IOSystem.hpp>
-#include <assimp/DefaultLogger.hpp>
-#include <assimp/ai_assert.h>
-#include <assimp/ZipArchiveIOSystem.h>
 
+#include "3MFXmlTags.h"
+#include <algorithm>
+#include <cassert>
 #include <cstdlib>
+#include <map>
 #include <memory>
 #include <vector>
-#include <map>
-#include <algorithm>
-#include <cassert>
-#include "3MFXmlTags.h"
 
 namespace Assimp {
 
@@ -68,49 +68,45 @@ typedef std::shared_ptr<OpcPackageRelationship> OpcPackageRelationshipPtr;
 
 class OpcPackageRelationshipReader {
 public:
-    OpcPackageRelationshipReader(XmlReader* xmlReader) {        
-        while(xmlReader->read()) {
-            if(xmlReader->getNodeType() == irr::io::EXN_ELEMENT &&
-               xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_CONTAINER)
-            {
+    OpcPackageRelationshipReader(XmlReader *xmlReader) {
+        while (xmlReader->read()) {
+            if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT &&
+                    xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_CONTAINER) {
                 ParseRootNode(xmlReader);
             }
         }
     }
 
-    void ParseRootNode(XmlReader* xmlReader)
-    {       
+    void ParseRootNode(XmlReader *xmlReader) {
         ParseAttributes(xmlReader);
 
-        while(xmlReader->read())
-        {
-            if(xmlReader->getNodeType() == irr::io::EXN_ELEMENT &&
-               xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_NODE)
-            {
+        while (xmlReader->read()) {
+            if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT &&
+                    xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_NODE) {
                 ParseChildNode(xmlReader);
             }
         }
     }
 
-    void ParseAttributes(XmlReader*) {
+    void ParseAttributes(XmlReader *) {
         // empty
     }
 
-    bool validateRels( OpcPackageRelationshipPtr &relPtr ) {
-        if ( relPtr->id.empty() || relPtr->type.empty() || relPtr->target.empty() ) {
+    bool validateRels(OpcPackageRelationshipPtr &relPtr) {
+        if (relPtr->id.empty() || relPtr->type.empty() || relPtr->target.empty()) {
             return false;
         }
         return true;
     }
 
-    void ParseChildNode(XmlReader* xmlReader) {        
+    void ParseChildNode(XmlReader *xmlReader) {
         OpcPackageRelationshipPtr relPtr(new OpcPackageRelationship());
 
         relPtr->id = xmlReader->getAttributeValueSafe(XmlTag::RELS_ATTRIB_ID.c_str());
         relPtr->type = xmlReader->getAttributeValueSafe(XmlTag::RELS_ATTRIB_TYPE.c_str());
         relPtr->target = xmlReader->getAttributeValueSafe(XmlTag::RELS_ATTRIB_TARGET.c_str());
-        if ( validateRels( relPtr ) ) {
-            m_relationShips.push_back( relPtr );
+        if (validateRels(relPtr)) {
+            m_relationShips.push_back(relPtr);
         }
     }
 
@@ -118,32 +114,34 @@ public:
 };
 
 // ------------------------------------------------------------------------------------------------
-D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile)
-: mRootStream(nullptr)
-, mZipArchive() {    
-    mZipArchive.reset( new ZipArchiveIOSystem( pIOHandler, rFile ) );
-    if(!mZipArchive->isOpen()) {
-        throw DeadlyImportError("Failed to open file " + rFile+ ".");
+D3MFOpcPackage::D3MFOpcPackage(IOSystem *pIOHandler, const std::string &rFile) :
+        mRootStream(nullptr), mZipArchive() {
+    mZipArchive.reset(new ZipArchiveIOSystem(pIOHandler, rFile));
+    if (!mZipArchive->isOpen()) {
+        throw DeadlyImportError("Failed to open file " + rFile + ".");
     }
 
     std::vector<std::string> fileList;
     mZipArchive->getFileList(fileList);
 
-    for (auto& file: fileList) {
-        if(file == D3MF::XmlTag::ROOT_RELATIONSHIPS_ARCHIVE) {
-            //PkgRelationshipReader pkgRelReader(file, archive);
-            ai_assert(mZipArchive->Exists(file.c_str()));
+    for (auto &file : fileList) {
+        if (file == D3MF::XmlTag::ROOT_RELATIONSHIPS_ARCHIVE) {
+            if (!mZipArchive->Exists(file.c_str())) {
+                continue;
+            }
 
             IOStream *fileStream = mZipArchive->Open(file.c_str());
-
-            ai_assert(fileStream != nullptr);
+            if (nullptr == fileStream) {
+                ai_assert(fileStream != nullptr);
+                continue;
+            }
 
             std::string rootFile = ReadPackageRootRelationship(fileStream);
-            if ( rootFile.size() > 0 && rootFile[ 0 ] == '/' ) {
-                rootFile = rootFile.substr( 1 );
-                if ( rootFile[ 0 ] == '/' ) {
+            if (rootFile.size() > 0 && rootFile[0] == '/') {
+                rootFile = rootFile.substr(1);
+                if (rootFile[0] == '/') {
                     // deal with zip-bug
-                    rootFile = rootFile.substr( 1 );
+                    rootFile = rootFile.substr(1);
                 }
             }
 
@@ -152,17 +150,16 @@ D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile)
             mZipArchive->Close(fileStream);
 
             mRootStream = mZipArchive->Open(rootFile.c_str());
-            ai_assert( mRootStream != nullptr );
-            if ( nullptr == mRootStream ) {
-                throw DeadlyExportError( "Cannot open root-file in archive : " + rootFile );
+            ai_assert(mRootStream != nullptr);
+            if (nullptr == mRootStream) {
+                throw DeadlyExportError("Cannot open root-file in archive : " + rootFile);
             }
 
-        } else if( file == D3MF::XmlTag::CONTENT_TYPES_ARCHIVE) {
-            ASSIMP_LOG_WARN_F("Ignored file of unsupported type CONTENT_TYPES_ARCHIVES",file);
+        } else if (file == D3MF::XmlTag::CONTENT_TYPES_ARCHIVE) {
+            ASSIMP_LOG_WARN_F("Ignored file of unsupported type CONTENT_TYPES_ARCHIVES", file);
         } else {
-            ASSIMP_LOG_WARN_F("Ignored file of unknown type: ",file);
+            ASSIMP_LOG_WARN_F("Ignored file of unknown type: ", file);
         }
-
     }
 }
 
@@ -170,32 +167,32 @@ D3MFOpcPackage::~D3MFOpcPackage() {
     mZipArchive->Close(mRootStream);
 }
 
-IOStream* D3MFOpcPackage::RootStream() const {
+IOStream *D3MFOpcPackage::RootStream() const {
     return mRootStream;
 }
 
 static const std::string ModelRef = "3D/3dmodel.model";
 
 bool D3MFOpcPackage::validate() {
-    if ( nullptr == mRootStream || nullptr == mZipArchive ) {
+    if (nullptr == mRootStream || nullptr == mZipArchive) {
         return false;
     }
 
-    return mZipArchive->Exists( ModelRef.c_str() );
+    return mZipArchive->Exists(ModelRef.c_str());
 }
 
-std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream* stream) {
+std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream *stream) {
     std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(stream));
     std::unique_ptr<XmlReader> xml(irr::io::createIrrXMLReader(xmlStream.get()));
 
     OpcPackageRelationshipReader reader(xml.get());
 
-    auto itr = std::find_if(reader.m_relationShips.begin(), reader.m_relationShips.end(), [](const OpcPackageRelationshipPtr& rel){
+    auto itr = std::find_if(reader.m_relationShips.begin(), reader.m_relationShips.end(), [](const OpcPackageRelationshipPtr &rel) {
         return rel->type == XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE;
     });
 
-    if ( itr == reader.m_relationShips.end() ) {
-        throw DeadlyImportError( "Cannot find " + XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE );
+    if (itr == reader.m_relationShips.end()) {
+        throw DeadlyImportError("Cannot find " + XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE);
     }
 
     return (*itr)->target;

+ 1 - 1
code/AssetLib/AC/ACLoader.cpp

@@ -627,7 +627,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
                     std::unique_ptr<Subdivider> div(Subdivider::Create(Subdivider::CATMULL_CLARKE));
                     ASSIMP_LOG_INFO("AC3D: Evaluating subdivision surface: " + object.name);
 
-                    std::vector<aiMesh *> cpy(meshes.size() - oldm, NULL);
+                    std::vector<aiMesh *> cpy(meshes.size() - oldm, nullptr);
                     div->Subdivide(&meshes[oldm], cpy.size(), &cpy.front(), object.subDiv, true);
                     std::copy(cpy.begin(), cpy.end(), meshes.begin() + oldm);
 

+ 3 - 1
code/AssetLib/AMF/AMFImporter.cpp

@@ -366,7 +366,9 @@ void AMFImporter::ParseFile(const std::string &pFile, IOSystem *pIOHandler) {
     std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
 
     // Check whether we can read from the file
-    if (file.get() == NULL) throw DeadlyImportError("Failed to open AMF file " + pFile + ".");
+    if (file.get() == nullptr) {
+        throw DeadlyImportError("Failed to open AMF file " + pFile + ".");
+    }
 
     // generate a XML reader for it
     std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));

+ 5 - 5
code/AssetLib/ASE/ASEParser.cpp

@@ -925,7 +925,7 @@ void Parser::ParseLV2AnimationBlock(ASE::BaseNode &mesh) {
 
                         ASSIMP_LOG_ERROR("ASE: Found target animation channel "
                                          "but the node is neither a camera nor a spot light");
-                        anim = NULL;
+                        anim = nullptr;
                     } else
                         anim = &mesh.mTargetAnim;
                 }
@@ -1797,14 +1797,14 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) {
 }
 // ------------------------------------------------------------------------------------------------
 void Parser::ParseLV4MeshLongTriple(unsigned int *apOut) {
-    ai_assert(NULL != apOut);
+    ai_assert(nullptr != apOut);
 
     for (unsigned int i = 0; i < 3; ++i)
         ParseLV4MeshLong(apOut[i]);
 }
 // ------------------------------------------------------------------------------------------------
 void Parser::ParseLV4MeshLongTriple(unsigned int *apOut, unsigned int &rIndexOut) {
-    ai_assert(NULL != apOut);
+    ai_assert(nullptr != apOut);
 
     // parse the index
     ParseLV4MeshLong(rIndexOut);
@@ -1814,7 +1814,7 @@ void Parser::ParseLV4MeshLongTriple(unsigned int *apOut, unsigned int &rIndexOut
 }
 // ------------------------------------------------------------------------------------------------
 void Parser::ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut) {
-    ai_assert(NULL != apOut);
+    ai_assert(nullptr != apOut);
 
     // parse the index
     ParseLV4MeshLong(rIndexOut);
@@ -1824,7 +1824,7 @@ void Parser::ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut) {
 }
 // ------------------------------------------------------------------------------------------------
 void Parser::ParseLV4MeshFloatTriple(ai_real *apOut) {
-    ai_assert(NULL != apOut);
+    ai_assert(nullptr != apOut);
 
     for (unsigned int i = 0; i < 3; ++i)
         ParseLV4MeshFloat(apOut[i]);

+ 94 - 122
code/AssetLib/ASE/ASEParser.h

@@ -40,15 +40,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ----------------------------------------------------------------------
 */
 
-
 /** @file Defines the helper data structures for importing ASE files  */
 #ifndef AI_ASEFILEHELPER_H_INC
 #define AI_ASEFILEHELPER_H_INC
 
 // public ASSIMP headers
-#include <assimp/types.h>
-#include <assimp/mesh.h>
 #include <assimp/anim.h>
+#include <assimp/mesh.h>
+#include <assimp/types.h>
 
 #ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
 
@@ -59,27 +58,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // ASE is quite similar to 3ds. We can reuse some structures
 #include "AssetLib/3DS/3DSLoader.h"
 
-namespace Assimp    {
-namespace ASE   {
+namespace Assimp {
+namespace ASE {
 
 using namespace D3DS;
 
 // ---------------------------------------------------------------------------
 /** Helper structure representing an ASE material */
-struct Material : public D3DS::Material
-{
+struct Material : public D3DS::Material {
     //! Default constructor has been deleted
     Material() = delete;
 
     //! Constructor with explicit name
-    explicit Material(const std::string &name)
-    : D3DS::Material(name)
-    , pcInstance(NULL)
-    , bNeed (false) {
+    explicit Material(const std::string &name) :
+            D3DS::Material(name),
+            pcInstance(nullptr),
+            bNeed(false) {
         // empty
     }
 
-    Material(const Material &other)            = default;
+    Material(const Material &other) = default;
 
     Material &operator=(const Material &other) {
         if (this == &other) {
@@ -93,19 +91,16 @@ struct Material : public D3DS::Material
         return *this;
     }
 
-
     //! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
     Material(Material &&other) AI_NO_EXCEPT
-    : D3DS::Material(std::move(other))
-    , avSubMaterials(std::move(other.avSubMaterials))
-    , pcInstance(std::move(other.pcInstance))
-    , bNeed(std::move(other.bNeed))
-    {
+            : D3DS::Material(std::move(other)),
+              avSubMaterials(std::move(other.avSubMaterials)),
+              pcInstance(std::move(other.pcInstance)),
+              bNeed(std::move(other.bNeed)) {
         other.pcInstance = nullptr;
     }
 
-
-    Material &operator=( Material &&other) AI_NO_EXCEPT {
+    Material &operator=(Material &&other) AI_NO_EXCEPT {
         if (this == &other) {
             return *this;
         }
@@ -121,15 +116,13 @@ struct Material : public D3DS::Material
         return *this;
     }
 
-
     ~Material() {}
 
-
     //! Contains all sub materials of this material
     std::vector<Material> avSubMaterials;
 
     //! aiMaterial object
-    aiMaterial* pcInstance;
+    aiMaterial *pcInstance;
 
     //! Can we remove this material?
     bool bNeed;
@@ -140,8 +133,8 @@ struct Material : public D3DS::Material
 struct Face : public FaceWithSmoothingGroup {
     //! Default constructor. Initializes everything with 0
     Face() AI_NO_EXCEPT
-    : iMaterial(DEFAULT_MATINDEX)
-    , iFace(0) {
+            : iMaterial(DEFAULT_MATINDEX),
+              iFace(0) {
         // empty
     }
 
@@ -172,8 +165,8 @@ struct Bone {
     Bone() = delete;
 
     //! Construction from an existing name
-    explicit Bone( const std::string& name)
-    : mName(name) {
+    explicit Bone(const std::string &name) :
+            mName(name) {
         // empty
     }
 
@@ -186,33 +179,34 @@ struct Bone {
 struct BoneVertex {
     //! Bone and corresponding vertex weight.
     //! -1 for unrequired bones ....
-    std::vector<std::pair<int,float> > mBoneWeights;
+    std::vector<std::pair<int, float>> mBoneWeights;
 };
 
 // ---------------------------------------------------------------------------
 /** Helper structure to represent an ASE file animation */
 struct Animation {
     enum Type {
-        TRACK   = 0x0,
-        BEZIER  = 0x1,
-        TCB     = 0x2
-    } mRotationType, mScalingType, mPositionType;
+        TRACK = 0x0,
+        BEZIER = 0x1,
+        TCB = 0x2
+    } mRotationType,
+            mScalingType, mPositionType;
 
     Animation() AI_NO_EXCEPT
-    :   mRotationType   (TRACK)
-    ,   mScalingType    (TRACK)
-    ,   mPositionType   (TRACK) {
+            : mRotationType(TRACK),
+              mScalingType(TRACK),
+              mPositionType(TRACK) {
         // empty
     }
 
     //! List of track rotation keyframes
-    std::vector< aiQuatKey > akeyRotations;
+    std::vector<aiQuatKey> akeyRotations;
 
     //! List of track position keyframes
-    std::vector< aiVectorKey > akeyPositions;
+    std::vector<aiVectorKey> akeyPositions;
 
     //! List of track scaling keyframes
-    std::vector< aiVectorKey > akeyScaling;
+    std::vector<aiVectorKey> akeyScaling;
 };
 
 // ---------------------------------------------------------------------------
@@ -220,7 +214,7 @@ struct Animation {
 struct InheritanceInfo {
     //! Default constructor
     InheritanceInfo() AI_NO_EXCEPT {
-        for ( size_t i=0; i<3; ++i ) {
+        for (size_t i = 0; i < 3; ++i) {
             abInheritPosition[i] = abInheritRotation[i] = abInheritScaling[i] = true;
         }
     }
@@ -239,17 +233,15 @@ struct InheritanceInfo {
 /** Represents an ASE file node. Base class for mesh, light and cameras */
 struct BaseNode {
     enum Type {
-        Light, 
-        Camera, 
-        Mesh, 
+        Light,
+        Camera,
+        Mesh,
         Dummy
     } mType;
 
     //! Construction from an existing name
-    BaseNode(Type _mType, const std::string &name)
-    : mType         (_mType)
-    , mName         (name)
-    , mProcessed    (false) {
+    BaseNode(Type _mType, const std::string &name) :
+            mType(_mType), mName(name), mProcessed(false) {
         // Set mTargetPosition to qnan
         const ai_real qnan = get_qnan();
         mTargetPosition.x = qnan;
@@ -289,14 +281,9 @@ struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode {
     Mesh() = delete;
 
     //! Construction from an existing name
-    explicit Mesh(const std::string &name)
-    : BaseNode( BaseNode::Mesh, name )
-    , mVertexColors()
-    , mBoneVertices()
-    , mBones()
-    , iMaterialIndex(Face::DEFAULT_MATINDEX)
-    , bSkip     (false) {
-        for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) {
+    explicit Mesh(const std::string &name) :
+            BaseNode(BaseNode::Mesh, name), mVertexColors(), mBoneVertices(), mBones(), iMaterialIndex(Face::DEFAULT_MATINDEX), bSkip(false) {
+        for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c) {
             this->mNumUVComponents[c] = 2;
         }
     }
@@ -325,10 +312,8 @@ struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode {
 
 // ---------------------------------------------------------------------------
 /** Helper structure to represent an ASE light source */
-struct Light : public BaseNode
-{
-    enum LightType
-    {
+struct Light : public BaseNode {
+    enum LightType {
         OMNI,
         TARGET,
         FREE,
@@ -339,17 +324,13 @@ struct Light : public BaseNode
     Light() = delete;
 
     //! Construction from an existing name
-    explicit Light(const std::string &name)
-    : BaseNode   (BaseNode::Light, name)
-    , mLightType (OMNI)
-    , mColor     (1.f,1.f,1.f)
-    , mIntensity (1.f) // light is white by default
-    , mAngle     (45.f)
-    , mFalloff   (0.f)
-    {
+    explicit Light(const std::string &name) :
+            BaseNode(BaseNode::Light, name), mLightType(OMNI), mColor(1.f, 1.f, 1.f), mIntensity(1.f) // light is white by default
+            ,
+            mAngle(45.f),
+            mFalloff(0.f) {
     }
 
-
     LightType mLightType;
     aiColor3D mColor;
     ai_real mIntensity;
@@ -359,10 +340,8 @@ struct Light : public BaseNode
 
 // ---------------------------------------------------------------------------
 /** Helper structure to represent an ASE camera */
-struct Camera : public BaseNode
-{
-    enum CameraType
-    {
+struct Camera : public BaseNode {
+    enum CameraType {
         FREE,
         TARGET
     };
@@ -370,18 +349,16 @@ struct Camera : public BaseNode
     //! Default constructor has been deleted
     Camera() = delete;
 
-
     //! Construction from an existing name
-    explicit Camera(const std::string &name)
-    : BaseNode    (BaseNode::Camera, name)
-    , mFOV        (0.75f)   // in radians
-    , mNear       (0.1f)
-    , mFar        (1000.f)  // could be zero
-    , mCameraType (FREE)
-    {
+    explicit Camera(const std::string &name) :
+            BaseNode(BaseNode::Camera, name), mFOV(0.75f) // in radians
+            ,
+            mNear(0.1f),
+            mFar(1000.f) // could be zero
+            ,
+            mCameraType(FREE) {
     }
 
-
     ai_real mFOV, mNear, mFar;
     CameraType mCameraType;
 };
@@ -391,7 +368,7 @@ struct Camera : public BaseNode
 struct Dummy : public BaseNode {
     //! Constructor
     Dummy() AI_NO_EXCEPT
-    : BaseNode  (BaseNode::Dummy, "DUMMY") {
+            : BaseNode(BaseNode::Dummy, "DUMMY") {
         // empty
     }
 };
@@ -414,7 +391,6 @@ private:
     }
 
 public:
-
     // -------------------------------------------------------------------
     //! Construct a parser from a given input file which is
     //! guaranteed to be terminated with zero.
@@ -422,15 +398,13 @@ public:
     //! @param fileFormatDefault Assumed file format version. If the
     //!   file format is specified in the file the new value replaces
     //!   the default value.
-    Parser (const char* szFile, unsigned int fileFormatDefault);
+    Parser(const char *szFile, unsigned int fileFormatDefault);
 
     // -------------------------------------------------------------------
     //! Parses the file into the parsers internal representation
     void Parse();
 
-
 private:
-
     // -------------------------------------------------------------------
     //! Parse the *SCENE block in a file
     void ParseLV1SceneBlock();
@@ -446,45 +420,45 @@ private:
     // -------------------------------------------------------------------
     //! Parse a *<xxx>OBJECT block in a file
     //! \param mesh Node to be filled
-    void ParseLV1ObjectBlock(BaseNode& mesh);
+    void ParseLV1ObjectBlock(BaseNode &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *MATERIAL blocks in a material list
     //! \param mat Material structure to be filled
-    void ParseLV2MaterialBlock(Material& mat);
+    void ParseLV2MaterialBlock(Material &mat);
 
     // -------------------------------------------------------------------
     //! Parse a *NODE_TM block in a file
     //! \param mesh Node (!) object to be filled
-    void ParseLV2NodeTransformBlock(BaseNode& mesh);
+    void ParseLV2NodeTransformBlock(BaseNode &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *TM_ANIMATION block in a file
     //! \param mesh Mesh object to be filled
-    void ParseLV2AnimationBlock(BaseNode& mesh);
-    void ParseLV3PosAnimationBlock(ASE::Animation& anim);
-    void ParseLV3ScaleAnimationBlock(ASE::Animation& anim);
-    void ParseLV3RotAnimationBlock(ASE::Animation& anim);
+    void ParseLV2AnimationBlock(BaseNode &mesh);
+    void ParseLV3PosAnimationBlock(ASE::Animation &anim);
+    void ParseLV3ScaleAnimationBlock(ASE::Animation &anim);
+    void ParseLV3RotAnimationBlock(ASE::Animation &anim);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH block in a file
     //! \param mesh Mesh object to be filled
-    void ParseLV2MeshBlock(Mesh& mesh);
+    void ParseLV2MeshBlock(Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *LIGHT_SETTINGS block in a file
     //! \param light Light object to be filled
-    void ParseLV2LightSettingsBlock(Light& light);
+    void ParseLV2LightSettingsBlock(Light &light);
 
     // -------------------------------------------------------------------
     //! Parse a *CAMERA_SETTINGS block in a file
     //! \param cam Camera object to be filled
-    void ParseLV2CameraSettingsBlock(Camera& cam);
+    void ParseLV2CameraSettingsBlock(Camera &cam);
 
     // -------------------------------------------------------------------
     //! Parse the *MAP_XXXXXX blocks in a material
     //! \param map Texture structure to be filled
-    void ParseLV3MapBlock(Texture& map);
+    void ParseLV3MapBlock(Texture &map);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_VERTEX_LIST block in a file
@@ -493,7 +467,7 @@ private:
     //! A warning is sent to the logger if the validations fails.
     //! \param mesh Mesh object to be filled
     void ParseLV3MeshVertexListBlock(
-        unsigned int iNumVertices,Mesh& mesh);
+            unsigned int iNumVertices, Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_FACE_LIST block in a file
@@ -502,7 +476,7 @@ private:
     //! A warning is sent to the logger if the validations fails.
     //! \param mesh Mesh object to be filled
     void ParseLV3MeshFaceListBlock(
-        unsigned int iNumFaces,Mesh& mesh);
+            unsigned int iNumFaces, Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_TVERT_LIST block in a file
@@ -512,7 +486,7 @@ private:
     //! \param mesh Mesh object to be filled
     //! \param iChannel Output UVW channel
     void ParseLV3MeshTListBlock(
-        unsigned int iNumVertices,Mesh& mesh, unsigned int iChannel = 0);
+            unsigned int iNumVertices, Mesh &mesh, unsigned int iChannel = 0);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_TFACELIST block in a file
@@ -522,7 +496,7 @@ private:
     //! \param mesh Mesh object to be filled
     //! \param iChannel Output UVW channel
     void ParseLV3MeshTFaceListBlock(
-        unsigned int iNumFaces,Mesh& mesh, unsigned int iChannel = 0);
+            unsigned int iNumFaces, Mesh &mesh, unsigned int iChannel = 0);
 
     // -------------------------------------------------------------------
     //! Parse an additional mapping channel
@@ -530,7 +504,7 @@ private:
     //! \param iChannel Channel index to be filled
     //! \param mesh Mesh object to be filled
     void ParseLV3MappingChannel(
-        unsigned int iChannel, Mesh& mesh);
+            unsigned int iChannel, Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_CVERTLIST block in a file
@@ -539,7 +513,7 @@ private:
     //! A warning is sent to the logger if the validations fails.
     //! \param mesh Mesh object to be filled
     void ParseLV3MeshCListBlock(
-        unsigned int iNumVertices, Mesh& mesh);
+            unsigned int iNumVertices, Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_CFACELIST block in a file
@@ -548,70 +522,70 @@ private:
     //! A warning is sent to the logger if the validations fails.
     //! \param mesh Mesh object to be filled
     void ParseLV3MeshCFaceListBlock(
-        unsigned int iNumFaces, Mesh& mesh);
+            unsigned int iNumFaces, Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_NORMALS block in a file
     //! \param mesh Mesh object to be filled
-    void ParseLV3MeshNormalListBlock(Mesh& mesh);
+    void ParseLV3MeshNormalListBlock(Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_WEIGHTSblock in a file
     //! \param mesh Mesh object to be filled
-    void ParseLV3MeshWeightsBlock(Mesh& mesh);
+    void ParseLV3MeshWeightsBlock(Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse the bone list of a file
     //! \param mesh Mesh object to be filled
     //! \param iNumBones Number of bones in the mesh
-    void ParseLV4MeshBones(unsigned int iNumBones,Mesh& mesh);
+    void ParseLV4MeshBones(unsigned int iNumBones, Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse the bone vertices list of a file
     //! \param mesh Mesh object to be filled
     //! \param iNumVertices Number of vertices to be parsed
-    void ParseLV4MeshBonesVertices(unsigned int iNumVertices,Mesh& mesh);
+    void ParseLV4MeshBonesVertices(unsigned int iNumVertices, Mesh &mesh);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_FACE block in a file
     //! \param out receive the face data
-    void ParseLV4MeshFace(ASE::Face& out);
+    void ParseLV4MeshFace(ASE::Face &out);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_VERT block in a file
     //! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL  ...)
     //! \param apOut Output buffer (3 floats)
     //! \param rIndexOut Output index
-    void ParseLV4MeshFloatTriple(ai_real* apOut, unsigned int& rIndexOut);
+    void ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_VERT block in a file
     //! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL  ...)
     //! \param apOut Output buffer (3 floats)
-    void ParseLV4MeshFloatTriple(ai_real* apOut);
+    void ParseLV4MeshFloatTriple(ai_real *apOut);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_TFACE block in a file
     //! (also works for MESH_CFACE)
     //! \param apOut Output buffer (3 ints)
     //! \param rIndexOut Output index
-    void ParseLV4MeshLongTriple(unsigned int* apOut, unsigned int& rIndexOut);
+    void ParseLV4MeshLongTriple(unsigned int *apOut, unsigned int &rIndexOut);
 
     // -------------------------------------------------------------------
     //! Parse a *MESH_TFACE block in a file
     //! (also works for MESH_CFACE)
     //! \param apOut Output buffer (3 ints)
-    void ParseLV4MeshLongTriple(unsigned int* apOut);
+    void ParseLV4MeshLongTriple(unsigned int *apOut);
 
     // -------------------------------------------------------------------
     //! Parse a single float element
     //! \param fOut Output float
-    void ParseLV4MeshFloat(ai_real& fOut);
+    void ParseLV4MeshFloat(ai_real &fOut);
 
     // -------------------------------------------------------------------
     //! Parse a single int element
     //! \param iOut Output integer
-    void ParseLV4MeshLong(unsigned int& iOut);
+    void ParseLV4MeshLong(unsigned int &iOut);
 
     // -------------------------------------------------------------------
     //! Skip everything to the next: '*' or '\0'
@@ -625,17 +599,17 @@ private:
     // -------------------------------------------------------------------
     //! Output a warning to the logger
     //! \param szWarn Warn message
-    void LogWarning(const char* szWarn);
+    void LogWarning(const char *szWarn);
 
     // -------------------------------------------------------------------
     //! Output a message to the logger
     //! \param szWarn Message
-    void LogInfo(const char* szWarn);
+    void LogInfo(const char *szWarn);
 
     // -------------------------------------------------------------------
     //! Output an error to the logger
     //! \param szWarn Error message
-    AI_WONT_RETURN void LogError(const char* szWarn) AI_WONT_RETURN_SUFFIX;
+    AI_WONT_RETURN void LogError(const char *szWarn) AI_WONT_RETURN_SUFFIX;
 
     // -------------------------------------------------------------------
     //! Parse a string, enclosed in double quotation marks
@@ -643,12 +617,11 @@ private:
     //! \param szName Name of the enclosing element -> used in error
     //! messages.
     //! \return false if an error occurred
-    bool ParseString(std::string& out,const char* szName);
+    bool ParseString(std::string &out, const char *szName);
 
 public:
-
     //! Pointer to current data
-    const char* filePtr;
+    const char *filePtr;
 
     //! background color to be passed to the viewer
     //! QNAN if none was found
@@ -695,9 +668,8 @@ public:
     unsigned int iFileFormat;
 };
 
-
 } // Namespace ASE
-} // Namespace ASSIMP
+} // namespace Assimp
 
 #endif // ASSIMP_BUILD_NO_3DS_IMPORTER
 

+ 3 - 3
code/AssetLib/Assbin/AssbinFileWriter.cpp

@@ -336,7 +336,7 @@ protected:
     void WriteBinaryNode(IOStream *container, const aiNode *node) {
         AssbinChunkWriter chunk(container, ASSBIN_CHUNK_AINODE);
 
-        unsigned int nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0);
+        unsigned int nb_metadata = (node->mMetaData != nullptr ? node->mMetaData->mNumProperties : 0);
 
         Write<aiString>(&chunk, node->mName);
         Write<aiMatrix4x4>(&chunk, node->mTransformation);
@@ -744,7 +744,7 @@ public:
         };
 
         try {
-            time_t tt = time(NULL);
+            time_t tt = time(nullptr);
 #if _WIN32
             tm *p = gmtime(&tt);
 #else
@@ -790,7 +790,7 @@ public:
             // Up to here the data is uncompressed. For compressed files, the rest
             // is compressed using standard DEFLATE from zlib.
             if (compressed) {
-                AssbinChunkWriter uncompressedStream(NULL, 0);
+                AssbinChunkWriter uncompressedStream(nullptr, 0);
                 WriteBinaryScene(&uncompressedStream, pScene);
 
                 uLongf uncompressedSize = static_cast<uLongf>(uncompressedStream.Tell());

+ 1 - 1
code/AssetLib/Assbin/AssbinLoader.cpp

@@ -604,7 +604,7 @@ void AssbinImporter::ReadBinaryScene(IOStream *stream, aiScene *scene) {
 
     // Read node graph
     //scene->mRootNode = new aiNode[1];
-    ReadBinaryNode(stream, &scene->mRootNode, (aiNode *)NULL);
+    ReadBinaryNode(stream, &scene->mRootNode, (aiNode *)nullptr);
 
     // Read all meshes
     if (scene->mNumMeshes) {

+ 1 - 1
code/AssetLib/Assxml/AssxmlFileWriter.cpp

@@ -189,7 +189,7 @@ static std::string encodeXML(const std::string &data) {
 // -----------------------------------------------------------------------------------
 // Write a text model dump
 static void WriteDump(const char *pFile, const char *cmd, const aiScene *scene, IOStream *io, bool shortened) {
-    time_t tt = ::time(NULL);
+    time_t tt = ::time(nullptr);
 #if _WIN32
     tm *p = gmtime(&tt);
 #else

+ 2 - 2
code/AssetLib/BVH/BVHLoader.cpp

@@ -422,9 +422,9 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
     anim->mNumChannels = static_cast<unsigned int>(mNodes.size());
     anim->mChannels = new aiNodeAnim *[anim->mNumChannels];
 
-    // FIX: set the array elements to NULL to ensure proper deletion if an exception is thrown
+    // FIX: set the array elements to nullptr to ensure proper deletion if an exception is thrown
     for (unsigned int i = 0; i < anim->mNumChannels; ++i)
-        anim->mChannels[i] = NULL;
+        anim->mChannels[i] = nullptr;
 
     for (unsigned int a = 0; a < anim->mNumChannels; a++) {
         const Node &node = mNodes[a];

+ 6 - 6
code/AssetLib/Blender/BlenderDNA.h

@@ -230,7 +230,7 @@ public:
 
     // --------------------------------------------------------
     /** Access a field of the structure by its canonical name. The pointer version
-     *  returns NULL on failure while the reference version raises an import error. */
+     *  returns nullptr on failure while the reference version raises an import error. */
     inline const Field &operator[](const std::string &ss) const;
     inline const Field *Get(const std::string &ss) const;
 
@@ -359,7 +359,7 @@ private:
     template <typename T>
     T *_allocate(vector<T> &out, size_t &s) const {
         out.resize(s);
-        return s ? &out.front() : NULL;
+        return s ? &out.front() : nullptr;
     }
 
     // --------------------------------------------------------
@@ -367,14 +367,14 @@ private:
     struct _defaultInitializer {
 
         template <typename T, unsigned int N>
-        void operator()(T (&out)[N], const char * = NULL) {
+        void operator()(T (&out)[N], const char * = nullptr) {
             for (unsigned int i = 0; i < N; ++i) {
                 out[i] = T();
             }
         }
 
         template <typename T, unsigned int N, unsigned int M>
-        void operator()(T (&out)[N][M], const char * = NULL) {
+        void operator()(T (&out)[N][M], const char * = nullptr) {
             for (unsigned int i = 0; i < N; ++i) {
                 for (unsigned int j = 0; j < M; ++j) {
                     out[i][j] = T();
@@ -383,7 +383,7 @@ private:
         }
 
         template <typename T>
-        void operator()(T &out, const char * = NULL) {
+        void operator()(T &out, const char * = nullptr) {
             out = T();
         }
     };
@@ -448,7 +448,7 @@ public:
 
 public:
     // --------------------------------------------------------
-    /** Access a structure by its canonical name, the pointer version returns NULL on failure
+    /** Access a structure by its canonical name, the pointer version returns nullptr on failure
       * while the reference version raises an error. */
     inline const Structure &operator[](const std::string &ss) const;
     inline const Structure *Get(const std::string &ss) const;

+ 1 - 1
code/AssetLib/Blender/BlenderDNA.inl

@@ -69,7 +69,7 @@ const Field& Structure :: operator [] (const std::string& ss) const
 const Field* Structure :: Get (const std::string& ss) const
 {
     std::map<std::string, size_t>::const_iterator it = indices.find(ss);
-    return it == indices.end() ? NULL : &fields[(*it).second];
+    return it == indices.end() ? nullptr : &fields[(*it).second];
 }
 
 //--------------------------------------------------------------------------------

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 240 - 281
code/AssetLib/Blender/BlenderLoader.cpp


+ 2 - 0
code/AssetLib/COB/COBLoader.cpp

@@ -322,7 +322,9 @@ aiNode *COBImporter::BuildNodes(const Node &root, const Scene &scin, aiScene *fi
                             break;
 
                         default:
+                            ASSIMP_LOG_ERROR("Unknown option.");
                             ai_assert(false); // shouldn't be here
+                            break;
                         }
                         mat->AddProperty(&shader, 1, AI_MATKEY_SHADING_MODEL);
                         if (shader != aiShadingMode_Gouraud) {

+ 1 - 1
code/AssetLib/CSM/CSMLoader.cpp

@@ -127,7 +127,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
 
     // Check whether we can read from the file
-    if( file.get() == NULL) {
+    if( file.get() == nullptr) {
         throw DeadlyImportError( "Failed to open CSM file " + pFile + ".");
     }
 

+ 4 - 4
code/AssetLib/Collada/ColladaHelper.h

@@ -298,14 +298,14 @@ struct Accessor {
     size_t mSubOffset[4]; // Suboffset inside the object for the common 4 elements. For a vector, that's XYZ, for a color RGBA and so on.
             // For example, SubOffset[0] denotes which of the values inside the object is the vector X component.
     std::string mSource; // URL of the source array
-    mutable const Data *mData; // Pointer to the source array, if resolved. NULL else
+    mutable const Data *mData; // Pointer to the source array, if resolved. nullptr else
 
     Accessor() {
         mCount = 0;
         mSize = 0;
         mOffset = 0;
         mStride = 0;
-        mData = NULL;
+        mData = nullptr;
         mSubOffset[0] = mSubOffset[1] = mSubOffset[2] = mSubOffset[3] = 0;
     }
 };
@@ -321,13 +321,13 @@ struct InputChannel {
     size_t mIndex; // Optional index, if multiple sets of the same data type are given
     size_t mOffset; // Index offset in the indices array of per-face indices. Don't ask, can't explain that any better.
     std::string mAccessor; // ID of the accessor where to read the actual values from.
-    mutable const Accessor *mResolved; // Pointer to the accessor, if resolved. NULL else
+    mutable const Accessor *mResolved; // Pointer to the accessor, if resolved. nullptr else
 
     InputChannel() {
         mType = IT_Invalid;
         mIndex = 0;
         mOffset = 0;
-        mResolved = NULL;
+        mResolved = nullptr;
     }
 };
 

+ 12 - 10
code/AssetLib/Collada/ColladaLoader.cpp

@@ -145,7 +145,7 @@ bool ColladaLoader::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool
     if (extension == "xml" || !extension.length() || checkSig) {
         /*  If CanRead() is called in order to check whether we
          *  support a specific file extension in general pIOHandler
-         *  might be NULL and it's our duty to return true here.
+         *  might be nullptr and it's our duty to return true here.
          */
         if (!pIOHandler) {
             return true;
@@ -316,7 +316,7 @@ void ColladaLoader::ResolveNodeInstances(const ColladaParser &pParser, const Col
     for (const auto &nodeInst : pNode->mNodeInstances) {
         // find the corresponding node in the library
         const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find(nodeInst.mNode);
-        const Collada::Node *nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second;
+        const Collada::Node *nd = itt == pParser.mNodeLibrary.end() ? nullptr : (*itt).second;
 
         // FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632
         // need to check for both name and ID to catch all. To avoid breaking valid files,
@@ -716,7 +716,7 @@ aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Collada::M
                     if (targetMesh->mSubMeshes.size() > 1) {
                         throw DeadlyImportError("Morphing target mesh must be a single");
                     }
-                    aimesh = CreateMesh(pParser, targetMesh, targetMesh->mSubMeshes.at(0), NULL, 0, 0);
+                    aimesh = CreateMesh(pParser, targetMesh, targetMesh->mSubMeshes.at(0), nullptr, 0, 0);
                     mTargetMeshes.push_back(aimesh);
                 }
                 targetMeshes.push_back(aimesh);
@@ -1000,7 +1000,7 @@ void ColladaLoader::StoreAnimations(aiScene *pScene, const ColladaParser &pParse
                 combinedAnim->mChannels = new aiNodeAnim *[combinedAnim->mNumChannels];
                 // add the template anim as first channel by moving its aiNodeAnim to the combined animation
                 combinedAnim->mChannels[0] = templateAnim->mChannels[0];
-                templateAnim->mChannels[0] = NULL;
+                templateAnim->mChannels[0] = nullptr;
                 delete templateAnim;
                 // combined animation replaces template animation in the anim array
                 mAnims[a] = combinedAnim;
@@ -1009,7 +1009,7 @@ void ColladaLoader::StoreAnimations(aiScene *pScene, const ColladaParser &pParse
                 for (size_t b = 0; b < collectedAnimIndices.size(); ++b) {
                     aiAnimation *srcAnimation = mAnims[collectedAnimIndices[b]];
                     combinedAnim->mChannels[1 + b] = srcAnimation->mChannels[0];
-                    srcAnimation->mChannels[0] = NULL;
+                    srcAnimation->mChannels[0] = nullptr;
                     delete srcAnimation;
                 }
 
@@ -1116,9 +1116,9 @@ void ColladaLoader::CreateAnimation(aiScene *pScene, const ColladaParser &pParse
 
         // find the collada node corresponding to the aiNode
         const Collada::Node *srcNode = FindNode(pParser.mRootNode, nodeName);
-        //      ai_assert( srcNode != NULL);
-        if (!srcNode)
+        if (!srcNode) {
             continue;
+        }
 
         // now check all channels if they affect the current node
         std::string targetID, subElement;
@@ -1132,8 +1132,9 @@ void ColladaLoader::CreateAnimation(aiScene *pScene, const ColladaParser &pParse
             std::string::size_type slashPos = srcChannel.mTarget.find('/');
             if (slashPos == std::string::npos) {
                 std::string::size_type targetPos = srcChannel.mTarget.find(srcNode->mID);
-                if (targetPos == std::string::npos)
+                if (targetPos == std::string::npos) {
                     continue;
+                }
 
                 // not node transform, but something else. store as unknown animation channel for now
                 entry.mChannel = &(*cit);
@@ -1777,11 +1778,12 @@ const Collada::Node *ColladaLoader::FindNode(const Collada::Node *pNode, const s
 
     for (size_t a = 0; a < pNode->mChildren.size(); ++a) {
         const Collada::Node *node = FindNode(pNode->mChildren[a], pName);
-        if (node)
+        if (node) {
             return node;
+        }
     }
 
-    return NULL;
+    return nullptr;
 }
 
 // ------------------------------------------------------------------------------------------------

+ 13 - 16
code/AssetLib/Collada/ColladaParser.cpp

@@ -89,7 +89,7 @@ ColladaParser::ColladaParser(IOSystem *pIOHandler, const std::string &pFile) :
 {
     // validate io-handler instance
     if (nullptr == pIOHandler) {
-        throw DeadlyImportError("IOSystem is NULL.");
+        throw DeadlyImportError("IOSystem is nullptr.");
     }
 
     std::unique_ptr<IOStream> daefile;
@@ -322,7 +322,7 @@ void ColladaParser::ReadStructure() {
             else if (IsElement("library_cameras"))
                 ReadCameraLibrary();
             else if (IsElement("library_nodes"))
-                ReadSceneNode(NULL); /* some hacking to reuse this piece of code */
+                ReadSceneNode(nullptr); /* some hacking to reuse this piece of code */
             else if (IsElement("scene"))
                 ReadScene();
             else
@@ -588,7 +588,7 @@ void ColladaParser::ReadAnimation(Collada::Animation *pParent) {
     typedef std::map<std::string, AnimationChannel> ChannelMap;
     ChannelMap channels;
     // this is the anim container in case we're a container
-    Animation *anim = NULL;
+    Animation *anim = nullptr;
 
     // optional name given as an attribute
     std::string animName;
@@ -1713,9 +1713,6 @@ void ColladaParser::ReadGeometryLibrary() {
                 int indexID = GetAttribute("id");
                 std::string id = mReader->getAttributeValue(indexID);
 
-                // TODO: (thom) support SIDs
-                // ai_assert( TestAttribute( "sid") == -1);
-
                 // create a mesh and store it in the library under its (resolved) ID
                 // Skip and warn if ID is not unique
                 if (mMeshLibrary.find(id) == mMeshLibrary.cend()) {
@@ -2329,7 +2326,7 @@ size_t ColladaParser::ReadPrimitives(Mesh &pMesh, std::vector<InputChannel> &pPe
     return numPrimitives;
 }
 
-///@note This function willn't work correctly if both PerIndex and PerVertex channels have same channels.
+///@note This function won't work correctly if both PerIndex and PerVertex channels have same channels.
 ///For example if TEXCOORD present in both <vertices> and <polylist> tags this function will create wrong uv coordinates.
 ///It's not clear from COLLADA documentation is this allowed or not. For now only exporter fixed to avoid such behavior
 void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset, Mesh &pMesh, std::vector<InputChannel> &pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t> &indices) {
@@ -2525,8 +2522,6 @@ void ColladaParser::ReadSceneNode(Node *pNode) {
                 if (attrName > -1)
                     child->mName = mReader->getAttributeValue(attrName);
 
-                // TODO: (thom) support SIDs
-                // ai_assert( TestAttribute( "sid") == -1);
 
                 if (pNode) {
                     pNode->mChildren.push_back(child);
@@ -2557,7 +2552,7 @@ void ColladaParser::ReadSceneNode(Node *pNode) {
                 ReadNodeTransformation(pNode, TF_SKEW);
             else if (IsElement("translate"))
                 ReadNodeTransformation(pNode, TF_TRANSLATE);
-            else if (IsElement("render") && pNode->mParent == NULL && 0 == pNode->mPrimaryCamera.length()) {
+            else if (IsElement("render") && pNode->mParent == nullptr && 0 == pNode->mPrimaryCamera.length()) {
                 // ... scene evaluation or, in other words, postprocessing pipeline,
                 // or, again in other words, a turing-complete description how to
                 // render a Collada scene. The only thing that is interesting for
@@ -2915,17 +2910,19 @@ const char *ColladaParser::GetTextContent() {
 }
 
 // ------------------------------------------------------------------------------------------------
-// Reads the text contents of an element, returns NULL if not given. Skips leading whitespace.
+// Reads the text contents of an element, returns nullptr if not given. Skips leading whitespace.
 const char *ColladaParser::TestTextContent() {
     // present node should be the beginning of an element
     if (mReader->getNodeType() != irr::io::EXN_ELEMENT || mReader->isEmptyElement())
-        return NULL;
+        return nullptr;
 
     // read contents of the element
-    if (!mReader->read())
-        return NULL;
-    if (mReader->getNodeType() != irr::io::EXN_TEXT && mReader->getNodeType() != irr::io::EXN_CDATA)
-        return NULL;
+    if (!mReader->read()) {
+        return nullptr;
+    }
+    if (mReader->getNodeType() != irr::io::EXN_TEXT && mReader->getNodeType() != irr::io::EXN_CDATA) {
+        return nullptr;
+    }
 
     // skip leading whitespace
     const char *text = mReader->getNodeData();

+ 1 - 1
code/AssetLib/Collada/ColladaParser.h

@@ -272,7 +272,7 @@ protected:
          Skips leading whitespace. */
     const char *GetTextContent();
 
-    /** Reads the text contents of an element, returns NULL if not given.
+    /** Reads the text contents of an element, returns nullptr if not given.
          Skips leading whitespace. */
     const char *TestTextContent();
 

+ 77 - 92
code/AssetLib/FBX/FBXAnimation.cpp

@@ -47,10 +47,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
 
-#include "FBXParser.h"
 #include "FBXDocument.h"
-#include "FBXImporter.h"
 #include "FBXDocumentUtil.h"
+#include "FBXImporter.h"
+#include "FBXParser.h"
 
 namespace Assimp {
 namespace FBX {
@@ -58,65 +58,60 @@ namespace FBX {
 using namespace Util;
 
 // ------------------------------------------------------------------------------------------------
-AnimationCurve::AnimationCurve(uint64_t id, const Element& element, const std::string& name, const Document& /*doc*/)
-: Object(id, element, name)
-{
-    const Scope& sc = GetRequiredScope(element);
-    const Element& KeyTime = GetRequiredElement(sc,"KeyTime");
-    const Element& KeyValueFloat = GetRequiredElement(sc,"KeyValueFloat");
+AnimationCurve::AnimationCurve(uint64_t id, const Element &element, const std::string &name, const Document & /*doc*/) :
+        Object(id, element, name) {
+    const Scope &sc = GetRequiredScope(element);
+    const Element &KeyTime = GetRequiredElement(sc, "KeyTime");
+    const Element &KeyValueFloat = GetRequiredElement(sc, "KeyValueFloat");
 
     ParseVectorDataArray(keys, KeyTime);
     ParseVectorDataArray(values, KeyValueFloat);
 
-    if(keys.size() != values.size()) {
-        DOMError("the number of key times does not match the number of keyframe values",&KeyTime);
+    if (keys.size() != values.size()) {
+        DOMError("the number of key times does not match the number of keyframe values", &KeyTime);
     }
 
     // check if the key times are well-ordered
-    if(!std::equal(keys.begin(), keys.end() - 1, keys.begin() + 1, std::less<KeyTimeList::value_type>())) {
-        DOMError("the keyframes are not in ascending order",&KeyTime);
+    if (!std::equal(keys.begin(), keys.end() - 1, keys.begin() + 1, std::less<KeyTimeList::value_type>())) {
+        DOMError("the keyframes are not in ascending order", &KeyTime);
     }
 
-    const Element* KeyAttrDataFloat = sc["KeyAttrDataFloat"];
-    if(KeyAttrDataFloat) {
+    const Element *KeyAttrDataFloat = sc["KeyAttrDataFloat"];
+    if (KeyAttrDataFloat) {
         ParseVectorDataArray(attributes, *KeyAttrDataFloat);
     }
 
-    const Element* KeyAttrFlags = sc["KeyAttrFlags"];
-    if(KeyAttrFlags) {
+    const Element *KeyAttrFlags = sc["KeyAttrFlags"];
+    if (KeyAttrFlags) {
         ParseVectorDataArray(flags, *KeyAttrFlags);
     }
 }
 
 // ------------------------------------------------------------------------------------------------
-AnimationCurve::~AnimationCurve()
-{
+AnimationCurve::~AnimationCurve() {
     // empty
 }
 
 // ------------------------------------------------------------------------------------------------
-AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, const std::string& name, 
-        const Document& doc, const char* const * target_prop_whitelist /*= NULL*/, 
-        size_t whitelist_size /*= 0*/)
-: Object(id, element, name)
-, target()
-, doc(doc)
-{
-    const Scope& sc = GetRequiredScope(element);
+AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element &element, const std::string &name,
+        const Document &doc, const char *const *target_prop_whitelist /*= nullptr*/,
+        size_t whitelist_size /*= 0*/) :
+        Object(id, element, name), target(), doc(doc) {
+    const Scope &sc = GetRequiredScope(element);
 
     // find target node
-    const char* whitelist[] = {"Model","NodeAttribute","Deformer"};
-    const std::vector<const Connection*>& conns = doc.GetConnectionsBySourceSequenced(ID(),whitelist,3);
+    const char *whitelist[] = { "Model", "NodeAttribute", "Deformer" };
+    const std::vector<const Connection *> &conns = doc.GetConnectionsBySourceSequenced(ID(), whitelist, 3);
 
-    for(const Connection* con : conns) {
+    for (const Connection *con : conns) {
 
         // link should go for a property
         if (!con->PropertyName().length()) {
             continue;
         }
 
-        if(target_prop_whitelist) {
-            const char* const s = con->PropertyName().c_str();
+        if (target_prop_whitelist) {
+            const char *const s = con->PropertyName().c_str();
             bool ok = false;
             for (size_t i = 0; i < whitelist_size; ++i) {
                 if (!strcmp(s, target_prop_whitelist[i])) {
@@ -130,16 +125,14 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
             }
         }
 
-        const Object* const ob = con->DestinationObject();
-        if(!ob) {
-            DOMWarning("failed to read destination object for AnimationCurveNode->Model link, ignoring",&element);
+        const Object *const ob = con->DestinationObject();
+        if (!ob) {
+            DOMWarning("failed to read destination object for AnimationCurveNode->Model link, ignoring", &element);
             continue;
         }
 
-        // XXX support constraints as DOM class
-        //ai_assert(dynamic_cast<const Model*>(ob) || dynamic_cast<const NodeAttribute*>(ob));
         target = ob;
-        if(!target) {
+        if (!target) {
             continue;
         }
 
@@ -147,42 +140,40 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
         break;
     }
 
-    if(!target) {
-        DOMWarning("failed to resolve target Model/NodeAttribute/Constraint for AnimationCurveNode",&element);
+    if (!target) {
+        DOMWarning("failed to resolve target Model/NodeAttribute/Constraint for AnimationCurveNode", &element);
     }
 
-    props = GetPropertyTable(doc,"AnimationCurveNode.FbxAnimCurveNode",element,sc,false);
+    props = GetPropertyTable(doc, "AnimationCurveNode.FbxAnimCurveNode", element, sc, false);
 }
 
 // ------------------------------------------------------------------------------------------------
-AnimationCurveNode::~AnimationCurveNode()
-{
+AnimationCurveNode::~AnimationCurveNode() {
     // empty
 }
 
 // ------------------------------------------------------------------------------------------------
-const AnimationCurveMap& AnimationCurveNode::Curves() const
-{
-    if ( curves.empty() ) {
+const AnimationCurveMap &AnimationCurveNode::Curves() const {
+    if (curves.empty()) {
         // resolve attached animation curves
-        const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationCurve");
+        const std::vector<const Connection *> &conns = doc.GetConnectionsByDestinationSequenced(ID(), "AnimationCurve");
 
-        for(const Connection* con : conns) {
+        for (const Connection *con : conns) {
 
             // link should go for a property
             if (!con->PropertyName().length()) {
                 continue;
             }
 
-            const Object* const ob = con->SourceObject();
-            if(!ob) {
-                DOMWarning("failed to read source object for AnimationCurve->AnimationCurveNode link, ignoring",&element);
+            const Object *const ob = con->SourceObject();
+            if (nullptr == ob) {
+                DOMWarning("failed to read source object for AnimationCurve->AnimationCurveNode link, ignoring", &element);
                 continue;
             }
 
-            const AnimationCurve* const anim = dynamic_cast<const AnimationCurve*>(ob);
-            if(!anim) {
-                DOMWarning("source object for ->AnimationCurveNode link is not an AnimationCurve",&element);
+            const AnimationCurve *const anim = dynamic_cast<const AnimationCurve *>(ob);
+            if (nullptr == anim) {
+                DOMWarning("source object for ->AnimationCurveNode link is not an AnimationCurve", &element);
                 continue;
             }
 
@@ -194,53 +185,49 @@ const AnimationCurveMap& AnimationCurveNode::Curves() const
 }
 
 // ------------------------------------------------------------------------------------------------
-AnimationLayer::AnimationLayer(uint64_t id, const Element& element, const std::string& name, const Document& doc)
-: Object(id, element, name)
-, doc(doc)
-{
-    const Scope& sc = GetRequiredScope(element);
+AnimationLayer::AnimationLayer(uint64_t id, const Element &element, const std::string &name, const Document &doc) :
+        Object(id, element, name), doc(doc) {
+    const Scope &sc = GetRequiredScope(element);
 
     // note: the props table here bears little importance and is usually absent
-    props = GetPropertyTable(doc,"AnimationLayer.FbxAnimLayer",element,sc, true);
+    props = GetPropertyTable(doc, "AnimationLayer.FbxAnimLayer", element, sc, true);
 }
 
 // ------------------------------------------------------------------------------------------------
-AnimationLayer::~AnimationLayer()
-{
+AnimationLayer::~AnimationLayer() {
     // empty
 }
 
 // ------------------------------------------------------------------------------------------------
-AnimationCurveNodeList AnimationLayer::Nodes(const char* const * target_prop_whitelist /*= NULL*/,
-    size_t whitelist_size /*= 0*/) const
-{
+AnimationCurveNodeList AnimationLayer::Nodes(const char *const *target_prop_whitelist /*= nullptr*/,
+        size_t whitelist_size /*= 0*/) const {
     AnimationCurveNodeList nodes;
 
     // resolve attached animation nodes
-    const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationCurveNode");
+    const std::vector<const Connection *> &conns = doc.GetConnectionsByDestinationSequenced(ID(), "AnimationCurveNode");
     nodes.reserve(conns.size());
 
-    for(const Connection* con : conns) {
+    for (const Connection *con : conns) {
 
         // link should not go to a property
         if (con->PropertyName().length()) {
             continue;
         }
 
-        const Object* const ob = con->SourceObject();
-        if(!ob) {
-            DOMWarning("failed to read source object for AnimationCurveNode->AnimationLayer link, ignoring",&element);
+        const Object *const ob = con->SourceObject();
+        if (!ob) {
+            DOMWarning("failed to read source object for AnimationCurveNode->AnimationLayer link, ignoring", &element);
             continue;
         }
 
-        const AnimationCurveNode* const anim = dynamic_cast<const AnimationCurveNode*>(ob);
-        if(!anim) {
-            DOMWarning("source object for ->AnimationLayer link is not an AnimationCurveNode",&element);
+        const AnimationCurveNode *const anim = dynamic_cast<const AnimationCurveNode *>(ob);
+        if (!anim) {
+            DOMWarning("source object for ->AnimationLayer link is not an AnimationCurveNode", &element);
             continue;
         }
 
-        if(target_prop_whitelist) {
-            const char* s = anim->TargetProperty().c_str();
+        if (target_prop_whitelist) {
+            const char *s = anim->TargetProperty().c_str();
             bool ok = false;
             for (size_t i = 0; i < whitelist_size; ++i) {
                 if (!strcmp(s, target_prop_whitelist[i])) {
@@ -248,7 +235,7 @@ AnimationCurveNodeList AnimationLayer::Nodes(const char* const * target_prop_whi
                     break;
                 }
             }
-            if(!ok) {
+            if (!ok) {
                 continue;
             }
         }
@@ -259,34 +246,33 @@ AnimationCurveNodeList AnimationLayer::Nodes(const char* const * target_prop_whi
 }
 
 // ------------------------------------------------------------------------------------------------
-AnimationStack::AnimationStack(uint64_t id, const Element& element, const std::string& name, const Document& doc)
-: Object(id, element, name)
-{
-    const Scope& sc = GetRequiredScope(element);
+AnimationStack::AnimationStack(uint64_t id, const Element &element, const std::string &name, const Document &doc) :
+        Object(id, element, name) {
+    const Scope &sc = GetRequiredScope(element);
 
     // note: we don't currently use any of these properties so we shouldn't bother if it is missing
-    props = GetPropertyTable(doc,"AnimationStack.FbxAnimStack",element,sc, true);
+    props = GetPropertyTable(doc, "AnimationStack.FbxAnimStack", element, sc, true);
 
     // resolve attached animation layers
-    const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"AnimationLayer");
+    const std::vector<const Connection *> &conns = doc.GetConnectionsByDestinationSequenced(ID(), "AnimationLayer");
     layers.reserve(conns.size());
 
-    for(const Connection* con : conns) {
+    for (const Connection *con : conns) {
 
         // link should not go to a property
         if (con->PropertyName().length()) {
             continue;
         }
 
-        const Object* const ob = con->SourceObject();
-        if(!ob) {
-            DOMWarning("failed to read source object for AnimationLayer->AnimationStack link, ignoring",&element);
+        const Object *const ob = con->SourceObject();
+        if (!ob) {
+            DOMWarning("failed to read source object for AnimationLayer->AnimationStack link, ignoring", &element);
             continue;
         }
 
-        const AnimationLayer* const anim = dynamic_cast<const AnimationLayer*>(ob);
-        if(!anim) {
-            DOMWarning("source object for ->AnimationStack link is not an AnimationLayer",&element);
+        const AnimationLayer *const anim = dynamic_cast<const AnimationLayer *>(ob);
+        if (!anim) {
+            DOMWarning("source object for ->AnimationStack link is not an AnimationLayer", &element);
             continue;
         }
         layers.push_back(anim);
@@ -294,12 +280,11 @@ AnimationStack::AnimationStack(uint64_t id, const Element& element, const std::s
 }
 
 // ------------------------------------------------------------------------------------------------
-AnimationStack::~AnimationStack()
-{
+AnimationStack::~AnimationStack() {
     // empty
 }
 
-} //!FBX
-} //!Assimp
+} // namespace FBX
+} // namespace Assimp
 
 #endif // ASSIMP_BUILD_NO_FBX_IMPORTER

+ 4 - 7
code/AssetLib/FBX/FBXConverter.cpp

@@ -804,11 +804,6 @@ bool FBXConverter::GenerateTransformationNodeChain(const Model &model, const std
         aiMatrix4x4::Translation(-GeometricTranslation, chain[TransformationComp_GeometricTranslationInverse]);
     }
 
-    // is_complex needs to be consistent with NeedsComplexTransformationChain()
-    // or the interplay between this code and the animation converter would
-    // not be guaranteed.
-    //ai_assert(NeedsComplexTransformationChain(model) == ((chainBits & chainMaskComplex) != 0));
-
     // now, if we have more than just Translation, Scaling and Rotation,
     // we need to generate a full node chain to accommodate for assimp's
     // lack to express pivots and offsets.
@@ -1290,7 +1285,8 @@ unsigned int FBXConverter::ConvertMeshMultiMaterial(const MeshGeometry &mesh, co
         }
 
         if (binormals) {
-            ai_assert(tangents.size() == vertices.size() && binormals->size() == vertices.size());
+            ai_assert(tangents.size() == vertices.size());
+            ai_assert(binormals->size() == vertices.size());
 
             out_mesh->mTangents = new aiVector3D[vertices.size()];
             out_mesh->mBitangents = new aiVector3D[vertices.size()];
@@ -3165,7 +3161,8 @@ FBXConverter::KeyFrameListList FBXConverter::GetKeyframeList(const std::vector<c
             }
 
             const AnimationCurve *const curve = kv.second;
-            ai_assert(curve->GetKeys().size() == curve->GetValues().size() && curve->GetKeys().size());
+            ai_assert(curve->GetKeys().size() == curve->GetValues().size());
+            ai_assert(curve->GetKeys().size());
 
             //get values within the start/stop time window
             std::shared_ptr<KeyTimeList> Keys(new KeyTimeList());

+ 2 - 2
code/AssetLib/FBX/FBXConverter.h

@@ -220,8 +220,8 @@ private:
     *    each output vertex the DOM index it maps to.
     */
     void ConvertWeights(aiMesh *out, const MeshGeometry &geo, const aiMatrix4x4 &absolute_transform,
-                        aiNode *parent = NULL, unsigned int materialIndex = NO_MATERIAL_SEPARATION,
-                        std::vector<unsigned int> *outputVertStartIndices = NULL);
+            aiNode *parent = nullptr, unsigned int materialIndex = NO_MATERIAL_SEPARATION,
+            std::vector<unsigned int> *outputVertStartIndices = nullptr);
 
     // ------------------------------------------------------------------------------------------------
     void ConvertCluster(std::vector<aiBone *> &local_mesh_bones, const Cluster *cl,

+ 2 - 2
code/AssetLib/FBX/FBXDocument.cpp

@@ -221,7 +221,7 @@ const Object* LazyObject::Get(bool dieOnError)
         if(!DefaultLogger::isNullLogger()) {
             ASSIMP_LOG_ERROR(ex.what());
         }
-        return NULL;
+        return nullptr;
     }
 
     if (!object.get()) {
@@ -467,7 +467,7 @@ void Document::ReadPropertyTemplates()
             const Element *Properties70 = (*innerSc)["Properties70"];
             if(Properties70) {
                 std::shared_ptr<const PropertyTable> props = std::make_shared<const PropertyTable>(
-                    *Properties70,std::shared_ptr<const PropertyTable>(static_cast<const PropertyTable*>(NULL))
+                        *Properties70, std::shared_ptr<const PropertyTable>(static_cast<const PropertyTable *>(nullptr))
                 );
 
                 templates[oname+"."+pname] = props;

+ 6 - 5
code/AssetLib/FBX/FBXDocument.h

@@ -96,7 +96,7 @@ public:
     template <typename T>
     const T* Get(bool dieOnError = false) {
         const Object* const ob = Get(dieOnError);
-        return ob ? dynamic_cast<const T*>(ob) : NULL;
+        return ob ? dynamic_cast<const T *>(ob) : nullptr;
     }
 
     uint64_t ID() const {
@@ -213,7 +213,8 @@ private:
     type name() const { \
         const int ival = PropertyGet<int>(Props(), fbx_stringize(name), static_cast<int>(default_value)); \
         if (ival < 0 || ival >= AI_CONCAT(type, _MAX)) { \
-            ai_assert(static_cast<int>(default_value) >= 0 && static_cast<int>(default_value) < AI_CONCAT(type, _MAX)); \
+            ai_assert(static_cast<int>(default_value) >= 0); \
+            ai_assert(static_cast<int>(default_value) < AI_CONCAT(type, _MAX)); \
             return static_cast<type>(default_value); \
         } \
         return static_cast<type>(ival); \
@@ -744,7 +745,7 @@ public:
     wants animations for. If the curve node does not match one of these, std::range_error
     will be thrown. */
     AnimationCurveNode(uint64_t id, const Element& element, const std::string& name, const Document& doc,
-        const char* const * target_prop_whitelist = NULL, size_t whitelist_size = 0);
+            const char *const *target_prop_whitelist = nullptr, size_t whitelist_size = 0);
 
     virtual ~AnimationCurveNode();
 
@@ -756,7 +757,7 @@ public:
 
     const AnimationCurveMap& Curves() const;
 
-    /** Object the curve is assigned to, this can be NULL if the
+    /** Object the curve is assigned to, this can be nullptr if the
      *  target object has no DOM representation or could not
      *  be read for other reasons.*/
     const Object* Target() const {
@@ -968,7 +969,7 @@ public:
 
     // note: a connection ensures that the source and dest objects exist, but
     // not that they have DOM representations, so the return value of one of
-    // these functions can still be NULL.
+    // these functions can still be nullptr.
     const Object* SourceObject() const;
     const Object* DestinationObject() const;
 

+ 3 - 3
code/AssetLib/FBX/FBXDocumentUtil.cpp

@@ -65,7 +65,7 @@ void DOMError(const std::string& message, const Token& token)
 }
 
 // ------------------------------------------------------------------------------------------------
-void DOMError(const std::string& message, const Element* element /*= NULL*/)
+void DOMError(const std::string& message, const Element* element /*= nullptr*/)
 {
     if(element) {
         DOMError(message,element->KeyToken());
@@ -84,7 +84,7 @@ void DOMWarning(const std::string& message, const Token& token)
 }
 
 // ------------------------------------------------------------------------------------------------
-void DOMWarning(const std::string& message, const Element* element /*= NULL*/)
+void DOMWarning(const std::string& message, const Element* element /*= nullptr*/)
 {
     if(element) {
         DOMWarning(message,element->KeyToken());
@@ -106,7 +106,7 @@ std::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc,
 {
     const Element* const Properties70 = sc["Properties70"];
     std::shared_ptr<const PropertyTable> templateProps = std::shared_ptr<const PropertyTable>(
-        static_cast<const PropertyTable*>(NULL));
+            static_cast<const PropertyTable *>(nullptr));
 
     if(templateName.length()) {
         PropertyTemplateMap::const_iterator it = doc.Templates().find(templateName);

+ 1 - 1
code/AssetLib/FBX/FBXMeshGeometry.cpp

@@ -241,7 +241,7 @@ const MatIndexArray& MeshGeometry::GetMaterialIndices() const {
 // ------------------------------------------------------------------------------------------------
 const unsigned int* MeshGeometry::ToOutputVertexIndex( unsigned int in_index, unsigned int& count ) const {
     if ( in_index >= m_mapping_counts.size() ) {
-        return NULL;
+        return nullptr;
     }
 
     ai_assert( m_mapping_counts.size() == m_mapping_offsets.size() );

+ 3 - 3
code/AssetLib/FBX/FBXMeshGeometry.h

@@ -61,10 +61,10 @@ public:
     Geometry( uint64_t id, const Element& element, const std::string& name, const Document& doc );
     virtual ~Geometry();
 
-    /** Get the Skin attached to this geometry or NULL */
+    /** Get the Skin attached to this geometry or nullptr */
     const Skin* DeformerSkin() const;
 
-    /** Get the BlendShape attached to this geometry or NULL */
+    /** Get the BlendShape attached to this geometry or nullptr */
     const std::vector<const BlendShape*>& GetBlendShapes() const;
 
 private:
@@ -123,7 +123,7 @@ public:
     /** Get per-face-vertex material assignments */
     const MatIndexArray& GetMaterialIndices() const;
 
-    /** Convert from a fbx file vertex index (for example from a #Cluster weight) or NULL
+    /** Convert from a fbx file vertex index (for example from a #Cluster weight) or nullptr
     * if the vertex index is not valid. */
     const unsigned int* ToOutputVertexIndex( unsigned int in_index, unsigned int& count ) const;
 

+ 11 - 11
code/AssetLib/FBX/FBXParser.cpp

@@ -77,7 +77,7 @@ namespace {
     }
 
     // ------------------------------------------------------------------------------------------------
-    AI_WONT_RETURN void ParseError(const std::string& message, const Element* element = NULL) AI_WONT_RETURN_SUFFIX;
+    AI_WONT_RETURN void ParseError(const std::string &message, const Element *element = nullptr) AI_WONT_RETURN_SUFFIX;
     AI_WONT_RETURN void ParseError(const std::string& message, const Element* element)
     {
         if(element) {
@@ -181,7 +181,7 @@ Scope::Scope(Parser& parser,bool topLevel)
     }
 
     TokenPtr n = parser.AdvanceToNextToken();
-    if(n == NULL) {
+    if (n == nullptr) {
         ParseError("unexpected end of file");
     }
 
@@ -196,7 +196,7 @@ Scope::Scope(Parser& parser,bool topLevel)
 
         // Element() should stop at the next Key token (or right after a Close token)
         n = parser.CurrentToken();
-        if(n == NULL) {
+        if (n == nullptr) {
             if (topLevel) {
                 return;
             }
@@ -236,7 +236,7 @@ TokenPtr Parser::AdvanceToNextToken()
 {
     last = current;
     if (cursor == tokens.end()) {
-        current = NULL;
+        current = nullptr;
     } else {
         current = *cursor++;
     }
@@ -258,7 +258,7 @@ TokenPtr Parser::LastToken() const
 // ------------------------------------------------------------------------------------------------
 uint64_t ParseTokenAsID(const Token& t, const char*& err_out)
 {
-    err_out = NULL;
+    err_out = nullptr;
 
     if (t.Type() != TokenType_DATA) {
         err_out = "expected TOK_DATA token";
@@ -296,7 +296,7 @@ uint64_t ParseTokenAsID(const Token& t, const char*& err_out)
 size_t ParseTokenAsDim(const Token& t, const char*& err_out)
 {
     // same as ID parsing, except there is a trailing asterisk
-    err_out = NULL;
+    err_out = nullptr;
 
     if (t.Type() != TokenType_DATA) {
         err_out = "expected TOK_DATA token";
@@ -342,7 +342,7 @@ size_t ParseTokenAsDim(const Token& t, const char*& err_out)
 // ------------------------------------------------------------------------------------------------
 float ParseTokenAsFloat(const Token& t, const char*& err_out)
 {
-    err_out = NULL;
+    err_out = nullptr;
 
     if (t.Type() != TokenType_DATA) {
         err_out = "expected TOK_DATA token";
@@ -385,7 +385,7 @@ float ParseTokenAsFloat(const Token& t, const char*& err_out)
 // ------------------------------------------------------------------------------------------------
 int ParseTokenAsInt(const Token& t, const char*& err_out)
 {
-    err_out = NULL;
+    err_out = nullptr;
 
     if (t.Type() != TokenType_DATA) {
         err_out = "expected TOK_DATA token";
@@ -421,7 +421,7 @@ int ParseTokenAsInt(const Token& t, const char*& err_out)
 // ------------------------------------------------------------------------------------------------
 int64_t ParseTokenAsInt64(const Token& t, const char*& err_out)
 {
-    err_out = NULL;
+    err_out = nullptr;
 
     if (t.Type() != TokenType_DATA) {
         err_out = "expected TOK_DATA token";
@@ -458,7 +458,7 @@ int64_t ParseTokenAsInt64(const Token& t, const char*& err_out)
 // ------------------------------------------------------------------------------------------------
 std::string ParseTokenAsString(const Token& t, const char*& err_out)
 {
-    err_out = NULL;
+    err_out = nullptr;
 
     if (t.Type() != TokenType_DATA) {
         err_out = "expected TOK_DATA token";
@@ -1211,7 +1211,7 @@ bool HasElement( const Scope& sc, const std::string& index ) {
 
 // ------------------------------------------------------------------------------------------------
 // extract a required element from a scope, abort if the element cannot be found
-const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element /*= NULL*/)
+const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element /*= nullptr*/)
 {
     const Element* el = sc[index];
     if(!el) {

+ 2 - 2
code/AssetLib/FBX/FBXParser.h

@@ -137,7 +137,7 @@ public:
 				return element->second;
 			}
 		}
-		return NULL;
+        return nullptr;
 	}
 
     ElementCollection GetCollection(const std::string& index) const {
@@ -219,7 +219,7 @@ void ParseVectorDataArray(std::vector<int64_t>& out, const Element& el);
 bool HasElement( const Scope& sc, const std::string& index );
 
 // extract a required element from a scope, abort if the element cannot be found
-const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element = NULL);
+const Element &GetRequiredElement(const Scope &sc, const std::string &index, const Element *element = nullptr);
 
 // extract required compound scope
 const Scope& GetRequiredScope(const Element& el);

+ 3 - 3
code/AssetLib/FBX/FBXProperties.cpp

@@ -70,7 +70,7 @@ Property::~Property()
 namespace {
 
 // ------------------------------------------------------------------------------------------------
-// read a typed property out of a FBX element. The return value is NULL if the property cannot be read.
+// read a typed property out of a FBX element. The return value is nullptr if the property cannot be read.
 Property* ReadTypedProperty(const Element& element)
 {
     ai_assert(element.KeyToken().StringContents() == "P");
@@ -112,7 +112,7 @@ Property* ReadTypedProperty(const Element& element)
     else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
         return new TypedProperty<float>(ParseTokenAsFloat(*tok[4]));
     }
-    return NULL;
+    return nullptr;
 }
 
 
@@ -197,7 +197,7 @@ const Property* PropertyTable::Get(const std::string& name) const
                 return templateProps->Get(name);
             }
 
-            return NULL;
+            return nullptr;
         }
     }
 

+ 1 - 1
code/AssetLib/FBX/FBXProperties.h

@@ -110,7 +110,7 @@ public:
 
     const Property* Get(const std::string& name) const;
 
-    // PropertyTable's need not be coupled with FBX elements so this can be NULL
+    // PropertyTable's need not be coupled with FBX elements so this can be nullptr
     const Element* GetElement() const {
         return element;
     }

+ 2 - 2
code/AssetLib/FBX/FBXTokenizer.cpp

@@ -127,7 +127,7 @@ void ProcessDataToken( TokenList& output_tokens, const char*& start, const char*
         TokenizeError("unexpected character, expected data token", line, column);
     }
 
-    start = end = NULL;
+    start = end = nullptr;
 }
 
 }
@@ -146,7 +146,7 @@ void Tokenize(TokenList& output_tokens, const char* input)
     bool in_double_quotes = false;
     bool pending_data_token = false;
 
-    const char* token_begin = NULL, *token_end = NULL;
+    const char *token_begin = nullptr, *token_end = nullptr;
     for (const char* cur = input;*cur;column += (*cur == '\t' ? ASSIMP_FBX_TAB_WIDTH : 1), ++cur) {
         const char c = *cur;
 

+ 154 - 180
code/AssetLib/HMP/HMPLoader.cpp

@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
 
 Copyright (c) 2006-2020, assimp team
 
-
-
 All rights reserved.
 
 Redistribution and use of this software in source and binary forms,
@@ -43,17 +41,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 /** @file Implementation of the MDL importer class */
 
-
 #ifndef ASSIMP_BUILD_NO_HMP_IMPORTER
 
 // internal headers
 #include "AssetLib/HMP/HMPLoader.h"
 #include "AssetLib/MD2/MD2FileData.h"
 
-#include <assimp/IOSystem.hpp>
-#include <assimp/DefaultLogger.hpp>
-#include <assimp/scene.h>
 #include <assimp/importerdesc.h>
+#include <assimp/scene.h>
+#include <assimp/DefaultLogger.hpp>
+#include <assimp/IOSystem.hpp>
 
 #include <memory>
 
@@ -74,24 +71,21 @@ static const aiImporterDesc desc = {
 
 // ------------------------------------------------------------------------------------------------
 // Constructor to be privately used by Importer
-HMPImporter::HMPImporter()
-{
+HMPImporter::HMPImporter() {
     // nothing to do here
 }
 
 // ------------------------------------------------------------------------------------------------
 // Destructor, private as well
-HMPImporter::~HMPImporter()
-{
+HMPImporter::~HMPImporter() {
     // nothing to do here
 }
 
 // ------------------------------------------------------------------------------------------------
 // Returns whether the class can handle the format of the given file.
-bool HMPImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool cs) const
-{
+bool HMPImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool cs) const {
     const std::string extension = GetExtension(pFile);
-    if (extension == "hmp" )
+    if (extension == "hmp")
         return true;
 
     // if check for extension is not enough, check for the magic tokens
@@ -100,167 +94,155 @@ bool HMPImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
         tokens[0] = AI_HMP_MAGIC_NUMBER_LE_4;
         tokens[1] = AI_HMP_MAGIC_NUMBER_LE_5;
         tokens[2] = AI_HMP_MAGIC_NUMBER_LE_7;
-        return CheckMagicToken(pIOHandler,pFile,tokens,3,0);
+        return CheckMagicToken(pIOHandler, pFile, tokens, 3, 0);
     }
     return false;
 }
 
 // ------------------------------------------------------------------------------------------------
 // Get list of all file extensions that are handled by this loader
-const aiImporterDesc* HMPImporter::GetInfo () const
-{
+const aiImporterDesc *HMPImporter::GetInfo() const {
     return &desc;
 }
 
 // ------------------------------------------------------------------------------------------------
 // Imports the given file into the given scene structure.
-void HMPImporter::InternReadFile( const std::string& pFile,
-                                 aiScene* _pScene, IOSystem* _pIOHandler)
-{
-    pScene     = _pScene;
+void HMPImporter::InternReadFile(const std::string &pFile,
+        aiScene *_pScene, IOSystem *_pIOHandler) {
+    pScene = _pScene;
     mIOHandler = _pIOHandler;
     std::unique_ptr<IOStream> file(mIOHandler->Open(pFile));
 
     // Check whether we can read from the file
-    if( file.get() == nullptr)
-        throw DeadlyImportError( "Failed to open HMP file " + pFile + ".");
+    if (file.get() == nullptr) {
+        throw DeadlyImportError("Failed to open HMP file " + pFile + ".");
+    }
 
     // Check whether the HMP file is large enough to contain
     // at least the file header
     const size_t fileSize = file->FileSize();
-    if( fileSize < 50)
-        throw DeadlyImportError( "HMP File is too small.");
+    if (fileSize < 50)
+        throw DeadlyImportError("HMP File is too small.");
 
     // Allocate storage and copy the contents of the file to a memory buffer
     mBuffer = new uint8_t[fileSize];
-    file->Read( (void*)mBuffer, 1, fileSize);
+    file->Read((void *)mBuffer, 1, fileSize);
     iFileSize = (unsigned int)fileSize;
 
     // Determine the file subtype and call the appropriate member function
-    const uint32_t iMagic = *((uint32_t*)this->mBuffer);
+    const uint32_t iMagic = *((uint32_t *)this->mBuffer);
 
     // HMP4 format
     if (AI_HMP_MAGIC_NUMBER_LE_4 == iMagic ||
-        AI_HMP_MAGIC_NUMBER_BE_4 == iMagic)
-    {
+            AI_HMP_MAGIC_NUMBER_BE_4 == iMagic) {
         ASSIMP_LOG_DEBUG("HMP subtype: 3D GameStudio A4, magic word is HMP4");
         InternReadFile_HMP4();
     }
     // HMP5 format
     else if (AI_HMP_MAGIC_NUMBER_LE_5 == iMagic ||
-             AI_HMP_MAGIC_NUMBER_BE_5 == iMagic)
-    {
+             AI_HMP_MAGIC_NUMBER_BE_5 == iMagic) {
         ASSIMP_LOG_DEBUG("HMP subtype: 3D GameStudio A5, magic word is HMP5");
         InternReadFile_HMP5();
     }
     // HMP7 format
     else if (AI_HMP_MAGIC_NUMBER_LE_7 == iMagic ||
-             AI_HMP_MAGIC_NUMBER_BE_7 == iMagic)
-    {
+             AI_HMP_MAGIC_NUMBER_BE_7 == iMagic) {
         ASSIMP_LOG_DEBUG("HMP subtype: 3D GameStudio A7, magic word is HMP7");
         InternReadFile_HMP7();
-    }
-    else
-    {
+    } else {
         // Print the magic word to the logger
         char szBuffer[5];
-        szBuffer[0] = ((char*)&iMagic)[0];
-        szBuffer[1] = ((char*)&iMagic)[1];
-        szBuffer[2] = ((char*)&iMagic)[2];
-        szBuffer[3] = ((char*)&iMagic)[3];
+        szBuffer[0] = ((char *)&iMagic)[0];
+        szBuffer[1] = ((char *)&iMagic)[1];
+        szBuffer[2] = ((char *)&iMagic)[2];
+        szBuffer[3] = ((char *)&iMagic)[3];
         szBuffer[4] = '\0';
 
         // We're definitely unable to load this file
-        throw DeadlyImportError( "Unknown HMP subformat " + pFile +
-            ". Magic word (" + szBuffer + ") is not known");
+        throw DeadlyImportError("Unknown HMP subformat " + pFile +
+                                ". Magic word (" + szBuffer + ") is not known");
     }
 
     // Set the AI_SCENE_FLAGS_TERRAIN bit
     pScene->mFlags |= AI_SCENE_FLAGS_TERRAIN;
 
     delete[] mBuffer;
-    mBuffer= nullptr;
-
+    mBuffer = nullptr;
 }
 
 // ------------------------------------------------------------------------------------------------
-void HMPImporter::ValidateHeader_HMP457( )
-{
-    const HMP::Header_HMP5* const pcHeader = (const HMP::Header_HMP5*)mBuffer;
+void HMPImporter::ValidateHeader_HMP457() {
+    const HMP::Header_HMP5 *const pcHeader = (const HMP::Header_HMP5 *)mBuffer;
 
-    if (120 > iFileSize)
-    {
+    if (120 > iFileSize) {
         throw DeadlyImportError("HMP file is too small (header size is "
-            "120 bytes, this file is smaller)");
+                                "120 bytes, this file is smaller)");
     }
 
     if (!pcHeader->ftrisize_x || !pcHeader->ftrisize_y)
         throw DeadlyImportError("Size of triangles in either  x or y direction is zero");
 
-    if(pcHeader->fnumverts_x < 1.0f || (pcHeader->numverts/pcHeader->fnumverts_x) < 1.0f)
+    if (pcHeader->fnumverts_x < 1.0f || (pcHeader->numverts / pcHeader->fnumverts_x) < 1.0f)
         throw DeadlyImportError("Number of triangles in either x or y direction is zero");
 
-    if(!pcHeader->numframes)
+    if (!pcHeader->numframes)
         throw DeadlyImportError("There are no frames. At least one should be there");
-
 }
 
 // ------------------------------------------------------------------------------------------------
-void HMPImporter::InternReadFile_HMP4( )
-{
+void HMPImporter::InternReadFile_HMP4() {
     throw DeadlyImportError("HMP4 is currently not supported");
 }
 
 // ------------------------------------------------------------------------------------------------
-void HMPImporter::InternReadFile_HMP5( )
-{
+void HMPImporter::InternReadFile_HMP5() {
     // read the file header and skip everything to byte 84
-    const HMP::Header_HMP5* pcHeader = (const HMP::Header_HMP5*)mBuffer;
-    const unsigned char* szCurrent = (const unsigned char*)(mBuffer+84);
+    const HMP::Header_HMP5 *pcHeader = (const HMP::Header_HMP5 *)mBuffer;
+    const unsigned char *szCurrent = (const unsigned char *)(mBuffer + 84);
     ValidateHeader_HMP457();
 
     // generate an output mesh
     pScene->mNumMeshes = 1;
-    pScene->mMeshes = new aiMesh*[1];
-    aiMesh* pcMesh = pScene->mMeshes[0] = new aiMesh();
+    pScene->mMeshes = new aiMesh *[1];
+    aiMesh *pcMesh = pScene->mMeshes[0] = new aiMesh();
 
     pcMesh->mMaterialIndex = 0;
     pcMesh->mVertices = new aiVector3D[pcHeader->numverts];
     pcMesh->mNormals = new aiVector3D[pcHeader->numverts];
 
     const unsigned int height = (unsigned int)(pcHeader->numverts / pcHeader->fnumverts_x);
-    const unsigned int width =  (unsigned int)pcHeader->fnumverts_x;
+    const unsigned int width = (unsigned int)pcHeader->fnumverts_x;
 
     // generate/load a material for the terrain
-    CreateMaterial(szCurrent,&szCurrent);
+    CreateMaterial(szCurrent, &szCurrent);
 
     // goto offset 120, I don't know why ...
     // (fixme) is this the frame header? I assume yes since it starts with 2.
     szCurrent += 36;
-    SizeCheck(szCurrent + sizeof(const HMP::Vertex_HMP7)*height*width);
+    SizeCheck(szCurrent + sizeof(const HMP::Vertex_HMP7) * height * width);
 
     // now load all vertices from the file
-    aiVector3D* pcVertOut = pcMesh->mVertices;
-    aiVector3D* pcNorOut = pcMesh->mNormals;
-    const HMP::Vertex_HMP5* src = (const HMP::Vertex_HMP5*) szCurrent;
-    for (unsigned int y = 0; y < height;++y)
-    {
-        for (unsigned int x = 0; x < width;++x)
-        {
+    aiVector3D *pcVertOut = pcMesh->mVertices;
+    aiVector3D *pcNorOut = pcMesh->mNormals;
+    const HMP::Vertex_HMP5 *src = (const HMP::Vertex_HMP5 *)szCurrent;
+    for (unsigned int y = 0; y < height; ++y) {
+        for (unsigned int x = 0; x < width; ++x) {
             pcVertOut->x = x * pcHeader->ftrisize_x;
             pcVertOut->y = y * pcHeader->ftrisize_y;
-            pcVertOut->z = (((float)src->z / 0xffff)-0.5f) * pcHeader->ftrisize_x * 8.0f;
-            MD2::LookupNormalIndex(src->normals162index, *pcNorOut );
-            ++pcVertOut;++pcNorOut;++src;
+            pcVertOut->z = (((float)src->z / 0xffff) - 0.5f) * pcHeader->ftrisize_x * 8.0f;
+            MD2::LookupNormalIndex(src->normals162index, *pcNorOut);
+            ++pcVertOut;
+            ++pcNorOut;
+            ++src;
         }
     }
 
     // generate texture coordinates if necessary
     if (pcHeader->numskins)
-        GenerateTextureCoords(width,height);
+        GenerateTextureCoords(width, height);
 
     // now build a list of faces
-    CreateOutputFaceList(width,height);
+    CreateOutputFaceList(width, height);
 
     // there is no nodegraph in HMP files. Simply assign the one mesh
     // (no, not the one ring) to the root node
@@ -272,17 +254,16 @@ void HMPImporter::InternReadFile_HMP5( )
 }
 
 // ------------------------------------------------------------------------------------------------
-void HMPImporter::InternReadFile_HMP7( )
-{
+void HMPImporter::InternReadFile_HMP7() {
     // read the file header and skip everything to byte 84
-    const HMP::Header_HMP5* const pcHeader = (const HMP::Header_HMP5*)mBuffer;
-    const unsigned char* szCurrent = (const unsigned char*)(mBuffer+84);
+    const HMP::Header_HMP5 *const pcHeader = (const HMP::Header_HMP5 *)mBuffer;
+    const unsigned char *szCurrent = (const unsigned char *)(mBuffer + 84);
     ValidateHeader_HMP457();
 
     // generate an output mesh
     pScene->mNumMeshes = 1;
-    pScene->mMeshes = new aiMesh*[1];
-    aiMesh* pcMesh = pScene->mMeshes[0] = new aiMesh();
+    pScene->mMeshes = new aiMesh *[1];
+    aiMesh *pcMesh = pScene->mMeshes[0] = new aiMesh();
 
     pcMesh->mMaterialIndex = 0;
     pcMesh->mVertices = new aiVector3D[pcHeader->numverts];
@@ -292,44 +273,44 @@ void HMPImporter::InternReadFile_HMP7( )
     const unsigned int width = (unsigned int)pcHeader->fnumverts_x;
 
     // generate/load a material for the terrain
-    CreateMaterial(szCurrent,&szCurrent);
+    CreateMaterial(szCurrent, &szCurrent);
 
     // goto offset 120, I don't know why ...
     // (fixme) is this the frame header? I assume yes since it starts with 2.
     szCurrent += 36;
 
-    SizeCheck(szCurrent + sizeof(const HMP::Vertex_HMP7)*height*width);
+    SizeCheck(szCurrent + sizeof(const HMP::Vertex_HMP7) * height * width);
 
     // now load all vertices from the file
-    aiVector3D* pcVertOut = pcMesh->mVertices;
-    aiVector3D* pcNorOut = pcMesh->mNormals;
-    const HMP::Vertex_HMP7* src = (const HMP::Vertex_HMP7*) szCurrent;
-    for (unsigned int y = 0; y < height;++y)
-    {
-        for (unsigned int x = 0; x < width;++x)
-        {
+    aiVector3D *pcVertOut = pcMesh->mVertices;
+    aiVector3D *pcNorOut = pcMesh->mNormals;
+    const HMP::Vertex_HMP7 *src = (const HMP::Vertex_HMP7 *)szCurrent;
+    for (unsigned int y = 0; y < height; ++y) {
+        for (unsigned int x = 0; x < width; ++x) {
             pcVertOut->x = x * pcHeader->ftrisize_x;
             pcVertOut->y = y * pcHeader->ftrisize_y;
 
             // FIXME: What exctly is the correct scaling factor to use?
             // possibly pcHeader->scale_origin[2] in combination with a
             // signed interpretation of src->z?
-            pcVertOut->z = (((float)src->z / 0xffff)-0.5f) * pcHeader->ftrisize_x * 8.0f;
+            pcVertOut->z = (((float)src->z / 0xffff) - 0.5f) * pcHeader->ftrisize_x * 8.0f;
 
-            pcNorOut->x = ((float)src->normal_x / 0x80 ); // * pcHeader->scale_origin[0];
-            pcNorOut->y = ((float)src->normal_y / 0x80 ); // * pcHeader->scale_origin[1];
+            pcNorOut->x = ((float)src->normal_x / 0x80); // * pcHeader->scale_origin[0];
+            pcNorOut->y = ((float)src->normal_y / 0x80); // * pcHeader->scale_origin[1];
             pcNorOut->z = 1.0f;
             pcNorOut->Normalize();
 
-            ++pcVertOut;++pcNorOut;++src;
+            ++pcVertOut;
+            ++pcNorOut;
+            ++src;
         }
     }
 
     // generate texture coordinates if necessary
-    if (pcHeader->numskins)GenerateTextureCoords(width,height);
+    if (pcHeader->numskins) GenerateTextureCoords(width, height);
 
     // now build a list of faces
-    CreateOutputFaceList(width,height);
+    CreateOutputFaceList(width, height);
 
     // there is no nodegraph in HMP files. Simply assign the one mesh
     // (no, not the One Ring) to the root node
@@ -341,96 +322,89 @@ void HMPImporter::InternReadFile_HMP7( )
 }
 
 // ------------------------------------------------------------------------------------------------
-void HMPImporter::CreateMaterial(const unsigned char* szCurrent,
-    const unsigned char** szCurrentOut)
-{
-    aiMesh* const pcMesh = pScene->mMeshes[0];
-    const HMP::Header_HMP5* const pcHeader = (const HMP::Header_HMP5*)mBuffer;
+void HMPImporter::CreateMaterial(const unsigned char *szCurrent,
+        const unsigned char **szCurrentOut) {
+    aiMesh *const pcMesh = pScene->mMeshes[0];
+    const HMP::Header_HMP5 *const pcHeader = (const HMP::Header_HMP5 *)mBuffer;
 
     // we don't need to generate texture coordinates if
     // we have no textures in the file ...
-    if (pcHeader->numskins)
-    {
+    if (pcHeader->numskins) {
         pcMesh->mTextureCoords[0] = new aiVector3D[pcHeader->numverts];
         pcMesh->mNumUVComponents[0] = 2;
 
         // now read the first skin and skip all others
-        ReadFirstSkin(pcHeader->numskins,szCurrent,&szCurrent);
-    }
-    else
-    {
+        ReadFirstSkin(pcHeader->numskins, szCurrent, &szCurrent);
+    } else {
         // generate a default material
         const int iMode = (int)aiShadingMode_Gouraud;
-        aiMaterial* pcHelper = new aiMaterial();
+        aiMaterial *pcHelper = new aiMaterial();
         pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
 
         aiColor3D clr;
         clr.b = clr.g = clr.r = 0.6f;
-        pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_DIFFUSE);
-        pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_SPECULAR);
+        pcHelper->AddProperty<aiColor3D>(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
+        pcHelper->AddProperty<aiColor3D>(&clr, 1, AI_MATKEY_COLOR_SPECULAR);
 
         clr.b = clr.g = clr.r = 0.05f;
-        pcHelper->AddProperty<aiColor3D>(&clr, 1,AI_MATKEY_COLOR_AMBIENT);
+        pcHelper->AddProperty<aiColor3D>(&clr, 1, AI_MATKEY_COLOR_AMBIENT);
 
         aiString szName;
         szName.Set(AI_DEFAULT_MATERIAL_NAME);
-        pcHelper->AddProperty(&szName,AI_MATKEY_NAME);
+        pcHelper->AddProperty(&szName, AI_MATKEY_NAME);
 
         // add the material to the scene
         pScene->mNumMaterials = 1;
-        pScene->mMaterials = new aiMaterial*[1];
+        pScene->mMaterials = new aiMaterial *[1];
         pScene->mMaterials[0] = pcHelper;
     }
     *szCurrentOut = szCurrent;
 }
 
 // ------------------------------------------------------------------------------------------------
-void HMPImporter::CreateOutputFaceList(unsigned int width,unsigned int height)
-{
-    aiMesh* const pcMesh = this->pScene->mMeshes[0];
+void HMPImporter::CreateOutputFaceList(unsigned int width, unsigned int height) {
+    aiMesh *const pcMesh = this->pScene->mMeshes[0];
 
     // Allocate enough storage
-    pcMesh->mNumFaces = (width-1) * (height-1);
+    pcMesh->mNumFaces = (width - 1) * (height - 1);
     pcMesh->mFaces = new aiFace[pcMesh->mNumFaces];
 
-    pcMesh->mNumVertices   = pcMesh->mNumFaces*4;
-    aiVector3D* pcVertices = new aiVector3D[pcMesh->mNumVertices];
-    aiVector3D* pcNormals  = new aiVector3D[pcMesh->mNumVertices];
+    pcMesh->mNumVertices = pcMesh->mNumFaces * 4;
+    aiVector3D *pcVertices = new aiVector3D[pcMesh->mNumVertices];
+    aiVector3D *pcNormals = new aiVector3D[pcMesh->mNumVertices];
 
-    aiFace* pcFaceOut(pcMesh->mFaces);
-    aiVector3D* pcVertOut = pcVertices;
-    aiVector3D* pcNorOut = pcNormals;
+    aiFace *pcFaceOut(pcMesh->mFaces);
+    aiVector3D *pcVertOut = pcVertices;
+    aiVector3D *pcNorOut = pcNormals;
 
-    aiVector3D* pcUVs = pcMesh->mTextureCoords[0] ? new aiVector3D[pcMesh->mNumVertices] : NULL;
-    aiVector3D* pcUVOut(pcUVs);
+    aiVector3D *pcUVs = pcMesh->mTextureCoords[0] ? new aiVector3D[pcMesh->mNumVertices] : nullptr;
+    aiVector3D *pcUVOut(pcUVs);
 
     // Build the terrain square
     unsigned int iCurrent = 0;
-    for (unsigned int y = 0; y < height-1;++y)  {
-        for (unsigned int x = 0; x < width-1;++x,++pcFaceOut)   {
+    for (unsigned int y = 0; y < height - 1; ++y) {
+        for (unsigned int x = 0; x < width - 1; ++x, ++pcFaceOut) {
             pcFaceOut->mNumIndices = 4;
             pcFaceOut->mIndices = new unsigned int[4];
 
-            *pcVertOut++ = pcMesh->mVertices[y*width+x];
-            *pcVertOut++ = pcMesh->mVertices[(y+1)*width+x];
-            *pcVertOut++ = pcMesh->mVertices[(y+1)*width+x+1];
-            *pcVertOut++ = pcMesh->mVertices[y*width+x+1];
-
-
-            *pcNorOut++ = pcMesh->mNormals[y*width+x];
-            *pcNorOut++ = pcMesh->mNormals[(y+1)*width+x];
-            *pcNorOut++ = pcMesh->mNormals[(y+1)*width+x+1];
-            *pcNorOut++ = pcMesh->mNormals[y*width+x+1];
-
-            if (pcMesh->mTextureCoords[0])
-            {
-                *pcUVOut++ = pcMesh->mTextureCoords[0][y*width+x];
-                *pcUVOut++ = pcMesh->mTextureCoords[0][(y+1)*width+x];
-                *pcUVOut++ = pcMesh->mTextureCoords[0][(y+1)*width+x+1];
-                *pcUVOut++ = pcMesh->mTextureCoords[0][y*width+x+1];
+            *pcVertOut++ = pcMesh->mVertices[y * width + x];
+            *pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x];
+            *pcVertOut++ = pcMesh->mVertices[(y + 1) * width + x + 1];
+            *pcVertOut++ = pcMesh->mVertices[y * width + x + 1];
+
+            *pcNorOut++ = pcMesh->mNormals[y * width + x];
+            *pcNorOut++ = pcMesh->mNormals[(y + 1) * width + x];
+            *pcNorOut++ = pcMesh->mNormals[(y + 1) * width + x + 1];
+            *pcNorOut++ = pcMesh->mNormals[y * width + x + 1];
+
+            if (pcMesh->mTextureCoords[0]) {
+                *pcUVOut++ = pcMesh->mTextureCoords[0][y * width + x];
+                *pcUVOut++ = pcMesh->mTextureCoords[0][(y + 1) * width + x];
+                *pcUVOut++ = pcMesh->mTextureCoords[0][(y + 1) * width + x + 1];
+                *pcUVOut++ = pcMesh->mTextureCoords[0][y * width + x + 1];
             }
 
-            for (unsigned int i = 0; i < 4;++i)
+            for (unsigned int i = 0; i < 4; ++i)
                 pcFaceOut->mIndices[i] = iCurrent++;
         }
     }
@@ -440,58 +414,58 @@ void HMPImporter::CreateOutputFaceList(unsigned int width,unsigned int height)
     delete[] pcMesh->mNormals;
     pcMesh->mNormals = pcNormals;
 
-    if (pcMesh->mTextureCoords[0])
-    {
+    if (pcMesh->mTextureCoords[0]) {
         delete[] pcMesh->mTextureCoords[0];
         pcMesh->mTextureCoords[0] = pcUVs;
     }
 }
 
 // ------------------------------------------------------------------------------------------------
-void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char* szCursor,
-    const unsigned char** szCursorOut)
-{
-    ai_assert( 0 != iNumSkins );
-    ai_assert( nullptr != szCursor);
+void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char *szCursor,
+        const unsigned char **szCursorOut) {
+    ai_assert(0 != iNumSkins);
+    ai_assert(nullptr != szCursor);
 
     // read the type of the skin ...
     // sometimes we need to skip 12 bytes here, I don't know why ...
-    uint32_t iType = *((uint32_t*)szCursor);
+    uint32_t iType = *((uint32_t *)szCursor);
     szCursor += sizeof(uint32_t);
-    if (0 == iType)
-    {
+    if (0 == iType) {
         szCursor += sizeof(uint32_t) * 2;
-        iType = *((uint32_t*)szCursor);
+        iType = *((uint32_t *)szCursor);
         szCursor += sizeof(uint32_t);
         if (!iType)
             throw DeadlyImportError("Unable to read HMP7 skin chunk");
-
     }
     // read width and height
-    uint32_t iWidth  = *((uint32_t*)szCursor); szCursor += sizeof(uint32_t);
-    uint32_t iHeight = *((uint32_t*)szCursor); szCursor += sizeof(uint32_t);
+    uint32_t iWidth = *((uint32_t *)szCursor);
+    szCursor += sizeof(uint32_t);
+    uint32_t iHeight = *((uint32_t *)szCursor);
+    szCursor += sizeof(uint32_t);
 
     // allocate an output material
-    aiMaterial* pcMat = new aiMaterial();
+    aiMaterial *pcMat = new aiMaterial();
 
     // read the skin, this works exactly as for MDL7
-    ParseSkinLump_3DGS_MDL7(szCursor,&szCursor,
-        pcMat,iType,iWidth,iHeight);
+    ParseSkinLump_3DGS_MDL7(szCursor, &szCursor,
+            pcMat, iType, iWidth, iHeight);
 
     // now we need to skip any other skins ...
-    for (unsigned int i = 1; i< iNumSkins;++i)
-    {
-        iType   = *((uint32_t*)szCursor);   szCursor += sizeof(uint32_t);
-        iWidth  = *((uint32_t*)szCursor);   szCursor += sizeof(uint32_t);
-        iHeight = *((uint32_t*)szCursor);   szCursor += sizeof(uint32_t);
+    for (unsigned int i = 1; i < iNumSkins; ++i) {
+        iType = *((uint32_t *)szCursor);
+        szCursor += sizeof(uint32_t);
+        iWidth = *((uint32_t *)szCursor);
+        szCursor += sizeof(uint32_t);
+        iHeight = *((uint32_t *)szCursor);
+        szCursor += sizeof(uint32_t);
 
-        SkipSkinLump_3DGS_MDL7(szCursor,&szCursor,iType,iWidth,iHeight);
+        SkipSkinLump_3DGS_MDL7(szCursor, &szCursor, iType, iWidth, iHeight);
         SizeCheck(szCursor);
     }
 
     // setup the material ...
     pScene->mNumMaterials = 1;
-    pScene->mMaterials = new aiMaterial*[1];
+    pScene->mMaterials = new aiMaterial *[1];
     pScene->mMaterials[0] = pcMat;
 
     *szCursorOut = szCursor;
@@ -500,20 +474,20 @@ void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char* szC
 // ------------------------------------------------------------------------------------------------
 // Generate proepr texture coords
 void HMPImporter::GenerateTextureCoords(
-    const unsigned int width, const unsigned int height)
-{
-    ai_assert(NULL != pScene->mMeshes && NULL != pScene->mMeshes[0] &&
-              NULL != pScene->mMeshes[0]->mTextureCoords[0]);
+        const unsigned int width, const unsigned int height) {
+    ai_assert(nullptr != pScene->mMeshes);
+    ai_assert(nullptr != pScene->mMeshes[0]);
+    ai_assert(nullptr != pScene->mMeshes[0]->mTextureCoords[0]);
 
-    aiVector3D* uv = pScene->mMeshes[0]->mTextureCoords[0];
+    aiVector3D *uv = pScene->mMeshes[0]->mTextureCoords[0];
 
-    const float fY = (1.0f / height) + (1.0f / height) / (height-1);
-    const float fX = (1.0f / width) + (1.0f / width) / (width-1);
+    const float fY = (1.0f / height) + (1.0f / height) / (height - 1);
+    const float fX = (1.0f / width) + (1.0f / width) / (width - 1);
 
-    for (unsigned int y = 0; y < height;++y)    {
-        for (unsigned int x = 0; x < width;++x,++uv)    {
-            uv->y = fY*y;
-            uv->x = fX*x;
+    for (unsigned int y = 0; y < height; ++y) {
+        for (unsigned int x = 0; x < width; ++x, ++uv) {
+            uv->y = fY * y;
+            uv->x = fX * x;
             uv->z = 0.0f;
         }
     }

+ 3 - 3
code/AssetLib/IFC/IFCBoolean.cpp

@@ -131,7 +131,7 @@ void WritePolygon(std::vector<IfcVector3> &resultpoly, TempMesh &result) {
 void ProcessBooleanHalfSpaceDifference(const Schema_2x3::IfcHalfSpaceSolid *hs, TempMesh &result,
         const TempMesh &first_operand,
         ConversionData & /*conv*/) {
-    ai_assert(hs != NULL);
+    ai_assert(hs != nullptr);
 
     const Schema_2x3::IfcPlane *const plane = hs->BaseSurface->ToPtr<Schema_2x3::IfcPlane>();
     if (!plane) {
@@ -366,7 +366,7 @@ bool PointInPoly(const IfcVector3 &p, const std::vector<IfcVector3> &boundary) {
 void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const Schema_2x3::IfcPolygonalBoundedHalfSpace *hs, TempMesh &result,
         const TempMesh &first_operand,
         ConversionData &conv) {
-    ai_assert(hs != NULL);
+    ai_assert(hs != nullptr);
 
     const Schema_2x3::IfcPlane *const plane = hs->BaseSurface->ToPtr<Schema_2x3::IfcPlane>();
     if (!plane) {
@@ -665,7 +665,7 @@ void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const Schema_2x3::IfcPoly
 void ProcessBooleanExtrudedAreaSolidDifference(const Schema_2x3::IfcExtrudedAreaSolid *as, TempMesh &result,
         const TempMesh &first_operand,
         ConversionData &conv) {
-    ai_assert(as != NULL);
+    ai_assert(as != nullptr);
 
     // This case is handled by reduction to an instance of the quadrify() algorithm.
     // Obviously, this won't work for arbitrarily complex cases. In fact, the first

+ 5 - 3
code/AssetLib/IFC/IFCCurve.cpp

@@ -389,7 +389,8 @@ public:
 
     // --------------------------------------------------
     void SampleDiscrete(TempMesh& out,IfcFloat a,IfcFloat b) const {
-        ai_assert(InRange(a) && InRange(b));
+        ai_assert(InRange(a));
+        ai_assert(InRange(b));
         return base->SampleDiscrete(out,TrimParam(a),TrimParam(b));
     }
 
@@ -446,7 +447,8 @@ public:
 
     // --------------------------------------------------
     size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
-        ai_assert(InRange(a) && InRange(b));
+        ai_assert(InRange(a));
+        ai_assert(InRange(b));
         return static_cast<size_t>( std::ceil(b) - std::floor(a) );
     }
 
@@ -489,7 +491,7 @@ Curve* Curve::Convert(const IFC::Schema_2x3::IfcCurve& curve,ConversionData& con
     }
 
     // XXX OffsetCurve2D, OffsetCurve3D not currently supported
-    return NULL;
+    return nullptr;
 }
 
 #ifdef ASSIMP_BUILD_DEBUG

+ 1 - 1
code/AssetLib/IFC/IFCGeometry.cpp

@@ -174,7 +174,7 @@ void ProcessPolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t m
         TempOpening& opening = fake_openings.back();
 
         opening.extrusionDir = master_normal;
-        opening.solid = NULL;
+        opening.solid = nullptr;
 
         opening.profileMesh = std::make_shared<TempMesh>();
         opening.profileMesh->mVerts.reserve(*iit);

+ 6 - 6
code/AssetLib/IFC/IFCLoader.cpp

@@ -172,7 +172,7 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
     if (GetExtension(pFile) == "ifczip") {
 #ifndef ASSIMP_BUILD_NO_COMPRESSED_IFC
         unzFile zip = unzOpen(pFile.c_str());
-        if (zip == NULL) {
+        if (zip == nullptr) {
             ThrowException("Could not open ifczip file for reading, unzip failed");
         }
 
@@ -373,7 +373,7 @@ void SetUnits(ConversionData &conv) {
 
 // ------------------------------------------------------------------------------------------------
 void SetCoordinateSpace(ConversionData &conv) {
-    const Schema_2x3::IfcRepresentationContext *fav = NULL;
+    const Schema_2x3::IfcRepresentationContext *fav = nullptr;
     for (const Schema_2x3::IfcRepresentationContext &v : conv.proj.RepresentationContexts) {
         fav = &v;
         // Model should be the most suitable type of context, hence ignore the others
@@ -790,7 +790,7 @@ aiNode *ProcessSpatialStructure(aiNode *parent, const Schema_2x3::IfcProduct &el
                 for (const Schema_2x3::IfcObjectDefinition &def : aggr->RelatedObjects) {
                     if (const Schema_2x3::IfcProduct *const prod = def.ToPtr<Schema_2x3::IfcProduct>()) {
 
-                        aiNode *const ndnew = ProcessSpatialStructure(nd_aggr.get(), *prod, conv, NULL);
+                        aiNode *const ndnew = ProcessSpatialStructure(nd_aggr.get(), *prod, conv, nullptr);
                         if (ndnew) {
                             nd_aggr->mChildren[nd_aggr->mNumChildren++] = ndnew;
                         }
@@ -870,7 +870,7 @@ void ProcessSpatialStructures(ConversionData &conv) {
                     if (def.GetID() == prod->GetID()) {
                         IFCImporter::LogVerboseDebug("selecting this spatial structure as root structure");
                         // got it, this is one primary site.
-                        nodes.push_back(ProcessSpatialStructure(NULL, *prod, conv, NULL));
+                        nodes.push_back(ProcessSpatialStructure(nullptr, *prod, conv, nullptr));
                     }
                 }
             }
@@ -887,7 +887,7 @@ void ProcessSpatialStructures(ConversionData &conv) {
                 continue;
             }
 
-            nodes.push_back(ProcessSpatialStructure(NULL, *prod, conv, NULL));
+            nodes.push_back(ProcessSpatialStructure(nullptr, *prod, conv, nullptr));
         }
 
         nb_nodes = nodes.size();
@@ -897,7 +897,7 @@ void ProcessSpatialStructures(ConversionData &conv) {
         conv.out->mRootNode = nodes[0];
     } else if (nb_nodes > 1) {
         conv.out->mRootNode = new aiNode("Root");
-        conv.out->mRootNode->mParent = NULL;
+        conv.out->mRootNode->mParent = nullptr;
         conv.out->mRootNode->mNumChildren = static_cast<unsigned int>(nb_nodes);
         conv.out->mRootNode->mChildren = new aiNode *[conv.out->mRootNode->mNumChildren];
 

+ 327 - 327
code/AssetLib/IFC/IFCReaderGen1_2x3.cpp

@@ -54,333 +54,333 @@ namespace {
 	typedef EXPRESS::ConversionSchema::SchemaEntry SchemaEntry;
 
     static const SchemaEntry schema_raw_2x3[] =  {
-		SchemaEntry("ifcstairtypeenum",NULL )
-,		SchemaEntry("ifcspacetypeenum",NULL )
-,		SchemaEntry("ifcwalltypeenum",NULL )
-,		SchemaEntry("ifcmonthinyearnumber",NULL )
-,		SchemaEntry("ifcheatfluxdensitymeasure",NULL )
-,		SchemaEntry("ifckinematicviscositymeasure",NULL )
-,		SchemaEntry("ifcsequenceenum",NULL )
-,		SchemaEntry("ifcairtoairheatrecoverytypeenum",NULL )
-,		SchemaEntry("ifcactorselect",NULL )
-,		SchemaEntry("ifctransformertypeenum",NULL )
-,		SchemaEntry("ifcunitaryequipmenttypeenum",NULL )
-,		SchemaEntry("ifcelectricflowstoragedevicetypeenum",NULL )
-,		SchemaEntry("ifcenergysequenceenum",NULL )
-,		SchemaEntry("ifcworkcontroltypeenum",NULL )
-,		SchemaEntry("ifccurvaturemeasure",NULL )
-,		SchemaEntry("ifcparametervalue",NULL )
-,		SchemaEntry("ifcappliedvalueselect",NULL )
-,		SchemaEntry("ifcwarpingconstantmeasure",NULL )
-,		SchemaEntry("ifcarithmeticoperatorenum",NULL )
-,		SchemaEntry("ifclinearforcemeasure",NULL )
-,		SchemaEntry("ifcwindowpanelpositionenum",NULL )
-,		SchemaEntry("ifcflowmetertypeenum",NULL )
-,		SchemaEntry("ifcrampflighttypeenum",NULL )
-,		SchemaEntry("ifcspecularhighlightselect",NULL )
-,		SchemaEntry("ifcactiontypeenum",NULL )
-,		SchemaEntry("ifcgeometricprojectionenum",NULL )
-,		SchemaEntry("ifctimeseriesdatatypeenum",NULL )
-,		SchemaEntry("ifcmagneticfluxmeasure",NULL )
-,		SchemaEntry("ifcobjecttypeenum",NULL )
-,		SchemaEntry("ifcdataoriginenum",NULL )
-,		SchemaEntry("ifcmassdensitymeasure",NULL )
-,		SchemaEntry("ifclightfixturetypeenum",NULL )
-,		SchemaEntry("ifcservicelifetypeenum",NULL )
-,		SchemaEntry("ifcelectricvoltagemeasure",NULL )
-,		SchemaEntry("ifcheatingvaluemeasure",NULL )
-,		SchemaEntry("ifcpresentabletext",NULL )
-,		SchemaEntry("ifcaheadorbehind",NULL )
-,		SchemaEntry("ifcsimplevalue",NULL )
-,		SchemaEntry("ifcsensortypeenum",NULL )
-,		SchemaEntry("ifcderivedunitenum",NULL )
-,		SchemaEntry("ifcsizeselect",NULL )
-,		SchemaEntry("ifctransportelementtypeenum",NULL )
-,		SchemaEntry("ifcinventorytypeenum",NULL )
-,		SchemaEntry("ifctextdecoration",NULL )
-,		SchemaEntry("ifcdirectionsenseenum",NULL )
-,		SchemaEntry("ifcductfittingtypeenum",NULL )
-,		SchemaEntry("ifcdocumentstatusenum",NULL )
-,		SchemaEntry("ifcslabtypeenum",NULL )
-,		SchemaEntry("ifcdoorstyleconstructionenum",NULL )
-,		SchemaEntry("ifcvolumemeasure",NULL )
-,		SchemaEntry("ifcinductancemeasure",NULL )
-,		SchemaEntry("ifccurtainwalltypeenum",NULL )
-,		SchemaEntry("ifcsiunitname",NULL )
-,		SchemaEntry("ifcspecularexponent",NULL )
-,		SchemaEntry("ifcsoundpressuremeasure",NULL )
-,		SchemaEntry("ifcanalysistheorytypeenum",NULL )
-,		SchemaEntry("ifcgasterminaltypeenum",NULL )
-,		SchemaEntry("ifcyearnumber",NULL )
-,		SchemaEntry("ifcmodulusofelasticitymeasure",NULL )
-,		SchemaEntry("ifcchangeactionenum",NULL )
-,		SchemaEntry("ifcdampertypeenum",NULL )
-,		SchemaEntry("ifcevaporatortypeenum",NULL )
-,		SchemaEntry("ifcionconcentrationmeasure",NULL )
-,		SchemaEntry("ifcductsegmenttypeenum",NULL )
-,		SchemaEntry("ifcprotectivedevicetypeenum",NULL )
-,		SchemaEntry("ifcabsorbeddosemeasure",NULL )
-,		SchemaEntry("ifcmassperlengthmeasure",NULL )
-,		SchemaEntry("ifctextfontname",NULL )
-,		SchemaEntry("ifcorientationselect",NULL )
-,		SchemaEntry("ifcilluminancemeasure",NULL )
-,		SchemaEntry("ifcfiresuppressionterminaltypeenum",NULL )
-,		SchemaEntry("ifcfontstyle",NULL )
-,		SchemaEntry("ifcmomentofinertiameasure",NULL )
-,		SchemaEntry("ifcmodulusofsubgradereactionmeasure",NULL )
-,		SchemaEntry("ifccomplexnumber",NULL )
-,		SchemaEntry("ifchumidifiertypeenum",NULL )
-,		SchemaEntry("ifcpresentationstyleselect",NULL )
-,		SchemaEntry("ifcthermaltransmittancemeasure",NULL )
-,		SchemaEntry("ifcribplatedirectionenum",NULL )
-,		SchemaEntry("ifcclassificationnotationselect",NULL )
-,		SchemaEntry("ifcminuteinhour",NULL )
-,		SchemaEntry("ifcinternalorexternalenum",NULL )
-,		SchemaEntry("ifcrotationalfrequencymeasure",NULL )
-,		SchemaEntry("ifcsanitaryterminaltypeenum",NULL )
-,		SchemaEntry("ifcsymbolstyleselect",NULL )
-,		SchemaEntry("ifcelementcompositionenum",NULL )
-,		SchemaEntry("ifctextpath",NULL )
-,		SchemaEntry("ifcpowermeasure",NULL )
-,		SchemaEntry("ifcsurfacestyleelementselect",NULL )
-,		SchemaEntry("ifcresourceconsumptionenum",NULL )
-,		SchemaEntry("ifcelectriccapacitancemeasure",NULL )
-,		SchemaEntry("ifclayersetdirectionenum",NULL )
-,		SchemaEntry("ifcrailingtypeenum",NULL )
-,		SchemaEntry("ifcobjectiveenum",NULL )
-,		SchemaEntry("ifcdocumentselect",NULL )
-,		SchemaEntry("ifcmodulusoflinearsubgradereactionmeasure",NULL )
-,		SchemaEntry("ifcthermaladmittancemeasure",NULL )
-,		SchemaEntry("ifctransitioncode",NULL )
-,		SchemaEntry("ifcconnectiontypeenum",NULL )
-,		SchemaEntry("ifcmonetarymeasure",NULL )
-,		SchemaEntry("ifcstackterminaltypeenum",NULL )
-,		SchemaEntry("ifccolour",NULL )
-,		SchemaEntry("ifctext",NULL )
-,		SchemaEntry("ifccontextdependentmeasure",NULL )
-,		SchemaEntry("ifcthermalconductivitymeasure",NULL )
-,		SchemaEntry("ifcprojectedortruelengthenum",NULL )
-,		SchemaEntry("ifcpressuremeasure",NULL )
-,		SchemaEntry("ifcmoisturediffusivitymeasure",NULL )
-,		SchemaEntry("ifcbooleanoperator",NULL )
-,		SchemaEntry("ifcpropertysourceenum",NULL )
-,		SchemaEntry("ifctimestamp",NULL )
-,		SchemaEntry("ifcmaterialselect",NULL )
-,		SchemaEntry("ifcgloballyuniqueid",NULL )
-,		SchemaEntry("ifcreflectancemethodenum",NULL )
-,		SchemaEntry("ifcvaporpermeabilitymeasure",NULL )
-,		SchemaEntry("ifctimeseriesscheduletypeenum",NULL )
-,		SchemaEntry("ifclinearmomentmeasure",NULL )
-,		SchemaEntry("ifcgeometricsetselect",NULL )
-,		SchemaEntry("ifcsectionmodulusmeasure",NULL )
-,		SchemaEntry("ifcbsplinecurveform",NULL )
-,		SchemaEntry("ifcdimensionextentusage",NULL )
-,		SchemaEntry("ifcthermalexpansioncoefficientmeasure",NULL )
-,		SchemaEntry("ifchourinday",NULL )
-,		SchemaEntry("ifclinearvelocitymeasure",NULL )
-,		SchemaEntry("ifctorquemeasure",NULL )
-,		SchemaEntry("ifctemperaturegradientmeasure",NULL )
-,		SchemaEntry("ifcfillstyleselect",NULL )
-,		SchemaEntry("ifcelectricchargemeasure",NULL )
-,		SchemaEntry("ifcheatexchangertypeenum",NULL )
-,		SchemaEntry("ifcelectriccurrentenum",NULL )
-,		SchemaEntry("ifcdaylightsavinghour",NULL )
-,		SchemaEntry("ifcshell",NULL )
-,		SchemaEntry("ifcdoseequivalentmeasure",NULL )
-,		SchemaEntry("ifcprojectordertypeenum",NULL )
-,		SchemaEntry("ifcderivedmeasurevalue",NULL )
-,		SchemaEntry("ifclightdistributioncurveenum",NULL )
-,		SchemaEntry("ifcwarpingmomentmeasure",NULL )
-,		SchemaEntry("ifcmembertypeenum",NULL )
-,		SchemaEntry("ifcsoundpowermeasure",NULL )
-,		SchemaEntry("ifctextalignment",NULL )
-,		SchemaEntry("ifccurveoredgecurve",NULL )
-,		SchemaEntry("ifcmassflowratemeasure",NULL )
-,		SchemaEntry("ifcisothermalmoisturecapacitymeasure",NULL )
-,		SchemaEntry("ifccsgselect",NULL )
-,		SchemaEntry("ifccoolingtowertypeenum",NULL )
-,		SchemaEntry("ifcmassmeasure",NULL )
-,		SchemaEntry("ifcpileconstructionenum",NULL )
-,		SchemaEntry("ifcdoorstyleoperationenum",NULL )
-,		SchemaEntry("ifcflowdirectionenum",NULL )
-,		SchemaEntry("ifcthermalloadsourceenum",NULL )
-,		SchemaEntry("ifclengthmeasure",NULL )
-,		SchemaEntry("ifcconstraintenum",NULL )
-,		SchemaEntry("ifcaxis2placement",NULL )
-,		SchemaEntry("ifcloadgrouptypeenum",NULL )
-,		SchemaEntry("ifcvalue",NULL )
-,		SchemaEntry("ifcreinforcingbarsurfaceenum",NULL )
-,		SchemaEntry("ifcprojectorderrecordtypeenum",NULL )
-,		SchemaEntry("ifcdatetimeselect",NULL )
-,		SchemaEntry("ifcstructuralsurfacetypeenum",NULL )
-,		SchemaEntry("ifcpermeablecoveringoperationenum",NULL )
-,		SchemaEntry("ifcfontweight",NULL )
-,		SchemaEntry("ifcphmeasure",NULL )
-,		SchemaEntry("ifcdescriptivemeasure",NULL )
-,		SchemaEntry("ifccurvestylefontselect",NULL )
-,		SchemaEntry("ifcunit",NULL )
-,		SchemaEntry("ifchatchlinedistanceselect",NULL )
-,		SchemaEntry("ifctextstyleselect",NULL )
-,		SchemaEntry("ifcmetricvalueselect",NULL )
-,		SchemaEntry("ifcvectorordirection",NULL )
-,		SchemaEntry("ifcassemblyplaceenum",NULL )
-,		SchemaEntry("ifcairterminaltypeenum",NULL )
-,		SchemaEntry("ifccoveringtypeenum",NULL )
-,		SchemaEntry("ifcplanarforcemeasure",NULL )
-,		SchemaEntry("ifcvalvetypeenum",NULL )
-,		SchemaEntry("ifcalarmtypeenum",NULL )
-,		SchemaEntry("ifcdynamicviscositymeasure",NULL )
-,		SchemaEntry("ifccurrencyenum",NULL )
-,		SchemaEntry("ifcmodulusofrotationalsubgradereactionmeasure",NULL )
-,		SchemaEntry("ifccablecarrierfittingtypeenum",NULL )
-,		SchemaEntry("ifcboolean",NULL )
-,		SchemaEntry("ifcactionsourcetypeenum",NULL )
-,		SchemaEntry("ifcstructuralactivityassignmentselect",NULL )
-,		SchemaEntry("ifcdistributionchamberelementtypeenum",NULL )
-,		SchemaEntry("ifcevaporativecoolertypeenum",NULL )
-,		SchemaEntry("ifcmagneticfluxdensitymeasure",NULL )
-,		SchemaEntry("ifclightdistributiondatasourceselect",NULL )
-,		SchemaEntry("ifctubebundletypeenum",NULL )
-,		SchemaEntry("ifcaccelerationmeasure",NULL )
-,		SchemaEntry("ifcboilertypeenum",NULL )
-,		SchemaEntry("ifcramptypeenum",NULL )
-,		SchemaEntry("ifcluminousintensitydistributionmeasure",NULL )
-,		SchemaEntry("ifctrimmingpreference",NULL )
-,		SchemaEntry("ifcspecificheatcapacitymeasure",NULL )
-,		SchemaEntry("ifcamountofsubstancemeasure",NULL )
-,		SchemaEntry("ifcroleenum",NULL )
-,		SchemaEntry("ifcdocumentconfidentialityenum",NULL )
-,		SchemaEntry("ifcfrequencymeasure",NULL )
-,		SchemaEntry("ifcsectiontypeenum",NULL )
-,		SchemaEntry("ifcelementassemblytypeenum",NULL )
-,		SchemaEntry("ifcfootingtypeenum",NULL )
-,		SchemaEntry("ifclayereditem",NULL )
-,		SchemaEntry("ifccablesegmenttypeenum",NULL )
-,		SchemaEntry("ifcdefinedsymbolselect",NULL )
-,		SchemaEntry("ifcbuildingelementproxytypeenum",NULL )
-,		SchemaEntry("ifcelectricgeneratortypeenum",NULL )
-,		SchemaEntry("ifcrotationalstiffnessmeasure",NULL )
-,		SchemaEntry("ifcspaceheatertypeenum",NULL )
-,		SchemaEntry("ifcareameasure",NULL )
-,		SchemaEntry("ifclabel",NULL )
-,		SchemaEntry("ifccostscheduletypeenum",NULL )
-,		SchemaEntry("ifcswitchingdevicetypeenum",NULL )
-,		SchemaEntry("ifcelectrictimecontroltypeenum",NULL )
-,		SchemaEntry("ifcfiltertypeenum",NULL )
-,		SchemaEntry("ifcpositivelengthmeasure",NULL )
-,		SchemaEntry("ifcnullstyle",NULL )
-,		SchemaEntry("ifcconditioncriterionselect",NULL )
-,		SchemaEntry("ifcshearmodulusmeasure",NULL )
-,		SchemaEntry("ifcnormalisedratiomeasure",NULL )
-,		SchemaEntry("ifcdoorpaneloperationenum",NULL )
-,		SchemaEntry("ifcpointorvertexpoint",NULL )
-,		SchemaEntry("ifcrooftypeenum",NULL )
-,		SchemaEntry("ifccountmeasure",NULL )
-,		SchemaEntry("ifcelectricconductancemeasure",NULL )
-,		SchemaEntry("ifcproceduretypeenum",NULL )
-,		SchemaEntry("ifcflowinstrumenttypeenum",NULL )
-,		SchemaEntry("ifcelectricmotortypeenum",NULL )
-,		SchemaEntry("ifcsurfaceside",NULL )
-,		SchemaEntry("ifcstructuralcurvetypeenum",NULL )
-,		SchemaEntry("ifccondensertypeenum",NULL )
-,		SchemaEntry("ifclinearstiffnessmeasure",NULL )
-,		SchemaEntry("ifcunitenum",NULL )
-,		SchemaEntry("ifcoccupanttypeenum",NULL )
-,		SchemaEntry("ifcthermalloadtypeenum",NULL )
-,		SchemaEntry("ifcreinforcingbarroleenum",NULL )
-,		SchemaEntry("ifcbenchmarkenum",NULL )
-,		SchemaEntry("ifcpositiveplaneanglemeasure",NULL )
-,		SchemaEntry("ifctexttransformation",NULL )
-,		SchemaEntry("ifcdraughtingcalloutelement",NULL )
-,		SchemaEntry("ifcratiomeasure",NULL )
-,		SchemaEntry("ifcsolidanglemeasure",NULL )
-,		SchemaEntry("ifcpipesegmenttypeenum",NULL )
-,		SchemaEntry("ifccablecarriersegmenttypeenum",NULL )
-,		SchemaEntry("ifccolourorfactor",NULL )
-,		SchemaEntry("ifcidentifier",NULL )
-,		SchemaEntry("ifctendontypeenum",NULL )
-,		SchemaEntry("ifccontrollertypeenum",NULL )
-,		SchemaEntry("ifcradioactivitymeasure",NULL )
-,		SchemaEntry("ifctimemeasure",NULL )
-,		SchemaEntry("ifcpumptypeenum",NULL )
-,		SchemaEntry("ifcelectricheatertypeenum",NULL )
-,		SchemaEntry("ifcbeamtypeenum",NULL )
-,		SchemaEntry("ifcstateenum",NULL )
-,		SchemaEntry("ifcsiprefix",NULL )
-,		SchemaEntry("ifcnumericmeasure",NULL )
-,		SchemaEntry("ifcoutlettypeenum",NULL )
-,		SchemaEntry("ifccompoundplaneanglemeasure",NULL )
-,		SchemaEntry("ifcservicelifefactortypeenum",NULL )
-,		SchemaEntry("ifclogicaloperatorenum",NULL )
-,		SchemaEntry("ifcbooleanoperand",NULL )
-,		SchemaEntry("ifcobjectreferenceselect",NULL )
-,		SchemaEntry("ifccooledbeamtypeenum",NULL )
-,		SchemaEntry("ifcductsilencertypeenum",NULL )
-,		SchemaEntry("ifcsectionalareaintegralmeasure",NULL )
-,		SchemaEntry("ifcfontvariant",NULL )
-,		SchemaEntry("ifcvolumetricflowratemeasure",NULL )
-,		SchemaEntry("ifcplatetypeenum",NULL )
-,		SchemaEntry("ifcenvironmentalimpactcategoryenum",NULL )
-,		SchemaEntry("ifcvibrationisolatortypeenum",NULL )
-,		SchemaEntry("ifcthermodynamictemperaturemeasure",NULL )
-,		SchemaEntry("ifcrotationalmassmeasure",NULL )
-,		SchemaEntry("ifcsecondinminute",NULL )
-,		SchemaEntry("ifcdayinmonthnumber",NULL )
-,		SchemaEntry("ifcdimensioncount",NULL )
-,		SchemaEntry("ifcwindowstyleoperationenum",NULL )
-,		SchemaEntry("ifcthermalresistancemeasure",NULL )
-,		SchemaEntry("ifcmeasurevalue",NULL )
-,		SchemaEntry("ifcwindowpaneloperationenum",NULL )
-,		SchemaEntry("ifcchillertypeenum",NULL )
-,		SchemaEntry("ifcpositiveratiomeasure",NULL )
-,		SchemaEntry("ifcinteger",NULL )
-,		SchemaEntry("ifclogical",NULL )
-,		SchemaEntry("ifcjunctionboxtypeenum",NULL )
-,		SchemaEntry("ifcaddresstypeenum",NULL )
-,		SchemaEntry("ifcwasteterminaltypeenum",NULL )
-,		SchemaEntry("ifctrimmingselect",NULL )
-,		SchemaEntry("ifclightemissionsourceenum",NULL )
-,		SchemaEntry("ifcsoundscaleenum",NULL )
-,		SchemaEntry("ifcluminousfluxmeasure",NULL )
-,		SchemaEntry("ifcelectricresistancemeasure",NULL )
-,		SchemaEntry("ifcintegercountratemeasure",NULL )
-,		SchemaEntry("ifcphysicalorvirtualenum",NULL )
-,		SchemaEntry("ifcmolecularweightmeasure",NULL )
-,		SchemaEntry("ifcprofiletypeenum",NULL )
-,		SchemaEntry("ifcboxalignment",NULL )
-,		SchemaEntry("ifcglobalorlocalenum",NULL )
-,		SchemaEntry("ifcspecularroughness",NULL )
-,		SchemaEntry("ifclamptypeenum",NULL )
-,		SchemaEntry("ifcpiletypeenum",NULL )
-,		SchemaEntry("ifcelectriccurrentmeasure",NULL )
-,		SchemaEntry("ifcfantypeenum",NULL )
-,		SchemaEntry("ifcsurfaceorfacesurface",NULL )
-,		SchemaEntry("ifcpipefittingtypeenum",NULL )
-,		SchemaEntry("ifctanktypeenum",NULL )
-,		SchemaEntry("ifccurvefontorscaledcurvefontselect",NULL )
-,		SchemaEntry("ifcwindowstyleconstructionenum",NULL )
-,		SchemaEntry("ifcairterminalboxtypeenum",NULL )
-,		SchemaEntry("ifcstairflighttypeenum",NULL )
-,		SchemaEntry("ifcluminousintensitymeasure",NULL )
-,		SchemaEntry("ifcmotorconnectiontypeenum",NULL )
-,		SchemaEntry("ifcplaneanglemeasure",NULL )
-,		SchemaEntry("ifcactuatortypeenum",NULL )
-,		SchemaEntry("ifccolumntypeenum",NULL )
-,		SchemaEntry("ifctextfontselect",NULL )
-,		SchemaEntry("ifcdoorpanelpositionenum",NULL )
-,		SchemaEntry("ifccoiltypeenum",NULL )
-,		SchemaEntry("ifcangularvelocitymeasure",NULL )
-,		SchemaEntry("ifcanalysismodeltypeenum",NULL )
-,		SchemaEntry("ifclibraryselect",NULL )
-,		SchemaEntry("ifcforcemeasure",NULL )
-,		SchemaEntry("ifcfillareastyletileshapeselect",NULL )
-,		SchemaEntry("ifcelectricappliancetypeenum",NULL )
-,		SchemaEntry("ifcsurfacetextureenum",NULL )
-,		SchemaEntry("ifccharacterstyleselect",NULL )
-,		SchemaEntry("ifcenergymeasure",NULL )
-,		SchemaEntry("ifcreal",NULL )
-,		SchemaEntry("ifccompressortypeenum",NULL )
-,		SchemaEntry("ifcelectricdistributionpointfunctionenum",NULL )
+		SchemaEntry("ifcstairtypeenum",nullptr )
+,		SchemaEntry("ifcspacetypeenum",nullptr )
+,		SchemaEntry("ifcwalltypeenum",nullptr )
+,		SchemaEntry("ifcmonthinyearnumber",nullptr )
+,		SchemaEntry("ifcheatfluxdensitymeasure",nullptr )
+,		SchemaEntry("ifckinematicviscositymeasure",nullptr )
+,		SchemaEntry("ifcsequenceenum",nullptr )
+,		SchemaEntry("ifcairtoairheatrecoverytypeenum",nullptr )
+,		SchemaEntry("ifcactorselect",nullptr )
+,		SchemaEntry("ifctransformertypeenum",nullptr )
+,		SchemaEntry("ifcunitaryequipmenttypeenum",nullptr )
+,		SchemaEntry("ifcelectricflowstoragedevicetypeenum",nullptr )
+,		SchemaEntry("ifcenergysequenceenum",nullptr )
+,		SchemaEntry("ifcworkcontroltypeenum",nullptr )
+,		SchemaEntry("ifccurvaturemeasure",nullptr )
+,		SchemaEntry("ifcparametervalue",nullptr )
+,		SchemaEntry("ifcappliedvalueselect",nullptr )
+,		SchemaEntry("ifcwarpingconstantmeasure",nullptr )
+,		SchemaEntry("ifcarithmeticoperatorenum",nullptr )
+,		SchemaEntry("ifclinearforcemeasure",nullptr )
+,		SchemaEntry("ifcwindowpanelpositionenum",nullptr )
+,		SchemaEntry("ifcflowmetertypeenum",nullptr )
+,		SchemaEntry("ifcrampflighttypeenum",nullptr )
+,		SchemaEntry("ifcspecularhighlightselect",nullptr )
+,		SchemaEntry("ifcactiontypeenum",nullptr )
+,		SchemaEntry("ifcgeometricprojectionenum",nullptr )
+,		SchemaEntry("ifctimeseriesdatatypeenum",nullptr )
+,		SchemaEntry("ifcmagneticfluxmeasure",nullptr )
+,		SchemaEntry("ifcobjecttypeenum",nullptr )
+,		SchemaEntry("ifcdataoriginenum",nullptr )
+,		SchemaEntry("ifcmassdensitymeasure",nullptr )
+,		SchemaEntry("ifclightfixturetypeenum",nullptr )
+,		SchemaEntry("ifcservicelifetypeenum",nullptr )
+,		SchemaEntry("ifcelectricvoltagemeasure",nullptr )
+,		SchemaEntry("ifcheatingvaluemeasure",nullptr )
+,		SchemaEntry("ifcpresentabletext",nullptr )
+,		SchemaEntry("ifcaheadorbehind",nullptr )
+,		SchemaEntry("ifcsimplevalue",nullptr )
+,		SchemaEntry("ifcsensortypeenum",nullptr )
+,		SchemaEntry("ifcderivedunitenum",nullptr )
+,		SchemaEntry("ifcsizeselect",nullptr )
+,		SchemaEntry("ifctransportelementtypeenum",nullptr )
+,		SchemaEntry("ifcinventorytypeenum",nullptr )
+,		SchemaEntry("ifctextdecoration",nullptr )
+,		SchemaEntry("ifcdirectionsenseenum",nullptr )
+,		SchemaEntry("ifcductfittingtypeenum",nullptr )
+,		SchemaEntry("ifcdocumentstatusenum",nullptr )
+,		SchemaEntry("ifcslabtypeenum",nullptr )
+,		SchemaEntry("ifcdoorstyleconstructionenum",nullptr )
+,		SchemaEntry("ifcvolumemeasure",nullptr )
+,		SchemaEntry("ifcinductancemeasure",nullptr )
+,		SchemaEntry("ifccurtainwalltypeenum",nullptr )
+,		SchemaEntry("ifcsiunitname",nullptr )
+,		SchemaEntry("ifcspecularexponent",nullptr )
+,		SchemaEntry("ifcsoundpressuremeasure",nullptr )
+,		SchemaEntry("ifcanalysistheorytypeenum",nullptr )
+,		SchemaEntry("ifcgasterminaltypeenum",nullptr )
+,		SchemaEntry("ifcyearnumber",nullptr )
+,		SchemaEntry("ifcmodulusofelasticitymeasure",nullptr )
+,		SchemaEntry("ifcchangeactionenum",nullptr )
+,		SchemaEntry("ifcdampertypeenum",nullptr )
+,		SchemaEntry("ifcevaporatortypeenum",nullptr )
+,		SchemaEntry("ifcionconcentrationmeasure",nullptr )
+,		SchemaEntry("ifcductsegmenttypeenum",nullptr )
+,		SchemaEntry("ifcprotectivedevicetypeenum",nullptr )
+,		SchemaEntry("ifcabsorbeddosemeasure",nullptr )
+,		SchemaEntry("ifcmassperlengthmeasure",nullptr )
+,		SchemaEntry("ifctextfontname",nullptr )
+,		SchemaEntry("ifcorientationselect",nullptr )
+,		SchemaEntry("ifcilluminancemeasure",nullptr )
+,		SchemaEntry("ifcfiresuppressionterminaltypeenum",nullptr )
+,		SchemaEntry("ifcfontstyle",nullptr )
+,		SchemaEntry("ifcmomentofinertiameasure",nullptr )
+,		SchemaEntry("ifcmodulusofsubgradereactionmeasure",nullptr )
+,		SchemaEntry("ifccomplexnumber",nullptr )
+,		SchemaEntry("ifchumidifiertypeenum",nullptr )
+,		SchemaEntry("ifcpresentationstyleselect",nullptr )
+,		SchemaEntry("ifcthermaltransmittancemeasure",nullptr )
+,		SchemaEntry("ifcribplatedirectionenum",nullptr )
+,		SchemaEntry("ifcclassificationnotationselect",nullptr )
+,		SchemaEntry("ifcminuteinhour",nullptr )
+,		SchemaEntry("ifcinternalorexternalenum",nullptr )
+,		SchemaEntry("ifcrotationalfrequencymeasure",nullptr )
+,		SchemaEntry("ifcsanitaryterminaltypeenum",nullptr )
+,		SchemaEntry("ifcsymbolstyleselect",nullptr )
+,		SchemaEntry("ifcelementcompositionenum",nullptr )
+,		SchemaEntry("ifctextpath",nullptr )
+,		SchemaEntry("ifcpowermeasure",nullptr )
+,		SchemaEntry("ifcsurfacestyleelementselect",nullptr )
+,		SchemaEntry("ifcresourceconsumptionenum",nullptr )
+,		SchemaEntry("ifcelectriccapacitancemeasure",nullptr )
+,		SchemaEntry("ifclayersetdirectionenum",nullptr )
+,		SchemaEntry("ifcrailingtypeenum",nullptr )
+,		SchemaEntry("ifcobjectiveenum",nullptr )
+,		SchemaEntry("ifcdocumentselect",nullptr )
+,		SchemaEntry("ifcmodulusoflinearsubgradereactionmeasure",nullptr )
+,		SchemaEntry("ifcthermaladmittancemeasure",nullptr )
+,		SchemaEntry("ifctransitioncode",nullptr )
+,		SchemaEntry("ifcconnectiontypeenum",nullptr )
+,		SchemaEntry("ifcmonetarymeasure",nullptr )
+,		SchemaEntry("ifcstackterminaltypeenum",nullptr )
+,		SchemaEntry("ifccolour",nullptr )
+,		SchemaEntry("ifctext",nullptr )
+,		SchemaEntry("ifccontextdependentmeasure",nullptr )
+,		SchemaEntry("ifcthermalconductivitymeasure",nullptr )
+,		SchemaEntry("ifcprojectedortruelengthenum",nullptr )
+,		SchemaEntry("ifcpressuremeasure",nullptr )
+,		SchemaEntry("ifcmoisturediffusivitymeasure",nullptr )
+,		SchemaEntry("ifcbooleanoperator",nullptr )
+,		SchemaEntry("ifcpropertysourceenum",nullptr )
+,		SchemaEntry("ifctimestamp",nullptr )
+,		SchemaEntry("ifcmaterialselect",nullptr )
+,		SchemaEntry("ifcgloballyuniqueid",nullptr )
+,		SchemaEntry("ifcreflectancemethodenum",nullptr )
+,		SchemaEntry("ifcvaporpermeabilitymeasure",nullptr )
+,		SchemaEntry("ifctimeseriesscheduletypeenum",nullptr )
+,		SchemaEntry("ifclinearmomentmeasure",nullptr )
+,		SchemaEntry("ifcgeometricsetselect",nullptr )
+,		SchemaEntry("ifcsectionmodulusmeasure",nullptr )
+,		SchemaEntry("ifcbsplinecurveform",nullptr )
+,		SchemaEntry("ifcdimensionextentusage",nullptr )
+,		SchemaEntry("ifcthermalexpansioncoefficientmeasure",nullptr )
+,		SchemaEntry("ifchourinday",nullptr )
+,		SchemaEntry("ifclinearvelocitymeasure",nullptr )
+,		SchemaEntry("ifctorquemeasure",nullptr )
+,		SchemaEntry("ifctemperaturegradientmeasure",nullptr )
+,		SchemaEntry("ifcfillstyleselect",nullptr )
+,		SchemaEntry("ifcelectricchargemeasure",nullptr )
+,		SchemaEntry("ifcheatexchangertypeenum",nullptr )
+,		SchemaEntry("ifcelectriccurrentenum",nullptr )
+,		SchemaEntry("ifcdaylightsavinghour",nullptr )
+,		SchemaEntry("ifcshell",nullptr )
+,		SchemaEntry("ifcdoseequivalentmeasure",nullptr )
+,		SchemaEntry("ifcprojectordertypeenum",nullptr )
+,		SchemaEntry("ifcderivedmeasurevalue",nullptr )
+,		SchemaEntry("ifclightdistributioncurveenum",nullptr )
+,		SchemaEntry("ifcwarpingmomentmeasure",nullptr )
+,		SchemaEntry("ifcmembertypeenum",nullptr )
+,		SchemaEntry("ifcsoundpowermeasure",nullptr )
+,		SchemaEntry("ifctextalignment",nullptr )
+,		SchemaEntry("ifccurveoredgecurve",nullptr )
+,		SchemaEntry("ifcmassflowratemeasure",nullptr )
+,		SchemaEntry("ifcisothermalmoisturecapacitymeasure",nullptr )
+,		SchemaEntry("ifccsgselect",nullptr )
+,		SchemaEntry("ifccoolingtowertypeenum",nullptr )
+,		SchemaEntry("ifcmassmeasure",nullptr )
+,		SchemaEntry("ifcpileconstructionenum",nullptr )
+,		SchemaEntry("ifcdoorstyleoperationenum",nullptr )
+,		SchemaEntry("ifcflowdirectionenum",nullptr )
+,		SchemaEntry("ifcthermalloadsourceenum",nullptr )
+,		SchemaEntry("ifclengthmeasure",nullptr )
+,		SchemaEntry("ifcconstraintenum",nullptr )
+,		SchemaEntry("ifcaxis2placement",nullptr )
+,		SchemaEntry("ifcloadgrouptypeenum",nullptr )
+,		SchemaEntry("ifcvalue",nullptr )
+,		SchemaEntry("ifcreinforcingbarsurfaceenum",nullptr )
+,		SchemaEntry("ifcprojectorderrecordtypeenum",nullptr )
+,		SchemaEntry("ifcdatetimeselect",nullptr )
+,		SchemaEntry("ifcstructuralsurfacetypeenum",nullptr )
+,		SchemaEntry("ifcpermeablecoveringoperationenum",nullptr )
+,		SchemaEntry("ifcfontweight",nullptr )
+,		SchemaEntry("ifcphmeasure",nullptr )
+,		SchemaEntry("ifcdescriptivemeasure",nullptr )
+,		SchemaEntry("ifccurvestylefontselect",nullptr )
+,		SchemaEntry("ifcunit",nullptr )
+,		SchemaEntry("ifchatchlinedistanceselect",nullptr )
+,		SchemaEntry("ifctextstyleselect",nullptr )
+,		SchemaEntry("ifcmetricvalueselect",nullptr )
+,		SchemaEntry("ifcvectorordirection",nullptr )
+,		SchemaEntry("ifcassemblyplaceenum",nullptr )
+,		SchemaEntry("ifcairterminaltypeenum",nullptr )
+,		SchemaEntry("ifccoveringtypeenum",nullptr )
+,		SchemaEntry("ifcplanarforcemeasure",nullptr )
+,		SchemaEntry("ifcvalvetypeenum",nullptr )
+,		SchemaEntry("ifcalarmtypeenum",nullptr )
+,		SchemaEntry("ifcdynamicviscositymeasure",nullptr )
+,		SchemaEntry("ifccurrencyenum",nullptr )
+,		SchemaEntry("ifcmodulusofrotationalsubgradereactionmeasure",nullptr )
+,		SchemaEntry("ifccablecarrierfittingtypeenum",nullptr )
+,		SchemaEntry("ifcboolean",nullptr )
+,		SchemaEntry("ifcactionsourcetypeenum",nullptr )
+,		SchemaEntry("ifcstructuralactivityassignmentselect",nullptr )
+,		SchemaEntry("ifcdistributionchamberelementtypeenum",nullptr )
+,		SchemaEntry("ifcevaporativecoolertypeenum",nullptr )
+,		SchemaEntry("ifcmagneticfluxdensitymeasure",nullptr )
+,		SchemaEntry("ifclightdistributiondatasourceselect",nullptr )
+,		SchemaEntry("ifctubebundletypeenum",nullptr )
+,		SchemaEntry("ifcaccelerationmeasure",nullptr )
+,		SchemaEntry("ifcboilertypeenum",nullptr )
+,		SchemaEntry("ifcramptypeenum",nullptr )
+,		SchemaEntry("ifcluminousintensitydistributionmeasure",nullptr )
+,		SchemaEntry("ifctrimmingpreference",nullptr )
+,		SchemaEntry("ifcspecificheatcapacitymeasure",nullptr )
+,		SchemaEntry("ifcamountofsubstancemeasure",nullptr )
+,		SchemaEntry("ifcroleenum",nullptr )
+,		SchemaEntry("ifcdocumentconfidentialityenum",nullptr )
+,		SchemaEntry("ifcfrequencymeasure",nullptr )
+,		SchemaEntry("ifcsectiontypeenum",nullptr )
+,		SchemaEntry("ifcelementassemblytypeenum",nullptr )
+,		SchemaEntry("ifcfootingtypeenum",nullptr )
+,		SchemaEntry("ifclayereditem",nullptr )
+,		SchemaEntry("ifccablesegmenttypeenum",nullptr )
+,		SchemaEntry("ifcdefinedsymbolselect",nullptr )
+,		SchemaEntry("ifcbuildingelementproxytypeenum",nullptr )
+,		SchemaEntry("ifcelectricgeneratortypeenum",nullptr )
+,		SchemaEntry("ifcrotationalstiffnessmeasure",nullptr )
+,		SchemaEntry("ifcspaceheatertypeenum",nullptr )
+,		SchemaEntry("ifcareameasure",nullptr )
+,		SchemaEntry("ifclabel",nullptr )
+,		SchemaEntry("ifccostscheduletypeenum",nullptr )
+,		SchemaEntry("ifcswitchingdevicetypeenum",nullptr )
+,		SchemaEntry("ifcelectrictimecontroltypeenum",nullptr )
+,		SchemaEntry("ifcfiltertypeenum",nullptr )
+,		SchemaEntry("ifcpositivelengthmeasure",nullptr )
+,		SchemaEntry("ifcnullstyle",nullptr )
+,		SchemaEntry("ifcconditioncriterionselect",nullptr )
+,		SchemaEntry("ifcshearmodulusmeasure",nullptr )
+,		SchemaEntry("ifcnormalisedratiomeasure",nullptr )
+,		SchemaEntry("ifcdoorpaneloperationenum",nullptr )
+,		SchemaEntry("ifcpointorvertexpoint",nullptr )
+,		SchemaEntry("ifcrooftypeenum",nullptr )
+,		SchemaEntry("ifccountmeasure",nullptr )
+,		SchemaEntry("ifcelectricconductancemeasure",nullptr )
+,		SchemaEntry("ifcproceduretypeenum",nullptr )
+,		SchemaEntry("ifcflowinstrumenttypeenum",nullptr )
+,		SchemaEntry("ifcelectricmotortypeenum",nullptr )
+,		SchemaEntry("ifcsurfaceside",nullptr )
+,		SchemaEntry("ifcstructuralcurvetypeenum",nullptr )
+,		SchemaEntry("ifccondensertypeenum",nullptr )
+,		SchemaEntry("ifclinearstiffnessmeasure",nullptr )
+,		SchemaEntry("ifcunitenum",nullptr )
+,		SchemaEntry("ifcoccupanttypeenum",nullptr )
+,		SchemaEntry("ifcthermalloadtypeenum",nullptr )
+,		SchemaEntry("ifcreinforcingbarroleenum",nullptr )
+,		SchemaEntry("ifcbenchmarkenum",nullptr )
+,		SchemaEntry("ifcpositiveplaneanglemeasure",nullptr )
+,		SchemaEntry("ifctexttransformation",nullptr )
+,		SchemaEntry("ifcdraughtingcalloutelement",nullptr )
+,		SchemaEntry("ifcratiomeasure",nullptr )
+,		SchemaEntry("ifcsolidanglemeasure",nullptr )
+,		SchemaEntry("ifcpipesegmenttypeenum",nullptr )
+,		SchemaEntry("ifccablecarriersegmenttypeenum",nullptr )
+,		SchemaEntry("ifccolourorfactor",nullptr )
+,		SchemaEntry("ifcidentifier",nullptr )
+,		SchemaEntry("ifctendontypeenum",nullptr )
+,		SchemaEntry("ifccontrollertypeenum",nullptr )
+,		SchemaEntry("ifcradioactivitymeasure",nullptr )
+,		SchemaEntry("ifctimemeasure",nullptr )
+,		SchemaEntry("ifcpumptypeenum",nullptr )
+,		SchemaEntry("ifcelectricheatertypeenum",nullptr )
+,		SchemaEntry("ifcbeamtypeenum",nullptr )
+,		SchemaEntry("ifcstateenum",nullptr )
+,		SchemaEntry("ifcsiprefix",nullptr )
+,		SchemaEntry("ifcnumericmeasure",nullptr )
+,		SchemaEntry("ifcoutlettypeenum",nullptr )
+,		SchemaEntry("ifccompoundplaneanglemeasure",nullptr )
+,		SchemaEntry("ifcservicelifefactortypeenum",nullptr )
+,		SchemaEntry("ifclogicaloperatorenum",nullptr )
+,		SchemaEntry("ifcbooleanoperand",nullptr )
+,		SchemaEntry("ifcobjectreferenceselect",nullptr )
+,		SchemaEntry("ifccooledbeamtypeenum",nullptr )
+,		SchemaEntry("ifcductsilencertypeenum",nullptr )
+,		SchemaEntry("ifcsectionalareaintegralmeasure",nullptr )
+,		SchemaEntry("ifcfontvariant",nullptr )
+,		SchemaEntry("ifcvolumetricflowratemeasure",nullptr )
+,		SchemaEntry("ifcplatetypeenum",nullptr )
+,		SchemaEntry("ifcenvironmentalimpactcategoryenum",nullptr )
+,		SchemaEntry("ifcvibrationisolatortypeenum",nullptr )
+,		SchemaEntry("ifcthermodynamictemperaturemeasure",nullptr )
+,		SchemaEntry("ifcrotationalmassmeasure",nullptr )
+,		SchemaEntry("ifcsecondinminute",nullptr )
+,		SchemaEntry("ifcdayinmonthnumber",nullptr )
+,		SchemaEntry("ifcdimensioncount",nullptr )
+,		SchemaEntry("ifcwindowstyleoperationenum",nullptr )
+,		SchemaEntry("ifcthermalresistancemeasure",nullptr )
+,		SchemaEntry("ifcmeasurevalue",nullptr )
+,		SchemaEntry("ifcwindowpaneloperationenum",nullptr )
+,		SchemaEntry("ifcchillertypeenum",nullptr )
+,		SchemaEntry("ifcpositiveratiomeasure",nullptr )
+,		SchemaEntry("ifcinteger",nullptr )
+,		SchemaEntry("ifclogical",nullptr )
+,		SchemaEntry("ifcjunctionboxtypeenum",nullptr )
+,		SchemaEntry("ifcaddresstypeenum",nullptr )
+,		SchemaEntry("ifcwasteterminaltypeenum",nullptr )
+,		SchemaEntry("ifctrimmingselect",nullptr )
+,		SchemaEntry("ifclightemissionsourceenum",nullptr )
+,		SchemaEntry("ifcsoundscaleenum",nullptr )
+,		SchemaEntry("ifcluminousfluxmeasure",nullptr )
+,		SchemaEntry("ifcelectricresistancemeasure",nullptr )
+,		SchemaEntry("ifcintegercountratemeasure",nullptr )
+,		SchemaEntry("ifcphysicalorvirtualenum",nullptr )
+,		SchemaEntry("ifcmolecularweightmeasure",nullptr )
+,		SchemaEntry("ifcprofiletypeenum",nullptr )
+,		SchemaEntry("ifcboxalignment",nullptr )
+,		SchemaEntry("ifcglobalorlocalenum",nullptr )
+,		SchemaEntry("ifcspecularroughness",nullptr )
+,		SchemaEntry("ifclamptypeenum",nullptr )
+,		SchemaEntry("ifcpiletypeenum",nullptr )
+,		SchemaEntry("ifcelectriccurrentmeasure",nullptr )
+,		SchemaEntry("ifcfantypeenum",nullptr )
+,		SchemaEntry("ifcsurfaceorfacesurface",nullptr )
+,		SchemaEntry("ifcpipefittingtypeenum",nullptr )
+,		SchemaEntry("ifctanktypeenum",nullptr )
+,		SchemaEntry("ifccurvefontorscaledcurvefontselect",nullptr )
+,		SchemaEntry("ifcwindowstyleconstructionenum",nullptr )
+,		SchemaEntry("ifcairterminalboxtypeenum",nullptr )
+,		SchemaEntry("ifcstairflighttypeenum",nullptr )
+,		SchemaEntry("ifcluminousintensitymeasure",nullptr )
+,		SchemaEntry("ifcmotorconnectiontypeenum",nullptr )
+,		SchemaEntry("ifcplaneanglemeasure",nullptr )
+,		SchemaEntry("ifcactuatortypeenum",nullptr )
+,		SchemaEntry("ifccolumntypeenum",nullptr )
+,		SchemaEntry("ifctextfontselect",nullptr )
+,		SchemaEntry("ifcdoorpanelpositionenum",nullptr )
+,		SchemaEntry("ifccoiltypeenum",nullptr )
+,		SchemaEntry("ifcangularvelocitymeasure",nullptr )
+,		SchemaEntry("ifcanalysismodeltypeenum",nullptr )
+,		SchemaEntry("ifclibraryselect",nullptr )
+,		SchemaEntry("ifcforcemeasure",nullptr )
+,		SchemaEntry("ifcfillareastyletileshapeselect",nullptr )
+,		SchemaEntry("ifcelectricappliancetypeenum",nullptr )
+,		SchemaEntry("ifcsurfacetextureenum",nullptr )
+,		SchemaEntry("ifccharacterstyleselect",nullptr )
+,		SchemaEntry("ifcenergymeasure",nullptr )
+,		SchemaEntry("ifcreal",nullptr )
+,		SchemaEntry("ifccompressortypeenum",nullptr )
+,		SchemaEntry("ifcelectricdistributionpointfunctionenum",nullptr )
 ,		SchemaEntry("ifcroot",&STEP::ObjectHelper<IfcRoot,4>::Construct )
 ,		SchemaEntry("ifcobjectdefinition",&STEP::ObjectHelper<IfcObjectDefinition,0>::Construct )
 ,		SchemaEntry("ifctypeobject",&STEP::ObjectHelper<IfcTypeObject,2>::Construct )

+ 1 - 1
code/AssetLib/IFC/IFCUtil.cpp

@@ -71,7 +71,7 @@ aiMesh* TempMesh::ToMesh()
     ai_assert(mVerts.size() == std::accumulate(mVertcnt.begin(),mVertcnt.end(),size_t(0)));
 
     if (mVerts.empty()) {
-        return NULL;
+        return nullptr;
     }
 
     std::unique_ptr<aiMesh> mesh(new aiMesh());

+ 1 - 1
code/AssetLib/IFC/IFCUtil.h

@@ -201,7 +201,7 @@ struct ConversionData
 
     struct MeshCacheIndex {
         const IFC::Schema_2x3::IfcRepresentationItem* item; unsigned int matindex;
-        MeshCacheIndex() : item(NULL), matindex(0) { }
+        MeshCacheIndex() : item(nullptr), matindex(0) { }
         MeshCacheIndex(const IFC::Schema_2x3::IfcRepresentationItem* i, unsigned int mi) : item(i), matindex(mi) { }
         bool operator == (const MeshCacheIndex& o) const { return item == o.item && matindex == o.matindex; }
         bool operator < (const MeshCacheIndex& o) const { return item < o.item || (item == o.item && matindex < o.matindex); }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 365 - 397
code/AssetLib/Irr/IRRLoader.cpp


+ 3 - 2
code/AssetLib/Irr/IRRMeshLoader.cpp

@@ -139,8 +139,9 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
 
     // Check whether we can read from the file
-    if( file.get() == NULL)
-        throw DeadlyImportError( "Failed to open IRRMESH file " + pFile + "");
+    if (file.get() == nullptr) {
+        throw DeadlyImportError("Failed to open IRRMESH file " + pFile + ".");
+    }
 
     // Construct the irrXML parser
     CIrrXML_IOStreamReader st(file.get());

+ 2 - 2
code/AssetLib/LWO/LWOAnimation.cpp

@@ -538,11 +538,11 @@ void AnimResolver::GetKeys(std::vector<aiVectorKey> &out,
 // ------------------------------------------------------------------------------------------------
 // Extract animation channel
 void AnimResolver::ExtractAnimChannel(aiNodeAnim **out, unsigned int /*= 0*/) {
-    *out = NULL;
+    *out = nullptr;
 
     //FIXME: crashes if more than one component is animated at different timings, to be resolved.
 
-    // If we have no envelopes, return NULL
+    // If we have no envelopes, return nullptr
     if (envelopes.empty()) {
         return;
     }

+ 2 - 2
code/AssetLib/LWO/LWOAnimation.h

@@ -211,7 +211,7 @@ public:
     // ------------------------------------------------------------------
     /** @brief Extract a node animation channel
      *  @param out Receives a pointer to a newly allocated node anim.
-     *    If there's just one keyframe defined, *out is set to NULL and
+     *    If there's just one keyframe defined, *out is set to nullptr and
      *    no animation channel is computed.
      *  @param flags Any combination of the AI_LWO_ANIM_FLAG_XXX flags.
      */
@@ -261,7 +261,7 @@ protected:
      *  @param envl_y Y-component envelope
      *  @param envl_z Z-component envelope
      *  @param flags Any combination of the AI_LWO_ANIM_FLAG_XXX flags.
-     *  @note Up to two input envelopes may be NULL
+     *  @note Up to two input envelopes may be nullptr
      */
     void GetKeys(std::vector<aiVectorKey>& out,
         LWO::Envelope* envl_x,

+ 1 - 1
code/AssetLib/LWO/LWOBLoader.cpp

@@ -255,7 +255,7 @@ void LWOImporter::LoadLWOBSurface(unsigned int size)
 
     mSurfaces->push_back( LWO::Surface () );
     LWO::Surface& surf = mSurfaces->back();
-    LWO::Texture* pTex = NULL;
+    LWO::Texture *pTex = nullptr;
 
     GetS0(surf.mName,size);
     bool running = true;

+ 1 - 1
code/AssetLib/LWO/LWOLoader.cpp

@@ -917,7 +917,7 @@ inline void CreateNewEntry(std::vector<T> &list, unsigned int srcIdx) {
 // ------------------------------------------------------------------------------------------------
 inline void LWOImporter::DoRecursiveVMAPAssignment(VMapEntry *base, unsigned int numRead,
         unsigned int idx, float *data) {
-    ai_assert(NULL != data);
+    ai_assert(nullptr != data);
     LWO::ReferrerList &refList = mCurLayer->mPointReferrers;
     unsigned int i;
 

+ 1 - 1
code/AssetLib/LWO/LWOLoader.h

@@ -305,7 +305,7 @@ private:
     /** Add children to a node
      *  @param node Node to become a father
      *  @param parent Index of the node
-     *  @param apcNodes Flat list of nodes - used nodes are set to NULL.
+     *  @param apcNodes Flat list of nodes - used nodes are set to nullptr.
     */
     void AddChildren(aiNode* node, uint16_t parent,
         std::vector<aiNode*>& apcNodes);

+ 2 - 2
code/AssetLib/LWO/LWOMaterial.cpp

@@ -79,7 +79,7 @@ inline aiTextureMapMode GetMapMode(LWO::Texture::Wrap in) {
 
 // ------------------------------------------------------------------------------------------------
 bool LWOImporter::HandleTextures(aiMaterial *pcMat, const TextureList &in, aiTextureType type) {
-    ai_assert(NULL != pcMat);
+    ai_assert(nullptr != pcMat);
 
     unsigned int cur = 0, temp = 0;
     aiString s;
@@ -603,7 +603,7 @@ void LWOImporter::LoadLWO2TextureBlock(LE_NCONST IFF::SubChunkHeader *head, unsi
     }
 
     // get the destination channel
-    TextureList *listRef = NULL;
+    TextureList *listRef = nullptr;
     switch (tex.type) {
         case AI_LWO_COLR:
             listRef = &surf.mColorTextures;

+ 3 - 3
code/AssetLib/LWS/LWSLoader.cpp

@@ -342,7 +342,7 @@ void LWSImporter::BuildGraph(aiNode *nd, LWS::NodeDesc &src, std::vector<Attachm
     if (src.type == LWS::NodeDesc::OBJECT) {
 
         // If the object is from an external file, get it
-        aiScene *obj = NULL;
+        aiScene *obj = nullptr;
         if (src.path.length()) {
             obj = batch.GetImport(src.id);
             if (!obj) {
@@ -359,7 +359,7 @@ void LWSImporter::BuildGraph(aiNode *nd, LWS::NodeDesc &src, std::vector<Attachm
 
                     //Remove first node from obj (the old pivot), reset transform of second node (the mesh node)
                     aiNode *newRootNode = obj->mRootNode->mChildren[0];
-                    obj->mRootNode->mChildren[0] = NULL;
+                    obj->mRootNode->mChildren[0] = nullptr;
                     delete obj->mRootNode;
 
                     obj->mRootNode = newRootNode;
@@ -600,7 +600,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
                 d.number = cur_object++;
             }
             std::string path = FindLWOFile(c);
-            d.id = batch.AddLoadRequest(path, 0, NULL);
+            d.id = batch.AddLoadRequest(path, 0, nullptr);
 
             d.path = path;
             nodes.push_back(d);

+ 13 - 1
code/AssetLib/LWS/LWSLoader.h

@@ -84,7 +84,19 @@ public:
  */
 struct NodeDesc {
     NodeDesc() :
-            type(), id(), number(0), parent(0), name(""), isPivotSet(false), lightColor(1.f, 1.f, 1.f), lightIntensity(1.f), lightType(0), lightFalloffType(0), lightConeAngle(45.f), lightEdgeAngle(), parent_resolved(NULL) {}
+            type(),
+            id(),
+            number(0),
+            parent(0),
+            name(""),
+            isPivotSet(false),
+            lightColor(1.f, 1.f, 1.f),
+            lightIntensity(1.f),
+            lightType(0),
+            lightFalloffType(0),
+            lightConeAngle(45.f),
+            lightEdgeAngle(),
+            parent_resolved(nullptr) {}
 
     enum {
 

+ 4 - 4
code/AssetLib/M3D/M3DExporter.cpp

@@ -181,7 +181,7 @@ M3D_INDEX addMaterial(const Assimp::M3DWrapper &m3d, const aiMaterial *mat) {
             }
             m3d->material[mi].name = SafeStr(name, true);
             m3d->material[mi].numprop = 0;
-            m3d->material[mi].prop = NULL;
+            m3d->material[mi].prop = nullptr;
             // iterate through the material property table and see what we got
             for (k = 0; k < 15; k++) {
                 unsigned int j;
@@ -229,8 +229,8 @@ M3D_INDEX addMaterial(const Assimp::M3DWrapper &m3d, const aiMaterial *mat) {
                 }
                 if (aiTxProps[k].pKey &&
                         mat->GetTexture((aiTextureType)aiTxProps[k].type,
-                                aiTxProps[k].index, &name, NULL, NULL, NULL,
-                                NULL, NULL) == AI_SUCCESS) {
+                                aiTxProps[k].index, &name, nullptr, nullptr, nullptr,
+                                nullptr, nullptr) == AI_SUCCESS) {
                     unsigned int i;
                     for (j = name.length - 1; j > 0 && name.data[j] != '.'; j++)
                         ;
@@ -259,7 +259,7 @@ M3D_INDEX addMaterial(const Assimp::M3DWrapper &m3d, const aiMaterial *mat) {
                         m3d->texture[i].name = fn;
                         m3d->texture[i].w = 0;
                         m3d->texture[i].h = 0;
-                        m3d->texture[i].d = NULL;
+                        m3d->texture[i].d = nullptr;
                     }
                     addProp(&m3d->material[mi],
                             m3d_propertytypes[k].id + 128, i);

+ 4 - 2
code/AssetLib/M3D/M3DImporter.cpp

@@ -618,8 +618,10 @@ aiColor4D M3DImporter::mkColor(uint32_t c) {
 void M3DImporter::convertPose(const M3DWrapper &m3d, aiMatrix4x4 *m, unsigned int posid, unsigned int orientid) {
     ai_assert(m != nullptr);
     ai_assert(m3d);
-    ai_assert(posid != M3D_UNDEF && posid < m3d->numvertex);
-    ai_assert(orientid != M3D_UNDEF && orientid < m3d->numvertex);
+    ai_assert(posid != M3D_UNDEF);
+    ai_assert(posid < m3d->numvertex);
+    ai_assert(orientid != M3D_UNDEF);
+    ai_assert(orientid < m3d->numvertex);
     if (!m3d->numvertex || !m3d->vertex)
         return;
     m3dv_t *p = &m3d->vertex[posid];

+ 12 - 12
code/AssetLib/M3D/M3DMaterials.h

@@ -71,14 +71,14 @@ static const aiMatProp aiProps[] = {
     { AI_MATKEY_OPACITY },                                      /* m3dp_d */
     { AI_MATKEY_SHADING_MODEL },                                /* m3dp_il */
 
-    { NULL, 0, 0 },                                             /* m3dp_Pr */
+    { nullptr, 0, 0 },                                          /* m3dp_Pr */
     { AI_MATKEY_REFLECTIVITY },                                 /* m3dp_Pm */
-    { NULL, 0, 0 },                                             /* m3dp_Ps */
+    { nullptr, 0, 0 },                                          /* m3dp_Ps */
     { AI_MATKEY_REFRACTI },                                     /* m3dp_Ni */
-    { NULL, 0, 0 },                                             /* m3dp_Nt */
-    { NULL, 0, 0 },
-    { NULL, 0, 0 },
-    { NULL, 0, 0 }
+    { nullptr, 0, 0 },                                          /* m3dp_Nt */
+    { nullptr, 0, 0 },
+    { nullptr, 0, 0 },
+    { nullptr, 0, 0 }
 };
 
 /* --- Texture Map Properties ---   !!!!! must match m3d_propertytypes !!!!! */
@@ -88,19 +88,19 @@ static const aiMatProp aiTxProps[] = {
     { AI_MATKEY_TEXTURE_SPECULAR(0) },                       /* m3dp_map_Ks */
     { AI_MATKEY_TEXTURE_SHININESS(0) },                      /* m3dp_map_Ns */
     { AI_MATKEY_TEXTURE_EMISSIVE(0) },                       /* m3dp_map_Ke */
-    { NULL, 0, 0 },                                          /* m3dp_map_Tf */
+    { nullptr, 0, 0 },                                       /* m3dp_map_Tf */
     { AI_MATKEY_TEXTURE_HEIGHT(0) },                         /* m3dp_bump */
     { AI_MATKEY_TEXTURE_OPACITY(0) },                        /* m3dp_map_d */
     { AI_MATKEY_TEXTURE_NORMALS(0) },                        /* m3dp_map_N */
 
     { AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE_ROUGHNESS,0) },/* m3dp_map_Pr */
     { AI_MATKEY_TEXTURE(aiTextureType_METALNESS,0) },        /* m3dp_map_Pm */
-    { NULL, 0, 0 },                                          /* m3dp_map_Ps */
+    { nullptr, 0, 0 },                                       /* m3dp_map_Ps */
     { AI_MATKEY_TEXTURE(aiTextureType_REFLECTION,0) },       /* m3dp_map_Ni */
-    { NULL, 0, 0 },                                          /* m3dp_map_Nt */
-    { NULL, 0, 0 },
-    { NULL, 0, 0 },
-    { NULL, 0, 0 }
+    { nullptr, 0, 0 },                                       /* m3dp_map_Nt */
+    { nullptr, 0, 0 },
+    { nullptr, 0, 0 },
+    { nullptr, 0, 0 }
 };
 
 #endif // AI_M3DMATERIALS_H_INC

+ 1 - 1
code/AssetLib/M3D/M3DWrapper.cpp

@@ -72,7 +72,7 @@ unsigned char *m3dimporter_readfile(char *fn, unsigned int *size) {
     std::unique_ptr<Assimp::IOStream> pStream(
             (reinterpret_cast<Assimp::IOSystem *>(m3dimporter_pIOHandler))->Open(file, "rb"));
     size_t fileSize = 0;
-    unsigned char *data = NULL;
+    unsigned char *data = nullptr;
     // sometimes pStream is nullptr in a single-threaded scenario too for some reason
     // (should be an empty object returning nothing I guess)
     if (pStream) {

+ 6 - 5
code/AssetLib/MD2/MD2Loader.cpp

@@ -221,20 +221,21 @@ void MD2Importer::InternReadFile( const std::string& pFile,
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
 
     // Check whether we can read from the file
-    if( file.get() == NULL)
-        throw DeadlyImportError( "Failed to open MD2 file " + pFile + "");
+    if (file.get() == nullptr) {
+        throw DeadlyImportError("Failed to open MD2 file " + pFile + "");
+    }
 
     // check whether the md3 file is large enough to contain
     // at least the file header
     fileSize = (unsigned int)file->FileSize();
-    if( fileSize < sizeof(MD2::Header))
-        throw DeadlyImportError( "MD2 File is too small");
+    if (fileSize < sizeof(MD2::Header)) {
+        throw DeadlyImportError("MD2 File is too small");
+    }
 
     std::vector<uint8_t> mBuffer2(fileSize);
     file->Read(&mBuffer2[0], 1, fileSize);
     mBuffer = &mBuffer2[0];
 
-
     m_pcHeader = (BE_NCONST MD2::Header*)mBuffer;
 
 #ifdef AI_BUILD_BIG_ENDIAN

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 234 - 271
code/AssetLib/MD3/MD3Loader.cpp


+ 87 - 71
code/AssetLib/MD5/MD5Loader.cpp

@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
 
 Copyright (c) 2006-2020, assimp team
 
-
-
 All rights reserved.
 
 Redistribution and use of this software in source and binary forms,
@@ -82,7 +80,15 @@ static const aiImporterDesc desc = {
 // ------------------------------------------------------------------------------------------------
 // Constructor to be privately used by Importer
 MD5Importer::MD5Importer() :
-        mIOHandler(nullptr), mBuffer(), fileSize(), iLineNumber(), pScene(), bHadMD5Mesh(), bHadMD5Anim(), bHadMD5Camera(), configNoAutoLoad(false) {
+        mIOHandler(nullptr),
+        mBuffer(),
+        mFileSize(),
+        mLineNumber(),
+        mScene(),
+        mHadMD5Mesh(),
+        mHadMD5Anim(),
+        mHadMD5Camera(),
+        mCconfigNoAutoLoad(false) {
     // empty
 }
 
@@ -106,6 +112,7 @@ bool MD5Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
         const char *tokens[] = { "MD5Version" };
         return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
     }
+
     return false;
 }
 
@@ -119,16 +126,15 @@ const aiImporterDesc *MD5Importer::GetInfo() const {
 // Setup import properties
 void MD5Importer::SetupProperties(const Importer *pImp) {
     // AI_CONFIG_IMPORT_MD5_NO_ANIM_AUTOLOAD
-    configNoAutoLoad = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD5_NO_ANIM_AUTOLOAD, 0));
+    mCconfigNoAutoLoad = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MD5_NO_ANIM_AUTOLOAD, 0));
 }
 
 // ------------------------------------------------------------------------------------------------
 // Imports the given file into the given scene structure.
-void MD5Importer::InternReadFile(const std::string &pFile,
-        aiScene *_pScene, IOSystem *pIOHandler) {
+void MD5Importer::InternReadFile(const std::string &pFile, aiScene *_pScene, IOSystem *pIOHandler) {
     mIOHandler = pIOHandler;
-    pScene = _pScene;
-    bHadMD5Mesh = bHadMD5Anim = bHadMD5Camera = false;
+    mScene = _pScene;
+    mHadMD5Mesh = mHadMD5Anim = mHadMD5Camera = false;
 
     // remove the file extension
     const std::string::size_type pos = pFile.find_last_of('.');
@@ -138,7 +144,7 @@ void MD5Importer::InternReadFile(const std::string &pFile,
     try {
         if (extension == "md5camera") {
             LoadMD5CameraFile();
-        } else if (configNoAutoLoad || extension == "md5anim") {
+        } else if (mCconfigNoAutoLoad || extension == "md5anim") {
             // determine file extension and process just *one* file
             if (extension.length() == 0) {
                 throw DeadlyImportError("Failure, need file extension to determine MD5 part type");
@@ -158,17 +164,17 @@ void MD5Importer::InternReadFile(const std::string &pFile,
     }
 
     // make sure we have at least one file
-    if (!bHadMD5Mesh && !bHadMD5Anim && !bHadMD5Camera) {
+    if (!mHadMD5Mesh && !mHadMD5Anim && !mHadMD5Camera) {
         throw DeadlyImportError("Failed to read valid contents out of this MD5* file");
     }
 
     // Now rotate the whole scene 90 degrees around the x axis to match our internal coordinate system
-    pScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f,
+    mScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f,
             0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
 
     // the output scene wouldn't pass the validation without this flag
-    if (!bHadMD5Mesh) {
-        pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
+    if (!mHadMD5Mesh) {
+        mScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
     }
 
     // clean the instance -- the BaseImporter instance may be reused later.
@@ -181,17 +187,17 @@ void MD5Importer::LoadFileIntoMemory(IOStream *file) {
     // unload the previous buffer, if any
     UnloadFileFromMemory();
 
-    ai_assert(NULL != file);
-    fileSize = (unsigned int)file->FileSize();
-    ai_assert(fileSize);
+    ai_assert(nullptr != file);
+    mFileSize = (unsigned int)file->FileSize();
+    ai_assert(mFileSize);
 
     // allocate storage and copy the contents of the file to a memory buffer
-    mBuffer = new char[fileSize + 1];
-    file->Read((void *)mBuffer, 1, fileSize);
-    iLineNumber = 1;
+    mBuffer = new char[mFileSize + 1];
+    file->Read((void *)mBuffer, 1, mFileSize);
+    mLineNumber = 1;
 
     // append a terminal 0
-    mBuffer[fileSize] = '\0';
+    mBuffer[mFileSize] = '\0';
 
     // now remove all line comments from the file
     CommentRemover::RemoveLineComments("//", mBuffer, ' ');
@@ -202,8 +208,8 @@ void MD5Importer::LoadFileIntoMemory(IOStream *file) {
 void MD5Importer::UnloadFileFromMemory() {
     // delete the file buffer
     delete[] mBuffer;
-    mBuffer = NULL;
-    fileSize = 0;
+    mBuffer = nullptr;
+    mFileSize = 0;
 }
 
 // ------------------------------------------------------------------------------------------------
@@ -243,7 +249,8 @@ void MD5Importer::MakeDataUnique(MD5::MeshDesc &meshSrc) {
 // ------------------------------------------------------------------------------------------------
 // Recursive node graph construction from a MD5MESH
 void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &bones) {
-    ai_assert(NULL != piParent && !piParent->mNumChildren);
+    ai_assert(nullptr != piParent);
+    ai_assert(!piParent->mNumChildren);
 
     // First find out how many children we'll have
     for (int i = 0; i < (int)bones.size(); ++i) {
@@ -293,7 +300,8 @@ void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &b
 // ------------------------------------------------------------------------------------------------
 // Recursive node graph construction from a MD5ANIM
 void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneList &bones, const aiNodeAnim **node_anims) {
-    ai_assert(NULL != piParent && !piParent->mNumChildren);
+    ai_assert(nullptr != piParent);
+    ai_assert(!piParent->mNumChildren);
 
     // First find out how many children we'll have
     for (int i = 0; i < (int)bones.size(); ++i) {
@@ -332,37 +340,37 @@ void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneLis
 // ------------------------------------------------------------------------------------------------
 // Load a MD5MESH file
 void MD5Importer::LoadMD5MeshFile() {
-    std::string pFile = mFile + "md5mesh";
-    std::unique_ptr<IOStream> file(mIOHandler->Open(pFile, "rb"));
+    std::string filename = mFile + "md5mesh";
+    std::unique_ptr<IOStream> file(mIOHandler->Open(filename, "rb"));
 
     // Check whether we can read from the file
     if (file.get() == nullptr || !file->FileSize()) {
-        ASSIMP_LOG_WARN("Failed to access MD5MESH file: " + pFile);
+        ASSIMP_LOG_WARN("Failed to access MD5MESH file: " + filename);
         return;
     }
-    bHadMD5Mesh = true;
+    mHadMD5Mesh = true;
     LoadFileIntoMemory(file.get());
 
     // now construct a parser and parse the file
-    MD5::MD5Parser parser(mBuffer, fileSize);
+    MD5::MD5Parser parser(mBuffer, mFileSize);
 
     // load the mesh information from it
     MD5::MD5MeshParser meshParser(parser.mSections);
 
     // create the bone hierarchy - first the root node and dummy nodes for all meshes
-    pScene->mRootNode = new aiNode("<MD5_Root>");
-    pScene->mRootNode->mNumChildren = 2;
-    pScene->mRootNode->mChildren = new aiNode *[2];
+    mScene->mRootNode = new aiNode("<MD5_Root>");
+    mScene->mRootNode->mNumChildren = 2;
+    mScene->mRootNode->mChildren = new aiNode *[2];
 
     // build the hierarchy from the MD5MESH file
-    aiNode *pcNode = pScene->mRootNode->mChildren[1] = new aiNode();
+    aiNode *pcNode = mScene->mRootNode->mChildren[1] = new aiNode();
     pcNode->mName.Set("<MD5_Hierarchy>");
-    pcNode->mParent = pScene->mRootNode;
+    pcNode->mParent = mScene->mRootNode;
     AttachChilds_Mesh(-1, pcNode, meshParser.mJoints);
 
-    pcNode = pScene->mRootNode->mChildren[0] = new aiNode();
+    pcNode = mScene->mRootNode->mChildren[0] = new aiNode();
     pcNode->mName.Set("<MD5_Mesh>");
-    pcNode->mParent = pScene->mRootNode;
+    pcNode->mParent = mScene->mRootNode;
 
 #if 0
     if (pScene->mRootNode->mChildren[1]->mNumChildren) /* start at the right hierarchy level */
@@ -371,28 +379,31 @@ void MD5Importer::LoadMD5MeshFile() {
 
     // FIX: MD5 files exported from Blender can have empty meshes
     for (std::vector<MD5::MeshDesc>::const_iterator it = meshParser.mMeshes.begin(), end = meshParser.mMeshes.end(); it != end; ++it) {
-        if (!(*it).mFaces.empty() && !(*it).mVertices.empty())
-            ++pScene->mNumMaterials;
+        if (!(*it).mFaces.empty() && !(*it).mVertices.empty()) {
+            ++mScene->mNumMaterials;
+        }
     }
 
     // generate all meshes
-    pScene->mNumMeshes = pScene->mNumMaterials;
-    pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
-    pScene->mMaterials = new aiMaterial *[pScene->mNumMeshes];
+    mScene->mNumMeshes = mScene->mNumMaterials;
+    mScene->mMeshes = new aiMesh *[mScene->mNumMeshes];
+    mScene->mMaterials = new aiMaterial *[mScene->mNumMeshes];
 
     //  storage for node mesh indices
-    pcNode->mNumMeshes = pScene->mNumMeshes;
+    pcNode->mNumMeshes = mScene->mNumMeshes;
     pcNode->mMeshes = new unsigned int[pcNode->mNumMeshes];
-    for (unsigned int m = 0; m < pcNode->mNumMeshes; ++m)
+    for (unsigned int m = 0; m < pcNode->mNumMeshes; ++m) {
         pcNode->mMeshes[m] = m;
+    }
 
     unsigned int n = 0;
     for (std::vector<MD5::MeshDesc>::iterator it = meshParser.mMeshes.begin(), end = meshParser.mMeshes.end(); it != end; ++it) {
         MD5::MeshDesc &meshSrc = *it;
-        if (meshSrc.mFaces.empty() || meshSrc.mVertices.empty())
+        if (meshSrc.mFaces.empty() || meshSrc.mVertices.empty()) {
             continue;
+        }
 
-        aiMesh *mesh = pScene->mMeshes[n] = new aiMesh();
+        aiMesh *mesh = mScene->mMeshes[n] = new aiMesh();
         mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
 
         // generate unique vertices in our internal verbose format
@@ -422,17 +433,19 @@ void MD5Importer::LoadMD5MeshFile() {
             for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w) {
                 MD5::WeightDesc &weightDesc = meshSrc.mWeights[w];
                 /* FIX for some invalid exporters */
-                if (!(weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON))
+                if (!(weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON)) {
                     ++piCount[weightDesc.mBone];
+                }
             }
         }
 
         // check how many we will need
-        for (unsigned int p = 0; p < meshParser.mJoints.size(); ++p)
+        for (unsigned int p = 0; p < meshParser.mJoints.size(); ++p) {
             if (piCount[p]) mesh->mNumBones++;
+        }
 
-        if (mesh->mNumBones) // just for safety
-        {
+        // just for safety
+        if (mesh->mNumBones) {
             mesh->mBones = new aiBone *[mesh->mNumBones];
             for (unsigned int q = 0, h = 0; q < meshParser.mJoints.size(); ++q) {
                 if (!piCount[q]) continue;
@@ -457,8 +470,9 @@ void MD5Importer::LoadMD5MeshFile() {
 
                 // there are models which have weights which don't sum to 1 ...
                 ai_real fSum = 0.0;
-                for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w)
+                for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w) {
                     fSum += meshSrc.mWeights[w].mWeight;
+                }
                 if (!fSum) {
                     ASSIMP_LOG_ERROR("MD5MESH: The sum of all vertex bone weights is 0");
                     continue;
@@ -466,11 +480,12 @@ void MD5Importer::LoadMD5MeshFile() {
 
                 // process bone weights
                 for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w) {
-                    if (w >= meshSrc.mWeights.size())
+                    if (w >= meshSrc.mWeights.size()) {
                         throw DeadlyImportError("MD5MESH: Invalid weight index");
+                    }
 
                     MD5::WeightDesc &weightDesc = meshSrc.mWeights[w];
-                    if (weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON) {
+                    if (weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON) { 
                         continue;
                     }
 
@@ -504,12 +519,12 @@ void MD5Importer::LoadMD5MeshFile() {
         for (unsigned int c = 0; c < mesh->mNumFaces; ++c) {
             mesh->mFaces[c].mNumIndices = 3;
             mesh->mFaces[c].mIndices = meshSrc.mFaces[c].mIndices;
-            meshSrc.mFaces[c].mIndices = NULL;
+            meshSrc.mFaces[c].mIndices = nullptr;
         }
 
         // generate a material for the mesh
         aiMaterial *mat = new aiMaterial();
-        pScene->mMaterials[n] = mat;
+        mScene->mMaterials[n] = mat;
 
         // insert the typical doom3 textures:
         // nnn_local.tga  - normal map
@@ -555,10 +570,11 @@ void MD5Importer::LoadMD5AnimFile() {
         ASSIMP_LOG_WARN("Failed to read MD5ANIM file: " + pFile);
         return;
     }
+
     LoadFileIntoMemory(file.get());
 
     // parse the basic file structure
-    MD5::MD5Parser parser(mBuffer, fileSize);
+    MD5::MD5Parser parser(mBuffer, mFileSize);
 
     // load the animation information from the parse tree
     MD5::MD5AnimParser animParser(parser.mSections);
@@ -568,10 +584,10 @@ void MD5Importer::LoadMD5AnimFile() {
             animParser.mBaseFrames.size() != animParser.mAnimatedBones.size()) {
         ASSIMP_LOG_ERROR("MD5ANIM: No frames or animated bones loaded");
     } else {
-        bHadMD5Anim = true;
+        mHadMD5Anim = true;
 
-        pScene->mAnimations = new aiAnimation *[pScene->mNumAnimations = 1];
-        aiAnimation *anim = pScene->mAnimations[0] = new aiAnimation();
+        mScene->mAnimations = new aiAnimation *[mScene->mNumAnimations = 1];
+        aiAnimation *anim = mScene->mAnimations[0] = new aiAnimation();
         anim->mNumChannels = (unsigned int)animParser.mAnimatedBones.size();
         anim->mChannels = new aiNodeAnim *[anim->mNumChannels];
         for (unsigned int i = 0; i < anim->mNumChannels; ++i) {
@@ -637,15 +653,15 @@ void MD5Importer::LoadMD5AnimFile() {
 
         // If we didn't build the hierarchy yet (== we didn't load a MD5MESH),
         // construct it now from the data given in the MD5ANIM.
-        if (!pScene->mRootNode) {
-            pScene->mRootNode = new aiNode();
-            pScene->mRootNode->mName.Set("<MD5_Hierarchy>");
+        if (!mScene->mRootNode) {
+            mScene->mRootNode = new aiNode();
+            mScene->mRootNode->mName.Set("<MD5_Hierarchy>");
 
-            AttachChilds_Anim(-1, pScene->mRootNode, animParser.mAnimatedBones, (const aiNodeAnim **)anim->mChannels);
+            AttachChilds_Anim(-1, mScene->mRootNode, animParser.mAnimatedBones, (const aiNodeAnim **)anim->mChannels);
 
             // Call SkeletonMeshBuilder to construct a mesh to represent the shape
-            if (pScene->mRootNode->mNumChildren) {
-                SkeletonMeshBuilder skeleton_maker(pScene, pScene->mRootNode->mChildren[0]);
+            if (mScene->mRootNode->mNumChildren) {
+                SkeletonMeshBuilder skeleton_maker(mScene, mScene->mRootNode->mChildren[0]);
             }
         }
     }
@@ -661,11 +677,11 @@ void MD5Importer::LoadMD5CameraFile() {
     if (!file.get() || !file->FileSize()) {
         throw DeadlyImportError("Failed to read MD5CAMERA file: " + pFile);
     }
-    bHadMD5Camera = true;
+    mHadMD5Camera = true;
     LoadFileIntoMemory(file.get());
 
     // parse the basic file structure
-    MD5::MD5Parser parser(mBuffer, fileSize);
+    MD5::MD5Parser parser(mBuffer, mFileSize);
 
     // load the camera animation data from the parse tree
     MD5::MD5CameraParser cameraParser(parser.mSections);
@@ -679,14 +695,14 @@ void MD5Importer::LoadMD5CameraFile() {
 
     // Construct output graph - a simple root with a dummy child.
     // The root node performs the coordinate system conversion
-    aiNode *root = pScene->mRootNode = new aiNode("<MD5CameraRoot>");
+    aiNode *root = mScene->mRootNode = new aiNode("<MD5CameraRoot>");
     root->mChildren = new aiNode *[root->mNumChildren = 1];
     root->mChildren[0] = new aiNode("<MD5Camera>");
     root->mChildren[0]->mParent = root;
 
     // ... but with one camera assigned to it
-    pScene->mCameras = new aiCamera *[pScene->mNumCameras = 1];
-    aiCamera *cam = pScene->mCameras[0] = new aiCamera();
+    mScene->mCameras = new aiCamera *[mScene->mNumCameras = 1];
+    aiCamera *cam = mScene->mCameras[0] = new aiCamera();
     cam->mName = "<MD5Camera>";
 
     // FIXME: Fov is currently set to the first frame's value
@@ -703,8 +719,8 @@ void MD5Importer::LoadMD5CameraFile() {
             cuts.push_back(static_cast<unsigned int>(frames.size() - 1));
     }
 
-    pScene->mNumAnimations = static_cast<unsigned int>(cuts.size() - 1);
-    aiAnimation **tmp = pScene->mAnimations = new aiAnimation *[pScene->mNumAnimations];
+    mScene->mNumAnimations = static_cast<unsigned int>(cuts.size() - 1);
+    aiAnimation **tmp = mScene->mAnimations = new aiAnimation *[mScene->mNumAnimations];
     for (std::vector<unsigned int>::const_iterator it = cuts.begin(); it != cuts.end() - 1; ++it) {
 
         aiAnimation *anim = *tmp++ = new aiAnimation();

+ 7 - 8
code/AssetLib/MD5/MD5Loader.h

@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
 
 Copyright (c) 2006-2020, assimp team
 
-
 All rights reserved.
 
 Redistribution and use of this software in source and binary forms,
@@ -156,25 +155,25 @@ protected:
     char *mBuffer;
 
     /** Size of the file */
-    unsigned int fileSize;
+    unsigned int mFileSize;
 
     /** Current line number. For debugging purposes */
-    unsigned int iLineNumber;
+    unsigned int mLineNumber;
 
     /** Scene to be filled */
-    aiScene *pScene;
+    aiScene *mScene;
 
     /** true if a MD5MESH file has already been parsed */
-    bool bHadMD5Mesh;
+    bool mHadMD5Mesh;
 
     /** true if a MD5ANIM file has already been parsed */
-    bool bHadMD5Anim;
+    bool mHadMD5Anim;
 
     /** true if a MD5CAMERA file has already been parsed */
-    bool bHadMD5Camera;
+    bool mHadMD5Camera;
 
     /** configuration option: prevent anim autoload */
-    bool configNoAutoLoad;
+    bool mCconfigNoAutoLoad;
 };
 
 } // end of namespace Assimp

+ 164 - 179
code/AssetLib/MD5/MD5Parser.cpp

@@ -45,25 +45,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *  @brief Implementation of the MD5 parser class
  */
 
-
 // internal headers
 #include "AssetLib/MD5/MD5Loader.h"
 #include "Material/MaterialSystem.h"
 
-#include <assimp/fast_atof.h>
 #include <assimp/ParsingUtils.h>
 #include <assimp/StringComparison.h>
-#include <assimp/DefaultLogger.hpp>
+#include <assimp/fast_atof.h>
 #include <assimp/mesh.h>
+#include <assimp/DefaultLogger.hpp>
 
 using namespace Assimp;
 using namespace Assimp::MD5;
 
 // ------------------------------------------------------------------------------------------------
 // Parse the segment structure fo a MD5 file
-MD5Parser::MD5Parser(char* _buffer, unsigned int _fileSize )
-{
-    ai_assert(NULL != _buffer && 0 != _fileSize);
+MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) {
+    ai_assert(nullptr != _buffer);
+    ai_assert(0 != _fileSize);
 
     buffer = _buffer;
     fileSize = _fileSize;
@@ -78,48 +77,45 @@ MD5Parser::MD5Parser(char* _buffer, unsigned int _fileSize )
     bool running = true;
     while (running) {
         mSections.push_back(Section());
-        Section& sec = mSections.back();
-        if(!ParseSection(sec))  {
+        Section &sec = mSections.back();
+        if (!ParseSection(sec)) {
             break;
         }
     }
 
-    if ( !DefaultLogger::isNullLogger())    {
+    if (!DefaultLogger::isNullLogger()) {
         char szBuffer[128]; // should be sufficiently large
-        ::ai_snprintf(szBuffer,128,"MD5Parser end. Parsed %i sections",(int)mSections.size());
+        ::ai_snprintf(szBuffer, 128, "MD5Parser end. Parsed %i sections", (int)mSections.size());
         ASSIMP_LOG_DEBUG(szBuffer);
     }
 }
 
 // ------------------------------------------------------------------------------------------------
 // Report error to the log stream
-/*static*/ AI_WONT_RETURN void MD5Parser::ReportError (const char* error, unsigned int line)
-{
+/*static*/ AI_WONT_RETURN void MD5Parser::ReportError(const char *error, unsigned int line) {
     char szBuffer[1024];
-    ::ai_snprintf(szBuffer, 1024, "[MD5] Line %u: %s",line,error);
+    ::ai_snprintf(szBuffer, 1024, "[MD5] Line %u: %s", line, error);
     throw DeadlyImportError(szBuffer);
 }
 
 // ------------------------------------------------------------------------------------------------
 // Report warning to the log stream
-/*static*/ void MD5Parser::ReportWarning (const char* warn, unsigned int line)
-{
+/*static*/ void MD5Parser::ReportWarning(const char *warn, unsigned int line) {
     char szBuffer[1024];
-    ::sprintf(szBuffer,"[MD5] Line %u: %s",line,warn);
+    ::sprintf(szBuffer, "[MD5] Line %u: %s", line, warn);
     ASSIMP_LOG_WARN(szBuffer);
 }
 
 // ------------------------------------------------------------------------------------------------
 // Parse and validate the MD5 header
-void MD5Parser::ParseHeader()
-{
+void MD5Parser::ParseHeader() {
     // parse and validate the file version
     SkipSpaces();
-    if (!TokenMatch(buffer,"MD5Version",10))    {
+    if (!TokenMatch(buffer, "MD5Version", 10)) {
         ReportError("Invalid MD5 file: MD5Version tag has not been found");
     }
     SkipSpaces();
-    unsigned int iVer = ::strtoul10(buffer,(const char**)&buffer);
+    unsigned int iVer = ::strtoul10(buffer, (const char **)&buffer);
     if (10 != iVer) {
         ReportError("MD5 version tag is unknown (10 is expected)");
     }
@@ -127,23 +123,24 @@ void MD5Parser::ParseHeader()
 
     // print the command line options to the console
     // FIX: can break the log length limit, so we need to be careful
-    char* sz = buffer;
-    while (!IsLineEnd( *buffer++));
-    ASSIMP_LOG_INFO(std::string(sz,std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer-sz))));
+    char *sz = buffer;
+    while (!IsLineEnd(*buffer++))
+        ;
+    ASSIMP_LOG_INFO(std::string(sz, std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer - sz))));
     SkipSpacesAndLineEnd();
 }
 
 // ------------------------------------------------------------------------------------------------
 // Recursive MD5 parsing function
-bool MD5Parser::ParseSection(Section& out)
-{
+bool MD5Parser::ParseSection(Section &out) {
     // store the current line number for use in error messages
     out.iLineNumber = lineNumber;
 
     // first parse the name of the section
-    char* sz = buffer;
-    while (!IsSpaceOrNewLine( *buffer))buffer++;
-    out.mName = std::string(sz,(uintptr_t)(buffer-sz));
+    char *sz = buffer;
+    while (!IsSpaceOrNewLine(*buffer))
+        buffer++;
+    out.mName = std::string(sz, (uintptr_t)(buffer - sz));
     SkipSpaces();
 
     bool running = true;
@@ -152,8 +149,7 @@ bool MD5Parser::ParseSection(Section& out)
             // it is a normal section so read all lines
             buffer++;
             bool run = true;
-            while (run)
-            {
+            while (run) {
                 if (!SkipSpacesAndLineEnd()) {
                     return false; // seems this was the last section
                 }
@@ -163,25 +159,26 @@ bool MD5Parser::ParseSection(Section& out)
                 }
 
                 out.mElements.push_back(Element());
-                Element& elem = out.mElements.back();
+                Element &elem = out.mElements.back();
 
                 elem.iLineNumber = lineNumber;
                 elem.szStart = buffer;
 
                 // terminate the line with zero
-                while (!IsLineEnd( *buffer))buffer++;
+                while (!IsLineEnd(*buffer))
+                    buffer++;
                 if (*buffer) {
                     ++lineNumber;
                     *buffer++ = '\0';
                 }
             }
             break;
-        }
-        else if (!IsSpaceOrNewLine(*buffer))    {
+        } else if (!IsSpaceOrNewLine(*buffer)) {
             // it is an element at global scope. Parse its value and go on
             sz = buffer;
-            while (!IsSpaceOrNewLine( *buffer++));
-            out.mGlobalValue = std::string(sz,(uintptr_t)(buffer-sz));
+            while (!IsSpaceOrNewLine(*buffer++))
+                ;
+            out.mGlobalValue = std::string(sz, (uintptr_t)(buffer - sz));
             continue;
         }
         break;
@@ -193,161 +190,161 @@ bool MD5Parser::ParseSection(Section& out)
 // Some dirty macros just because they're so funny and easy to debug
 
 // skip all spaces ... handle EOL correctly
-#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)
-#define AI_MD5_READ_TRIPLE(vec) \
-    AI_MD5_SKIP_SPACES(); \
-    if ('(' != *sz++) \
-        MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber); \
-    AI_MD5_SKIP_SPACES(); \
-    sz = fast_atoreal_move<float>(sz,(float&)vec.x); \
-    AI_MD5_SKIP_SPACES(); \
-    sz = fast_atoreal_move<float>(sz,(float&)vec.y); \
-    AI_MD5_SKIP_SPACES(); \
-    sz = fast_atoreal_move<float>(sz,(float&)vec.z); \
-    AI_MD5_SKIP_SPACES(); \
-    if (')' != *sz++) \
-        MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber);
-
-	// parse a string, enclosed in quotation marks or not
-#define AI_MD5_PARSE_STRING(out) \
-    bool bQuota = (*sz == '\"'); \
-    const char* szStart = sz; \
-    while (!IsSpaceOrNewLine(*sz))++sz; \
-    const char* szEnd = sz; \
-    if (bQuota) { \
-        szStart++; \
-        if ('\"' != *(szEnd-=1)) { \
+#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)
+#define AI_MD5_READ_TRIPLE(vec)                                                         \
+    AI_MD5_SKIP_SPACES();                                                               \
+    if ('(' != *sz++)                                                                   \
+        MD5Parser::ReportWarning("Unexpected token: ( was expected", elem.iLineNumber); \
+    AI_MD5_SKIP_SPACES();                                                               \
+    sz = fast_atoreal_move<float>(sz, (float &)vec.x);                                  \
+    AI_MD5_SKIP_SPACES();                                                               \
+    sz = fast_atoreal_move<float>(sz, (float &)vec.y);                                  \
+    AI_MD5_SKIP_SPACES();                                                               \
+    sz = fast_atoreal_move<float>(sz, (float &)vec.z);                                  \
+    AI_MD5_SKIP_SPACES();                                                               \
+    if (')' != *sz++)                                                                   \
+        MD5Parser::ReportWarning("Unexpected token: ) was expected", elem.iLineNumber);
+
+// parse a string, enclosed in quotation marks or not
+#define AI_MD5_PARSE_STRING(out)                                                   \
+    bool bQuota = (*sz == '\"');                                                   \
+    const char *szStart = sz;                                                      \
+    while (!IsSpaceOrNewLine(*sz))                                                 \
+        ++sz;                                                                      \
+    const char *szEnd = sz;                                                        \
+    if (bQuota) {                                                                  \
+        szStart++;                                                                 \
+        if ('\"' != *(szEnd -= 1)) {                                               \
             MD5Parser::ReportWarning("Expected closing quotation marks in string", \
-                elem.iLineNumber); \
-            continue; \
-        } \
-    } \
-    out.length = (size_t)(szEnd - szStart); \
-    ::memcpy(out.data,szStart,out.length); \
+                    elem.iLineNumber);                                             \
+            continue;                                                              \
+        }                                                                          \
+    }                                                                              \
+    out.length = (size_t)(szEnd - szStart);                                        \
+    ::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 = (ai_uint32) (szEnd - szStart); \
-    ::memcpy(out.data,szStart,out.length); \
+// 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 = (ai_uint32)(szEnd - szStart); \
+    ::memcpy(out.data, szStart, out.length);   \
     out.data[out.length] = '\0';
 // ------------------------------------------------------------------------------------------------
 // .MD5MESH parsing function
-MD5MeshParser::MD5MeshParser(SectionList& mSections)
-{
+MD5MeshParser::MD5MeshParser(SectionList &mSections) {
     ASSIMP_LOG_DEBUG("MD5MeshParser begin");
 
     // now parse all sections
-    for (SectionList::const_iterator iter =  mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter){
-        if ( (*iter).mName == "numMeshes")  {
+    for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
+        if ((*iter).mName == "numMeshes") {
             mMeshes.reserve(::strtoul10((*iter).mGlobalValue.c_str()));
-        }
-        else if ( (*iter).mName == "numJoints") {
+        } else if ((*iter).mName == "numJoints") {
             mJoints.reserve(::strtoul10((*iter).mGlobalValue.c_str()));
-        }
-        else if ((*iter).mName == "joints") {
+        } else if ((*iter).mName == "joints") {
             // "origin" -1 ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000000 0.707107 )
-            for (const auto & elem : (*iter).mElements){
+            for (const auto &elem : (*iter).mElements) {
                 mJoints.push_back(BoneDesc());
-                BoneDesc& desc = mJoints.back();
-				
-                const char* sz = elem.szStart;
-				AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
+                BoneDesc &desc = mJoints.back();
+
+                const char *sz = elem.szStart;
+                AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
                 AI_MD5_SKIP_SPACES();
 
                 // negative values, at least -1, is allowed here
-                desc.mParentIndex = (int)strtol10(sz,&sz);
+                desc.mParentIndex = (int)strtol10(sz, &sz);
 
                 AI_MD5_READ_TRIPLE(desc.mPositionXYZ);
                 AI_MD5_READ_TRIPLE(desc.mRotationQuat); // normalized quaternion, so w is not there
             }
-        }
-        else if ((*iter).mName == "mesh")   {
+        } else if ((*iter).mName == "mesh") {
             mMeshes.push_back(MeshDesc());
-            MeshDesc& desc = mMeshes.back();
+            MeshDesc &desc = mMeshes.back();
 
-            for (const auto & elem : (*iter).mElements){
-                const char* sz = elem.szStart;
+            for (const auto &elem : (*iter).mElements) {
+                const char *sz = elem.szStart;
 
                 // shader attribute
-                if (TokenMatch(sz,"shader",6))  {
+                if (TokenMatch(sz, "shader", 6)) {
                     AI_MD5_SKIP_SPACES();
                     AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mShader);
                 }
                 // numverts attribute
-                else if (TokenMatch(sz,"numverts",8))   {
+                else if (TokenMatch(sz, "numverts", 8)) {
                     AI_MD5_SKIP_SPACES();
                     desc.mVertices.resize(strtoul10(sz));
                 }
                 // numtris attribute
-                else if (TokenMatch(sz,"numtris",7))    {
+                else if (TokenMatch(sz, "numtris", 7)) {
                     AI_MD5_SKIP_SPACES();
                     desc.mFaces.resize(strtoul10(sz));
                 }
                 // numweights attribute
-                else if (TokenMatch(sz,"numweights",10))    {
+                else if (TokenMatch(sz, "numweights", 10)) {
                     AI_MD5_SKIP_SPACES();
                     desc.mWeights.resize(strtoul10(sz));
                 }
                 // vert attribute
                 // "vert 0 ( 0.394531 0.513672 ) 0 1"
-                else if (TokenMatch(sz,"vert",4))   {
+                else if (TokenMatch(sz, "vert", 4)) {
                     AI_MD5_SKIP_SPACES();
-                    const unsigned int idx = ::strtoul10(sz,&sz);
+                    const unsigned int idx = ::strtoul10(sz, &sz);
                     AI_MD5_SKIP_SPACES();
                     if (idx >= desc.mVertices.size())
-                        desc.mVertices.resize(idx+1);
+                        desc.mVertices.resize(idx + 1);
 
-                    VertexDesc& vert = desc.mVertices[idx];
+                    VertexDesc &vert = desc.mVertices[idx];
                     if ('(' != *sz++)
-                        MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber);
+                        MD5Parser::ReportWarning("Unexpected token: ( was expected", elem.iLineNumber);
                     AI_MD5_SKIP_SPACES();
-                    sz = fast_atoreal_move<float>(sz,(float&)vert.mUV.x);
+                    sz = fast_atoreal_move<float>(sz, (float &)vert.mUV.x);
                     AI_MD5_SKIP_SPACES();
-                    sz = fast_atoreal_move<float>(sz,(float&)vert.mUV.y);
+                    sz = fast_atoreal_move<float>(sz, (float &)vert.mUV.y);
                     AI_MD5_SKIP_SPACES();
                     if (')' != *sz++)
-                        MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber);
+                        MD5Parser::ReportWarning("Unexpected token: ) was expected", elem.iLineNumber);
                     AI_MD5_SKIP_SPACES();
-                    vert.mFirstWeight = ::strtoul10(sz,&sz);
+                    vert.mFirstWeight = ::strtoul10(sz, &sz);
                     AI_MD5_SKIP_SPACES();
-                    vert.mNumWeights = ::strtoul10(sz,&sz);
+                    vert.mNumWeights = ::strtoul10(sz, &sz);
                 }
                 // tri attribute
                 // "tri 0 15 13 12"
-                else if (TokenMatch(sz,"tri",3)) {
+                else if (TokenMatch(sz, "tri", 3)) {
                     AI_MD5_SKIP_SPACES();
-                    const unsigned int idx = strtoul10(sz,&sz);
+                    const unsigned int idx = strtoul10(sz, &sz);
                     if (idx >= desc.mFaces.size())
-                        desc.mFaces.resize(idx+1);
+                        desc.mFaces.resize(idx + 1);
 
-                    aiFace& face = desc.mFaces[idx];
+                    aiFace &face = desc.mFaces[idx];
                     face.mIndices = new unsigned int[face.mNumIndices = 3];
-                    for (unsigned int i = 0; i < 3;++i) {
+                    for (unsigned int i = 0; i < 3; ++i) {
                         AI_MD5_SKIP_SPACES();
-                        face.mIndices[i] = strtoul10(sz,&sz);
+                        face.mIndices[i] = strtoul10(sz, &sz);
                     }
                 }
                 // weight attribute
                 // "weight 362 5 0.500000 ( -3.553583 11.893474 9.719339 )"
-                else if (TokenMatch(sz,"weight",6)) {
+                else if (TokenMatch(sz, "weight", 6)) {
                     AI_MD5_SKIP_SPACES();
-                    const unsigned int idx = strtoul10(sz,&sz);
+                    const unsigned int idx = strtoul10(sz, &sz);
                     AI_MD5_SKIP_SPACES();
                     if (idx >= desc.mWeights.size())
-                        desc.mWeights.resize(idx+1);
+                        desc.mWeights.resize(idx + 1);
 
-                    WeightDesc& weight = desc.mWeights[idx];
-                    weight.mBone = strtoul10(sz,&sz);
+                    WeightDesc &weight = desc.mWeights[idx];
+                    weight.mBone = strtoul10(sz, &sz);
                     AI_MD5_SKIP_SPACES();
-                    sz = fast_atoreal_move<float>(sz,weight.mWeight);
+                    sz = fast_atoreal_move<float>(sz, weight.mWeight);
                     AI_MD5_READ_TRIPLE(weight.vOffsetPosition);
                 }
             }
@@ -358,57 +355,54 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
 
 // ------------------------------------------------------------------------------------------------
 // .MD5ANIM parsing function
-MD5AnimParser::MD5AnimParser(SectionList& mSections)
-{
+MD5AnimParser::MD5AnimParser(SectionList &mSections) {
     ASSIMP_LOG_DEBUG("MD5AnimParser begin");
 
     fFrameRate = 24.0f;
     mNumAnimatedComponents = UINT_MAX;
-    for (SectionList::const_iterator iter =  mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) {
-        if ((*iter).mName == "hierarchy")   {
+    for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
+        if ((*iter).mName == "hierarchy") {
             // "sheath" 0 63 6
-            for (const auto & elem : (*iter).mElements) {
-                mAnimatedBones.push_back ( AnimBoneDesc () );
-                AnimBoneDesc& desc = mAnimatedBones.back();
+            for (const auto &elem : (*iter).mElements) {
+                mAnimatedBones.push_back(AnimBoneDesc());
+                AnimBoneDesc &desc = mAnimatedBones.back();
 
-                const char* sz = elem.szStart;
+                const char *sz = elem.szStart;
                 AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
                 AI_MD5_SKIP_SPACES();
 
                 // parent index - negative values are allowed (at least -1)
-                desc.mParentIndex = ::strtol10(sz,&sz);
+                desc.mParentIndex = ::strtol10(sz, &sz);
 
                 // flags (highest is 2^6-1)
                 AI_MD5_SKIP_SPACES();
-                if(63 < (desc.iFlags = ::strtoul10(sz,&sz))){
-                    MD5Parser::ReportWarning("Invalid flag combination in hierarchy section",elem.iLineNumber);
+                if (63 < (desc.iFlags = ::strtoul10(sz, &sz))) {
+                    MD5Parser::ReportWarning("Invalid flag combination in hierarchy section", elem.iLineNumber);
                 }
                 AI_MD5_SKIP_SPACES();
 
                 // index of the first animation keyframe component for this joint
-                desc.iFirstKeyIndex = ::strtoul10(sz,&sz);
+                desc.iFirstKeyIndex = ::strtoul10(sz, &sz);
             }
-        }
-        else if((*iter).mName == "baseframe")   {
+        } else if ((*iter).mName == "baseframe") {
             // ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000242 0.707107 )
-            for (const auto & elem : (*iter).mElements) {
-                const char* sz = elem.szStart;
+            for (const auto &elem : (*iter).mElements) {
+                const char *sz = elem.szStart;
 
-                mBaseFrames.push_back ( BaseFrameDesc () );
-                BaseFrameDesc& desc = mBaseFrames.back();
+                mBaseFrames.push_back(BaseFrameDesc());
+                BaseFrameDesc &desc = mBaseFrames.back();
 
                 AI_MD5_READ_TRIPLE(desc.vPositionXYZ);
                 AI_MD5_READ_TRIPLE(desc.vRotationQuat);
             }
-        }
-        else if((*iter).mName ==  "frame")  {
+        } else if ((*iter).mName == "frame") {
             if (!(*iter).mGlobalValue.length()) {
-                MD5Parser::ReportWarning("A frame section must have a frame index",(*iter).iLineNumber);
+                MD5Parser::ReportWarning("A frame section must have a frame index", (*iter).iLineNumber);
                 continue;
             }
 
-            mFrames.push_back ( FrameDesc () );
-            FrameDesc& desc = mFrames.back();
+            mFrames.push_back(FrameDesc());
+            FrameDesc &desc = mFrames.back();
             desc.iIndex = strtoul10((*iter).mGlobalValue.c_str());
 
             // we do already know how much storage we will presumably need
@@ -417,31 +411,28 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
             }
 
             // now read all elements (continuous list of floats)
-            for (const auto & elem : (*iter).mElements){
-                const char* sz = elem.szStart;
-                while (SkipSpacesAndLineEnd(&sz))   {
-                    float f;sz = fast_atoreal_move<float>(sz,f);
+            for (const auto &elem : (*iter).mElements) {
+                const char *sz = elem.szStart;
+                while (SkipSpacesAndLineEnd(&sz)) {
+                    float f;
+                    sz = fast_atoreal_move<float>(sz, f);
                     desc.mValues.push_back(f);
                 }
             }
-        }
-        else if((*iter).mName == "numFrames")   {
+        } else if ((*iter).mName == "numFrames") {
             mFrames.reserve(strtoul10((*iter).mGlobalValue.c_str()));
-        }
-        else if((*iter).mName == "numJoints")   {
+        } else if ((*iter).mName == "numJoints") {
             const unsigned int num = strtoul10((*iter).mGlobalValue.c_str());
             mAnimatedBones.reserve(num);
 
             // try to guess the number of animated components if that element is not given
-            if (UINT_MAX  == mNumAnimatedComponents) {
+            if (UINT_MAX == mNumAnimatedComponents) {
                 mNumAnimatedComponents = num * 6;
             }
-        }
-        else if((*iter).mName == "numAnimatedComponents")   {
-            mAnimatedBones.reserve( strtoul10((*iter).mGlobalValue.c_str()));
-        }
-        else if((*iter).mName == "frameRate")   {
-            fast_atoreal_move<float>((*iter).mGlobalValue.c_str(),fFrameRate);
+        } else if ((*iter).mName == "numAnimatedComponents") {
+            mAnimatedBones.reserve(strtoul10((*iter).mGlobalValue.c_str()));
+        } else if ((*iter).mName == "frameRate") {
+            fast_atoreal_move<float>((*iter).mGlobalValue.c_str(), fFrameRate);
         }
     }
     ASSIMP_LOG_DEBUG("MD5AnimParser end");
@@ -449,32 +440,27 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
 
 // ------------------------------------------------------------------------------------------------
 // .MD5CAMERA parsing function
-MD5CameraParser::MD5CameraParser(SectionList& mSections)
-{
+MD5CameraParser::MD5CameraParser(SectionList &mSections) {
     ASSIMP_LOG_DEBUG("MD5CameraParser begin");
     fFrameRate = 24.0f;
 
-    for (SectionList::const_iterator iter =  mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) {
-        if ((*iter).mName == "numFrames")   {
+    for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
+        if ((*iter).mName == "numFrames") {
             frames.reserve(strtoul10((*iter).mGlobalValue.c_str()));
-        }
-        else if ((*iter).mName == "frameRate")  {
-            fFrameRate = fast_atof ((*iter).mGlobalValue.c_str());
-        }
-        else if ((*iter).mName == "numCuts")    {
+        } else if ((*iter).mName == "frameRate") {
+            fFrameRate = fast_atof((*iter).mGlobalValue.c_str());
+        } else if ((*iter).mName == "numCuts") {
             cuts.reserve(strtoul10((*iter).mGlobalValue.c_str()));
-        }
-        else if ((*iter).mName == "cuts")   {
-            for (const auto & elem : (*iter).mElements){
-                cuts.push_back(strtoul10(elem.szStart)+1);
+        } else if ((*iter).mName == "cuts") {
+            for (const auto &elem : (*iter).mElements) {
+                cuts.push_back(strtoul10(elem.szStart) + 1);
             }
-        }
-        else if ((*iter).mName == "camera") {
-            for (const auto & elem : (*iter).mElements){
-                const char* sz = elem.szStart;
+        } else if ((*iter).mName == "camera") {
+            for (const auto &elem : (*iter).mElements) {
+                const char *sz = elem.szStart;
 
                 frames.push_back(CameraAnimFrameDesc());
-                CameraAnimFrameDesc& cur = frames.back();
+                CameraAnimFrameDesc &cur = frames.back();
                 AI_MD5_READ_TRIPLE(cur.vPositionXYZ);
                 AI_MD5_READ_TRIPLE(cur.vRotationQuat);
                 AI_MD5_SKIP_SPACES();
@@ -484,4 +470,3 @@ MD5CameraParser::MD5CameraParser(SectionList& mSections)
     }
     ASSIMP_LOG_DEBUG("MD5CameraParser end");
 }
-

+ 4 - 4
code/AssetLib/MDC/MDCLoader.cpp

@@ -267,7 +267,7 @@ void MDCImporter::InternReadFile(
 
     // necessary that we don't crash if an exception occurs
     for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
-        pScene->mMeshes[i] = NULL;
+        pScene->mMeshes[i] = nullptr;
     }
 
     // now read all surfaces
@@ -347,8 +347,8 @@ void MDCImporter::InternReadFile(
 
 #endif
 
-        const MDC::CompressedVertex *pcCVerts = NULL;
-        int16_t *mdcCompVert = NULL;
+        const MDC::CompressedVertex *pcCVerts = nullptr;
+        int16_t *mdcCompVert = nullptr;
 
         // access compressed frames for large frame numbers, but never for the first
         if (this->configFrameID && pcSurface->ulNumCompFrames > 0) {
@@ -359,7 +359,7 @@ void MDCImporter::InternReadFile(
                                                            pcSurface->ulOffsetCompVerts) +
                            *mdcCompVert * pcSurface->ulNumVertices;
             } else
-                mdcCompVert = NULL;
+                mdcCompVert = nullptr;
         }
 
         // copy all faces

+ 4 - 2
code/AssetLib/MDL/HalfLife/HL1MDLLoader.h

@@ -222,12 +222,14 @@ void HL1MDLLoader::load_file_into_buffer(const std::string &file_path, unsigned
 
     std::unique_ptr<IOStream> file(io_->Open(file_path));
 
-    if (file.get() == NULL)
+    if (file.get() == nullptr) {
         throw DeadlyImportError("Failed to open MDL file " + DefaultIOSystem::fileName(file_path) + ".");
+    }
 
     const size_t file_size = file->FileSize();
-    if (file_size < sizeof(MDLFileHeader))
+    if (file_size < sizeof(MDLFileHeader)) {
         throw DeadlyImportError("MDL file is too small.");
+    }
 
     buffer = new unsigned char[1 + file_size];
     file->Read((void *)buffer, 1, file_size);

+ 23 - 20
code/AssetLib/MDL/MDLLoader.cpp

@@ -278,7 +278,7 @@ void MDLImporter::SizeCheck(const void *szPos) {
 // ------------------------------------------------------------------------------------------------
 // Just for debugging purposes
 void MDLImporter::SizeCheck(const void *szPos, const char *szFile, unsigned int iLine) {
-    ai_assert(NULL != szFile);
+    ai_assert(nullptr != szFile);
     if (!szPos || (const unsigned char *)szPos > mBuffer + iFileSize) {
         // remove a directory if there is one
         const char *szFilePtr = ::strrchr(szFile, '\\');
@@ -304,7 +304,7 @@ void MDLImporter::SizeCheck(const void *szPos, const char *szFile, unsigned int
 // ------------------------------------------------------------------------------------------------
 // Validate a quake file header
 void MDLImporter::ValidateHeader_Quake1(const MDL::Header *pcHeader) {
-    // some values may not be NULL
+    // some values may not be nullptr
     if (!pcHeader->num_frames)
         throw DeadlyImportError("[Quake 1 MDL] There are no frames in the file");
 
@@ -359,7 +359,7 @@ void FlipQuakeHeader(BE_NCONST MDL::Header *pcHeader) {
 // ------------------------------------------------------------------------------------------------
 // Read a Quake 1 file
 void MDLImporter::InternReadFile_Quake1() {
-    ai_assert(NULL != pScene);
+    ai_assert(nullptr != pScene);
 
     BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header *)this->mBuffer;
 
@@ -548,7 +548,7 @@ void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1() {
             delete pScene->mTextures[0];
             delete[] pScene->mTextures;
 
-            pScene->mTextures = NULL;
+            pScene->mTextures = nullptr;
             pScene->mNumTextures = 0;
         } else {
             clr.b = clr.a = clr.g = clr.r = 1.0f;
@@ -572,7 +572,7 @@ void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1() {
 // ------------------------------------------------------------------------------------------------
 // Read a MDL 3,4,5 file
 void MDLImporter::InternReadFile_3DGS_MDL345() {
-    ai_assert(NULL != pScene);
+    ai_assert(nullptr != pScene);
 
     // the header of MDL 3/4/5 is nearly identical to the original Quake1 header
     BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header *)this->mBuffer;
@@ -791,7 +791,7 @@ void MDLImporter::ImportUVCoordinate_3DGS_MDL345(
         aiVector3D &vOut,
         const MDL::TexCoord_MDL3 *pcSrc,
         unsigned int iIndex) {
-    ai_assert(NULL != pcSrc);
+    ai_assert(nullptr != pcSrc);
     const MDL::Header *const pcHeader = (const MDL::Header *)this->mBuffer;
 
     // validate UV indices
@@ -860,7 +860,7 @@ void MDLImporter::CalculateUVCoordinates_MDL5() {
 // ------------------------------------------------------------------------------------------------
 // Validate the header of a MDL7 file
 void MDLImporter::ValidateHeader_3DGS_MDL7(const MDL::Header_MDL7 *pcHeader) {
-    ai_assert(NULL != pcHeader);
+    ai_assert(nullptr != pcHeader);
 
     // There are some fixed sizes ...
     if (sizeof(MDL::ColorValue_MDL7) != pcHeader->colorvalue_stc_size) {
@@ -887,7 +887,7 @@ void MDLImporter::ValidateHeader_3DGS_MDL7(const MDL::Header_MDL7 *pcHeader) {
 void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7 **apcOutBones) {
     const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
     const MDL::Bone_MDL7 *pcBones = (const MDL::Bone_MDL7 *)(pcHeader + 1);
-    ai_assert(NULL != apcOutBones);
+    ai_assert(nullptr != apcOutBones);
 
     // first find the bone that has NO parent, calculate the
     // animation matrix for it, then go on and search for the next parent
@@ -979,7 +979,7 @@ MDL::IntBone_MDL7 **MDLImporter::LoadBones_3DGS_MDL7() {
                 AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS != pcHeader->bone_stc_size &&
                 AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE != pcHeader->bone_stc_size) {
             ASSIMP_LOG_WARN("Unknown size of bone data structure");
-            return NULL;
+            return nullptr;
         }
 
         MDL::IntBone_MDL7 **apcBonesOut = new MDL::IntBone_MDL7 *[pcHeader->bones_num];
@@ -990,7 +990,7 @@ MDL::IntBone_MDL7 **MDLImporter::LoadBones_3DGS_MDL7() {
         CalcAbsBoneMatrices_3DGS_MDL7(apcBonesOut);
         return apcBonesOut;
     }
-    return NULL;
+    return nullptr;
 }
 
 // ------------------------------------------------------------------------------------------------
@@ -1014,7 +1014,7 @@ void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7 &groupInfo,
             unsigned int iIndex = pcGroupTris->v_index[c];
             if (iIndex > (unsigned int)groupInfo.pcGroup->numverts) {
                 // (we might need to read this section a second time - to process frame vertices correctly)
-                pcGroupTris->v_index[c] = (uint16_t) (iIndex = groupInfo.pcGroup->numverts - 1 );
+                pcGroupTris->v_index[c] = (uint16_t)(iIndex = groupInfo.pcGroup->numverts - 1);
                 ASSIMP_LOG_WARN("Index overflow in MDL7 vertex list");
             }
 
@@ -1337,7 +1337,7 @@ void MDLImporter::SortByMaterials_3DGS_MDL7(
 // ------------------------------------------------------------------------------------------------
 // Read a MDL7 file
 void MDLImporter::InternReadFile_3DGS_MDL7() {
-    ai_assert(NULL != pScene);
+    ai_assert(nullptr != pScene);
 
     MDL::IntSharedData_MDL7 sharedData;
 
@@ -1368,7 +1368,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7() {
 
     // load all bones (they are shared by all groups, so
     // we'll need to add them to all groups/meshes later)
-    // apcBonesOut is a list of all bones or NULL if they could not been loaded
+    // apcBonesOut is a list of all bones or nullptr if they could not been loaded
     szCurrent += pcHeader->bones_num * pcHeader->bone_stc_size;
     sharedData.apcOutBones = this->LoadBones_3DGS_MDL7();
 
@@ -1558,9 +1558,9 @@ void MDLImporter::InternReadFile_3DGS_MDL7() {
     if (1 == pScene->mRootNode->mNumChildren && !sharedData.apcOutBones) {
         aiNode *pcOldRoot = this->pScene->mRootNode;
         pScene->mRootNode = pcOldRoot->mChildren[0];
-        pcOldRoot->mChildren[0] = NULL;
+        pcOldRoot->mChildren[0] = nullptr;
         delete pcOldRoot;
-        pScene->mRootNode->mParent = NULL;
+        pScene->mRootNode->mParent = nullptr;
     } else
         pScene->mRootNode->mName.Set("<mesh_root>");
 
@@ -1665,7 +1665,8 @@ void MDLImporter::ParseBoneTrafoKeys_3DGS_MDL7(
 // Attach bones to the output nodegraph
 void MDLImporter::AddBonesToNodeGraph_3DGS_MDL7(const MDL::IntBone_MDL7 **apcBones,
         aiNode *pcParent, uint16_t iParentIndex) {
-    ai_assert(NULL != apcBones && NULL != pcParent);
+    ai_assert(nullptr != apcBones);
+    ai_assert(nullptr != pcParent);
 
     // get a pointer to the header ...
     const MDL::Header_MDL7 *const pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
@@ -1696,7 +1697,7 @@ void MDLImporter::AddBonesToNodeGraph_3DGS_MDL7(const MDL::IntBone_MDL7 **apcBon
 // Build output animations
 void MDLImporter::BuildOutputAnims_3DGS_MDL7(
         const MDL::IntBone_MDL7 **apcBonesOut) {
-    ai_assert(NULL != apcBonesOut);
+    ai_assert(nullptr != apcBonesOut);
     const MDL::Header_MDL7 *const pcHeader = (const MDL::Header_MDL7 *)mBuffer;
 
     // one animation ...
@@ -1755,8 +1756,8 @@ void MDLImporter::BuildOutputAnims_3DGS_MDL7(
 void MDLImporter::AddAnimationBoneTrafoKey_3DGS_MDL7(unsigned int iTrafo,
         const MDL::BoneTransform_MDL7 *pcBoneTransforms,
         MDL::IntBone_MDL7 **apcBonesOut) {
-    ai_assert(NULL != pcBoneTransforms);
-    ai_assert(NULL != apcBonesOut);
+    ai_assert(nullptr != pcBoneTransforms);
+    ai_assert(nullptr != apcBonesOut);
 
     // first .. get the transformation matrix
     aiMatrix4x4 mTransform;
@@ -1920,7 +1921,9 @@ void MDLImporter::JoinSkins_3DGS_MDL7(
         aiMaterial *pcMat1,
         aiMaterial *pcMat2,
         aiMaterial *pcMatOut) {
-    ai_assert(NULL != pcMat1 && NULL != pcMat2 && NULL != pcMatOut);
+    ai_assert(nullptr != pcMat1);
+    ai_assert(nullptr != pcMat2);
+    ai_assert(nullptr != pcMatOut);
 
     // first create a full copy of the first skin property set
     // and assign it to the output material

+ 1 - 1
code/AssetLib/MDL/MDLLoader.h

@@ -320,7 +320,7 @@ protected:
     /** Load the bone list of a MDL7 file
      * \return If the bones could be loaded successfully, a valid
      *   array containing pointers to a temporary bone
-     *   representation. NULL if the bones could not be loaded.
+     *   representation. nullptr if the bones could not be loaded.
      */
     MDL::IntBone_MDL7** LoadBones_3DGS_MDL7();
 

+ 2 - 2
code/AssetLib/MDL/MDLMaterialLoader.cpp

@@ -364,7 +364,7 @@ void MDLImporter::ParseTextureColorData(const unsigned char *szData,
 void MDLImporter::CreateTexture_3DGS_MDL5(const unsigned char *szData,
         unsigned int iType,
         unsigned int *piSkip) {
-    ai_assert(NULL != piSkip);
+    ai_assert(nullptr != piSkip);
     bool bNoRead = *piSkip == UINT_MAX;
 
     // allocate a new texture object
@@ -428,7 +428,7 @@ void MDLImporter::CreateTexture_3DGS_MDL5(const unsigned char *szData,
             delete[] pc;
         }
     } else {
-        pcNew->pcData = NULL;
+        pcNew->pcData = nullptr;
         delete pcNew;
     }
     return;

+ 1 - 1
code/AssetLib/MMD/MMDImporter.cpp

@@ -134,7 +134,7 @@ void MMDImporter::InternReadFile(const std::string &file, aiScene *pScene,
 // ------------------------------------------------------------------------------------------------
 void MMDImporter::CreateDataFromImport(const pmx::PmxModel *pModel,
         aiScene *pScene) {
-    if (pModel == NULL) {
+    if (pModel == nullptr) {
         return;
     }
 

+ 1 - 1
code/AssetLib/MMD/MMDPmdParser.h

@@ -131,7 +131,7 @@ namespace pmd
 			stream->read((char*) &index_count, sizeof(uint32_t));
 			stream->read((char*) &buffer, sizeof(char) * 20);
 			char* pstar = strchr(buffer, '*');
-			if (NULL == pstar)
+            if (nullptr == pstar)
 			{
 				texture_filename = std::string(buffer);
 				sphere_filename.clear();

+ 1 - 1
code/AssetLib/MS3D/MS3DLoader.cpp

@@ -657,7 +657,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile,
         }
         // fixup to pass the validation if not a single animation channel is non-trivial
         if (!anim->mNumChannels) {
-            anim->mChannels = NULL;
+            anim->mChannels = nullptr;
         }
     }
 }

+ 12 - 12
code/AssetLib/NFF/NFFLoader.cpp

@@ -154,7 +154,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector<ShadingInfo> &output,
         return;
     }
 
-    ShadingInfo *curShader = NULL;
+    ShadingInfo *curShader = nullptr;
 
     // No read the file line per line
     char line[4096];
@@ -238,9 +238,9 @@ void NFFImporter::InternReadFile(const std::string &pFile,
 
     bool hasCam = false;
 
-    MeshInfo *currentMeshWithNormals = NULL;
-    MeshInfo *currentMesh = NULL;
-    MeshInfo *currentMeshWithUVCoords = NULL;
+    MeshInfo *currentMeshWithNormals = nullptr;
+    MeshInfo *currentMesh = nullptr;
+    MeshInfo *currentMeshWithUVCoords = nullptr;
 
     ShadingInfo s; // current material info
 
@@ -542,7 +542,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
                     // search the list of all shaders we have for this object whether
                     // there is an identical one. In this case, we append our mesh
                     // data to it.
-                    MeshInfo *mesh = NULL;
+                    MeshInfo *mesh = nullptr;
                     for (std::vector<MeshInfo>::iterator it = meshes.begin() + objStart, end = meshes.end();
                             it != end; ++it) {
                         if ((*it).shader == shader && (*it).matIndex == matIdx) {
@@ -603,11 +603,11 @@ void NFFImporter::InternReadFile(const std::string &pFile,
         while (GetNextLine(buffer, line)) {
             sz = line;
             if ('p' == line[0] || TokenMatch(sz, "tpp", 3)) {
-                MeshInfo *out = NULL;
+                MeshInfo *out = nullptr;
 
                 // 'tpp' - texture polygon patch primitive
                 if ('t' == line[0]) {
-                    currentMeshWithUVCoords = NULL;
+                    currentMeshWithUVCoords = nullptr;
                     for (auto &mesh : meshesWithUVCoords) {
                         if (mesh.shader == s) {
                             currentMeshWithUVCoords = &mesh;
@@ -624,7 +624,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
                 }
                 // 'pp' - polygon patch primitive
                 else if ('p' == line[1]) {
-                    currentMeshWithNormals = NULL;
+                    currentMeshWithNormals = nullptr;
                     for (auto &mesh : meshesWithNormals) {
                         if (mesh.shader == s) {
                             currentMeshWithNormals = &mesh;
@@ -642,7 +642,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
                 }
                 // 'p' - polygon primitive
                 else {
-                    currentMesh = NULL;
+                    currentMesh = nullptr;
                     for (auto &mesh : meshes) {
                         if (mesh.shader == s) {
                             currentMesh = &mesh;
@@ -969,8 +969,8 @@ void NFFImporter::InternReadFile(const std::string &pFile,
     root->mNumChildren = numNamed + (hasCam ? 1 : 0) + (unsigned int)lights.size();
     root->mNumMeshes = pScene->mNumMeshes - numNamed;
 
-    aiNode **ppcChildren = NULL;
-    unsigned int *pMeshes = NULL;
+    aiNode **ppcChildren = nullptr;
+    unsigned int *pMeshes = nullptr;
     if (root->mNumMeshes)
         pMeshes = root->mMeshes = new unsigned int[root->mNumMeshes];
     if (root->mNumChildren)
@@ -1037,7 +1037,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
         mesh->mNumFaces = (unsigned int)src.faces.size();
 
         // Generate sub nodes for named meshes
-        if (src.name[0] && NULL != ppcChildren) {
+        if (src.name[0] && nullptr != ppcChildren) {
             aiNode *const node = *ppcChildren = new aiNode();
             node->mParent = root;
             node->mNumMeshes = 1;

+ 3 - 3
code/AssetLib/Obj/ObjExporter.cpp

@@ -70,14 +70,14 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
     // we're still here - export successfully completed. Write both the main OBJ file and the material script
     {
         std::unique_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
-        if(outfile == NULL) {
+        if (outfile == nullptr) {
             throw DeadlyExportError("could not open output .obj file: " + std::string(pFile));
         }
         outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
     }
     {
         std::unique_ptr<IOStream> outfile (pIOSystem->Open(exporter.GetMaterialLibFileName(),"wt"));
-        if(outfile == NULL) {
+        if (outfile == nullptr) {
             throw DeadlyExportError("could not open output .mtl file: " + std::string(exporter.GetMaterialLibFileName()));
         }
         outfile->Write( exporter.mOutputMat.str().c_str(), static_cast<size_t>(exporter.mOutputMat.tellp()),1);
@@ -97,7 +97,7 @@ void ExportSceneObjNoMtl(const char* pFile,IOSystem* pIOSystem, const aiScene* p
     // we're still here - export successfully completed. Write both the main OBJ file and the material script
     {
         std::unique_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
-        if(outfile == NULL) {
+        if (outfile == nullptr) {
             throw DeadlyExportError("could not open output .obj file: " + std::string(pFile));
         }
         outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);

+ 15 - 11
code/AssetLib/Obj/ObjFileData.h

@@ -41,12 +41,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #pragma once
 #ifndef OBJ_FILEDATA_H_INC
-#    define OBJ_FILEDATA_H_INC
+#define OBJ_FILEDATA_H_INC
 
-#    include <assimp/mesh.h>
-#    include <assimp/types.h>
-#    include <map>
-#    include <vector>
+#include <assimp/mesh.h>
+#include <assimp/types.h>
+#include <map>
+#include <vector>
 
 namespace Assimp {
 namespace ObjFile {
@@ -215,7 +215,11 @@ struct Mesh {
 
     /// Constructor
     explicit Mesh(const std::string &name) :
-            m_name(name), m_pMaterial(NULL), m_uiNumIndices(0), m_uiMaterialIndex(NoMaterial), m_hasNormals(false) {
+            m_name(name),
+            m_pMaterial(nullptr),
+            m_uiNumIndices(0),
+            m_uiMaterialIndex(NoMaterial),
+            m_hasNormals(false) {
         memset(m_uiUVCoordinates, 0, sizeof(unsigned int) * AI_MAX_NUMBER_OF_TEXTURECOORDS);
     }
 
@@ -275,13 +279,13 @@ struct Model {
     //! \brief  The default class constructor
     Model() :
             m_ModelName(""),
-            m_pCurrent(NULL),
-            m_pCurrentMaterial(NULL),
-            m_pDefaultMaterial(NULL),
-            m_pGroupFaceIDs(NULL),
+            m_pCurrent(nullptr),
+            m_pCurrentMaterial(nullptr),
+            m_pDefaultMaterial(nullptr),
+            m_pGroupFaceIDs(nullptr),
             m_strActiveGroup(""),
             m_TextureCoordDim(0),
-            m_pCurrentMesh(NULL) {
+            m_pCurrentMesh(nullptr) {
         // empty
     }
 

+ 15 - 15
code/AssetLib/Obj/ObjFileImporter.cpp

@@ -252,9 +252,9 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model *pModel, aiScene
 aiNode *ObjFileImporter::createNodes(const ObjFile::Model *pModel, const ObjFile::Object *pObject,
         aiNode *pParent, aiScene *pScene,
         std::vector<aiMesh *> &MeshArray) {
-    ai_assert(NULL != pModel);
-    if (NULL == pObject) {
-        return NULL;
+    ai_assert(nullptr != pModel);
+    if (nullptr == pObject) {
+        return nullptr;
     }
 
     // Store older mesh size to be able to computes mesh offsets for new mesh instances
@@ -264,7 +264,7 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model *pModel, const ObjFile
     pNode->mName = pObject->m_strObjName;
 
     // If we have a parent node, store it
-    ai_assert(NULL != pParent);
+    ai_assert(nullptr != pParent);
     appendChildToParentNode(pParent, pNode);
 
     for (size_t i = 0; i < pObject->m_Meshes.size(); ++i) {
@@ -308,20 +308,20 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model *pModel, const ObjFile
 //  Create topology data
 aiMesh *ObjFileImporter::createTopology(const ObjFile::Model *pModel, const ObjFile::Object *pData, unsigned int meshIndex) {
     // Checking preconditions
-    ai_assert(NULL != pModel);
+    ai_assert(nullptr != pModel);
 
-    if (NULL == pData) {
-        return NULL;
+    if (nullptr == pData) {
+        return nullptr;
     }
 
     // Create faces
     ObjFile::Mesh *pObjMesh = pModel->m_Meshes[meshIndex];
     if (!pObjMesh) {
-        return NULL;
+        return nullptr;
     }
 
     if (pObjMesh->m_Faces.empty()) {
-        return NULL;
+        return nullptr;
     }
 
     std::unique_ptr<aiMesh> pMesh(new aiMesh);
@@ -331,7 +331,7 @@ aiMesh *ObjFileImporter::createTopology(const ObjFile::Model *pModel, const ObjF
 
     for (size_t index = 0; index < pObjMesh->m_Faces.size(); index++) {
         ObjFile::Face *const inp = pObjMesh->m_Faces[index];
-        ai_assert(NULL != inp);
+        ai_assert(nullptr != inp);
 
         if (inp->m_PrimitiveType == aiPrimitiveType_LINE) {
             pMesh->mNumFaces += static_cast<unsigned int>(inp->m_vertices.size() - 1);
@@ -400,7 +400,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model *pModel,
         aiMesh *pMesh,
         unsigned int numIndices) {
     // Checking preconditions
-    ai_assert(NULL != pCurrentObject);
+    ai_assert(nullptr != pCurrentObject);
 
     // Break, if no faces are stored in object
     if (pCurrentObject->m_Meshes.empty())
@@ -408,7 +408,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model *pModel,
 
     // Get current mesh
     ObjFile::Mesh *pObjMesh = pModel->m_Meshes[uiMeshIndex];
-    if (NULL == pObjMesh || pObjMesh->m_uiNumIndices < 1) {
+    if (nullptr == pObjMesh || pObjMesh->m_uiNumIndices < 1) {
         return;
     }
 
@@ -561,7 +561,7 @@ void ObjFileImporter::addTextureMappingModeProperty(aiMaterial *mat, aiTextureTy
 // ------------------------------------------------------------------------------------------------
 //  Creates the material
 void ObjFileImporter::createMaterials(const ObjFile::Model *pModel, aiScene *pScene) {
-    if (NULL == pScene) {
+    if (nullptr == pScene) {
         return;
     }
 
@@ -717,8 +717,8 @@ void ObjFileImporter::createMaterials(const ObjFile::Model *pModel, aiScene *pSc
 //  Appends this node to the parent node
 void ObjFileImporter::appendChildToParentNode(aiNode *pParent, aiNode *pChild) {
     // Checking preconditions
-    ai_assert(NULL != pParent);
-    ai_assert(NULL != pChild);
+    ai_assert(nullptr != pParent);
+    ai_assert(nullptr != pChild);
 
     // Assign parent to child
     pChild->mParent = pParent;

+ 3 - 3
code/AssetLib/Obj/ObjFileMtlImporter.cpp

@@ -200,7 +200,7 @@ void ObjFileMtlImporter::load() {
 // -------------------------------------------------------------------
 //  Loads a color definition
 void ObjFileMtlImporter::getColorRGBA(aiColor3D *pColor) {
-    ai_assert(NULL != pColor);
+    ai_assert(nullptr != pColor);
 
     ai_real r(0.0), g(0.0), b(0.0);
     m_DataIt = getFloat<DataArrayIt>(m_DataIt, m_DataItEnd, r);
@@ -274,7 +274,7 @@ void ObjFileMtlImporter::createMaterial() {
 // -------------------------------------------------------------------
 //  Gets a texture name from data.
 void ObjFileMtlImporter::getTexture() {
-    aiString *out(NULL);
+    aiString *out(nullptr);
     int clampIndex = -1;
 
     const char *pPtr(&(*m_DataIt));
@@ -332,7 +332,7 @@ void ObjFileMtlImporter::getTexture() {
 
     std::string texture;
     m_DataIt = getName<DataArrayIt>(m_DataIt, m_DataItEnd, texture);
-    if (NULL != out) {
+    if (nullptr != out) {
         out->Set(texture);
     }
 }

+ 9 - 8
code/AssetLib/Obj/ObjFileParser.cpp

@@ -494,19 +494,19 @@ void ObjFileParser::getFace(aiPrimitiveType type) {
     }
 
     // Set active material, if one set
-    if (NULL != m_pModel->m_pCurrentMaterial) {
+    if (nullptr != m_pModel->m_pCurrentMaterial) {
         face->m_pMaterial = m_pModel->m_pCurrentMaterial;
     } else {
         face->m_pMaterial = m_pModel->m_pDefaultMaterial;
     }
 
     // Create a default object, if nothing is there
-    if (NULL == m_pModel->m_pCurrent) {
+    if (nullptr == m_pModel->m_pCurrent) {
         createObject(DefaultObjName);
     }
 
     // Assign face to mesh
-    if (NULL == m_pModel->m_pCurrentMesh) {
+    if (nullptr == m_pModel->m_pCurrentMesh) {
         createMesh(DefaultObjName);
     }
 
@@ -753,7 +753,7 @@ void ObjFileParser::getObjectName() {
     std::string strObjectName(pStart, &(*m_DataIt));
     if (!strObjectName.empty()) {
         // Reset current object
-        m_pModel->m_pCurrent = NULL;
+        m_pModel->m_pCurrent = nullptr;
 
         // Search for actual object
         for (std::vector<ObjFile::Object *>::const_iterator it = m_pModel->m_Objects.begin();
@@ -766,7 +766,7 @@ void ObjFileParser::getObjectName() {
         }
 
         // Allocate a new object, if current one was not found before
-        if (NULL == m_pModel->m_pCurrent) {
+        if (nullptr == m_pModel->m_pCurrent) {
             createObject(strObjectName);
         }
     }
@@ -775,7 +775,7 @@ void ObjFileParser::getObjectName() {
 // -------------------------------------------------------------------
 //  Creates a new object instance
 void ObjFileParser::createObject(const std::string &objName) {
-    ai_assert(NULL != m_pModel);
+    ai_assert(nullptr != m_pModel);
 
     m_pModel->m_pCurrent = new ObjFile::Object;
     m_pModel->m_pCurrent->m_strObjName = objName;
@@ -792,11 +792,12 @@ void ObjFileParser::createObject(const std::string &objName) {
 // -------------------------------------------------------------------
 //  Creates a new mesh
 void ObjFileParser::createMesh(const std::string &meshName) {
-    ai_assert(NULL != m_pModel);
+    ai_assert(nullptr != m_pModel);
+
     m_pModel->m_pCurrentMesh = new ObjFile::Mesh(meshName);
     m_pModel->m_Meshes.push_back(m_pModel->m_pCurrentMesh);
     unsigned int meshId = static_cast<unsigned int>(m_pModel->m_Meshes.size() - 1);
-    if (NULL != m_pModel->m_pCurrent) {
+    if (nullptr != m_pModel->m_pCurrent) {
         m_pModel->m_pCurrent->m_Meshes.push_back(meshId);
     } else {
         ASSIMP_LOG_ERROR("OBJ: No object detected to attach a new mesh instance.");

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 271 - 368
code/AssetLib/Ogre/OgreStructs.cpp


+ 2 - 2
code/AssetLib/Ply/PlyExporter.cpp

@@ -77,7 +77,7 @@ void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
 
     // we're still here - export successfully completed. Write the file.
     std::unique_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
-    if(outfile == NULL) {
+    if (outfile == nullptr) {
         throw DeadlyExportError("could not open output .ply file: " + std::string(pFile));
     }
 
@@ -91,7 +91,7 @@ void ExportScenePlyBinary(const char* pFile, IOSystem* pIOSystem, const aiScene*
 
     // we're still here - export successfully completed. Write the file.
     std::unique_ptr<IOStream> outfile(pIOSystem->Open(pFile, "wb"));
-    if (outfile == NULL) {
+    if (outfile == nullptr) {
         throw DeadlyExportError("could not open output .ply file: " + std::string(pFile));
     }
 

+ 4 - 4
code/AssetLib/Ply/PlyLoader.cpp

@@ -693,7 +693,7 @@ void PLYImporter::GetMaterialColor(const std::vector<PLY::PropertyInstance> &avL
         unsigned int aiPositions[4],
         PLY::EDataType aiTypes[4],
         aiColor4D *clrOut) {
-    ai_assert(NULL != clrOut);
+    ai_assert(nullptr != clrOut);
 
     if (0xFFFFFFFF == aiPositions[0])
         clrOut->r = 0.0f;
@@ -736,7 +736,7 @@ void PLYImporter::GetMaterialColor(const std::vector<PLY::PropertyInstance> &avL
 // ------------------------------------------------------------------------------------------------
 // Extract a material from the PLY DOM
 void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &defaultTexture, const bool pointsOnly) {
-    ai_assert(NULL != pvOut);
+    ai_assert(nullptr != pvOut);
 
     // diffuse[4], specular[4], ambient[4]
     // rgba order
@@ -752,7 +752,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
         { EDT_Char, EDT_Char, EDT_Char, EDT_Char },
         { EDT_Char, EDT_Char, EDT_Char, EDT_Char }
     };
-    PLY::ElementInstanceList *pcList = NULL;
+    PLY::ElementInstanceList *pcList = nullptr;
 
     unsigned int iPhong = 0xFFFFFFFF;
     PLY::EDataType ePhong = EDT_Char;
@@ -835,7 +835,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
         }
     }
     // check whether we have a valid source for the material data
-    if (NULL != pcList) {
+    if (nullptr != pcList) {
         for (std::vector<ElementInstance>::const_iterator i = pcList->alInstances.begin(); i != pcList->alInstances.end(); ++i) {
             aiColor4D clrOut;
             aiMaterial *pcHelper = new aiMaterial();

+ 735 - 919
code/AssetLib/Ply/PlyParser.cpp

@@ -42,285 +42,201 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 /** @file Implementation of the PLY parser class */
 
-
 #ifndef ASSIMP_BUILD_NO_PLY_IMPORTER
 
+#include "PlyLoader.h"
+#include <assimp/ByteSwapper.h>
 #include <assimp/fast_atof.h>
 #include <assimp/DefaultLogger.hpp>
-#include <assimp/ByteSwapper.h>
-#include "PlyLoader.h"
 
 using namespace Assimp;
 
 // ------------------------------------------------------------------------------------------------
 PLY::EDataType PLY::Property::ParseDataType(std::vector<char> &buffer) {
-  ai_assert(!buffer.empty());
-
-  PLY::EDataType eOut = PLY::EDT_INVALID;
-
-  if (PLY::DOM::TokenMatch(buffer, "char", 4) ||
-    PLY::DOM::TokenMatch(buffer, "int8", 4))
-  {
-    eOut = PLY::EDT_Char;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "uchar", 5) ||
-    PLY::DOM::TokenMatch(buffer, "uint8", 5))
-  {
-    eOut = PLY::EDT_UChar;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "short", 5) ||
-    PLY::DOM::TokenMatch(buffer, "int16", 5))
-  {
-    eOut = PLY::EDT_Short;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "ushort", 6) ||
-    PLY::DOM::TokenMatch(buffer, "uint16", 6))
-  {
-    eOut = PLY::EDT_UShort;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "int32", 5) || PLY::DOM::TokenMatch(buffer, "int", 3))
-  {
-    eOut = PLY::EDT_Int;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "uint32", 6) || PLY::DOM::TokenMatch(buffer, "uint", 4))
-  {
-    eOut = PLY::EDT_UInt;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "float", 5) || PLY::DOM::TokenMatch(buffer, "float32", 7))
-  {
-    eOut = PLY::EDT_Float;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "double64", 8) || PLY::DOM::TokenMatch(buffer, "double", 6) ||
-    PLY::DOM::TokenMatch(buffer, "float64", 7))
-  {
-    eOut = PLY::EDT_Double;
-  }
-  if (PLY::EDT_INVALID == eOut)
-  {
-      ASSIMP_LOG_INFO("Found unknown data type in PLY file. This is OK");
-  }
+    ai_assert(!buffer.empty());
+
+    PLY::EDataType eOut = PLY::EDT_INVALID;
+
+    if (PLY::DOM::TokenMatch(buffer, "char", 4) ||
+            PLY::DOM::TokenMatch(buffer, "int8", 4)) {
+        eOut = PLY::EDT_Char;
+    } else if (PLY::DOM::TokenMatch(buffer, "uchar", 5) ||
+               PLY::DOM::TokenMatch(buffer, "uint8", 5)) {
+        eOut = PLY::EDT_UChar;
+    } else if (PLY::DOM::TokenMatch(buffer, "short", 5) ||
+               PLY::DOM::TokenMatch(buffer, "int16", 5)) {
+        eOut = PLY::EDT_Short;
+    } else if (PLY::DOM::TokenMatch(buffer, "ushort", 6) ||
+               PLY::DOM::TokenMatch(buffer, "uint16", 6)) {
+        eOut = PLY::EDT_UShort;
+    } else if (PLY::DOM::TokenMatch(buffer, "int32", 5) || PLY::DOM::TokenMatch(buffer, "int", 3)) {
+        eOut = PLY::EDT_Int;
+    } else if (PLY::DOM::TokenMatch(buffer, "uint32", 6) || PLY::DOM::TokenMatch(buffer, "uint", 4)) {
+        eOut = PLY::EDT_UInt;
+    } else if (PLY::DOM::TokenMatch(buffer, "float", 5) || PLY::DOM::TokenMatch(buffer, "float32", 7)) {
+        eOut = PLY::EDT_Float;
+    } else if (PLY::DOM::TokenMatch(buffer, "double64", 8) || PLY::DOM::TokenMatch(buffer, "double", 6) ||
+               PLY::DOM::TokenMatch(buffer, "float64", 7)) {
+        eOut = PLY::EDT_Double;
+    }
+    if (PLY::EDT_INVALID == eOut) {
+        ASSIMP_LOG_INFO("Found unknown data type in PLY file. This is OK");
+    }
 
-  return eOut;
+    return eOut;
 }
 
 // ------------------------------------------------------------------------------------------------
 PLY::ESemantic PLY::Property::ParseSemantic(std::vector<char> &buffer) {
-  ai_assert(!buffer.empty());
-
-  PLY::ESemantic eOut = PLY::EST_INVALID;
-  if (PLY::DOM::TokenMatch(buffer, "red", 3)) {
-    eOut = PLY::EST_Red;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "green", 5)) {
-    eOut = PLY::EST_Green;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "blue", 4)) {
-    eOut = PLY::EST_Blue;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "alpha", 5)) {
-    eOut = PLY::EST_Alpha;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "vertex_index", 12) || PLY::DOM::TokenMatch(buffer, "vertex_indices", 14)) {
-    eOut = PLY::EST_VertexIndex;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "texcoord", 8)) // Manage uv coords on faces
-  {
-    eOut = PLY::EST_TextureCoordinates;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "material_index", 14))
-  {
-    eOut = PLY::EST_MaterialIndex;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "ambient_red", 11))
-  {
-    eOut = PLY::EST_AmbientRed;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "ambient_green", 13))
-  {
-    eOut = PLY::EST_AmbientGreen;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "ambient_blue", 12))
-  {
-    eOut = PLY::EST_AmbientBlue;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "ambient_alpha", 13))
-  {
-    eOut = PLY::EST_AmbientAlpha;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "diffuse_red", 11))
-  {
-    eOut = PLY::EST_DiffuseRed;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "diffuse_green", 13))
-  {
-    eOut = PLY::EST_DiffuseGreen;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "diffuse_blue", 12))
-  {
-    eOut = PLY::EST_DiffuseBlue;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "diffuse_alpha", 13))
-  {
-    eOut = PLY::EST_DiffuseAlpha;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "specular_red", 12))
-  {
-    eOut = PLY::EST_SpecularRed;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "specular_green", 14))
-  {
-    eOut = PLY::EST_SpecularGreen;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "specular_blue", 13))
-  {
-    eOut = PLY::EST_SpecularBlue;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "specular_alpha", 14))
-  {
-    eOut = PLY::EST_SpecularAlpha;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "opacity", 7))
-  {
-    eOut = PLY::EST_Opacity;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "specular_power", 14))
-  {
-    eOut = PLY::EST_PhongPower;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "r", 1))
-  {
-    eOut = PLY::EST_Red;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "g", 1))
-  {
-    eOut = PLY::EST_Green;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "b", 1))
-  {
-    eOut = PLY::EST_Blue;
-  }
+    ai_assert(!buffer.empty());
+
+    PLY::ESemantic eOut = PLY::EST_INVALID;
+    if (PLY::DOM::TokenMatch(buffer, "red", 3)) {
+        eOut = PLY::EST_Red;
+    } else if (PLY::DOM::TokenMatch(buffer, "green", 5)) {
+        eOut = PLY::EST_Green;
+    } else if (PLY::DOM::TokenMatch(buffer, "blue", 4)) {
+        eOut = PLY::EST_Blue;
+    } else if (PLY::DOM::TokenMatch(buffer, "alpha", 5)) {
+        eOut = PLY::EST_Alpha;
+    } else if (PLY::DOM::TokenMatch(buffer, "vertex_index", 12) || PLY::DOM::TokenMatch(buffer, "vertex_indices", 14)) {
+        eOut = PLY::EST_VertexIndex;
+    } else if (PLY::DOM::TokenMatch(buffer, "texcoord", 8)) // Manage uv coords on faces
+    {
+        eOut = PLY::EST_TextureCoordinates;
+    } else if (PLY::DOM::TokenMatch(buffer, "material_index", 14)) {
+        eOut = PLY::EST_MaterialIndex;
+    } else if (PLY::DOM::TokenMatch(buffer, "ambient_red", 11)) {
+        eOut = PLY::EST_AmbientRed;
+    } else if (PLY::DOM::TokenMatch(buffer, "ambient_green", 13)) {
+        eOut = PLY::EST_AmbientGreen;
+    } else if (PLY::DOM::TokenMatch(buffer, "ambient_blue", 12)) {
+        eOut = PLY::EST_AmbientBlue;
+    } else if (PLY::DOM::TokenMatch(buffer, "ambient_alpha", 13)) {
+        eOut = PLY::EST_AmbientAlpha;
+    } else if (PLY::DOM::TokenMatch(buffer, "diffuse_red", 11)) {
+        eOut = PLY::EST_DiffuseRed;
+    } else if (PLY::DOM::TokenMatch(buffer, "diffuse_green", 13)) {
+        eOut = PLY::EST_DiffuseGreen;
+    } else if (PLY::DOM::TokenMatch(buffer, "diffuse_blue", 12)) {
+        eOut = PLY::EST_DiffuseBlue;
+    } else if (PLY::DOM::TokenMatch(buffer, "diffuse_alpha", 13)) {
+        eOut = PLY::EST_DiffuseAlpha;
+    } else if (PLY::DOM::TokenMatch(buffer, "specular_red", 12)) {
+        eOut = PLY::EST_SpecularRed;
+    } else if (PLY::DOM::TokenMatch(buffer, "specular_green", 14)) {
+        eOut = PLY::EST_SpecularGreen;
+    } else if (PLY::DOM::TokenMatch(buffer, "specular_blue", 13)) {
+        eOut = PLY::EST_SpecularBlue;
+    } else if (PLY::DOM::TokenMatch(buffer, "specular_alpha", 14)) {
+        eOut = PLY::EST_SpecularAlpha;
+    } else if (PLY::DOM::TokenMatch(buffer, "opacity", 7)) {
+        eOut = PLY::EST_Opacity;
+    } else if (PLY::DOM::TokenMatch(buffer, "specular_power", 14)) {
+        eOut = PLY::EST_PhongPower;
+    } else if (PLY::DOM::TokenMatch(buffer, "r", 1)) {
+        eOut = PLY::EST_Red;
+    } else if (PLY::DOM::TokenMatch(buffer, "g", 1)) {
+        eOut = PLY::EST_Green;
+    } else if (PLY::DOM::TokenMatch(buffer, "b", 1)) {
+        eOut = PLY::EST_Blue;
+    }
 
-  // NOTE: Blender3D exports texture coordinates as s,t tuples
-  else if (PLY::DOM::TokenMatch(buffer, "u", 1) || PLY::DOM::TokenMatch(buffer, "s", 1) || PLY::DOM::TokenMatch(buffer, "tx", 2) || PLY::DOM::TokenMatch(buffer, "texture_u", 9))
-  {
-    eOut = PLY::EST_UTextureCoord;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "v", 1) || PLY::DOM::TokenMatch(buffer, "t", 1) || PLY::DOM::TokenMatch(buffer, "ty", 2) || PLY::DOM::TokenMatch(buffer, "texture_v", 9))
-  {
-    eOut = PLY::EST_VTextureCoord;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "x", 1))
-  {
-    eOut = PLY::EST_XCoord;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "y", 1)) {
-    eOut = PLY::EST_YCoord;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "z", 1)) {
-    eOut = PLY::EST_ZCoord;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "nx", 2)) {
-    eOut = PLY::EST_XNormal;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "ny", 2)) {
-    eOut = PLY::EST_YNormal;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "nz", 2)) {
-    eOut = PLY::EST_ZNormal;
-  }
-  else {
-      ASSIMP_LOG_INFO("Found unknown property semantic in file. This is ok");
-    PLY::DOM::SkipLine(buffer);
-  }
-  return eOut;
+    // NOTE: Blender3D exports texture coordinates as s,t tuples
+    else if (PLY::DOM::TokenMatch(buffer, "u", 1) || PLY::DOM::TokenMatch(buffer, "s", 1) || PLY::DOM::TokenMatch(buffer, "tx", 2) || PLY::DOM::TokenMatch(buffer, "texture_u", 9)) {
+        eOut = PLY::EST_UTextureCoord;
+    } else if (PLY::DOM::TokenMatch(buffer, "v", 1) || PLY::DOM::TokenMatch(buffer, "t", 1) || PLY::DOM::TokenMatch(buffer, "ty", 2) || PLY::DOM::TokenMatch(buffer, "texture_v", 9)) {
+        eOut = PLY::EST_VTextureCoord;
+    } else if (PLY::DOM::TokenMatch(buffer, "x", 1)) {
+        eOut = PLY::EST_XCoord;
+    } else if (PLY::DOM::TokenMatch(buffer, "y", 1)) {
+        eOut = PLY::EST_YCoord;
+    } else if (PLY::DOM::TokenMatch(buffer, "z", 1)) {
+        eOut = PLY::EST_ZCoord;
+    } else if (PLY::DOM::TokenMatch(buffer, "nx", 2)) {
+        eOut = PLY::EST_XNormal;
+    } else if (PLY::DOM::TokenMatch(buffer, "ny", 2)) {
+        eOut = PLY::EST_YNormal;
+    } else if (PLY::DOM::TokenMatch(buffer, "nz", 2)) {
+        eOut = PLY::EST_ZNormal;
+    } else {
+        ASSIMP_LOG_INFO("Found unknown property semantic in file. This is ok");
+        PLY::DOM::SkipLine(buffer);
+    }
+    return eOut;
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::Property::ParseProperty(std::vector<char> &buffer, PLY::Property* pOut)
-{
-  ai_assert(!buffer.empty());
+bool PLY::Property::ParseProperty(std::vector<char> &buffer, PLY::Property *pOut) {
+    ai_assert(!buffer.empty());
 
-  // Forms supported:
-  // "property float x"
-  // "property list uchar int vertex_index"
+    // Forms supported:
+    // "property float x"
+    // "property list uchar int vertex_index"
 
-  // skip leading spaces
-  if (!PLY::DOM::SkipSpaces(buffer)) {
-    return false;
-  }
-
-  // skip the "property" string at the beginning
-  if (!PLY::DOM::TokenMatch(buffer, "property", 8))
-  {
-    // seems not to be a valid property entry
-    return false;
-  }
-  // get next word
-  if (!PLY::DOM::SkipSpaces(buffer)) {
-    return false;
-  }
-  if (PLY::DOM::TokenMatch(buffer, "list", 4))
-  {
-    pOut->bIsList = true;
+    // skip leading spaces
+    if (!PLY::DOM::SkipSpaces(buffer)) {
+        return false;
+    }
 
-    // seems to be a list.
-    if (EDT_INVALID == (pOut->eFirstType = PLY::Property::ParseDataType(buffer)))
-    {
-      // unable to parse list size data type
-      PLY::DOM::SkipLine(buffer);
-      return false;
+    // skip the "property" string at the beginning
+    if (!PLY::DOM::TokenMatch(buffer, "property", 8)) {
+        // seems not to be a valid property entry
+        return false;
     }
-    if (!PLY::DOM::SkipSpaces(buffer))return false;
-    if (EDT_INVALID == (pOut->eType = PLY::Property::ParseDataType(buffer)))
-    {
-      // unable to parse list data type
-      PLY::DOM::SkipLine(buffer);
-      return false;
+    // get next word
+    if (!PLY::DOM::SkipSpaces(buffer)) {
+        return false;
     }
-  }
-  else
-  {
-    if (EDT_INVALID == (pOut->eType = PLY::Property::ParseDataType(buffer)))
-    {
-      // unable to parse data type. Skip the property
-      PLY::DOM::SkipLine(buffer);
-      return false;
+    if (PLY::DOM::TokenMatch(buffer, "list", 4)) {
+        pOut->bIsList = true;
+
+        // seems to be a list.
+        if (EDT_INVALID == (pOut->eFirstType = PLY::Property::ParseDataType(buffer))) {
+            // unable to parse list size data type
+            PLY::DOM::SkipLine(buffer);
+            return false;
+        }
+        if (!PLY::DOM::SkipSpaces(buffer)) return false;
+        if (EDT_INVALID == (pOut->eType = PLY::Property::ParseDataType(buffer))) {
+            // unable to parse list data type
+            PLY::DOM::SkipLine(buffer);
+            return false;
+        }
+    } else {
+        if (EDT_INVALID == (pOut->eType = PLY::Property::ParseDataType(buffer))) {
+            // unable to parse data type. Skip the property
+            PLY::DOM::SkipLine(buffer);
+            return false;
+        }
     }
-  }
 
-  if (!PLY::DOM::SkipSpaces(buffer))
-    return false;
+    if (!PLY::DOM::SkipSpaces(buffer))
+        return false;
 
-  pOut->Semantic = PLY::Property::ParseSemantic(buffer);
+    pOut->Semantic = PLY::Property::ParseSemantic(buffer);
 
-  if (PLY::EST_INVALID == pOut->Semantic)
-  {
-    ASSIMP_LOG_INFO("Found unknown semantic in PLY file. This is OK");
-    std::string(&buffer[0], &buffer[0] + strlen(&buffer[0]));
-  }
+    if (PLY::EST_INVALID == pOut->Semantic) {
+        ASSIMP_LOG_INFO("Found unknown semantic in PLY file. This is OK");
+        std::string(&buffer[0], &buffer[0] + strlen(&buffer[0]));
+    }
 
-  PLY::DOM::SkipSpacesAndLineEnd(buffer);
-  return true;
+    PLY::DOM::SkipSpacesAndLineEnd(buffer);
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
-PLY::EElementSemantic PLY::Element::ParseSemantic(std::vector<char> &buffer)
-{
-  ai_assert(!buffer.empty());
-
-  PLY::EElementSemantic eOut = PLY::EEST_INVALID;
-  if (PLY::DOM::TokenMatch(buffer, "vertex", 6))
-  {
-    eOut = PLY::EEST_Vertex;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "face", 4))
-  {
-    eOut = PLY::EEST_Face;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "tristrips", 9))
-  {
-    eOut = PLY::EEST_TriStrip;
-  }
+PLY::EElementSemantic PLY::Element::ParseSemantic(std::vector<char> &buffer) {
+    ai_assert(!buffer.empty());
+
+    PLY::EElementSemantic eOut = PLY::EEST_INVALID;
+    if (PLY::DOM::TokenMatch(buffer, "vertex", 6)) {
+        eOut = PLY::EEST_Vertex;
+    } else if (PLY::DOM::TokenMatch(buffer, "face", 4)) {
+        eOut = PLY::EEST_Face;
+    } else if (PLY::DOM::TokenMatch(buffer, "tristrips", 9)) {
+        eOut = PLY::EEST_TriStrip;
+    }
 #if 0
   // TODO: maybe implement this?
   else if (PLY::DOM::TokenMatch(buffer,"range_grid",10))
@@ -328,815 +244,715 @@ PLY::EElementSemantic PLY::Element::ParseSemantic(std::vector<char> &buffer)
     eOut = PLY::EEST_Face;
   }
 #endif
-  else if (PLY::DOM::TokenMatch(buffer, "edge", 4))
-  {
-    eOut = PLY::EEST_Edge;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "material", 8))
-  {
-    eOut = PLY::EEST_Material;
-  }
-  else if (PLY::DOM::TokenMatch(buffer, "TextureFile", 11))
-  {
-    eOut = PLY::EEST_TextureFile;
-  }
+    else if (PLY::DOM::TokenMatch(buffer, "edge", 4)) {
+        eOut = PLY::EEST_Edge;
+    } else if (PLY::DOM::TokenMatch(buffer, "material", 8)) {
+        eOut = PLY::EEST_Material;
+    } else if (PLY::DOM::TokenMatch(buffer, "TextureFile", 11)) {
+        eOut = PLY::EEST_TextureFile;
+    }
 
-  return eOut;
+    return eOut;
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::Element::ParseElement(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer, PLY::Element* pOut)
-{
-  ai_assert(NULL != pOut);
-  // Example format: "element vertex 8"
+bool PLY::Element::ParseElement(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer, PLY::Element *pOut) {
+    ai_assert(nullptr != pOut);
+    // Example format: "element vertex 8"
 
-  // skip leading spaces
-  if (!PLY::DOM::SkipSpaces(buffer))
-  {
-    return false;
-  }
+    // skip leading spaces
+    if (!PLY::DOM::SkipSpaces(buffer)) {
+        return false;
+    }
 
-  // skip the "element" string at the beginning
-  if (!PLY::DOM::TokenMatch(buffer, "element", 7) && !PLY::DOM::TokenMatch(buffer, "comment", 7))
-  {
-    // seems not to be a valid property entry
-    return false;
-  }
-  // get next word
-  if (!PLY::DOM::SkipSpaces(buffer))
-    return false;
+    // skip the "element" string at the beginning
+    if (!PLY::DOM::TokenMatch(buffer, "element", 7) && !PLY::DOM::TokenMatch(buffer, "comment", 7)) {
+        // seems not to be a valid property entry
+        return false;
+    }
+    // get next word
+    if (!PLY::DOM::SkipSpaces(buffer))
+        return false;
 
-  // parse the semantic of the element
-  pOut->eSemantic = PLY::Element::ParseSemantic(buffer);
-  if (PLY::EEST_INVALID == pOut->eSemantic)
-  {
-    // if the exact semantic can't be determined, just store
-    // the original string identifier
-    pOut->szName = std::string(&buffer[0], &buffer[0] + strlen(&buffer[0]));
-  }
+    // parse the semantic of the element
+    pOut->eSemantic = PLY::Element::ParseSemantic(buffer);
+    if (PLY::EEST_INVALID == pOut->eSemantic) {
+        // if the exact semantic can't be determined, just store
+        // the original string identifier
+        pOut->szName = std::string(&buffer[0], &buffer[0] + strlen(&buffer[0]));
+    }
 
-  if (!PLY::DOM::SkipSpaces(buffer))
-    return false;
+    if (!PLY::DOM::SkipSpaces(buffer))
+        return false;
 
-  if (PLY::EEST_TextureFile == pOut->eSemantic)
-  {
-    char* endPos = &buffer[0] + (strlen(&buffer[0]) - 1);
-    pOut->szName = std::string(&buffer[0], endPos);
+    if (PLY::EEST_TextureFile == pOut->eSemantic) {
+        char *endPos = &buffer[0] + (strlen(&buffer[0]) - 1);
+        pOut->szName = std::string(&buffer[0], endPos);
 
-    // go to the next line
-    PLY::DOM::SkipSpacesAndLineEnd(buffer);
+        // go to the next line
+        PLY::DOM::SkipSpacesAndLineEnd(buffer);
 
-    return true;
-  }
+        return true;
+    }
 
-  //parse the number of occurrences of this element
-  const char* pCur = (char*)&buffer[0];
-  pOut->NumOccur = strtoul10(pCur, &pCur);
+    //parse the number of occurrences of this element
+    const char *pCur = (char *)&buffer[0];
+    pOut->NumOccur = strtoul10(pCur, &pCur);
 
-  // go to the next line
-  PLY::DOM::SkipSpacesAndLineEnd(buffer);
+    // go to the next line
+    PLY::DOM::SkipSpacesAndLineEnd(buffer);
 
-  // now parse all properties of the element
-  while (true)
-  {
-    streamBuffer.getNextLine(buffer);
-    pCur = (char*)&buffer[0];
+    // now parse all properties of the element
+    while (true) {
+        streamBuffer.getNextLine(buffer);
+        pCur = (char *)&buffer[0];
 
-    // skip all comments
-    PLY::DOM::SkipComments(buffer);
+        // skip all comments
+        PLY::DOM::SkipComments(buffer);
 
-    PLY::Property prop;
-    if (!PLY::Property::ParseProperty(buffer, &prop))
-      break;
+        PLY::Property prop;
+        if (!PLY::Property::ParseProperty(buffer, &prop))
+            break;
 
-    pOut->alProperties.push_back(prop);
-  }
+        pOut->alProperties.push_back(prop);
+    }
 
-  return true;
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::DOM::SkipSpaces(std::vector<char> &buffer)
-{
-  const char* pCur = buffer.empty() ? NULL : (char*)&buffer[0];
-  bool ret = false;
-  if (pCur)
-  {
-    const char* szCur = pCur;
-    ret = Assimp::SkipSpaces(pCur, &pCur);
+bool PLY::DOM::SkipSpaces(std::vector<char> &buffer) {
+    const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0];
+    bool ret = false;
+    if (pCur) {
+        const char *szCur = pCur;
+        ret = Assimp::SkipSpaces(pCur, &pCur);
+
+        uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
+        buffer.erase(buffer.begin(), buffer.begin() + iDiff);
+        return ret;
+    }
 
-    uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
-    buffer.erase(buffer.begin(), buffer.begin() + iDiff);
     return ret;
-  }
-
-  return ret;
 }
 
-bool PLY::DOM::SkipLine(std::vector<char> &buffer)
-{
-  const char* pCur = buffer.empty() ? NULL : (char*)&buffer[0];
-  bool ret = false;
-  if (pCur)
-  {
-    const char* szCur = pCur;
-    ret = Assimp::SkipLine(pCur, &pCur);
+bool PLY::DOM::SkipLine(std::vector<char> &buffer) {
+    const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0];
+    bool ret = false;
+    if (pCur) {
+        const char *szCur = pCur;
+        ret = Assimp::SkipLine(pCur, &pCur);
 
-    uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
-    buffer.erase(buffer.begin(), buffer.begin() + iDiff);
-    return ret;
-  }
+        uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
+        buffer.erase(buffer.begin(), buffer.begin() + iDiff);
+        return ret;
+    }
 
-  return ret;
+    return ret;
 }
 
-bool PLY::DOM::TokenMatch(std::vector<char> &buffer, const char* token, unsigned int len)
-{
-  const char* pCur = buffer.empty() ? NULL : (char*)&buffer[0];
-  bool ret = false;
-  if (pCur)
-  {
-    const char* szCur = pCur;
-    ret = Assimp::TokenMatch(pCur, token, len);
+bool PLY::DOM::TokenMatch(std::vector<char> &buffer, const char *token, unsigned int len) {
+    const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0];
+    bool ret = false;
+    if (pCur) {
+        const char *szCur = pCur;
+        ret = Assimp::TokenMatch(pCur, token, len);
 
-    uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
-    buffer.erase(buffer.begin(), buffer.begin() + iDiff);
-    return ret;
-  }
+        uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
+        buffer.erase(buffer.begin(), buffer.begin() + iDiff);
+        return ret;
+    }
 
-  return ret;
+    return ret;
 }
 
-bool PLY::DOM::SkipSpacesAndLineEnd(std::vector<char> &buffer)
-{
-  const char* pCur = buffer.empty() ? NULL : (char*)&buffer[0];
-  bool ret = false;
-  if (pCur)
-  {
-    const char* szCur = pCur;
-    ret = Assimp::SkipSpacesAndLineEnd(pCur, &pCur);
+bool PLY::DOM::SkipSpacesAndLineEnd(std::vector<char> &buffer) {
+    const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0];
+    bool ret = false;
+    if (pCur) {
+        const char *szCur = pCur;
+        ret = Assimp::SkipSpacesAndLineEnd(pCur, &pCur);
 
-    uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
-    buffer.erase(buffer.begin(), buffer.begin() + iDiff);
-    return ret;
-  }
+        uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
+        buffer.erase(buffer.begin(), buffer.begin() + iDiff);
+        return ret;
+    }
 
-  return ret;
+    return ret;
 }
 
-bool PLY::DOM::SkipComments(std::vector<char> &buffer)
-{
-  ai_assert(!buffer.empty());
+bool PLY::DOM::SkipComments(std::vector<char> &buffer) {
+    ai_assert(!buffer.empty());
 
-  std::vector<char> nbuffer = buffer;
-  // skip spaces
-  if (!SkipSpaces(nbuffer)) {
-    return false;
-  }
+    std::vector<char> nbuffer = buffer;
+    // skip spaces
+    if (!SkipSpaces(nbuffer)) {
+        return false;
+    }
 
-  if (TokenMatch(nbuffer, "comment", 7))
-  {
-    if (!SkipSpaces(nbuffer))
-      SkipLine(nbuffer);
+    if (TokenMatch(nbuffer, "comment", 7)) {
+        if (!SkipSpaces(nbuffer))
+            SkipLine(nbuffer);
 
-    if (!TokenMatch(nbuffer, "TextureFile", 11))
-    {
-      SkipLine(nbuffer);
-      buffer = nbuffer;
-      return true;
-    }
+        if (!TokenMatch(nbuffer, "TextureFile", 11)) {
+            SkipLine(nbuffer);
+            buffer = nbuffer;
+            return true;
+        }
 
-    return true;
-  }
+        return true;
+    }
 
-  return false;
+    return false;
 }
 
 // ------------------------------------------------------------------------------------------------
 bool PLY::DOM::ParseHeader(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer, bool isBinary) {
     ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseHeader() begin");
 
-  // parse all elements
-  while (!buffer.empty())
-  {
-    // skip all comments
-    PLY::DOM::SkipComments(buffer);
-
-    PLY::Element out;
-    if (PLY::Element::ParseElement(streamBuffer, buffer, &out))
-    {
-      // add the element to the list of elements
-      alElements.push_back(out);
-    }
-    else if (TokenMatch(buffer, "end_header", 10))
-    {
-      // we have reached the end of the header
-      break;
-    }
-    else
-    {
-      // ignore unknown header elements
-      streamBuffer.getNextLine(buffer);
+    // parse all elements
+    while (!buffer.empty()) {
+        // skip all comments
+        PLY::DOM::SkipComments(buffer);
+
+        PLY::Element out;
+        if (PLY::Element::ParseElement(streamBuffer, buffer, &out)) {
+            // add the element to the list of elements
+            alElements.push_back(out);
+        } else if (TokenMatch(buffer, "end_header", 10)) {
+            // we have reached the end of the header
+            break;
+        } else {
+            // ignore unknown header elements
+            streamBuffer.getNextLine(buffer);
+        }
     }
-  }
 
-  if (!isBinary) // it would occur an error, if binary data start with values as space or line end.
-    SkipSpacesAndLineEnd(buffer);
+    if (!isBinary) // it would occur an error, if binary data start with values as space or line end.
+        SkipSpacesAndLineEnd(buffer);
 
-  ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseHeader() succeeded");
-  return true;
+    ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseHeader() succeeded");
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::DOM::ParseElementInstanceLists(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer, PLYImporter* loader)
-{
+bool PLY::DOM::ParseElementInstanceLists(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer, PLYImporter *loader) {
     ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceLists() begin");
-  alElementData.resize(alElements.size());
-
-  std::vector<PLY::Element>::const_iterator i = alElements.begin();
-  std::vector<PLY::ElementInstanceList>::iterator a = alElementData.begin();
-
-  // parse all element instances
-  //construct vertices and faces
-  for (; i != alElements.end(); ++i, ++a)
-  {
-    if ((*i).eSemantic == EEST_Vertex || (*i).eSemantic == EEST_Face || (*i).eSemantic == EEST_TriStrip)
-    {
-      PLY::ElementInstanceList::ParseInstanceList(streamBuffer, buffer, &(*i), NULL, loader);
-    }
-    else
-    {
-      (*a).alInstances.resize((*i).NumOccur);
-      PLY::ElementInstanceList::ParseInstanceList(streamBuffer, buffer, &(*i), &(*a), NULL);
+    alElementData.resize(alElements.size());
+
+    std::vector<PLY::Element>::const_iterator i = alElements.begin();
+    std::vector<PLY::ElementInstanceList>::iterator a = alElementData.begin();
+
+    // parse all element instances
+    //construct vertices and faces
+    for (; i != alElements.end(); ++i, ++a) {
+        if ((*i).eSemantic == EEST_Vertex || (*i).eSemantic == EEST_Face || (*i).eSemantic == EEST_TriStrip) {
+            PLY::ElementInstanceList::ParseInstanceList(streamBuffer, buffer, &(*i), nullptr, loader);
+        } else {
+            (*a).alInstances.resize((*i).NumOccur);
+            PLY::ElementInstanceList::ParseInstanceList(streamBuffer, buffer, &(*i), &(*a), nullptr);
+        }
     }
-  }
 
-  ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceLists() succeeded");
-  return true;
+    ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceLists() succeeded");
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
 bool PLY::DOM::ParseElementInstanceListsBinary(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer,
-    const char* &pCur,
-    unsigned int &bufferSize,
-    PLYImporter* loader,
-    bool p_bBE)
-{
+        const char *&pCur,
+        unsigned int &bufferSize,
+        PLYImporter *loader,
+        bool p_bBE) {
     ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceListsBinary() begin");
-  alElementData.resize(alElements.size());
-
-  std::vector<PLY::Element>::const_iterator i = alElements.begin();
-  std::vector<PLY::ElementInstanceList>::iterator a = alElementData.begin();
-
-  // parse all element instances
-  for (; i != alElements.end(); ++i, ++a)
-  {
-    if ((*i).eSemantic == EEST_Vertex || (*i).eSemantic == EEST_Face || (*i).eSemantic == EEST_TriStrip)
-    {
-      PLY::ElementInstanceList::ParseInstanceListBinary(streamBuffer, buffer, pCur, bufferSize, &(*i), NULL, loader, p_bBE);
-    }
-    else
-    {
-      (*a).alInstances.resize((*i).NumOccur);
-      PLY::ElementInstanceList::ParseInstanceListBinary(streamBuffer, buffer, pCur, bufferSize, &(*i), &(*a), NULL, p_bBE);
+    alElementData.resize(alElements.size());
+
+    std::vector<PLY::Element>::const_iterator i = alElements.begin();
+    std::vector<PLY::ElementInstanceList>::iterator a = alElementData.begin();
+
+    // parse all element instances
+    for (; i != alElements.end(); ++i, ++a) {
+        if ((*i).eSemantic == EEST_Vertex || (*i).eSemantic == EEST_Face || (*i).eSemantic == EEST_TriStrip) {
+            PLY::ElementInstanceList::ParseInstanceListBinary(streamBuffer, buffer, pCur, bufferSize, &(*i), nullptr, loader, p_bBE);
+        } else {
+            (*a).alInstances.resize((*i).NumOccur);
+            PLY::ElementInstanceList::ParseInstanceListBinary(streamBuffer, buffer, pCur, bufferSize, &(*i), &(*a), nullptr, p_bBE);
+        }
     }
-  }
 
-  ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceListsBinary() succeeded");
-  return true;
+    ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseElementInstanceListsBinary() succeeded");
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::DOM::ParseInstanceBinary(IOStreamBuffer<char> &streamBuffer, DOM* p_pcOut, PLYImporter* loader, bool p_bBE)
-{
-  ai_assert(NULL != p_pcOut);
-  ai_assert(NULL != loader);
+bool PLY::DOM::ParseInstanceBinary(IOStreamBuffer<char> &streamBuffer, DOM *p_pcOut, PLYImporter *loader, bool p_bBE) {
+    ai_assert(nullptr != p_pcOut);
+    ai_assert(nullptr != loader);
 
-  std::vector<char> buffer;
-  streamBuffer.getNextLine(buffer);
+    std::vector<char> buffer;
+    streamBuffer.getNextLine(buffer);
 
-  ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() begin");
+    ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() begin");
 
-  if (!p_pcOut->ParseHeader(streamBuffer, buffer, true))
-  {
-      ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() failure");
-    return false;
-  }
+    if (!p_pcOut->ParseHeader(streamBuffer, buffer, true)) {
+        ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() failure");
+        return false;
+    }
 
-  streamBuffer.getNextBlock(buffer);
-  unsigned int bufferSize = static_cast<unsigned int>(buffer.size());
-  const char* pCur = (char*)&buffer[0];
-  if (!p_pcOut->ParseElementInstanceListsBinary(streamBuffer, buffer, pCur, bufferSize, loader, p_bBE))
-  {
-      ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() failure");
-    return false;
-  }
-  ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() succeeded");
-  return true;
+    streamBuffer.getNextBlock(buffer);
+    unsigned int bufferSize = static_cast<unsigned int>(buffer.size());
+    const char *pCur = (char *)&buffer[0];
+    if (!p_pcOut->ParseElementInstanceListsBinary(streamBuffer, buffer, pCur, bufferSize, loader, p_bBE)) {
+        ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() failure");
+        return false;
+    }
+    ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstanceBinary() succeeded");
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::DOM::ParseInstance(IOStreamBuffer<char> &streamBuffer, DOM* p_pcOut, PLYImporter* loader)
-{
-  ai_assert(NULL != p_pcOut);
-  ai_assert(NULL != loader);
+bool PLY::DOM::ParseInstance(IOStreamBuffer<char> &streamBuffer, DOM *p_pcOut, PLYImporter *loader) {
+    ai_assert(nullptr != p_pcOut);
+    ai_assert(nullptr != loader);
 
-  std::vector<char> buffer;
-  streamBuffer.getNextLine(buffer);
+    std::vector<char> buffer;
+    streamBuffer.getNextLine(buffer);
 
-  ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() begin");
+    ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() begin");
 
-  if (!p_pcOut->ParseHeader(streamBuffer, buffer, false))
-  {
-      ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() failure");
-    return false;
-  }
+    if (!p_pcOut->ParseHeader(streamBuffer, buffer, false)) {
+        ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() failure");
+        return false;
+    }
 
-  //get next line after header
-  streamBuffer.getNextLine(buffer);
-  if (!p_pcOut->ParseElementInstanceLists(streamBuffer, buffer, loader))
-  {
-      ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() failure");
-    return false;
-  }
-  ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() succeeded");
-  return true;
+    //get next line after header
+    streamBuffer.getNextLine(buffer);
+    if (!p_pcOut->ParseElementInstanceLists(streamBuffer, buffer, loader)) {
+        ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() failure");
+        return false;
+    }
+    ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() succeeded");
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
 bool PLY::ElementInstanceList::ParseInstanceList(
-  IOStreamBuffer<char> &streamBuffer,
-  std::vector<char> &buffer,
-  const PLY::Element* pcElement,
-  PLY::ElementInstanceList* p_pcOut,
-  PLYImporter* loader)
-{
-  ai_assert(NULL != pcElement);
-
-  // parse all elements
-  if (EEST_INVALID == pcElement->eSemantic || pcElement->alProperties.empty())
-  {
-    // if the element has an unknown semantic we can skip all lines
-    // However, there could be comments
-    for (unsigned int i = 0; i < pcElement->NumOccur; ++i)
-    {
-      PLY::DOM::SkipComments(buffer);
-      PLY::DOM::SkipLine(buffer);
-      streamBuffer.getNextLine(buffer);
-    }
-  }
-  else
-  {
-    const char* pCur = (const char*)&buffer[0];
-    // be sure to have enough storage
-    for (unsigned int i = 0; i < pcElement->NumOccur; ++i)
-    {
-      if (p_pcOut)
-        PLY::ElementInstance::ParseInstance(pCur, pcElement, &p_pcOut->alInstances[i]);
-      else
-      {
-        ElementInstance elt;
-        PLY::ElementInstance::ParseInstance(pCur, pcElement, &elt);
-
-        // Create vertex or face
-        if (pcElement->eSemantic == EEST_Vertex)
-        {
-          //call loader instance from here
-          loader->LoadVertex(pcElement, &elt, i);
+        IOStreamBuffer<char> &streamBuffer,
+        std::vector<char> &buffer,
+        const PLY::Element *pcElement,
+        PLY::ElementInstanceList *p_pcOut,
+        PLYImporter *loader) {
+    ai_assert(nullptr != pcElement);
+
+    // parse all elements
+    if (EEST_INVALID == pcElement->eSemantic || pcElement->alProperties.empty()) {
+        // if the element has an unknown semantic we can skip all lines
+        // However, there could be comments
+        for (unsigned int i = 0; i < pcElement->NumOccur; ++i) {
+            PLY::DOM::SkipComments(buffer);
+            PLY::DOM::SkipLine(buffer);
+            streamBuffer.getNextLine(buffer);
         }
-        else if (pcElement->eSemantic == EEST_Face)
-        {
-          //call loader instance from here
-          loader->LoadFace(pcElement, &elt, i);
+    } else {
+        const char *pCur = (const char *)&buffer[0];
+        // be sure to have enough storage
+        for (unsigned int i = 0; i < pcElement->NumOccur; ++i) {
+            if (p_pcOut)
+                PLY::ElementInstance::ParseInstance(pCur, pcElement, &p_pcOut->alInstances[i]);
+            else {
+                ElementInstance elt;
+                PLY::ElementInstance::ParseInstance(pCur, pcElement, &elt);
+
+                // Create vertex or face
+                if (pcElement->eSemantic == EEST_Vertex) {
+                    //call loader instance from here
+                    loader->LoadVertex(pcElement, &elt, i);
+                } else if (pcElement->eSemantic == EEST_Face) {
+                    //call loader instance from here
+                    loader->LoadFace(pcElement, &elt, i);
+                } else if (pcElement->eSemantic == EEST_TriStrip) {
+                    //call loader instance from here
+                    loader->LoadFace(pcElement, &elt, i);
+                }
+            }
+
+            streamBuffer.getNextLine(buffer);
+            pCur = (buffer.empty()) ? nullptr : (const char *)&buffer[0];
         }
-        else if (pcElement->eSemantic == EEST_TriStrip)
-        {
-          //call loader instance from here
-          loader->LoadFace(pcElement, &elt, i);
-        }
-      }
-
-      streamBuffer.getNextLine(buffer);
-      pCur = (buffer.empty()) ? NULL : (const char*)&buffer[0];
     }
-  }
-  return true;
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
 bool PLY::ElementInstanceList::ParseInstanceListBinary(
-  IOStreamBuffer<char> &streamBuffer,
-  std::vector<char> &buffer,
-  const char* &pCur,
-  unsigned int &bufferSize,
-  const PLY::Element* pcElement,
-  PLY::ElementInstanceList* p_pcOut,
-  PLYImporter* loader,
-  bool p_bBE /* = false */)
-{
-  ai_assert(NULL != pcElement);
-
-  // we can add special handling code for unknown element semantics since
-  // we can't skip it as a whole block (we don't know its exact size
-  // due to the fact that lists could be contained in the property list
-  // of the unknown element)
-  for (unsigned int i = 0; i < pcElement->NumOccur; ++i)
-  {
-    if (p_pcOut)
-      PLY::ElementInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, pcElement, &p_pcOut->alInstances[i], p_bBE);
-    else
-    {
-      ElementInstance elt;
-      PLY::ElementInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, pcElement, &elt, p_bBE);
-
-      // Create vertex or face
-      if (pcElement->eSemantic == EEST_Vertex)
-      {
-        //call loader instance from here
-        loader->LoadVertex(pcElement, &elt, i);
-      }
-      else if (pcElement->eSemantic == EEST_Face)
-      {
-        //call loader instance from here
-        loader->LoadFace(pcElement, &elt, i);
-      }
-      else if (pcElement->eSemantic == EEST_TriStrip)
-      {
-        //call loader instance from here
-        loader->LoadFace(pcElement, &elt, i);
-      }
+        IOStreamBuffer<char> &streamBuffer,
+        std::vector<char> &buffer,
+        const char *&pCur,
+        unsigned int &bufferSize,
+        const PLY::Element *pcElement,
+        PLY::ElementInstanceList *p_pcOut,
+        PLYImporter *loader,
+        bool p_bBE /* = false */) {
+    ai_assert(nullptr != pcElement);
+
+    // we can add special handling code for unknown element semantics since
+    // we can't skip it as a whole block (we don't know its exact size
+    // due to the fact that lists could be contained in the property list
+    // of the unknown element)
+    for (unsigned int i = 0; i < pcElement->NumOccur; ++i) {
+        if (p_pcOut)
+            PLY::ElementInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, pcElement, &p_pcOut->alInstances[i], p_bBE);
+        else {
+            ElementInstance elt;
+            PLY::ElementInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, pcElement, &elt, p_bBE);
+
+            // Create vertex or face
+            if (pcElement->eSemantic == EEST_Vertex) {
+                //call loader instance from here
+                loader->LoadVertex(pcElement, &elt, i);
+            } else if (pcElement->eSemantic == EEST_Face) {
+                //call loader instance from here
+                loader->LoadFace(pcElement, &elt, i);
+            } else if (pcElement->eSemantic == EEST_TriStrip) {
+                //call loader instance from here
+                loader->LoadFace(pcElement, &elt, i);
+            }
+        }
     }
-  }
-  return true;
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::ElementInstance::ParseInstance(const char* &pCur,
-  const PLY::Element* pcElement,
-  PLY::ElementInstance* p_pcOut)
-{
-  ai_assert(NULL != pcElement);
-  ai_assert(NULL != p_pcOut);
-
-  // allocate enough storage
-  p_pcOut->alProperties.resize(pcElement->alProperties.size());
-
-  std::vector<PLY::PropertyInstance>::iterator i = p_pcOut->alProperties.begin();
-  std::vector<PLY::Property>::const_iterator  a = pcElement->alProperties.begin();
-  for (; i != p_pcOut->alProperties.end(); ++i, ++a)
-  {
-    if (!(PLY::PropertyInstance::ParseInstance(pCur, &(*a), &(*i))))
-    {
-        ASSIMP_LOG_WARN("Unable to parse property instance. "
-        "Skipping this element instance");
-
-      PLY::PropertyInstance::ValueUnion v = PLY::PropertyInstance::DefaultValue((*a).eType);
-      (*i).avList.push_back(v);
+bool PLY::ElementInstance::ParseInstance(const char *&pCur,
+        const PLY::Element *pcElement,
+        PLY::ElementInstance *p_pcOut) {
+    ai_assert(nullptr != pcElement);
+    ai_assert(nullptr != p_pcOut);
+
+    // allocate enough storage
+    p_pcOut->alProperties.resize(pcElement->alProperties.size());
+
+    std::vector<PLY::PropertyInstance>::iterator i = p_pcOut->alProperties.begin();
+    std::vector<PLY::Property>::const_iterator a = pcElement->alProperties.begin();
+    for (; i != p_pcOut->alProperties.end(); ++i, ++a) {
+        if (!(PLY::PropertyInstance::ParseInstance(pCur, &(*a), &(*i)))) {
+            ASSIMP_LOG_WARN("Unable to parse property instance. "
+                            "Skipping this element instance");
+
+            PLY::PropertyInstance::ValueUnion v = PLY::PropertyInstance::DefaultValue((*a).eType);
+            (*i).avList.push_back(v);
+        }
     }
-  }
-  return true;
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
 bool PLY::ElementInstance::ParseInstanceBinary(
-  IOStreamBuffer<char> &streamBuffer,
-  std::vector<char> &buffer,
-  const char* &pCur,
-  unsigned int &bufferSize,
-  const PLY::Element* pcElement,
-  PLY::ElementInstance* p_pcOut,
-  bool p_bBE /* = false */)
-{
-  ai_assert(NULL != pcElement);
-  ai_assert(NULL != p_pcOut);
-
-  // allocate enough storage
-  p_pcOut->alProperties.resize(pcElement->alProperties.size());
-
-  std::vector<PLY::PropertyInstance>::iterator i = p_pcOut->alProperties.begin();
-  std::vector<PLY::Property>::const_iterator   a = pcElement->alProperties.begin();
-  for (; i != p_pcOut->alProperties.end(); ++i, ++a)
-  {
-    if (!(PLY::PropertyInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, &(*a), &(*i), p_bBE)))
-    {
-        ASSIMP_LOG_WARN("Unable to parse binary property instance. "
-        "Skipping this element instance");
-
-      (*i).avList.push_back(PLY::PropertyInstance::DefaultValue((*a).eType));
+        IOStreamBuffer<char> &streamBuffer,
+        std::vector<char> &buffer,
+        const char *&pCur,
+        unsigned int &bufferSize,
+        const PLY::Element *pcElement,
+        PLY::ElementInstance *p_pcOut,
+        bool p_bBE /* = false */) {
+    ai_assert(nullptr != pcElement);
+    ai_assert(nullptr != p_pcOut);
+
+    // allocate enough storage
+    p_pcOut->alProperties.resize(pcElement->alProperties.size());
+
+    std::vector<PLY::PropertyInstance>::iterator i = p_pcOut->alProperties.begin();
+    std::vector<PLY::Property>::const_iterator a = pcElement->alProperties.begin();
+    for (; i != p_pcOut->alProperties.end(); ++i, ++a) {
+        if (!(PLY::PropertyInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, &(*a), &(*i), p_bBE))) {
+            ASSIMP_LOG_WARN("Unable to parse binary property instance. "
+                            "Skipping this element instance");
+
+            (*i).avList.push_back(PLY::PropertyInstance::DefaultValue((*a).eType));
+        }
     }
-  }
-  return true;
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::PropertyInstance::ParseInstance(const char* &pCur,
-  const PLY::Property* prop, PLY::PropertyInstance* p_pcOut)
-{
-  ai_assert(NULL != prop);
-  ai_assert(NULL != p_pcOut);
-
-  // skip spaces at the beginning
-  if (!SkipSpaces(&pCur))
-  {
-    return false;
-  }
+bool PLY::PropertyInstance::ParseInstance(const char *&pCur,
+        const PLY::Property *prop, PLY::PropertyInstance *p_pcOut) {
+    ai_assert(nullptr != prop);
+    ai_assert(nullptr != p_pcOut);
 
-  if (prop->bIsList)
-  {
-    // parse the number of elements in the list
-    PLY::PropertyInstance::ValueUnion v;
-    PLY::PropertyInstance::ParseValue(pCur, prop->eFirstType, &v);
+    // skip spaces at the beginning
+    if (!SkipSpaces(&pCur)) {
+        return false;
+    }
 
-    // convert to unsigned int
-    unsigned int iNum = PLY::PropertyInstance::ConvertTo<unsigned int>(v, prop->eFirstType);
+    if (prop->bIsList) {
+        // parse the number of elements in the list
+        PLY::PropertyInstance::ValueUnion v;
+        PLY::PropertyInstance::ParseValue(pCur, prop->eFirstType, &v);
 
-    // parse all list elements
-    p_pcOut->avList.resize(iNum);
-    for (unsigned int i = 0; i < iNum; ++i)
-    {
-      if (!SkipSpaces(&pCur))
-        return false;
+        // convert to unsigned int
+        unsigned int iNum = PLY::PropertyInstance::ConvertTo<unsigned int>(v, prop->eFirstType);
 
-      PLY::PropertyInstance::ParseValue(pCur, prop->eType, &p_pcOut->avList[i]);
-    }
-  }
-  else
-  {
-    // parse the property
-    PLY::PropertyInstance::ValueUnion v;
+        // parse all list elements
+        p_pcOut->avList.resize(iNum);
+        for (unsigned int i = 0; i < iNum; ++i) {
+            if (!SkipSpaces(&pCur))
+                return false;
 
-    PLY::PropertyInstance::ParseValue(pCur, prop->eType, &v);
-    p_pcOut->avList.push_back(v);
-  }
-  SkipSpacesAndLineEnd(&pCur);
-  return true;
+            PLY::PropertyInstance::ParseValue(pCur, prop->eType, &p_pcOut->avList[i]);
+        }
+    } else {
+        // parse the property
+        PLY::PropertyInstance::ValueUnion v;
+
+        PLY::PropertyInstance::ParseValue(pCur, prop->eType, &v);
+        p_pcOut->avList.push_back(v);
+    }
+    SkipSpacesAndLineEnd(&pCur);
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
 bool PLY::PropertyInstance::ParseInstanceBinary(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer,
-  const char* &pCur,
-  unsigned int &bufferSize,
-  const PLY::Property* prop,
-  PLY::PropertyInstance* p_pcOut,
-  bool p_bBE)
-{
-  ai_assert(NULL != prop);
-  ai_assert(NULL != p_pcOut);
-
-  // parse all elements
-  if (prop->bIsList)
-  {
-    // parse the number of elements in the list
-    PLY::PropertyInstance::ValueUnion v;
-    PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eFirstType, &v, p_bBE);
-
-    // convert to unsigned int
-    unsigned int iNum = PLY::PropertyInstance::ConvertTo<unsigned int>(v, prop->eFirstType);
-
-    // parse all list elements
-    p_pcOut->avList.resize(iNum);
-    for (unsigned int i = 0; i < iNum; ++i)
-    {
-      PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eType, &p_pcOut->avList[i], p_bBE);
+        const char *&pCur,
+        unsigned int &bufferSize,
+        const PLY::Property *prop,
+        PLY::PropertyInstance *p_pcOut,
+        bool p_bBE) {
+    ai_assert(nullptr != prop);
+    ai_assert(nullptr != p_pcOut);
+
+    // parse all elements
+    if (prop->bIsList) {
+        // parse the number of elements in the list
+        PLY::PropertyInstance::ValueUnion v;
+        PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eFirstType, &v, p_bBE);
+
+        // convert to unsigned int
+        unsigned int iNum = PLY::PropertyInstance::ConvertTo<unsigned int>(v, prop->eFirstType);
+
+        // parse all list elements
+        p_pcOut->avList.resize(iNum);
+        for (unsigned int i = 0; i < iNum; ++i) {
+            PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eType, &p_pcOut->avList[i], p_bBE);
+        }
+    } else {
+        // parse the property
+        PLY::PropertyInstance::ValueUnion v;
+        PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eType, &v, p_bBE);
+        p_pcOut->avList.push_back(v);
     }
-  }
-  else
-  {
-    // parse the property
-    PLY::PropertyInstance::ValueUnion v;
-    PLY::PropertyInstance::ParseValueBinary(streamBuffer, buffer, pCur, bufferSize, prop->eType, &v, p_bBE);
-    p_pcOut->avList.push_back(v);
-  }
-  return true;
+    return true;
 }
 
 // ------------------------------------------------------------------------------------------------
-PLY::PropertyInstance::ValueUnion PLY::PropertyInstance::DefaultValue(PLY::EDataType eType)
-{
-  PLY::PropertyInstance::ValueUnion out;
+PLY::PropertyInstance::ValueUnion PLY::PropertyInstance::DefaultValue(PLY::EDataType eType) {
+    PLY::PropertyInstance::ValueUnion out;
 
-  switch (eType)
-  {
-  case EDT_Float:
-    out.fFloat = 0.f;
-    return out;
+    switch (eType) {
+    case EDT_Float:
+        out.fFloat = 0.f;
+        return out;
 
-  case EDT_Double:
-    out.fDouble = 0.;
-    return out;
+    case EDT_Double:
+        out.fDouble = 0.;
+        return out;
 
-  default:;
-  };
-  out.iUInt = 0;
-  return out;
+    default:;
+    };
+    out.iUInt = 0;
+    return out;
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::PropertyInstance::ParseValue(const char* &pCur,
-  PLY::EDataType eType,
-  PLY::PropertyInstance::ValueUnion* out)
-{
-  ai_assert(NULL != pCur);
-  ai_assert(NULL != out);
-
-  //calc element size
-  bool ret = true;
-  switch (eType)
-  {
-  case EDT_UInt:
-  case EDT_UShort:
-  case EDT_UChar:
-
-    out->iUInt = (uint32_t)strtoul10(pCur, &pCur);
-    break;
-
-  case EDT_Int:
-  case EDT_Short:
-  case EDT_Char:
-
-    out->iInt = (int32_t)strtol10(pCur, &pCur);
-    break;
-
-  case EDT_Float:
-    // technically this should cast to float, but people tend to use float descriptors for double data
-    // this is the best way to not risk losing precision on import and it doesn't hurt to do this
-    ai_real f;
-    pCur = fast_atoreal_move<ai_real>(pCur, f);
-    out->fFloat = (ai_real)f;
-    break;
-
-  case EDT_Double:
-    double d;
-    pCur = fast_atoreal_move<double>(pCur, d);
-    out->fDouble = (double)d;
-    break;
-
-  case EDT_INVALID:
-  default:
-    ret = false;
-    break;
-  }
+bool PLY::PropertyInstance::ParseValue(const char *&pCur,
+        PLY::EDataType eType,
+        PLY::PropertyInstance::ValueUnion *out) {
+    ai_assert(nullptr != pCur);
+    ai_assert(nullptr != out);
+
+    //calc element size
+    bool ret = true;
+    switch (eType) {
+    case EDT_UInt:
+    case EDT_UShort:
+    case EDT_UChar:
+
+        out->iUInt = (uint32_t)strtoul10(pCur, &pCur);
+        break;
+
+    case EDT_Int:
+    case EDT_Short:
+    case EDT_Char:
+
+        out->iInt = (int32_t)strtol10(pCur, &pCur);
+        break;
+
+    case EDT_Float:
+        // technically this should cast to float, but people tend to use float descriptors for double data
+        // this is the best way to not risk losing precision on import and it doesn't hurt to do this
+        ai_real f;
+        pCur = fast_atoreal_move<ai_real>(pCur, f);
+        out->fFloat = (ai_real)f;
+        break;
+
+    case EDT_Double:
+        double d;
+        pCur = fast_atoreal_move<double>(pCur, d);
+        out->fDouble = (double)d;
+        break;
+
+    case EDT_INVALID:
+    default:
+        ret = false;
+        break;
+    }
 
-  return ret;
+    return ret;
 }
 
 // ------------------------------------------------------------------------------------------------
 bool PLY::PropertyInstance::ParseValueBinary(IOStreamBuffer<char> &streamBuffer,
-  std::vector<char> &buffer,
-  const char* &pCur,
-  unsigned int &bufferSize,
-  PLY::EDataType eType,
-  PLY::PropertyInstance::ValueUnion* out,
-  bool p_bBE)
-{
-  ai_assert(NULL != out);
-
-  //calc element size
-  unsigned int lsize = 0;
-  switch (eType)
-  {
-  case EDT_Char:
-  case EDT_UChar:
-    lsize = 1;
-    break;
-
-  case EDT_UShort:
-  case EDT_Short:
-    lsize = 2;
-    break;
-
-  case EDT_UInt:
-  case EDT_Int:
-  case EDT_Float:
-    lsize = 4;
-    break;
-
-  case EDT_Double:
-    lsize = 8;
-    break;
-
-  case EDT_INVALID:
-  default:
-      break;
-  }
+        std::vector<char> &buffer,
+        const char *&pCur,
+        unsigned int &bufferSize,
+        PLY::EDataType eType,
+        PLY::PropertyInstance::ValueUnion *out,
+        bool p_bBE) {
+    ai_assert(nullptr != out);
+
+    //calc element size
+    unsigned int lsize = 0;
+    switch (eType) {
+    case EDT_Char:
+    case EDT_UChar:
+        lsize = 1;
+        break;
+
+    case EDT_UShort:
+    case EDT_Short:
+        lsize = 2;
+        break;
+
+    case EDT_UInt:
+    case EDT_Int:
+    case EDT_Float:
+        lsize = 4;
+        break;
+
+    case EDT_Double:
+        lsize = 8;
+        break;
+
+    case EDT_INVALID:
+    default:
+        break;
+    }
 
-  //read the next file block if needed
-  if (bufferSize < lsize)
-  {
-    std::vector<char> nbuffer;
-    if (streamBuffer.getNextBlock(nbuffer))
-    {
-      //concat buffer contents
-      buffer = std::vector<char>(buffer.end() - bufferSize, buffer.end());
-      buffer.insert(buffer.end(), nbuffer.begin(), nbuffer.end());
-      nbuffer.clear();
-      bufferSize = static_cast<unsigned int>(buffer.size());
-      pCur = (char*)&buffer[0];
+    //read the next file block if needed
+    if (bufferSize < lsize) {
+        std::vector<char> nbuffer;
+        if (streamBuffer.getNextBlock(nbuffer)) {
+            //concat buffer contents
+            buffer = std::vector<char>(buffer.end() - bufferSize, buffer.end());
+            buffer.insert(buffer.end(), nbuffer.begin(), nbuffer.end());
+            nbuffer.clear();
+            bufferSize = static_cast<unsigned int>(buffer.size());
+            pCur = (char *)&buffer[0];
+        } else {
+            throw DeadlyImportError("Invalid .ply file: File corrupted");
+        }
     }
-    else
-    {
-      throw DeadlyImportError("Invalid .ply file: File corrupted");
+
+    bool ret = true;
+    switch (eType) {
+    case EDT_UInt: {
+        uint32_t t;
+        memcpy(&t, pCur, sizeof(uint32_t));
+        pCur += sizeof(uint32_t);
+
+        // Swap endianness
+        if (p_bBE) ByteSwap::Swap(&t);
+        out->iUInt = t;
+        break;
     }
-  }
 
-  bool ret = true;
-  switch (eType)
-  {
-  case EDT_UInt:
-  {
-    uint32_t t;
-    memcpy(&t, pCur, sizeof(uint32_t));
-    pCur += sizeof(uint32_t);
-
-    // Swap endianness
-    if (p_bBE)ByteSwap::Swap(&t);
-    out->iUInt = t;
-    break;
-  }
+    case EDT_UShort: {
+        uint16_t t;
+        memcpy(&t, pCur, sizeof(uint16_t));
+        pCur += sizeof(uint16_t);
 
-  case EDT_UShort:
-  {
-    uint16_t t;
-    memcpy(&t, pCur, sizeof(uint16_t));
-    pCur += sizeof(uint16_t);
-
-    // Swap endianness
-    if (p_bBE)ByteSwap::Swap(&t);
-    out->iUInt = t;
-    break;
-  }
+        // Swap endianness
+        if (p_bBE) ByteSwap::Swap(&t);
+        out->iUInt = t;
+        break;
+    }
 
-  case EDT_UChar:
-  {
-    uint8_t t;
-    memcpy(&t, pCur, sizeof(uint8_t));
-    pCur += sizeof(uint8_t);
-    out->iUInt = t;
-    break;
-  }
+    case EDT_UChar: {
+        uint8_t t;
+        memcpy(&t, pCur, sizeof(uint8_t));
+        pCur += sizeof(uint8_t);
+        out->iUInt = t;
+        break;
+    }
 
-  case EDT_Int:
-  {
-    int32_t t;
-    memcpy(&t, pCur, sizeof(int32_t));
-    pCur += sizeof(int32_t);
-
-    // Swap endianness
-    if (p_bBE)ByteSwap::Swap(&t);
-    out->iInt = t;
-    break;
-  }
+    case EDT_Int: {
+        int32_t t;
+        memcpy(&t, pCur, sizeof(int32_t));
+        pCur += sizeof(int32_t);
 
-  case EDT_Short:
-  {
-    int16_t t;
-    memcpy(&t, pCur, sizeof(int16_t));
-    pCur += sizeof(int16_t);
-
-    // Swap endianness
-    if (p_bBE)ByteSwap::Swap(&t);
-    out->iInt = t;
-    break;
-  }
+        // Swap endianness
+        if (p_bBE) ByteSwap::Swap(&t);
+        out->iInt = t;
+        break;
+    }
 
-  case EDT_Char:
-  {
-    int8_t t;
-    memcpy(&t, pCur, sizeof(int8_t));
-    pCur += sizeof(int8_t);
-    out->iInt = t;
-    break;
-  }
+    case EDT_Short: {
+        int16_t t;
+        memcpy(&t, pCur, sizeof(int16_t));
+        pCur += sizeof(int16_t);
 
-  case EDT_Float:
-  {
-    float t;
-    memcpy(&t, pCur, sizeof(float));
-    pCur += sizeof(float);
-
-    // Swap endianness
-    if (p_bBE)ByteSwap::Swap(&t);
-    out->fFloat = t;
-    break;
-  }
-  case EDT_Double:
-  {
-    double t;
-    memcpy(&t, pCur, sizeof(double));
-    pCur += sizeof(double);
-
-    // Swap endianness
-    if (p_bBE)ByteSwap::Swap(&t);
-    out->fDouble = t;
-    break;
-  }
-  default:
-    ret = false;
-  }
+        // Swap endianness
+        if (p_bBE) ByteSwap::Swap(&t);
+        out->iInt = t;
+        break;
+    }
+
+    case EDT_Char: {
+        int8_t t;
+        memcpy(&t, pCur, sizeof(int8_t));
+        pCur += sizeof(int8_t);
+        out->iInt = t;
+        break;
+    }
+
+    case EDT_Float: {
+        float t;
+        memcpy(&t, pCur, sizeof(float));
+        pCur += sizeof(float);
 
-  bufferSize -= lsize;
+        // Swap endianness
+        if (p_bBE) ByteSwap::Swap(&t);
+        out->fFloat = t;
+        break;
+    }
+    case EDT_Double: {
+        double t;
+        memcpy(&t, pCur, sizeof(double));
+        pCur += sizeof(double);
+
+        // Swap endianness
+        if (p_bBE) ByteSwap::Swap(&t);
+        out->fDouble = t;
+        break;
+    }
+    default:
+        ret = false;
+    }
 
-  return ret;
+    bufferSize -= lsize;
+
+    return ret;
 }
 
 #endif // !! ASSIMP_BUILD_NO_PLY_IMPORTER

+ 224 - 246
code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp

@@ -43,27 +43,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
 
 #include "Q3BSPFileImporter.h"
-#include "Q3BSPFileParser.h"
 #include "Q3BSPFileData.h"
+#include "Q3BSPFileParser.h"
 
 #include <assimp/DefaultLogger.hpp>
 
 #ifdef ASSIMP_BUILD_NO_OWN_ZLIB
-#   include <zlib.h>
+#include <zlib.h>
 #else
-#   include "../contrib/zlib/zlib.h"
+#include "../contrib/zlib/zlib.h"
 #endif
 
-#include <assimp/types.h>
-#include <assimp/mesh.h>
-#include <assimp/scene.h>
-#include <assimp/ai_assert.h>
 #include <assimp/DefaultIOSystem.h>
+#include <assimp/StringComparison.h>
 #include <assimp/ZipArchiveIOSystem.h>
+#include <assimp/ai_assert.h>
 #include <assimp/importerdesc.h>
-#include <vector>
+#include <assimp/mesh.h>
+#include <assimp/scene.h>
+#include <assimp/types.h>
 #include <sstream>
-#include <assimp/StringComparison.h>
+#include <vector>
 
 static const aiImporterDesc desc = {
     "Quake III BSP Importer",
@@ -84,7 +84,7 @@ using namespace Q3BSP;
 
 // ------------------------------------------------------------------------------------------------
 //  Local function to create a material key name.
-static void createKey( int id1, int id2, std::string &key ) {
+static void createKey(int id1, int id2, std::string &key) {
     std::ostringstream str;
     str << id1 << "." << id2;
     key = str.str();
@@ -92,27 +92,27 @@ static void createKey( int id1, int id2, std::string &key ) {
 
 // ------------------------------------------------------------------------------------------------
 //  Local function to extract the texture ids from a material key-name.
-static void extractIds( const std::string &key, int &id1, int &id2 ) {
+static void extractIds(const std::string &key, int &id1, int &id2) {
     id1 = -1;
     id2 = -1;
     if (key.empty()) {
         return;
     }
 
-    const std::string::size_type pos = key.find( "." );
+    const std::string::size_type pos = key.find(".");
     if (std::string::npos == pos) {
         return;
     }
 
-    std::string tmp1 = key.substr( 0, pos );
-    std::string tmp2 = key.substr( pos + 1, key.size() - pos - 1 );
-    id1 = atoi( tmp1.c_str() );
-    id2 = atoi( tmp2.c_str() );
+    std::string tmp1 = key.substr(0, pos);
+    std::string tmp2 = key.substr(pos + 1, key.size() - pos - 1);
+    id1 = atoi(tmp1.c_str());
+    id2 = atoi(tmp2.c_str());
 }
 
 // ------------------------------------------------------------------------------------------------
 //  Local helper function to normalize filenames.
-static void normalizePathName( const std::string &rPath, std::string &normalizedPath ) {
+static void normalizePathName(const std::string &rPath, std::string &normalizedPath) {
     normalizedPath = "";
     if (rPath.empty()) {
         return;
@@ -125,12 +125,12 @@ static void normalizePathName( const std::string &rPath, std::string &normalized
 #endif
 
     static const unsigned int numDelimiters = 2;
-    const char delimiters[ numDelimiters ] = { '/', '\\' };
+    const char delimiters[numDelimiters] = { '/', '\\' };
     normalizedPath = rPath;
     for (const char delimiter : delimiters) {
-        for ( size_t j=0; j<normalizedPath.size(); ++j ) {
-            if ( normalizedPath[j] == delimiter ) {
-                normalizedPath[ j ] = sep[ 0 ];
+        for (size_t j = 0; j < normalizedPath.size(); ++j) {
+            if (normalizedPath[j] == delimiter) {
+                normalizedPath[j] = sep[0];
             }
         }
     }
@@ -138,11 +138,8 @@ static void normalizePathName( const std::string &rPath, std::string &normalized
 
 // ------------------------------------------------------------------------------------------------
 //  Constructor.
-Q3BSPFileImporter::Q3BSPFileImporter()
-: m_pCurrentMesh( nullptr )
-, m_pCurrentFace(nullptr)
-, m_MaterialLookupMap()
-, mTextures() {
+Q3BSPFileImporter::Q3BSPFileImporter() :
+        m_pCurrentMesh(nullptr), m_pCurrentFace(nullptr), m_MaterialLookupMap(), mTextures() {
     // empty
 }
 
@@ -153,9 +150,9 @@ Q3BSPFileImporter::~Q3BSPFileImporter() {
     m_pCurrentFace = nullptr;
 
     // Clear face-to-material map
-    for ( FaceMap::iterator it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it ) {
+    for (FaceMap::iterator it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it) {
         const std::string &matName = it->first;
-        if ( !matName.empty() ) {
+        if (!matName.empty()) {
             delete it->second;
         }
     }
@@ -164,9 +161,9 @@ Q3BSPFileImporter::~Q3BSPFileImporter() {
 
 // ------------------------------------------------------------------------------------------------
 //  Returns true, if the loader can read this.
-bool Q3BSPFileImporter::CanRead( const std::string& rFile, IOSystem* /*pIOHandler*/, bool checkSig ) const {
-    if(!checkSig) {
-        return SimpleExtensionCheck( rFile, "pk3", "bsp" );
+bool Q3BSPFileImporter::CanRead(const std::string &rFile, IOSystem * /*pIOHandler*/, bool checkSig) const {
+    if (!checkSig) {
+        return SimpleExtensionCheck(rFile, "pk3", "bsp");
     }
 
     return false;
@@ -174,69 +171,69 @@ bool Q3BSPFileImporter::CanRead( const std::string& rFile, IOSystem* /*pIOHandle
 
 // ------------------------------------------------------------------------------------------------
 //  Adds extensions.
-const aiImporterDesc* Q3BSPFileImporter::GetInfo () const {
+const aiImporterDesc *Q3BSPFileImporter::GetInfo() const {
     return &desc;
 }
 
 // ------------------------------------------------------------------------------------------------
 //  Import method.
-void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene* scene, IOSystem* ioHandler) {
-    ZipArchiveIOSystem Archive( ioHandler, rFile );
-    if ( !Archive.isOpen() ) {
-        throw DeadlyImportError( "Failed to open file " + rFile + "." );
+void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene *scene, IOSystem *ioHandler) {
+    ZipArchiveIOSystem Archive(ioHandler, rFile);
+    if (!Archive.isOpen()) {
+        throw DeadlyImportError("Failed to open file " + rFile + ".");
     }
 
-    std::string archiveName( "" ), mapName( "" );
-    separateMapName( rFile, archiveName, mapName );
+    std::string archiveName(""), mapName("");
+    separateMapName(rFile, archiveName, mapName);
 
-    if ( mapName.empty() ) {
-        if ( !findFirstMapInArchive( Archive, mapName ) ) {
+    if (mapName.empty()) {
+        if (!findFirstMapInArchive(Archive, mapName)) {
             return;
         }
     }
 
-    Q3BSPFileParser fileParser( mapName, &Archive );
+    Q3BSPFileParser fileParser(mapName, &Archive);
     Q3BSPModel *pBSPModel = fileParser.getModel();
-    if ( nullptr != pBSPModel ) {
-        CreateDataFromImport( pBSPModel, scene, &Archive );
+    if (nullptr != pBSPModel) {
+        CreateDataFromImport(pBSPModel, scene, &Archive);
     }
 }
 
 // ------------------------------------------------------------------------------------------------
 //  Separates the map name from the import name.
-void Q3BSPFileImporter::separateMapName( const std::string &importName, std::string &archiveName, std::string &mapName ) {
+void Q3BSPFileImporter::separateMapName(const std::string &importName, std::string &archiveName, std::string &mapName) {
     archiveName = "";
     mapName = "";
     if (importName.empty()) {
         return;
     }
 
-    const std::string::size_type pos = importName.rfind( "," );
-    if ( std::string::npos == pos ) {
+    const std::string::size_type pos = importName.rfind(",");
+    if (std::string::npos == pos) {
         archiveName = importName;
         return;
     }
 
-    archiveName = importName.substr( 0, pos );
-    mapName = importName.substr( pos, importName.size() - pos - 1 );
+    archiveName = importName.substr(0, pos);
+    mapName = importName.substr(pos, importName.size() - pos - 1);
 }
 
 // ------------------------------------------------------------------------------------------------
 //  Returns the first map in the map archive.
-bool Q3BSPFileImporter::findFirstMapInArchive(ZipArchiveIOSystem &bspArchive, std::string &mapName ) {
+bool Q3BSPFileImporter::findFirstMapInArchive(ZipArchiveIOSystem &bspArchive, std::string &mapName) {
     mapName = "";
     std::vector<std::string> fileList;
-    bspArchive.getFileListExtension( fileList, "bsp" );
+    bspArchive.getFileListExtension(fileList, "bsp");
     if (fileList.empty()) {
         return false;
     }
 
-    std::vector<std::string>::iterator it( fileList.begin() );
-    for ( ; it != fileList.end(); ++it ) {
-        const std::string::size_type pos = (*it).find( "maps/" );
-        if ( std::string::npos != pos ) {
-            std::string::size_type extPos = (*it).find( ".bsp" );
-            if ( std::string::npos != extPos ) {
+    std::vector<std::string>::iterator it(fileList.begin());
+    for (; it != fileList.end(); ++it) {
+        const std::string::size_type pos = (*it).find("maps/");
+        if (std::string::npos != pos) {
+            std::string::size_type extPos = (*it).find(".bsp");
+            if (std::string::npos != extPos) {
                 mapName = *it;
                 return true;
             }
@@ -248,122 +245,122 @@ bool Q3BSPFileImporter::findFirstMapInArchive(ZipArchiveIOSystem &bspArchive, st
 
 // ------------------------------------------------------------------------------------------------
 //  Creates the assimp specific data.
-void Q3BSPFileImporter::CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
-    ZipArchiveIOSystem *pArchive ) {
+void Q3BSPFileImporter::CreateDataFromImport(const Q3BSP::Q3BSPModel *pModel, aiScene *pScene,
+        ZipArchiveIOSystem *pArchive) {
     if (nullptr == pModel || nullptr == pScene) {
         return;
     }
 
     pScene->mRootNode = new aiNode;
-    if ( !pModel->m_ModelName.empty() ) {
-        pScene->mRootNode->mName.Set( pModel->m_ModelName );
+    if (!pModel->m_ModelName.empty()) {
+        pScene->mRootNode->mName.Set(pModel->m_ModelName);
     }
 
     // Create the face to material relation map
-    createMaterialMap( pModel );
+    createMaterialMap(pModel);
 
     // Create all nodes
-    CreateNodes( pModel, pScene, pScene->mRootNode );
+    CreateNodes(pModel, pScene, pScene->mRootNode);
 
     // Create the assigned materials
-    createMaterials( pModel, pScene, pArchive );
+    createMaterials(pModel, pScene, pArchive);
 }
 
 // ------------------------------------------------------------------------------------------------
 //  Creates all assimp nodes.
-void Q3BSPFileImporter::CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
-        aiNode *pParent ) {
-    if ( nullptr == pModel ) {
+void Q3BSPFileImporter::CreateNodes(const Q3BSP::Q3BSPModel *pModel, aiScene *pScene,
+        aiNode *pParent) {
+    if (nullptr == pModel) {
         return;
     }
 
-    unsigned int matIdx( 0 );
-    std::vector<aiMesh*> MeshArray;
-    std::vector<aiNode*> NodeArray;
-    for ( FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it ) {
-        std::vector<Q3BSP::sQ3BSPFace*> *pArray = (*it).second;
-        size_t numVerts = countData( *pArray );
-        if ( 0 != numVerts ) {
-            aiMesh *pMesh( nullptr );
-            aiNode *pNode = CreateTopology( pModel, matIdx, *pArray, &pMesh );
-            if ( nullptr != pNode ) {
-                NodeArray.push_back( pNode );
-                MeshArray.push_back( pMesh );
+    unsigned int matIdx(0);
+    std::vector<aiMesh *> MeshArray;
+    std::vector<aiNode *> NodeArray;
+    for (FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it) {
+        std::vector<Q3BSP::sQ3BSPFace *> *pArray = (*it).second;
+        size_t numVerts = countData(*pArray);
+        if (0 != numVerts) {
+            aiMesh *pMesh(nullptr);
+            aiNode *pNode = CreateTopology(pModel, matIdx, *pArray, &pMesh);
+            if (nullptr != pNode) {
+                NodeArray.push_back(pNode);
+                MeshArray.push_back(pMesh);
             }
         }
         matIdx++;
     }
 
-    pScene->mNumMeshes = static_cast<unsigned int>( MeshArray.size() );
-    if ( pScene->mNumMeshes > 0 ) {
-        pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
-        for ( size_t i = 0; i < MeshArray.size(); i++ ) {
-            aiMesh *pMesh = MeshArray[ i ];
-            if ( nullptr != pMesh ) {
-                pScene->mMeshes[ i ] = pMesh;
+    pScene->mNumMeshes = static_cast<unsigned int>(MeshArray.size());
+    if (pScene->mNumMeshes > 0) {
+        pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
+        for (size_t i = 0; i < MeshArray.size(); i++) {
+            aiMesh *pMesh = MeshArray[i];
+            if (nullptr != pMesh) {
+                pScene->mMeshes[i] = pMesh;
             }
         }
     }
 
     pParent->mNumChildren = static_cast<unsigned int>(MeshArray.size());
-    pParent->mChildren = new aiNode*[ pScene->mRootNode->mNumChildren ];
-    for ( size_t i=0; i<NodeArray.size(); i++ ) {
-        aiNode *pNode = NodeArray[ i ];
+    pParent->mChildren = new aiNode *[pScene->mRootNode->mNumChildren];
+    for (size_t i = 0; i < NodeArray.size(); i++) {
+        aiNode *pNode = NodeArray[i];
         pNode->mParent = pParent;
-        pParent->mChildren[ i ] = pNode;
-        pParent->mChildren[ i ]->mMeshes[ 0 ] = static_cast<unsigned int>(i);
+        pParent->mChildren[i] = pNode;
+        pParent->mChildren[i]->mMeshes[0] = static_cast<unsigned int>(i);
     }
 }
 
 // ------------------------------------------------------------------------------------------------
 //  Creates the topology.
-aiNode *Q3BSPFileImporter::CreateTopology( const Q3BSP::Q3BSPModel *pModel, unsigned int materialIdx,
-        std::vector<sQ3BSPFace*> &rArray, aiMesh **pMesh ) {
-    size_t numVerts = countData( rArray );
-    if ( 0 == numVerts ) {
+aiNode *Q3BSPFileImporter::CreateTopology(const Q3BSP::Q3BSPModel *pModel, unsigned int materialIdx,
+        std::vector<sQ3BSPFace *> &rArray, aiMesh **pMesh) {
+    size_t numVerts = countData(rArray);
+    if (0 == numVerts) {
         return nullptr;
     }
 
-    size_t numFaces = countFaces( rArray );
-    if ( 0 == numFaces ) {
+    size_t numFaces = countFaces(rArray);
+    if (0 == numFaces) {
         return nullptr;
     }
 
     aiMesh *mesh = new aiMesh;
-    size_t numTriangles = countTriangles( rArray );
+    size_t numTriangles = countTriangles(rArray);
     mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
 
-    mesh->mFaces = new aiFace[ numTriangles ];
+    mesh->mFaces = new aiFace[numTriangles];
     mesh->mNumFaces = static_cast<unsigned int>(numTriangles);
 
     mesh->mNumVertices = static_cast<unsigned int>(numVerts);
-    mesh->mVertices = new aiVector3D[ numVerts ];
-    mesh->mNormals =  new aiVector3D[ numVerts ];
-    mesh->mTextureCoords[ 0 ] = new aiVector3D[ numVerts ];
-    mesh->mTextureCoords[ 1 ] = new aiVector3D[ numVerts ];
+    mesh->mVertices = new aiVector3D[numVerts];
+    mesh->mNormals = new aiVector3D[numVerts];
+    mesh->mTextureCoords[0] = new aiVector3D[numVerts];
+    mesh->mTextureCoords[1] = new aiVector3D[numVerts];
     mesh->mMaterialIndex = materialIdx;
 
     unsigned int faceIdx = 0;
     unsigned int vertIdx = 0;
-    mesh->mNumUVComponents[ 0 ] = 2;
-    mesh->mNumUVComponents[ 1 ] = 2;
-    for ( std::vector<sQ3BSPFace*>::const_iterator it = rArray.begin(); it != rArray.end(); ++it ) {
+    mesh->mNumUVComponents[0] = 2;
+    mesh->mNumUVComponents[1] = 2;
+    for (std::vector<sQ3BSPFace *>::const_iterator it = rArray.begin(); it != rArray.end(); ++it) {
         Q3BSP::sQ3BSPFace *pQ3BSPFace = *it;
-        ai_assert( NULL != pQ3BSPFace );
-        if ( nullptr == pQ3BSPFace ) {
+        ai_assert(nullptr != pQ3BSPFace);
+        if (nullptr == pQ3BSPFace) {
             continue;
         }
 
-        if ( pQ3BSPFace->iNumOfFaceVerts > 0 ) {
-            if ( pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh ) {
-                createTriangleTopology( pModel, pQ3BSPFace, mesh, faceIdx, vertIdx );
+        if (pQ3BSPFace->iNumOfFaceVerts > 0) {
+            if (pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh) {
+                createTriangleTopology(pModel, pQ3BSPFace, mesh, faceIdx, vertIdx);
             }
         }
     }
 
     aiNode *pNode = new aiNode;
     pNode->mNumMeshes = 1;
-    pNode->mMeshes = new unsigned int[ 1 ];
+    pNode->mMeshes = new unsigned int[1];
     *pMesh = mesh;
 
     return pNode;
@@ -371,27 +368,27 @@ aiNode *Q3BSPFileImporter::CreateTopology( const Q3BSP::Q3BSPModel *pModel, unsi
 
 // ------------------------------------------------------------------------------------------------
 //  Creates the triangle topology from a face array.
-void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, sQ3BSPFace *pQ3BSPFace,
-        aiMesh* pMesh, unsigned int &faceIdx, unsigned int &vertIdx ) {
-    ai_assert( faceIdx < pMesh->mNumFaces );
+void Q3BSPFileImporter::createTriangleTopology(const Q3BSP::Q3BSPModel *pModel, sQ3BSPFace *pQ3BSPFace,
+        aiMesh *pMesh, unsigned int &faceIdx, unsigned int &vertIdx) {
+    ai_assert(faceIdx < pMesh->mNumFaces);
 
-    m_pCurrentFace = getNextFace( pMesh, faceIdx );
-    if ( nullptr == m_pCurrentFace ) {
+    m_pCurrentFace = getNextFace(pMesh, faceIdx);
+    if (nullptr == m_pCurrentFace) {
         return;
     }
 
     m_pCurrentFace->mNumIndices = 3;
-    m_pCurrentFace->mIndices = new unsigned int[ m_pCurrentFace->mNumIndices ];
+    m_pCurrentFace->mIndices = new unsigned int[m_pCurrentFace->mNumIndices];
 
-    size_t idx( 0 );
-    for ( size_t i = 0; i < (size_t) pQ3BSPFace->iNumOfFaceVerts; ++i ) {
-        const size_t index = pQ3BSPFace->iVertexIndex + pModel->m_Indices[ pQ3BSPFace->iFaceVertexIndex + i ];
-        if ( index >= pModel->m_Vertices.size() ) {
+    size_t idx(0);
+    for (size_t i = 0; i < (size_t)pQ3BSPFace->iNumOfFaceVerts; ++i) {
+        const size_t index = pQ3BSPFace->iVertexIndex + pModel->m_Indices[pQ3BSPFace->iFaceVertexIndex + i];
+        if (index >= pModel->m_Vertices.size()) {
             continue;
         }
 
-        sQ3BSPVertex *pVertex = pModel->m_Vertices[ index ];
-        if ( nullptr == pVertex ) {
+        sQ3BSPVertex *pVertex = pModel->m_Vertices[index];
+        if (nullptr == pVertex) {
             continue;
         }
         if (idx > 2) {
@@ -400,15 +397,15 @@ void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel,
             if (nullptr != m_pCurrentFace) {
                 m_pCurrentFace->mNumIndices = 3;
                 m_pCurrentFace->mIndices = new unsigned int[3];
-                m_pCurrentFace->mIndices[ idx ] = vertIdx;
+                m_pCurrentFace->mIndices[idx] = vertIdx;
             }
         }
 
-        pMesh->mVertices[ vertIdx ].Set( pVertex->vPosition.x, pVertex->vPosition.y, pVertex->vPosition.z );
-        pMesh->mNormals[ vertIdx ].Set( pVertex->vNormal.x, pVertex->vNormal.y, pVertex->vNormal.z );
+        pMesh->mVertices[vertIdx].Set(pVertex->vPosition.x, pVertex->vPosition.y, pVertex->vPosition.z);
+        pMesh->mNormals[vertIdx].Set(pVertex->vNormal.x, pVertex->vNormal.y, pVertex->vNormal.z);
 
-        pMesh->mTextureCoords[ 0 ][ vertIdx ].Set( pVertex->vTexCoord.x, pVertex->vTexCoord.y, 0.0f );
-        pMesh->mTextureCoords[ 1 ][ vertIdx ].Set( pVertex->vLightmap.x, pVertex->vLightmap.y, 0.0f );
+        pMesh->mTextureCoords[0][vertIdx].Set(pVertex->vTexCoord.x, pVertex->vTexCoord.y, 0.0f);
+        pMesh->mTextureCoords[1][vertIdx].Set(pVertex->vLightmap.x, pVertex->vLightmap.y, 0.0f);
 
         vertIdx++;
         idx++;
@@ -417,65 +414,61 @@ void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel,
 
 // ------------------------------------------------------------------------------------------------
 //  Creates all referenced materials.
-void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
-    ZipArchiveIOSystem *pArchive ) {
-    if ( m_MaterialLookupMap.empty() ) {
+void Q3BSPFileImporter::createMaterials(const Q3BSP::Q3BSPModel *pModel, aiScene *pScene,
+        ZipArchiveIOSystem *pArchive) {
+    if (m_MaterialLookupMap.empty()) {
         return;
     }
 
-    pScene->mMaterials = new aiMaterial*[ m_MaterialLookupMap.size() ];
+    pScene->mMaterials = new aiMaterial *[m_MaterialLookupMap.size()];
     aiString aiMatName;
-    int textureId( -1 ), lightmapId( -1 );
-    for ( FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end();
-        ++it ) {
-        const std::string matName( it->first );
-        if ( matName.empty() ) {
+    int textureId(-1), lightmapId(-1);
+    for (FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end();
+            ++it) {
+        const std::string matName(it->first);
+        if (matName.empty()) {
             continue;
         }
 
-        aiMatName.Set( matName );
+        aiMatName.Set(matName);
         aiMaterial *pMatHelper = new aiMaterial;
-        pMatHelper->AddProperty( &aiMatName, AI_MATKEY_NAME );
+        pMatHelper->AddProperty(&aiMatName, AI_MATKEY_NAME);
 
-        extractIds( matName, textureId, lightmapId );
+        extractIds(matName, textureId, lightmapId);
 
         // Adding the texture
-        if ( -1 != textureId ) {
-            sQ3BSPTexture *pTexture = pModel->m_Textures[ textureId ];
-            if ( nullptr != pTexture ) {
-                std::string tmp( "*" ), texName( "" );
+        if (-1 != textureId) {
+            sQ3BSPTexture *pTexture = pModel->m_Textures[textureId];
+            if (nullptr != pTexture) {
+                std::string tmp("*"), texName("");
                 tmp += pTexture->strName;
                 tmp += ".jpg";
-                normalizePathName( tmp, texName );
+                normalizePathName(tmp, texName);
 
-                if ( !importTextureFromArchive( pModel, pArchive, pScene, pMatHelper, textureId ) ) {
+                if (!importTextureFromArchive(pModel, pArchive, pScene, pMatHelper, textureId)) {
                     ASSIMP_LOG_ERROR("Cannot import texture from archive " + texName);
                 }
             }
-
         }
-        if ( -1 != lightmapId )
-        {
-            importLightmap( pModel, pScene, pMatHelper, lightmapId );
+        if (-1 != lightmapId) {
+            importLightmap(pModel, pScene, pMatHelper, lightmapId);
         }
-        pScene->mMaterials[ pScene->mNumMaterials ] = pMatHelper;
+        pScene->mMaterials[pScene->mNumMaterials] = pMatHelper;
         pScene->mNumMaterials++;
     }
     pScene->mNumTextures = static_cast<unsigned int>(mTextures.size());
-    pScene->mTextures = new aiTexture*[ pScene->mNumTextures ];
-    std::copy( mTextures.begin(), mTextures.end(), pScene->mTextures );
+    pScene->mTextures = new aiTexture *[pScene->mNumTextures];
+    std::copy(mTextures.begin(), mTextures.end(), pScene->mTextures);
 }
 
 // ------------------------------------------------------------------------------------------------
 //  Counts the number of referenced vertices.
-size_t Q3BSPFileImporter::countData( const std::vector<sQ3BSPFace*> &faceArray ) const {
-    size_t numVerts( 0 );
-    for ( std::vector<sQ3BSPFace*>::const_iterator it = faceArray.begin(); it != faceArray.end();
-        ++it )
-    {
+size_t Q3BSPFileImporter::countData(const std::vector<sQ3BSPFace *> &faceArray) const {
+    size_t numVerts(0);
+    for (std::vector<sQ3BSPFace *>::const_iterator it = faceArray.begin(); it != faceArray.end();
+            ++it) {
         sQ3BSPFace *pQ3BSPFace = *it;
-        if ( pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh )
-        {
+        if (pQ3BSPFace->iType == Polygon || pQ3BSPFace->iType == TriangleMesh) {
             Q3BSP::sQ3BSPFace *face = *it;
             if (nullptr != face) {
                 numVerts += face->iNumOfFaceVerts;
@@ -488,15 +481,12 @@ size_t Q3BSPFileImporter::countData( const std::vector<sQ3BSPFace*> &faceArray )
 
 // ------------------------------------------------------------------------------------------------
 //  Counts the faces with vertices.
-size_t Q3BSPFileImporter::countFaces( const std::vector<Q3BSP::sQ3BSPFace*> &rArray ) const
-{
+size_t Q3BSPFileImporter::countFaces(const std::vector<Q3BSP::sQ3BSPFace *> &rArray) const {
     size_t numFaces = 0;
-    for ( std::vector<sQ3BSPFace*>::const_iterator it = rArray.begin(); it != rArray.end();
-        ++it )
-    {
+    for (std::vector<sQ3BSPFace *>::const_iterator it = rArray.begin(); it != rArray.end();
+            ++it) {
         Q3BSP::sQ3BSPFace *pQ3BSPFace = *it;
-        if ( pQ3BSPFace->iNumOfFaceVerts > 0 )
-        {
+        if (pQ3BSPFace->iNumOfFaceVerts > 0) {
             numFaces++;
         }
     }
@@ -506,15 +496,12 @@ size_t Q3BSPFileImporter::countFaces( const std::vector<Q3BSP::sQ3BSPFace*> &rAr
 
 // ------------------------------------------------------------------------------------------------
 //  Counts the number of triangles in a Q3-face-array.
-size_t Q3BSPFileImporter::countTriangles( const std::vector<Q3BSP::sQ3BSPFace*> &rArray ) const
-{
+size_t Q3BSPFileImporter::countTriangles(const std::vector<Q3BSP::sQ3BSPFace *> &rArray) const {
     size_t numTriangles = 0;
-    for ( std::vector<Q3BSP::sQ3BSPFace*>::const_iterator it = rArray.begin(); it != rArray.end();
-        ++it )
-    {
+    for (std::vector<Q3BSP::sQ3BSPFace *>::const_iterator it = rArray.begin(); it != rArray.end();
+            ++it) {
         const Q3BSP::sQ3BSPFace *pQ3BSPFace = *it;
-        if ( NULL != pQ3BSPFace )
-        {
+        if (nullptr != pQ3BSPFace) {
             numTriangles += pQ3BSPFace->iNumOfFaceVerts / 3;
         }
     }
@@ -524,38 +511,34 @@ size_t Q3BSPFileImporter::countTriangles( const std::vector<Q3BSP::sQ3BSPFace*>
 
 // ------------------------------------------------------------------------------------------------
 //  Creates the faces-to-material map.
-void Q3BSPFileImporter::createMaterialMap( const Q3BSP::Q3BSPModel *pModel ) {
-    std::string key( "" );
-    std::vector<sQ3BSPFace*> *pCurFaceArray = NULL;
-    for ( size_t idx = 0; idx < pModel->m_Faces.size(); idx++ )
-    {
-        Q3BSP::sQ3BSPFace *pQ3BSPFace = pModel->m_Faces[ idx ];
+void Q3BSPFileImporter::createMaterialMap(const Q3BSP::Q3BSPModel *pModel) {
+    std::string key("");
+    std::vector<sQ3BSPFace *> *pCurFaceArray = nullptr;
+    for (size_t idx = 0; idx < pModel->m_Faces.size(); idx++) {
+        Q3BSP::sQ3BSPFace *pQ3BSPFace = pModel->m_Faces[idx];
         const int texId = pQ3BSPFace->iTextureID;
         const int lightMapId = pQ3BSPFace->iLightmapID;
-        createKey( texId, lightMapId, key );
-        FaceMapIt it = m_MaterialLookupMap.find( key );
-        if ( m_MaterialLookupMap.end() == it ) {
-            pCurFaceArray = new std::vector<Q3BSP::sQ3BSPFace*>;
-            m_MaterialLookupMap[ key ] = pCurFaceArray;
-        }
-        else
-        {
+        createKey(texId, lightMapId, key);
+        FaceMapIt it = m_MaterialLookupMap.find(key);
+        if (m_MaterialLookupMap.end() == it) {
+            pCurFaceArray = new std::vector<Q3BSP::sQ3BSPFace *>;
+            m_MaterialLookupMap[key] = pCurFaceArray;
+        } else {
             pCurFaceArray = (*it).second;
         }
-        ai_assert( nullptr != pCurFaceArray );
-        if (nullptr != pCurFaceArray )
-        {
-            pCurFaceArray->push_back( pQ3BSPFace );
+        ai_assert(nullptr != pCurFaceArray);
+        if (nullptr != pCurFaceArray) {
+            pCurFaceArray->push_back(pQ3BSPFace);
         }
     }
 }
 
 // ------------------------------------------------------------------------------------------------
 //  Returns the next face.
-aiFace *Q3BSPFileImporter::getNextFace( aiMesh *mesh, unsigned int &faceIdx ) {
-    aiFace *face( nullptr );
-    if ( faceIdx < mesh->mNumFaces ) {
-        face = &mesh->mFaces[ faceIdx ];
+aiFace *Q3BSPFileImporter::getNextFace(aiMesh *mesh, unsigned int &faceIdx) {
+    aiFace *face(nullptr);
+    if (faceIdx < mesh->mNumFaces) {
+        face = &mesh->mFaces[faceIdx];
         ++faceIdx;
     }
 
@@ -564,31 +547,31 @@ aiFace *Q3BSPFileImporter::getNextFace( aiMesh *mesh, unsigned int &faceIdx ) {
 
 // ------------------------------------------------------------------------------------------------
 //  Imports a texture file.
-bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model,
-                                                 ZipArchiveIOSystem *archive, aiScene*,
-                                                 aiMaterial *pMatHelper, int textureId ) {
-    if (nullptr == archive || nullptr == pMatHelper ) {
+bool Q3BSPFileImporter::importTextureFromArchive(const Q3BSP::Q3BSPModel *model,
+        ZipArchiveIOSystem *archive, aiScene *,
+        aiMaterial *pMatHelper, int textureId) {
+    if (nullptr == archive || nullptr == pMatHelper) {
         return false;
     }
 
-    if ( textureId < 0 || textureId >= static_cast<int>( model->m_Textures.size() ) ) {
+    if (textureId < 0 || textureId >= static_cast<int>(model->m_Textures.size())) {
         return false;
     }
 
     bool res = true;
-    sQ3BSPTexture *pTexture = model->m_Textures[ textureId ];
-    if ( !pTexture ) {
+    sQ3BSPTexture *pTexture = model->m_Textures[textureId];
+    if (!pTexture) {
         return false;
     }
 
     std::vector<std::string> supportedExtensions;
-    supportedExtensions.push_back( ".jpg" );
-    supportedExtensions.push_back( ".png" );
-    supportedExtensions.push_back( ".tga" );
+    supportedExtensions.push_back(".jpg");
+    supportedExtensions.push_back(".png");
+    supportedExtensions.push_back(".tga");
     std::string textureName, ext;
-    if ( expandFile( archive, pTexture->strName, supportedExtensions, textureName, ext ) ) {
-        IOStream *pTextureStream = archive->Open( textureName.c_str() );
-        if ( pTextureStream ) {
+    if (expandFile(archive, pTexture->strName, supportedExtensions, textureName, ext)) {
+        IOStream *pTextureStream = archive->Open(textureName.c_str());
+        if (pTextureStream) {
             size_t texSize = pTextureStream->FileSize();
             aiTexture *curTexture = new aiTexture;
             curTexture->mHeight = 0;
@@ -605,20 +588,20 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model
             res = true;
 
             aiString name;
-            name.data[ 0 ] = '*';
-            name.length = 1 + ASSIMP_itoa10( name.data + 1, static_cast<unsigned int>(MAXLEN-1), static_cast<int32_t>(mTextures.size()) );
+            name.data[0] = '*';
+            name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast<unsigned int>(MAXLEN - 1), static_cast<int32_t>(mTextures.size()));
 
-            archive->Close( pTextureStream );
+            archive->Close(pTextureStream);
 
-            pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
+            pMatHelper->AddProperty(&name, AI_MATKEY_TEXTURE_DIFFUSE(0));
             mTextures.push_back(curTexture);
         } else {
             // If it doesn't exist in the archive, it is probably just a reference to an external file.
             // We'll leave it up to the user to figure out which extension the file has.
             aiString name;
-            strncpy( name.data, pTexture->strName, sizeof name.data );
-            name.length = static_cast<ai_uint32>(strlen( name.data ));
-            pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
+            strncpy(name.data, pTexture->strName, sizeof name.data);
+            name.length = static_cast<ai_uint32>(strlen(name.data));
+            pMatHelper->AddProperty(&name, AI_MATKEY_TEXTURE_DIFFUSE(0));
         }
     }
 
@@ -627,19 +610,18 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model
 
 // ------------------------------------------------------------------------------------------------
 //  Imports a light map file.
-bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene,
-                                       aiMaterial *pMatHelper, int lightmapId )
-{
-    if (nullptr == pModel || nullptr == pScene || nullptr == pMatHelper ) {
+bool Q3BSPFileImporter::importLightmap(const Q3BSP::Q3BSPModel *pModel, aiScene *pScene,
+        aiMaterial *pMatHelper, int lightmapId) {
+    if (nullptr == pModel || nullptr == pScene || nullptr == pMatHelper) {
         return false;
     }
 
-    if ( lightmapId < 0 || lightmapId >= static_cast<int>( pModel->m_Lightmaps.size() ) ) {
+    if (lightmapId < 0 || lightmapId >= static_cast<int>(pModel->m_Lightmaps.size())) {
         return false;
     }
 
-    sQ3BSPLightmap *pLightMap = pModel->m_Lightmaps[ lightmapId ];
-    if (nullptr == pLightMap ) {
+    sQ3BSPLightmap *pLightMap = pModel->m_Lightmaps[lightmapId];
+    if (nullptr == pLightMap) {
         return false;
     }
 
@@ -649,21 +631,21 @@ bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene
     pTexture->mHeight = CE_BSP_LIGHTMAPHEIGHT;
     pTexture->pcData = new aiTexel[CE_BSP_LIGHTMAPWIDTH * CE_BSP_LIGHTMAPHEIGHT];
 
-    ::memcpy( pTexture->pcData, pLightMap->bLMapData, pTexture->mWidth );
+    ::memcpy(pTexture->pcData, pLightMap->bLMapData, pTexture->mWidth);
     size_t p = 0;
-    for ( size_t i = 0; i < CE_BSP_LIGHTMAPWIDTH * CE_BSP_LIGHTMAPHEIGHT; ++i ) {
-        pTexture->pcData[ i ].r = pLightMap->bLMapData[ p++ ];
-        pTexture->pcData[ i ].g = pLightMap->bLMapData[ p++ ];
-        pTexture->pcData[ i ].b = pLightMap->bLMapData[ p++ ];
-        pTexture->pcData[ i ].a = 0xFF;
+    for (size_t i = 0; i < CE_BSP_LIGHTMAPWIDTH * CE_BSP_LIGHTMAPHEIGHT; ++i) {
+        pTexture->pcData[i].r = pLightMap->bLMapData[p++];
+        pTexture->pcData[i].g = pLightMap->bLMapData[p++];
+        pTexture->pcData[i].b = pLightMap->bLMapData[p++];
+        pTexture->pcData[i].a = 0xFF;
     }
 
     aiString name;
-    name.data[ 0 ] = '*';
-    name.length = 1 + ASSIMP_itoa10( name.data + 1, static_cast<unsigned int>(MAXLEN-1), static_cast<int32_t>(mTextures.size()) );
+    name.data[0] = '*';
+    name.length = 1 + ASSIMP_itoa10(name.data + 1, static_cast<unsigned int>(MAXLEN - 1), static_cast<int32_t>(mTextures.size()));
 
-    pMatHelper->AddProperty( &name,AI_MATKEY_TEXTURE_LIGHTMAP( 1 ) );
-    mTextures.push_back( pTexture );
+    pMatHelper->AddProperty(&name, AI_MATKEY_TEXTURE_LIGHTMAP(1));
+    mTextures.push_back(pTexture);
 
     return true;
 }
@@ -671,25 +653,21 @@ bool Q3BSPFileImporter::importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene
 // ------------------------------------------------------------------------------------------------
 //  Will search for a supported extension.
 bool Q3BSPFileImporter::expandFile(ZipArchiveIOSystem *pArchive, const std::string &rFilename,
-                                   const std::vector<std::string> &rExtList, std::string &rFile,
-                                   std::string &rExt )
-{
-    ai_assert( NULL != pArchive );
-    ai_assert( !rFilename.empty() );
-
-    if ( rExtList.empty() )
-    {
-        rFile =  rFilename;
+        const std::vector<std::string> &rExtList, std::string &rFile,
+        std::string &rExt) {
+    ai_assert(nullptr != pArchive);
+    ai_assert(!rFilename.empty());
+
+    if (rExtList.empty()) {
+        rFile = rFilename;
         rExt = "";
         return true;
     }
 
     bool found = false;
-    for ( std::vector<std::string>::const_iterator it = rExtList.begin(); it != rExtList.end(); ++it )
-    {
+    for (std::vector<std::string>::const_iterator it = rExtList.begin(); it != rExtList.end(); ++it) {
         const std::string textureName = rFilename + *it;
-        if ( pArchive->Exists( textureName.c_str() ) )
-        {
+        if (pArchive->Exists(textureName.c_str())) {
             rExt = *it;
             rFile = textureName;
             found = true;

+ 213 - 257
code/AssetLib/Q3D/Q3DLoader.cpp

@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
 
 Copyright (c) 2006-2020, assimp team
 
-
-
 All rights reserved.
 
 Redistribution and use of this software in source and binary forms,
@@ -45,17 +43,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *  @brief Implementation of the Q3D importer class
  */
 
-
 #ifndef ASSIMP_BUILD_NO_Q3D_IMPORTER
 
 // internal headers
 #include "Q3DLoader.h"
 #include <assimp/StreamReader.h>
 #include <assimp/fast_atof.h>
-#include <assimp/IOSystem.hpp>
-#include <assimp/DefaultLogger.hpp>
-#include <assimp/scene.h>
 #include <assimp/importerdesc.h>
+#include <assimp/scene.h>
+#include <assimp/DefaultLogger.hpp>
+#include <assimp/IOSystem.hpp>
 
 using namespace Assimp;
 
@@ -74,68 +71,66 @@ static const aiImporterDesc desc = {
 
 // ------------------------------------------------------------------------------------------------
 // Constructor to be privately used by Importer
-Q3DImporter::Q3DImporter()
-{}
+Q3DImporter::Q3DImporter() {
+    // empty
+}
 
 // ------------------------------------------------------------------------------------------------
 // Destructor, private as well
-Q3DImporter::~Q3DImporter()
-{}
+Q3DImporter::~Q3DImporter() {
+    // empty
+}
 
 // ------------------------------------------------------------------------------------------------
 // Returns whether the class can handle the format of the given file.
-bool Q3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
-{
+bool Q3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
     const std::string extension = GetExtension(pFile);
 
     if (extension == "q3s" || extension == "q3o")
         return true;
-    else if (!extension.length() || checkSig)   {
+    else if (!extension.length() || checkSig) {
         if (!pIOHandler)
             return true;
-        const char* tokens[] = {"quick3Do","quick3Ds"};
-        return SearchFileHeaderForToken(pIOHandler,pFile,tokens,2);
+        const char *tokens[] = { "quick3Do", "quick3Ds" };
+        return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2);
     }
     return false;
 }
 
 // ------------------------------------------------------------------------------------------------
-const aiImporterDesc* Q3DImporter::GetInfo () const
-{
+const aiImporterDesc *Q3DImporter::GetInfo() const {
     return &desc;
 }
 
 // ------------------------------------------------------------------------------------------------
 // Imports the given file into the given scene structure.
-void Q3DImporter::InternReadFile( const std::string& pFile,
-    aiScene* pScene, IOSystem* pIOHandler)
-{
-    StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
+void Q3DImporter::InternReadFile(const std::string &pFile,
+        aiScene *pScene, IOSystem *pIOHandler) {
+    StreamReaderLE stream(pIOHandler->Open(pFile, "rb"));
 
     // The header is 22 bytes large
     if (stream.GetRemainingSize() < 22)
         throw DeadlyImportError("File is either empty or corrupt: " + pFile);
 
     // Check the file's signature
-    if (ASSIMP_strincmp( (const char*)stream.GetPtr(), "quick3Do", 8 ) &&
-        ASSIMP_strincmp( (const char*)stream.GetPtr(), "quick3Ds", 8 ))
-    {
+    if (ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Do", 8) &&
+            ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Ds", 8)) {
         throw DeadlyImportError("Not a Quick3D file. Signature string is: " +
-            std::string((const char*)stream.GetPtr(),8));
+                                std::string((const char *)stream.GetPtr(), 8));
     }
 
     // Print the file format version
     ASSIMP_LOG_INFO_F("Quick3D File format version: ",
-        std::string(&((const char*)stream.GetPtr())[8],2));
+            std::string(&((const char *)stream.GetPtr())[8], 2));
 
     // ... an store it
-    char major = ((const char*)stream.GetPtr())[8];
-    char minor = ((const char*)stream.GetPtr())[9];
+    char major = ((const char *)stream.GetPtr())[8];
+    char minor = ((const char *)stream.GetPtr())[9];
 
     stream.IncPtr(10);
-    unsigned int numMeshes    = (unsigned int)stream.GetI4();
-    unsigned int numMats      = (unsigned int)stream.GetI4();
-    unsigned int numTextures  = (unsigned int)stream.GetI4();
+    unsigned int numMeshes = (unsigned int)stream.GetI4();
+    unsigned int numMats = (unsigned int)stream.GetI4();
+    unsigned int numTextures = (unsigned int)stream.GetI4();
 
     std::vector<Material> materials;
     materials.reserve(numMats);
@@ -146,124 +141,109 @@ void Q3DImporter::InternReadFile( const std::string& pFile,
     // Allocate the scene root node
     pScene->mRootNode = new aiNode();
 
-    aiColor3D fgColor (0.6f,0.6f,0.6f);
+    aiColor3D fgColor(0.6f, 0.6f, 0.6f);
 
     // Now read all file chunks
-    while (true)
-    {
-        if (stream.GetRemainingSize() < 1)break;
+    while (true) {
+        if (stream.GetRemainingSize() < 1) break;
         char c = stream.GetI1();
-        switch (c)
-        {
+        switch (c) {
             // Meshes chunk
-        case 'm':
-            {
-                for (unsigned int quak = 0; quak < numMeshes; ++quak)
-                {
-                    meshes.push_back(Mesh());
-                    Mesh& mesh = meshes.back();
-
-                    // read all vertices
-                    unsigned int numVerts = (unsigned int)stream.GetI4();
-                    if (!numVerts)
-                        throw DeadlyImportError("Quick3D: Found mesh with zero vertices");
-
-                    std::vector<aiVector3D>& verts = mesh.verts;
-                    verts.resize(numVerts);
-
-                    for (unsigned int i = 0; i < numVerts;++i)
-                    {
-                        verts[i].x = stream.GetF4();
-                        verts[i].y = stream.GetF4();
-                        verts[i].z = stream.GetF4();
-                    }
+        case 'm': {
+            for (unsigned int quak = 0; quak < numMeshes; ++quak) {
+                meshes.push_back(Mesh());
+                Mesh &mesh = meshes.back();
+
+                // read all vertices
+                unsigned int numVerts = (unsigned int)stream.GetI4();
+                if (!numVerts)
+                    throw DeadlyImportError("Quick3D: Found mesh with zero vertices");
+
+                std::vector<aiVector3D> &verts = mesh.verts;
+                verts.resize(numVerts);
+
+                for (unsigned int i = 0; i < numVerts; ++i) {
+                    verts[i].x = stream.GetF4();
+                    verts[i].y = stream.GetF4();
+                    verts[i].z = stream.GetF4();
+                }
 
-                    // read all faces
-                    numVerts = (unsigned int)stream.GetI4();
-                    if (!numVerts)
-                        throw DeadlyImportError("Quick3D: Found mesh with zero faces");
+                // read all faces
+                numVerts = (unsigned int)stream.GetI4();
+                if (!numVerts)
+                    throw DeadlyImportError("Quick3D: Found mesh with zero faces");
 
-                    std::vector<Face >& faces = mesh.faces;
-                    faces.reserve(numVerts);
+                std::vector<Face> &faces = mesh.faces;
+                faces.reserve(numVerts);
 
-                    // number of indices
-                    for (unsigned int i = 0; i < numVerts;++i)
-                    {
-                        faces.push_back(Face(stream.GetI2()) );
-                        if (faces.back().indices.empty())
-                            throw DeadlyImportError("Quick3D: Found face with zero indices");
-                    }
+                // number of indices
+                for (unsigned int i = 0; i < numVerts; ++i) {
+                    faces.push_back(Face(stream.GetI2()));
+                    if (faces.back().indices.empty())
+                        throw DeadlyImportError("Quick3D: Found face with zero indices");
+                }
 
-                    // indices
-                    for (unsigned int i = 0; i < numVerts;++i)
-                    {
-                        Face& vec = faces[i];
-                        for (unsigned int a = 0; a < (unsigned int)vec.indices.size();++a)
-                            vec.indices[a] = stream.GetI4();
-                    }
+                // indices
+                for (unsigned int i = 0; i < numVerts; ++i) {
+                    Face &vec = faces[i];
+                    for (unsigned int a = 0; a < (unsigned int)vec.indices.size(); ++a)
+                        vec.indices[a] = stream.GetI4();
+                }
 
-                    // material indices
-                    for (unsigned int i = 0; i < numVerts;++i)
-                    {
-                        faces[i].mat = (unsigned int)stream.GetI4();
-                    }
+                // material indices
+                for (unsigned int i = 0; i < numVerts; ++i) {
+                    faces[i].mat = (unsigned int)stream.GetI4();
+                }
 
-                    // read all normals
-                    numVerts = (unsigned int)stream.GetI4();
-                    std::vector<aiVector3D>& normals = mesh.normals;
-                    normals.resize(numVerts);
+                // read all normals
+                numVerts = (unsigned int)stream.GetI4();
+                std::vector<aiVector3D> &normals = mesh.normals;
+                normals.resize(numVerts);
 
-                    for (unsigned int i = 0; i < numVerts;++i)
-                    {
-                        normals[i].x = stream.GetF4();
-                        normals[i].y = stream.GetF4();
-                        normals[i].z = stream.GetF4();
-                    }
+                for (unsigned int i = 0; i < numVerts; ++i) {
+                    normals[i].x = stream.GetF4();
+                    normals[i].y = stream.GetF4();
+                    normals[i].z = stream.GetF4();
+                }
 
-                    numVerts = (unsigned int)stream.GetI4();
-                    if (numTextures && numVerts)
-                    {
-                        // read all texture coordinates
-                        std::vector<aiVector3D>& uv = mesh.uv;
-                        uv.resize(numVerts);
-
-                        for (unsigned int i = 0; i < numVerts;++i)
-                        {
-                            uv[i].x = stream.GetF4();
-                            uv[i].y = stream.GetF4();
-                        }
+                numVerts = (unsigned int)stream.GetI4();
+                if (numTextures && numVerts) {
+                    // read all texture coordinates
+                    std::vector<aiVector3D> &uv = mesh.uv;
+                    uv.resize(numVerts);
 
-                        // UV indices
-                        for (unsigned int i = 0; i < (unsigned int)faces.size();++i)
-                        {
-                            Face& vec = faces[i];
-                            for (unsigned int a = 0; a < (unsigned int)vec.indices.size();++a)
-                            {
-                                vec.uvindices[a] = stream.GetI4();
-                                if (!i && !a)
-                                    mesh.prevUVIdx = vec.uvindices[a];
-                                else if (vec.uvindices[a] != mesh.prevUVIdx)
-                                    mesh.prevUVIdx = UINT_MAX;
-                            }
-                        }
+                    for (unsigned int i = 0; i < numVerts; ++i) {
+                        uv[i].x = stream.GetF4();
+                        uv[i].y = stream.GetF4();
                     }
 
-                    // we don't need the rest, but we need to get to the next chunk
-                    stream.IncPtr(36);
-                    if (minor > '0' && major == '3')
-                        stream.IncPtr(mesh.faces.size());
+                    // UV indices
+                    for (unsigned int i = 0; i < (unsigned int)faces.size(); ++i) {
+                        Face &vec = faces[i];
+                        for (unsigned int a = 0; a < (unsigned int)vec.indices.size(); ++a) {
+                            vec.uvindices[a] = stream.GetI4();
+                            if (!i && !a)
+                                mesh.prevUVIdx = vec.uvindices[a];
+                            else if (vec.uvindices[a] != mesh.prevUVIdx)
+                                mesh.prevUVIdx = UINT_MAX;
+                        }
+                    }
                 }
-                // stream.IncPtr(4); // unknown value here
+
+                // we don't need the rest, but we need to get to the next chunk
+                stream.IncPtr(36);
+                if (minor > '0' && major == '3')
+                    stream.IncPtr(mesh.faces.size());
             }
-            break;
+            // stream.IncPtr(4); // unknown value here
+        } break;
 
             // materials chunk
         case 'c':
 
-            for (unsigned int i = 0; i < numMats; ++i)
-            {
+            for (unsigned int i = 0; i < numMats; ++i) {
                 materials.push_back(Material());
-                Material& mat = materials.back();
+                Material &mat = materials.back();
 
                 // read the material name
                 c = stream.GetI1();
@@ -308,17 +288,18 @@ void Q3DImporter::InternReadFile( const std::string& pFile,
             if (!numTextures) {
                 break;
             }
-            pScene->mTextures = new aiTexture*[pScene->mNumTextures];
+            pScene->mTextures = new aiTexture *[pScene->mNumTextures];
             // to make sure we won't crash if we leave through an exception
-            ::memset(pScene->mTextures,0,sizeof(void*)*pScene->mNumTextures);
+            ::memset(pScene->mTextures, 0, sizeof(void *) * pScene->mNumTextures);
             for (unsigned int i = 0; i < pScene->mNumTextures; ++i) {
-                aiTexture* tex = pScene->mTextures[i] = new aiTexture;
+                aiTexture *tex = pScene->mTextures[i] = new aiTexture;
 
                 // skip the texture name
-                while (stream.GetI1());
+                while (stream.GetI1())
+                    ;
 
                 // read texture width and height
-                tex->mWidth  = (unsigned int)stream.GetI4();
+                tex->mWidth = (unsigned int)stream.GetI4();
                 tex->mHeight = (unsigned int)stream.GetI4();
 
                 if (!tex->mWidth || !tex->mHeight) {
@@ -326,11 +307,10 @@ void Q3DImporter::InternReadFile( const std::string& pFile,
                 }
 
                 unsigned int mul = tex->mWidth * tex->mHeight;
-                aiTexel* begin = tex->pcData = new aiTexel[mul];
-                aiTexel* const end = & begin[mul-1] +1;
-
+                aiTexel *begin = tex->pcData = new aiTexel[mul];
+                aiTexel *const end = &begin[mul - 1] + 1;
 
-                for (;begin != end; ++begin) {
+                for (; begin != end; ++begin) {
                     begin->r = stream.GetI1();
                     begin->g = stream.GetI1();
                     begin->b = stream.GetI1();
@@ -341,68 +321,66 @@ void Q3DImporter::InternReadFile( const std::string& pFile,
             break;
 
             // scene chunk
-        case 's':
-            {
-                // skip position and rotation
-                stream.IncPtr(12);
-
-                for (unsigned int i = 0; i < 4;++i)
-                    for (unsigned int a = 0; a < 4;++a)
-                        pScene->mRootNode->mTransformation[i][a] = stream.GetF4();
+        case 's': {
+            // skip position and rotation
+            stream.IncPtr(12);
 
-                stream.IncPtr(16);
+            for (unsigned int i = 0; i < 4; ++i)
+                for (unsigned int a = 0; a < 4; ++a)
+                    pScene->mRootNode->mTransformation[i][a] = stream.GetF4();
 
-                // now setup a single camera
-                pScene->mNumCameras = 1;
-                pScene->mCameras = new aiCamera*[1];
-                aiCamera* cam = pScene->mCameras[0] = new aiCamera();
-                cam->mPosition.x = stream.GetF4();
-                cam->mPosition.y = stream.GetF4();
-                cam->mPosition.z = stream.GetF4();
-                cam->mName.Set("Q3DCamera");
+            stream.IncPtr(16);
 
-                // skip eye rotation for the moment
-                stream.IncPtr(12);
+            // now setup a single camera
+            pScene->mNumCameras = 1;
+            pScene->mCameras = new aiCamera *[1];
+            aiCamera *cam = pScene->mCameras[0] = new aiCamera();
+            cam->mPosition.x = stream.GetF4();
+            cam->mPosition.y = stream.GetF4();
+            cam->mPosition.z = stream.GetF4();
+            cam->mName.Set("Q3DCamera");
 
-                // read the default material color
-                fgColor .r = stream.GetF4();
-                fgColor .g = stream.GetF4();
-                fgColor .b = stream.GetF4();
+            // skip eye rotation for the moment
+            stream.IncPtr(12);
 
-                // skip some unimportant properties
-                stream.IncPtr(29);
+            // read the default material color
+            fgColor.r = stream.GetF4();
+            fgColor.g = stream.GetF4();
+            fgColor.b = stream.GetF4();
 
-                // setup a single point light with no attenuation
-                pScene->mNumLights = 1;
-                pScene->mLights = new aiLight*[1];
-                aiLight* light = pScene->mLights[0] = new aiLight();
-                light->mName.Set("Q3DLight");
-                light->mType = aiLightSource_POINT;
+            // skip some unimportant properties
+            stream.IncPtr(29);
 
-                light->mAttenuationConstant  = 1;
-                light->mAttenuationLinear    = 0;
-                light->mAttenuationQuadratic = 0;
+            // setup a single point light with no attenuation
+            pScene->mNumLights = 1;
+            pScene->mLights = new aiLight *[1];
+            aiLight *light = pScene->mLights[0] = new aiLight();
+            light->mName.Set("Q3DLight");
+            light->mType = aiLightSource_POINT;
 
-                light->mColorDiffuse.r = stream.GetF4();
-                light->mColorDiffuse.g = stream.GetF4();
-                light->mColorDiffuse.b = stream.GetF4();
+            light->mAttenuationConstant = 1;
+            light->mAttenuationLinear = 0;
+            light->mAttenuationQuadratic = 0;
 
-                light->mColorSpecular = light->mColorDiffuse;
+            light->mColorDiffuse.r = stream.GetF4();
+            light->mColorDiffuse.g = stream.GetF4();
+            light->mColorDiffuse.b = stream.GetF4();
 
+            light->mColorSpecular = light->mColorDiffuse;
 
-                // We don't need the rest, but we need to know where this chunk ends.
-                unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4());
+            // We don't need the rest, but we need to know where this chunk ends.
+            unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4());
 
-                // skip the background file name
-                while (stream.GetI1());
+            // skip the background file name
+            while (stream.GetI1())
+                ;
 
-                // skip background texture data + the remaining fields
-                stream.IncPtr(temp*3 + 20); // 4 bytes of unknown data here
+            // skip background texture data + the remaining fields
+            stream.IncPtr(temp * 3 + 20); // 4 bytes of unknown data here
 
-                // TODO
-                goto outer;
-            }
-            break;
+            // TODO
+            goto outer;
+        } break;
 
         default:
             throw DeadlyImportError("Quick3D: Unknown chunk");
@@ -416,55 +394,50 @@ outer:
         throw DeadlyImportError("Quick3D: No meshes loaded");
 
     // If we have no materials loaded - generate a default mat
-    if (materials.empty())
-    {
+    if (materials.empty()) {
         ASSIMP_LOG_INFO("Quick3D: No material found, generating one");
         materials.push_back(Material());
-        materials.back().diffuse  = fgColor ;
+        materials.back().diffuse = fgColor;
     }
 
     // find out which materials we'll need
     typedef std::pair<unsigned int, unsigned int> FaceIdx;
-    typedef std::vector< FaceIdx > FaceIdxArray;
-    FaceIdxArray* fidx = new FaceIdxArray[materials.size()];
+    typedef std::vector<FaceIdx> FaceIdxArray;
+    FaceIdxArray *fidx = new FaceIdxArray[materials.size()];
 
     unsigned int p = 0;
     for (std::vector<Mesh>::iterator it = meshes.begin(), end = meshes.end();
-         it != end; ++it,++p)
-    {
+            it != end; ++it, ++p) {
         unsigned int q = 0;
         for (std::vector<Face>::iterator fit = (*it).faces.begin(), fend = (*it).faces.end();
-             fit != fend; ++fit,++q)
-        {
-            if ((*fit).mat >= materials.size())
-            {
+                fit != fend; ++fit, ++q) {
+            if ((*fit).mat >= materials.size()) {
                 ASSIMP_LOG_WARN("Quick3D: Material index overflow");
                 (*fit).mat = 0;
             }
-            if (fidx[(*fit).mat].empty())++pScene->mNumMeshes;
-            fidx[(*fit).mat].push_back( FaceIdx(p,q) );
+            if (fidx[(*fit).mat].empty()) ++pScene->mNumMeshes;
+            fidx[(*fit).mat].push_back(FaceIdx(p, q));
         }
     }
     pScene->mNumMaterials = pScene->mNumMeshes;
-    pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
-    pScene->mMeshes = new aiMesh*[pScene->mNumMaterials];
+    pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
+    pScene->mMeshes = new aiMesh *[pScene->mNumMaterials];
 
-    for (unsigned int i = 0, real = 0; i < (unsigned int)materials.size(); ++i)
-    {
-        if (fidx[i].empty())continue;
+    for (unsigned int i = 0, real = 0; i < (unsigned int)materials.size(); ++i) {
+        if (fidx[i].empty()) continue;
 
         // Allocate a mesh and a material
-        aiMesh* mesh = pScene->mMeshes[real] = new aiMesh();
-        aiMaterial* mat = new aiMaterial();
+        aiMesh *mesh = pScene->mMeshes[real] = new aiMesh();
+        aiMaterial *mat = new aiMaterial();
         pScene->mMaterials[real] = mat;
 
         mesh->mMaterialIndex = real;
 
         // Build the output material
-        Material& srcMat = materials[i];
-        mat->AddProperty(&srcMat.diffuse,  1,AI_MATKEY_COLOR_DIFFUSE);
-        mat->AddProperty(&srcMat.specular, 1,AI_MATKEY_COLOR_SPECULAR);
-        mat->AddProperty(&srcMat.ambient,  1,AI_MATKEY_COLOR_AMBIENT);
+        Material &srcMat = materials[i];
+        mat->AddProperty(&srcMat.diffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
+        mat->AddProperty(&srcMat.specular, 1, AI_MATKEY_COLOR_SPECULAR);
+        mat->AddProperty(&srcMat.ambient, 1, AI_MATKEY_COLOR_AMBIENT);
 
         // NOTE: Ignore transparency for the moment - it seems
         // unclear how to interpret the data
@@ -482,57 +455,48 @@ outer:
         mat->AddProperty(&m, 1, AI_MATKEY_SHADING_MODEL);
 
         if (srcMat.name.length)
-            mat->AddProperty(&srcMat.name,AI_MATKEY_NAME);
+            mat->AddProperty(&srcMat.name, AI_MATKEY_NAME);
 
         // Add a texture
-        if (srcMat.texIdx < pScene->mNumTextures || real < pScene->mNumTextures)
-        {
+        if (srcMat.texIdx < pScene->mNumTextures || real < pScene->mNumTextures) {
             srcMat.name.data[0] = '*';
-            srcMat.name.length  = ASSIMP_itoa10(&srcMat.name.data[1],1000,
-                (srcMat.texIdx < pScene->mNumTextures ? srcMat.texIdx : real));
-            mat->AddProperty(&srcMat.name,AI_MATKEY_TEXTURE_DIFFUSE(0));
+            srcMat.name.length = ASSIMP_itoa10(&srcMat.name.data[1], 1000,
+                    (srcMat.texIdx < pScene->mNumTextures ? srcMat.texIdx : real));
+            mat->AddProperty(&srcMat.name, AI_MATKEY_TEXTURE_DIFFUSE(0));
         }
 
         mesh->mNumFaces = (unsigned int)fidx[i].size();
-        aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
+        aiFace *faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
 
         // Now build the output mesh. First find out how many
         // vertices we'll need
-        for (FaceIdxArray::const_iterator it = fidx[i].begin(),end = fidx[i].end();
-             it != end; ++it)
-        {
-            mesh->mNumVertices += (unsigned int)meshes[(*it).first].faces[
-                (*it).second].indices.size();
+        for (FaceIdxArray::const_iterator it = fidx[i].begin(), end = fidx[i].end();
+                it != end; ++it) {
+            mesh->mNumVertices += (unsigned int)meshes[(*it).first].faces[(*it).second].indices.size();
         }
 
-        aiVector3D* verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
-        aiVector3D* norms = mesh->mNormals  = new aiVector3D[mesh->mNumVertices];
-        aiVector3D* uv;
-        if (real < pScene->mNumTextures)
-        {
-            uv = mesh->mTextureCoords[0] =  new aiVector3D[mesh->mNumVertices];
-            mesh->mNumUVComponents[0]    =  2;
+        aiVector3D *verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
+        aiVector3D *norms = mesh->mNormals = new aiVector3D[mesh->mNumVertices];
+        aiVector3D *uv = nullptr;
+        if (real < pScene->mNumTextures) {
+            uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
+            mesh->mNumUVComponents[0] = 2;
         }
-        else uv = NULL;
 
         // Build the final array
         unsigned int cnt = 0;
-        for (FaceIdxArray::const_iterator it = fidx[i].begin(),end = fidx[i].end();
-             it != end; ++it, ++faces)
-        {
-            Mesh& curMesh = meshes[(*it).first];
+        for (FaceIdxArray::const_iterator it = fidx[i].begin(), end = fidx[i].end();
+                it != end; ++it, ++faces) {
+            Mesh &curMesh = meshes[(*it).first];
             Face &face = curMesh.faces[(*it).second];
             faces->mNumIndices = (unsigned int)face.indices.size();
-            faces->mIndices = new unsigned int [faces->mNumIndices];
-
+            faces->mIndices = new unsigned int[faces->mNumIndices];
 
             aiVector3D faceNormal;
             bool fnOK = false;
 
-            for (unsigned int n = 0; n < faces->mNumIndices;++n, ++cnt, ++norms, ++verts)
-            {
-                if (face.indices[n] >= curMesh.verts.size())
-                {
+            for (unsigned int n = 0; n < faces->mNumIndices; ++n, ++cnt, ++norms, ++verts) {
+                if (face.indices[n] >= curMesh.verts.size()) {
                     ASSIMP_LOG_WARN("Quick3D: Vertex index overflow");
                     face.indices[n] = 0;
                 }
@@ -540,11 +504,9 @@ outer:
                 // copy vertices
                 *verts = curMesh.verts[face.indices[n]];
 
-                if (face.indices[n] >= curMesh.normals.size() && faces->mNumIndices >= 3)
-                {
+                if (face.indices[n] >= curMesh.normals.size() && faces->mNumIndices >= 3) {
                     // we have no normal here - assign the face normal
-                    if (!fnOK)
-                    {
+                    if (!fnOK) {
                         const aiVector3D &pV1 = curMesh.verts[face.indices[0]];
                         const aiVector3D &pV2 = curMesh.verts[face.indices[1]];
                         const aiVector3D &pV3 = curMesh.verts[face.indices.size() - 1];
@@ -557,16 +519,12 @@ outer:
                 }
 
                 // copy texture coordinates
-                if (uv && curMesh.uv.size())
-                {
+                if (uv && curMesh.uv.size()) {
                     if (curMesh.prevUVIdx != 0xffffffff && curMesh.uv.size() >= curMesh.verts.size()) // workaround
                     {
                         *uv = curMesh.uv[face.indices[n]];
-                    }
-                    else
-                    {
-                        if (face.uvindices[n] >= curMesh.uv.size())
-                        {
+                    } else {
+                        if (face.uvindices[n] >= curMesh.uv.size()) {
                             ASSIMP_LOG_WARN("Quick3D: Texture coordinate index overflow");
                             face.uvindices[n] = 0;
                         }
@@ -579,7 +537,6 @@ outer:
                 // setup the new vertex index
                 faces->mIndices[n] = cnt;
             }
-
         }
         ++real;
     }
@@ -589,8 +546,8 @@ outer:
 
     // Now we need to attach the meshes to the root node of the scene
     pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
-    pScene->mRootNode->mMeshes = new unsigned int [pScene->mNumMeshes];
-    for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
+    pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
+    for (unsigned int i = 0; i < pScene->mNumMeshes; ++i)
         pScene->mRootNode->mMeshes[i] = i;
 
     /*pScene->mRootNode->mTransformation *= aiMatrix4x4(
@@ -600,13 +557,12 @@ outer:
         0.f, 0.f, 0.f, 1.f);*/
 
     // Add cameras and light sources to the scene root node
-    pScene->mRootNode->mNumChildren = pScene->mNumLights+pScene->mNumCameras;
-    if (pScene->mRootNode->mNumChildren)
-    {
-        pScene->mRootNode->mChildren = new aiNode* [ pScene->mRootNode->mNumChildren ];
+    pScene->mRootNode->mNumChildren = pScene->mNumLights + pScene->mNumCameras;
+    if (pScene->mRootNode->mNumChildren) {
+        pScene->mRootNode->mChildren = new aiNode *[pScene->mRootNode->mNumChildren];
 
         // the light source
-        aiNode* nd = pScene->mRootNode->mChildren[0] = new aiNode();
+        aiNode *nd = pScene->mRootNode->mChildren[0] = new aiNode();
         nd->mParent = pScene->mRootNode;
         nd->mName.Set("Q3DLight");
         nd->mTransformation = pScene->mRootNode->mTransformation;

+ 102 - 131
code/AssetLib/Raw/RawLoader.cpp

@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
 
 Copyright (c) 2006-2020, assimp team
 
-
-
 All rights reserved.
 
 Redistribution and use of this software in source and binary forms,
@@ -45,18 +43,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *  @brief Implementation of the RAW importer class
  */
 
-
 #ifndef ASSIMP_BUILD_NO_RAW_IMPORTER
 
 // internal headers
 #include "RawLoader.h"
 #include <assimp/ParsingUtils.h>
 #include <assimp/fast_atof.h>
-#include <memory>
-#include <assimp/IOSystem.hpp>
-#include <assimp/DefaultLogger.hpp>
-#include <assimp/scene.h>
 #include <assimp/importerdesc.h>
+#include <assimp/scene.h>
+#include <assimp/DefaultLogger.hpp>
+#include <assimp/IOSystem.hpp>
+#include <memory>
 
 using namespace Assimp;
 
@@ -75,146 +72,129 @@ static const aiImporterDesc desc = {
 
 // ------------------------------------------------------------------------------------------------
 // Constructor to be privately used by Importer
-RAWImporter::RAWImporter()
-{}
+RAWImporter::RAWImporter() {
+    // empty
+}
 
 // ------------------------------------------------------------------------------------------------
 // Destructor, private as well
-RAWImporter::~RAWImporter()
-{}
+RAWImporter::~RAWImporter() {
+    // empty
+}
 
 // ------------------------------------------------------------------------------------------------
 // Returns whether the class can handle the format of the given file.
-bool RAWImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const
-{
-    return SimpleExtensionCheck(pFile,"raw");
+bool RAWImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
+    return SimpleExtensionCheck(pFile, "raw");
 }
 
 // ------------------------------------------------------------------------------------------------
-const aiImporterDesc* RAWImporter::GetInfo () const
-{
+const aiImporterDesc *RAWImporter::GetInfo() const {
     return &desc;
 }
 
 // ------------------------------------------------------------------------------------------------
 // Imports the given file into the given scene structure.
-void RAWImporter::InternReadFile( const std::string& pFile,
-    aiScene* pScene, IOSystem* pIOHandler)
-{
-    std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
+void RAWImporter::InternReadFile(const std::string &pFile,
+        aiScene *pScene, IOSystem *pIOHandler) {
+    std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
 
     // Check whether we can read from the file
-    if( file.get() == NULL) {
-        throw DeadlyImportError( "Failed to open RAW file " + pFile + ".");
+    if (file.get() == nullptr) {
+        throw DeadlyImportError("Failed to open RAW file " + pFile + ".");
     }
 
     // allocate storage and copy the contents of the file to a memory buffer
     // (terminate it with zero)
     std::vector<char> mBuffer2;
-    TextFileToBuffer(file.get(),mBuffer2);
-    const char* buffer = &mBuffer2[0];
+    TextFileToBuffer(file.get(), mBuffer2);
+    const char *buffer = &mBuffer2[0];
 
     // list of groups loaded from the file
-    std::vector< GroupInformation > outGroups(1,GroupInformation("<default>"));
-    std::vector< GroupInformation >::iterator curGroup = outGroups.begin();
+    std::vector<GroupInformation> outGroups(1, GroupInformation("<default>"));
+    std::vector<GroupInformation>::iterator curGroup = outGroups.begin();
 
     // now read all lines
     char line[4096];
-    while (GetNextLine(buffer,line))
-    {
+    while (GetNextLine(buffer, line)) {
         // if the line starts with a non-numeric identifier, it marks
         // the beginning of a new group
-        const char* sz = line;SkipSpaces(&sz);
-        if (IsLineEnd(*sz))continue;
-        if (!IsNumeric(*sz))
-        {
-            const char* sz2 = sz;
-            while (!IsSpaceOrNewLine(*sz2))++sz2;
-            const unsigned int length = (unsigned int)(sz2-sz);
+        const char *sz = line;
+        SkipSpaces(&sz);
+        if (IsLineEnd(*sz)) continue;
+        if (!IsNumeric(*sz)) {
+            const char *sz2 = sz;
+            while (!IsSpaceOrNewLine(*sz2))
+                ++sz2;
+            const unsigned int length = (unsigned int)(sz2 - sz);
 
             // find an existing group with this name
-            for (std::vector< GroupInformation >::iterator it = outGroups.begin(), end = outGroups.end();
-                it != end;++it)
-            {
-                if (length == (*it).name.length() && !::strcmp(sz,(*it).name.c_str()))
-                {
-                    curGroup = it;sz2 = NULL;
+            for (std::vector<GroupInformation>::iterator it = outGroups.begin(), end = outGroups.end();
+                    it != end; ++it) {
+                if (length == (*it).name.length() && !::strcmp(sz, (*it).name.c_str())) {
+                    curGroup = it;
+                    sz2 = nullptr;
                     break;
                 }
             }
-            if (sz2)
-            {
-                outGroups.push_back(GroupInformation(std::string(sz,length)));
-                curGroup = outGroups.end()-1;
+            if (sz2) {
+                outGroups.push_back(GroupInformation(std::string(sz, length)));
+                curGroup = outGroups.end() - 1;
             }
-        }
-        else
-        {
+        } else {
             // there can be maximally 12 floats plus an extra texture file name
             float data[12];
             unsigned int num;
-            for (num = 0; num < 12;++num)
-            {
-                if(!SkipSpaces(&sz) || !IsNumeric(*sz))break;
-                sz = fast_atoreal_move<float>(sz,data[num]);
+            for (num = 0; num < 12; ++num) {
+                if (!SkipSpaces(&sz) || !IsNumeric(*sz)) break;
+                sz = fast_atoreal_move<float>(sz, data[num]);
             }
-            if (num != 12 && num != 9)
-            {
+            if (num != 12 && num != 9) {
                 ASSIMP_LOG_ERROR("A line may have either 9 or 12 floats and an optional texture");
                 continue;
             }
 
-            MeshInformation* output = NULL;
+            MeshInformation *output = nullptr;
 
-            const char* sz2 = sz;
+            const char *sz2 = sz;
             unsigned int length;
-            if (!IsLineEnd(*sz))
-            {
-                while (!IsSpaceOrNewLine(*sz2))++sz2;
-                length = (unsigned int)(sz2-sz);
-            }
-            else if (9 == num)
-            {
+            if (!IsLineEnd(*sz)) {
+                while (!IsSpaceOrNewLine(*sz2))
+                    ++sz2;
+                length = (unsigned int)(sz2 - sz);
+            } else if (9 == num) {
                 sz = "%default%";
                 length = 9;
-            }
-            else
-            {
+            } else {
                 sz = "";
                 length = 0;
             }
 
             // search in the list of meshes whether we have one with this texture
-            for (auto &mesh : (*curGroup).meshes)
-            {
-                if (length == mesh.name.length() && (length ? !::strcmp(sz, mesh.name.c_str()) : true))
-                {
+            for (auto &mesh : (*curGroup).meshes) {
+                if (length == mesh.name.length() && (length ? !::strcmp(sz, mesh.name.c_str()) : true)) {
                     output = &mesh;
                     break;
                 }
             }
             // if we don't have the mesh, create it
-            if (!output)
-            {
-                (*curGroup).meshes.push_back(MeshInformation(std::string(sz,length)));
+            if (!output) {
+                (*curGroup).meshes.push_back(MeshInformation(std::string(sz, length)));
                 output = &((*curGroup).meshes.back());
             }
-            if (12 == num)
-            {
-                aiColor4D v(data[0],data[1],data[2],1.0f);
+            if (12 == num) {
+                aiColor4D v(data[0], data[1], data[2], 1.0f);
                 output->colors.push_back(v);
                 output->colors.push_back(v);
                 output->colors.push_back(v);
 
-                output->vertices.push_back(aiVector3D(data[3],data[4],data[5]));
-                output->vertices.push_back(aiVector3D(data[6],data[7],data[8]));
-                output->vertices.push_back(aiVector3D(data[9],data[10],data[11]));
-            }
-            else
-            {
-                output->vertices.push_back(aiVector3D(data[0],data[1],data[2]));
-                output->vertices.push_back(aiVector3D(data[3],data[4],data[5]));
-                output->vertices.push_back(aiVector3D(data[6],data[7],data[8]));
+                output->vertices.push_back(aiVector3D(data[3], data[4], data[5]));
+                output->vertices.push_back(aiVector3D(data[6], data[7], data[8]));
+                output->vertices.push_back(aiVector3D(data[9], data[10], data[11]));
+            } else {
+                output->vertices.push_back(aiVector3D(data[0], data[1], data[2]));
+                output->vertices.push_back(aiVector3D(data[3], data[4], data[5]));
+                output->vertices.push_back(aiVector3D(data[6], data[7], data[8]));
             }
         }
     }
@@ -224,105 +204,96 @@ void RAWImporter::InternReadFile( const std::string& pFile,
 
     // count the number of valid groups
     // (meshes can't be empty)
-    for (auto & outGroup : outGroups)
-    {
-        if (!outGroup.meshes.empty())
-        {
+    for (auto &outGroup : outGroups) {
+        if (!outGroup.meshes.empty()) {
             ++pScene->mRootNode->mNumChildren;
-            pScene->mNumMeshes += (unsigned int) outGroup.meshes.size();
+            pScene->mNumMeshes += (unsigned int)outGroup.meshes.size();
         }
     }
 
-    if (!pScene->mNumMeshes)
-    {
+    if (!pScene->mNumMeshes) {
         throw DeadlyImportError("RAW: No meshes loaded. The file seems to be corrupt or empty.");
     }
 
-    pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
-    aiNode** cc;
-    if (1 == pScene->mRootNode->mNumChildren)
-    {
+    pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
+    aiNode **cc;
+    if (1 == pScene->mRootNode->mNumChildren) {
         cc = &pScene->mRootNode;
         pScene->mRootNode->mNumChildren = 0;
     } else {
-        cc = new aiNode*[pScene->mRootNode->mNumChildren];
-        memset(cc, 0, sizeof(aiNode*) * pScene->mRootNode->mNumChildren);
+        cc = new aiNode *[pScene->mRootNode->mNumChildren];
+        memset(cc, 0, sizeof(aiNode *) * pScene->mRootNode->mNumChildren);
         pScene->mRootNode->mChildren = cc;
     }
 
     pScene->mNumMaterials = pScene->mNumMeshes;
-    aiMaterial** mats = pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
+    aiMaterial **mats = pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
 
     unsigned int meshIdx = 0;
-    for (auto & outGroup : outGroups)
-    {
-        if (outGroup.meshes.empty())continue;
+    for (auto &outGroup : outGroups) {
+        if (outGroup.meshes.empty()) continue;
 
-        aiNode* node;
-        if (pScene->mRootNode->mNumChildren)
-        {
+        aiNode *node;
+        if (pScene->mRootNode->mNumChildren) {
             node = *cc = new aiNode();
             node->mParent = pScene->mRootNode;
-        }
-        else node = *cc;
+        } else
+            node = *cc;
         node->mName.Set(outGroup.name);
 
         // add all meshes
-        node->mNumMeshes = (unsigned int) outGroup.meshes.size();
-        unsigned int* pi = node->mMeshes = new unsigned int[ node->mNumMeshes ];
-        for (std::vector< MeshInformation >::iterator it2 = outGroup.meshes.begin(),
-            end2 = outGroup.meshes.end(); it2 != end2; ++it2)
-        {
+        node->mNumMeshes = (unsigned int)outGroup.meshes.size();
+        unsigned int *pi = node->mMeshes = new unsigned int[node->mNumMeshes];
+        for (std::vector<MeshInformation>::iterator it2 = outGroup.meshes.begin(),
+                                                    end2 = outGroup.meshes.end();
+                it2 != end2; ++it2) {
             ai_assert(!(*it2).vertices.empty());
 
             // allocate the mesh
             *pi++ = meshIdx;
-            aiMesh* mesh = pScene->mMeshes[meshIdx] = new aiMesh();
+            aiMesh *mesh = pScene->mMeshes[meshIdx] = new aiMesh();
             mesh->mMaterialIndex = meshIdx++;
 
             mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
 
             // allocate storage for the vertex components and copy them
             mesh->mNumVertices = (unsigned int)(*it2).vertices.size();
-            mesh->mVertices = new aiVector3D[ mesh->mNumVertices ];
-            ::memcpy(mesh->mVertices,&(*it2).vertices[0],sizeof(aiVector3D)*mesh->mNumVertices);
+            mesh->mVertices = new aiVector3D[mesh->mNumVertices];
+            ::memcpy(mesh->mVertices, &(*it2).vertices[0], sizeof(aiVector3D) * mesh->mNumVertices);
 
-            if ((*it2).colors.size())
-            {
+            if ((*it2).colors.size()) {
                 ai_assert((*it2).colors.size() == mesh->mNumVertices);
 
-                mesh->mColors[0] = new aiColor4D[ mesh->mNumVertices ];
-                ::memcpy(mesh->mColors[0],&(*it2).colors[0],sizeof(aiColor4D)*mesh->mNumVertices);
+                mesh->mColors[0] = new aiColor4D[mesh->mNumVertices];
+                ::memcpy(mesh->mColors[0], &(*it2).colors[0], sizeof(aiColor4D) * mesh->mNumVertices);
             }
 
             // generate triangles
             ai_assert(0 == mesh->mNumVertices % 3);
-            aiFace* fc = mesh->mFaces = new aiFace[ mesh->mNumFaces = mesh->mNumVertices/3 ];
-            aiFace* const fcEnd = fc + mesh->mNumFaces;
+            aiFace *fc = mesh->mFaces = new aiFace[mesh->mNumFaces = mesh->mNumVertices / 3];
+            aiFace *const fcEnd = fc + mesh->mNumFaces;
             unsigned int n = 0;
-            while (fc != fcEnd)
-            {
-                aiFace& f = *fc++;
+            while (fc != fcEnd) {
+                aiFace &f = *fc++;
                 f.mIndices = new unsigned int[f.mNumIndices = 3];
-                for (unsigned int m = 0; m < 3;++m)
+                for (unsigned int m = 0; m < 3; ++m)
                     f.mIndices[m] = n++;
             }
 
             // generate a material for the mesh
-            aiMaterial* mat = new aiMaterial();
+            aiMaterial *mat = new aiMaterial();
 
-            aiColor4D clr(1.0f,1.0f,1.0f,1.0f);
+            aiColor4D clr(1.0f, 1.0f, 1.0f, 1.0f);
             if ("%default%" == (*it2).name) // a gray default material
             {
                 clr.r = clr.g = clr.b = 0.6f;
-            }
-            else if ((*it2).name.length() > 0) // a texture
+            } else if ((*it2).name.length() > 0) // a texture
             {
                 aiString s;
                 s.Set((*it2).name);
-                mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0));
+                mat->AddProperty(&s, AI_MATKEY_TEXTURE_DIFFUSE(0));
             }
-            mat->AddProperty<aiColor4D>(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
+            mat->AddProperty<aiColor4D>(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
             *mats++ = mat;
         }
     }

+ 180 - 239
code/AssetLib/SIB/SIBImporter.cpp

@@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *  Nevertheless, this implementation is reasonably complete.
  */
 
-
 #ifndef ASSIMP_BUILD_NO_SIB_IMPORTER
 
 // internal headers
@@ -60,15 +59,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <assimp/StreamReader.h>
 #include <assimp/TinyFormatter.h>
 #ifdef ASSIMP_USE_HUNTER
-#  include <utf8/utf8.h>
+#include <utf8/utf8.h>
 #else
 //#  include "../contrib/ConvertUTF/ConvertUTF.h"
-#  include "../contrib/utf8cpp/source/utf8.h"
+#include "../contrib/utf8cpp/source/utf8.h"
 #endif
-#include <assimp/IOSystem.hpp>
-#include <assimp/DefaultLogger.hpp>
-#include <assimp/scene.h>
 #include <assimp/importerdesc.h>
+#include <assimp/scene.h>
+#include <assimp/DefaultLogger.hpp>
+#include <assimp/IOSystem.hpp>
 
 #include <map>
 
@@ -86,14 +85,14 @@ static const aiImporterDesc desc = {
 };
 
 struct SIBChunk {
-    uint32_t    Tag;
-    uint32_t    Size;
+    uint32_t Tag;
+    uint32_t Size;
 } PACK_STRUCT;
 
-enum { 
-    POS, 
-    NRM, 
-    UV,    
+enum {
+    POS,
+    NRM,
+    UV,
     N
 };
 
@@ -122,14 +121,14 @@ struct SIBObject {
 };
 
 struct SIB {
-    std::vector<aiMaterial*> mtls;
-    std::vector<aiMesh*> meshes;
-    std::vector<aiLight*> lights;
+    std::vector<aiMaterial *> mtls;
+    std::vector<aiMesh *> meshes;
+    std::vector<aiLight *> lights;
     std::vector<SIBObject> objs, insts;
 };
 
 // ------------------------------------------------------------------------------------------------
-static SIBEdge& GetEdge(SIBMesh* mesh, uint32_t posA, uint32_t posB) {
+static SIBEdge &GetEdge(SIBMesh *mesh, uint32_t posA, uint32_t posB) {
     SIBPair pair = (posA < posB) ? SIBPair(posA, posB) : SIBPair(posB, posA);
     std::map<SIBPair, uint32_t>::iterator it = mesh->edgeMap.find(pair);
     if (it != mesh->edgeMap.end())
@@ -146,10 +145,9 @@ static SIBEdge& GetEdge(SIBMesh* mesh, uint32_t posA, uint32_t posB) {
 // ------------------------------------------------------------------------------------------------
 // Helpers for reading chunked data.
 
-#define TAG(A,B,C,D) ((A << 24) | (B << 16) | (C << 8) | D)
+#define TAG(A, B, C, D) ((A << 24) | (B << 16) | (C << 8) | D)
 
-static SIBChunk ReadChunk(StreamReaderLE* stream)
-{
+static SIBChunk ReadChunk(StreamReaderLE *stream) {
     SIBChunk chunk;
     chunk.Tag = stream->GetU4();
     chunk.Size = stream->GetU4();
@@ -159,8 +157,7 @@ static SIBChunk ReadChunk(StreamReaderLE* stream)
     return chunk;
 }
 
-static aiColor3D ReadColor(StreamReaderLE* stream)
-{
+static aiColor3D ReadColor(StreamReaderLE *stream) {
     float r = stream->GetF4();
     float g = stream->GetF4();
     float b = stream->GetF4();
@@ -168,37 +165,36 @@ static aiColor3D ReadColor(StreamReaderLE* stream)
     return aiColor3D(r, g, b);
 }
 
-static void UnknownChunk(StreamReaderLE* /*stream*/, const SIBChunk& chunk)
-{
+static void UnknownChunk(StreamReaderLE * /*stream*/, const SIBChunk &chunk) {
     char temp[5] = {
-        static_cast<char>(( chunk.Tag>>24 ) & 0xff),
-        static_cast<char>(( chunk.Tag>>16 ) & 0xff),
-        static_cast<char>(( chunk.Tag>>8 ) & 0xff),
+        static_cast<char>((chunk.Tag >> 24) & 0xff),
+        static_cast<char>((chunk.Tag >> 16) & 0xff),
+        static_cast<char>((chunk.Tag >> 8) & 0xff),
         static_cast<char>(chunk.Tag & 0xff), '\0'
     };
 
-    ASSIMP_LOG_WARN((Formatter::format(), "SIB: Skipping unknown '",temp,"' chunk."));
+    ASSIMP_LOG_WARN((Formatter::format(), "SIB: Skipping unknown '", temp, "' chunk."));
 }
 
 // Reads a UTF-16LE string and returns it at UTF-8.
 static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) {
-    if ( nullptr == stream || 0 == numWChars ) {
+    if (nullptr == stream || 0 == numWChars) {
         static const aiString empty;
         return empty;
     }
 
     // Allocate buffers (max expansion is 1 byte -> 4 bytes for UTF-8)
     std::vector<unsigned char> str;
-    str.reserve( numWChars * 4 + 1 );
-    uint16_t *temp = new uint16_t[ numWChars ];
-    for ( uint32_t n = 0; n < numWChars; ++n ) {
-        temp[ n ] = stream->GetU2();
+    str.reserve(numWChars * 4 + 1);
+    uint16_t *temp = new uint16_t[numWChars];
+    for (uint32_t n = 0; n < numWChars; ++n) {
+        temp[n] = stream->GetU2();
     }
 
     // Convert it and NUL-terminate.
-    const uint16_t *start( temp ), *end( temp + numWChars );
-    utf8::utf16to8( start, end, back_inserter( str ) );
-    str[ str.size() - 1 ] = '\0';
+    const uint16_t *start(temp), *end(temp + numWChars);
+    utf8::utf16to8(start, end, back_inserter(str));
+    str[str.size() - 1] = '\0';
 
     // Return the final string.
     aiString result = aiString((const char *)&str[0]);
@@ -221,52 +217,49 @@ SIBImporter::~SIBImporter() {
 
 // ------------------------------------------------------------------------------------------------
 // Returns whether the class can handle the format of the given file.
-bool SIBImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const {
+bool SIBImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
     return SimpleExtensionCheck(pFile, "sib");
 }
 
 // ------------------------------------------------------------------------------------------------
-const aiImporterDesc* SIBImporter::GetInfo () const {
+const aiImporterDesc *SIBImporter::GetInfo() const {
     return &desc;
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadVerts(SIBMesh* mesh, StreamReaderLE* stream, uint32_t count) {
-    if ( nullptr == mesh || nullptr == stream ) {
+static void ReadVerts(SIBMesh *mesh, StreamReaderLE *stream, uint32_t count) {
+    if (nullptr == mesh || nullptr == stream) {
         return;
     }
 
     mesh->pos.resize(count);
-    for ( uint32_t n=0; n<count; ++n ) {
-        mesh->pos[ n ].x = stream->GetF4();
-        mesh->pos[ n ].y = stream->GetF4();
-        mesh->pos[ n ].z = stream->GetF4();
+    for (uint32_t n = 0; n < count; ++n) {
+        mesh->pos[n].x = stream->GetF4();
+        mesh->pos[n].y = stream->GetF4();
+        mesh->pos[n].z = stream->GetF4();
     }
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadFaces(SIBMesh* mesh, StreamReaderLE* stream)
-{
+static void ReadFaces(SIBMesh *mesh, StreamReaderLE *stream) {
     uint32_t ptIdx = 0;
-    while (stream->GetRemainingSizeToLimit() > 0)
-    {
+    while (stream->GetRemainingSizeToLimit() > 0) {
         uint32_t numPoints = stream->GetU4();
 
         // Store room for the N index channels, plus the point count.
         size_t pos = mesh->idx.size() + 1;
-        mesh->idx.resize(pos + numPoints*N);
-        mesh->idx[pos-1] = numPoints;
+        mesh->idx.resize(pos + numPoints * N);
+        mesh->idx[pos - 1] = numPoints;
         uint32_t *idx = &mesh->idx[pos];
 
-        mesh->faceStart.push_back(static_cast<uint32_t>(pos-1));
+        mesh->faceStart.push_back(static_cast<uint32_t>(pos - 1));
         mesh->mtls.push_back(0);
 
         // Read all the position data.
         // UV/normals will be supplied later.
         // Positions are supplied indexed already, so we preserve that
         // mapping. UVs are supplied uniquely, so we allocate unique indices.
-        for (uint32_t n=0;n<numPoints;n++,idx+=N,ptIdx++)
-        {
+        for (uint32_t n = 0; n < numPoints; n++, idx += N, ptIdx++) {
             uint32_t p = stream->GetU4();
             if (p >= mesh->pos.size())
                 throw DeadlyImportError("Vertex index is out of range.");
@@ -277,17 +270,15 @@ static void ReadFaces(SIBMesh* mesh, StreamReaderLE* stream)
     }
 
     // Allocate data channels for normals/UVs.
-    mesh->nrm.resize(ptIdx, aiVector3D(0,0,0));
-    mesh->uv.resize(ptIdx, aiVector3D(0,0,0));
+    mesh->nrm.resize(ptIdx, aiVector3D(0, 0, 0));
+    mesh->uv.resize(ptIdx, aiVector3D(0, 0, 0));
 
     mesh->numPts = ptIdx;
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadUVs(SIBMesh* mesh, StreamReaderLE* stream)
-{
-    while (stream->GetRemainingSizeToLimit() > 0)
-    {
+static void ReadUVs(SIBMesh *mesh, StreamReaderLE *stream) {
+    while (stream->GetRemainingSizeToLimit() > 0) {
         uint32_t faceIdx = stream->GetU4();
         uint32_t numPoints = stream->GetU4();
 
@@ -297,8 +288,7 @@ static void ReadUVs(SIBMesh* mesh, StreamReaderLE* stream)
         uint32_t pos = mesh->faceStart[faceIdx];
         uint32_t *idx = &mesh->idx[pos + 1];
 
-        for (uint32_t n=0;n<numPoints;n++,idx+=N)
-        {
+        for (uint32_t n = 0; n < numPoints; n++, idx += N) {
             uint32_t id = idx[UV];
             mesh->uv[id].x = stream->GetF4();
             mesh->uv[id].y = stream->GetF4();
@@ -307,19 +297,16 @@ static void ReadUVs(SIBMesh* mesh, StreamReaderLE* stream)
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadMtls(SIBMesh* mesh, StreamReaderLE* stream)
-{
+static void ReadMtls(SIBMesh *mesh, StreamReaderLE *stream) {
     // Material assignments are stored run-length encoded.
     // Also, we add 1 to each material so that we can use mtl #0
     // as the default material.
     uint32_t prevFace = stream->GetU4();
     uint32_t prevMtl = stream->GetU4() + 1;
-    while (stream->GetRemainingSizeToLimit() > 0)
-    {
+    while (stream->GetRemainingSizeToLimit() > 0) {
         uint32_t face = stream->GetU4();
         uint32_t mtl = stream->GetU4() + 1;
-        while (prevFace < face)
-        {
+        while (prevFace < face) {
             if (prevFace >= mesh->mtls.size())
                 throw DeadlyImportError("Invalid face index.");
             mesh->mtls[prevFace++] = prevMtl;
@@ -334,8 +321,7 @@ static void ReadMtls(SIBMesh* mesh, StreamReaderLE* stream)
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadAxis(aiMatrix4x4& axis, StreamReaderLE* stream)
-{
+static void ReadAxis(aiMatrix4x4 &axis, StreamReaderLE *stream) {
     axis.a4 = stream->GetF4();
     axis.b4 = stream->GetF4();
     axis.c4 = stream->GetF4();
@@ -355,10 +341,8 @@ static void ReadAxis(aiMatrix4x4& axis, StreamReaderLE* stream)
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadEdges(SIBMesh* mesh, StreamReaderLE* stream)
-{
-    while (stream->GetRemainingSizeToLimit() > 0)
-    {
+static void ReadEdges(SIBMesh *mesh, StreamReaderLE *stream) {
+    while (stream->GetRemainingSizeToLimit() > 0) {
         uint32_t posA = stream->GetU4();
         uint32_t posB = stream->GetU4();
         GetEdge(mesh, posA, posB);
@@ -366,10 +350,8 @@ static void ReadEdges(SIBMesh* mesh, StreamReaderLE* stream)
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadCreases(SIBMesh* mesh, StreamReaderLE* stream)
-{
-    while (stream->GetRemainingSizeToLimit() > 0)
-    {
+static void ReadCreases(SIBMesh *mesh, StreamReaderLE *stream) {
+    while (stream->GetRemainingSizeToLimit() > 0) {
         uint32_t edge = stream->GetU4();
         if (edge >= mesh->edges.size())
             throw DeadlyImportError("SIB: Invalid edge index.");
@@ -378,22 +360,19 @@ static void ReadCreases(SIBMesh* mesh, StreamReaderLE* stream)
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ConnectFaces(SIBMesh* mesh)
-{
+static void ConnectFaces(SIBMesh *mesh) {
     // Find faces connected to each edge.
     size_t numFaces = mesh->faceStart.size();
-    for (size_t faceIdx=0;faceIdx<numFaces;faceIdx++)
-    {
+    for (size_t faceIdx = 0; faceIdx < numFaces; faceIdx++) {
         uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]];
         uint32_t numPoints = *idx++;
-        uint32_t prev = idx[(numPoints-1)*N+POS];
+        uint32_t prev = idx[(numPoints - 1) * N + POS];
 
-        for (uint32_t i=0;i<numPoints;i++,idx+=N)
-        {
+        for (uint32_t i = 0; i < numPoints; i++, idx += N) {
             uint32_t next = idx[POS];
 
             // Find this edge.
-            SIBEdge& edge = GetEdge(mesh, prev, next);
+            SIBEdge &edge = GetEdge(mesh, prev, next);
 
             // Link this face onto it.
             // This gives potentially undesirable normals when used
@@ -409,45 +388,39 @@ static void ConnectFaces(SIBMesh* mesh)
 }
 
 // ------------------------------------------------------------------------------------------------
-static aiVector3D CalculateVertexNormal(SIBMesh* mesh, uint32_t faceIdx, uint32_t pos,
-                                        const std::vector<aiVector3D>& faceNormals)
-{
+static aiVector3D CalculateVertexNormal(SIBMesh *mesh, uint32_t faceIdx, uint32_t pos,
+        const std::vector<aiVector3D> &faceNormals) {
     // Creased edges complicate this. We need to find the start/end range of the
     // ring of faces that touch this position.
     // We do this in two passes. The first pass is to find the end of the range,
     // the second is to work backwards to the start and calculate the final normal.
     aiVector3D vtxNormal;
-    for (int pass=0;pass<2;pass++)
-    {
+    for (int pass = 0; pass < 2; pass++) {
         vtxNormal = aiVector3D(0, 0, 0);
         uint32_t startFaceIdx = faceIdx;
         uint32_t prevFaceIdx = faceIdx;
 
         // Process each connected face.
-        while (true)
-        {
+        while (true) {
             // Accumulate the face normal.
             vtxNormal += faceNormals[faceIdx];
 
             uint32_t nextFaceIdx = 0xffffffff;
 
             // Move to the next edge sharing this position.
-            uint32_t* idx = &mesh->idx[mesh->faceStart[faceIdx]];
+            uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]];
             uint32_t numPoints = *idx++;
-            uint32_t posA = idx[(numPoints-1)*N+POS];
-            for (uint32_t n=0;n<numPoints;n++,idx+=N)
-            {
+            uint32_t posA = idx[(numPoints - 1) * N + POS];
+            for (uint32_t n = 0; n < numPoints; n++, idx += N) {
                 uint32_t posB = idx[POS];
 
                 // Test if this edge shares our target position.
-                if (posA == pos || posB == pos)
-                {
-                    SIBEdge& edge = GetEdge(mesh, posA, posB);
+                if (posA == pos || posB == pos) {
+                    SIBEdge &edge = GetEdge(mesh, posA, posB);
 
                     // Non-manifold meshes can produce faces which share
                     // positions but have no edge entry, so check it.
-                    if (edge.faceA == faceIdx || edge.faceB == faceIdx)
-                    {
+                    if (edge.faceA == faceIdx || edge.faceB == faceIdx) {
                         // Move to whichever side we didn't just come from.
                         if (!edge.creased) {
                             if (edge.faceA != prevFaceIdx && edge.faceA != faceIdx && edge.faceA != 0xffffffff)
@@ -479,24 +452,21 @@ static aiVector3D CalculateVertexNormal(SIBMesh* mesh, uint32_t faceIdx, uint32_
 }
 
 // ------------------------------------------------------------------------------------------------
-static void CalculateNormals(SIBMesh* mesh)
-{
+static void CalculateNormals(SIBMesh *mesh) {
     size_t numFaces = mesh->faceStart.size();
 
     // Calculate face normals.
     std::vector<aiVector3D> faceNormals(numFaces);
-    for (size_t faceIdx=0;faceIdx<numFaces;faceIdx++)
-    {
-        uint32_t* idx = &mesh->idx[mesh->faceStart[faceIdx]];
+    for (size_t faceIdx = 0; faceIdx < numFaces; faceIdx++) {
+        uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]];
         uint32_t numPoints = *idx++;
 
         aiVector3D faceNormal(0, 0, 0);
 
-        uint32_t *prev = &idx[(numPoints-1)*N];
+        uint32_t *prev = &idx[(numPoints - 1) * N];
 
-        for (uint32_t i=0;i<numPoints;i++)
-        {
-            uint32_t *next = &idx[i*N];
+        for (uint32_t i = 0; i < numPoints; i++) {
+            uint32_t *next = &idx[i * N];
 
             faceNormal += mesh->pos[prev[POS]] ^ mesh->pos[next[POS]];
             prev = next;
@@ -506,15 +476,13 @@ static void CalculateNormals(SIBMesh* mesh)
     }
 
     // Calculate vertex normals.
-    for (size_t faceIdx=0;faceIdx<numFaces;faceIdx++)
-    {
-        uint32_t* idx = &mesh->idx[mesh->faceStart[faceIdx]];
+    for (size_t faceIdx = 0; faceIdx < numFaces; faceIdx++) {
+        uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]];
         uint32_t numPoints = *idx++;
 
-        for (uint32_t i=0;i<numPoints;i++)
-        {
-            uint32_t pos = idx[i*N+POS];
-            uint32_t nrm = idx[i*N+NRM];
+        for (uint32_t i = 0; i < numPoints; i++) {
+            uint32_t pos = idx[i * N + POS];
+            uint32_t nrm = idx[i * N + NRM];
             aiVector3D vtxNorm = CalculateVertexNormal(mesh, static_cast<uint32_t>(faceIdx), pos, faceNormals);
             mesh->nrm[nrm] = vtxNorm;
         }
@@ -522,43 +490,39 @@ static void CalculateNormals(SIBMesh* mesh)
 }
 
 // ------------------------------------------------------------------------------------------------
-struct TempMesh
-{
+struct TempMesh {
     std::vector<aiVector3D> vtx;
     std::vector<aiVector3D> nrm;
     std::vector<aiVector3D> uv;
-    std::vector<aiFace>     faces;
+    std::vector<aiFace> faces;
 };
 
-static void ReadShape(SIB* sib, StreamReaderLE* stream)
-{
+static void ReadShape(SIB *sib, StreamReaderLE *stream) {
     SIBMesh smesh;
     aiString name;
 
-    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk))
-    {
+    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) {
         SIBChunk chunk = ReadChunk(stream);
         unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size);
 
-        switch (chunk.Tag)
-        {
-        case TAG('M','I','R','P'): break; // mirror plane maybe?
-        case TAG('I','M','R','P'): break; // instance mirror? (not supported here yet)
-        case TAG('D','I','N','F'): break; // display info, not needed
-        case TAG('P','I','N','F'): break; // ?
-        case TAG('V','M','I','R'): break; // ?
-        case TAG('F','M','I','R'): break; // ?
-        case TAG('T','X','S','M'): break; // ?
-        case TAG('F','A','H','S'): break; // ?
-        case TAG('V','R','T','S'): ReadVerts(&smesh, stream, chunk.Size/12); break;
-        case TAG('F','A','C','S'): ReadFaces(&smesh, stream); break;
-        case TAG('F','T','V','S'): ReadUVs(&smesh, stream); break;
-        case TAG('S','N','A','M'): name = ReadString(stream, chunk.Size/2); break;
-        case TAG('F','A','M','A'): ReadMtls(&smesh, stream); break;
-        case TAG('A','X','I','S'): ReadAxis(smesh.axis, stream); break;
-        case TAG('E','D','G','S'): ReadEdges(&smesh, stream); break;
-        case TAG('E','C','R','S'): ReadCreases(&smesh, stream); break;
-        default:                   UnknownChunk(stream, chunk); break;
+        switch (chunk.Tag) {
+        case TAG('M', 'I', 'R', 'P'): break; // mirror plane maybe?
+        case TAG('I', 'M', 'R', 'P'): break; // instance mirror? (not supported here yet)
+        case TAG('D', 'I', 'N', 'F'): break; // display info, not needed
+        case TAG('P', 'I', 'N', 'F'): break; // ?
+        case TAG('V', 'M', 'I', 'R'): break; // ?
+        case TAG('F', 'M', 'I', 'R'): break; // ?
+        case TAG('T', 'X', 'S', 'M'): break; // ?
+        case TAG('F', 'A', 'H', 'S'): break; // ?
+        case TAG('V', 'R', 'T', 'S'): ReadVerts(&smesh, stream, chunk.Size / 12); break;
+        case TAG('F', 'A', 'C', 'S'): ReadFaces(&smesh, stream); break;
+        case TAG('F', 'T', 'V', 'S'): ReadUVs(&smesh, stream); break;
+        case TAG('S', 'N', 'A', 'M'): name = ReadString(stream, chunk.Size / 2); break;
+        case TAG('F', 'A', 'M', 'A'): ReadMtls(&smesh, stream); break;
+        case TAG('A', 'X', 'I', 'S'): ReadAxis(smesh.axis, stream); break;
+        case TAG('E', 'D', 'G', 'S'): ReadEdges(&smesh, stream); break;
+        case TAG('E', 'C', 'R', 'S'): ReadCreases(&smesh, stream); break;
+        default: UnknownChunk(stream, chunk); break;
         }
 
         stream->SetCurrentPos(stream->GetReadLimit());
@@ -585,25 +549,22 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream)
     std::vector<TempMesh> meshes(sib->mtls.size());
 
     // Un-index the source data and apply to each vertex.
-    for (unsigned fi=0;fi<smesh.faceStart.size();fi++)
-    {
+    for (unsigned fi = 0; fi < smesh.faceStart.size(); fi++) {
         uint32_t start = smesh.faceStart[fi];
         uint32_t mtl = smesh.mtls[fi];
         uint32_t *idx = &smesh.idx[start];
 
-        if (mtl >= meshes.size())
-        {
+        if (mtl >= meshes.size()) {
             ASSIMP_LOG_ERROR("SIB: Face material index is invalid.");
             mtl = 0;
         }
 
-        TempMesh& dest = meshes[mtl];
+        TempMesh &dest = meshes[mtl];
 
         aiFace face;
         face.mNumIndices = *idx++;
         face.mIndices = new unsigned[face.mNumIndices];
-        for (unsigned pt=0;pt<face.mNumIndices;pt++,idx+=N)
-        {
+        for (unsigned pt = 0; pt < face.mNumIndices; pt++, idx += N) {
             size_t vtxIdx = dest.vtx.size();
             face.mIndices[pt] = static_cast<unsigned int>(vtxIdx);
 
@@ -611,7 +572,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream)
             // we did it when creating the data.
             aiVector3D pos = smesh.pos[idx[POS]];
             aiVector3D nrm = smesh.nrm[idx[NRM]];
-            aiVector3D uv  = smesh.uv[idx[UV]];
+            aiVector3D uv = smesh.uv[idx[UV]];
 
             // The verts are supplied in world-space, so let's
             // transform them back into the local space of this mesh:
@@ -632,13 +593,12 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream)
 
     // Now that we know the size of everything,
     // we can build the final one-material-per-mesh data.
-    for (size_t n=0;n<meshes.size();n++)
-    {
-        TempMesh& src = meshes[n];
+    for (size_t n = 0; n < meshes.size(); n++) {
+        TempMesh &src = meshes[n];
         if (src.faces.empty())
             continue;
 
-        aiMesh* mesh = new aiMesh;
+        aiMesh *mesh = new aiMesh;
         mesh->mName = name;
         mesh->mNumFaces = static_cast<unsigned int>(src.faces.size());
         mesh->mFaces = new aiFace[mesh->mNumFaces];
@@ -649,14 +609,12 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream)
         mesh->mNumUVComponents[0] = 2;
         mesh->mMaterialIndex = static_cast<unsigned int>(n);
 
-        for (unsigned i=0;i<mesh->mNumVertices;i++)
-        {
+        for (unsigned i = 0; i < mesh->mNumVertices; i++) {
             mesh->mVertices[i] = src.vtx[i];
             mesh->mNormals[i] = src.nrm[i];
             mesh->mTextureCoords[0][i] = src.uv[i];
         }
-        for (unsigned i=0;i<mesh->mNumFaces;i++)
-        {
+        for (unsigned i = 0; i < mesh->mNumFaces; i++) {
             mesh->mFaces[i] = src.faces[i];
         }
 
@@ -668,8 +626,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream)
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadMaterial(SIB* sib, StreamReaderLE* stream)
-{
+static void ReadMaterial(SIB *sib, StreamReaderLE *stream) {
     aiColor3D diff = ReadColor(stream);
     aiColor3D ambi = ReadColor(stream);
     aiColor3D spec = ReadColor(stream);
@@ -677,11 +634,11 @@ static void ReadMaterial(SIB* sib, StreamReaderLE* stream)
     float shiny = (float)stream->GetU4();
 
     uint32_t nameLen = stream->GetU4();
-    aiString name = ReadString(stream, nameLen/2);
+    aiString name = ReadString(stream, nameLen / 2);
     uint32_t texLen = stream->GetU4();
-    aiString tex = ReadString(stream, texLen/2);
+    aiString tex = ReadString(stream, texLen / 2);
 
-    aiMaterial* mtl = new aiMaterial();
+    aiMaterial *mtl = new aiMaterial();
     mtl->AddProperty(&diff, 1, AI_MATKEY_COLOR_DIFFUSE);
     mtl->AddProperty(&ambi, 1, AI_MATKEY_COLOR_AMBIENT);
     mtl->AddProperty(&spec, 1, AI_MATKEY_COLOR_SPECULAR);
@@ -697,8 +654,7 @@ static void ReadMaterial(SIB* sib, StreamReaderLE* stream)
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadLightInfo(aiLight* light, StreamReaderLE* stream)
-{
+static void ReadLightInfo(aiLight *light, StreamReaderLE *stream) {
     uint32_t type = stream->GetU4();
     switch (type) {
     case 0: light->mType = aiLightSource_POINT; break;
@@ -728,7 +684,7 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream)
     // 99% and 1% percentiles.
     //    OpenGL: I = cos(angle)^E
     //   Solving: angle = acos(I^(1/E))
-    ai_real E = ai_real( 1.0 ) / std::max(spotExponent, (ai_real)0.00001);
+    ai_real E = ai_real(1.0) / std::max(spotExponent, (ai_real)0.00001);
     ai_real inner = std::acos(std::pow((ai_real)0.99, E));
     ai_real outer = std::acos(std::pow((ai_real)0.01, E));
 
@@ -739,20 +695,17 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream)
     light->mAngleOuterCone = outer;
 }
 
-static void ReadLight(SIB* sib, StreamReaderLE* stream)
-{
-    aiLight* light = new aiLight();
+static void ReadLight(SIB *sib, StreamReaderLE *stream) {
+    aiLight *light = new aiLight();
 
-    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk))
-    {
+    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) {
         SIBChunk chunk = ReadChunk(stream);
         unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size);
 
-        switch (chunk.Tag)
-        {
-        case TAG('L','N','F','O'): ReadLightInfo(light, stream); break;
-        case TAG('S','N','A','M'): light->mName = ReadString(stream, chunk.Size/2); break;
-        default:                   UnknownChunk(stream, chunk); break;
+        switch (chunk.Tag) {
+        case TAG('L', 'N', 'F', 'O'): ReadLightInfo(light, stream); break;
+        case TAG('S', 'N', 'A', 'M'): light->mName = ReadString(stream, chunk.Size / 2); break;
+        default: UnknownChunk(stream, chunk); break;
         }
 
         stream->SetCurrentPos(stream->GetReadLimit());
@@ -763,8 +716,7 @@ static void ReadLight(SIB* sib, StreamReaderLE* stream)
 }
 
 // ------------------------------------------------------------------------------------------------
-static void ReadScale(aiMatrix4x4& axis, StreamReaderLE* stream)
-{
+static void ReadScale(aiMatrix4x4 &axis, StreamReaderLE *stream) {
     aiMatrix4x4 scale;
     scale.a1 = stream->GetF4();
     scale.b1 = stream->GetF4();
@@ -786,68 +738,61 @@ static void ReadScale(aiMatrix4x4& axis, StreamReaderLE* stream)
     axis = axis * scale;
 }
 
-static void ReadInstance(SIB* sib, StreamReaderLE* stream)
-{
+static void ReadInstance(SIB *sib, StreamReaderLE *stream) {
     SIBObject inst;
     uint32_t shapeIndex = 0;
 
-    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk))
-    {
+    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) {
         SIBChunk chunk = ReadChunk(stream);
         unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size);
 
-        switch (chunk.Tag)
-        {
-        case TAG('D','I','N','F'): break; // display info, not needed
-        case TAG('P','I','N','F'): break; // ?
-        case TAG('A','X','I','S'): ReadAxis(inst.axis, stream); break;
-        case TAG('I','N','S','I'): shapeIndex = stream->GetU4(); break;
-        case TAG('S','M','T','X'): ReadScale(inst.axis, stream); break;
-        case TAG('S','N','A','M'): inst.name = ReadString(stream, chunk.Size/2); break;
-        default:                   UnknownChunk(stream, chunk); break;
+        switch (chunk.Tag) {
+        case TAG('D', 'I', 'N', 'F'): break; // display info, not needed
+        case TAG('P', 'I', 'N', 'F'): break; // ?
+        case TAG('A', 'X', 'I', 'S'): ReadAxis(inst.axis, stream); break;
+        case TAG('I', 'N', 'S', 'I'): shapeIndex = stream->GetU4(); break;
+        case TAG('S', 'M', 'T', 'X'): ReadScale(inst.axis, stream); break;
+        case TAG('S', 'N', 'A', 'M'): inst.name = ReadString(stream, chunk.Size / 2); break;
+        default: UnknownChunk(stream, chunk); break;
         }
 
         stream->SetCurrentPos(stream->GetReadLimit());
         stream->SetReadLimit(oldLimit);
     }
 
-    if ( shapeIndex >= sib->objs.size() ) {
-        throw DeadlyImportError( "SIB: Invalid shape index." );
+    if (shapeIndex >= sib->objs.size()) {
+        throw DeadlyImportError("SIB: Invalid shape index.");
     }
 
-    const SIBObject& src = sib->objs[shapeIndex];
+    const SIBObject &src = sib->objs[shapeIndex];
     inst.meshIdx = src.meshIdx;
     inst.meshCount = src.meshCount;
     sib->insts.push_back(inst);
 }
 
 // ------------------------------------------------------------------------------------------------
-static void CheckVersion(StreamReaderLE* stream)
-{
+static void CheckVersion(StreamReaderLE *stream) {
     uint32_t version = stream->GetU4();
-    if ( version < 1 || version > 2 ) {
-        throw DeadlyImportError( "SIB: Unsupported file version." );
+    if (version < 1 || version > 2) {
+        throw DeadlyImportError("SIB: Unsupported file version.");
     }
 }
 
-static void ReadScene(SIB* sib, StreamReaderLE* stream)
-{
+static void ReadScene(SIB *sib, StreamReaderLE *stream) {
     // Parse each chunk in turn.
-    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk))
-    {
+    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk)) {
         SIBChunk chunk = ReadChunk(stream);
         unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size);
 
-        switch (chunk.Tag)
-        {
-        case TAG('H','E','A','D'): CheckVersion(stream); break;
-        case TAG('S','H','A','P'): ReadShape(sib, stream); break;
-        case TAG('G','R','P','S'): break; // group assignment, we don't import this
-        case TAG('T','E','X','P'): break; // ?
-        case TAG('I','N','S','T'): ReadInstance(sib, stream); break;
-        case TAG('M','A','T','R'): ReadMaterial(sib, stream); break;
-        case TAG('L','G','H','T'): ReadLight(sib, stream); break;
-        default:                   UnknownChunk(stream, chunk); break;
+        switch (chunk.Tag) {
+        case TAG('H', 'E', 'A', 'D'): CheckVersion(stream); break;
+        case TAG('S', 'H', 'A', 'P'): ReadShape(sib, stream); break;
+        case TAG('G', 'R', 'P', 'S'): break; // group assignment, we don't import this
+        case TAG('T', 'E', 'X', 'P'): break; // ?
+        case TAG('I', 'N', 'S', 'T'): ReadInstance(sib, stream); break;
+        case TAG('M', 'A', 'T', 'R'): ReadMaterial(sib, stream); break;
+        case TAG('L', 'G', 'H', 'T'): ReadLight(sib, stream); break;
+        default: UnknownChunk(stream, chunk); break;
         }
 
         stream->SetCurrentPos(stream->GetReadLimit());
@@ -857,9 +802,8 @@ static void ReadScene(SIB* sib, StreamReaderLE* stream)
 
 // ------------------------------------------------------------------------------------------------
 // Imports the given file into the given scene structure.
-void SIBImporter::InternReadFile(const std::string& pFile,
-    aiScene* pScene, IOSystem* pIOHandler)
-{
+void SIBImporter::InternReadFile(const std::string &pFile,
+        aiScene *pScene, IOSystem *pIOHandler) {
     StreamReaderLE stream(pIOHandler->Open(pFile, "rb"));
 
     // We should have at least one chunk
@@ -869,7 +813,7 @@ void SIBImporter::InternReadFile(const std::string& pFile,
     SIB sib;
 
     // Default material.
-    aiMaterial* defmtl = new aiMaterial;
+    aiMaterial *defmtl = new aiMaterial;
     aiString defname = aiString(AI_DEFAULT_MATERIAL_NAME);
     defmtl->AddProperty(&defname, AI_MATKEY_NAME);
     sib.mtls.push_back(defmtl);
@@ -886,57 +830,54 @@ void SIBImporter::InternReadFile(const std::string& pFile,
     pScene->mNumMaterials = static_cast<unsigned int>(sib.mtls.size());
     pScene->mNumMeshes = static_cast<unsigned int>(sib.meshes.size());
     pScene->mNumLights = static_cast<unsigned int>(sib.lights.size());
-    pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial*[pScene->mNumMaterials] : NULL;
-    pScene->mMeshes = pScene->mNumMeshes ? new aiMesh*[pScene->mNumMeshes] : NULL;
-    pScene->mLights = pScene->mNumLights ? new aiLight*[pScene->mNumLights] : NULL;
+    pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial *[pScene->mNumMaterials] : nullptr;
+    pScene->mMeshes = pScene->mNumMeshes ? new aiMesh *[pScene->mNumMeshes] : nullptr;
+    pScene->mLights = pScene->mNumLights ? new aiLight *[pScene->mNumLights] : nullptr;
     if (pScene->mNumMaterials)
-        memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial*) * pScene->mNumMaterials);
+        memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial *) * pScene->mNumMaterials);
     if (pScene->mNumMeshes)
-        memcpy(pScene->mMeshes, &sib.meshes[0], sizeof(aiMesh*) * pScene->mNumMeshes);
+        memcpy(pScene->mMeshes, &sib.meshes[0], sizeof(aiMesh *) * pScene->mNumMeshes);
     if (pScene->mNumLights)
-        memcpy(pScene->mLights, &sib.lights[0], sizeof(aiLight*) * pScene->mNumLights);
+        memcpy(pScene->mLights, &sib.lights[0], sizeof(aiLight *) * pScene->mNumLights);
 
     // Construct the root node.
     size_t childIdx = 0;
     aiNode *root = new aiNode();
     root->mName.Set("<SIBRoot>");
     root->mNumChildren = static_cast<unsigned int>(sib.objs.size() + sib.lights.size());
-    root->mChildren = root->mNumChildren ? new aiNode*[root->mNumChildren] : NULL;
+    root->mChildren = root->mNumChildren ? new aiNode *[root->mNumChildren] : nullptr;
     pScene->mRootNode = root;
 
     // Add nodes for each object.
-    for (size_t n=0;n<sib.objs.size();n++)
-    {
+    for (size_t n = 0; n < sib.objs.size(); n++) {
         ai_assert(root->mChildren);
-        SIBObject& obj = sib.objs[n];
-        aiNode* node = new aiNode;
+        SIBObject &obj = sib.objs[n];
+        aiNode *node = new aiNode;
         root->mChildren[childIdx++] = node;
         node->mName = obj.name;
         node->mParent = root;
         node->mTransformation = obj.axis;
 
         node->mNumMeshes = static_cast<unsigned int>(obj.meshCount);
-        node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : NULL;
-        for (unsigned i=0;i<node->mNumMeshes;i++)
+        node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : nullptr;
+        for (unsigned i = 0; i < node->mNumMeshes; i++)
             node->mMeshes[i] = static_cast<unsigned int>(obj.meshIdx + i);
 
         // Mark instanced objects as being so.
-        if (n >= firstInst)
-        {
-            node->mMetaData = aiMetadata::Alloc( 1 );
-            node->mMetaData->Set( 0, "IsInstance", true );
+        if (n >= firstInst) {
+            node->mMetaData = aiMetadata::Alloc(1);
+            node->mMetaData->Set(0, "IsInstance", true);
         }
     }
 
     // Add nodes for each light.
     // (no transformation as the light is already in world space)
-    for (size_t n=0;n<sib.lights.size();n++)
-    {
+    for (size_t n = 0; n < sib.lights.size(); n++) {
         ai_assert(root->mChildren);
-        aiLight* light = sib.lights[n];
-        if ( nullptr != light ) {
-            aiNode* node = new aiNode;
-            root->mChildren[ childIdx++ ] = node;
+        aiLight *light = sib.lights[n];
+        if (nullptr != light) {
+            aiNode *node = new aiNode;
+            root->mChildren[childIdx++] = node;
             node->mName = light->mName;
             node->mParent = root;
         }

+ 1 - 1
code/AssetLib/SMD/SMDLoader.cpp

@@ -577,7 +577,7 @@ void SMDImporter::GetAnimationFileList(const std::string &pFile, IOSystem* pIOHa
     char *context1, *context2;
 
     tok1 = strtok_s(&buf[0], "\r\n", &context1);
-    while (tok1 != NULL) {
+    while (tok1 != nullptr) {
         tok2 = strtok_s(tok1, " \t", &context2);
         if (tok2) {
             char *p = tok2;

+ 4 - 4
code/AssetLib/STEPParser/STEPFileReader.cpp

@@ -299,7 +299,7 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
 }
 
 // ------------------------------------------------------------------------------------------------
-std::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= NULL*/)
+std::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= nullptr*/)
 {
     const char* cur = inout;
     SkipSpaces(&cur);
@@ -422,7 +422,7 @@ std::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*& i
 }
 
 // ------------------------------------------------------------------------------------------------
-std::shared_ptr<const EXPRESS::LIST> EXPRESS::LIST::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= NULL*/) {
+std::shared_ptr<const EXPRESS::LIST> EXPRESS::LIST::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= nullptr*/) {
     const std::shared_ptr<EXPRESS::LIST> list = std::make_shared<EXPRESS::LIST>();
     EXPRESS::LIST::MemberList& members = list->members;
 
@@ -540,9 +540,9 @@ void STEP::LazyObject::LazyInit() const {
     const char* acopy = args;
     std::shared_ptr<const EXPRESS::LIST> conv_args = EXPRESS::LIST::Parse(acopy,(uint64_t)STEP::SyntaxError::LINE_NOT_SPECIFIED,&db.GetSchema());
     delete[] args;
-    args = NULL;
+    args = nullptr;
 
-    // if the converter fails, it should throw an exception, but it should never return NULL
+    // if the converter fails, it should throw an exception, but it should never return nullptr
     try {
         obj = proc(db,*conv_args);
     }

+ 2 - 2
code/AssetLib/STL/STLExporter.cpp

@@ -72,7 +72,7 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
     
     // we're still here - export successfully completed. Write the file.
     std::unique_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
-    if(outfile == NULL) {
+    if (outfile == nullptr) {
         throw DeadlyExportError("could not open output .stl file: " + std::string(pFile));
     }
 
@@ -91,7 +91,7 @@ void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene*
     
     // we're still here - export successfully completed. Write the file.
     std::unique_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wb"));
-    if(outfile == NULL) {
+    if (outfile == nullptr) {
         throw DeadlyExportError("could not open output .stl file: " + std::string(pFile));
     }
 

+ 2 - 2
code/AssetLib/Step/StepExporter.cpp

@@ -108,7 +108,7 @@ void ExportSceneStep(const char* pFile,IOSystem* pIOSystem, const aiScene* pScen
 
     // we're still here - export successfully completed. Write result to the given IOSYstem
     std::unique_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
-    if(outfile == NULL) {
+    if (outfile == nullptr) {
         throw DeadlyExportError("could not open output .stp file: " + std::string(pFile));
     }
 
@@ -204,7 +204,7 @@ void StepExporter::WriteFile()
 
     static const unsigned int date_nb_chars = 20;
     char date_str[date_nb_chars];
-    std::time_t date = std::time(NULL);
+    std::time_t date = std::time(nullptr);
     std::strftime(date_str, date_nb_chars, "%Y-%m-%dT%H:%M:%S", std::localtime(&date));
 
     // write the header

+ 8 - 4
code/AssetLib/Terragen/TerragenLoader.cpp

@@ -87,12 +87,16 @@ bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, b
     if (!extension.length() || checkSig) {
         /*  If CanRead() is called in order to check whether we
          *  support a specific file extension in general pIOHandler
-         *  might be NULL and it's our duty to return true here.
+         *  might be nullptr and it's our duty to return true here.
          */
-        if (!pIOHandler) return true;
+        if (!pIOHandler) {
+            return true;
+        }
+
         const char *tokens[] = { "terragen" };
         return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
     }
+
     return false;
 }
 
@@ -116,7 +120,7 @@ void TerragenImporter::InternReadFile(const std::string &pFile,
     IOStream *file = pIOHandler->Open(pFile, "rb");
 
     // Check whether we can read from the file
-    if (file == NULL)
+    if (file == nullptr)
         throw DeadlyImportError("Failed to open TERRAGEN TERRAIN file " + pFile + ".");
 
     // Construct a stream reader to read all data in the correct endianness
@@ -199,7 +203,7 @@ void TerragenImporter::InternReadFile(const std::string &pFile,
             aiFace *f = m->mFaces = new aiFace[m->mNumFaces = (x - 1) * (y - 1)];
             aiVector3D *pv = m->mVertices = new aiVector3D[m->mNumVertices = m->mNumFaces * 4];
 
-            aiVector3D *uv(NULL);
+            aiVector3D *uv(nullptr);
             float step_y(0.0f), step_x(0.0f);
             if (configComputeUVs) {
                 uv = m->mTextureCoords[0] = new aiVector3D[m->mNumVertices];

+ 1 - 1
code/AssetLib/X/XFileExporter.cpp

@@ -89,7 +89,7 @@ void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pSce
     
     // we're still here - export successfully completed. Write result to the given IOSYstem
     std::unique_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
-    if(outfile == NULL) {
+    if (outfile == nullptr) {
         throw DeadlyExportError("could not open output .x file: " + std::string(pFile));
     }
 

+ 1 - 1
code/AssetLib/X/XFileImporter.cpp

@@ -113,7 +113,7 @@ const aiImporterDesc* XFileImporter::GetInfo () const {
 void XFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
     // read file into memory
     std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
-    if ( file.get() == NULL ) {
+    if ( file.get() == nullptr ) {
         throw DeadlyImportError( "Failed to open file " + pFile + "." );
     }
 

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 260 - 339
code/AssetLib/X/XFileParser.cpp


+ 1 - 1
code/AssetLib/X/XFileParser.h

@@ -104,7 +104,7 @@ protected:
     //! reads header of data object including the opening brace.
     //! returns false if error happened, and writes name of object
     //! if there is one
-    void readHeadOfDataObject( std::string* poName = NULL);
+    void readHeadOfDataObject(std::string *poName = nullptr);
 
     //! checks for closing curly brace, throws exception if not there
     void CheckForClosingBrace();

+ 2 - 2
code/AssetLib/X3D/X3DImporter_Shape.cpp

@@ -64,8 +64,8 @@ namespace Assimp
 // A ProtoInstance node (with the proper node type) can be substituted for any node in this content model."
 // </Shape>
 // A Shape node is unlit if either of the following is true:
-//     The shape's appearance field is NULL (default).
-//     The material field in the Appearance node is NULL (default).
+//     The shape's appearance field is nullptr (default).
+//     The material field in the Appearance node is nullptr (default).
 // NOTE Geometry nodes that represent lines or points do not support lighting.
 void X3DImporter::ParseNode_Shape_Shape()
 {

+ 193 - 254
code/AssetLib/XGL/XGLLoader.cpp

@@ -43,18 +43,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 /** @file Implementation of the XGL/ZGL importer class */
 
-
 #ifndef ASSIMP_BUILD_NO_XGL_IMPORTER
 
 #include "XGLLoader.h"
 #include <assimp/ParsingUtils.h>
 #include <assimp/fast_atof.h>
 
-#include <assimp/StreamReader.h>
 #include <assimp/MemoryIOWrapper.h>
+#include <assimp/StreamReader.h>
+#include <assimp/importerdesc.h>
 #include <assimp/mesh.h>
 #include <assimp/scene.h>
-#include <assimp/importerdesc.h>
 #include <cctype>
 #include <memory>
 
@@ -64,21 +63,20 @@ using namespace irr::io;
 
 // zlib is needed for compressed XGL files
 #ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL
-#   ifdef ASSIMP_BUILD_NO_OWN_ZLIB
-#       include <zlib.h>
-#   else
-#       include <contrib/zlib/zlib.h>
-#   endif
+#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
+#include <zlib.h>
+#else
+#include <contrib/zlib/zlib.h>
+#endif
 #endif
-
 
 namespace Assimp { // this has to be in here because LogFunctions is in ::Assimp
-    template<> const char* LogFunctions<XGLImporter>::Prefix()
-    {
-        static auto prefix = "XGL: ";
-        return prefix;
-    }
+template <>
+const char *LogFunctions<XGLImporter>::Prefix() {
+    static auto prefix = "XGL: ";
+    return prefix;
 }
+} // namespace Assimp
 
 static const aiImporterDesc desc = {
     "XGL Importer",
@@ -93,12 +91,10 @@ static const aiImporterDesc desc = {
     "xgl zgl"
 };
 
-
 // ------------------------------------------------------------------------------------------------
 // Constructor to be privately used by Importer
-XGLImporter::XGLImporter()
-: m_reader( nullptr )
-, m_scene( nullptr ) {
+XGLImporter::XGLImporter() :
+        m_reader(nullptr), m_scene(nullptr) {
     // empty
 }
 
@@ -110,8 +106,7 @@ XGLImporter::~XGLImporter() {
 
 // ------------------------------------------------------------------------------------------------
 // Returns whether the class can handle the format of the given file.
-bool XGLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
-{
+bool XGLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
     /* NOTE: A simple check for the file extension is not enough
      * here. XGL and ZGL are ok, but xml is too generic
      * and might be collada as well. So open the file and
@@ -121,38 +116,35 @@ bool XGLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
 
     if (extension == "xgl" || extension == "zgl") {
         return true;
-    }
-    else if (extension == "xml" || checkSig) {
-        ai_assert(pIOHandler != NULL);
+    } else if (extension == "xml" || checkSig) {
+        ai_assert(pIOHandler != nullptr);
 
-        const char* tokens[] = {"<world>","<World>","<WORLD>"};
-        return SearchFileHeaderForToken(pIOHandler,pFile,tokens,3);
+        const char *tokens[] = { "<world>", "<World>", "<WORLD>" };
+        return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 3);
     }
     return false;
 }
 
 // ------------------------------------------------------------------------------------------------
 // Get a list of all file extensions which are handled by this class
-const aiImporterDesc* XGLImporter::GetInfo () const
-{
+const aiImporterDesc *XGLImporter::GetInfo() const {
     return &desc;
 }
 
 // ------------------------------------------------------------------------------------------------
 // Imports the given file into the given scene structure.
-void XGLImporter::InternReadFile( const std::string& pFile,
-    aiScene* pScene, IOSystem* pIOHandler)
-{
+void XGLImporter::InternReadFile(const std::string &pFile,
+        aiScene *pScene, IOSystem *pIOHandler) {
 #ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL
     std::vector<Bytef> uncompressed;
 #endif
 
     m_scene = pScene;
-    std::shared_ptr<IOStream> stream( pIOHandler->Open( pFile, "rb"));
+    std::shared_ptr<IOStream> stream(pIOHandler->Open(pFile, "rb"));
 
     // check whether we can read from the file
-    if( stream.get() == NULL) {
-        throw DeadlyImportError( "Failed to open XGL/ZGL file " + pFile + "");
+    if (stream.get() == nullptr) {
+        throw DeadlyImportError("Failed to open XGL/ZGL file " + pFile + "");
     }
 
     // see if its compressed, if so uncompress it
@@ -166,7 +158,7 @@ void XGLImporter::InternReadFile( const std::string& pFile,
         z_stream zstream;
         zstream.opaque = Z_NULL;
         zstream.zalloc = Z_NULL;
-        zstream.zfree  = Z_NULL;
+        zstream.zfree = Z_NULL;
         zstream.data_type = Z_BINARY;
 
         // raw decompression without a zlib or gzip header
@@ -175,14 +167,14 @@ void XGLImporter::InternReadFile( const std::string& pFile,
         // skip two extra bytes, zgl files do carry a crc16 upfront (I think)
         raw_reader->IncPtr(2);
 
-        zstream.next_in   = reinterpret_cast<Bytef*>( raw_reader->GetPtr() );
-        zstream.avail_in  = (uInt) raw_reader->GetRemainingSize();
+        zstream.next_in = reinterpret_cast<Bytef *>(raw_reader->GetPtr());
+        zstream.avail_in = (uInt)raw_reader->GetRemainingSize();
 
         size_t total = 0l;
 
         // TODO: be smarter about this, decompress directly into heap buffer
         // and decompress the data .... do 1k chunks in the hope that we won't kill the stack
-    #define MYBLOCK 1024
+#define MYBLOCK 1024
         Bytef block[MYBLOCK];
         int ret;
         do {
@@ -196,51 +188,49 @@ void XGLImporter::InternReadFile( const std::string& pFile,
             const size_t have = MYBLOCK - zstream.avail_out;
             total += have;
             uncompressed.resize(total);
-            memcpy(uncompressed.data() + total - have,block,have);
-        }
-        while (ret != Z_STREAM_END);
+            memcpy(uncompressed.data() + total - have, block, have);
+        } while (ret != Z_STREAM_END);
 
         // terminate zlib
         inflateEnd(&zstream);
 
         // replace the input stream with a memory stream
-        stream.reset(new MemoryIOStream(reinterpret_cast<uint8_t*>(uncompressed.data()),total));
+        stream.reset(new MemoryIOStream(reinterpret_cast<uint8_t *>(uncompressed.data()), total));
 #endif
     }
 
     // construct the irrXML parser
     CIrrXML_IOStreamReader st(stream.get());
-    m_reader.reset( createIrrXMLReader( ( IFileReadCallBack* ) &st ) );
+    m_reader.reset(createIrrXMLReader((IFileReadCallBack *)&st));
 
     // parse the XML file
     TempScope scope;
 
-    while (ReadElement())   {
-        if (!ASSIMP_stricmp(m_reader->getNodeName(),"world")) {
+    while (ReadElement()) {
+        if (!ASSIMP_stricmp(m_reader->getNodeName(), "world")) {
             ReadWorld(scope);
         }
     }
 
-
-    std::vector<aiMesh*>& meshes = scope.meshes_linear;
-    std::vector<aiMaterial*>& materials = scope.materials_linear;
-    if(!meshes.size() || !materials.size()) {
+    std::vector<aiMesh *> &meshes = scope.meshes_linear;
+    std::vector<aiMaterial *> &materials = scope.materials_linear;
+    if (!meshes.size() || !materials.size()) {
         ThrowException("failed to extract data from XGL file, no meshes loaded");
     }
 
     // copy meshes
     m_scene->mNumMeshes = static_cast<unsigned int>(meshes.size());
-    m_scene->mMeshes = new aiMesh*[m_scene->mNumMeshes]();
-    std::copy(meshes.begin(),meshes.end(),m_scene->mMeshes);
+    m_scene->mMeshes = new aiMesh *[m_scene->mNumMeshes]();
+    std::copy(meshes.begin(), meshes.end(), m_scene->mMeshes);
 
     // copy materials
     m_scene->mNumMaterials = static_cast<unsigned int>(materials.size());
-    m_scene->mMaterials = new aiMaterial*[m_scene->mNumMaterials]();
-    std::copy(materials.begin(),materials.end(),m_scene->mMaterials);
+    m_scene->mMaterials = new aiMaterial *[m_scene->mNumMaterials]();
+    std::copy(materials.begin(), materials.end(), m_scene->mMaterials);
 
     if (scope.light) {
         m_scene->mNumLights = 1;
-        m_scene->mLights = new aiLight*[1];
+        m_scene->mLights = new aiLight *[1];
         m_scene->mLights[0] = scope.light;
 
         scope.light->mName = m_scene->mRootNode->mName;
@@ -250,9 +240,8 @@ void XGLImporter::InternReadFile( const std::string& pFile,
 }
 
 // ------------------------------------------------------------------------------------------------
-bool XGLImporter::ReadElement()
-{
-    while(m_reader->read()) {
+bool XGLImporter::ReadElement() {
+    while (m_reader->read()) {
         if (m_reader->getNodeType() == EXN_ELEMENT) {
             return true;
         }
@@ -261,13 +250,11 @@ bool XGLImporter::ReadElement()
 }
 
 // ------------------------------------------------------------------------------------------------
-bool XGLImporter::ReadElementUpToClosing(const char* closetag)
-{
-    while(m_reader->read()) {
+bool XGLImporter::ReadElementUpToClosing(const char *closetag) {
+    while (m_reader->read()) {
         if (m_reader->getNodeType() == EXN_ELEMENT) {
             return true;
-        }
-        else if (m_reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(m_reader->getNodeName(),closetag)) {
+        } else if (m_reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(m_reader->getNodeName(), closetag)) {
             return false;
         }
     }
@@ -276,13 +263,11 @@ bool XGLImporter::ReadElementUpToClosing(const char* closetag)
 }
 
 // ------------------------------------------------------------------------------------------------
-bool XGLImporter::SkipToText()
-{
-    while(m_reader->read()) {
+bool XGLImporter::SkipToText() {
+    while (m_reader->read()) {
         if (m_reader->getNodeType() == EXN_TEXT) {
             return true;
-        }
-        else if (m_reader->getNodeType() == EXN_ELEMENT || m_reader->getNodeType() == EXN_ELEMENT_END) {
+        } else if (m_reader->getNodeType() == EXN_ELEMENT || m_reader->getNodeType() == EXN_ELEMENT_END) {
             ThrowException("expected text contents but found another element (or element end)");
         }
     }
@@ -290,9 +275,8 @@ bool XGLImporter::SkipToText()
 }
 
 // ------------------------------------------------------------------------------------------------
-std::string XGLImporter::GetElementName()
-{
-    const char* s  = m_reader->getNodeName();
+std::string XGLImporter::GetElementName() {
+    const char *s = m_reader->getNodeName();
     size_t len = strlen(s);
 
     std::string ret;
@@ -302,26 +286,23 @@ std::string XGLImporter::GetElementName()
 }
 
 // ------------------------------------------------------------------------------------------------
-void XGLImporter::ReadWorld(TempScope& scope)
-{
+void XGLImporter::ReadWorld(TempScope &scope) {
     while (ReadElementUpToClosing("world")) {
-        const std::string& s = GetElementName();
+        const std::string &s = GetElementName();
         // XXX right now we'd skip <lighting> if it comes after
         // <object> or <mesh>
         if (s == "lighting") {
             ReadLighting(scope);
-        }
-        else if (s == "object" || s == "mesh" || s == "mat") {
+        } else if (s == "object" || s == "mesh" || s == "mat") {
             break;
         }
     }
 
-
-    aiNode* const nd = ReadObject(scope,true,"world");
-    if(!nd) {
+    aiNode *const nd = ReadObject(scope, true, "world");
+    if (!nd) {
         ThrowException("failure reading <world>");
     }
-    if(!nd->mName.length) {
+    if (!nd->mName.length) {
         nd->mName.Set("WORLD");
     }
 
@@ -329,37 +310,31 @@ void XGLImporter::ReadWorld(TempScope& scope)
 }
 
 // ------------------------------------------------------------------------------------------------
-void XGLImporter::ReadLighting(TempScope& scope)
-{
-    while (ReadElementUpToClosing("lighting"))  {
-        const std::string& s = GetElementName();
+void XGLImporter::ReadLighting(TempScope &scope) {
+    while (ReadElementUpToClosing("lighting")) {
+        const std::string &s = GetElementName();
         if (s == "directionallight") {
             scope.light = ReadDirectionalLight();
-        }
-        else if (s == "ambient") {
+        } else if (s == "ambient") {
             LogWarn("ignoring <ambient> tag");
-        }
-        else if (s == "spheremap") {
+        } else if (s == "spheremap") {
             LogWarn("ignoring <spheremap> tag");
         }
     }
 }
 
 // ------------------------------------------------------------------------------------------------
-aiLight* XGLImporter::ReadDirectionalLight()
-{
+aiLight *XGLImporter::ReadDirectionalLight() {
     std::unique_ptr<aiLight> l(new aiLight());
     l->mType = aiLightSource_DIRECTIONAL;
 
-    while (ReadElementUpToClosing("directionallight"))  {
-        const std::string& s = GetElementName();
+    while (ReadElementUpToClosing("directionallight")) {
+        const std::string &s = GetElementName();
         if (s == "direction") {
             l->mDirection = ReadVec3();
-        }
-        else if (s == "diffuse") {
+        } else if (s == "diffuse") {
             l->mColorDiffuse = ReadCol3();
-        }
-        else if (s == "specular") {
+        } else if (s == "specular") {
             l->mColorSpecular = ReadCol3();
         }
     }
@@ -367,49 +342,44 @@ aiLight* XGLImporter::ReadDirectionalLight()
 }
 
 // ------------------------------------------------------------------------------------------------
-aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* closetag)
-{
+aiNode *XGLImporter::ReadObject(TempScope &scope, bool skipFirst, const char *closetag) {
     aiNode *nd = new aiNode;
-    std::vector<aiNode*> children;
+    std::vector<aiNode *> children;
     std::vector<unsigned int> meshes;
 
     try {
-        while (skipFirst || ReadElementUpToClosing(closetag))   {
+        while (skipFirst || ReadElementUpToClosing(closetag)) {
             skipFirst = false;
 
-            const std::string& s = GetElementName();
+            const std::string &s = GetElementName();
             if (s == "mesh") {
                 const size_t prev = scope.meshes_linear.size();
-                if(ReadMesh(scope)) {
+                if (ReadMesh(scope)) {
                     const size_t newc = scope.meshes_linear.size();
-                    for(size_t i = 0; i < newc-prev; ++i) {
-                        meshes.push_back(static_cast<unsigned int>(i+prev));
+                    for (size_t i = 0; i < newc - prev; ++i) {
+                        meshes.push_back(static_cast<unsigned int>(i + prev));
                     }
                 }
-            }
-            else if (s == "mat") {
+            } else if (s == "mat") {
                 ReadMaterial(scope);
-            }
-            else if (s == "object") {
+            } else if (s == "object") {
                 children.push_back(ReadObject(scope));
-            }
-            else if (s == "objectref") {
+            } else if (s == "objectref") {
                 // XXX
-            }
-            else if (s == "meshref") {
-                const unsigned int id = static_cast<unsigned int>( ReadIndexFromText() );
+            } else if (s == "meshref") {
+                const unsigned int id = static_cast<unsigned int>(ReadIndexFromText());
 
-                std::multimap<unsigned int, aiMesh*>::iterator it = scope.meshes.find(id), end = scope.meshes.end();
+                std::multimap<unsigned int, aiMesh *>::iterator it = scope.meshes.find(id), end = scope.meshes.end();
                 if (it == end) {
                     ThrowException("<meshref> index out of range");
                 }
 
-                for(; it != end && (*it).first == id; ++it) {
+                for (; it != end && (*it).first == id; ++it) {
                     // ok, this is n^2 and should get optimized one day
-                    aiMesh* const m = (*it).second;
+                    aiMesh *const m = (*it).second;
 
                     unsigned int i = 0, mcount = static_cast<unsigned int>(scope.meshes_linear.size());
-                    for(; i < mcount; ++i) {
+                    for (; i < mcount; ++i) {
                         if (scope.meshes_linear[i] == m) {
                             meshes.push_back(i);
                             break;
@@ -418,14 +388,13 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl
 
                     ai_assert(i < mcount);
                 }
-            }
-            else if (s == "transform") {
+            } else if (s == "transform") {
                 nd->mTransformation = ReadTrafo();
             }
         }
 
-    } catch(...) {
-        for(aiNode* ch : children) {
+    } catch (...) {
+        for (aiNode *ch : children) {
             delete ch;
         }
         throw;
@@ -441,7 +410,7 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl
     nd->mNumMeshes = static_cast<unsigned int>(meshes.size());
     if (nd->mNumMeshes) {
         nd->mMeshes = new unsigned int[nd->mNumMeshes]();
-        for(unsigned int i = 0; i < nd->mNumMeshes; ++i) {
+        for (unsigned int i = 0; i < nd->mNumMeshes; ++i) {
             nd->mMeshes[i] = meshes[i];
         }
     }
@@ -449,8 +418,8 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl
     // link children to parent
     nd->mNumChildren = static_cast<unsigned int>(children.size());
     if (nd->mNumChildren) {
-        nd->mChildren = new aiNode*[nd->mNumChildren]();
-        for(unsigned int i = 0; i < nd->mNumChildren; ++i) {
+        nd->mChildren = new aiNode *[nd->mNumChildren]();
+        for (unsigned int i = 0; i < nd->mNumChildren; ++i) {
             nd->mChildren[i] = children[i];
             children[i]->mParent = nd;
         }
@@ -460,25 +429,22 @@ aiNode* XGLImporter::ReadObject(TempScope& scope, bool skipFirst, const char* cl
 }
 
 // ------------------------------------------------------------------------------------------------
-aiMatrix4x4 XGLImporter::ReadTrafo()
-{
+aiMatrix4x4 XGLImporter::ReadTrafo() {
     aiVector3D forward, up, right, position;
     float scale = 1.0f;
 
     while (ReadElementUpToClosing("transform")) {
-        const std::string& s = GetElementName();
+        const std::string &s = GetElementName();
         if (s == "forward") {
             forward = ReadVec3();
-        }
-        else if (s == "up") {
+        } else if (s == "up") {
             up = ReadVec3();
-        }
-        else if (s == "position") {
+        } else if (s == "position") {
             position = ReadVec3();
         }
         if (s == "scale") {
             scale = ReadFloat();
-            if(scale < 0.f) {
+            if (scale < 0.f) {
                 // this is wrong, but we can leave the value and pass it to the caller
                 LogError("found negative scaling in <transform>, ignoring");
             }
@@ -486,7 +452,7 @@ aiMatrix4x4 XGLImporter::ReadTrafo()
     }
 
     aiMatrix4x4 m;
-    if(forward.SquareLength() < 1e-4 || up.SquareLength() < 1e-4) {
+    if (forward.SquareLength() < 1e-4 || up.SquareLength() < 1e-4) {
         LogError("A direction vector in <transform> is zero, ignoring trafo");
         return m;
     }
@@ -526,37 +492,36 @@ aiMatrix4x4 XGLImporter::ReadTrafo()
 }
 
 // ------------------------------------------------------------------------------------------------
-aiMesh* XGLImporter::ToOutputMesh(const TempMaterialMesh& m)
-{
+aiMesh *XGLImporter::ToOutputMesh(const TempMaterialMesh &m) {
     std::unique_ptr<aiMesh> mesh(new aiMesh());
 
     mesh->mNumVertices = static_cast<unsigned int>(m.positions.size());
     mesh->mVertices = new aiVector3D[mesh->mNumVertices];
-    std::copy(m.positions.begin(),m.positions.end(),mesh->mVertices);
+    std::copy(m.positions.begin(), m.positions.end(), mesh->mVertices);
 
-    if(m.normals.size()) {
+    if (m.normals.size()) {
         mesh->mNormals = new aiVector3D[mesh->mNumVertices];
-        std::copy(m.normals.begin(),m.normals.end(),mesh->mNormals);
+        std::copy(m.normals.begin(), m.normals.end(), mesh->mNormals);
     }
 
-    if(m.uvs.size()) {
+    if (m.uvs.size()) {
         mesh->mNumUVComponents[0] = 2;
         mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
 
-        for(unsigned int i = 0; i < mesh->mNumVertices; ++i) {
-            mesh->mTextureCoords[0][i] = aiVector3D(m.uvs[i].x,m.uvs[i].y,0.f);
+        for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
+            mesh->mTextureCoords[0][i] = aiVector3D(m.uvs[i].x, m.uvs[i].y, 0.f);
         }
     }
 
-    mesh->mNumFaces =  static_cast<unsigned int>(m.vcounts.size());
+    mesh->mNumFaces = static_cast<unsigned int>(m.vcounts.size());
     mesh->mFaces = new aiFace[m.vcounts.size()];
 
     unsigned int idx = 0;
-    for(unsigned int i = 0; i < mesh->mNumFaces; ++i) {
-        aiFace& f = mesh->mFaces[i];
+    for (unsigned int i = 0; i < mesh->mNumFaces; ++i) {
+        aiFace &f = mesh->mFaces[i];
         f.mNumIndices = m.vcounts[i];
         f.mIndices = new unsigned int[f.mNumIndices];
-        for(unsigned int c = 0; c < f.mNumIndices; ++c) {
+        for (unsigned int c = 0; c < f.mNumIndices; ++c) {
             f.mIndices[c] = idx++;
         }
     }
@@ -569,57 +534,49 @@ aiMesh* XGLImporter::ToOutputMesh(const TempMaterialMesh& m)
 }
 
 // ------------------------------------------------------------------------------------------------
-bool XGLImporter::ReadMesh(TempScope& scope)
-{
+bool XGLImporter::ReadMesh(TempScope &scope) {
     TempMesh t;
 
     std::map<unsigned int, TempMaterialMesh> bymat;
     const unsigned int mesh_id = ReadIDAttr();
 
-    while (ReadElementUpToClosing("mesh"))  {
-        const std::string& s = GetElementName();
+    while (ReadElementUpToClosing("mesh")) {
+        const std::string &s = GetElementName();
 
         if (s == "mat") {
             ReadMaterial(scope);
-        }
-        else if (s == "p") {
+        } else if (s == "p") {
             if (!m_reader->getAttributeValue("ID")) {
                 LogWarn("no ID attribute on <p>, ignoring");
-            }
-            else {
+            } else {
                 int id = m_reader->getAttributeValueAsInt("ID");
                 t.points[id] = ReadVec3();
             }
-        }
-        else if (s == "n") {
+        } else if (s == "n") {
             if (!m_reader->getAttributeValue("ID")) {
                 LogWarn("no ID attribute on <n>, ignoring");
-            }
-            else {
+            } else {
                 int id = m_reader->getAttributeValueAsInt("ID");
                 t.normals[id] = ReadVec3();
             }
-        }
-        else if (s == "tc") {
+        } else if (s == "tc") {
             if (!m_reader->getAttributeValue("ID")) {
                 LogWarn("no ID attribute on <tc>, ignoring");
-            }
-            else {
+            } else {
                 int id = m_reader->getAttributeValueAsInt("ID");
                 t.uvs[id] = ReadVec2();
             }
-        }
-        else if (s == "f" || s == "l" || s == "p") {
+        } else if (s == "f" || s == "l" || s == "p") {
             const unsigned int vcount = s == "f" ? 3 : (s == "l" ? 2 : 1);
 
             unsigned int mid = ~0u;
             TempFace tf[3];
-            bool has[3] = {0};
+            bool has[3] = { 0 };
 
-            while (ReadElementUpToClosing(s.c_str()))   {
-                const std::string& elemName = GetElementName();
+            while (ReadElementUpToClosing(s.c_str())) {
+                const std::string &elemName = GetElementName();
                 if (elemName == "fv1" || elemName == "lv1" || elemName == "pv1") {
-                    ReadFaceVertex(t,tf[0]);
+                    ReadFaceVertex(t, tf[0]);
                     has[0] = true;
                 } else if (elemName == "fv2" || elemName == "lv2") {
                     ReadFaceVertex(t, tf[1]);
@@ -646,7 +603,7 @@ bool XGLImporter::ReadMesh(TempScope& scope)
 
             bool nor = false;
             bool uv = false;
-            for(unsigned int i = 0; i < vcount; ++i) {
+            for (unsigned int i = 0; i < vcount; ++i) {
                 if (!has[i]) {
                     ThrowException("missing face vertex data");
                 }
@@ -655,24 +612,24 @@ bool XGLImporter::ReadMesh(TempScope& scope)
                 uv = uv || tf[i].has_uv;
             }
 
-            if (mid >= (1<<30)) {
+            if (mid >= (1 << 30)) {
                 LogWarn("material indices exhausted, this may cause errors in the output");
             }
-            unsigned int meshId = mid | ((nor?1:0)<<31) | ((uv?1:0)<<30);
+            unsigned int meshId = mid | ((nor ? 1 : 0) << 31) | ((uv ? 1 : 0) << 30);
 
-            TempMaterialMesh& mesh = bymat[meshId];
+            TempMaterialMesh &mesh = bymat[meshId];
             mesh.matid = mid;
 
-            for(unsigned int i = 0; i < vcount; ++i) {
+            for (unsigned int i = 0; i < vcount; ++i) {
                 mesh.positions.push_back(tf[i].pos);
-                if(nor) {
+                if (nor) {
                     mesh.normals.push_back(tf[i].normal);
                 }
-                if(uv) {
+                if (uv) {
                     mesh.uvs.push_back(tf[i].uv);
                 }
 
-                mesh.pflags |= 1 << (vcount-1);
+                mesh.pflags |= 1 << (vcount - 1);
             }
 
             mesh.vcounts.push_back(vcount);
@@ -681,13 +638,13 @@ bool XGLImporter::ReadMesh(TempScope& scope)
 
     // finally extract output meshes and add them to the scope
     typedef std::pair<const unsigned int, TempMaterialMesh> pairt;
-    for(const pairt& p : bymat) {
-        aiMesh* const m  = ToOutputMesh(p.second);
+    for (const pairt &p : bymat) {
+        aiMesh *const m = ToOutputMesh(p.second);
         scope.meshes_linear.push_back(m);
 
         // if this is a definition, keep it on the stack
-        if(mesh_id != ~0u) {
-            scope.meshes.insert(std::pair<unsigned int, aiMesh*>(mesh_id,m));
+        if (mesh_id != ~0u) {
+            scope.meshes.insert(std::pair<unsigned int, aiMesh *>(mesh_id, m));
         }
     }
 
@@ -696,26 +653,25 @@ bool XGLImporter::ReadMesh(TempScope& scope)
 }
 
 // ----------------------------------------------------------------------------------------------
-unsigned int XGLImporter::ResolveMaterialRef(TempScope& scope)
-{
-    const std::string& s = GetElementName();
+unsigned int XGLImporter::ResolveMaterialRef(TempScope &scope) {
+    const std::string &s = GetElementName();
     if (s == "mat") {
         ReadMaterial(scope);
-        return static_cast<unsigned int>(scope.materials_linear.size()-1);
+        return static_cast<unsigned int>(scope.materials_linear.size() - 1);
     }
 
     const int id = ReadIndexFromText();
 
-    std::map<unsigned int, aiMaterial*>::iterator it = scope.materials.find(id), end = scope.materials.end();
+    std::map<unsigned int, aiMaterial *>::iterator it = scope.materials.find(id), end = scope.materials.end();
     if (it == end) {
         ThrowException("<matref> index out of range");
     }
 
     // ok, this is n^2 and should get optimized one day
-    aiMaterial* const m = (*it).second;
+    aiMaterial *const m = (*it).second;
 
     unsigned int i = 0, mcount = static_cast<unsigned int>(scope.materials_linear.size());
-    for(; i < mcount; ++i) {
+    for (; i < mcount; ++i) {
         if (scope.materials_linear[i] == m) {
             return i;
         }
@@ -726,35 +682,30 @@ unsigned int XGLImporter::ResolveMaterialRef(TempScope& scope)
 }
 
 // ------------------------------------------------------------------------------------------------
-void XGLImporter::ReadMaterial(TempScope& scope) {
+void XGLImporter::ReadMaterial(TempScope &scope) {
     const unsigned int mat_id = ReadIDAttr();
 
-    aiMaterial *mat(new aiMaterial );
-    while (ReadElementUpToClosing("mat"))  {
-        const std::string& s = GetElementName();
+    aiMaterial *mat(new aiMaterial);
+    while (ReadElementUpToClosing("mat")) {
+        const std::string &s = GetElementName();
         if (s == "amb") {
             const aiColor3D c = ReadCol3();
-            mat->AddProperty(&c,1,AI_MATKEY_COLOR_AMBIENT);
-        }
-        else if (s == "diff") {
+            mat->AddProperty(&c, 1, AI_MATKEY_COLOR_AMBIENT);
+        } else if (s == "diff") {
             const aiColor3D c = ReadCol3();
-            mat->AddProperty(&c,1,AI_MATKEY_COLOR_DIFFUSE);
-        }
-        else if (s == "spec") {
+            mat->AddProperty(&c, 1, AI_MATKEY_COLOR_DIFFUSE);
+        } else if (s == "spec") {
             const aiColor3D c = ReadCol3();
-            mat->AddProperty(&c,1,AI_MATKEY_COLOR_SPECULAR);
-        }
-        else if (s == "emiss") {
+            mat->AddProperty(&c, 1, AI_MATKEY_COLOR_SPECULAR);
+        } else if (s == "emiss") {
             const aiColor3D c = ReadCol3();
-            mat->AddProperty(&c,1,AI_MATKEY_COLOR_EMISSIVE);
-        }
-        else if (s == "alpha") {
+            mat->AddProperty(&c, 1, AI_MATKEY_COLOR_EMISSIVE);
+        } else if (s == "alpha") {
             const float f = ReadFloat();
-            mat->AddProperty(&f,1,AI_MATKEY_OPACITY);
-        }
-        else if (s == "shine") {
+            mat->AddProperty(&f, 1, AI_MATKEY_OPACITY);
+        } else if (s == "shine") {
             const float f = ReadFloat();
-            mat->AddProperty(&f,1,AI_MATKEY_SHININESS);
+            mat->AddProperty(&f, 1, AI_MATKEY_SHININESS);
         }
     }
 
@@ -763,13 +714,12 @@ void XGLImporter::ReadMaterial(TempScope& scope) {
 }
 
 // ----------------------------------------------------------------------------------------------
-void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out)
-{
-    const std::string& end = GetElementName();
+void XGLImporter::ReadFaceVertex(const TempMesh &t, TempFace &out) {
+    const std::string &end = GetElementName();
 
     bool havep = false;
-    while (ReadElementUpToClosing(end.c_str()))  {
-        const std::string& s = GetElementName();
+    while (ReadElementUpToClosing(end.c_str())) {
+        const std::string &s = GetElementName();
         if (s == "pref") {
             const unsigned int id = ReadIndexFromText();
             std::map<unsigned int, aiVector3D>::const_iterator it = t.points.find(id);
@@ -779,8 +729,7 @@ void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out)
 
             out.pos = (*it).second;
             havep = true;
-        }
-        else if (s == "nref") {
+        } else if (s == "nref") {
             const unsigned int id = ReadIndexFromText();
             std::map<unsigned int, aiVector3D>::const_iterator it = t.normals.find(id);
             if (it == t.normals.end()) {
@@ -789,8 +738,7 @@ void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out)
 
             out.normal = (*it).second;
             out.has_normal = true;
-        }
-        else if (s == "tcref") {
+        } else if (s == "tcref") {
             const unsigned int id = ReadIndexFromText();
             std::map<unsigned int, aiVector2D>::const_iterator it = t.uvs.find(id);
             if (it == t.uvs.end()) {
@@ -799,14 +747,11 @@ void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out)
 
             out.uv = (*it).second;
             out.has_uv = true;
-        }
-        else if (s == "p") {
+        } else if (s == "p") {
             out.pos = ReadVec3();
-        }
-        else if (s == "n") {
+        } else if (s == "n") {
             out.normal = ReadVec3();
-        }
-        else if (s == "tc") {
+        } else if (s == "tc") {
             out.uv = ReadVec2();
         }
     }
@@ -817,11 +762,10 @@ void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out)
 }
 
 // ------------------------------------------------------------------------------------------------
-unsigned int XGLImporter::ReadIDAttr()
-{
-    for(int i = 0, e = m_reader->getAttributeCount(); i < e; ++i) {
+unsigned int XGLImporter::ReadIDAttr() {
+    for (int i = 0, e = m_reader->getAttributeCount(); i < e; ++i) {
 
-        if(!ASSIMP_stricmp(m_reader->getAttributeName(i),"id")) {
+        if (!ASSIMP_stricmp(m_reader->getAttributeName(i), "id")) {
             return m_reader->getAttributeValueAsInt(i);
         }
     }
@@ -829,21 +773,20 @@ unsigned int XGLImporter::ReadIDAttr()
 }
 
 // ------------------------------------------------------------------------------------------------
-float XGLImporter::ReadFloat()
-{
-    if(!SkipToText()) {
+float XGLImporter::ReadFloat() {
+    if (!SkipToText()) {
         LogError("unexpected EOF reading float element contents");
         return 0.f;
     }
-    const char* s = m_reader->getNodeData(), *se;
+    const char *s = m_reader->getNodeData(), *se;
 
-    if(!SkipSpaces(&s)) {
+    if (!SkipSpaces(&s)) {
         LogError("unexpected EOL, failed to parse float");
         return 0.f;
     }
 
     float t;
-    se = fast_atoreal_move(s,t);
+    se = fast_atoreal_move(s, t);
 
     if (se == s) {
         LogError("failed to read float text");
@@ -854,19 +797,18 @@ float XGLImporter::ReadFloat()
 }
 
 // ------------------------------------------------------------------------------------------------
-unsigned int XGLImporter::ReadIndexFromText()
-{
-    if(!SkipToText()) {
+unsigned int XGLImporter::ReadIndexFromText() {
+    if (!SkipToText()) {
         LogError("unexpected EOF reading index element contents");
         return ~0u;
     }
-    const char* s = m_reader->getNodeData(), *se;
-    if(!SkipSpaces(&s)) {
+    const char *s = m_reader->getNodeData(), *se;
+    if (!SkipSpaces(&s)) {
         LogError("unexpected EOL, failed to parse index element");
         return ~0u;
     }
 
-    const unsigned int t = strtoul10(s,&se);
+    const unsigned int t = strtoul10(s, &se);
 
     if (se == s) {
         LogError("failed to read index");
@@ -877,23 +819,22 @@ unsigned int XGLImporter::ReadIndexFromText()
 }
 
 // ------------------------------------------------------------------------------------------------
-aiVector2D XGLImporter::ReadVec2()
-{
+aiVector2D XGLImporter::ReadVec2() {
     aiVector2D vec;
 
-    if(!SkipToText()) {
+    if (!SkipToText()) {
         LogError("unexpected EOF reading vec2 contents");
         return vec;
     }
-    const char* s = m_reader->getNodeData();
+    const char *s = m_reader->getNodeData();
 
     ai_real v[2];
-	for(int i = 0; i < 2; ++i) {
-        if(!SkipSpaces(&s)) {
+    for (int i = 0; i < 2; ++i) {
+        if (!SkipSpaces(&s)) {
             LogError("unexpected EOL, failed to parse vec2");
             return vec;
         }
-		
+
         v[i] = fast_atof(&s);
 
         SkipSpaces(&s);
@@ -903,25 +844,24 @@ aiVector2D XGLImporter::ReadVec2()
         }
         ++s;
     }
-	vec.x = v[0];
-	vec.y = v[1];
+    vec.x = v[0];
+    vec.y = v[1];
 
     return vec;
 }
 
 // ------------------------------------------------------------------------------------------------
-aiVector3D XGLImporter::ReadVec3()
-{
+aiVector3D XGLImporter::ReadVec3() {
     aiVector3D vec;
 
-    if(!SkipToText()) {
+    if (!SkipToText()) {
         LogError("unexpected EOF reading vec3 contents");
         return vec;
     }
-    const char* s = m_reader->getNodeData();
+    const char *s = m_reader->getNodeData();
 
-    for(int i = 0; i < 3; ++i) {
-        if(!SkipSpaces(&s)) {
+    for (int i = 0; i < 3; ++i) {
+        if (!SkipSpaces(&s)) {
             LogError("unexpected EOL, failed to parse vec3");
             return vec;
         }
@@ -939,13 +879,12 @@ aiVector3D XGLImporter::ReadVec3()
 }
 
 // ------------------------------------------------------------------------------------------------
-aiColor3D XGLImporter::ReadCol3()
-{
-    const aiVector3D& v = ReadVec3();
+aiColor3D XGLImporter::ReadCol3() {
+    const aiVector3D &v = ReadVec3();
     if (v.x < 0.f || v.x > 1.0f || v.y < 0.f || v.y > 1.0f || v.z < 0.f || v.z > 1.0f) {
         LogWarn("color values out of range, ignoring");
     }
-    return aiColor3D(v.x,v.y,v.z);
+    return aiColor3D(v.x, v.y, v.z);
 }
 
 #endif

+ 44 - 62
code/AssetLib/XGL/XGLLoader.h

@@ -47,69 +47,59 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define AI_XGLLOADER_H_INCLUDED
 
 #include <assimp/BaseImporter.h>
-#include <assimp/irrXMLWrapper.h>
 #include <assimp/LogAux.h>
+#include <assimp/irrXMLWrapper.h>
+#include <assimp/light.h>
 #include <assimp/material.h>
-#include <assimp/Importer.hpp>
 #include <assimp/mesh.h>
-#include <assimp/light.h>
-#include <memory>
+#include <assimp/Importer.hpp>
 #include <map>
+#include <memory>
 
 struct aiNode;
 
-namespace Assimp    {
+namespace Assimp {
 
 // ---------------------------------------------------------------------------
 /** XGL/ZGL importer.
  *
  * Spec: http://vizstream.aveva.com/release/vsplatform/XGLSpec.htm
  */
-class XGLImporter : public BaseImporter, public LogFunctions<XGLImporter>
-{
+class XGLImporter : public BaseImporter, public LogFunctions<XGLImporter> {
 public:
-
     XGLImporter();
     ~XGLImporter();
 
-
 public:
-
     // -------------------------------------------------------------------
     /** Returns whether the class can handle the format of the given file.
      *  See BaseImporter::CanRead() for details.    */
-    bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
-        bool checkSig) const;
+    bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
+            bool checkSig) const;
 
 protected:
-
     // -------------------------------------------------------------------
     /** Return importer meta information.
      * See #BaseImporter::GetInfo for the details  */
-    const aiImporterDesc* GetInfo () const;
+    const aiImporterDesc *GetInfo() const;
 
     // -------------------------------------------------------------------
     /** Imports the given file into the given scene structure.
      * See BaseImporter::InternReadFile() for details */
-    void InternReadFile( const std::string& pFile, aiScene* pScene,
-        IOSystem* pIOHandler);
+    void InternReadFile(const std::string &pFile, aiScene *pScene,
+            IOSystem *pIOHandler);
 
 private:
+    struct TempScope {
+        TempScope() :
+                light() {}
 
-
-    struct TempScope
-    {
-        TempScope()
-            : light()
-        {}
-
-        ~TempScope()
-        {
-            for(aiMesh* m : meshes_linear) {
+        ~TempScope() {
+            for (aiMesh *m : meshes_linear) {
                 delete m;
             }
 
-            for(aiMaterial* m : materials_linear) {
+            for (aiMaterial *m : materials_linear) {
                 delete m;
             }
 
@@ -117,45 +107,41 @@ private:
         }
 
         void dismiss() {
-            light = NULL;
+            light = nullptr;
             meshes_linear.clear();
             materials_linear.clear();
             meshes.clear();
             materials.clear();
         }
 
-        std::multimap<unsigned int, aiMesh*> meshes;
-        std::map<unsigned int, aiMaterial*> materials;
+        std::multimap<unsigned int, aiMesh *> meshes;
+        std::map<unsigned int, aiMaterial *> materials;
 
-        std::vector<aiMesh*> meshes_linear;
-        std::vector<aiMaterial*> materials_linear;
+        std::vector<aiMesh *> meshes_linear;
+        std::vector<aiMaterial *> materials_linear;
 
-        aiLight* light;
+        aiLight *light;
     };
 
-
     struct SortMeshByMaterialId {
-        SortMeshByMaterialId(const TempScope& scope) : scope(scope) {}
+        SortMeshByMaterialId(const TempScope &scope) :
+                scope(scope) {}
         bool operator()(unsigned int a, unsigned int b) const {
             return scope.meshes_linear[a]->mMaterialIndex < scope.meshes_linear[b]->mMaterialIndex;
         };
 
-        const TempScope& scope;
+        const TempScope &scope;
     };
 
-    struct TempMesh
-    {
+    struct TempMesh {
         std::map<unsigned int, aiVector3D> points;
         std::map<unsigned int, aiVector3D> normals;
         std::map<unsigned int, aiVector2D> uvs;
     };
 
-    struct TempMaterialMesh
-    {
-        TempMaterialMesh()
-            : pflags()
-            , matid()
-        {}
+    struct TempMaterialMesh {
+        TempMaterialMesh() :
+                pflags(), matid() {}
 
         std::vector<aiVector3D> positions, normals;
         std::vector<aiVector2D> uvs;
@@ -165,12 +151,9 @@ private:
         unsigned int matid;
     };
 
-    struct TempFace
-    {
-        TempFace()
-            : has_uv()
-            , has_normal()
-        {}
+    struct TempFace {
+        TempFace() :
+                has_uv(), has_normal() {}
 
         aiVector3D pos;
         aiVector3D normal;
@@ -180,21 +163,20 @@ private:
     };
 
 private:
-
     void Cleanup();
 
     std::string GetElementName();
     bool ReadElement();
-    bool ReadElementUpToClosing(const char* closetag);
+    bool ReadElementUpToClosing(const char *closetag);
     bool SkipToText();
     unsigned int ReadIDAttr();
 
-    void ReadWorld(TempScope& scope);
-    void ReadLighting(TempScope& scope);
-    aiLight* ReadDirectionalLight();
-    aiNode* ReadObject(TempScope& scope,bool skipFirst = false,const char* closetag = "object");
-    bool ReadMesh(TempScope& scope);
-    void ReadMaterial(TempScope& scope);
+    void ReadWorld(TempScope &scope);
+    void ReadLighting(TempScope &scope);
+    aiLight *ReadDirectionalLight();
+    aiNode *ReadObject(TempScope &scope, bool skipFirst = false, const char *closetag = "object");
+    bool ReadMesh(TempScope &scope);
+    void ReadMaterial(TempScope &scope);
     aiVector2D ReadVec2();
     aiVector3D ReadVec3();
     aiColor3D ReadCol3();
@@ -202,13 +184,13 @@ private:
     unsigned int ReadIndexFromText();
     float ReadFloat();
 
-    aiMesh* ToOutputMesh(const TempMaterialMesh& m);
-    void ReadFaceVertex(const TempMesh& t, TempFace& out);
-    unsigned int ResolveMaterialRef(TempScope& scope);
+    aiMesh *ToOutputMesh(const TempMaterialMesh &m);
+    void ReadFaceVertex(const TempMesh &t, TempFace &out);
+    unsigned int ResolveMaterialRef(TempScope &scope);
 
 private:
     std::shared_ptr<irr::io::IrrXMLReader> m_reader;
-    aiScene* m_scene;
+    aiScene *m_scene;
 };
 
 } // end of namespace Assimp

+ 189 - 216
code/AssetLib/glTF/glTFImporter.cpp

@@ -48,12 +48,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <assimp/StringComparison.h>
 #include <assimp/StringUtils.h>
-#include <assimp/Importer.hpp>
-#include <assimp/scene.h>
 #include <assimp/ai_assert.h>
-#include <assimp/DefaultLogger.hpp>
-#include <assimp/importerdesc.h>
 #include <assimp/commonMetaData.h>
+#include <assimp/importerdesc.h>
+#include <assimp/scene.h>
+#include <assimp/DefaultLogger.hpp>
+#include <assimp/Importer.hpp>
 
 #include <memory>
 
@@ -69,8 +69,7 @@ static const aiImporterDesc desc = {
     "",
     "",
     "",
-    aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_SupportCompressedFlavour
-        | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental,
+    aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_SupportCompressedFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental,
     0,
     0,
     0,
@@ -78,11 +77,8 @@ static const aiImporterDesc desc = {
     "gltf glb"
 };
 
-glTFImporter::glTFImporter()
-: BaseImporter()
-, meshOffsets()
-, embeddedTexIdxs()
-, mScene( nullptr ) {
+glTFImporter::glTFImporter() :
+        BaseImporter(), meshOffsets(), embeddedTexIdxs(), mScene(nullptr) {
     // empty
 }
 
@@ -90,11 +86,11 @@ glTFImporter::~glTFImporter() {
     // empty
 }
 
-const aiImporterDesc* glTFImporter::GetInfo() const {
+const aiImporterDesc *glTFImporter::GetInfo() const {
     return &desc;
 }
 
-bool glTFImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool /* checkSig */) const {
+bool glTFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /* checkSig */) const {
     const std::string &extension = GetExtension(pFile);
 
     if (extension != "gltf" && extension != "glb") {
@@ -115,9 +111,8 @@ bool glTFImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool
     return false;
 }
 
-inline
-void SetMaterialColorProperty(std::vector<int>& embeddedTexIdxs, Asset& /*r*/, glTF::TexProperty prop, aiMaterial* mat,
-        aiTextureType texType, const char* pKey, unsigned int type, unsigned int idx) {
+inline void SetMaterialColorProperty(std::vector<int> &embeddedTexIdxs, Asset & /*r*/, glTF::TexProperty prop, aiMaterial *mat,
+        aiTextureType texType, const char *pKey, unsigned int type, unsigned int idx) {
     if (prop.texture) {
         if (prop.texture->source) {
             aiString uri(prop.texture->source->uri);
@@ -138,22 +133,22 @@ void SetMaterialColorProperty(std::vector<int>& embeddedTexIdxs, Asset& /*r*/, g
     }
 }
 
-void glTFImporter::ImportMaterials(glTF::Asset& r) {
+void glTFImporter::ImportMaterials(glTF::Asset &r) {
     mScene->mNumMaterials = unsigned(r.materials.Size());
-    mScene->mMaterials = new aiMaterial*[mScene->mNumMaterials];
+    mScene->mMaterials = new aiMaterial *[mScene->mNumMaterials];
 
     for (unsigned int i = 0; i < mScene->mNumMaterials; ++i) {
-        aiMaterial* aimat = mScene->mMaterials[i] = new aiMaterial();
+        aiMaterial *aimat = mScene->mMaterials[i] = new aiMaterial();
 
-        Material& mat = r.materials[i];
+        Material &mat = r.materials[i];
 
         /*if (!mat.name.empty())*/ {
             aiString str(mat.id /*mat.name*/);
             aimat->AddProperty(&str, AI_MATKEY_NAME);
         }
 
-        SetMaterialColorProperty(embeddedTexIdxs, r, mat.ambient,  aimat, aiTextureType_AMBIENT,  AI_MATKEY_COLOR_AMBIENT );
-        SetMaterialColorProperty(embeddedTexIdxs, r, mat.diffuse,  aimat, aiTextureType_DIFFUSE,  AI_MATKEY_COLOR_DIFFUSE );
+        SetMaterialColorProperty(embeddedTexIdxs, r, mat.ambient, aimat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT);
+        SetMaterialColorProperty(embeddedTexIdxs, r, mat.diffuse, aimat, aiTextureType_DIFFUSE, AI_MATKEY_COLOR_DIFFUSE);
         SetMaterialColorProperty(embeddedTexIdxs, r, mat.specular, aimat, aiTextureType_SPECULAR, AI_MATKEY_COLOR_SPECULAR);
         SetMaterialColorProperty(embeddedTexIdxs, r, mat.emission, aimat, aiTextureType_EMISSIVE, AI_MATKEY_COLOR_EMISSIVE);
 
@@ -172,29 +167,25 @@ void glTFImporter::ImportMaterials(glTF::Asset& r) {
         mScene->mNumMaterials = 1;
         // Delete the array of length zero created above.
         delete[] mScene->mMaterials;
-        mScene->mMaterials = new aiMaterial*[1];
+        mScene->mMaterials = new aiMaterial *[1];
         mScene->mMaterials[0] = new aiMaterial();
     }
 }
 
-
-static inline void SetFace(aiFace& face, int a)
-{
+static inline void SetFace(aiFace &face, int a) {
     face.mNumIndices = 1;
     face.mIndices = new unsigned int[1];
     face.mIndices[0] = a;
 }
 
-static inline void SetFace(aiFace& face, int a, int b)
-{
+static inline void SetFace(aiFace &face, int a, int b) {
     face.mNumIndices = 2;
     face.mIndices = new unsigned int[2];
     face.mIndices[0] = a;
     face.mIndices[1] = b;
 }
 
-static inline void SetFace(aiFace& face, int a, int b, int c)
-{
+static inline void SetFace(aiFace &face, int a, int b, int c) {
     face.mNumIndices = 3;
     face.mIndices = new unsigned int[3];
     face.mIndices[0] = a;
@@ -202,9 +193,7 @@ static inline void SetFace(aiFace& face, int a, int b, int c)
     face.mIndices[2] = c;
 }
 
-#ifdef ASSIMP_BUILD_DEBUG
-static inline bool CheckValidFacesIndices(aiFace* faces, unsigned nFaces, unsigned nVerts)
-{
+static inline bool CheckValidFacesIndices(aiFace *faces, unsigned nFaces, unsigned nVerts) {
     for (unsigned i = 0; i < nFaces; ++i) {
         for (unsigned j = 0; j < faces[i].mNumIndices; ++j) {
             unsigned idx = faces[i].mIndices[j];
@@ -214,105 +203,98 @@ static inline bool CheckValidFacesIndices(aiFace* faces, unsigned nFaces, unsign
     }
     return true;
 }
-#endif // ASSIMP_BUILD_DEBUG
 
-void glTFImporter::ImportMeshes(glTF::Asset& r)
-{
-    std::vector<aiMesh*> meshes;
+void glTFImporter::ImportMeshes(glTF::Asset &r) {
+    std::vector<aiMesh *> meshes;
 
     unsigned int k = 0;
     meshOffsets.clear();
 
     for (unsigned int m = 0; m < r.meshes.Size(); ++m) {
-        Mesh& mesh = r.meshes[m];
+        Mesh &mesh = r.meshes[m];
 
-		// Check if mesh extensions is used
-		if(mesh.Extension.size() > 0)
-		{
-			for(Mesh::SExtension* cur_ext : mesh.Extension)
-			{
+        // Check if mesh extensions is used
+        if (mesh.Extension.size() > 0) {
+            for (Mesh::SExtension *cur_ext : mesh.Extension) {
 #ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
-				if(cur_ext->Type == Mesh::SExtension::EType::Compression_Open3DGC)
-				{
-					// Limitations for meshes when using Open3DGC-compression.
-					// It's a current limitation of sp... Specification have not this part still - about mesh compression. Why only one primitive?
-					// Because glTF is very flexibly. But in fact it ugly flexible. Every primitive can has own set of accessors and accessors can
-					// point to a-a-a-a-any part of buffer (through bufferview of course) and even to another buffer. We know that "Open3DGC-compression"
-					// is applicable only to part of buffer. As we can't guaranty continuity of the data for decoder, we will limit quantity of primitives.
-					// Yes indices, coordinates etc. still can br stored in different buffers, but with current specification it's a exporter problem.
-					// Also primitive can has only one of "POSITION", "NORMAL" and less then "AI_MAX_NUMBER_OF_TEXTURECOORDS" of "TEXCOORD". All accessor
-					// of primitive must point to one continuous region of the buffer.
-					if(mesh.primitives.size() > 2) throw DeadlyImportError("GLTF: When using Open3DGC compression then only one primitive per mesh are allowed.");
-
-					Mesh::SCompression_Open3DGC* o3dgc_ext = (Mesh::SCompression_Open3DGC*)cur_ext;
-					Ref<Buffer> buf = r.buffers.Get(o3dgc_ext->Buffer);
-
-					buf->EncodedRegion_SetCurrent(mesh.id);
-				}
-				else
+                if (cur_ext->Type == Mesh::SExtension::EType::Compression_Open3DGC) {
+                    // Limitations for meshes when using Open3DGC-compression.
+                    // It's a current limitation of sp... Specification have not this part still - about mesh compression. Why only one primitive?
+                    // Because glTF is very flexibly. But in fact it ugly flexible. Every primitive can has own set of accessors and accessors can
+                    // point to a-a-a-a-any part of buffer (through bufferview of course) and even to another buffer. We know that "Open3DGC-compression"
+                    // is applicable only to part of buffer. As we can't guaranty continuity of the data for decoder, we will limit quantity of primitives.
+                    // Yes indices, coordinates etc. still can br stored in different buffers, but with current specification it's a exporter problem.
+                    // Also primitive can has only one of "POSITION", "NORMAL" and less then "AI_MAX_NUMBER_OF_TEXTURECOORDS" of "TEXCOORD". All accessor
+                    // of primitive must point to one continuous region of the buffer.
+                    if (mesh.primitives.size() > 2) throw DeadlyImportError("GLTF: When using Open3DGC compression then only one primitive per mesh are allowed.");
+
+                    Mesh::SCompression_Open3DGC *o3dgc_ext = (Mesh::SCompression_Open3DGC *)cur_ext;
+                    Ref<Buffer> buf = r.buffers.Get(o3dgc_ext->Buffer);
+
+                    buf->EncodedRegion_SetCurrent(mesh.id);
+                } else
 #endif
-				{
-					throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + to_string(cur_ext->Type) +
-											"\"), only Open3DGC is supported.");
-				}
-			}
-		}// if(mesh.Extension.size() > 0)
-
-		meshOffsets.push_back(k);
+                {
+                    throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + to_string(cur_ext->Type) +
+                                            "\"), only Open3DGC is supported.");
+                }
+            }
+        } // if(mesh.Extension.size() > 0)
+
+        meshOffsets.push_back(k);
         k += unsigned(mesh.primitives.size());
 
         for (unsigned int p = 0; p < mesh.primitives.size(); ++p) {
-            Mesh::Primitive& prim = mesh.primitives[p];
+            Mesh::Primitive &prim = mesh.primitives[p];
 
-            aiMesh* aim = new aiMesh();
+            aiMesh *aim = new aiMesh();
             meshes.push_back(aim);
 
             aim->mName = mesh.id;
             if (mesh.primitives.size() > 1) {
-                ai_uint32& len = aim->mName.length;
+                ai_uint32 &len = aim->mName.length;
                 aim->mName.data[len] = '-';
                 len += 1 + ASSIMP_itoa10(aim->mName.data + len + 1, unsigned(MAXLEN - len - 1), p);
             }
 
             switch (prim.mode) {
-                case PrimitiveMode_POINTS:
-                    aim->mPrimitiveTypes |= aiPrimitiveType_POINT;
-                    break;
-
-                case PrimitiveMode_LINES:
-                case PrimitiveMode_LINE_LOOP:
-                case PrimitiveMode_LINE_STRIP:
-                    aim->mPrimitiveTypes |= aiPrimitiveType_LINE;
-                    break;
-
-                case PrimitiveMode_TRIANGLES:
-                case PrimitiveMode_TRIANGLE_STRIP:
-                case PrimitiveMode_TRIANGLE_FAN:
-                    aim->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE;
-                    break;
+            case PrimitiveMode_POINTS:
+                aim->mPrimitiveTypes |= aiPrimitiveType_POINT;
+                break;
+
+            case PrimitiveMode_LINES:
+            case PrimitiveMode_LINE_LOOP:
+            case PrimitiveMode_LINE_STRIP:
+                aim->mPrimitiveTypes |= aiPrimitiveType_LINE;
+                break;
+
+            case PrimitiveMode_TRIANGLES:
+            case PrimitiveMode_TRIANGLE_STRIP:
+            case PrimitiveMode_TRIANGLE_FAN:
+                aim->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE;
+                break;
             }
 
-            Mesh::Primitive::Attributes& attr = prim.attributes;
+            Mesh::Primitive::Attributes &attr = prim.attributes;
 
-			if (attr.position.size() > 0 && attr.position[0]) {
+            if (attr.position.size() > 0 && attr.position[0]) {
                 aim->mNumVertices = attr.position[0]->count;
                 attr.position[0]->ExtractData(aim->mVertices);
-			}
+            }
 
-			if (attr.normal.size() > 0 && attr.normal[0]) attr.normal[0]->ExtractData(aim->mNormals);
+            if (attr.normal.size() > 0 && attr.normal[0]) attr.normal[0]->ExtractData(aim->mNormals);
 
             for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) {
                 attr.texcoord[tc]->ExtractData(aim->mTextureCoords[tc]);
                 aim->mNumUVComponents[tc] = attr.texcoord[tc]->GetNumComponents();
 
-                aiVector3D* values = aim->mTextureCoords[tc];
+                aiVector3D *values = aim->mTextureCoords[tc];
                 for (unsigned int i = 0; i < aim->mNumVertices; ++i) {
                     values[i].y = 1 - values[i].y; // Flip Y coords
                 }
             }
 
-
-            aiFace* faces = 0;
+            aiFace *faces = 0;
             unsigned int nFaces = 0;
 
             if (prim.indices) {
@@ -322,76 +304,75 @@ void glTFImporter::ImportMeshes(glTF::Asset& r)
                 ai_assert(data.IsValid());
 
                 switch (prim.mode) {
-                    case PrimitiveMode_POINTS: {
-                        nFaces = count;
-                        faces = new aiFace[nFaces];
-                        for (unsigned int i = 0; i < count; ++i) {
-                            SetFace(faces[i], data.GetUInt(i));
-                        }
-                        break;
+                case PrimitiveMode_POINTS: {
+                    nFaces = count;
+                    faces = new aiFace[nFaces];
+                    for (unsigned int i = 0; i < count; ++i) {
+                        SetFace(faces[i], data.GetUInt(i));
                     }
+                    break;
+                }
 
-                    case PrimitiveMode_LINES: {
-                        nFaces = count / 2;
-                        if (nFaces * 2 != count) {
-                            ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped.");
-                            count = nFaces * 2;
-                        }
-                        faces = new aiFace[nFaces];
-                        for (unsigned int i = 0; i < count; i += 2) {
-                            SetFace(faces[i / 2], data.GetUInt(i), data.GetUInt(i + 1));
-                        }
-                        break;
+                case PrimitiveMode_LINES: {
+                    nFaces = count / 2;
+                    if (nFaces * 2 != count) {
+                        ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped.");
+                        count = nFaces * 2;
+                    }
+                    faces = new aiFace[nFaces];
+                    for (unsigned int i = 0; i < count; i += 2) {
+                        SetFace(faces[i / 2], data.GetUInt(i), data.GetUInt(i + 1));
                     }
+                    break;
+                }
 
-                    case PrimitiveMode_LINE_LOOP:
-                    case PrimitiveMode_LINE_STRIP: {
-                        nFaces = count - ((prim.mode == PrimitiveMode_LINE_STRIP) ? 1 : 0);
-                        faces = new aiFace[nFaces];
-                        SetFace(faces[0], data.GetUInt(0), data.GetUInt(1));
-                        for (unsigned int i = 2; i < count; ++i) {
-                            SetFace(faces[i - 1], faces[i - 2].mIndices[1], data.GetUInt(i));
-                        }
-                        if (prim.mode == PrimitiveMode_LINE_LOOP) { // close the loop
-                            SetFace(faces[count - 1], faces[count - 2].mIndices[1], faces[0].mIndices[0]);
-                        }
-                        break;
+                case PrimitiveMode_LINE_LOOP:
+                case PrimitiveMode_LINE_STRIP: {
+                    nFaces = count - ((prim.mode == PrimitiveMode_LINE_STRIP) ? 1 : 0);
+                    faces = new aiFace[nFaces];
+                    SetFace(faces[0], data.GetUInt(0), data.GetUInt(1));
+                    for (unsigned int i = 2; i < count; ++i) {
+                        SetFace(faces[i - 1], faces[i - 2].mIndices[1], data.GetUInt(i));
+                    }
+                    if (prim.mode == PrimitiveMode_LINE_LOOP) { // close the loop
+                        SetFace(faces[count - 1], faces[count - 2].mIndices[1], faces[0].mIndices[0]);
                     }
+                    break;
+                }
 
-                    case PrimitiveMode_TRIANGLES: {
-                        nFaces = count / 3;
-                        if (nFaces * 3 != count) {
-                            ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped.");
-                            count = nFaces * 3;
-                        }
-                        faces = new aiFace[nFaces];
-                        for (unsigned int i = 0; i < count; i += 3) {
-                            SetFace(faces[i / 3], data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
-                        }
-                        break;
+                case PrimitiveMode_TRIANGLES: {
+                    nFaces = count / 3;
+                    if (nFaces * 3 != count) {
+                        ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped.");
+                        count = nFaces * 3;
                     }
-                    case PrimitiveMode_TRIANGLE_STRIP: {
-                        nFaces = count - 2;
-                        faces = new aiFace[nFaces];
-                        SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2));
-                        for (unsigned int i = 3; i < count; ++i) {
-                            SetFace(faces[i - 2], faces[i - 1].mIndices[1], faces[i - 1].mIndices[2], data.GetUInt(i));
-                        }
-                        break;
+                    faces = new aiFace[nFaces];
+                    for (unsigned int i = 0; i < count; i += 3) {
+                        SetFace(faces[i / 3], data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
                     }
-                    case PrimitiveMode_TRIANGLE_FAN:
-                        nFaces = count - 2;
-                        faces = new aiFace[nFaces];
-                        SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2));
-                        for (unsigned int i = 3; i < count; ++i) {
-                            SetFace(faces[i - 2], faces[0].mIndices[0], faces[i - 1].mIndices[2], data.GetUInt(i));
-                        }
-                        break;
+                    break;
                 }
-            }
-            else { // no indices provided so directly generate from counts
+                case PrimitiveMode_TRIANGLE_STRIP: {
+                    nFaces = count - 2;
+                    faces = new aiFace[nFaces];
+                    SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2));
+                    for (unsigned int i = 3; i < count; ++i) {
+                        SetFace(faces[i - 2], faces[i - 1].mIndices[1], faces[i - 1].mIndices[2], data.GetUInt(i));
+                    }
+                    break;
+                }
+                case PrimitiveMode_TRIANGLE_FAN:
+                    nFaces = count - 2;
+                    faces = new aiFace[nFaces];
+                    SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2));
+                    for (unsigned int i = 3; i < count; ++i) {
+                        SetFace(faces[i - 2], faces[0].mIndices[0], faces[i - 1].mIndices[2], data.GetUInt(i));
+                    }
+                    break;
+                }
+            } else { // no indices provided so directly generate from counts
 
-                // use the already determined count as it includes checks 
+                // use the already determined count as it includes checks
                 unsigned int count = aim->mNumVertices;
 
                 switch (prim.mode) {
@@ -466,7 +447,11 @@ void glTFImporter::ImportMeshes(glTF::Asset& r)
             if (faces) {
                 aim->mFaces = faces;
                 aim->mNumFaces = nFaces;
-                ai_assert(CheckValidFacesIndices(faces, nFaces, aim->mNumVertices));
+                const bool validRes = CheckValidFacesIndices(faces, nFaces, aim->mNumVertices);
+                if (!validRes) {
+                    ai_assert(validRes);
+                    ASSIMP_LOG_WARN("Invalid number of faces detected.");
+                }
             }
 
             if (prim.material) {
@@ -480,22 +465,22 @@ void glTFImporter::ImportMeshes(glTF::Asset& r)
     CopyVector(meshes, mScene->mMeshes, mScene->mNumMeshes);
 }
 
-void glTFImporter::ImportCameras(glTF::Asset& r) {
+void glTFImporter::ImportCameras(glTF::Asset &r) {
     if (!r.cameras.Size()) {
         return;
     }
 
     mScene->mNumCameras = r.cameras.Size();
-    mScene->mCameras = new aiCamera*[r.cameras.Size()];
+    mScene->mCameras = new aiCamera *[r.cameras.Size()];
     for (size_t i = 0; i < r.cameras.Size(); ++i) {
-        Camera& cam = r.cameras[i];
+        Camera &cam = r.cameras[i];
 
-        aiCamera* aicam = mScene->mCameras[i] = new aiCamera();
+        aiCamera *aicam = mScene->mCameras[i] = new aiCamera();
 
         if (cam.type == Camera::Perspective) {
-            aicam->mAspect        = cam.perspective.aspectRatio;
+            aicam->mAspect = cam.perspective.aspectRatio;
             aicam->mHorizontalFOV = cam.perspective.yfov * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect);
-            aicam->mClipPlaneFar  = cam.perspective.zfar;
+            aicam->mClipPlaneFar = cam.perspective.zfar;
             aicam->mClipPlaneNear = cam.perspective.znear;
         } else {
             aicam->mClipPlaneFar = cam.ortographic.zfar;
@@ -509,30 +494,33 @@ void glTFImporter::ImportCameras(glTF::Asset& r) {
     }
 }
 
-void glTFImporter::ImportLights(glTF::Asset& r)
-{
+void glTFImporter::ImportLights(glTF::Asset &r) {
     if (!r.lights.Size()) return;
 
     mScene->mNumLights = r.lights.Size();
-    mScene->mLights = new aiLight*[r.lights.Size()];
+    mScene->mLights = new aiLight *[r.lights.Size()];
 
     for (size_t i = 0; i < r.lights.Size(); ++i) {
-        Light& l = r.lights[i];
+        Light &l = r.lights[i];
 
-        aiLight* ail = mScene->mLights[i] = new aiLight();
+        aiLight *ail = mScene->mLights[i] = new aiLight();
 
         switch (l.type) {
-            case Light::Type_directional:
-                ail->mType = aiLightSource_DIRECTIONAL; break;
+        case Light::Type_directional:
+            ail->mType = aiLightSource_DIRECTIONAL;
+            break;
 
-            case Light::Type_spot:
-                ail->mType = aiLightSource_SPOT; break;
+        case Light::Type_spot:
+            ail->mType = aiLightSource_SPOT;
+            break;
 
-            case Light::Type_ambient:
-                ail->mType = aiLightSource_AMBIENT; break;
+        case Light::Type_ambient:
+            ail->mType = aiLightSource_AMBIENT;
+            break;
 
-            default: // Light::Type_point
-                ail->mType = aiLightSource_POINT; break;
+        default: // Light::Type_point
+            ail->mType = aiLightSource_POINT;
+            break;
         }
 
         CopyValue(l.color, ail->mColorAmbient);
@@ -542,35 +530,32 @@ void glTFImporter::ImportLights(glTF::Asset& r)
         ail->mAngleOuterCone = l.falloffAngle;
         ail->mAngleInnerCone = l.falloffExponent; // TODO fix this, it does not look right at all
 
-        ail->mAttenuationConstant  = l.constantAttenuation;
-        ail->mAttenuationLinear    = l.linearAttenuation;
+        ail->mAttenuationConstant = l.constantAttenuation;
+        ail->mAttenuationLinear = l.linearAttenuation;
         ail->mAttenuationQuadratic = l.quadraticAttenuation;
     }
 }
 
+aiNode *ImportNode(aiScene *pScene, glTF::Asset &r, std::vector<unsigned int> &meshOffsets, glTF::Ref<glTF::Node> &ptr) {
+    Node &node = *ptr;
 
-aiNode* ImportNode(aiScene* pScene, glTF::Asset& r, std::vector<unsigned int>& meshOffsets, glTF::Ref<glTF::Node>& ptr)
-{
-    Node& node = *ptr;
-
-    aiNode* ainode = new aiNode(node.id);
+    aiNode *ainode = new aiNode(node.id);
 
     if (!node.children.empty()) {
         ainode->mNumChildren = unsigned(node.children.size());
-        ainode->mChildren = new aiNode*[ainode->mNumChildren];
+        ainode->mChildren = new aiNode *[ainode->mNumChildren];
 
         for (unsigned int i = 0; i < ainode->mNumChildren; ++i) {
-            aiNode* child = ImportNode(pScene, r, meshOffsets, node.children[i]);
+            aiNode *child = ImportNode(pScene, r, meshOffsets, node.children[i]);
             child->mParent = ainode;
             ainode->mChildren[i] = child;
         }
     }
 
-    aiMatrix4x4& matrix = ainode->mTransformation;
+    aiMatrix4x4 &matrix = ainode->mTransformation;
     if (node.matrix.isPresent) {
         CopyValue(node.matrix.value, matrix);
-    }
-    else {
+    } else {
         if (node.translation.isPresent) {
             aiVector3D trans;
             CopyValue(node.translation.value, trans);
@@ -587,7 +572,6 @@ aiNode* ImportNode(aiScene* pScene, glTF::Asset& r, std::vector<unsigned int>& m
             matrix = s * matrix;
         }
 
-
         if (node.rotation.isPresent) {
             aiQuaternion rot;
             CopyValue(node.rotation.value, rot);
@@ -625,22 +609,20 @@ aiNode* ImportNode(aiScene* pScene, glTF::Asset& r, std::vector<unsigned int>& m
     return ainode;
 }
 
-void glTFImporter::ImportNodes(glTF::Asset& r)
-{
+void glTFImporter::ImportNodes(glTF::Asset &r) {
     if (!r.scene) return;
 
-    std::vector< Ref<Node> > rootNodes = r.scene->nodes;
+    std::vector<Ref<Node>> rootNodes = r.scene->nodes;
 
     // The root nodes
     unsigned int numRootNodes = unsigned(rootNodes.size());
     if (numRootNodes == 1) { // a single root node: use it
         mScene->mRootNode = ImportNode(mScene, r, meshOffsets, rootNodes[0]);
-    }
-    else if (numRootNodes > 1) { // more than one root node: create a fake root
-        aiNode* root = new aiNode("ROOT");
-        root->mChildren = new aiNode*[numRootNodes];
+    } else if (numRootNodes > 1) { // more than one root node: create a fake root
+        aiNode *root = new aiNode("ROOT");
+        root->mChildren = new aiNode *[numRootNodes];
         for (unsigned int i = 0; i < numRootNodes; ++i) {
-            aiNode* node = ImportNode(mScene, r, meshOffsets, rootNodes[i]);
+            aiNode *node = ImportNode(mScene, r, meshOffsets, rootNodes[i]);
             node->mParent = root;
             root->mChildren[root->mNumChildren++] = node;
         }
@@ -652,8 +634,7 @@ void glTFImporter::ImportNodes(glTF::Asset& r)
     //}
 }
 
-void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r)
-{
+void glTFImporter::ImportEmbeddedTextures(glTF::Asset &r) {
     embeddedTexIdxs.resize(r.images.Size(), -1);
 
     int numEmbeddedTexs = 0;
@@ -665,7 +646,7 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r)
     if (numEmbeddedTexs == 0)
         return;
 
-    mScene->mTextures = new aiTexture*[numEmbeddedTexs];
+    mScene->mTextures = new aiTexture *[numEmbeddedTexs];
 
     // Add the embedded textures
     for (size_t i = 0; i < r.images.Size(); ++i) {
@@ -675,18 +656,18 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r)
         int idx = mScene->mNumTextures++;
         embeddedTexIdxs[i] = idx;
 
-        aiTexture* tex = mScene->mTextures[idx] = new aiTexture();
+        aiTexture *tex = mScene->mTextures[idx] = new aiTexture();
 
         size_t length = img.GetDataLength();
-        void* data = img.StealData();
+        void *data = img.StealData();
 
         tex->mFilename = img.name;
         tex->mWidth = static_cast<unsigned int>(length);
         tex->mHeight = 0;
-        tex->pcData = reinterpret_cast<aiTexel*>(data);
+        tex->pcData = reinterpret_cast<aiTexel *>(data);
 
         if (!img.mimeType.empty()) {
-            const char* ext = strchr(img.mimeType.c_str(), '/') + 1;
+            const char *ext = strchr(img.mimeType.c_str(), '/') + 1;
             if (ext) {
                 if (strcmp(ext, "jpeg") == 0) ext = "jpg";
 
@@ -699,32 +680,26 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r)
     }
 }
 
-void glTFImporter::ImportCommonMetadata(glTF::Asset& a)
-{
+void glTFImporter::ImportCommonMetadata(glTF::Asset &a) {
     ai_assert(mScene->mMetaData == nullptr);
     const bool hasVersion = !a.asset.version.empty();
     const bool hasGenerator = !a.asset.generator.empty();
     const bool hasCopyright = !a.asset.copyright.empty();
-    if (hasVersion || hasGenerator || hasCopyright)
-    {
+    if (hasVersion || hasGenerator || hasCopyright) {
         mScene->mMetaData = new aiMetadata;
-        if (hasVersion)
-        {
+        if (hasVersion) {
             mScene->mMetaData->Add(AI_METADATA_SOURCE_FORMAT_VERSION, aiString(a.asset.version));
         }
-        if (hasGenerator)
-        {
+        if (hasGenerator) {
             mScene->mMetaData->Add(AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator));
         }
-        if (hasCopyright)
-        {
+        if (hasCopyright) {
             mScene->mMetaData->Add(AI_METADATA_SOURCE_COPYRIGHT, aiString(a.asset.copyright));
         }
     }
 }
 
-void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
-{
+void glTFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
     // clean all member arrays
     meshOffsets.clear();
     embeddedTexIdxs.clear();
@@ -735,7 +710,6 @@ void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOS
     glTF::Asset asset(pIOHandler);
     asset.Load(pFile, GetExtension(pFile) == "glb");
 
-
     //
     // Copy the data out
     //
@@ -757,4 +731,3 @@ void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOS
 }
 
 #endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
-

+ 29 - 41
code/CApi/AssimpCExport.cpp

@@ -48,108 +48,96 @@ Assimp C export interface. See Exporter.cpp for some notes.
 #ifndef ASSIMP_BUILD_NO_EXPORT
 
 #include "CInterfaceIOWrapper.h"
-#include <assimp/SceneCombiner.h>
 #include "Common/ScenePrivate.h"
+#include <assimp/SceneCombiner.h>
 #include <assimp/Exporter.hpp>
 
 using namespace Assimp;
 
 // ------------------------------------------------------------------------------------------------
-ASSIMP_API size_t aiGetExportFormatCount(void)
-{
+ASSIMP_API size_t aiGetExportFormatCount(void) {
     return Exporter().GetExportFormatCount();
 }
 
 // ------------------------------------------------------------------------------------------------
-ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t index)
-{
+ASSIMP_API const aiExportFormatDesc *aiGetExportFormatDescription(size_t index) {
     // Note: this is valid as the index always pertains to a built-in exporter,
     // for which the returned structure is guaranteed to be of static storage duration.
     Exporter exporter;
-    const aiExportFormatDesc* orig( exporter.GetExportFormatDescription( index ) );
-    if (NULL == orig) {
-        return NULL;
+    const aiExportFormatDesc *orig(exporter.GetExportFormatDescription(index));
+    if (nullptr == orig) {
+        return nullptr;
     }
 
     aiExportFormatDesc *desc = new aiExportFormatDesc;
-    desc->description = new char[ strlen( orig->description ) + 1 ]();
-    ::memcpy( (char*) desc->description, orig->description, strlen( orig->description ) );
-    desc->fileExtension = new char[ strlen( orig->fileExtension ) + 1 ]();
-    ::memcpy( ( char* ) desc->fileExtension, orig->fileExtension, strlen( orig->fileExtension ) );
-    desc->id = new char[ strlen( orig->id ) + 1 ]();
-    ::memcpy( ( char* ) desc->id, orig->id, strlen( orig->id ) );
+    desc->description = new char[strlen(orig->description) + 1]();
+    ::memcpy((char *)desc->description, orig->description, strlen(orig->description));
+    desc->fileExtension = new char[strlen(orig->fileExtension) + 1]();
+    ::memcpy((char *)desc->fileExtension, orig->fileExtension, strlen(orig->fileExtension));
+    desc->id = new char[strlen(orig->id) + 1]();
+    ::memcpy((char *)desc->id, orig->id, strlen(orig->id));
 
     return desc;
 }
 
 // ------------------------------------------------------------------------------------------------
-ASSIMP_API void aiReleaseExportFormatDescription( const aiExportFormatDesc *desc ) {
-    if (NULL == desc) {
+ASSIMP_API void aiReleaseExportFormatDescription(const aiExportFormatDesc *desc) {
+    if (nullptr == desc) {
         return;
     }
 
-    delete [] desc->description;
-    delete [] desc->fileExtension;
-    delete [] desc->id;
+    delete[] desc->description;
+    delete[] desc->fileExtension;
+    delete[] desc->id;
     delete desc;
 }
 
 // ------------------------------------------------------------------------------------------------
-ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut)
-{
+ASSIMP_API void aiCopyScene(const aiScene *pIn, aiScene **pOut) {
     if (!pOut || !pIn) {
         return;
     }
 
-    SceneCombiner::CopyScene(pOut,pIn,true);
+    SceneCombiner::CopyScene(pOut, pIn, true);
     ScenePriv(*pOut)->mIsCopy = true;
 }
 
-
 // ------------------------------------------------------------------------------------------------
-ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn)
-{
+ASSIMP_API void aiFreeScene(const C_STRUCT aiScene *pIn) {
     // note: aiReleaseImport() is also able to delete scene copies, but in addition
     // it also handles scenes with import metadata.
     delete pIn;
 }
 
-
 // ------------------------------------------------------------------------------------------------
-ASSIMP_API aiReturn aiExportScene( const aiScene* pScene, const char* pFormatId, const char* pFileName, unsigned int pPreprocessing )
-{
-    return ::aiExportSceneEx(pScene,pFormatId,pFileName,NULL,pPreprocessing);
+ASSIMP_API aiReturn aiExportScene(const aiScene *pScene, const char *pFormatId, const char *pFileName, unsigned int pPreprocessing) {
+    return ::aiExportSceneEx(pScene, pFormatId, pFileName, nullptr, pPreprocessing);
 }
 
-
 // ------------------------------------------------------------------------------------------------
-ASSIMP_API aiReturn aiExportSceneEx( const aiScene* pScene, const char* pFormatId, const char* pFileName, aiFileIO* pIO, unsigned int pPreprocessing )
-{
+ASSIMP_API aiReturn aiExportSceneEx(const aiScene *pScene, const char *pFormatId, const char *pFileName, aiFileIO *pIO, unsigned int pPreprocessing) {
     Exporter exp;
 
     if (pIO) {
         exp.SetIOHandler(new CIOSystemWrapper(pIO));
     }
-    return exp.Export(pScene,pFormatId,pFileName,pPreprocessing);
+    return exp.Export(pScene, pFormatId, pFileName, pPreprocessing);
 }
 
-
 // ------------------------------------------------------------------------------------------------
-ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing  )
-{
+ASSIMP_API const C_STRUCT aiExportDataBlob *aiExportSceneToBlob(const aiScene *pScene, const char *pFormatId, unsigned int pPreprocessing) {
     Exporter exp;
-    if (!exp.ExportToBlob(pScene,pFormatId,pPreprocessing)) {
-        return NULL;
+    if (!exp.ExportToBlob(pScene, pFormatId, pPreprocessing)) {
+        return nullptr;
     }
-    const aiExportDataBlob* blob = exp.GetOrphanedBlob();
+    const aiExportDataBlob *blob = exp.GetOrphanedBlob();
     ai_assert(blob);
 
     return blob;
 }
 
 // ------------------------------------------------------------------------------------------------
-ASSIMP_API C_STRUCT void aiReleaseExportBlob( const aiExportDataBlob* pData )
-{
+ASSIMP_API C_STRUCT void aiReleaseExportBlob(const aiExportDataBlob *pData) {
     delete pData;
 }
 

+ 1 - 1
code/CApi/CInterfaceIOWrapper.cpp

@@ -116,7 +116,7 @@ char CIOSystemWrapper::getOsSeparator() const {
 IOStream *CIOSystemWrapper::Open(const char *pFile, const char *pMode) {
     aiFile *p = mFileSystem->OpenProc(mFileSystem, pFile, pMode);
     if (!p) {
-        return NULL;
+        return nullptr;
     }
     return new CIOStreamWrapper(p, this);
 }

+ 1 - 0
code/CMakeLists.txt

@@ -199,6 +199,7 @@ SET( Common_SRCS
   Common/simd.h
   Common/simd.cpp
   Common/material.cpp
+  Common/AssertHandler.cpp
 )
 SOURCE_GROUP(Common FILES ${Common_SRCS})
 

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio