From 161bf7f83b378335d708fd2e0f6ad2346d867f18 Mon Sep 17 00:00:00 2001 From: Areloch Date: Tue, 5 Mar 2019 14:39:38 -0600 Subject: [PATCH] Updated assimp to latest --- Engine/lib/assimp/code/3DSConverter.cpp | 36 +- Engine/lib/assimp/code/3DSExporter.cpp | 9 +- Engine/lib/assimp/code/3DSExporter.h | 7 +- Engine/lib/assimp/code/3DSHelper.h | 155 +- Engine/lib/assimp/code/3DSLoader.cpp | 125 +- Engine/lib/assimp/code/3DSLoader.h | 7 +- Engine/lib/assimp/code/3MFXmlTags.h | 19 +- Engine/lib/assimp/code/ACLoader.cpp | 49 +- Engine/lib/assimp/code/ACLoader.h | 5 +- Engine/lib/assimp/code/AMFImporter.cpp | 7 +- Engine/lib/assimp/code/AMFImporter.hpp | 257 +- .../lib/assimp/code/AMFImporter_Geometry.cpp | 3 +- Engine/lib/assimp/code/AMFImporter_Macro.hpp | 11 +- .../lib/assimp/code/AMFImporter_Material.cpp | 101 +- Engine/lib/assimp/code/AMFImporter_Node.hpp | 186 +- .../assimp/code/AMFImporter_Postprocess.cpp | 18 +- Engine/lib/assimp/code/ASELoader.cpp | 40 +- Engine/lib/assimp/code/ASELoader.h | 5 +- Engine/lib/assimp/code/ASEParser.cpp | 69 +- Engine/lib/assimp/code/ASEParser.h | 230 +- Engine/lib/assimp/code/AssbinExporter.cpp | 1265 +-- Engine/lib/assimp/code/AssbinExporter.h | 14 +- Engine/lib/assimp/code/AssbinLoader.cpp | 369 +- Engine/lib/assimp/code/AssbinLoader.h | 48 +- Engine/lib/assimp/code/Assimp.cpp | 13 +- Engine/lib/assimp/code/AssimpCExport.cpp | 4 +- Engine/lib/assimp/code/AssxmlExporter.cpp | 19 +- Engine/lib/assimp/code/AssxmlExporter.h | 3 +- Engine/lib/assimp/code/B3DImporter.cpp | 63 +- Engine/lib/assimp/code/B3DImporter.h | 14 +- Engine/lib/assimp/code/BVHLoader.cpp | 121 +- Engine/lib/assimp/code/BVHLoader.h | 10 +- Engine/lib/assimp/code/BaseImporter.cpp | 125 +- Engine/lib/assimp/code/BaseProcess.cpp | 9 +- Engine/lib/assimp/code/BaseProcess.h | 13 +- Engine/lib/assimp/code/Bitmap.cpp | 10 +- Engine/lib/assimp/code/BlenderBMesh.h | 2 +- Engine/lib/assimp/code/BlenderCustomData.cpp | 189 + Engine/lib/assimp/code/BlenderCustomData.h | 89 + Engine/lib/assimp/code/BlenderDNA.cpp | 31 +- Engine/lib/assimp/code/BlenderDNA.h | 46 +- Engine/lib/assimp/code/BlenderDNA.inl | 113 +- Engine/lib/assimp/code/BlenderIntermediate.h | 11 +- Engine/lib/assimp/code/BlenderLoader.cpp | 110 +- Engine/lib/assimp/code/BlenderLoader.h | 7 +- Engine/lib/assimp/code/BlenderModifier.cpp | 33 +- Engine/lib/assimp/code/BlenderModifier.h | 62 +- Engine/lib/assimp/code/BlenderScene.cpp | 48 +- Engine/lib/assimp/code/BlenderScene.h | 83 +- Engine/lib/assimp/code/BlenderSceneGen.h | 11 + Engine/lib/assimp/code/BlenderTessellator.cpp | 3 +- Engine/lib/assimp/code/BlenderTessellator.h | 7 +- Engine/lib/assimp/code/C4DImporter.cpp | 2 +- Engine/lib/assimp/code/C4DImporter.h | 4 +- .../lib/assimp/code/CInterfaceIOWrapper.cpp | 3 +- Engine/lib/assimp/code/CInterfaceIOWrapper.h | 3 +- Engine/lib/assimp/code/CMakeLists.txt | 197 +- Engine/lib/assimp/code/COBLoader.cpp | 124 +- Engine/lib/assimp/code/COBLoader.h | 29 +- Engine/lib/assimp/code/COBScene.h | 5 +- Engine/lib/assimp/code/CSMLoader.cpp | 15 +- Engine/lib/assimp/code/CSMLoader.h | 5 +- .../lib/assimp/code/CalcTangentsProcess.cpp | 21 +- Engine/lib/assimp/code/CalcTangentsProcess.h | 3 +- Engine/lib/assimp/code/ColladaExporter.cpp | 57 +- Engine/lib/assimp/code/ColladaExporter.h | 7 +- Engine/lib/assimp/code/ColladaHelper.h | 10 +- Engine/lib/assimp/code/ColladaLoader.cpp | 236 +- Engine/lib/assimp/code/ColladaLoader.h | 6 +- Engine/lib/assimp/code/ColladaParser.cpp | 84 +- Engine/lib/assimp/code/ColladaParser.h | 10 +- .../assimp/code/ComputeUVMappingProcess.cpp | 17 +- .../lib/assimp/code/ComputeUVMappingProcess.h | 3 +- Engine/lib/assimp/code/ConvertToLHProcess.cpp | 140 +- Engine/lib/assimp/code/ConvertToLHProcess.h | 3 +- Engine/lib/assimp/code/CreateAnimMesh.cpp | 2 +- Engine/lib/assimp/code/D3MFExporter.cpp | 86 +- Engine/lib/assimp/code/D3MFExporter.h | 11 +- Engine/lib/assimp/code/D3MFImporter.cpp | 321 +- Engine/lib/assimp/code/D3MFImporter.h | 5 +- Engine/lib/assimp/code/D3MFOpcPackage.cpp | 77 +- Engine/lib/assimp/code/D3MFOpcPackage.h | 17 +- Engine/lib/assimp/code/DXFHelper.h | 70 +- Engine/lib/assimp/code/DXFLoader.cpp | 253 +- Engine/lib/assimp/code/DXFLoader.h | 37 +- Engine/lib/assimp/code/DeboneProcess.cpp | 15 +- Engine/lib/assimp/code/DeboneProcess.h | 3 +- Engine/lib/assimp/code/DefaultIOStream.cpp | 6 +- Engine/lib/assimp/code/DefaultIOSystem.cpp | 124 +- Engine/lib/assimp/code/DefaultLogger.cpp | 129 +- .../lib/assimp/code/DefaultProgressHandler.h | 7 +- .../assimp/code/DropFaceNormalsProcess.cpp | 109 + ...tepExporter.h => DropFaceNormalsProcess.h} | 84 +- .../lib/assimp/code/EmbedTexturesProcess.cpp | 152 + Engine/lib/assimp/code/EmbedTexturesProcess.h | 85 + Engine/lib/assimp/code/Exporter.cpp | 170 +- Engine/lib/assimp/code/FBXAnimation.cpp | 7 +- Engine/lib/assimp/code/FBXBinaryTokenizer.cpp | 64 +- Engine/lib/assimp/code/FBXCommon.h | 86 + Engine/lib/assimp/code/FBXCompileConfig.h | 3 +- Engine/lib/assimp/code/FBXConverter.cpp | 6451 +++++++------- Engine/lib/assimp/code/FBXConverter.h | 394 +- Engine/lib/assimp/code/FBXDeformer.cpp | 50 +- Engine/lib/assimp/code/FBXDocument.cpp | 45 +- Engine/lib/assimp/code/FBXDocument.h | 167 +- Engine/lib/assimp/code/FBXDocumentUtil.cpp | 9 +- Engine/lib/assimp/code/FBXDocumentUtil.h | 18 +- Engine/lib/assimp/code/FBXExportNode.cpp | 568 ++ Engine/lib/assimp/code/FBXExportNode.h | 271 + Engine/lib/assimp/code/FBXExportProperty.cpp | 364 + Engine/lib/assimp/code/FBXExportProperty.h | 129 + Engine/lib/assimp/code/FBXExporter.cpp | 2480 ++++++ Engine/lib/assimp/code/FBXExporter.h | 178 + Engine/lib/assimp/code/FBXImportSettings.h | 11 +- Engine/lib/assimp/code/FBXImporter.cpp | 25 +- Engine/lib/assimp/code/FBXImporter.h | 7 +- Engine/lib/assimp/code/FBXMaterial.cpp | 66 +- Engine/lib/assimp/code/FBXMeshGeometry.cpp | 116 +- Engine/lib/assimp/code/FBXMeshGeometry.h | 64 +- Engine/lib/assimp/code/FBXModel.cpp | 3 +- Engine/lib/assimp/code/FBXNodeAttribute.cpp | 3 +- Engine/lib/assimp/code/FBXParser.cpp | 40 +- Engine/lib/assimp/code/FBXParser.h | 12 +- Engine/lib/assimp/code/FBXProperties.cpp | 8 +- Engine/lib/assimp/code/FBXProperties.h | 23 +- Engine/lib/assimp/code/FBXTokenizer.cpp | 9 +- Engine/lib/assimp/code/FBXTokenizer.h | 3 +- Engine/lib/assimp/code/FBXUtil.cpp | 5 +- Engine/lib/assimp/code/FBXUtil.h | 3 +- Engine/lib/assimp/code/FIReader.cpp | 13 +- Engine/lib/assimp/code/FIReader.hpp | 5 +- Engine/lib/assimp/code/FileLogStream.h | 3 +- Engine/lib/assimp/code/FileSystemFilter.h | 181 +- Engine/lib/assimp/code/FindDegenerates.cpp | 86 +- Engine/lib/assimp/code/FindDegenerates.h | 6 +- .../lib/assimp/code/FindInstancesProcess.cpp | 13 +- Engine/lib/assimp/code/FindInstancesProcess.h | 17 +- .../assimp/code/FindInvalidDataProcess.cpp | 141 +- .../lib/assimp/code/FindInvalidDataProcess.h | 23 +- Engine/lib/assimp/code/FixNormalsStep.cpp | 43 +- Engine/lib/assimp/code/FixNormalsStep.h | 3 +- .../lib/assimp/code/GenFaceNormalsProcess.cpp | 30 +- .../lib/assimp/code/GenFaceNormalsProcess.h | 6 +- .../assimp/code/GenVertexNormalsProcess.cpp | 43 +- .../lib/assimp/code/GenVertexNormalsProcess.h | 4 +- Engine/lib/assimp/code/HMPFileData.h | 7 +- Engine/lib/assimp/code/HMPLoader.cpp | 9 +- Engine/lib/assimp/code/HMPLoader.h | 5 +- Engine/lib/assimp/code/HalfLifeFileData.h | 7 +- Engine/lib/assimp/code/IFCBoolean.cpp | 831 -- Engine/lib/assimp/code/IFCCurve.cpp | 617 -- Engine/lib/assimp/code/IFCGeometry.cpp | 885 -- Engine/lib/assimp/code/IFCLoader.cpp | 982 --- Engine/lib/assimp/code/IFCLoader.h | 133 - Engine/lib/assimp/code/IFCMaterial.cpp | 205 - Engine/lib/assimp/code/IFCOpenings.cpp | 1699 ---- Engine/lib/assimp/code/IFCProfile.cpp | 190 - Engine/lib/assimp/code/IFCReaderGen.h | 4368 ---------- Engine/lib/assimp/code/IFCReaderGen1.cpp | 3168 ------- Engine/lib/assimp/code/IFCReaderGen2.cpp | 1917 ----- Engine/lib/assimp/code/IFCUtil.cpp | 707 -- Engine/lib/assimp/code/IFCUtil.h | 429 - Engine/lib/assimp/code/IFF.h | 2 +- Engine/lib/assimp/code/Importer.cpp | 198 +- Engine/lib/assimp/code/Importer.h | 33 +- Engine/lib/assimp/code/ImporterRegistry.cpp | 13 +- .../lib/assimp/code/ImproveCacheLocality.cpp | 40 +- Engine/lib/assimp/code/ImproveCacheLocality.h | 3 +- .../lib/assimp/code/JoinVerticesProcess.cpp | 332 +- Engine/lib/assimp/code/JoinVerticesProcess.h | 3 +- Engine/lib/assimp/code/LWOAnimation.cpp | 3 +- Engine/lib/assimp/code/LWOAnimation.h | 42 +- Engine/lib/assimp/code/LWOBLoader.cpp | 39 +- Engine/lib/assimp/code/LWOFileData.h | 17 +- Engine/lib/assimp/code/LWOLoader.cpp | 102 +- Engine/lib/assimp/code/LWOLoader.h | 7 +- Engine/lib/assimp/code/LWOMaterial.cpp | 51 +- Engine/lib/assimp/code/LWSLoader.cpp | 57 +- Engine/lib/assimp/code/LWSLoader.h | 5 +- .../assimp/code/LimitBoneWeightsProcess.cpp | 21 +- .../lib/assimp/code/LimitBoneWeightsProcess.h | 9 +- Engine/lib/assimp/code/MD2FileData.h | 3 +- Engine/lib/assimp/code/MD2Loader.cpp | 25 +- Engine/lib/assimp/code/MD2Loader.h | 7 +- Engine/lib/assimp/code/MD2NormalTable.h | 3 +- Engine/lib/assimp/code/MD3FileData.h | 5 +- Engine/lib/assimp/code/MD3Loader.cpp | 66 +- Engine/lib/assimp/code/MD3Loader.h | 13 +- Engine/lib/assimp/code/MD4FileData.h | 6 +- Engine/lib/assimp/code/MD5Loader.cpp | 28 +- Engine/lib/assimp/code/MD5Loader.h | 7 +- Engine/lib/assimp/code/MD5Parser.cpp | 29 +- Engine/lib/assimp/code/MD5Parser.h | 19 +- Engine/lib/assimp/code/MDCFileData.h | 67 +- Engine/lib/assimp/code/MDCLoader.cpp | 38 +- Engine/lib/assimp/code/MDCLoader.h | 7 +- Engine/lib/assimp/code/MDLDefaultColorMap.h | 3 +- Engine/lib/assimp/code/MDLFileData.h | 48 +- Engine/lib/assimp/code/MDLLoader.cpp | 119 +- Engine/lib/assimp/code/MDLLoader.h | 5 +- Engine/lib/assimp/code/MDLMaterialLoader.cpp | 46 +- Engine/lib/assimp/code/MMDCpp14.h | 3 +- Engine/lib/assimp/code/MMDImporter.cpp | 38 +- Engine/lib/assimp/code/MMDImporter.h | 2 +- Engine/lib/assimp/code/MMDPmdParser.h | 3 +- Engine/lib/assimp/code/MMDPmxParser.cpp | 89 +- Engine/lib/assimp/code/MMDPmxParser.h | 4 +- Engine/lib/assimp/code/MMDVmdParser.h | 3 +- Engine/lib/assimp/code/MS3DLoader.cpp | 24 +- Engine/lib/assimp/code/MS3DLoader.h | 7 +- Engine/lib/assimp/code/MakeVerboseFormat.cpp | 14 +- Engine/lib/assimp/code/MakeVerboseFormat.h | 3 +- Engine/lib/assimp/code/MaterialSystem.cpp | 96 +- Engine/lib/assimp/code/MaterialSystem.h | 3 +- Engine/lib/assimp/code/NDOLoader.cpp | 13 +- Engine/lib/assimp/code/NDOLoader.h | 2 +- Engine/lib/assimp/code/NFFLoader.cpp | 58 +- Engine/lib/assimp/code/NFFLoader.h | 5 +- Engine/lib/assimp/code/OFFLoader.cpp | 253 +- Engine/lib/assimp/code/OFFLoader.h | 5 +- Engine/lib/assimp/code/ObjExporter.cpp | 132 +- Engine/lib/assimp/code/ObjExporter.h | 102 +- Engine/lib/assimp/code/ObjFileData.h | 3 +- Engine/lib/assimp/code/ObjFileImporter.cpp | 270 +- Engine/lib/assimp/code/ObjFileImporter.h | 5 +- Engine/lib/assimp/code/ObjFileMtlImporter.cpp | 27 +- Engine/lib/assimp/code/ObjFileMtlImporter.h | 3 +- Engine/lib/assimp/code/ObjFileParser.cpp | 60 +- Engine/lib/assimp/code/ObjFileParser.h | 8 +- Engine/lib/assimp/code/ObjTools.h | 7 +- .../lib/assimp/code/OgreBinarySerializer.cpp | 49 +- Engine/lib/assimp/code/OgreBinarySerializer.h | 5 +- Engine/lib/assimp/code/OgreImporter.cpp | 3 +- Engine/lib/assimp/code/OgreImporter.h | 5 +- Engine/lib/assimp/code/OgreMaterial.cpp | 44 +- Engine/lib/assimp/code/OgreParsingUtils.h | 60 +- Engine/lib/assimp/code/OgreStructs.cpp | 11 +- Engine/lib/assimp/code/OgreStructs.h | 5 +- Engine/lib/assimp/code/OgreXmlSerializer.cpp | 233 +- Engine/lib/assimp/code/OgreXmlSerializer.h | 9 +- Engine/lib/assimp/code/OpenGEXExporter.cpp | 3 +- Engine/lib/assimp/code/OpenGEXExporter.h | 3 +- Engine/lib/assimp/code/OpenGEXImporter.cpp | 80 +- Engine/lib/assimp/code/OpenGEXImporter.h | 15 +- Engine/lib/assimp/code/OpenGEXStructs.h | 3 +- Engine/lib/assimp/code/OptimizeGraph.cpp | 69 +- Engine/lib/assimp/code/OptimizeGraph.h | 5 +- Engine/lib/assimp/code/OptimizeMeshes.cpp | 15 +- Engine/lib/assimp/code/OptimizeMeshes.h | 21 +- Engine/lib/assimp/code/PlyExporter.cpp | 44 +- Engine/lib/assimp/code/PlyExporter.h | 3 +- Engine/lib/assimp/code/PlyLoader.cpp | 730 +- Engine/lib/assimp/code/PlyLoader.h | 6 +- Engine/lib/assimp/code/PlyParser.cpp | 113 +- Engine/lib/assimp/code/PlyParser.h | 82 +- Engine/lib/assimp/code/PolyTools.h | 3 +- Engine/lib/assimp/code/PostStepRegistry.cpp | 33 +- .../lib/assimp/code/PretransformVertices.cpp | 60 +- Engine/lib/assimp/code/PretransformVertices.h | 12 +- Engine/lib/assimp/code/ProcessHelper.cpp | 5 +- Engine/lib/assimp/code/ProcessHelper.h | 11 +- Engine/lib/assimp/code/Q3BSPFileData.h | 20 +- Engine/lib/assimp/code/Q3BSPFileImporter.cpp | 397 +- Engine/lib/assimp/code/Q3BSPFileImporter.h | 13 +- Engine/lib/assimp/code/Q3BSPFileParser.cpp | 60 +- Engine/lib/assimp/code/Q3BSPFileParser.h | 5 +- Engine/lib/assimp/code/Q3BSPZipArchive.cpp | 25 +- Engine/lib/assimp/code/Q3BSPZipArchive.h | 5 +- Engine/lib/assimp/code/Q3DLoader.cpp | 37 +- Engine/lib/assimp/code/Q3DLoader.h | 5 +- Engine/lib/assimp/code/RawLoader.cpp | 14 +- Engine/lib/assimp/code/RawLoader.h | 5 +- Engine/lib/assimp/code/RemoveComments.cpp | 11 +- .../assimp/code/RemoveRedundantMaterials.cpp | 17 +- .../assimp/code/RemoveRedundantMaterials.h | 4 +- Engine/lib/assimp/code/RemoveVCProcess.cpp | 16 +- Engine/lib/assimp/code/RemoveVCProcess.h | 3 +- Engine/lib/assimp/code/SGSpatialSort.cpp | 5 +- Engine/lib/assimp/code/SIBImporter.cpp | 15 +- Engine/lib/assimp/code/SIBImporter.h | 5 +- Engine/lib/assimp/code/SMDLoader.cpp | 796 +- Engine/lib/assimp/code/SMDLoader.h | 62 +- Engine/lib/assimp/code/STEPFile.h | 1019 --- Engine/lib/assimp/code/STEPFileEncoding.cpp | 427 - Engine/lib/assimp/code/STEPFileReader.cpp | 544 -- Engine/lib/assimp/code/STLExporter.cpp | 79 +- Engine/lib/assimp/code/STLExporter.h | 12 +- Engine/lib/assimp/code/STLLoader.cpp | 126 +- Engine/lib/assimp/code/STLLoader.h | 5 +- Engine/lib/assimp/code/ScaleProcess.cpp | 14 +- Engine/lib/assimp/code/ScaleProcess.h | 3 +- Engine/lib/assimp/code/SceneCombiner.cpp | 120 +- Engine/lib/assimp/code/ScenePreprocessor.cpp | 17 +- Engine/lib/assimp/code/ScenePreprocessor.h | 3 +- Engine/lib/assimp/code/ScenePrivate.h | 42 +- .../lib/assimp/code/SkeletonMeshBuilder.cpp | 5 +- Engine/lib/assimp/code/SortByPTypeProcess.cpp | 54 +- Engine/lib/assimp/code/SortByPTypeProcess.h | 3 +- Engine/lib/assimp/code/SpatialSort.cpp | 9 +- .../assimp/code/SplitByBoneCountProcess.cpp | 13 +- .../lib/assimp/code/SplitByBoneCountProcess.h | 3 +- Engine/lib/assimp/code/SplitLargeMeshes.cpp | 331 +- Engine/lib/assimp/code/SplitLargeMeshes.h | 3 +- Engine/lib/assimp/code/StandardShapes.cpp | 9 +- Engine/lib/assimp/code/StdOStreamLogStream.h | 3 +- Engine/lib/assimp/code/StepExporter.cpp | 372 - Engine/lib/assimp/code/Subdivision.cpp | 26 +- Engine/lib/assimp/code/TargetAnimation.cpp | 3 +- Engine/lib/assimp/code/TargetAnimation.h | 3 +- Engine/lib/assimp/code/TerragenLoader.cpp | 7 +- Engine/lib/assimp/code/TerragenLoader.h | 5 +- Engine/lib/assimp/code/TextureTransform.cpp | 41 +- Engine/lib/assimp/code/TextureTransform.h | 38 +- Engine/lib/assimp/code/TriangulateProcess.cpp | 47 +- Engine/lib/assimp/code/TriangulateProcess.h | 3 +- Engine/lib/assimp/code/UnrealLoader.cpp | 19 +- Engine/lib/assimp/code/UnrealLoader.h | 5 +- .../lib/assimp/code/ValidateDataStructure.cpp | 53 +- .../lib/assimp/code/ValidateDataStructure.h | 3 +- Engine/lib/assimp/code/Version.cpp | 35 +- .../assimp/code/VertexTriangleAdjacency.cpp | 36 +- .../lib/assimp/code/VertexTriangleAdjacency.h | 32 +- Engine/lib/assimp/code/Win32DebugLogStream.h | 3 +- Engine/lib/assimp/code/X3DExporter.cpp | 4 +- Engine/lib/assimp/code/X3DExporter.hpp | 2 +- Engine/lib/assimp/code/X3DImporter.cpp | 7 +- Engine/lib/assimp/code/X3DImporter.hpp | 9 +- .../assimp/code/X3DImporter_Geometry2D.cpp | 3 +- .../assimp/code/X3DImporter_Geometry3D.cpp | 13 +- Engine/lib/assimp/code/X3DImporter_Group.cpp | 3 +- Engine/lib/assimp/code/X3DImporter_Light.cpp | 5 +- Engine/lib/assimp/code/X3DImporter_Macro.hpp | 7 +- .../lib/assimp/code/X3DImporter_Metadata.cpp | 5 +- .../assimp/code/X3DImporter_Networking.cpp | 3 +- Engine/lib/assimp/code/X3DImporter_Node.hpp | 3 +- .../assimp/code/X3DImporter_Postprocess.cpp | 7 +- .../lib/assimp/code/X3DImporter_Rendering.cpp | 3 +- Engine/lib/assimp/code/X3DImporter_Shape.cpp | 3 +- .../lib/assimp/code/X3DImporter_Texturing.cpp | 3 +- Engine/lib/assimp/code/X3DVocabulary.cpp | 3 +- Engine/lib/assimp/code/XFileExporter.cpp | 13 +- Engine/lib/assimp/code/XFileExporter.h | 3 +- Engine/lib/assimp/code/XFileHelper.h | 121 +- Engine/lib/assimp/code/XFileImporter.cpp | 355 +- Engine/lib/assimp/code/XFileImporter.h | 5 +- Engine/lib/assimp/code/XFileParser.cpp | 354 +- Engine/lib/assimp/code/XFileParser.h | 62 +- Engine/lib/assimp/code/XGLLoader.cpp | 58 +- Engine/lib/assimp/code/XGLLoader.h | 9 +- Engine/lib/assimp/code/glTF2Asset.h | 135 +- Engine/lib/assimp/code/glTF2Asset.inl | 262 +- Engine/lib/assimp/code/glTF2AssetWriter.h | 5 +- Engine/lib/assimp/code/glTF2AssetWriter.inl | 186 +- Engine/lib/assimp/code/glTF2Exporter.cpp | 339 +- Engine/lib/assimp/code/glTF2Exporter.h | 31 +- Engine/lib/assimp/code/glTF2Importer.cpp | 713 +- Engine/lib/assimp/code/glTF2Importer.h | 7 +- Engine/lib/assimp/code/glTFAsset.h | 17 +- Engine/lib/assimp/code/glTFAsset.inl | 68 +- Engine/lib/assimp/code/glTFAssetWriter.h | 3 +- Engine/lib/assimp/code/glTFAssetWriter.inl | 3 +- Engine/lib/assimp/code/glTFExporter.cpp | 21 +- Engine/lib/assimp/code/glTFExporter.h | 7 +- Engine/lib/assimp/code/glTFImporter.cpp | 107 +- Engine/lib/assimp/code/glTFImporter.h | 5 +- Engine/lib/assimp/{ => code}/revision.h | 0 Engine/lib/assimp/code/scene.cpp | 3 +- Engine/lib/assimp/code/simd.cpp | 79 + Engine/lib/assimp/code/simd.h | 53 + .../lib/assimp/contrib/Open3DGC/o3dgcTimer.h | 4 +- Engine/lib/assimp/contrib/clipper/clipper.cpp | 10 +- .../assimp/contrib/irrXML/CXMLReaderImpl.h | 11 +- Engine/lib/assimp/contrib/irrXML/irrArray.h | 3 +- Engine/lib/assimp/contrib/irrXML/irrXML.cpp | 2 +- .../openddlparser/code/OpenDDLParser.cpp | 6 + .../openddlparser/OpenDDLParserUtils.h | 24 +- .../lib/assimp/contrib/stb_image/stb_image.h | 7462 +++++++++++++++++ Engine/lib/assimp/contrib/unzip/unzip.c | 4 + Engine/lib/assimp/contrib/zip/src/miniz.h | 2 +- .../lib/assimp/include/assimp/BaseImporter.h | 361 + Engine/lib/assimp/include/assimp/Bitmap.h | 125 + .../lib/assimp/include/assimp/BlobIOSystem.h | 338 + .../lib/assimp/include/assimp/ByteSwapper.h | 287 + .../include/assimp/Compiler/pushpack1.h | 2 +- .../assimp/CreateAnimMesh.h} | 32 +- .../assimp/include/assimp/DefaultIOStream.h | 27 +- .../assimp/include/assimp/DefaultIOSystem.h | 12 +- .../assimp/include/assimp/DefaultLogger.hpp | 7 +- .../lib/assimp/include/assimp/Exceptional.h | 125 + Engine/lib/assimp/include/assimp/Exporter.hpp | 42 +- .../assimp/include/assimp/GenericProperty.h | 133 + Engine/lib/assimp/include/assimp/Hash.h | 118 + Engine/lib/assimp/include/assimp/IOStream.hpp | 14 +- .../assimp/include/assimp/IOStreamBuffer.h | 355 + Engine/lib/assimp/include/assimp/IOSystem.hpp | 10 +- Engine/lib/assimp/include/assimp/Importer.hpp | 12 +- .../lib/assimp/include/assimp/LineSplitter.h | 285 + Engine/lib/assimp/include/assimp/LogAux.h | 131 + .../lib/assimp/include/assimp/LogStream.hpp | 9 +- Engine/lib/assimp/include/assimp/Logger.hpp | 113 +- Engine/lib/assimp/include/assimp/Macros.h | 49 + .../lib/assimp/include/assimp/MathFunctions.h | 77 + .../assimp/include/assimp/MemoryIOWrapper.h | 244 + .../lib/assimp/include/assimp/NullLogger.hpp | 3 +- .../lib/assimp/include/assimp/ParsingUtils.h | 260 + Engine/lib/assimp/include/assimp/Profiler.h | 99 + .../assimp/include/assimp/ProgressHandler.hpp | 27 +- .../assimp/include/assimp/RemoveComments.h | 91 + .../lib/assimp/include/assimp/SGSpatialSort.h | 150 + .../lib/assimp/include/assimp/SceneCombiner.h | 3 +- .../include/assimp/SkeletonMeshBuilder.h | 125 + .../assimp/include/assimp/SmoothingGroups.h | 108 + .../assimp/include/assimp/SmoothingGroups.inl | 138 + .../lib/assimp/include/assimp/SpatialSort.h | 174 + .../assimp/include/assimp/StandardShapes.h | 200 + .../lib/assimp/include/assimp/StreamReader.h | 343 + .../lib/assimp/include/assimp/StreamWriter.h | 303 + .../assimp/include/assimp/StringComparison.h | 233 + .../lib/assimp/include/assimp/StringUtils.h | 143 + .../lib/assimp/include/assimp/Subdivision.h | 131 + .../lib/assimp/include/assimp/TinyFormatter.h | 166 + Engine/lib/assimp/include/assimp/Vertex.h | 348 + .../assimp/XMLTools.h} | 56 +- Engine/lib/assimp/include/assimp/ai_assert.h | 10 +- Engine/lib/assimp/include/assimp/anim.h | 79 +- Engine/lib/assimp/include/assimp/camera.h | 5 +- Engine/lib/assimp/include/assimp/cexport.h | 6 +- Engine/lib/assimp/include/assimp/cfileio.h | 3 +- Engine/lib/assimp/include/assimp/cimport.h | 3 +- Engine/lib/assimp/include/assimp/color4.h | 8 +- Engine/lib/assimp/include/assimp/color4.inl | 3 +- Engine/lib/assimp/include/assimp/config.h | 37 +- Engine/lib/assimp/include/assimp/config.h.in | 992 +++ Engine/lib/assimp/include/assimp/defs.h | 117 +- Engine/lib/assimp/include/assimp/fast_atof.h | 373 + .../lib/assimp/include/assimp/importerdesc.h | 3 +- .../lib/assimp/include/assimp/irrXMLWrapper.h | 144 + Engine/lib/assimp/include/assimp/light.h | 5 +- Engine/lib/assimp/include/assimp/material.h | 32 +- Engine/lib/assimp/include/assimp/material.inl | 7 +- Engine/lib/assimp/include/assimp/matrix3x3.h | 5 +- .../lib/assimp/include/assimp/matrix3x3.inl | 13 +- Engine/lib/assimp/include/assimp/matrix4x4.h | 5 +- .../lib/assimp/include/assimp/matrix4x4.inl | 71 +- Engine/lib/assimp/include/assimp/mesh.h | 297 +- Engine/lib/assimp/include/assimp/metadata.h | 104 +- .../lib/assimp/include/assimp/pbrmaterial.h | 77 + .../port/AndroidJNI/AndroidJNIIOSystem.h | 92 + .../lib/assimp/include/assimp/postprocess.h | 42 +- Engine/lib/assimp/include/assimp/qnan.h | 165 + Engine/lib/assimp/include/assimp/quaternion.h | 5 +- .../lib/assimp/include/assimp/quaternion.inl | 3 +- Engine/lib/assimp/include/assimp/scene.h | 34 +- Engine/lib/assimp/include/assimp/texture.h | 36 +- Engine/lib/assimp/include/assimp/types.h | 41 +- Engine/lib/assimp/include/assimp/vector2.h | 19 +- Engine/lib/assimp/include/assimp/vector2.inl | 67 +- Engine/lib/assimp/include/assimp/vector3.h | 7 +- Engine/lib/assimp/include/assimp/vector3.inl | 175 +- Engine/lib/assimp/include/assimp/version.h | 9 +- Tools/CMake/libraries/assimp.cmake | 2 + 461 files changed, 34662 insertions(+), 30165 deletions(-) create mode 100644 Engine/lib/assimp/code/BlenderCustomData.cpp create mode 100644 Engine/lib/assimp/code/BlenderCustomData.h create mode 100644 Engine/lib/assimp/code/DropFaceNormalsProcess.cpp rename Engine/lib/assimp/code/{StepExporter.h => DropFaceNormalsProcess.h} (50%) create mode 100644 Engine/lib/assimp/code/EmbedTexturesProcess.cpp create mode 100644 Engine/lib/assimp/code/EmbedTexturesProcess.h create mode 100644 Engine/lib/assimp/code/FBXCommon.h create mode 100644 Engine/lib/assimp/code/FBXExportNode.cpp create mode 100644 Engine/lib/assimp/code/FBXExportNode.h create mode 100644 Engine/lib/assimp/code/FBXExportProperty.cpp create mode 100644 Engine/lib/assimp/code/FBXExportProperty.h create mode 100644 Engine/lib/assimp/code/FBXExporter.cpp create mode 100644 Engine/lib/assimp/code/FBXExporter.h delete mode 100644 Engine/lib/assimp/code/IFCBoolean.cpp delete mode 100644 Engine/lib/assimp/code/IFCCurve.cpp delete mode 100644 Engine/lib/assimp/code/IFCGeometry.cpp delete mode 100644 Engine/lib/assimp/code/IFCLoader.cpp delete mode 100644 Engine/lib/assimp/code/IFCLoader.h delete mode 100644 Engine/lib/assimp/code/IFCMaterial.cpp delete mode 100644 Engine/lib/assimp/code/IFCOpenings.cpp delete mode 100644 Engine/lib/assimp/code/IFCProfile.cpp delete mode 100644 Engine/lib/assimp/code/IFCReaderGen.h delete mode 100644 Engine/lib/assimp/code/IFCReaderGen1.cpp delete mode 100644 Engine/lib/assimp/code/IFCReaderGen2.cpp delete mode 100644 Engine/lib/assimp/code/IFCUtil.cpp delete mode 100644 Engine/lib/assimp/code/IFCUtil.h delete mode 100644 Engine/lib/assimp/code/STEPFile.h delete mode 100644 Engine/lib/assimp/code/STEPFileEncoding.cpp delete mode 100644 Engine/lib/assimp/code/STEPFileReader.cpp delete mode 100644 Engine/lib/assimp/code/StepExporter.cpp rename Engine/lib/assimp/{ => code}/revision.h (100%) create mode 100644 Engine/lib/assimp/code/simd.cpp create mode 100644 Engine/lib/assimp/code/simd.h create mode 100644 Engine/lib/assimp/contrib/stb_image/stb_image.h create mode 100644 Engine/lib/assimp/include/assimp/BaseImporter.h create mode 100644 Engine/lib/assimp/include/assimp/Bitmap.h create mode 100644 Engine/lib/assimp/include/assimp/BlobIOSystem.h create mode 100644 Engine/lib/assimp/include/assimp/ByteSwapper.h rename Engine/lib/assimp/{code/STEPFileEncoding.h => include/assimp/CreateAnimMesh.h} (72%) create mode 100644 Engine/lib/assimp/include/assimp/Exceptional.h create mode 100644 Engine/lib/assimp/include/assimp/GenericProperty.h create mode 100644 Engine/lib/assimp/include/assimp/Hash.h create mode 100644 Engine/lib/assimp/include/assimp/IOStreamBuffer.h create mode 100644 Engine/lib/assimp/include/assimp/LineSplitter.h create mode 100644 Engine/lib/assimp/include/assimp/LogAux.h create mode 100644 Engine/lib/assimp/include/assimp/Macros.h create mode 100644 Engine/lib/assimp/include/assimp/MathFunctions.h create mode 100644 Engine/lib/assimp/include/assimp/MemoryIOWrapper.h create mode 100644 Engine/lib/assimp/include/assimp/ParsingUtils.h create mode 100644 Engine/lib/assimp/include/assimp/Profiler.h create mode 100644 Engine/lib/assimp/include/assimp/RemoveComments.h create mode 100644 Engine/lib/assimp/include/assimp/SGSpatialSort.h create mode 100644 Engine/lib/assimp/include/assimp/SkeletonMeshBuilder.h create mode 100644 Engine/lib/assimp/include/assimp/SmoothingGroups.h create mode 100644 Engine/lib/assimp/include/assimp/SmoothingGroups.inl create mode 100644 Engine/lib/assimp/include/assimp/SpatialSort.h create mode 100644 Engine/lib/assimp/include/assimp/StandardShapes.h create mode 100644 Engine/lib/assimp/include/assimp/StreamReader.h create mode 100644 Engine/lib/assimp/include/assimp/StreamWriter.h create mode 100644 Engine/lib/assimp/include/assimp/StringComparison.h create mode 100644 Engine/lib/assimp/include/assimp/StringUtils.h create mode 100644 Engine/lib/assimp/include/assimp/Subdivision.h create mode 100644 Engine/lib/assimp/include/assimp/TinyFormatter.h create mode 100644 Engine/lib/assimp/include/assimp/Vertex.h rename Engine/lib/assimp/{code/STEPFileReader.h => include/assimp/XMLTools.h} (58%) create mode 100644 Engine/lib/assimp/include/assimp/config.h.in create mode 100644 Engine/lib/assimp/include/assimp/fast_atof.h create mode 100644 Engine/lib/assimp/include/assimp/irrXMLWrapper.h create mode 100644 Engine/lib/assimp/include/assimp/pbrmaterial.h create mode 100644 Engine/lib/assimp/include/assimp/port/AndroidJNI/AndroidJNIIOSystem.h create mode 100644 Engine/lib/assimp/include/assimp/qnan.h diff --git a/Engine/lib/assimp/code/3DSConverter.cpp b/Engine/lib/assimp/code/3DSConverter.cpp index 820c28f90..e6865a809 100644 --- a/Engine/lib/assimp/code/3DSConverter.cpp +++ b/Engine/lib/assimp/code/3DSConverter.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -50,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "TargetAnimation.h" #include #include -#include "StringComparison.h" +#include #include #include @@ -71,7 +72,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() unsigned int idx( NotSet ); for (unsigned int i = 0; i < mScene->mMaterials.size();++i) { - std::string s = mScene->mMaterials[i].mName; + std::string &s = mScene->mMaterials[i].mName; for ( std::string::iterator it = s.begin(); it != s.end(); ++it ) { *it = static_cast< char >( ::tolower( *it ) ); } @@ -119,7 +120,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() else if ( (*a) >= mScene->mMaterials.size()) { (*a) = idx; - DefaultLogger::get()->warn("Material index overflow in 3DS file. Using default material"); + ASSIMP_LOG_WARN("Material index overflow in 3DS file. Using default material"); ++cnt; } } @@ -127,12 +128,11 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() if (cnt && idx == mScene->mMaterials.size()) { // We need to create our own default material - D3DS::Material sMat; + D3DS::Material sMat("%%%DEFAULT"); sMat.mDiffuse = aiColor3D(0.3f,0.3f,0.3f); - sMat.mName = "%%%DEFAULT"; mScene->mMaterials.push_back(sMat); - DefaultLogger::get()->info("3DS: Generating default material"); + ASSIMP_LOG_INFO("3DS: Generating default material"); } } @@ -147,12 +147,12 @@ void Discreet3DSImporter::CheckIndices(D3DS::Mesh& sMesh) { if ((*i).mIndices[a] >= sMesh.mPositions.size()) { - DefaultLogger::get()->warn("3DS: Vertex index overflow)"); + ASSIMP_LOG_WARN("3DS: Vertex index overflow)"); (*i).mIndices[a] = (uint32_t)sMesh.mPositions.size()-1; } if ( !sMesh.mTexCoords.empty() && (*i).mIndices[a] >= sMesh.mTexCoords.size()) { - DefaultLogger::get()->warn("3DS: Texture coordinate index overflow)"); + ASSIMP_LOG_WARN("3DS: Texture coordinate index overflow)"); (*i).mIndices[a] = (uint32_t)sMesh.mTexCoords.size()-1; } } @@ -204,8 +204,9 @@ void CopyTexture(aiMaterial& mat, D3DS::Texture& texture, aiTextureType type) mat.AddProperty( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0)); // Setup the texture mapping mode - mat.AddProperty((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_U(type,0)); - mat.AddProperty((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_V(type,0)); + int mapMode = static_cast(texture.mMapMode); + mat.AddProperty(&mapMode,1,AI_MATKEY_MAPPINGMODE_U(type,0)); + mat.AddProperty(&mapMode,1,AI_MATKEY_MAPPINGMODE_V(type,0)); // Mirroring - double the scaling values // FIXME: this is not really correct ... @@ -313,7 +314,8 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material& oldMat, case D3DS::Discreet3DS::Blinn : eShading = aiShadingMode_Blinn; break; } - mat.AddProperty( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL); + int eShading_ = static_cast(eShading); + mat.AddProperty(&eShading_, 1, AI_MATKEY_SHADING_MODEL); // DIFFUSE texture if( oldMat.sTexDiffuse.mMapName.length() > 0) @@ -497,7 +499,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut, pvCurrent->x *= -1.f; t2->x *= -1.f; } - DefaultLogger::get()->info("3DS: Flipping mesh X-Axis"); + ASSIMP_LOG_INFO("3DS: Flipping mesh X-Axis"); } // Handle pivot point @@ -573,11 +575,11 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut, pcIn->aTargetPositionKeys.size() > 1) { aiAnimation* anim = pcSOut->mAnimations[0]; - ai_assert(NULL != anim); + ai_assert(nullptr != anim); if (pcIn->aCameraRollKeys.size() > 1) { - DefaultLogger::get()->debug("3DS: Converting camera roll track ..."); + ASSIMP_LOG_DEBUG("3DS: Converting camera roll track ..."); // Camera roll keys - in fact they're just rotations // around the camera's z axis. The angles are given @@ -597,7 +599,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut, #if 0 if (pcIn->aTargetPositionKeys.size() > 1) { - DefaultLogger::get()->debug("3DS: Converting target track ..."); + ASSIMP_LOG_DEBUG("3DS: Converting target track ..."); // Camera or spot light - need to convert the separate // target position channel to our representation @@ -743,7 +745,7 @@ void Discreet3DSImporter::GenerateNodeGraph(aiScene* pcOut) // | | | | | // MESH_0 MESH_1 MESH_2 ... MESH_N CAMERA_0 .... // - DefaultLogger::get()->warn("No hierarchy information has been found in the file. "); + ASSIMP_LOG_WARN("No hierarchy information has been found in the file. "); pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes + static_cast(mScene->mCameras.size() + mScene->mLights.size()); diff --git a/Engine/lib/assimp/code/3DSExporter.cpp b/Engine/lib/assimp/code/3DSExporter.cpp index 2f561fcd6..2501d4049 100644 --- a/Engine/lib/assimp/code/3DSExporter.cpp +++ b/Engine/lib/assimp/code/3DSExporter.cpp @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -47,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "3DSHelper.h" #include #include "SplitLargeMeshes.h" -#include "StringComparison.h" +#include #include #include #include @@ -183,7 +184,7 @@ void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScen } // end of namespace Assimp // ------------------------------------------------------------------------------------------------ -Discreet3DSExporter:: Discreet3DSExporter(std::shared_ptr outfile, const aiScene* scene) +Discreet3DSExporter:: Discreet3DSExporter(std::shared_ptr &outfile, const aiScene* scene) : scene(scene) , writer(outfile) { @@ -380,7 +381,7 @@ void Discreet3DSExporter::WriteTexture(const aiMaterial& mat, aiTextureType type // TODO: handle embedded textures properly if (path.data[0] == '*') { - DefaultLogger::get()->error("Ignoring embedded texture for export: " + std::string(path.C_Str())); + ASSIMP_LOG_ERROR("Ignoring embedded texture for export: " + std::string(path.C_Str())); return; } diff --git a/Engine/lib/assimp/code/3DSExporter.h b/Engine/lib/assimp/code/3DSExporter.h index fc02e2390..035b562cf 100644 --- a/Engine/lib/assimp/code/3DSExporter.h +++ b/Engine/lib/assimp/code/3DSExporter.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -48,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "StreamWriter.h" +#include #include struct aiScene; @@ -66,7 +67,7 @@ namespace Assimp // ------------------------------------------------------------------------------------------------ class Discreet3DSExporter { public: - Discreet3DSExporter(std::shared_ptr outfile, const aiScene* pScene); + Discreet3DSExporter(std::shared_ptr &outfile, const aiScene* pScene); ~Discreet3DSExporter(); private: diff --git a/Engine/lib/assimp/code/3DSHelper.h b/Engine/lib/assimp/code/3DSHelper.h index 9e701c3dd..8eb4cd97c 100644 --- a/Engine/lib/assimp/code/3DSHelper.h +++ b/Engine/lib/assimp/code/3DSHelper.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -44,10 +45,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_3DSFILEHELPER_H_INC #define AI_3DSFILEHELPER_H_INC -#include "SpatialSort.h" -#include "SmoothingGroups.h" -#include "StringUtils.h" -#include "qnan.h" +#include +#include +#include +#include #include #include #include @@ -57,7 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { namespace D3DS { -#include "./../include/assimp/Compiler/pushpack1.h" +#include // --------------------------------------------------------------------------- /** Discreet3DS class: Helper class for loading 3ds files. Defines chunks @@ -65,7 +66,7 @@ namespace D3DS { */ class Discreet3DS { private: - Discreet3DS() { + Discreet3DS() AI_NO_EXCEPT { // empty } @@ -327,19 +328,17 @@ struct Face : public FaceWithSmoothingGroup // --------------------------------------------------------------------------- /** Helper structure representing a texture */ -struct Texture -{ +struct Texture { //! Default constructor - Texture() - : mOffsetU (0.0) - , mOffsetV (0.0) - , mScaleU (1.0) - , mScaleV (1.0) - , mRotation (0.0) - , mMapMode (aiTextureMapMode_Wrap) - , bPrivate() - , iUVSrc (0) - { + Texture() AI_NO_EXCEPT + : mOffsetU (0.0) + , mOffsetV (0.0) + , mScaleU (1.0) + , mScaleV (1.0) + , mRotation (0.0) + , mMapMode (aiTextureMapMode_Wrap) + , bPrivate() + , iUVSrc (0) { mTextureBlend = get_qnan(); } @@ -364,15 +363,20 @@ struct Texture int iUVSrc; }; -#include "./../include/assimp/Compiler/poppack1.h" +#include // --------------------------------------------------------------------------- /** Helper structure representing a 3ds material */ struct Material { - //! Default constructor. Builds a default name for the material - Material() - : mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black + //! Default constructor has been deleted + Material() = delete; + + + //! Constructor with explicit name + explicit Material(const std::string &name) + : mName(name) + , mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black , mSpecularExponent ( ai_real( 0.0 ) ) , mShininessStrength ( ai_real( 1.0 ) ) , mShading(Discreet3DS::Gouraud) @@ -380,13 +384,70 @@ struct Material , mBumpHeight ( ai_real( 1.0 ) ) , mTwoSided (false) { - static int iCnt = 0; - - char szTemp[128]; - ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; } + + Material(const Material &other) = default; + Material &operator=(const Material &other) = default; + + + //! Move constructor. This is explicitly written because MSVC doesn't support defaulting it + Material(Material &&other) AI_NO_EXCEPT + : mName(std::move(other.mName)) + , mDiffuse(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 &operator=(Material &&other) AI_NO_EXCEPT { + if (this == &other) { + return *this; + } + + 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); + + return *this; + } + + + virtual ~Material() {} + + //! Name of the material std::string mName; //! Diffuse color of the material @@ -432,17 +493,16 @@ struct Material /** Helper structure to represent a 3ds file mesh */ struct Mesh : public MeshWithSmoothingGroups { - //! Default constructor - Mesh() - { - static int iCnt = 0; + //! Default constructor has been deleted + Mesh() = delete; - // Generate a default name for the mesh - char szTemp[128]; - ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; + //! Constructor with explicit name + explicit Mesh(const std::string &name) + : mName(name) + { } + //! Name of the mesh std::string mName; @@ -488,25 +548,22 @@ struct aiFloatKey /** Helper structure to represent a 3ds file node */ struct Node { - Node(): - mParent(NULL) - , mInstanceNumber(0) - , mHierarchyPos (0) - , mHierarchyIndex (0) - , mInstanceCount (1) + Node() = delete; + + explicit Node(const std::string &name) + : mParent(NULL) + , mName(name) + , mInstanceNumber(0) + , mHierarchyPos (0) + , mHierarchyIndex (0) + , mInstanceCount (1) { - static int iCnt = 0; - - // Generate a default name for the node - char szTemp[128]; - ::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - aRotationKeys.reserve (20); aPositionKeys.reserve (20); aScalingKeys.reserve (20); } + ~Node() { for (unsigned int i = 0; i < mChildren.size();++i) diff --git a/Engine/lib/assimp/code/3DSLoader.cpp b/Engine/lib/assimp/code/3DSLoader.cpp index 704884a57..96b80c962 100644 --- a/Engine/lib/assimp/code/3DSLoader.cpp +++ b/Engine/lib/assimp/code/3DSLoader.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -51,12 +52,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // internal headers #include "3DSLoader.h" -#include "Macros.h" +#include #include #include #include #include -#include "StringComparison.h" +#include using namespace Assimp; @@ -70,7 +71,7 @@ static const aiImporterDesc desc = { 0, 0, 0, - "3ds prj" + "3ds prj" }; @@ -105,29 +106,31 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer Discreet3DSImporter::Discreet3DSImporter() - : stream(), - mLastNodeIndex(), - mCurrentNode(), - mRootNode(), - mScene(), - mMasterScale(), - bHasBG(), - bIsPrj() -{} +: stream() +, mLastNodeIndex() +, mCurrentNode() +, mRootNode() +, mScene() +, mMasterScale() +, bHasBG() +, bIsPrj() { + // empty +} // ------------------------------------------------------------------------------------------------ // Destructor, private as well -Discreet3DSImporter::~Discreet3DSImporter() -{} +Discreet3DSImporter::~Discreet3DSImporter() { + // empty +} // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const -{ +bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const { std::string extension = GetExtension(pFile); - if(extension == "3ds" || extension == "prj" ) { + if(extension == "3ds" || extension == "prj") { return true; } + if (!extension.length() || checkSig) { uint16_t token[3]; token[0] = 0x4d4d; @@ -158,19 +161,21 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { StreamReaderLE stream(pIOHandler->Open(pFile,"rb")); - this->stream = &stream; // We should have at least one chunk if (stream.GetRemainingSize() < 16) { throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile); } + this->stream = &stream; // Allocate our temporary 3DS representation - mScene = new D3DS::Scene(); + D3DS::Scene _scene; + mScene = &_scene; // Initialize members + D3DS::Node _rootNode("UNNAMED"); mLastNodeIndex = -1; - mCurrentNode = new D3DS::Node(); + mCurrentNode = &_rootNode; mRootNode = mCurrentNode; mRootNode->mHierarchyPos = -1; mRootNode->mHierarchyIndex = -1; @@ -190,7 +195,6 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile, // file. for (auto &mesh : mScene->mMeshes) { if (mesh.mFaces.size() > 0 && mesh.mPositions.size() == 0) { - delete mScene; throw DeadlyImportError("3DS file contains faces but no vertices: " + pFile); } CheckIndices(mesh); @@ -198,7 +202,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile, ComputeNormalsWithSmoothingsGroups(mesh); } - // Replace all occurrences of the default material with a + // Replace all occurences of the default material with a // valid material. Generate it if no material containing // DEFAULT in its name has been found in the file ReplaceDefaultMaterial(); @@ -209,16 +213,14 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile, ConvertScene(pScene); // Generate the node graph for the scene. This is a little bit - // tricky since we'll need to split some meshes into submeshes + // tricky since we'll need to split some meshes into sub-meshes GenerateNodeGraph(pScene); // Now apply the master scaling factor to the scene ApplyMasterScale(pScene); - // Delete our internal scene representation and the root - // node, so the whole hierarchy will follow - delete mRootNode; - delete mScene; + // Our internal scene representation and the root + // node will be automatically deleted, so the whole hierarchy will follow AI_DEBUG_INVALIDATE_PTR(mRootNode); AI_DEBUG_INVALIDATE_PTR(mScene); @@ -247,16 +249,18 @@ void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene) // Reads a new chunk from the file void Discreet3DSImporter::ReadChunk(Discreet3DS::Chunk* pcOut) { - ai_assert(pcOut != NULL); + ai_assert(pcOut != nullptr); pcOut->Flag = stream->GetI2(); pcOut->Size = stream->GetI4(); - if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize()) + if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize()) { throw DeadlyImportError("Chunk is too large"); + } - if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit()) - DefaultLogger::get()->error("3DS: Chunk overflow"); + if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit()) { + ASSIMP_LOG_ERROR("3DS: Chunk overflow"); + } } // ------------------------------------------------------------------------------------------------ @@ -317,7 +321,7 @@ void Discreet3DSImporter::ParseEditorChunk() // print the version number char buff[10]; ASSIMP_itoa10(buff,stream->GetI2()); - DefaultLogger::get()->info(std::string("3DS file format version: ") + buff); + ASSIMP_LOG_INFO_F(std::string("3DS file format version: "), buff); } break; }; @@ -346,7 +350,7 @@ void Discreet3DSImporter::ParseObjectChunk() case Discreet3DS::CHUNK_MAT_MATERIAL: // Add a new material to the list - mScene->mMaterials.push_back(D3DS::Material()); + mScene->mMaterials.push_back(D3DS::Material(std::string("UNNAMED_" + to_string(mScene->mMaterials.size())))); ParseMaterialChunk(); break; @@ -358,7 +362,7 @@ void Discreet3DSImporter::ParseObjectChunk() if (is_qnan(mClrAmbient.r)) { // We failed to read the ambient base color. - DefaultLogger::get()->error("3DS: Failed to read ambient base color"); + ASSIMP_LOG_ERROR("3DS: Failed to read ambient base color"); mClrAmbient.r = mClrAmbient.g = mClrAmbient.b = 0.0f; } break; @@ -402,11 +406,7 @@ void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num) case Discreet3DS::CHUNK_TRIMESH: { // this starts a new triangle mesh - mScene->mMeshes.push_back(D3DS::Mesh()); - D3DS::Mesh& m = mScene->mMeshes.back(); - - // Setup the name of the mesh - m.mName = std::string(name, num); + mScene->mMeshes.push_back(D3DS::Mesh(std::string(name, num))); // Read mesh chunks ParseMeshChunk(); @@ -464,7 +464,7 @@ void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num) if (len < 1e-5) { // There are some files with lookat == position. Don't know why or whether it's ok or not. - DefaultLogger::get()->error("3DS: Unable to read proper camera look-at vector"); + ASSIMP_LOG_ERROR("3DS: Unable to read proper camera look-at vector"); camera->mLookAt = aiVector3D(0.0,1.0,0.0); } @@ -630,9 +630,9 @@ void Discreet3DSImporter::SkipTCBInfo() if (!flags) { // Currently we can't do anything with these values. They occur // quite rare, so it wouldn't be worth the effort implementing - // them. 3DS ist not really suitable for complex animations, + // them. 3DS is not really suitable for complex animations, // so full support is not required. - DefaultLogger::get()->warn("3DS: Skipping TCB animation info"); + ASSIMP_LOG_WARN("3DS: Skipping TCB animation info"); } if (flags & Discreet3DS::KEY_USE_TENS) { @@ -690,8 +690,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) pcNode->mInstanceCount++; instanceNumber = pcNode->mInstanceCount; } - pcNode = new D3DS::Node(); - pcNode->mName = name; + pcNode = new D3DS::Node(name); pcNode->mInstanceNumber = instanceNumber; // There are two unknown values which we can safely ignore @@ -734,7 +733,6 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) // If object name is DUMMY, take this one instead if (mCurrentNode->mName == "$$$DUMMY") { - //DefaultLogger::get()->warn("3DS: Skipping dummy object name for non-dummy object"); mCurrentNode->mName = std::string(sz); break; } @@ -745,7 +743,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) if ( Discreet3DS::CHUNK_TRACKINFO != parent) { - DefaultLogger::get()->warn("3DS: Skipping pivot subchunk for non usual object"); + ASSIMP_LOG_WARN("3DS: Skipping pivot subchunk for non usual object"); break; } @@ -807,7 +805,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) { // roll keys are accepted for cameras only if (parent != Discreet3DS::CHUNK_TRACKCAMERA) { - DefaultLogger::get()->warn("3DS: Ignoring roll track for non-camera object"); + ASSIMP_LOG_WARN("3DS: Ignoring roll track for non-camera object"); break; } bool sortKeys = false; @@ -847,7 +845,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) // CAMERA FOV KEYFRAME case Discreet3DS::CHUNK_TRACKFOV: { - DefaultLogger::get()->error("3DS: Skipping FOV animation track. " + ASSIMP_LOG_ERROR("3DS: Skipping FOV animation track. " "This is not supported"); } break; @@ -987,7 +985,7 @@ void Discreet3DSImporter::ParseFaceChunk() } } if (0xcdcdcdcd == idx) { - DefaultLogger::get()->error(std::string("3DS: Unknown material: ") + sz); + ASSIMP_LOG_ERROR_F( "3DS: Unknown material: ", sz); } // Now continue and read all material indices @@ -997,7 +995,7 @@ void Discreet3DSImporter::ParseFaceChunk() // check range if (fidx >= mMesh.mFaceMaterials.size()) { - DefaultLogger::get()->error("3DS: Invalid face index in face material list"); + ASSIMP_LOG_ERROR("3DS: Invalid face index in face material list"); } else mMesh.mFaceMaterials[fidx] = idx; }} @@ -1112,7 +1110,7 @@ void Discreet3DSImporter::ParseMaterialChunk() if (!cnt) { // This may not be, we use the default name instead - DefaultLogger::get()->error("3DS: Empty material name"); + ASSIMP_LOG_ERROR("3DS: Empty material name"); } else mScene->mMaterials.back().mName = std::string(sz,cnt); } @@ -1125,7 +1123,7 @@ void Discreet3DSImporter::ParseMaterialChunk() ParseColorChunk(pc); if (is_qnan(pc->r)) { // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read DIFFUSE chunk"); + ASSIMP_LOG_ERROR("3DS: Unable to read DIFFUSE chunk"); pc->r = pc->g = pc->b = 1.0f; }} break; @@ -1137,7 +1135,7 @@ void Discreet3DSImporter::ParseMaterialChunk() ParseColorChunk(pc); if (is_qnan(pc->r)) { // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read SPECULAR chunk"); + ASSIMP_LOG_ERROR("3DS: Unable to read SPECULAR chunk"); pc->r = pc->g = pc->b = 1.0f; }} break; @@ -1149,7 +1147,7 @@ void Discreet3DSImporter::ParseMaterialChunk() ParseColorChunk(pc); if (is_qnan(pc->r)) { // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read AMBIENT chunk"); + ASSIMP_LOG_ERROR("3DS: Unable to read AMBIENT chunk"); pc->r = pc->g = pc->b = 0.0f; }} break; @@ -1161,7 +1159,7 @@ void Discreet3DSImporter::ParseMaterialChunk() ParseColorChunk(pc); if (is_qnan(pc->r)) { // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read EMISSIVE chunk"); + ASSIMP_LOG_ERROR("3DS: Unable to read EMISSIVE chunk"); pc->r = pc->g = pc->b = 0.0f; }} break; @@ -1295,7 +1293,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) pcOut->mScaleU = stream->GetF4(); if (0.0f == pcOut->mScaleU) { - DefaultLogger::get()->warn("Texture coordinate scaling in the x direction is zero. Assuming 1."); + ASSIMP_LOG_WARN("Texture coordinate scaling in the x direction is zero. Assuming 1."); pcOut->mScaleU = 1.0f; } break; @@ -1304,7 +1302,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) pcOut->mScaleV = stream->GetF4(); if (0.0f == pcOut->mScaleV) { - DefaultLogger::get()->warn("Texture coordinate scaling in the y direction is zero. Assuming 1."); + ASSIMP_LOG_WARN("Texture coordinate scaling in the y direction is zero. Assuming 1."); pcOut->mScaleV = 1.0f; } break; @@ -1346,15 +1344,16 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) // ------------------------------------------------------------------------------------------------ // Read a percentage chunk -ai_real Discreet3DSImporter::ParsePercentageChunk() -{ +ai_real Discreet3DSImporter::ParsePercentageChunk() { Discreet3DS::Chunk chunk; ReadChunk(&chunk); - if (Discreet3DS::CHUNK_PERCENTF == chunk.Flag) - return stream->GetF4(); - else if (Discreet3DS::CHUNK_PERCENTW == chunk.Flag) + if (Discreet3DS::CHUNK_PERCENTF == chunk.Flag) { + return stream->GetF4() * ai_real(100) / ai_real(0xFFFF); + } else if (Discreet3DS::CHUNK_PERCENTW == chunk.Flag) { return (ai_real)((uint16_t)stream->GetI2()) / (ai_real)0xFFFF; + } + return get_qnan(); } diff --git a/Engine/lib/assimp/code/3DSLoader.h b/Engine/lib/assimp/code/3DSLoader.h index 0e377180b..f57e6a8e3 100644 --- a/Engine/lib/assimp/code/3DSLoader.h +++ b/Engine/lib/assimp/code/3DSLoader.h @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -46,13 +47,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_3DSIMPORTER_H_INC #define AI_3DSIMPORTER_H_INC -#include "BaseImporter.h" +#include #include #ifndef ASSIMP_BUILD_NO_3DS_IMPORTER #include "3DSHelper.h" -#include "StreamReader.h" +#include struct aiNode; diff --git a/Engine/lib/assimp/code/3MFXmlTags.h b/Engine/lib/assimp/code/3MFXmlTags.h index 7e47422f1..ea6aeede0 100644 --- a/Engine/lib/assimp/code/3MFXmlTags.h +++ b/Engine/lib/assimp/code/3MFXmlTags.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -44,6 +45,11 @@ namespace Assimp { namespace D3MF { namespace XmlTag { + // Meta-data + static const std::string meta = "metadata"; + static const std::string meta_name = "name"; + + // Model-data specific tags static const std::string model = "model"; static const std::string model_unit = "unit"; static const std::string metadata = "metadata"; @@ -61,6 +67,8 @@ namespace XmlTag { static const std::string v2 = "v2"; static const std::string v3 = "v3"; static const std::string id = "id"; + static const std::string pid = "pid"; + static const std::string p1 = "p1"; static const std::string name = "name"; static const std::string type = "type"; static const std::string build = "build"; @@ -68,6 +76,14 @@ namespace XmlTag { static const std::string objectid = "objectid"; static const std::string transform = "transform"; + // Material definitions + static const std::string basematerials = "basematerials"; + static const std::string basematerials_id = "id"; + static const std::string basematerials_base = "base"; + static const std::string basematerials_name = "name"; + static const std::string basematerials_displaycolor = "displaycolor"; + + // Meta info tags static const std::string CONTENT_TYPES_ARCHIVE = "[Content_Types].xml"; static const std::string ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels"; static const std::string SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types"; @@ -82,7 +98,6 @@ namespace XmlTag { static const std::string PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture"; static const std::string PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"; static const std::string PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"; - } } // Namespace D3MF diff --git a/Engine/lib/assimp/code/ACLoader.cpp b/Engine/lib/assimp/code/ACLoader.cpp index a30baa75a..2eb839553 100644 --- a/Engine/lib/assimp/code/ACLoader.cpp +++ b/Engine/lib/assimp/code/ACLoader.cpp @@ -4,7 +4,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -49,11 +50,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // internal headers #include "ACLoader.h" -#include "ParsingUtils.h" -#include "fast_atof.h" -#include "Subdivision.h" +#include +#include +#include #include "Importer.h" -#include "BaseImporter.h" +#include #include #include #include @@ -84,7 +85,7 @@ static const aiImporterDesc desc = { #define AI_AC_SKIP_TO_NEXT_TOKEN() \ if (!SkipSpaces(&buffer)) \ { \ - DefaultLogger::get()->error("AC3D: Unexpected EOF/EOL"); \ + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL"); \ continue; \ } @@ -100,7 +101,7 @@ static const aiImporterDesc desc = { { \ if (IsLineEnd( *buffer )) \ { \ - DefaultLogger::get()->error("AC3D: Unexpected EOF/EOL in string"); \ + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL in string"); \ out = "ERROR"; \ break; \ } \ @@ -119,7 +120,7 @@ static const aiImporterDesc desc = { { \ if (strncmp(buffer,name,name_length) || !IsSpace(buffer[name_length])) \ { \ - DefaultLogger::get()->error("AC3D: Unexpexted token. " name " was expected."); \ + ASSIMP_LOG_ERROR("AC3D: Unexpexted token. " name " was expected."); \ continue; \ } \ buffer += name_length+1; \ @@ -216,7 +217,7 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) light->mName.length = ::ai_snprintf(light->mName.data, MAXLEN, "ACLight_%i",static_cast(mLights->size())-1); obj.name = std::string( light->mName.data ); - DefaultLogger::get()->debug("AC3D: Light source encountered"); + ASSIMP_LOG_DEBUG("AC3D: Light source encountered"); obj.type = Object::Light; } else if (!ASSIMP_strincmp(buffer,"group",5)) @@ -306,12 +307,12 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) { if (!GetNextLine()) { - DefaultLogger::get()->error("AC3D: Unexpected EOF: not all vertices have been parsed yet"); + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: not all vertices have been parsed yet"); break; } else if (!IsNumeric(*buffer)) { - DefaultLogger::get()->error("AC3D: Unexpected token: not all vertices have been parsed yet"); + ASSIMP_LOG_ERROR("AC3D: Unexpected token: not all vertices have been parsed yet"); --buffer; // make sure the line is processed a second time break; } @@ -337,8 +338,8 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) // example writes no surf chunks if (!Q3DWorkAround) { - DefaultLogger::get()->warn("AC3D: SURF token was expected"); - DefaultLogger::get()->debug("Continuing with Quick3D Workaround enabled"); + ASSIMP_LOG_WARN("AC3D: SURF token was expected"); + ASSIMP_LOG_DEBUG("Continuing with Quick3D Workaround enabled"); } --buffer; // make sure the line is processed a second time // break; --- see fix notes above @@ -383,7 +384,7 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) { if(!GetNextLine()) { - DefaultLogger::get()->error("AC3D: Unexpected EOF: surface references are incomplete"); + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: surface references are incomplete"); break; } surf.entries.push_back(Surface::SurfaceEntry()); @@ -404,7 +405,7 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) } } } - DefaultLogger::get()->error("AC3D: Unexpected EOF: \'kids\' line was expected"); + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: \'kids\' line was expected"); } // ------------------------------------------------------------------------------------------------ @@ -477,7 +478,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, therefore: if no surfaces are defined return point data only */ - DefaultLogger::get()->info("AC3D: No surfaces defined in object definition, " + ASSIMP_LOG_INFO("AC3D: No surfaces defined in object definition, " "a point list is returned"); meshes.push_back(new aiMesh()); @@ -518,12 +519,12 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, unsigned int idx = (*it).mat; if (idx >= needMat.size()) { - DefaultLogger::get()->error("AC3D: material index is out of range"); + ASSIMP_LOG_ERROR("AC3D: material index is out of range"); idx = 0; } if ((*it).entries.empty()) { - DefaultLogger::get()->warn("AC3D: surface her zero vertex references"); + ASSIMP_LOG_WARN("AC3D: surface her zero vertex references"); } // validate all vertex indices to make sure we won't crash here @@ -532,7 +533,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, { if ((*it2).first >= object.vertices.size()) { - DefaultLogger::get()->warn("AC3D: Invalid vertex reference"); + ASSIMP_LOG_WARN("AC3D: Invalid vertex reference"); (*it2).first = 0; } } @@ -560,7 +561,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, if ((*it).flags & 0xf) { - DefaultLogger::get()->warn("AC3D: The type flag of a surface is unknown"); + ASSIMP_LOG_WARN("AC3D: The type flag of a surface is unknown"); (*it).flags &= ~(0xf); } @@ -711,7 +712,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, if (object.subDiv) { if (configEvalSubdivision) { std::unique_ptr div(Subdivider::Create(Subdivider::CATMULL_CLARKE)); - DefaultLogger::get()->info("AC3D: Evaluating subdivision surface: "+object.name); + ASSIMP_LOG_INFO("AC3D: Evaluating subdivision surface: "+object.name); std::vector cpy(meshes.size()-oldm,NULL); div->Subdivide(&meshes[oldm],cpy.size(),&cpy.front(),object.subDiv,true); @@ -720,7 +721,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, // previous meshes are deleted vy Subdivide(). } else { - DefaultLogger::get()->info("AC3D: Letting the subdivision surface untouched due to my configuration: " + ASSIMP_LOG_INFO("AC3D: Letting the subdivision surface untouched due to my configuration: " +object.name); } } @@ -812,7 +813,7 @@ void AC3DImporter::InternReadFile( const std::string& pFile, unsigned int version = HexDigitToDecimal( buffer[4] ); char msg[3]; ASSIMP_itoa10(msg,3,version); - DefaultLogger::get()->info(std::string("AC3D file format version: ") + msg); + ASSIMP_LOG_INFO_F("AC3D file format version: ", msg); std::vector materials; materials.reserve(5); @@ -856,7 +857,7 @@ void AC3DImporter::InternReadFile( const std::string& pFile, } if (materials.empty()) { - DefaultLogger::get()->warn("AC3D: No material has been found"); + ASSIMP_LOG_WARN("AC3D: No material has been found"); materials.push_back(Material()); } diff --git a/Engine/lib/assimp/code/ACLoader.h b/Engine/lib/assimp/code/ACLoader.h index 4b202b77a..cab2c3ae5 100644 --- a/Engine/lib/assimp/code/ACLoader.h +++ b/Engine/lib/assimp/code/ACLoader.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -47,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "BaseImporter.h" +#include #include struct aiNode; diff --git a/Engine/lib/assimp/code/AMFImporter.cpp b/Engine/lib/assimp/code/AMFImporter.cpp index e9211fe53..d173bd0f5 100644 --- a/Engine/lib/assimp/code/AMFImporter.cpp +++ b/Engine/lib/assimp/code/AMFImporter.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -51,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "AMFImporter.hpp" #include "AMFImporter_Macro.hpp" -#include "fast_atof.h" +#include #include // Header files, stdlib. @@ -229,7 +230,7 @@ casu_cres: if(!skipped_before[sk_idx]) { skipped_before[sk_idx] = true; - LogWarning("Skipping node \"" + nn + "\" in " + pParentNodeName + "."); + ASSIMP_LOG_WARN_F("Skipping node \"", nn, "\" in ", pParentNodeName, "."); } } diff --git a/Engine/lib/assimp/code/AMFImporter.hpp b/Engine/lib/assimp/code/AMFImporter.hpp index 47ddc073b..2b8086a06 100644 --- a/Engine/lib/assimp/code/AMFImporter.hpp +++ b/Engine/lib/assimp/code/AMFImporter.hpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -56,14 +57,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include "assimp/types.h" -#include "BaseImporter.h" -#include "irrXMLWrapper.h" +#include +#include // Header files, stdlib. #include -namespace Assimp -{ +namespace Assimp { + /// \class AMFImporter /// Class that holding scene graph which include: geometry, metadata, materials etc. /// @@ -98,100 +99,49 @@ namespace Assimp /// new - and children , , , , , /// old - and children , , , , , /// -class AMFImporter : public BaseImporter -{ - /***********************************************/ - /******************** Types ********************/ - /***********************************************/ - +class AMFImporter : public BaseImporter { private: + struct SPP_Material;// forward declaration - struct SPP_Material;// forward declaration + /// \struct SPP_Composite + /// Data type for post-processing step. More suitable container for part of material's composition. + struct SPP_Composite { + SPP_Material* Material;///< Pointer to material - part of composition. + std::string Formula;///< Formula for calculating ratio of \ref Material. + }; - /// \struct SPP_Composite - /// Data type for postprocessing step. More suitable container for part of material's composition. - struct SPP_Composite - { - SPP_Material* Material;///< Pointer to material - part of composition. - std::string Formula;///< Formula for calculating ratio of \ref Material. - }; + /// \struct SPP_Material + /// Data type for post-processing step. More suitable container for material. + struct SPP_Material { + std::string ID;///< Material ID. + std::list Metadata;///< Metadata of material. + CAMFImporter_NodeElement_Color* Color;///< Color of material. + std::list Composition;///< List of child materials if current material is composition of few another. - /// \struct SPP_Material - /// Data type for postprocessing step. More suitable container for material. - struct SPP_Material - { - std::string ID;///< Material ID. - std::list Metadata;///< Metadata of material. - CAMFImporter_NodeElement_Color* Color;///< Color of material. - std::list Composition;///< List of child materials if current material is composition of few another. + /// Return color calculated for specified coordinate. + /// \param [in] pX - "x" coordinate. + /// \param [in] pY - "y" coordinate. + /// \param [in] pZ - "z" coordinate. + /// \return calculated color. + aiColor4D GetColor(const float pX, const float pY, const float pZ) const; + }; - /// \fn aiColor4D GetColor(const float pX, const float pY, const float pZ) const - /// Return color calculated for specified coordinate. - /// \param [in] pX - "x" coordinate. - /// \param [in] pY - "y" coordinate. - /// \param [in] pZ - "z" coordinate. - /// \return calculated color. - aiColor4D GetColor(const float pX, const float pY, const float pZ) const; - }; + /// Data type for post-processing step. More suitable container for texture. + struct SPP_Texture { + std::string ID; + size_t Width, Height, Depth; + bool Tiled; + char FormatHint[9];// 8 for string + 1 for terminator. + uint8_t *Data; + }; - /// \struct SPP_Texture - /// Data type for post-processing step. More suitable container for texture. - struct SPP_Texture - { - std::string ID; - size_t Width, Height, Depth; - bool Tiled; - char FormatHint[ 9 ];// 8 for string + 1 for terminator. - uint8_t *Data; - }; + /// Data type for post-processing step. Contain face data. + struct SComplexFace { + aiFace Face;///< Face vertices. + const CAMFImporter_NodeElement_Color* Color;///< Face color. Equal to nullptr if color is not set for the face. + const CAMFImporter_NodeElement_TexMap* TexMap;///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face. + }; - /// \struct SComplexFace - /// Data type for post-processing step. Contain face data. - struct SComplexFace - { - aiFace Face;///< Face vertices. - const CAMFImporter_NodeElement_Color* Color;///< Face color. Equal to nullptr if color is not set for the face. - const CAMFImporter_NodeElement_TexMap* TexMap;///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face. - }; - - - - /***********************************************/ - /****************** Constants ******************/ - /***********************************************/ - -private: - - static const aiImporterDesc Description; - - /***********************************************/ - /****************** Variables ******************/ - /***********************************************/ - -private: - - CAMFImporter_NodeElement* mNodeElement_Cur;///< Current element. - std::list mNodeElement_List;///< All elements of scene graph. - irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object - std::string mUnit; - std::list mMaterial_Converted;///< List of converted materials for postprocessing step. - std::list mTexture_Converted;///< List of converted textures for postprocessing step. - - /***********************************************/ - /****************** Functions ******************/ - /***********************************************/ - -private: - - /// \fn AMFImporter(const AMFImporter& pScene) - /// Disabled copy constructor. - AMFImporter(const AMFImporter& pScene); - - /// \fn AMFImporter& operator=(const AMFImporter& pScene) - /// Disabled assign operator. - AMFImporter& operator=(const AMFImporter& pScene); - - /// \fn void Clear() /// Clear all temporary data. void Clear(); @@ -199,7 +149,6 @@ private: /************* Functions: find set *************/ /***********************************************/ - /// \fn bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, aiNode** pNode) const /// Find specified node element in node elements list ( \ref mNodeElement_List). /// \param [in] pID - ID(name) of requested node element. /// \param [in] pType - type of node element. @@ -207,7 +156,6 @@ private: /// \return true - if the node element is found, else - false. bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement** pNodeElement) const; - /// \fn bool Find_ConvertedNode(const std::string& pID, std::list& pNodeList, aiNode** pNode) const /// Find requested aiNode in node list. /// \param [in] pID - ID(name) of requested node. /// \param [in] pNodeList - list of nodes where to find the node. @@ -215,15 +163,13 @@ private: /// \return true - if the node is found, else - false. bool Find_ConvertedNode(const std::string& pID, std::list& pNodeList, aiNode** pNode) const; - /// \fn bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const /// Find material in list for converted materials. Use at postprocessing step. /// \param [in] pID - material ID. /// \param [out] pConvertedMaterial - pointer to found converted material (\ref SPP_Material). /// \return true - if the material is found, else - false. bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const; - /// \fn bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A, uint32_t* pConvertedTextureIndex = nullptr) const - /// Find texture in list of converted textures. Use at postprocessing step, + /// Find texture in list of converted textures. Use at postprocessing step, /// \param [in] pID_R - ID of source "red" texture. /// \param [in] pID_G - ID of source "green" texture. /// \param [in] pID_B - ID of source "blue" texture. @@ -234,11 +180,7 @@ private: bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A, uint32_t* pConvertedTextureIndex = nullptr) const; - /***********************************************/ - /********* Functions: postprocess set **********/ - /***********************************************/ - /// \fn void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector& pVertexCoordinateArray, std::vector& pVertexColorArray) const /// Get data stored in and place it to arrays. /// \param [in] pNodeElement - reference to node element which kept data. /// \param [in] pVertexCoordinateArray - reference to vertices coordinates kept in . @@ -247,7 +189,6 @@ private: void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector& pVertexCoordinateArray, std::vector& pVertexColorArray) const; - /// \fn size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A) /// Return converted texture ID which related to specified source textures ID's. If converted texture does not exist then it will be created and ID on new /// converted texture will be returned. Conversion: set of textures from \ref CAMFImporter_NodeElement_Texture to one \ref SPP_Texture and place it /// to converted textures list. @@ -259,27 +200,23 @@ private: /// \return index of the texture in array of the converted textures. size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A); - /// \fn void PostprocessHelper_SplitFacesByTextureID(std::list& pInputList, std::list > pOutputList_Separated) /// Separate input list by texture IDs. This step is needed because aiMesh can contain mesh which is use only one texture (or set: diffuse, bump etc). /// \param [in] pInputList - input list with faces. Some of them can contain color or texture mapping, or both of them, or nothing. Will be cleared after /// processing. /// \param [out] pOutputList_Separated - output list of the faces lists. Separated faces list by used texture IDs. Will be cleared before processing. void PostprocessHelper_SplitFacesByTextureID(std::list& pInputList, std::list >& pOutputList_Separated); - /// \fn void Postprocess_AddMetadata(const std::list& pMetadataList, aiNode& pSceneNode) const /// Check if child elements of node element is metadata and add it to scene node. /// \param [in] pMetadataList - reference to list with collected metadata. /// \param [out] pSceneNode - scene node in which metadata will be added. void Postprocess_AddMetadata(const std::list& pMetadataList, aiNode& pSceneNode) const; - /// \fn void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list& pMeshList, aiNode** pSceneNode) /// To create aiMesh and aiNode for it from . /// \param [in] pNodeElement - reference to node element which kept data. /// \param [out] pMeshList - reference to a list with all aiMesh of the scene. /// \param [out] pSceneNode - pointer to place where new aiNode will be created. void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list& pMeshList, aiNode** pSceneNode); - /// \fn void Postprocess_BuildMeshSet(const CAMFImporter_NodeElement_Mesh& pNodeElement, const std::vector& pVertexCoordinateArray, const std::vector& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor, std::list& pMeshList, aiNode& pSceneNode) /// Create mesh for every in . /// \param [in] pNodeElement - reference to node element which kept data. /// \param [in] pVertexCoordinateArray - reference to vertices coordinates for all 's. @@ -293,27 +230,20 @@ private: const std::vector& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor, std::list& pMeshList, aiNode& pSceneNode); - /// \fn void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial) /// Convert material from \ref CAMFImporter_NodeElement_Material to \ref SPP_Material. /// \param [in] pMaterial - source CAMFImporter_NodeElement_Material. void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial); - /// \fn void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list& pNodeList) const /// Create and add to aiNode's list new part of scene graph defined by . /// \param [in] pConstellation - reference to node. /// \param [out] pNodeList - reference to aiNode's list. void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list& pNodeList) const; - /// \fn void Postprocess_BuildScene() /// Build Assimp scene graph in aiScene from collected data. /// \param [out] pScene - pointer to aiScene where tree will be built. void Postprocess_BuildScene(aiScene* pScene); - /***********************************************/ - /************* Functions: throw set ************/ - /***********************************************/ - /// \fn void Throw_CloseNotFound(const std::string& pNode) /// Call that function when close tag of node not found and exception must be raised. /// E.g.: /// @@ -323,19 +253,16 @@ private: /// \param [in] pNode - node name in which exception happened. void Throw_CloseNotFound(const std::string& pNode); - /// \fn void Throw_IncorrectAttr(const std::string& pAttrName) /// Call that function when attribute name is incorrect and exception must be raised. /// \param [in] pAttrName - attribute name. /// \throw DeadlyImportError. void Throw_IncorrectAttr(const std::string& pAttrName); - /// \fn void Throw_IncorrectAttrValue(const std::string& pAttrName) /// Call that function when attribute value is incorrect and exception must be raised. /// \param [in] pAttrName - attribute name. /// \throw DeadlyImportError. void Throw_IncorrectAttrValue(const std::string& pAttrName); - /// \fn void Throw_MoreThanOnceDefined(const std::string& pNode, const std::string& pDescription) /// Call that function when some type of nodes are defined twice or more when must be used only once and exception must be raised. /// E.g.: /// @@ -347,216 +274,158 @@ private: /// \param [in] pDescription - message about error. E.g. what the node defined while exception raised. void Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription); - /// \fn void Throw_ID_NotFound(const std::string& pID) const /// Call that function when referenced element ID are not found in graph and exception must be raised. /// \param [in] pID - ID of of element which not found. /// \throw DeadlyImportError. void Throw_ID_NotFound(const std::string& pID) const; - /***********************************************/ - /************** Functions: LOG set *************/ - /***********************************************/ - - /// \fn void LogInfo(const std::string& pMessage) - /// Short variant for calling \ref DefaultLogger::get()->info() - void LogInfo(const std::string& pMessage) { DefaultLogger::get()->info(pMessage); } - - /// \fn void LogWarning(const std::string& pMessage) - /// Short variant for calling \ref DefaultLogger::get()->warn() - void LogWarning(const std::string& pMessage) { DefaultLogger::get()->warn(pMessage); } - - /// \fn void LogError(const std::string& pMessage) - /// Short variant for calling \ref DefaultLogger::get()->error() - void LogError(const std::string& pMessage) { DefaultLogger::get()->error(pMessage); } - - /***********************************************/ - /************** Functions: XML set *************/ - /***********************************************/ - - /// \fn void XML_CheckNode_MustHaveChildren() /// Check if current node have children: .... If not then exception will throwed. void XML_CheckNode_MustHaveChildren(); - /// \fn bool XML_CheckNode_NameEqual(const std::string& pNodeName) /// Check if current node name is equal to pNodeName. /// \param [in] pNodeName - name for checking. /// return true if current node name is equal to pNodeName, else - false. bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; } - /// \fn void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName) /// Skip unsupported node and report about that. Depend on node name can be skipped begin tag of node all whole node. /// \param [in] pParentNodeName - parent node name. Used for reporting. void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName); - /// \fn bool XML_SearchNode(const std::string& pNodeName) /// Search for specified node in file. XML file read pointer(mReader) will point to found node or file end after search is end. /// \param [in] pNodeName - requested node name. /// return true - if node is found, else - false. bool XML_SearchNode(const std::string& pNodeName); - /// \fn bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx) /// Read attribute value. /// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set). /// \return read data. bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx); - /// \fn float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx) /// Read attribute value. /// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set). /// \return read data. float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx); - /// \fn uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx) /// Read attribute value. /// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set). /// \return read data. uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx); - /// \fn float XML_ReadNode_GetVal_AsFloat() /// Read node value. /// \return read data. float XML_ReadNode_GetVal_AsFloat(); - /// \fn uint32_t XML_ReadNode_GetVal_AsU32() /// Read node value. /// \return read data. uint32_t XML_ReadNode_GetVal_AsU32(); - /// \fn void XML_ReadNode_GetVal_AsString(std::string& pValue) /// Read node value. /// \return read data. void XML_ReadNode_GetVal_AsString(std::string& pValue); - /***********************************************/ - /******** Functions: parse set private *********/ - /***********************************************/ - - /// \fn void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode) /// Make pNode as current and enter deeper for parsing child nodes. At end \ref ParseHelper_Node_Exit must be called. /// \param [in] pNode - new current node. void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode); - /// \fn void ParseHelper_Group_End() /// This function must be called when exiting from grouping node. \ref ParseHelper_Group_Begin. void ParseHelper_Node_Exit(); - /// \fn void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString) /// Attribute values of floating point types can take form ".x"(without leading zero). irrXMLReader can not read this form of values and it /// must be converted to right form - "0.xxx". /// \param [in] pInStr - pointer to input string which can contain incorrect form of values. /// \param [out[ pOutString - output string with right form of values. void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString); - /// \fn void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector& pOutputData) const /// Decode Base64-encoded data. /// \param [in] pInputBase64 - reference to input Base64-encoded string. /// \param [out] pOutputData - reference to output array for decoded data. void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector& pOutputData) const; - /// \fn void ParseNode_Root() /// Parse node of the file. void ParseNode_Root(); - /******** Functions: top nodes *********/ - - /// \fn void ParseNode_Constellation() /// Parse node of the file. void ParseNode_Constellation(); - /// \fn void ParseNode_Constellation() /// Parse node of the file. void ParseNode_Instance(); - /// \fn void ParseNode_Material() /// Parse node of the file. void ParseNode_Material(); - /// \fn void ParseNode_Metadata() /// Parse node. void ParseNode_Metadata(); - /// \fn void ParseNode_Object() /// Parse node of the file. void ParseNode_Object(); - /// \fn void ParseNode_Texture() /// Parse node of the file. void ParseNode_Texture(); - /******** Functions: geometry nodes *********/ - - /// \fn void ParseNode_Coordinates() /// Parse node of the file. void ParseNode_Coordinates(); - /// \fn void ParseNode_Edge() /// Parse node of the file. void ParseNode_Edge(); - /// \fn void ParseNode_Mesh() /// Parse node of the file. void ParseNode_Mesh(); - /// \fn void ParseNode_Triangle() /// Parse node of the file. void ParseNode_Triangle(); - /// \fn void ParseNode_Vertex() /// Parse node of the file. void ParseNode_Vertex(); - /// \fn void ParseNode_Vertices() /// Parse node of the file. void ParseNode_Vertices(); - /// \fn void ParseNode_Volume() /// Parse node of the file. void ParseNode_Volume(); - /******** Functions: material nodes *********/ - - /// \fn void ParseNode_Color() /// Parse node of the file. void ParseNode_Color(); - /// \fn void ParseNode_TexMap(const bool pUseOldName = false) /// Parse of node of the file. /// \param [in] pUseOldName - if true then use old name of node(and children) - , instead of new name - . void ParseNode_TexMap(const bool pUseOldName = false); public: - - /// \fn AMFImporter() /// Default constructor. - AMFImporter() - : mNodeElement_Cur(nullptr), mReader(nullptr) - {} + AMFImporter() AI_NO_EXCEPT + : mNodeElement_Cur(nullptr) + , mReader(nullptr) { + // empty + } - /// \fn ~AMFImporter() /// Default destructor. ~AMFImporter(); - /***********************************************/ - /******** Functions: parse set, public *********/ - /***********************************************/ - - /// \fn void ParseFile(const std::string& pFile, IOSystem* pIOHandler) /// Parse AMF file and fill scene graph. The function has no return value. Result can be found by analyzing the generated graph. - /// Also exception can be throwed if trouble will found. + /// Also exception can be thrown if trouble will found. /// \param [in] pFile - name of file to be parsed. /// \param [in] pIOHandler - pointer to IO helper object. void ParseFile(const std::string& pFile, IOSystem* pIOHandler); - /***********************************************/ - /********* Functions: BaseImporter set *********/ - /***********************************************/ - bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const; void GetExtensionList(std::set& pExtensionList); void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler); const aiImporterDesc* GetInfo ()const; -};// class AMFImporter + AMFImporter(const AMFImporter& pScene) = delete; + AMFImporter& operator=(const AMFImporter& pScene) = delete; + +private: + static const aiImporterDesc Description; + + CAMFImporter_NodeElement* mNodeElement_Cur;///< Current element. + std::list mNodeElement_List;///< All elements of scene graph. + irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object + std::string mUnit; + std::list mMaterial_Converted;///< List of converted materials for postprocessing step. + std::list mTexture_Converted;///< List of converted textures for postprocessing step. + +}; }// namespace Assimp diff --git a/Engine/lib/assimp/code/AMFImporter_Geometry.cpp b/Engine/lib/assimp/code/AMFImporter_Geometry.cpp index afba3f2bc..f1538e3fb 100644 --- a/Engine/lib/assimp/code/AMFImporter_Geometry.cpp +++ b/Engine/lib/assimp/code/AMFImporter_Geometry.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. diff --git a/Engine/lib/assimp/code/AMFImporter_Macro.hpp b/Engine/lib/assimp/code/AMFImporter_Macro.hpp index b7c0f9863..f60c5fbbb 100644 --- a/Engine/lib/assimp/code/AMFImporter_Macro.hpp +++ b/Engine/lib/assimp/code/AMFImporter_Macro.hpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -70,7 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } /// \def MACRO_ATTRREAD_CHECK_REF -/// Check curent attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then +/// Check current attribute name and if it equal to requested then read value. Result write to output variable by reference. If result was read then /// "continue" will called. /// \param [in] pAttrName - attribute name. /// \param [out] pVarName - output variable name. @@ -83,7 +84,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } /// \def MACRO_ATTRREAD_CHECK_RET -/// Check curent attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction. +/// Check current attribute name and if it equal to requested then read value. Result write to output variable using return value of \ref pFunction. /// If result was read then "continue" will called. /// \param [in] pAttrName - attribute name. /// \param [out] pVarName - output variable name. @@ -129,7 +130,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } while(false) /// \def MACRO_NODECHECK_READCOMP_F -/// Check curent node name and if it equal to requested then read value. Result write to output variable of type "float". +/// Check current node name and if it equal to requested then read value. Result write to output variable of type "float". /// If result was read then "continue" will called. Also check if node data already read then raise exception. /// \param [in] pNodeName - node name. /// \param [in, out] pReadFlag - read flag. @@ -146,7 +147,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } /// \def MACRO_NODECHECK_READCOMP_U32 -/// Check curent node name and if it equal to requested then read value. Result write to output variable of type "uint32_t". +/// Check current node name and if it equal to requested then read value. Result write to output variable of type "uint32_t". /// If result was read then "continue" will called. Also check if node data already read then raise exception. /// \param [in] pNodeName - node name. /// \param [in, out] pReadFlag - read flag. diff --git a/Engine/lib/assimp/code/AMFImporter_Material.cpp b/Engine/lib/assimp/code/AMFImporter_Material.cpp index d15099fac..2f36df061 100644 --- a/Engine/lib/assimp/code/AMFImporter_Material.cpp +++ b/Engine/lib/assimp/code/AMFImporter_Material.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -67,10 +68,9 @@ namespace Assimp // Multi elements - No. // Red, Greed, Blue and Alpha (transparency) component of a color in sRGB space, values ranging from 0 to 1. The // values can be specified as constants, or as a formula depending on the coordinates. -void AMFImporter::ParseNode_Color() -{ -std::string profile; -CAMFImporter_NodeElement* ne; +void AMFImporter::ParseNode_Color() { + std::string profile; + CAMFImporter_NodeElement* ne; // Read attributes for node . MACRO_ATTRREAD_LOOPBEG; @@ -97,15 +97,19 @@ CAMFImporter_NodeElement* ne; MACRO_NODECHECK_LOOPEND("color"); ParseHelper_Node_Exit(); // check that all components was defined - if(!(read_flag[0] && read_flag[1] && read_flag[2])) throw DeadlyImportError("Not all color components are defined."); - // check if is absent. Then manualy add "a == 1". - if(!read_flag[3]) als.Color.a = 1; + if (!(read_flag[0] && read_flag[1] && read_flag[2])) { + throw DeadlyImportError("Not all color components are defined."); + } - }// if(!mReader->isEmptyElement()) + // check if is absent. Then manually add "a == 1". + if (!read_flag[3]) { + als.Color.a = 1; + } + } else { mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element - }// if(!mReader->isEmptyElement()) else + } als.Composed = false; mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph. @@ -118,10 +122,9 @@ CAMFImporter_NodeElement* ne; // An available material. // Multi elements - Yes. // Parent element - . -void AMFImporter::ParseNode_Material() -{ -std::string id; -CAMFImporter_NodeElement* ne; +void AMFImporter::ParseNode_Material() { + std::string id; + CAMFImporter_NodeElement* ne; // Read attributes for node . MACRO_ATTRREAD_LOOPBEG; @@ -130,9 +133,11 @@ CAMFImporter_NodeElement* ne; // create new object. ne = new CAMFImporter_NodeElement_Material(mNodeElement_Cur); - // and assign read data + + // and assign read data ((CAMFImporter_NodeElement_Material*)ne)->ID = id; - // Check for child nodes + + // Check for child nodes if(!mReader->isEmptyElement()) { bool col_read = false; @@ -153,11 +158,11 @@ CAMFImporter_NodeElement* ne; if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; } MACRO_NODECHECK_LOOPEND("material"); 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. } @@ -180,14 +185,13 @@ CAMFImporter_NodeElement* ne; // Parent element - . void AMFImporter::ParseNode_Texture() { -std::string id; -uint32_t width = 0; -uint32_t height = 0; -uint32_t depth = 1; -std::string type; -bool tiled = false; -std::string enc64_data; -CAMFImporter_NodeElement* ne; + std::string id; + uint32_t width = 0; + uint32_t height = 0; + uint32_t depth = 1; + std::string type; + bool tiled = false; + std::string enc64_data; // Read attributes for node . MACRO_ATTRREAD_LOOPBEG; @@ -200,20 +204,34 @@ CAMFImporter_NodeElement* ne; MACRO_ATTRREAD_LOOPEND; // create new texture object. - ne = new CAMFImporter_NodeElement_Texture(mNodeElement_Cur); + CAMFImporter_NodeElement *ne = new CAMFImporter_NodeElement_Texture(mNodeElement_Cur); CAMFImporter_NodeElement_Texture& als = *((CAMFImporter_NodeElement_Texture*)ne);// alias for convenience // Check for child nodes - if(!mReader->isEmptyElement()) XML_ReadNode_GetVal_AsString(enc64_data); + if (!mReader->isEmptyElement()) { + XML_ReadNode_GetVal_AsString(enc64_data); + } // check that all components was defined - if(id.empty()) throw DeadlyImportError("ID for texture must be defined."); - if(width < 1) Throw_IncorrectAttrValue("width"); - if(height < 1) Throw_IncorrectAttrValue("height"); - if(depth < 1) Throw_IncorrectAttrValue("depth"); - if(type != "grayscale") Throw_IncorrectAttrValue("type"); - if(enc64_data.empty()) throw DeadlyImportError("Texture data not defined."); + if (id.empty()) { + throw DeadlyImportError("ID for texture must be defined."); + } + if (width < 1) { + Throw_IncorrectAttrValue("width"); + } + if (height < 1) { + Throw_IncorrectAttrValue("height"); + } + if (depth < 1) { + Throw_IncorrectAttrValue("depth"); + } + if (type != "grayscale") { + Throw_IncorrectAttrValue("type"); + } + if (enc64_data.empty()) { + throw DeadlyImportError("Texture data not defined."); + } // copy data als.ID = id; als.Width = width; @@ -221,8 +239,11 @@ CAMFImporter_NodeElement* ne; als.Depth = depth; als.Tiled = tiled; ParseHelper_Decode_Base64(enc64_data, als.Data); - // check data size - if((width * height * depth) != als.Data.size()) throw DeadlyImportError("Texture has incorrect data size."); + + // check data size + if ((width * height * depth) != als.Data.size()) { + throw DeadlyImportError("Texture has incorrect data size."); + } 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. @@ -242,10 +263,8 @@ CAMFImporter_NodeElement* ne; // , , , , , . Old name: , , , , , . // Multi elements - No. // Texture coordinates for every vertex of triangle. -void AMFImporter::ParseNode_TexMap(const bool pUseOldName) -{ -std::string rtexid, gtexid, btexid, atexid; -CAMFImporter_NodeElement* ne; +void AMFImporter::ParseNode_TexMap(const bool pUseOldName) { + std::string rtexid, gtexid, btexid, atexid; // Read attributes for node . MACRO_ATTRREAD_LOOPBEG; @@ -256,7 +275,7 @@ CAMFImporter_NodeElement* ne; MACRO_ATTRREAD_LOOPEND; // create new texture coordinates object. - ne = new CAMFImporter_NodeElement_TexMap(mNodeElement_Cur); + CAMFImporter_NodeElement *ne = new CAMFImporter_NodeElement_TexMap(mNodeElement_Cur); CAMFImporter_NodeElement_TexMap& als = *((CAMFImporter_NodeElement_TexMap*)ne);// alias for convenience // check data diff --git a/Engine/lib/assimp/code/AMFImporter_Node.hpp b/Engine/lib/assimp/code/AMFImporter_Node.hpp index 522e6ccca..a1bf9f008 100644 --- a/Engine/lib/assimp/code/AMFImporter_Node.hpp +++ b/Engine/lib/assimp/code/AMFImporter_Node.hpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -61,7 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /// \class CAMFImporter_NodeElement /// Base class for elements of nodes. class CAMFImporter_NodeElement { - public: /// Define what data type contain node element. enum EType { @@ -95,15 +95,11 @@ public: /// Destructor, virtual.. // empty } -private: - /// Disabled copy constructor. - CAMFImporter_NodeElement(const CAMFImporter_NodeElement& pNodeElement); - - /// Disabled assign operator. - CAMFImporter_NodeElement& operator=(const CAMFImporter_NodeElement& pNodeElement); - - /// Disabled default constructor. - CAMFImporter_NodeElement(); + /// Disabled copy constructor and co. + CAMFImporter_NodeElement(const CAMFImporter_NodeElement& pNodeElement) = delete; + CAMFImporter_NodeElement(CAMFImporter_NodeElement&&) = delete; + CAMFImporter_NodeElement& operator=(const CAMFImporter_NodeElement& pNodeElement) = delete; + CAMFImporter_NodeElement() = delete; protected: /// In constructor inheritor must set element type. @@ -120,9 +116,7 @@ protected: /// \struct CAMFImporter_NodeElement_Constellation /// A collection of objects or constellations with specific relative locations. -struct CAMFImporter_NodeElement_Constellation : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Constellation(CAMFImporter_NodeElement* pParent) +struct CAMFImporter_NodeElement_Constellation : public CAMFImporter_NodeElement { /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Constellation(CAMFImporter_NodeElement* pParent) @@ -133,9 +127,7 @@ struct CAMFImporter_NodeElement_Constellation : public CAMFImporter_NodeElement /// \struct CAMFImporter_NodeElement_Instance /// Part of constellation. -struct CAMFImporter_NodeElement_Instance : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ +struct CAMFImporter_NodeElement_Instance : public CAMFImporter_NodeElement { std::string ObjectID;///< ID of object for instantiation. /// \var Delta - The distance of translation in the x, y, or z direction, respectively, in the referenced object's coordinate system, to @@ -146,237 +138,185 @@ struct CAMFImporter_NodeElement_Instance : public CAMFImporter_NodeElement /// instance of the object in the current constellation. Rotations shall be executed in order of x first, then y, then z. aiVector3D Rotation; - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Instance(CAMFImporter_NodeElement* pParent) /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Instance(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Instance, pParent) {} - -};// struct CAMFImporter_NodeElement_Instance +}; /// \struct CAMFImporter_NodeElement_Metadata /// Structure that define metadata node. -struct CAMFImporter_NodeElement_Metadata : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ +struct CAMFImporter_NodeElement_Metadata : public CAMFImporter_NodeElement { - std::string Type;///< Type of "Value". + std::string Type;///< Type of "Value". std::string Value;///< Value. - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Metadata(CAMFImporter_NodeElement* pParent) /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Metadata(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Metadata, pParent) {} - -};// struct CAMFImporter_NodeElement_Metadata +}; /// \struct CAMFImporter_NodeElement_Root /// Structure that define root node. -struct CAMFImporter_NodeElement_Root : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ +struct CAMFImporter_NodeElement_Root : public CAMFImporter_NodeElement { std::string Unit;///< The units to be used. May be "inch", "millimeter", "meter", "feet", or "micron". std::string Version;///< Version of format. - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Root(CAMFImporter_NodeElement* pParent) /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Root(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Root, pParent) {} - -};// struct CAMFImporter_NodeElement_Root +}; /// \struct CAMFImporter_NodeElement_Color /// Structure that define object node. -struct CAMFImporter_NodeElement_Color : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ +struct CAMFImporter_NodeElement_Color : public CAMFImporter_NodeElement { + bool Composed; ///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color. + std::string Color_Composed[4]; ///< By components formulas of composed color. [0..3] - RGBA. + aiColor4D Color; ///< Constant color. + std::string Profile; ///< The ICC color space used to interpret the three color channels r, g and b.. - bool Composed;///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color. - std::string Color_Composed[4];///< By components formulas of composed color. [0..3] => RGBA. - aiColor4D Color;///< Constant color. - std::string Profile;///< The ICC color space used to interpret the three color channels , and .. - - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent) - /// Constructor. - /// \param [in] pParent - pointer to parent node. + /// @brief Constructor. + /// @param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Color, pParent) - {} - -};// struct CAMFImporter_NodeElement_Color + : CAMFImporter_NodeElement(ENET_Color, pParent) + , Composed( false ) + , Color() + , Profile() { + // empty + } +}; /// \struct CAMFImporter_NodeElement_Material /// Structure that define material node. -struct CAMFImporter_NodeElement_Material : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent) +struct CAMFImporter_NodeElement_Material : public CAMFImporter_NodeElement { + /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Material, pParent) {} -};// struct CAMFImporter_NodeElement_Material +}; /// \struct CAMFImporter_NodeElement_Object /// Structure that define object node. -struct CAMFImporter_NodeElement_Object : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Object(CAMFImporter_NodeElement* pParent) - /// Constructor. +struct CAMFImporter_NodeElement_Object : public CAMFImporter_NodeElement { + + /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Object(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Object, pParent) {} - -};// struct CAMFImporter_NodeElement_Object +}; /// \struct CAMFImporter_NodeElement_Mesh /// Structure that define mesh node. -struct CAMFImporter_NodeElement_Mesh : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Mesh(CAMFImporter_NodeElement* pParent) +struct CAMFImporter_NodeElement_Mesh : public CAMFImporter_NodeElement { /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Mesh(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Mesh, pParent) {} - -};// struct CAMFImporter_NodeElement_Mesh +}; /// \struct CAMFImporter_NodeElement_Vertex /// Structure that define vertex node. -struct CAMFImporter_NodeElement_Vertex : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Vertex(CAMFImporter_NodeElement* pParent) +struct CAMFImporter_NodeElement_Vertex : public CAMFImporter_NodeElement { /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Vertex(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Vertex, pParent) {} - -};// struct CAMFImporter_NodeElement_Vertex +}; /// \struct CAMFImporter_NodeElement_Edge /// Structure that define edge node. -struct CAMFImporter_NodeElement_Edge : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Edge(CAMFImporter_NodeElement* pParent) +struct CAMFImporter_NodeElement_Edge : public CAMFImporter_NodeElement { /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Edge(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Edge, pParent) {} -};// struct CAMFImporter_NodeElement_Vertex +}; /// \struct CAMFImporter_NodeElement_Vertices /// Structure that define vertices node. -struct CAMFImporter_NodeElement_Vertices : public CAMFImporter_NodeElement -{ - /// \fn CAMFImporter_NodeElement_Vertices(CAMFImporter_NodeElement* pParent) +struct CAMFImporter_NodeElement_Vertices : public CAMFImporter_NodeElement { /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Vertices(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Vertices, pParent) {} - -};// struct CAMFImporter_NodeElement_Vertices +}; /// \struct CAMFImporter_NodeElement_Volume /// Structure that define volume node. -struct CAMFImporter_NodeElement_Volume : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - +struct CAMFImporter_NodeElement_Volume : public CAMFImporter_NodeElement { std::string MaterialID;///< Which material to use. std::string Type;///< What this volume describes can be “region†or “supportâ€. If none specified, “object†is assumed. - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Volume(CAMFImporter_NodeElement* pParent) /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Volume(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Volume, pParent) {} - -};// struct CAMFImporter_NodeElement_Volume +}; /// \struct CAMFImporter_NodeElement_Coordinates /// Structure that define coordinates node. struct CAMFImporter_NodeElement_Coordinates : public CAMFImporter_NodeElement { - /****************** Variables ******************/ - aiVector3D Coordinate;///< Coordinate. - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Coordinates(CAMFImporter_NodeElement* pParent) /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Coordinates(CAMFImporter_NodeElement* pParent) : CAMFImporter_NodeElement(ENET_Coordinates, pParent) {} -};// struct CAMFImporter_NodeElement_Coordinates +}; /// \struct CAMFImporter_NodeElement_TexMap /// Structure that define texture coordinates node. -struct CAMFImporter_NodeElement_TexMap : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - +struct CAMFImporter_NodeElement_TexMap : public CAMFImporter_NodeElement { aiVector3D TextureCoordinate[3];///< Texture coordinates. std::string TextureID_R;///< Texture ID for red color component. std::string TextureID_G;///< Texture ID for green color component. std::string TextureID_B;///< Texture ID for blue color component. std::string TextureID_A;///< Texture ID for alpha color component. - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent) /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_TexMap, pParent) - {} - -};// struct CAMFImporter_NodeElement_TexMap + : CAMFImporter_NodeElement(ENET_TexMap, pParent) + , TextureCoordinate{} + , TextureID_R() + , TextureID_G() + , TextureID_B() + , TextureID_A() { + // empty + } +}; /// \struct CAMFImporter_NodeElement_Triangle /// Structure that define triangle node. -struct CAMFImporter_NodeElement_Triangle : public CAMFImporter_NodeElement -{ - /****************** Variables ******************/ - +struct CAMFImporter_NodeElement_Triangle : public CAMFImporter_NodeElement { size_t V[3];///< Triangle vertices. - /****************** Functions ******************/ - - /// \fn CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent) /// Constructor. /// \param [in] pParent - pointer to parent node. CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent) - : CAMFImporter_NodeElement(ENET_Triangle, pParent) - {} - -};// struct CAMFImporter_NodeElement_Triangle + : CAMFImporter_NodeElement(ENET_Triangle, pParent) { + // empty + } +}; /// Structure that define texture node. struct CAMFImporter_NodeElement_Texture : public CAMFImporter_NodeElement { @@ -395,6 +335,6 @@ struct CAMFImporter_NodeElement_Texture : public CAMFImporter_NodeElement { , Tiled( false ){ // empty } -};// struct CAMFImporter_NodeElement_Texture +}; #endif // INCLUDED_AI_AMF_IMPORTER_NODE_H diff --git a/Engine/lib/assimp/code/AMFImporter_Postprocess.cpp b/Engine/lib/assimp/code/AMFImporter_Postprocess.cpp index 991eb97e7..2bfe3f78c 100644 --- a/Engine/lib/assimp/code/AMFImporter_Postprocess.cpp +++ b/Engine/lib/assimp/code/AMFImporter_Postprocess.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -51,8 +52,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Header files, Assimp. #include -#include "StandardShapes.h" -#include "StringUtils.h" +#include +#include // Header files, stdlib. #include @@ -155,10 +156,11 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string& TextureConverted_Index = 0; for(const SPP_Texture& tex_convd: mTexture_Converted) { - if(tex_convd.ID == TextureConverted_ID) - return TextureConverted_Index; - else - TextureConverted_Index++; + if ( tex_convd.ID == TextureConverted_ID ) { + return TextureConverted_Index; + } else { + ++TextureConverted_Index; + } } // @@ -768,7 +770,7 @@ std::list ch_node; // find referenced object if(!Find_ConvertedNode(als.ObjectID, pNodeList, &found_node)) Throw_ID_NotFound(als.ObjectID); - // create node for apllying transformation + // create node for applying transformation t_node = new aiNode; t_node->mParent = con_node; // apply transformation diff --git a/Engine/lib/assimp/code/ASELoader.cpp b/Engine/lib/assimp/code/ASELoader.cpp index 65935f48f..321e8548a 100644 --- a/Engine/lib/assimp/code/ASELoader.cpp +++ b/Engine/lib/assimp/code/ASELoader.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -50,8 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // internal headers #include "ASELoader.h" -#include "StringComparison.h" -#include "SkeletonMeshBuilder.h" +#include +#include #include "TargetAnimation.h" #include #include @@ -62,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include // utilities -#include "fast_atof.h" +#include using namespace Assimp; using namespace Assimp::ASE; @@ -83,11 +84,11 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer ASEImporter::ASEImporter() - : mParser(), - mBuffer(), - pcScene(), - configRecomputeNormals(), - noSkeletonMesh() +: mParser() +, mBuffer() +, pcScene() +, configRecomputeNormals() +, noSkeletonMesh() {} // ------------------------------------------------------------------------------------------------ @@ -199,7 +200,7 @@ void ASEImporter::InternReadFile( const std::string& pFile, ConvertMeshes(*i,avOutMeshes); } if (tookNormals) { - DefaultLogger::get()->debug("ASE: Taking normals from the file. Use " + ASSIMP_LOG_DEBUG("ASE: Taking normals from the file. Use " "the AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS setting if you " "experience problems"); } @@ -276,14 +277,13 @@ void ASEImporter::GenerateDefaultMaterial() } if (bHas || mParser->m_vMaterials.empty()) { // add a simple material without submaterials to the parser's list - mParser->m_vMaterials.push_back ( ASE::Material() ); + mParser->m_vMaterials.push_back ( ASE::Material(AI_DEFAULT_MATERIAL_NAME) ); ASE::Material& mat = mParser->m_vMaterials.back(); mat.mDiffuse = aiColor3D(0.6f,0.6f,0.6f); mat.mSpecular = aiColor3D(1.0f,1.0f,1.0f); mat.mAmbient = aiColor3D(0.05f,0.05f,0.05f); mat.mShading = Discreet3DS::Gouraud; - mat.mName = AI_DEFAULT_MATERIAL_NAME; } } @@ -297,15 +297,15 @@ void ASEImporter::BuildAnimations(const std::vector& nodes) // TODO: Implement Bezier & TCB support if ((*i)->mAnim.mPositionType != ASE::Animation::TRACK) { - DefaultLogger::get()->warn("ASE: Position controller uses Bezier/TCB keys. " + ASSIMP_LOG_WARN("ASE: Position controller uses Bezier/TCB keys. " "This is not supported."); } if ((*i)->mAnim.mRotationType != ASE::Animation::TRACK) { - DefaultLogger::get()->warn("ASE: Rotation controller uses Bezier/TCB keys. " + ASSIMP_LOG_WARN("ASE: Rotation controller uses Bezier/TCB keys. " "This is not supported."); } if ((*i)->mAnim.mScalingType != ASE::Animation::TRACK) { - DefaultLogger::get()->warn("ASE: Position controller uses Bezier/TCB keys. " + ASSIMP_LOG_WARN("ASE: Position controller uses Bezier/TCB keys. " "This is not supported."); } @@ -583,7 +583,7 @@ void ASEImporter::AddNodes (const std::vector& nodes, node->mTransformation = mParentAdjust*snode->mTransform; // Add sub nodes - prevent stack overflow due to recursive parenting - if (node->mName != node->mParent->mName) { + if (node->mName != node->mParent->mName && node->mName != node->mParent->mParent->mName ) { AddNodes(nodes,node,node->mName.data,snode->mTransform); } @@ -624,7 +624,7 @@ void ASEImporter::AddNodes (const std::vector& nodes, node->mNumChildren++; // What we did is so great, it is at least worth a debug message - DefaultLogger::get()->debug("ASE: Generating separate target node ("+snode->mName+")"); + ASSIMP_LOG_DEBUG("ASE: Generating separate target node ("+snode->mName+")"); } } @@ -947,7 +947,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, std::vector& avOutMesh // validate the material index of the mesh if (mesh.iMaterialIndex >= mParser->m_vMaterials.size()) { mesh.iMaterialIndex = (unsigned int)mParser->m_vMaterials.size()-1; - DefaultLogger::get()->warn("Material index is out of range"); + ASSIMP_LOG_WARN("Material index is out of range"); } // If the material the mesh is assigned to is consisting of submeshes, split it @@ -957,11 +957,11 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, std::vector& avOutMesh std::vector* aiSplit = new std::vector[vSubMaterials.size()]; - // build a list of all faces per submaterial + // build a list of all faces per sub-material for (unsigned int i = 0; i < mesh.mFaces.size();++i) { // check range if (mesh.mFaces[i].iMaterial >= vSubMaterials.size()) { - DefaultLogger::get()->warn("Submaterial index is out of range"); + ASSIMP_LOG_WARN("Submaterial index is out of range"); // use the last material instead aiSplit[vSubMaterials.size()-1].push_back(i); diff --git a/Engine/lib/assimp/code/ASELoader.h b/Engine/lib/assimp/code/ASELoader.h index 8a8d4faa4..33406e3e5 100644 --- a/Engine/lib/assimp/code/ASELoader.h +++ b/Engine/lib/assimp/code/ASELoader.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -45,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_ASELOADER_H_INCLUDED #define AI_ASELOADER_H_INCLUDED -#include "BaseImporter.h" +#include #include #include "ASEParser.h" diff --git a/Engine/lib/assimp/code/ASEParser.cpp b/Engine/lib/assimp/code/ASEParser.cpp index 7de80a2d8..e8d6febc2 100644 --- a/Engine/lib/assimp/code/ASEParser.cpp +++ b/Engine/lib/assimp/code/ASEParser.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -51,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // internal headers #include "TextureTransform.h" #include "ASELoader.h" -#include "fast_atof.h" +#include #include using namespace Assimp; @@ -150,7 +151,7 @@ void Parser::LogWarning(const char* szWarn) #endif // output the warning to the logger ... - DefaultLogger::get()->warn(szTemp); + ASSIMP_LOG_WARN(szTemp); } // ------------------------------------------------------------------------------------------------ @@ -166,7 +167,7 @@ void Parser::LogInfo(const char* szWarn) #endif // output the information to the logger ... - DefaultLogger::get()->info(szTemp); + ASSIMP_LOG_INFO(szTemp); } // ------------------------------------------------------------------------------------------------ @@ -266,7 +267,9 @@ void Parser::Parse() // at the file extension (ASE, ASK, ASC) // ************************************************************* - if (fmt)iFileFormat = fmt; + if ( fmt ) { + iFileFormat = fmt; + } continue; } // main scene information @@ -292,7 +295,7 @@ void Parser::Parse() if (TokenMatch(filePtr,"GEOMOBJECT",10)) { - m_vMeshes.push_back(Mesh()); + m_vMeshes.push_back(Mesh("UNNAMED")); ParseLV1ObjectBlock(m_vMeshes.back()); continue; } @@ -308,14 +311,14 @@ void Parser::Parse() if (TokenMatch(filePtr,"LIGHTOBJECT",11)) { - m_vLights.push_back(Light()); + m_vLights.push_back(Light("UNNAMED")); ParseLV1ObjectBlock(m_vLights.back()); continue; } // camera object if (TokenMatch(filePtr,"CAMERAOBJECT",12)) { - m_vCameras.push_back(Camera()); + m_vCameras.push_back(Camera("UNNAMED")); ParseLV1ObjectBlock(m_vCameras.back()); continue; } @@ -426,28 +429,25 @@ void Parser::ParseLV1SoftSkinBlock() // Reserve enough storage vert.mBoneWeights.reserve(numWeights); - for (unsigned int w = 0; w < numWeights;++w) - { - std::string bone; + std::string bone; + for (unsigned int w = 0; w < numWeights;++w) { + bone.clear(); ParseString(bone,"*MESH_SOFTSKINVERTS.Bone"); // Find the bone in the mesh's list std::pair me; me.first = -1; - for (unsigned int n = 0; n < curMesh->mBones.size();++n) - { - if (curMesh->mBones[n].mName == bone) - { + for (unsigned int n = 0; n < curMesh->mBones.size();++n) { + if (curMesh->mBones[n].mName == bone) { me.first = n; break; } } - if (-1 == me.first) - { + if (-1 == me.first) { // We don't have this bone yet, so add it to the list - me.first = (int)curMesh->mBones.size(); - curMesh->mBones.push_back(ASE::Bone(bone)); + me.first = static_cast( curMesh->mBones.size() ); + curMesh->mBones.push_back( ASE::Bone( bone ) ); } ParseLV4MeshFloat( me.second ); @@ -528,7 +528,7 @@ void Parser::ParseLV1MaterialListBlock() ParseLV4MeshLong(iMaterialCount); // now allocate enough storage to hold all materials - m_vMaterials.resize(iOldMaterialCount+iMaterialCount); + m_vMaterials.resize(iOldMaterialCount+iMaterialCount, Material("INVALID")); continue; } if (TokenMatch(filePtr,"MATERIAL",8)) @@ -706,7 +706,7 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat) ParseLV4MeshLong(iNumSubMaterials); // allocate enough storage - mat.avSubMaterials.resize(iNumSubMaterials); + mat.avSubMaterials.resize(iNumSubMaterials, Material("INVALID SUBMATERIAL")); } // submaterial chunks if (TokenMatch(filePtr,"SUBMATERIAL",11)) @@ -744,6 +744,7 @@ void Parser::ParseLV3MapBlock(Texture& map) // empty the texture won't be used later. // *********************************************************** bool parsePath = true; + std::string temp; while (true) { if ('*' == *filePtr) @@ -752,12 +753,12 @@ void Parser::ParseLV3MapBlock(Texture& map) // type of map if (TokenMatch(filePtr,"MAP_CLASS" ,9)) { - std::string temp; + temp.clear(); if(!ParseString(temp,"*MAP_CLASS")) SkipToNextToken(); if (temp != "Bitmap" && temp != "Normal Bump") { - DefaultLogger::get()->warn("ASE: Skipping unknown map type: " + temp); + ASSIMP_LOG_WARN_F("ASE: Skipping unknown map type: ", temp); parsePath = false; } continue; @@ -772,7 +773,7 @@ void Parser::ParseLV3MapBlock(Texture& map) { // Files with 'None' as map name are produced by // an Maja to ASE exporter which name I forgot .. - DefaultLogger::get()->warn("ASE: Skipping invalid map entry"); + ASSIMP_LOG_WARN("ASE: Skipping invalid map entry"); map.mMapName = ""; } @@ -1071,7 +1072,7 @@ void Parser::ParseLV2AnimationBlock(ASE::BaseNode& mesh) ( mesh.mType != BaseNode::Light || ((ASE::Light&)mesh).mLightType != ASE::Light::TARGET)) { - DefaultLogger::get()->error("ASE: Found target animation channel " + ASSIMP_LOG_ERROR("ASE: Found target animation channel " "but the node is neither a camera nor a spot light"); anim = NULL; } @@ -1097,7 +1098,7 @@ void Parser::ParseLV2AnimationBlock(ASE::BaseNode& mesh) if (!anim || anim == &mesh.mTargetAnim) { // Target animation channels may have no rotation channels - DefaultLogger::get()->error("ASE: Ignoring scaling channel in target animation"); + ASSIMP_LOG_ERROR("ASE: Ignoring scaling channel in target animation"); SkipSection(); } else ParseLV3ScaleAnimationBlock(*anim); @@ -1111,7 +1112,7 @@ void Parser::ParseLV2AnimationBlock(ASE::BaseNode& mesh) if (!anim || anim == &mesh.mTargetAnim) { // Target animation channels may have no rotation channels - DefaultLogger::get()->error("ASE: Ignoring rotation channel in target animation"); + ASSIMP_LOG_ERROR("ASE: Ignoring rotation channel in target animation"); SkipSection(); } else ParseLV3RotAnimationBlock(*anim); @@ -1294,12 +1295,14 @@ void Parser::ParseLV2NodeTransformBlock(ASE::BaseNode& mesh) { mode = 2; } - else DefaultLogger::get()->error("ASE: Ignoring target transform, " - "this is no spot light or target camera"); + else { + ASSIMP_LOG_ERROR("ASE: Ignoring target transform, " + "this is no spot light or target camera"); + } } else { - DefaultLogger::get()->error("ASE: Unknown node transformation: " + temp); + ASSIMP_LOG_ERROR("ASE: Unknown node transformation: " + temp); // mode = 0 } continue; @@ -1553,7 +1556,7 @@ void Parser::ParseLV3MeshWeightsBlock(ASE::Mesh& mesh) void Parser::ParseLV4MeshBones(unsigned int iNumBones,ASE::Mesh& mesh) { AI_ASE_PARSER_INIT(); - mesh.mBones.resize(iNumBones); + mesh.mBones.resize(iNumBones, Bone("UNNAMED")); while (true) { if ('*' == *filePtr) @@ -1915,7 +1918,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh& sMesh) else if (index == face.mIndices[2]) index = 2; else { - DefaultLogger::get()->error("ASE: Invalid vertex index in MESH_VERTEXNORMAL section"); + ASSIMP_LOG_ERROR("ASE: Invalid vertex index in MESH_VERTEXNORMAL section"); continue; } // We'll renormalize later @@ -1927,7 +1930,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh& sMesh) ParseLV4MeshFloatTriple(&vNormal.x,faceIdx); if (faceIdx >= sMesh.mFaces.size()) { - DefaultLogger::get()->error("ASE: Invalid vertex index in MESH_FACENORMAL section"); + ASSIMP_LOG_ERROR("ASE: Invalid vertex index in MESH_FACENORMAL section"); continue; } diff --git a/Engine/lib/assimp/code/ASEParser.h b/Engine/lib/assimp/code/ASEParser.h index db64f2a16..b8c820632 100644 --- a/Engine/lib/assimp/code/ASEParser.h +++ b/Engine/lib/assimp/code/ASEParser.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -52,8 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_3DS_IMPORTER // for some helper routines like IsSpace() -#include "ParsingUtils.h" -#include "qnan.h" +#include +#include // ASE is quite similar to 3ds. We can reuse some structures #include "3DSLoader.h" @@ -67,9 +68,51 @@ using namespace D3DS; /** Helper structure representing an ASE material */ struct Material : public D3DS::Material { - //! Default constructor - Material() : pcInstance(NULL), bNeed (false) - {} + //! Default constructor has been deleted + Material() = delete; + + //! Constructor with explicit name + explicit Material(const std::string &name) + : D3DS::Material(name) + , pcInstance(NULL) + , bNeed (false) { + // empty + } + + Material(const Material &other) = default; + Material &operator=(const Material &other) = default; + + + //! 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)) + { + other.pcInstance = nullptr; + } + + + Material &operator=(Material &&other) AI_NO_EXCEPT { + if (this == &other) { + return *this; + } + + D3DS::Material::operator=(std::move(other)); + + avSubMaterials = std::move(other.avSubMaterials); + pcInstance = std::move(other.pcInstance); + bNeed = std::move(other.bNeed); + + other.pcInstance = nullptr; + + return *this; + } + + + ~Material() {} + //! Contains all sub materials of this material std::vector avSubMaterials; @@ -83,19 +126,12 @@ struct Material : public D3DS::Material // --------------------------------------------------------------------------- /** Helper structure to represent an ASE file face */ -struct Face : public FaceWithSmoothingGroup -{ +struct Face : public FaceWithSmoothingGroup { //! Default constructor. Initializes everything with 0 - Face() - { - mColorIndices[0] = mColorIndices[1] = mColorIndices[2] = 0; - for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i) - { - amUVIndices[i][0] = amUVIndices[i][1] = amUVIndices[i][2] = 0; - } - - iMaterial = DEFAULT_MATINDEX; - iFace = 0; + Face() AI_NO_EXCEPT + : iMaterial(DEFAULT_MATINDEX) + , iFace(0) { + // empty } //! special value to indicate that no material index has @@ -103,8 +139,6 @@ struct Face : public FaceWithSmoothingGroup //! will replace this value later. static const unsigned int DEFAULT_MATINDEX = 0xFFFFFFFF; - - //! Indices into each list of texture coordinates unsigned int amUVIndices[AI_MAX_NUMBER_OF_TEXTURECOORDS][3]; @@ -122,23 +156,15 @@ struct Face : public FaceWithSmoothingGroup // --------------------------------------------------------------------------- /** Helper structure to represent an ASE file bone */ -struct Bone -{ +struct Bone { //! Constructor - Bone() - { - static int iCnt = 0; - - // Generate a default name for the bone - char szTemp[128]; - ::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - } + Bone() = delete; //! Construction from an existing name explicit Bone( const std::string& name) - : mName (name) - {} + : mName(name) { + // empty + } //! Name of the bone std::string mName; @@ -146,29 +172,22 @@ struct Bone // --------------------------------------------------------------------------- /** Helper structure to represent an ASE file bone vertex */ -struct BoneVertex -{ +struct BoneVertex { //! Bone and corresponding vertex weight. //! -1 for unrequired bones .... std::vector > mBoneWeights; - - //! Position of the bone vertex. - //! MUST be identical to the vertex position - //aiVector3D mPosition; }; // --------------------------------------------------------------------------- /** Helper structure to represent an ASE file animation */ -struct Animation -{ - enum Type - { +struct Animation { + enum Type { TRACK = 0x0, BEZIER = 0x1, TCB = 0x2 } mRotationType, mScalingType, mPositionType; - Animation() + Animation() AI_NO_EXCEPT : mRotationType (TRACK) , mScalingType (TRACK) , mPositionType (TRACK) @@ -182,19 +201,16 @@ struct Animation //! List of track scaling keyframes std::vector< aiVectorKey > akeyScaling; - }; // --------------------------------------------------------------------------- /** Helper structure to represent the inheritance information of an ASE node */ -struct InheritanceInfo -{ +struct InheritanceInfo { //! Default constructor - InheritanceInfo() - { - // set the inheritance flag for all axes by default to true - for (unsigned int i = 0; i < 3;++i) + InheritanceInfo() AI_NO_EXCEPT { + for ( size_t i=0; i<3; ++i ) { abInheritPosition[i] = abInheritRotation[i] = abInheritScaling[i] = true; + } } //! Inherit the parent's position?, axis order is x,y,z @@ -209,26 +225,25 @@ struct InheritanceInfo // --------------------------------------------------------------------------- /** Represents an ASE file node. Base class for mesh, light and cameras */ -struct BaseNode -{ - enum Type {Light, Camera, Mesh, Dummy} mType; - - //! Constructor. Creates a default name for the node - explicit BaseNode(Type _mType) - : mType (_mType) - , mProcessed (false) - { - // generate a default name for the node - static int iCnt = 0; - char szTemp[128]; // should be sufficiently large - ::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; +struct BaseNode { + enum Type { + Light, + Camera, + Mesh, + Dummy + } mType; + //! Construction from an existing name + 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; } + //! Name of the mesh std::string mName; @@ -258,19 +273,21 @@ struct BaseNode // --------------------------------------------------------------------------- /** Helper structure to represent an ASE file mesh */ -struct Mesh : public MeshWithSmoothingGroups, public BaseNode -{ - //! Constructor. - Mesh() - : BaseNode (BaseNode::Mesh) - , bSkip (false) - { - // use 2 texture vertex components by default - for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) - this->mNumUVComponents[c] = 2; +struct Mesh : public MeshWithSmoothingGroups, public BaseNode { + //! Default constructor has been deleted + Mesh() = delete; - // setup the default material index by default - iMaterialIndex = Face::DEFAULT_MATINDEX; + //! 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) { + this->mNumUVComponents[c] = 2; + } } //! List of all texture coordinate sets @@ -307,17 +324,21 @@ struct Light : public BaseNode DIRECTIONAL }; - //! Constructor. - Light() - : BaseNode (BaseNode::Light) - , mLightType (OMNI) - , mColor (1.f,1.f,1.f) - , mIntensity (1.f) // light is white by default - , mAngle (45.f) - , mFalloff (0.f) + //! Default constructor has been deleted + 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) { } + LightType mLightType; aiColor3D mColor; ai_real mIntensity; @@ -335,28 +356,32 @@ struct Camera : public BaseNode TARGET }; - //! Constructor - Camera() - : BaseNode (BaseNode::Camera) - , mFOV (0.75f) // in radians - , mNear (0.1f) - , mFar (1000.f) // could be zero - , mCameraType (FREE) + //! 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) { } + ai_real mFOV, mNear, mFar; CameraType mCameraType; }; // --------------------------------------------------------------------------- /** Helper structure to represent an ASE helper object (dummy) */ -struct Dummy : public BaseNode -{ +struct Dummy : public BaseNode { //! Constructor - Dummy() - : BaseNode (BaseNode::Dummy) - { + Dummy() AI_NO_EXCEPT + : BaseNode (BaseNode::Dummy, "DUMMY") { + // empty } }; @@ -371,18 +396,17 @@ struct Dummy : public BaseNode // ------------------------------------------------------------------------------- /** \brief Class to parse ASE files */ -class Parser -{ - +class Parser { private: - - Parser() {} + Parser() AI_NO_EXCEPT { + // empty + } public: // ------------------------------------------------------------------- //! Construct a parser from a given input file which is - //! guaranted to be terminated with zero. + //! guaranteed to be terminated with zero. //! @param szFile Input file //! @param fileFormatDefault Assumed file format version. If the //! file format is specified in the file the new value replaces diff --git a/Engine/lib/assimp/code/AssbinExporter.cpp b/Engine/lib/assimp/code/AssbinExporter.cpp index bcac2e08f..03b0368ce 100644 --- a/Engine/lib/assimp/code/AssbinExporter.cpp +++ b/Engine/lib/assimp/code/AssbinExporter.cpp @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -41,13 +42,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file AssbinExporter.cpp * ASSBIN exporter main code */ + +#ifndef ASSIMP_BUILD_NO_EXPORT +#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER + #include "assbin_chunks.h" #include #include #include #include #include "ProcessHelper.h" -#include "Exceptional.h" +#include #ifdef ASSIMP_BUILD_NO_OWN_ZLIB # include @@ -57,152 +62,154 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include - -#ifndef ASSIMP_BUILD_NO_EXPORT -#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER - -using namespace Assimp; - -namespace Assimp { +namespace Assimp { template -size_t Write(IOStream * stream, const T& v) -{ +size_t Write(IOStream * stream, const T& v) { return stream->Write( &v, sizeof(T), 1 ); } - // ----------------------------------------------------------------------------------- // Serialize an aiString template <> -inline size_t Write(IOStream * stream, const aiString& s) -{ +inline +size_t Write(IOStream * stream, const aiString& s) { const size_t s2 = (uint32_t)s.length; stream->Write(&s,4,1); stream->Write(s.data,s2,1); + return s2+4; } // ----------------------------------------------------------------------------------- // Serialize an unsigned int as uint32_t template <> -inline size_t Write(IOStream * stream, const unsigned int& w) -{ +inline +size_t Write(IOStream * stream, const unsigned int& w) { const uint32_t t = (uint32_t)w; if (w > t) { // this shouldn't happen, integers in Assimp data structures never exceed 2^32 - throw new DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion"); + throw DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion"); } stream->Write(&t,4,1); + return 4; } // ----------------------------------------------------------------------------------- // Serialize an unsigned int as uint16_t template <> -inline size_t Write(IOStream * stream, const uint16_t& w) -{ +inline +size_t Write(IOStream * stream, const uint16_t& w) { static_assert(sizeof(uint16_t)==2, "sizeof(uint16_t)==2"); stream->Write(&w,2,1); + return 2; } // ----------------------------------------------------------------------------------- // Serialize a float template <> -inline size_t Write(IOStream * stream, const float& f) -{ +inline +size_t Write(IOStream * stream, const float& f) { static_assert(sizeof(float)==4, "sizeof(float)==4"); stream->Write(&f,4,1); + return 4; } // ----------------------------------------------------------------------------------- // Serialize a double template <> -inline size_t Write(IOStream * stream, const double& f) -{ +inline +size_t Write(IOStream * stream, const double& f) { static_assert(sizeof(double)==8, "sizeof(double)==8"); stream->Write(&f,8,1); + return 8; } // ----------------------------------------------------------------------------------- // Serialize a vec3 template <> -inline size_t Write(IOStream * stream, const aiVector3D& v) -{ +inline +size_t Write(IOStream * stream, const aiVector3D& v) { size_t t = Write(stream,v.x); t += Write(stream,v.y); t += Write(stream,v.z); + return t; } // ----------------------------------------------------------------------------------- // Serialize a color value template <> -inline size_t Write(IOStream * stream, const aiColor3D& v) -{ +inline +size_t Write(IOStream * stream, const aiColor3D& v) { size_t t = Write(stream,v.r); t += Write(stream,v.g); t += Write(stream,v.b); + return t; } // ----------------------------------------------------------------------------------- // Serialize a color value template <> -inline size_t Write(IOStream * stream, const aiColor4D& v) -{ +inline +size_t Write(IOStream * stream, const aiColor4D& v) { size_t t = Write(stream,v.r); t += Write(stream,v.g); t += Write(stream,v.b); t += Write(stream,v.a); + return t; } // ----------------------------------------------------------------------------------- // Serialize a quaternion template <> -inline size_t Write(IOStream * stream, const aiQuaternion& v) -{ +inline +size_t Write(IOStream * stream, const aiQuaternion& v) { size_t t = Write(stream,v.w); t += Write(stream,v.x); t += Write(stream,v.y); t += Write(stream,v.z); ai_assert(t == 16); + return 16; } - // ----------------------------------------------------------------------------------- // Serialize a vertex weight template <> -inline size_t Write(IOStream * stream, const aiVertexWeight& v) -{ +inline +size_t Write(IOStream * stream, const aiVertexWeight& v) { size_t t = Write(stream,v.mVertexId); + return t+Write(stream,v.mWeight); } // ----------------------------------------------------------------------------------- // Serialize a mat4x4 template <> -inline size_t Write(IOStream * stream, const aiMatrix4x4& m) -{ +inline +size_t Write(IOStream * stream, const aiMatrix4x4& m) { for (unsigned int i = 0; i < 4;++i) { for (unsigned int i2 = 0; i2 < 4;++i2) { Write(stream,m[i][i2]); } } + return 64; } // ----------------------------------------------------------------------------------- // Serialize an aiVectorKey template <> -inline size_t Write(IOStream * stream, const aiVectorKey& v) -{ +inline +size_t Write(IOStream * stream, const aiVectorKey& v) { const size_t t = Write(stream,v.mTime); return t + Write(stream,v.mValue); } @@ -210,16 +217,16 @@ inline size_t Write(IOStream * stream, const aiVectorKey& v) // ----------------------------------------------------------------------------------- // Serialize an aiQuatKey template <> -inline size_t Write(IOStream * stream, const aiQuatKey& v) -{ +inline +size_t Write(IOStream * stream, const aiQuatKey& v) { const size_t t = Write(stream,v.mTime); return t + Write(stream,v.mValue); } template -inline size_t WriteBounds(IOStream * stream, const T* in, unsigned int size) -{ - T minc,maxc; +inline +size_t WriteBounds(IOStream * stream, const T* in, unsigned int size) { + T minc, maxc; ArrayBounds(in,size,minc,maxc); const size_t t = Write(stream,minc); @@ -229,590 +236,606 @@ inline size_t WriteBounds(IOStream * stream, const T* in, unsigned int size) // We use this to write out non-byte arrays so that we write using the specializations. // This way we avoid writing out extra bytes that potentially come from struct alignment. template -inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size) -{ +inline +size_t WriteArray(IOStream * stream, const T* in, unsigned int size) { size_t n = 0; for (unsigned int i=0; i(stream,in[i]); + return n; } - // ---------------------------------------------------------------------------------- - /** @class AssbinChunkWriter - * @brief Chunk writer mechanism for the .assbin file structure - * - * This is a standard in-memory IOStream (most of the code is based on BlobIOStream), - * the difference being that this takes another IOStream as a "container" in the - * constructor, and when it is destroyed, it appends the magic number, the chunk size, - * and the chunk contents to the container stream. This allows relatively easy chunk - * chunk construction, even recursively. - */ - class AssbinChunkWriter : public IOStream - { - private: - - uint8_t* buffer; - uint32_t magic; - IOStream * container; - size_t cur_size, cursor, initial; - - private: - // ------------------------------------------------------------------- - void Grow(size_t need = 0) - { - size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) )); - - const uint8_t* const old = buffer; - buffer = new uint8_t[new_size]; - - if (old) { - memcpy(buffer,old,cur_size); - delete[] old; - } - - cur_size = new_size; - } - - public: - - AssbinChunkWriter( IOStream * container, uint32_t magic, size_t initial = 4096) - : buffer(NULL), magic(magic), container(container), cur_size(0), cursor(0), initial(initial) - { - } - - virtual ~AssbinChunkWriter() - { - if (container) { - container->Write( &magic, sizeof(uint32_t), 1 ); - container->Write( &cursor, sizeof(uint32_t), 1 ); - container->Write( buffer, 1, cursor ); - } - if (buffer) delete[] buffer; - } - - void * GetBufferPointer() { return buffer; } - - // ------------------------------------------------------------------- - virtual size_t Read(void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) { return 0; } - virtual aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/) { return aiReturn_FAILURE; } - virtual size_t Tell() const { return cursor; } - virtual void Flush() { } - - virtual size_t FileSize() const - { - return cursor; - } - - // ------------------------------------------------------------------- - virtual size_t Write(const void* pvBuffer, size_t pSize, size_t pCount) - { - pSize *= pCount; - if (cursor + pSize > cur_size) { - Grow(cursor + pSize); - } - - memcpy(buffer+cursor, pvBuffer, pSize); - cursor += pSize; - - return pCount; - } - - }; - - // ---------------------------------------------------------------------------------- - /** @class AssbinExport - * @brief Assbin exporter class - * - * This class performs the .assbin exporting, and is responsible for the file layout. - */ - class AssbinExport - { - private: - bool shortened; - bool compressed; - - 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); - - Write(&chunk,node->mName); - Write(&chunk,node->mTransformation); - Write(&chunk,node->mNumChildren); - Write(&chunk,node->mNumMeshes); - Write(&chunk,nb_metadata); - - for (unsigned int i = 0; i < node->mNumMeshes;++i) { - Write(&chunk,node->mMeshes[i]); - } - - for (unsigned int i = 0; i < node->mNumChildren;++i) { - WriteBinaryNode( &chunk, node->mChildren[i] ); - } - - for (unsigned int i = 0; i < nb_metadata; ++i) { - const aiString& key = node->mMetaData->mKeys[i]; - aiMetadataType type = node->mMetaData->mValues[i].mType; - void* value = node->mMetaData->mValues[i].mData; - - Write(&chunk, key); - Write(&chunk, type); - - switch (type) { - case AI_BOOL: - Write(&chunk, *((bool*) value)); - break; - case AI_INT32: - Write(&chunk, *((int32_t*) value)); - break; - case AI_UINT64: - Write(&chunk, *((uint64_t*) value)); - break; - case AI_FLOAT: - Write(&chunk, *((float*) value)); - break; - case AI_DOUBLE: - Write(&chunk, *((double*) value)); - break; - case AI_AISTRING: - Write(&chunk, *((aiString*) value)); - break; - case AI_AIVECTOR3D: - Write(&chunk, *((aiVector3D*) value)); - break; -#ifdef SWIG - case FORCE_32BIT: -#endif // SWIG - default: - break; - } - } - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryTexture(IOStream * container, const aiTexture* tex) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AITEXTURE ); - - Write(&chunk,tex->mWidth); - Write(&chunk,tex->mHeight); - chunk.Write( tex->achFormatHint, sizeof(char), 4 ); - - if(!shortened) { - if (!tex->mHeight) { - chunk.Write(tex->pcData,1,tex->mWidth); - } - else { - chunk.Write(tex->pcData,1,tex->mWidth*tex->mHeight*4); - } - } - - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryBone(IOStream * container, const aiBone* b) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIBONE ); - - Write(&chunk,b->mName); - Write(&chunk,b->mNumWeights); - Write(&chunk,b->mOffsetMatrix); - - // for the moment we write dumb min/max values for the bones, too. - // maybe I'll add a better, hash-like solution later - if (shortened) { - WriteBounds(&chunk,b->mWeights,b->mNumWeights); - } // else write as usual - else WriteArray(&chunk,b->mWeights,b->mNumWeights); - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryMesh(IOStream * container, const aiMesh* mesh) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMESH ); - - Write(&chunk,mesh->mPrimitiveTypes); - Write(&chunk,mesh->mNumVertices); - Write(&chunk,mesh->mNumFaces); - Write(&chunk,mesh->mNumBones); - Write(&chunk,mesh->mMaterialIndex); - - // first of all, write bits for all existent vertex components - unsigned int c = 0; - if (mesh->mVertices) { - c |= ASSBIN_MESH_HAS_POSITIONS; - } - if (mesh->mNormals) { - c |= ASSBIN_MESH_HAS_NORMALS; - } - if (mesh->mTangents && mesh->mBitangents) { - c |= ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS; - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) { - if (!mesh->mTextureCoords[n]) { - break; - } - c |= ASSBIN_MESH_HAS_TEXCOORD(n); - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) { - if (!mesh->mColors[n]) { - break; - } - c |= ASSBIN_MESH_HAS_COLOR(n); - } - Write(&chunk,c); - - aiVector3D minVec, maxVec; - if (mesh->mVertices) { - if (shortened) { - WriteBounds(&chunk,mesh->mVertices,mesh->mNumVertices); - } // else write as usual - else WriteArray(&chunk,mesh->mVertices,mesh->mNumVertices); - } - if (mesh->mNormals) { - if (shortened) { - WriteBounds(&chunk,mesh->mNormals,mesh->mNumVertices); - } // else write as usual - else WriteArray(&chunk,mesh->mNormals,mesh->mNumVertices); - } - if (mesh->mTangents && mesh->mBitangents) { - if (shortened) { - WriteBounds(&chunk,mesh->mTangents,mesh->mNumVertices); - WriteBounds(&chunk,mesh->mBitangents,mesh->mNumVertices); - } // else write as usual - else { - WriteArray(&chunk,mesh->mTangents,mesh->mNumVertices); - WriteArray(&chunk,mesh->mBitangents,mesh->mNumVertices); - } - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) { - if (!mesh->mColors[n]) - break; - - if (shortened) { - WriteBounds(&chunk,mesh->mColors[n],mesh->mNumVertices); - } // else write as usual - else WriteArray(&chunk,mesh->mColors[n],mesh->mNumVertices); - } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) { - if (!mesh->mTextureCoords[n]) - break; - - // write number of UV components - Write(&chunk,mesh->mNumUVComponents[n]); - - if (shortened) { - WriteBounds(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices); - } // else write as usual - else WriteArray(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices); - } - - // write faces. There are no floating-point calculations involved - // in these, so we can write a simple hash over the face data - // to the dump file. We generate a single 32 Bit hash for 512 faces - // using Assimp's standard hashing function. - if (shortened) { - unsigned int processed = 0; - for (unsigned int job;(job = std::min(mesh->mNumFaces-processed,512u));processed += job) { - - uint32_t hash = 0; - for (unsigned int a = 0; a < job;++a) { - - const aiFace& f = mesh->mFaces[processed+a]; - uint32_t tmp = f.mNumIndices; - hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); - for (unsigned int i = 0; i < f.mNumIndices; ++i) { - static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff"); - tmp = static_cast( f.mIndices[i] ); - hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); - } - } - Write(&chunk,hash); - } - } - else // else write as usual - { - // if there are less than 2^16 vertices, we can simply use 16 bit integers ... - for (unsigned int i = 0; i < mesh->mNumFaces;++i) { - const aiFace& f = mesh->mFaces[i]; - - static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff"); - Write(&chunk,f.mNumIndices); - - for (unsigned int a = 0; a < f.mNumIndices;++a) { - if (mesh->mNumVertices < (1u<<16)) { - Write(&chunk,f.mIndices[a]); - } - else Write(&chunk,f.mIndices[a]); - } - } - } - - // write bones - if (mesh->mNumBones) { - for (unsigned int a = 0; a < mesh->mNumBones;++a) { - const aiBone* b = mesh->mBones[a]; - WriteBinaryBone(&chunk,b); - } - } - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryMaterialProperty(IOStream * container, const aiMaterialProperty* prop) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIALPROPERTY ); - - Write(&chunk,prop->mKey); - Write(&chunk,prop->mSemantic); - Write(&chunk,prop->mIndex); - - Write(&chunk,prop->mDataLength); - Write(&chunk,(unsigned int)prop->mType); - chunk.Write(prop->mData,1,prop->mDataLength); - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryMaterial(IOStream * container, const aiMaterial* mat) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIAL); - - Write(&chunk,mat->mNumProperties); - for (unsigned int i = 0; i < mat->mNumProperties;++i) { - WriteBinaryMaterialProperty( &chunk, mat->mProperties[i]); - } - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryNodeAnim(IOStream * container, const aiNodeAnim* nd) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODEANIM ); - - Write(&chunk,nd->mNodeName); - Write(&chunk,nd->mNumPositionKeys); - Write(&chunk,nd->mNumRotationKeys); - Write(&chunk,nd->mNumScalingKeys); - Write(&chunk,nd->mPreState); - Write(&chunk,nd->mPostState); - - if (nd->mPositionKeys) { - if (shortened) { - WriteBounds(&chunk,nd->mPositionKeys,nd->mNumPositionKeys); - - } // else write as usual - else WriteArray(&chunk,nd->mPositionKeys,nd->mNumPositionKeys); - } - if (nd->mRotationKeys) { - if (shortened) { - WriteBounds(&chunk,nd->mRotationKeys,nd->mNumRotationKeys); - - } // else write as usual - else WriteArray(&chunk,nd->mRotationKeys,nd->mNumRotationKeys); - } - if (nd->mScalingKeys) { - if (shortened) { - WriteBounds(&chunk,nd->mScalingKeys,nd->mNumScalingKeys); - - } // else write as usual - else WriteArray(&chunk,nd->mScalingKeys,nd->mNumScalingKeys); - } - } - - - // ----------------------------------------------------------------------------------- - void WriteBinaryAnim( IOStream * container, const aiAnimation* anim ) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIANIMATION ); - - Write(&chunk,anim->mName); - Write(&chunk,anim->mDuration); - Write(&chunk,anim->mTicksPerSecond); - Write(&chunk,anim->mNumChannels); - - for (unsigned int a = 0; a < anim->mNumChannels;++a) { - const aiNodeAnim* nd = anim->mChannels[a]; - WriteBinaryNodeAnim(&chunk,nd); - } - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryLight( IOStream * container, const aiLight* l ) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AILIGHT ); - - Write(&chunk,l->mName); - Write(&chunk,l->mType); - - if (l->mType != aiLightSource_DIRECTIONAL) { - Write(&chunk,l->mAttenuationConstant); - Write(&chunk,l->mAttenuationLinear); - Write(&chunk,l->mAttenuationQuadratic); - } - - Write(&chunk,l->mColorDiffuse); - Write(&chunk,l->mColorSpecular); - Write(&chunk,l->mColorAmbient); - - if (l->mType == aiLightSource_SPOT) { - Write(&chunk,l->mAngleInnerCone); - Write(&chunk,l->mAngleOuterCone); - } - - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryCamera( IOStream * container, const aiCamera* cam ) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AICAMERA ); - - Write(&chunk,cam->mName); - Write(&chunk,cam->mPosition); - Write(&chunk,cam->mLookAt); - Write(&chunk,cam->mUp); - Write(&chunk,cam->mHorizontalFOV); - Write(&chunk,cam->mClipPlaneNear); - Write(&chunk,cam->mClipPlaneFar); - Write(&chunk,cam->mAspect); - } - - // ----------------------------------------------------------------------------------- - void WriteBinaryScene( IOStream * container, const aiScene* scene) - { - AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AISCENE ); - - // basic scene information - Write(&chunk,scene->mFlags); - Write(&chunk,scene->mNumMeshes); - Write(&chunk,scene->mNumMaterials); - Write(&chunk,scene->mNumAnimations); - Write(&chunk,scene->mNumTextures); - Write(&chunk,scene->mNumLights); - Write(&chunk,scene->mNumCameras); - - // write node graph - WriteBinaryNode( &chunk, scene->mRootNode ); - - // write all meshes - for (unsigned int i = 0; i < scene->mNumMeshes;++i) { - const aiMesh* mesh = scene->mMeshes[i]; - WriteBinaryMesh( &chunk,mesh); - } - - // write materials - for (unsigned int i = 0; i< scene->mNumMaterials; ++i) { - const aiMaterial* mat = scene->mMaterials[i]; - WriteBinaryMaterial(&chunk,mat); - } - - // write all animations - for (unsigned int i = 0; i < scene->mNumAnimations;++i) { - const aiAnimation* anim = scene->mAnimations[i]; - WriteBinaryAnim(&chunk,anim); - } - - - // write all textures - for (unsigned int i = 0; i < scene->mNumTextures;++i) { - const aiTexture* mesh = scene->mTextures[i]; - WriteBinaryTexture(&chunk,mesh); - } - - // write lights - for (unsigned int i = 0; i < scene->mNumLights;++i) { - const aiLight* l = scene->mLights[i]; - WriteBinaryLight(&chunk,l); - } - - // write cameras - for (unsigned int i = 0; i < scene->mNumCameras;++i) { - const aiCamera* cam = scene->mCameras[i]; - WriteBinaryCamera(&chunk,cam); - } - - } - - public: - AssbinExport() - : shortened(false), compressed(false) // temporary settings until properties are introduced for exporters - { - } - - // ----------------------------------------------------------------------------------- - // Write a binary model dump - void WriteBinaryDump(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene) - { - IOStream * out = pIOSystem->Open( pFile, "wb" ); - if (!out) return; - - time_t tt = time(NULL); - tm* p = gmtime(&tt); - - // header - char s[64]; - memset( s, 0, 64 ); -#if _MSC_VER >= 1400 - sprintf_s(s,"ASSIMP.binary-dump.%s",asctime(p)); -#else - ai_snprintf(s,64,"ASSIMP.binary-dump.%s",asctime(p)); -#endif - out->Write( s, 44, 1 ); - // == 44 bytes - - Write( out, ASSBIN_VERSION_MAJOR ); - Write( out, ASSBIN_VERSION_MINOR ); - Write( out, aiGetVersionRevision() ); - Write( out, aiGetCompileFlags() ); - Write( out, shortened ); - Write( out, compressed ); - // == 20 bytes - - char buff[256]; - strncpy(buff,pFile,256); - out->Write(buff,sizeof(char),256); - - char cmd[] = "\0"; - strncpy(buff,cmd,128); - out->Write(buff,sizeof(char),128); - - // leave 64 bytes free for future extensions - memset(buff,0xcd,64); - out->Write(buff,sizeof(char),64); - // == 435 bytes - - // ==== total header size: 512 bytes - ai_assert( out->Tell() == ASSBIN_HEADER_LENGTH ); - - // 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 ); - WriteBinaryScene( &uncompressedStream, pScene ); - - uLongf uncompressedSize = static_cast(uncompressedStream.Tell()); - uLongf compressedSize = (uLongf)(uncompressedStream.Tell() * 1.001 + 12.); - uint8_t* compressedBuffer = new uint8_t[ compressedSize ]; - - compress2( compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9 ); - - out->Write( &uncompressedSize, sizeof(uint32_t), 1 ); - out->Write( compressedBuffer, sizeof(char), compressedSize ); - - delete[] compressedBuffer; - } - else - { - WriteBinaryScene( out, pScene ); - } - - pIOSystem->Close( out ); - } - }; - -void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) +// ---------------------------------------------------------------------------------- +/** @class AssbinChunkWriter + * @brief Chunk writer mechanism for the .assbin file structure + * + * This is a standard in-memory IOStream (most of the code is based on BlobIOStream), + * the difference being that this takes another IOStream as a "container" in the + * constructor, and when it is destroyed, it appends the magic number, the chunk size, + * and the chunk contents to the container stream. This allows relatively easy chunk + * chunk construction, even recursively. + */ +class AssbinChunkWriter : public IOStream { +private: + + uint8_t* buffer; + uint32_t magic; + IOStream * container; + size_t cur_size, cursor, initial; + +private: + // ------------------------------------------------------------------- + void Grow(size_t need = 0) + { + size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) )); + + const uint8_t* const old = buffer; + buffer = new uint8_t[new_size]; + + if (old) { + memcpy(buffer,old,cur_size); + delete[] old; + } + + cur_size = new_size; + } + +public: + + AssbinChunkWriter( IOStream * container, uint32_t magic, size_t initial = 4096) + : buffer(NULL), magic(magic), container(container), cur_size(0), cursor(0), initial(initial) + { + } + + virtual ~AssbinChunkWriter() + { + if (container) { + container->Write( &magic, sizeof(uint32_t), 1 ); + container->Write( &cursor, sizeof(uint32_t), 1 ); + container->Write( buffer, 1, cursor ); + } + if (buffer) delete[] buffer; + } + + void * GetBufferPointer() { return buffer; } + + // ------------------------------------------------------------------- + virtual size_t Read(void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) { + return 0; + } + virtual aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/) { + return aiReturn_FAILURE; + } + virtual size_t Tell() const { + return cursor; + } + virtual void Flush() { + // not implemented + } + + virtual size_t FileSize() const { + return cursor; + } + + // ------------------------------------------------------------------- + virtual size_t Write(const void* pvBuffer, size_t pSize, size_t pCount) { + pSize *= pCount; + if (cursor + pSize > cur_size) { + Grow(cursor + pSize); + } + + memcpy(buffer+cursor, pvBuffer, pSize); + cursor += pSize; + + return pCount; + } + +}; + +// ---------------------------------------------------------------------------------- +/** @class AssbinExport + * @brief Assbin exporter class + * + * This class performs the .assbin exporting, and is responsible for the file layout. + */ +class AssbinExport +{ +private: + bool shortened; + bool compressed; + +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); + + Write(&chunk,node->mName); + Write(&chunk,node->mTransformation); + Write(&chunk,node->mNumChildren); + Write(&chunk,node->mNumMeshes); + Write(&chunk,nb_metadata); + + for (unsigned int i = 0; i < node->mNumMeshes;++i) { + Write(&chunk,node->mMeshes[i]); + } + + for (unsigned int i = 0; i < node->mNumChildren;++i) { + WriteBinaryNode( &chunk, node->mChildren[i] ); + } + + for (unsigned int i = 0; i < nb_metadata; ++i) { + const aiString& key = node->mMetaData->mKeys[i]; + aiMetadataType type = node->mMetaData->mValues[i].mType; + void* value = node->mMetaData->mValues[i].mData; + + Write(&chunk, key); + Write(&chunk, type); + + switch (type) { + case AI_BOOL: + Write(&chunk, *((bool*) value)); + break; + case AI_INT32: + Write(&chunk, *((int32_t*) value)); + break; + case AI_UINT64: + Write(&chunk, *((uint64_t*) value)); + break; + case AI_FLOAT: + Write(&chunk, *((float*) value)); + break; + case AI_DOUBLE: + Write(&chunk, *((double*) value)); + break; + case AI_AISTRING: + Write(&chunk, *((aiString*) value)); + break; + case AI_AIVECTOR3D: + Write(&chunk, *((aiVector3D*) value)); + break; +#ifdef SWIG + case FORCE_32BIT: +#endif // SWIG + default: + break; + } + } + } + + // ----------------------------------------------------------------------------------- + void WriteBinaryTexture(IOStream * container, const aiTexture* tex) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AITEXTURE ); + + Write(&chunk,tex->mWidth); + Write(&chunk,tex->mHeight); + chunk.Write( tex->achFormatHint, sizeof(char), 4 ); + + if(!shortened) { + if (!tex->mHeight) { + chunk.Write(tex->pcData,1,tex->mWidth); + } + else { + chunk.Write(tex->pcData,1,tex->mWidth*tex->mHeight*4); + } + } + + } + + // ----------------------------------------------------------------------------------- + void WriteBinaryBone(IOStream * container, const aiBone* b) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIBONE ); + + Write(&chunk,b->mName); + Write(&chunk,b->mNumWeights); + Write(&chunk,b->mOffsetMatrix); + + // for the moment we write dumb min/max values for the bones, too. + // maybe I'll add a better, hash-like solution later + if (shortened) { + WriteBounds(&chunk,b->mWeights,b->mNumWeights); + } // else write as usual + else WriteArray(&chunk,b->mWeights,b->mNumWeights); + } + + // ----------------------------------------------------------------------------------- + void WriteBinaryMesh(IOStream * container, const aiMesh* mesh) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMESH ); + + Write(&chunk,mesh->mPrimitiveTypes); + Write(&chunk,mesh->mNumVertices); + Write(&chunk,mesh->mNumFaces); + Write(&chunk,mesh->mNumBones); + Write(&chunk,mesh->mMaterialIndex); + + // first of all, write bits for all existent vertex components + unsigned int c = 0; + if (mesh->mVertices) { + c |= ASSBIN_MESH_HAS_POSITIONS; + } + if (mesh->mNormals) { + c |= ASSBIN_MESH_HAS_NORMALS; + } + if (mesh->mTangents && mesh->mBitangents) { + c |= ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS; + } + for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) { + if (!mesh->mTextureCoords[n]) { + break; + } + c |= ASSBIN_MESH_HAS_TEXCOORD(n); + } + for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) { + if (!mesh->mColors[n]) { + break; + } + c |= ASSBIN_MESH_HAS_COLOR(n); + } + Write(&chunk,c); + + aiVector3D minVec, maxVec; + if (mesh->mVertices) { + if (shortened) { + WriteBounds(&chunk,mesh->mVertices,mesh->mNumVertices); + } // else write as usual + else WriteArray(&chunk,mesh->mVertices,mesh->mNumVertices); + } + if (mesh->mNormals) { + if (shortened) { + WriteBounds(&chunk,mesh->mNormals,mesh->mNumVertices); + } // else write as usual + else WriteArray(&chunk,mesh->mNormals,mesh->mNumVertices); + } + if (mesh->mTangents && mesh->mBitangents) { + if (shortened) { + WriteBounds(&chunk,mesh->mTangents,mesh->mNumVertices); + WriteBounds(&chunk,mesh->mBitangents,mesh->mNumVertices); + } // else write as usual + else { + WriteArray(&chunk,mesh->mTangents,mesh->mNumVertices); + WriteArray(&chunk,mesh->mBitangents,mesh->mNumVertices); + } + } + for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) { + if (!mesh->mColors[n]) + break; + + if (shortened) { + WriteBounds(&chunk,mesh->mColors[n],mesh->mNumVertices); + } // else write as usual + else WriteArray(&chunk,mesh->mColors[n],mesh->mNumVertices); + } + for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) { + if (!mesh->mTextureCoords[n]) + break; + + // write number of UV components + Write(&chunk,mesh->mNumUVComponents[n]); + + if (shortened) { + WriteBounds(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices); + } // else write as usual + else WriteArray(&chunk,mesh->mTextureCoords[n],mesh->mNumVertices); + } + + // write faces. There are no floating-point calculations involved + // in these, so we can write a simple hash over the face data + // to the dump file. We generate a single 32 Bit hash for 512 faces + // using Assimp's standard hashing function. + if (shortened) { + unsigned int processed = 0; + for (unsigned int job;(job = std::min(mesh->mNumFaces-processed,512u));processed += job) { + + uint32_t hash = 0; + for (unsigned int a = 0; a < job;++a) { + + const aiFace& f = mesh->mFaces[processed+a]; + uint32_t tmp = f.mNumIndices; + hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); + for (unsigned int i = 0; i < f.mNumIndices; ++i) { + static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff"); + tmp = static_cast( f.mIndices[i] ); + hash = SuperFastHash(reinterpret_cast(&tmp),sizeof tmp,hash); + } + } + Write(&chunk,hash); + } + } + else // else write as usual + { + // if there are less than 2^16 vertices, we can simply use 16 bit integers ... + for (unsigned int i = 0; i < mesh->mNumFaces;++i) { + const aiFace& f = mesh->mFaces[i]; + + static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff"); + Write(&chunk,f.mNumIndices); + + for (unsigned int a = 0; a < f.mNumIndices;++a) { + if (mesh->mNumVertices < (1u<<16)) { + Write(&chunk,f.mIndices[a]); + } + else Write(&chunk,f.mIndices[a]); + } + } + } + + // write bones + if (mesh->mNumBones) { + for (unsigned int a = 0; a < mesh->mNumBones;++a) { + const aiBone* b = mesh->mBones[a]; + WriteBinaryBone(&chunk,b); + } + } + } + + // ----------------------------------------------------------------------------------- + void WriteBinaryMaterialProperty(IOStream * container, const aiMaterialProperty* prop) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIALPROPERTY ); + + Write(&chunk,prop->mKey); + Write(&chunk,prop->mSemantic); + Write(&chunk,prop->mIndex); + + Write(&chunk,prop->mDataLength); + Write(&chunk,(unsigned int)prop->mType); + chunk.Write(prop->mData,1,prop->mDataLength); + } + + // ----------------------------------------------------------------------------------- + void WriteBinaryMaterial(IOStream * container, const aiMaterial* mat) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIMATERIAL); + + Write(&chunk,mat->mNumProperties); + for (unsigned int i = 0; i < mat->mNumProperties;++i) { + WriteBinaryMaterialProperty( &chunk, mat->mProperties[i]); + } + } + + // ----------------------------------------------------------------------------------- + void WriteBinaryNodeAnim(IOStream * container, const aiNodeAnim* nd) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODEANIM ); + + Write(&chunk,nd->mNodeName); + Write(&chunk,nd->mNumPositionKeys); + Write(&chunk,nd->mNumRotationKeys); + Write(&chunk,nd->mNumScalingKeys); + Write(&chunk,nd->mPreState); + Write(&chunk,nd->mPostState); + + if (nd->mPositionKeys) { + if (shortened) { + WriteBounds(&chunk,nd->mPositionKeys,nd->mNumPositionKeys); + + } // else write as usual + else WriteArray(&chunk,nd->mPositionKeys,nd->mNumPositionKeys); + } + if (nd->mRotationKeys) { + if (shortened) { + WriteBounds(&chunk,nd->mRotationKeys,nd->mNumRotationKeys); + + } // else write as usual + else WriteArray(&chunk,nd->mRotationKeys,nd->mNumRotationKeys); + } + if (nd->mScalingKeys) { + if (shortened) { + WriteBounds(&chunk,nd->mScalingKeys,nd->mNumScalingKeys); + + } // else write as usual + else WriteArray(&chunk,nd->mScalingKeys,nd->mNumScalingKeys); + } + } + + + // ----------------------------------------------------------------------------------- + void WriteBinaryAnim( IOStream * container, const aiAnimation* anim ) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AIANIMATION ); + + Write(&chunk,anim->mName); + Write(&chunk,anim->mDuration); + Write(&chunk,anim->mTicksPerSecond); + Write(&chunk,anim->mNumChannels); + + for (unsigned int a = 0; a < anim->mNumChannels;++a) { + const aiNodeAnim* nd = anim->mChannels[a]; + WriteBinaryNodeAnim(&chunk,nd); + } + } + + // ----------------------------------------------------------------------------------- + void WriteBinaryLight( IOStream * container, const aiLight* l ) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AILIGHT ); + + Write(&chunk,l->mName); + Write(&chunk,l->mType); + + if (l->mType != aiLightSource_DIRECTIONAL) { + Write(&chunk,l->mAttenuationConstant); + Write(&chunk,l->mAttenuationLinear); + Write(&chunk,l->mAttenuationQuadratic); + } + + Write(&chunk,l->mColorDiffuse); + Write(&chunk,l->mColorSpecular); + Write(&chunk,l->mColorAmbient); + + if (l->mType == aiLightSource_SPOT) { + Write(&chunk,l->mAngleInnerCone); + Write(&chunk,l->mAngleOuterCone); + } + + } + + // ----------------------------------------------------------------------------------- + void WriteBinaryCamera( IOStream * container, const aiCamera* cam ) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AICAMERA ); + + Write(&chunk,cam->mName); + Write(&chunk,cam->mPosition); + Write(&chunk,cam->mLookAt); + Write(&chunk,cam->mUp); + Write(&chunk,cam->mHorizontalFOV); + Write(&chunk,cam->mClipPlaneNear); + Write(&chunk,cam->mClipPlaneFar); + Write(&chunk,cam->mAspect); + } + + // ----------------------------------------------------------------------------------- + void WriteBinaryScene( IOStream * container, const aiScene* scene) + { + AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AISCENE ); + + // basic scene information + Write(&chunk,scene->mFlags); + Write(&chunk,scene->mNumMeshes); + Write(&chunk,scene->mNumMaterials); + Write(&chunk,scene->mNumAnimations); + Write(&chunk,scene->mNumTextures); + Write(&chunk,scene->mNumLights); + Write(&chunk,scene->mNumCameras); + + // write node graph + WriteBinaryNode( &chunk, scene->mRootNode ); + + // write all meshes + for (unsigned int i = 0; i < scene->mNumMeshes;++i) { + const aiMesh* mesh = scene->mMeshes[i]; + WriteBinaryMesh( &chunk,mesh); + } + + // write materials + for (unsigned int i = 0; i< scene->mNumMaterials; ++i) { + const aiMaterial* mat = scene->mMaterials[i]; + WriteBinaryMaterial(&chunk,mat); + } + + // write all animations + for (unsigned int i = 0; i < scene->mNumAnimations;++i) { + const aiAnimation* anim = scene->mAnimations[i]; + WriteBinaryAnim(&chunk,anim); + } + + + // write all textures + for (unsigned int i = 0; i < scene->mNumTextures;++i) { + const aiTexture* mesh = scene->mTextures[i]; + WriteBinaryTexture(&chunk,mesh); + } + + // write lights + for (unsigned int i = 0; i < scene->mNumLights;++i) { + const aiLight* l = scene->mLights[i]; + WriteBinaryLight(&chunk,l); + } + + // write cameras + for (unsigned int i = 0; i < scene->mNumCameras;++i) { + const aiCamera* cam = scene->mCameras[i]; + WriteBinaryCamera(&chunk,cam); + } + + } + +public: + AssbinExport() + : shortened(false), compressed(false) // temporary settings until properties are introduced for exporters + { + } + + // ----------------------------------------------------------------------------------- + // Write a binary model dump + void WriteBinaryDump(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene) + { + IOStream * out = pIOSystem->Open( pFile, "wb" ); + if (!out) return; + + time_t tt = time(NULL); +#if _WIN32 + tm* p = gmtime(&tt); +#else + struct tm now; + tm* p = gmtime_r(&tt, &now); +#endif + + // header + char s[64]; + memset( s, 0, 64 ); +#if _MSC_VER >= 1400 + sprintf_s(s,"ASSIMP.binary-dump.%s",asctime(p)); +#else + ai_snprintf(s,64,"ASSIMP.binary-dump.%s",asctime(p)); +#endif + out->Write( s, 44, 1 ); + // == 44 bytes + + Write( out, ASSBIN_VERSION_MAJOR ); + Write( out, ASSBIN_VERSION_MINOR ); + Write( out, aiGetVersionRevision() ); + Write( out, aiGetCompileFlags() ); + Write( out, shortened ); + Write( out, compressed ); + // == 20 bytes + + char buff[256]; + strncpy(buff,pFile,256); + out->Write(buff,sizeof(char),256); + + char cmd[] = "\0"; + strncpy(buff,cmd,128); + out->Write(buff,sizeof(char),128); + + // leave 64 bytes free for future extensions + memset(buff,0xcd,64); + out->Write(buff,sizeof(char),64); + // == 435 bytes + + // ==== total header size: 512 bytes + ai_assert( out->Tell() == ASSBIN_HEADER_LENGTH ); + + // 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 ); + WriteBinaryScene( &uncompressedStream, pScene ); + + uLongf uncompressedSize = static_cast(uncompressedStream.Tell()); + uLongf compressedSize = (uLongf)compressBound(uncompressedSize); + uint8_t* compressedBuffer = new uint8_t[ compressedSize ]; + + int res = compress2( compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9 ); + if(res != Z_OK) + { + delete [] compressedBuffer; + pIOSystem->Close(out); + throw DeadlyExportError("Compression failed."); + } + + out->Write( &uncompressedSize, sizeof(uint32_t), 1 ); + out->Write( compressedBuffer, sizeof(char), compressedSize ); + + delete[] compressedBuffer; + } + else + { + WriteBinaryScene( out, pScene ); + } + + pIOSystem->Close( out ); + } +}; + +void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { AssbinExport exporter; exporter.WriteBinaryDump( pFile, pIOSystem, pScene ); } diff --git a/Engine/lib/assimp/code/AssbinExporter.h b/Engine/lib/assimp/code/AssbinExporter.h index 55bb9fc82..3e13639bb 100644 --- a/Engine/lib/assimp/code/AssbinExporter.h +++ b/Engine/lib/assimp/code/AssbinExporter.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -45,6 +46,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_ASSBINEXPORTER_H_INC #define AI_ASSBINEXPORTER_H_INC -// nothing really needed here - reserved for future use like properties +#include -#endif +// nothing really needed here - reserved for future use like properties +namespace Assimp { + +void ASSIMP_API ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/); + +} + +#endif // AI_ASSBINEXPORTER_H_INC diff --git a/Engine/lib/assimp/code/AssbinLoader.cpp b/Engine/lib/assimp/code/AssbinLoader.cpp index a7044c119..7adb8db6f 100644 --- a/Engine/lib/assimp/code/AssbinLoader.cpp +++ b/Engine/lib/assimp/code/AssbinLoader.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -51,11 +52,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // internal headers #include "AssbinLoader.h" #include "assbin_chunks.h" -#include "MemoryIOWrapper.h" +#include #include #include #include #include +#include #ifdef ASSIMP_BUILD_NO_OWN_ZLIB # include @@ -78,16 +80,17 @@ static const aiImporterDesc desc = { "assbin" }; -const aiImporterDesc* AssbinImporter::GetInfo() const -{ +// ----------------------------------------------------------------------------------- +const aiImporterDesc* AssbinImporter::GetInfo() const { return &desc; } -bool AssbinImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/ ) const -{ +// ----------------------------------------------------------------------------------- +bool AssbinImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/ ) const { IOStream * in = pIOHandler->Open(pFile); - if (!in) + if (nullptr == in) { return false; + } char s[32]; in->Read( s, sizeof(char), 32 ); @@ -97,17 +100,19 @@ bool AssbinImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bo return strncmp( s, "ASSIMP.binary-dump.", 19 ) == 0; } +// ----------------------------------------------------------------------------------- template -T Read(IOStream * stream) -{ +T Read(IOStream * stream) { T t; - stream->Read( &t, sizeof(T), 1 ); + size_t res = stream->Read( &t, sizeof(T), 1 ); + if(res != 1) + throw DeadlyImportError("Unexpected EOF"); return t; } +// ----------------------------------------------------------------------------------- template <> -aiVector3D Read(IOStream * stream) -{ +aiVector3D Read(IOStream * stream) { aiVector3D v; v.x = Read(stream); v.y = Read(stream); @@ -115,9 +120,9 @@ aiVector3D Read(IOStream * stream) return v; } +// ----------------------------------------------------------------------------------- template <> -aiColor4D Read(IOStream * stream) -{ +aiColor4D Read(IOStream * stream) { aiColor4D c; c.r = Read(stream); c.g = Read(stream); @@ -126,9 +131,9 @@ aiColor4D Read(IOStream * stream) return c; } +// ----------------------------------------------------------------------------------- template <> -aiQuaternion Read(IOStream * stream) -{ +aiQuaternion Read(IOStream * stream) { aiQuaternion v; v.w = Read(stream); v.x = Read(stream); @@ -137,28 +142,29 @@ aiQuaternion Read(IOStream * stream) return v; } +// ----------------------------------------------------------------------------------- template <> -aiString Read(IOStream * stream) -{ +aiString Read(IOStream * stream) { aiString s; stream->Read(&s.length,4,1); - stream->Read(s.data,s.length,1); + if(s.length) + stream->Read(s.data,s.length,1); s.data[s.length] = 0; return s; } +// ----------------------------------------------------------------------------------- template <> -aiVertexWeight Read(IOStream * stream) -{ +aiVertexWeight Read(IOStream * stream) { aiVertexWeight w; w.mVertexId = Read(stream); w.mWeight = Read(stream); return w; } +// ----------------------------------------------------------------------------------- template <> -aiMatrix4x4 Read(IOStream * stream) -{ +aiMatrix4x4 Read(IOStream * stream) { aiMatrix4x4 m; for (unsigned int i = 0; i < 4;++i) { for (unsigned int i2 = 0; i2 < 4;++i2) { @@ -168,76 +174,85 @@ aiMatrix4x4 Read(IOStream * stream) return m; } +// ----------------------------------------------------------------------------------- template <> -aiVectorKey Read(IOStream * stream) -{ +aiVectorKey Read(IOStream * stream) { aiVectorKey v; v.mTime = Read(stream); v.mValue = Read(stream); return v; } +// ----------------------------------------------------------------------------------- template <> -aiQuatKey Read(IOStream * stream) -{ +aiQuatKey Read(IOStream * stream) { aiQuatKey v; v.mTime = Read(stream); v.mValue = Read(stream); return v; } +// ----------------------------------------------------------------------------------- template -void ReadArray(IOStream * stream, T * out, unsigned int size) -{ - for (unsigned int i=0; i(stream); +void ReadArray( IOStream *stream, T * out, unsigned int size) { + ai_assert( nullptr != stream ); + ai_assert( nullptr != out ); + + for (unsigned int i=0; i(stream); + } } -template void ReadBounds( IOStream * stream, T* /*p*/, unsigned int n ) -{ +// ----------------------------------------------------------------------------------- +template +void ReadBounds( IOStream * stream, T* /*p*/, unsigned int n ) { // not sure what to do here, the data isn't really useful. stream->Seek( sizeof(T) * n, aiOrigin_CUR ); } -void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* parent ) { - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AINODE); +// ----------------------------------------------------------------------------------- +void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** onode, aiNode* parent ) { + if(Read(stream) != ASSBIN_CHUNK_AINODE) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); - *node = new aiNode(); + std::unique_ptr node(new aiNode()); - (*node)->mName = Read(stream); - (*node)->mTransformation = Read(stream); - (*node)->mNumChildren = Read(stream); - (*node)->mNumMeshes = Read(stream); + node->mName = Read(stream); + node->mTransformation = Read(stream); + unsigned numChildren = Read(stream); + unsigned numMeshes = Read(stream); unsigned int nb_metadata = Read(stream); if(parent) { - (*node)->mParent = parent; + node->mParent = parent; } - if ((*node)->mNumMeshes) { - (*node)->mMeshes = new unsigned int[(*node)->mNumMeshes]; - for (unsigned int i = 0; i < (*node)->mNumMeshes; ++i) { - (*node)->mMeshes[i] = Read(stream); + if (numMeshes) + { + node->mMeshes = new unsigned int[numMeshes]; + for (unsigned int i = 0; i < numMeshes; ++i) { + node->mMeshes[i] = Read(stream); + node->mNumMeshes++; } } - if ((*node)->mNumChildren) { - (*node)->mChildren = new aiNode*[(*node)->mNumChildren]; - for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) { - ReadBinaryNode( stream, &(*node)->mChildren[i], *node ); + if (numChildren) { + node->mChildren = new aiNode*[numChildren]; + for (unsigned int i = 0; i < numChildren; ++i) { + ReadBinaryNode( stream, &node->mChildren[i], node.get() ); + node->mNumChildren++; } } if ( nb_metadata > 0 ) { - (*node)->mMetaData = aiMetadata::Alloc(nb_metadata); + node->mMetaData = aiMetadata::Alloc(nb_metadata); for (unsigned int i = 0; i < nb_metadata; ++i) { - (*node)->mMetaData->mKeys[i] = Read(stream); - (*node)->mMetaData->mValues[i].mType = (aiMetadataType) Read(stream); - void* data( nullptr ); + node->mMetaData->mKeys[i] = Read(stream); + node->mMetaData->mValues[i].mType = (aiMetadataType) Read(stream); + void* data = nullptr; - switch ((*node)->mMetaData->mValues[i].mType) { + switch (node->mMetaData->mValues[i].mType) { case AI_BOOL: data = new bool(Read(stream)); break; @@ -266,17 +281,16 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* p break; } - (*node)->mMetaData->mValues[i].mData = data; + node->mMetaData->mValues[i].mData = data; } } + *onode = node.release(); } // ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIBONE); +void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) { + if(Read(stream) != ASSBIN_CHUNK_AIBONE) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); b->mName = Read(stream); @@ -285,23 +299,23 @@ void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) // for the moment we write dumb min/max values for the bones, too. // maybe I'll add a better, hash-like solution later - if (shortened) - { + if (shortened) { ReadBounds(stream,b->mWeights,b->mNumWeights); - } // else write as usual - else - { + } else { + // else write as usual b->mWeights = new aiVertexWeight[b->mNumWeights]; ReadArray(stream,b->mWeights,b->mNumWeights); } } - -void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIMESH); +// ----------------------------------------------------------------------------------- +static bool fitsIntoUI16(unsigned int mNumVertices) { + return ( mNumVertices < (1u<<16) ); +} +// ----------------------------------------------------------------------------------- +void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) { + if(Read(stream) != ASSBIN_CHUNK_AIMESH) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); mesh->mPrimitiveTypes = Read(stream); @@ -313,70 +327,61 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) // first of all, write bits for all existent vertex components unsigned int c = Read(stream); - if (c & ASSBIN_MESH_HAS_POSITIONS) - { + if (c & ASSBIN_MESH_HAS_POSITIONS) { if (shortened) { ReadBounds(stream,mesh->mVertices,mesh->mNumVertices); - } // else write as usual - else - { + } else { + // else write as usual mesh->mVertices = new aiVector3D[mesh->mNumVertices]; ReadArray(stream,mesh->mVertices,mesh->mNumVertices); } } - if (c & ASSBIN_MESH_HAS_NORMALS) - { + if (c & ASSBIN_MESH_HAS_NORMALS) { if (shortened) { ReadBounds(stream,mesh->mNormals,mesh->mNumVertices); - } // else write as usual - else - { + } else { + // else write as usual mesh->mNormals = new aiVector3D[mesh->mNumVertices]; ReadArray(stream,mesh->mNormals,mesh->mNumVertices); } } - if (c & ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS) - { + if (c & ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS) { if (shortened) { ReadBounds(stream,mesh->mTangents,mesh->mNumVertices); ReadBounds(stream,mesh->mBitangents,mesh->mNumVertices); - } // else write as usual - else - { + } else { + // else write as usual mesh->mTangents = new aiVector3D[mesh->mNumVertices]; ReadArray(stream,mesh->mTangents,mesh->mNumVertices); mesh->mBitangents = new aiVector3D[mesh->mNumVertices]; ReadArray(stream,mesh->mBitangents,mesh->mNumVertices); } } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) - { - if (!(c & ASSBIN_MESH_HAS_COLOR(n))) + for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) { + if (!(c & ASSBIN_MESH_HAS_COLOR(n))) { break; + } - if (shortened) - { + if (shortened) { ReadBounds(stream,mesh->mColors[n],mesh->mNumVertices); - } // else write as usual - else - { + } else { + // else write as usual mesh->mColors[n] = new aiColor4D[mesh->mNumVertices]; ReadArray(stream,mesh->mColors[n],mesh->mNumVertices); } } - for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) - { - if (!(c & ASSBIN_MESH_HAS_TEXCOORD(n))) + for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) { + if (!(c & ASSBIN_MESH_HAS_TEXCOORD(n))) { break; + } // write number of UV components mesh->mNumUVComponents[n] = Read(stream); if (shortened) { ReadBounds(stream,mesh->mTextureCoords[n],mesh->mNumVertices); - } // else write as usual - else - { + } else { + // else write as usual mesh->mTextureCoords[n] = new aiVector3D[mesh->mNumVertices]; ReadArray(stream,mesh->mTextureCoords[n],mesh->mNumVertices); } @@ -388,9 +393,8 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) // using Assimp's standard hashing function. if (shortened) { Read(stream); - } - else // else write as usual - { + } else { + // else write as usual // if there are less than 2^16 vertices, we can simply use 16 bit integers ... mesh->mFaces = new aiFace[mesh->mNumFaces]; for (unsigned int i = 0; i < mesh->mNumFaces;++i) { @@ -401,12 +405,10 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) f.mIndices = new unsigned int[f.mNumIndices]; for (unsigned int a = 0; a < f.mNumIndices;++a) { - if (mesh->mNumVertices < (1u<<16)) - { + // Check if unsigned short ( 16 bit ) are big enought for the indices + if ( fitsIntoUI16( mesh->mNumVertices ) ) { f.mIndices[a] = Read(stream); - } - else - { + } else { f.mIndices[a] = Read(stream); } } @@ -423,11 +425,10 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) } } -void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIALPROPERTY); +// ----------------------------------------------------------------------------------- +void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop) { + if(Read(stream) != ASSBIN_CHUNK_AIMATERIALPROPERTY) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); prop->mKey = Read(stream); @@ -441,11 +442,9 @@ void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialPro } // ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIAL); +void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) { + if(Read(stream) != ASSBIN_CHUNK_AIMATERIAL) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); mat->mNumAllocated = mat->mNumProperties = Read(stream); @@ -464,11 +463,9 @@ void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) } // ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AINODEANIM); +void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) { + if(Read(stream) != ASSBIN_CHUNK_AINODEANIM) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); nd->mNodeName = Read(stream); @@ -492,9 +489,8 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) if (shortened) { ReadBounds(stream,nd->mRotationKeys,nd->mNumRotationKeys); - } // else write as usual - else - { + } else { + // else write as usual nd->mRotationKeys = new aiQuatKey[nd->mNumRotationKeys]; ReadArray(stream,nd->mRotationKeys,nd->mNumRotationKeys); } @@ -503,22 +499,18 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) if (shortened) { ReadBounds(stream,nd->mScalingKeys,nd->mNumScalingKeys); - } // else write as usual - else - { + } else { + // else write as usual nd->mScalingKeys = new aiVectorKey[nd->mNumScalingKeys]; ReadArray(stream,nd->mScalingKeys,nd->mNumScalingKeys); } } } - // ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AIANIMATION); +void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) { + if(Read(stream) != ASSBIN_CHUNK_AIANIMATION) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); anim->mName = Read (stream); @@ -526,8 +518,7 @@ void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) anim->mTicksPerSecond = Read (stream); anim->mNumChannels = Read(stream); - if (anim->mNumChannels) - { + if (anim->mNumChannels) { anim->mChannels = new aiNodeAnim*[ anim->mNumChannels ]; for (unsigned int a = 0; a < anim->mNumChannels;++a) { anim->mChannels[a] = new aiNodeAnim(); @@ -536,11 +527,10 @@ void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) } } -void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AITEXTURE); +// ----------------------------------------------------------------------------------- +void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) { + if(Read(stream) != ASSBIN_CHUNK_AITEXTURE) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); tex->mWidth = Read(stream); @@ -551,21 +541,17 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) if (!tex->mHeight) { tex->pcData = new aiTexel[ tex->mWidth ]; stream->Read(tex->pcData,1,tex->mWidth); - } - else { + } else { tex->pcData = new aiTexel[ tex->mWidth*tex->mHeight ]; stream->Read(tex->pcData,1,tex->mWidth*tex->mHeight*4); } } - } // ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AILIGHT); +void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) { + if(Read(stream) != ASSBIN_CHUNK_AILIGHT) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); l->mName = Read(stream); @@ -585,15 +571,12 @@ void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) l->mAngleInnerCone = Read(stream); l->mAngleOuterCone = Read(stream); } - } // ----------------------------------------------------------------------------------- -void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AICAMERA); +void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) { + if(Read(stream) != ASSBIN_CHUNK_AICAMERA) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); cam->mName = Read(stream); @@ -606,11 +589,10 @@ void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) cam->mAspect = Read(stream); } -void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) -{ - uint32_t chunkID = Read(stream); - (void)(chunkID); - ai_assert(chunkID == ASSBIN_CHUNK_AISCENE); +// ----------------------------------------------------------------------------------- +void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) { + if(Read(stream) != ASSBIN_CHUNK_AISCENE) + throw DeadlyImportError("Magic chunk identifiers are wrong!"); /*uint32_t size =*/ Read(stream); scene->mFlags = Read(stream); @@ -622,13 +604,13 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) scene->mNumCameras = Read(stream); // Read node graph - scene->mRootNode = new aiNode[1]; + //scene->mRootNode = new aiNode[1]; ReadBinaryNode( stream, &scene->mRootNode, (aiNode*)NULL ); // Read all meshes - if (scene->mNumMeshes) - { + if (scene->mNumMeshes) { scene->mMeshes = new aiMesh*[scene->mNumMeshes]; + memset(scene->mMeshes, 0, scene->mNumMeshes*sizeof(aiMesh*)); for (unsigned int i = 0; i < scene->mNumMeshes;++i) { scene->mMeshes[i] = new aiMesh(); ReadBinaryMesh( stream,scene->mMeshes[i]); @@ -636,9 +618,9 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) } // Read materials - if (scene->mNumMaterials) - { + if (scene->mNumMaterials) { scene->mMaterials = new aiMaterial*[scene->mNumMaterials]; + memset(scene->mMaterials, 0, scene->mNumMaterials*sizeof(aiMaterial*)); for (unsigned int i = 0; i< scene->mNumMaterials; ++i) { scene->mMaterials[i] = new aiMaterial(); ReadBinaryMaterial(stream,scene->mMaterials[i]); @@ -646,9 +628,9 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) } // Read all animations - if (scene->mNumAnimations) - { + if (scene->mNumAnimations) { scene->mAnimations = new aiAnimation*[scene->mNumAnimations]; + memset(scene->mAnimations, 0, scene->mNumAnimations*sizeof(aiAnimation*)); for (unsigned int i = 0; i < scene->mNumAnimations;++i) { scene->mAnimations[i] = new aiAnimation(); ReadBinaryAnim(stream,scene->mAnimations[i]); @@ -656,9 +638,9 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) } // Read all textures - if (scene->mNumTextures) - { + if (scene->mNumTextures) { scene->mTextures = new aiTexture*[scene->mNumTextures]; + memset(scene->mTextures, 0, scene->mNumTextures*sizeof(aiTexture*)); for (unsigned int i = 0; i < scene->mNumTextures;++i) { scene->mTextures[i] = new aiTexture(); ReadBinaryTexture(stream,scene->mTextures[i]); @@ -666,9 +648,9 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) } // Read lights - if (scene->mNumLights) - { + if (scene->mNumLights) { scene->mLights = new aiLight*[scene->mNumLights]; + memset(scene->mLights, 0, scene->mNumLights*sizeof(aiLight*)); for (unsigned int i = 0; i < scene->mNumLights;++i) { scene->mLights[i] = new aiLight(); ReadBinaryLight(stream,scene->mLights[i]); @@ -676,9 +658,9 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) } // Read cameras - if (scene->mNumCameras) - { + if (scene->mNumCameras) { scene->mCameras = new aiCamera*[scene->mNumCameras]; + memset(scene->mCameras, 0, scene->mNumCameras*sizeof(aiCamera*)); for (unsigned int i = 0; i < scene->mNumCameras;++i) { scene->mCameras[i] = new aiCamera(); ReadBinaryCamera(stream,scene->mCameras[i]); @@ -687,16 +669,22 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) } -void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler ) -{ +// ----------------------------------------------------------------------------------- +void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler ) { IOStream * stream = pIOHandler->Open(pFile,"rb"); - if (!stream) + if (nullptr == stream) { return; + } - stream->Seek( 44, aiOrigin_CUR ); // signature + // signature + stream->Seek( 44, aiOrigin_CUR ); + + unsigned int versionMajor = Read(stream); + unsigned int versionMinor = Read(stream); + if (versionMinor != ASSBIN_VERSION_MINOR || versionMajor != ASSBIN_VERSION_MAJOR) { + throw DeadlyImportError( "Invalid version, data format not compatible!" ); + } - /*unsigned int versionMajor =*/ Read(stream); - /*unsigned int versionMinor =*/ Read(stream); /*unsigned int versionRevision =*/ Read(stream); /*unsigned int compileFlags =*/ Read(stream); @@ -710,17 +698,24 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene, stream->Seek( 128, aiOrigin_CUR ); // options stream->Seek( 64, aiOrigin_CUR ); // padding - if (compressed) - { + if (compressed) { uLongf uncompressedSize = Read(stream); uLongf compressedSize = static_cast(stream->FileSize() - stream->Tell()); unsigned char * compressedData = new unsigned char[ compressedSize ]; - stream->Read( compressedData, 1, compressedSize ); + size_t len = stream->Read( compressedData, 1, compressedSize ); + ai_assert(len == compressedSize); unsigned char * uncompressedData = new unsigned char[ uncompressedSize ]; - uncompress( uncompressedData, &uncompressedSize, compressedData, compressedSize ); + int res = uncompress( uncompressedData, &uncompressedSize, compressedData, len ); + if(res != Z_OK) + { + delete [] uncompressedData; + delete [] compressedData; + pIOHandler->Close(stream); + throw DeadlyImportError("Zlib decompression failed."); + } MemoryIOStream io( uncompressedData, uncompressedSize ); @@ -728,9 +723,7 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene, delete[] uncompressedData; delete[] compressedData; - } - else - { + } else { ReadBinaryScene(stream,pScene); } diff --git a/Engine/lib/assimp/code/AssbinLoader.h b/Engine/lib/assimp/code/AssbinLoader.h index 2eb7a6488..9f2dde125 100644 --- a/Engine/lib/assimp/code/AssbinLoader.h +++ b/Engine/lib/assimp/code/AssbinLoader.h @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -46,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_ASSBINIMPORTER_H_INC #define AI_ASSBINIMPORTER_H_INC -#include "BaseImporter.h" +#include struct aiMesh; struct aiNode; @@ -69,32 +70,33 @@ namespace Assimp { class AssbinImporter : public BaseImporter { private: - bool shortened; - bool compressed; + bool shortened; + bool compressed; public: - virtual bool CanRead( - const std::string& pFile, - IOSystem* pIOHandler, - bool checkSig + virtual bool CanRead( + const std::string& pFile, + IOSystem* pIOHandler, + bool checkSig ) const; - virtual const aiImporterDesc* GetInfo() const; - virtual void InternReadFile( + virtual const aiImporterDesc* GetInfo() const; + virtual void InternReadFile( const std::string& pFile, - aiScene* pScene, - IOSystem* pIOHandler + aiScene* pScene, + IOSystem* pIOHandler ); - void ReadBinaryScene( IOStream * stream, aiScene* pScene ); - void ReadBinaryNode( IOStream * stream, aiNode** mRootNode, aiNode* parent ); - void ReadBinaryMesh( IOStream * stream, aiMesh* mesh ); - void ReadBinaryBone( IOStream * stream, aiBone* bone ); - void ReadBinaryMaterial(IOStream * stream, aiMaterial* mat); - void ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop); - void ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd); - void ReadBinaryAnim( IOStream * stream, aiAnimation* anim ); - void ReadBinaryTexture(IOStream * stream, aiTexture* tex); - void ReadBinaryLight( IOStream * stream, aiLight* l ); - void ReadBinaryCamera( IOStream * stream, aiCamera* cam ); + void ReadHeader(); + void ReadBinaryScene( IOStream * stream, aiScene* pScene ); + void ReadBinaryNode( IOStream * stream, aiNode** mRootNode, aiNode* parent ); + void ReadBinaryMesh( IOStream * stream, aiMesh* mesh ); + void ReadBinaryBone( IOStream * stream, aiBone* bone ); + void ReadBinaryMaterial(IOStream * stream, aiMaterial* mat); + void ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop); + void ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd); + void ReadBinaryAnim( IOStream * stream, aiAnimation* anim ); + void ReadBinaryTexture(IOStream * stream, aiTexture* tex); + void ReadBinaryLight( IOStream * stream, aiLight* l ); + void ReadBinaryCamera( IOStream * stream, aiCamera* cam ); }; } // end of namespace Assimp diff --git a/Engine/lib/assimp/code/Assimp.cpp b/Engine/lib/assimp/code/Assimp.cpp index 9269f905e..41e1a4800 100644 --- a/Engine/lib/assimp/code/Assimp.cpp +++ b/Engine/lib/assimp/code/Assimp.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -49,13 +50,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include +#include +#include -#include "GenericProperty.h" #include "CInterfaceIOWrapper.h" #include "Importer.h" -#include "Exceptional.h" #include "ScenePrivate.h" -#include "BaseImporter.h" + #include // ------------------------------------------------------------------------------------------------ @@ -106,7 +108,6 @@ namespace Assimp { static std::mutex gLogStreamMutex; #endif - // ------------------------------------------------------------------------------------------------ // Custom LogStream implementation for the C-API class LogToCallbackRedirector : public LogStream { @@ -145,7 +146,7 @@ private: // ------------------------------------------------------------------------------------------------ void ReportSceneNotFoundError() { - DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. " + ASSIMP_LOG_ERROR("Unable to find the Assimp::Importer for this aiScene. " "The C-API does not accept scenes produced by the C++ API and vice versa"); ai_assert(false); diff --git a/Engine/lib/assimp/code/AssimpCExport.cpp b/Engine/lib/assimp/code/AssimpCExport.cpp index b8d3264a1..beb3ec3c5 100644 --- a/Engine/lib/assimp/code/AssimpCExport.cpp +++ b/Engine/lib/assimp/code/AssimpCExport.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -59,7 +60,6 @@ ASSIMP_API size_t aiGetExportFormatCount(void) return Exporter().GetExportFormatCount(); } - // ------------------------------------------------------------------------------------------------ ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t index) { diff --git a/Engine/lib/assimp/code/AssxmlExporter.cpp b/Engine/lib/assimp/code/AssxmlExporter.cpp index 90ed66701..fc9a6bae5 100644 --- a/Engine/lib/assimp/code/AssxmlExporter.cpp +++ b/Engine/lib/assimp/code/AssxmlExporter.cpp @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -41,6 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file AssxmlExporter.cpp * ASSXML exporter main code */ + +#ifndef ASSIMP_BUILD_NO_EXPORT +#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER + #include #include #include "ProcessHelper.h" @@ -57,9 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#ifndef ASSIMP_BUILD_NO_EXPORT -#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER - using namespace Assimp; namespace Assimp { @@ -182,8 +184,13 @@ static std::string encodeXML(const std::string& data) { static void WriteDump(const aiScene* scene, IOStream* io, bool shortened) { time_t tt = ::time( NULL ); - tm* p = ::gmtime( &tt ); - ai_assert( nullptr != p ); +#if _WIN32 + tm* p = gmtime(&tt); +#else + struct tm now; + tm* p = gmtime_r(&tt, &now); +#endif + ai_assert(nullptr != p); // write header std::string header( diff --git a/Engine/lib/assimp/code/AssxmlExporter.h b/Engine/lib/assimp/code/AssxmlExporter.h index 9694f74a3..8ca887eea 100644 --- a/Engine/lib/assimp/code/AssxmlExporter.h +++ b/Engine/lib/assimp/code/AssxmlExporter.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. diff --git a/Engine/lib/assimp/code/B3DImporter.cpp b/Engine/lib/assimp/code/B3DImporter.cpp index bc888fb66..e48646de9 100644 --- a/Engine/lib/assimp/code/B3DImporter.cpp +++ b/Engine/lib/assimp/code/B3DImporter.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -51,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "B3DImporter.h" #include "TextureTransform.h" #include "ConvertToLHProcess.h" -#include "StringUtils.h" +#include #include #include #include @@ -93,7 +94,6 @@ void DeleteAllBarePointers(std::vector& x) B3DImporter::~B3DImporter() { - DeleteAllBarePointers(_animations); } // ------------------------------------------------------------------------------------------------ @@ -267,6 +267,21 @@ T *B3DImporter::to_array( const vector &v ){ return p; } + +// ------------------------------------------------------------------------------------------------ +template +T **unique_to_array( vector > &v ){ + if( v.empty() ) { + return 0; + } + T **p = new T*[ v.size() ]; + for( size_t i = 0; i < v.size(); ++i ){ + p[i] = v[i].release(); + } + return p; +} + + // ------------------------------------------------------------------------------------------------ void B3DImporter::ReadTEXS(){ while( ChunkSize() ){ @@ -295,8 +310,7 @@ void B3DImporter::ReadBRUS(){ /*int blend=**/ReadInt(); int fx=ReadInt(); - aiMaterial *mat=new aiMaterial; - _materials.push_back( mat ); + std::unique_ptr mat(new aiMaterial); // Name aiString ainame( name ); @@ -333,6 +347,7 @@ void B3DImporter::ReadBRUS(){ mat->AddProperty( &texname,AI_MATKEY_TEXTURE_DIFFUSE(0) ); } } + _materials.emplace_back( std::move(mat) ); } } @@ -386,8 +401,7 @@ void B3DImporter::ReadTRIS( int v0 ){ Fail( "Bad material id" ); } - aiMesh *mesh=new aiMesh; - _meshes.push_back( mesh ); + std::unique_ptr mesh(new aiMesh); mesh->mMaterialIndex=matid; mesh->mNumFaces=0; @@ -415,6 +429,8 @@ void B3DImporter::ReadTRIS( int v0 ){ ++mesh->mNumFaces; ++face; } + + _meshes.emplace_back( std::move(mesh) ); } // ------------------------------------------------------------------------------------------------ @@ -500,11 +516,11 @@ void B3DImporter::ReadANIM(){ int frames=ReadInt(); float fps=ReadFloat(); - aiAnimation *anim=new aiAnimation; - _animations.push_back( anim ); + std::unique_ptr anim(new aiAnimation); anim->mDuration=frames; anim->mTicksPerSecond=fps; + _animations.emplace_back( std::move(anim) ); } // ------------------------------------------------------------------------------------------------ @@ -531,7 +547,7 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){ node->mParent=parent; node->mTransformation=tform; - aiNodeAnim *nodeAnim=0; + std::unique_ptr nodeAnim; vector meshes; vector children; @@ -549,11 +565,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){ ReadANIM(); }else if( t=="KEYS" ){ if( !nodeAnim ){ - nodeAnim=new aiNodeAnim; - _nodeAnims.push_back( nodeAnim ); + nodeAnim.reset(new aiNodeAnim); nodeAnim->mNodeName=node->mName; } - ReadKEYS( nodeAnim ); + ReadKEYS( nodeAnim.get() ); }else if( t=="NODE" ){ aiNode *child=ReadNODE( node ); children.push_back( child ); @@ -561,6 +576,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){ ExitChunk(); } + if (nodeAnim) { + _nodeAnims.emplace_back( std::move(nodeAnim) ); + } + node->mNumMeshes= static_cast(meshes.size()); node->mMeshes=to_array( meshes ); @@ -586,7 +605,6 @@ void B3DImporter::ReadBB3D( aiScene *scene ){ _nodeAnims.clear(); - DeleteAllBarePointers(_animations); _animations.clear(); string t=ReadChunk(); @@ -596,7 +614,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){ if (!DefaultLogger::isNullLogger()) { char dmp[128]; ai_snprintf(dmp, 128, "B3D file format version: %i",version); - DefaultLogger::get()->info(dmp); + ASSIMP_LOG_INFO(dmp); } while( ChunkSize() ){ @@ -622,7 +640,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){ aiNode *node=_nodes[i]; for( size_t j=0;jmNumMeshes;++j ){ - aiMesh *mesh=_meshes[node->mMeshes[j]]; + aiMesh *mesh = _meshes[node->mMeshes[j]].get(); int n_tris=mesh->mNumFaces; int n_verts=mesh->mNumVertices=n_tris * 3; @@ -685,27 +703,28 @@ void B3DImporter::ReadBB3D( aiScene *scene ){ //nodes scene->mRootNode=_nodes[0]; + _nodes.clear(); // node ownership now belongs to scene //material if( !_materials.size() ){ - _materials.push_back( new aiMaterial ); + _materials.emplace_back( std::unique_ptr(new aiMaterial) ); } scene->mNumMaterials= static_cast(_materials.size()); - scene->mMaterials=to_array( _materials ); + scene->mMaterials = unique_to_array( _materials ); //meshes scene->mNumMeshes= static_cast(_meshes.size()); - scene->mMeshes=to_array( _meshes ); + scene->mMeshes = unique_to_array( _meshes ); //animations if( _animations.size()==1 && _nodeAnims.size() ){ - aiAnimation *anim=_animations.back(); + aiAnimation *anim = _animations.back().get(); anim->mNumChannels=static_cast(_nodeAnims.size()); - anim->mChannels=to_array( _nodeAnims ); + anim->mChannels = unique_to_array( _nodeAnims ); scene->mNumAnimations=static_cast(_animations.size()); - scene->mAnimations=to_array( _animations ); + scene->mAnimations=unique_to_array( _animations ); } // convert to RH diff --git a/Engine/lib/assimp/code/B3DImporter.h b/Engine/lib/assimp/code/B3DImporter.h index 94644edd4..d52dac34a 100644 --- a/Engine/lib/assimp/code/B3DImporter.h +++ b/Engine/lib/assimp/code/B3DImporter.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -47,8 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "BaseImporter.h" +#include +#include #include struct aiNodeAnim; @@ -116,15 +118,15 @@ private: std::vector _stack; std::vector _textures; - std::vector _materials; + std::vector > _materials; int _vflags,_tcsets,_tcsize; std::vector _vertices; std::vector _nodes; - std::vector _meshes; - std::vector _nodeAnims; - std::vector _animations; + std::vector > _meshes; + std::vector > _nodeAnims; + std::vector > _animations; }; } diff --git a/Engine/lib/assimp/code/BVHLoader.cpp b/Engine/lib/assimp/code/BVHLoader.cpp index c20cbec4e..cd9ab0843 100644 --- a/Engine/lib/assimp/code/BVHLoader.cpp +++ b/Engine/lib/assimp/code/BVHLoader.cpp @@ -4,7 +4,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -45,14 +46,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_BVH_IMPORTER #include "BVHLoader.h" -#include "fast_atof.h" -#include "SkeletonMeshBuilder.h" +#include +#include #include #include -#include "TinyFormatter.h" +#include #include #include #include +#include using namespace Assimp; using namespace Assimp::Formatter; @@ -198,6 +200,7 @@ aiNode* BVHLoader::ReadNode() Node& internNode = mNodes.back(); // now read the node's contents + std::string siteToken; while( 1) { std::string token = GetNextToken(); @@ -217,7 +220,8 @@ aiNode* BVHLoader::ReadNode() else if( token == "End") { // The real symbol is "End Site". Second part comes in a separate token - std::string siteToken = GetNextToken(); + siteToken.clear(); + siteToken = GetNextToken(); if( siteToken != "Site") ThrowException( format() << "Expected \"End Site\" keyword, but found \"" << token << " " << siteToken << "\"." ); @@ -261,21 +265,18 @@ aiNode* BVHLoader::ReadEndSite( const std::string& pParentName) aiNode* node = new aiNode( "EndSite_" + pParentName); // now read the node's contents. Only possible entry is "OFFSET" - while( 1) - { - std::string token = GetNextToken(); + std::string token; + while( 1) { + token.clear(); + token = GetNextToken(); // end node's offset - if( token == "OFFSET") - { + if( token == "OFFSET") { ReadNodeOffset( node); - } - else if( token == "}") - { + } else if( token == "}") { // we're done with the end node break; - } else - { + } else { // everything else is a parse error ThrowException( format() << "Unknown keyword \"" << token << "\"." ); } @@ -295,8 +296,10 @@ void BVHLoader::ReadNodeOffset( aiNode* pNode) offset.z = GetNextTokenAsFloat(); // build a transformation matrix from it - pNode->mTransformation = aiMatrix4x4( 1.0f, 0.0f, 0.0f, offset.x, 0.0f, 1.0f, 0.0f, offset.y, - 0.0f, 0.0f, 1.0f, offset.z, 0.0f, 0.0f, 0.0f, 1.0f); + pNode->mTransformation = aiMatrix4x4( 1.0f, 0.0f, 0.0f, offset.x, + 0.0f, 1.0f, 0.0f, offset.y, + 0.0f, 0.0f, 1.0f, offset.z, + 0.0f, 0.0f, 0.0f, 1.0f); } // ------------------------------------------------------------------------------------------------ @@ -459,6 +462,13 @@ void BVHLoader::CreateAnimation( aiScene* pScene) aiNodeAnim* nodeAnim = new aiNodeAnim; anim->mChannels[a] = nodeAnim; nodeAnim->mNodeName.Set( nodeName); + std::map channelMap; + + //Build map of channels + for (unsigned int channel = 0; channel < node.mChannels.size(); ++channel) + { + channelMap[node.mChannels[channel]] = channel; + } // translational part, if given if( node.mChannels.size() == 6) @@ -470,16 +480,32 @@ void BVHLoader::CreateAnimation( aiScene* pScene) { poskey->mTime = double( fr); - // Now compute all translations in the right order - for( unsigned int channel = 0; channel < 3; ++channel) + // Now compute all translations + for(BVHLoader::ChannelType channel = Channel_PositionX; channel <= Channel_PositionZ; channel = (BVHLoader::ChannelType)(channel +1)) { - switch( node.mChannels[channel]) - { - case Channel_PositionX: poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + channel]; break; - case Channel_PositionY: poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + channel]; break; - case Channel_PositionZ: poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + channel]; break; - default: throw DeadlyImportError( "Unexpected animation channel setup at node " + nodeName ); - } + //Find channel in node + std::map::iterator mapIter = channelMap.find(channel); + + if (mapIter == channelMap.end()) + throw DeadlyImportError("Missing position channel in node " + nodeName); + else { + int channelIdx = mapIter->second; + switch (channel) { + case Channel_PositionX: + poskey->mValue.x = node.mChannelValues[fr * node.mChannels.size() + channelIdx]; + break; + case Channel_PositionY: + poskey->mValue.y = node.mChannelValues[fr * node.mChannels.size() + channelIdx]; + break; + case Channel_PositionZ: + poskey->mValue.z = node.mChannelValues[fr * node.mChannels.size() + channelIdx]; + break; + + default: + break; + } + + } } ++poskey; } @@ -495,12 +521,6 @@ void BVHLoader::CreateAnimation( aiScene* pScene) // rotation part. Always present. First find value offsets { - unsigned int rotOffset = 0; - if( node.mChannels.size() == 6) - { - // Offset all further calculations - rotOffset = 3; - } // Then create the number of rotation keys nodeAnim->mNumRotationKeys = mAnimNumFrames; @@ -510,20 +530,33 @@ void BVHLoader::CreateAnimation( aiScene* pScene) { aiMatrix4x4 temp; aiMatrix3x3 rotMatrix; + for (BVHLoader::ChannelType channel = Channel_RotationX; channel <= Channel_RotationZ; channel = (BVHLoader::ChannelType)(channel + 1)) + { + //Find channel in node + std::map::iterator mapIter = channelMap.find(channel); - for( unsigned int channel = 0; channel < 3; ++channel) - { - // translate ZXY euler angels into a quaternion - const float angle = node.mChannelValues[fr * node.mChannels.size() + rotOffset + channel] * float( AI_MATH_PI) / 180.0f; + if (mapIter == channelMap.end()) + throw DeadlyImportError("Missing rotation channel in node " + nodeName); + else { + int channelIdx = mapIter->second; + // translate ZXY euler angels into a quaternion + const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; - // Compute rotation transformations in the right order - switch (node.mChannels[rotOffset+channel]) - { - case Channel_RotationX: aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp); break; - case Channel_RotationY: aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp); break; - case Channel_RotationZ: aiMatrix4x4::RotationZ( angle, temp); rotMatrix *= aiMatrix3x3( temp); break; - default: throw DeadlyImportError( "Unexpected animation channel setup at node " + nodeName ); - } + // Compute rotation transformations in the right order + switch (channel) + { + case Channel_RotationX: + aiMatrix4x4::RotationX(angle, temp); rotMatrix *= aiMatrix3x3(temp); + break; + case Channel_RotationY: + aiMatrix4x4::RotationY(angle, temp); rotMatrix *= aiMatrix3x3(temp); + break; + case Channel_RotationZ: aiMatrix4x4::RotationZ(angle, temp); rotMatrix *= aiMatrix3x3(temp); + break; + default: + break; + } + } } rotkey->mTime = double( fr); diff --git a/Engine/lib/assimp/code/BVHLoader.h b/Engine/lib/assimp/code/BVHLoader.h index 6a89e1aaf..33b4e2453 100644 --- a/Engine/lib/assimp/code/BVHLoader.h +++ b/Engine/lib/assimp/code/BVHLoader.h @@ -4,7 +4,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -48,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_BVHLOADER_H_INC #define AI_BVHLOADER_H_INC -#include "BaseImporter.h" +#include struct aiNode; @@ -83,7 +84,10 @@ class BVHLoader : public BaseImporter std::vector mChannels; std::vector mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames - Node() { } + Node() + : mNode(nullptr) + { } + explicit Node( const aiNode* pNode) : mNode( pNode) { } }; diff --git a/Engine/lib/assimp/code/BaseImporter.cpp b/Engine/lib/assimp/code/BaseImporter.cpp index b9b9eeb71..4803c6d6f 100644 --- a/Engine/lib/assimp/code/BaseImporter.cpp +++ b/Engine/lib/assimp/code/BaseImporter.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -44,14 +45,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of BaseImporter */ -#include "BaseImporter.h" +#include +#include #include "FileSystemFilter.h" #include "Importer.h" -#include "ByteSwapper.h" +#include #include #include #include #include + #include #include #include @@ -62,24 +65,25 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -BaseImporter::BaseImporter() -: m_progress() -{ +BaseImporter::BaseImporter() AI_NO_EXCEPT +: m_progress() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Destructor, private as well -BaseImporter::~BaseImporter() -{ +BaseImporter::~BaseImporter() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Imports the given file and returns the imported data. -aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) -{ +aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) { m_progress = pImp->GetProgressHandler(); + if (nullptr == m_progress) { + return nullptr; + } + ai_assert(m_progress); // Gather configuration properties for this run @@ -99,8 +103,8 @@ aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, } catch( const std::exception& err ) { // extract error description m_ErrorText = err.what(); - DefaultLogger::get()->error(m_ErrorText); - return NULL; + ASSIMP_LOG_ERROR(m_ErrorText); + return nullptr; } // return what we gathered from the import. @@ -114,13 +118,12 @@ void BaseImporter::SetupProperties(const Importer* /*pImp*/) } // ------------------------------------------------------------------------------------------------ -void BaseImporter::GetExtensionList(std::set& extensions) -{ +void BaseImporter::GetExtensionList(std::set& extensions) { const aiImporterDesc* desc = GetInfo(); - ai_assert(desc != NULL); + ai_assert(desc != nullptr); const char* ext = desc->mFileExtensions; - ai_assert(ext != NULL); + ai_assert(ext != nullptr ); const char* last = ext; do { @@ -142,31 +145,29 @@ void BaseImporter::GetExtensionList(std::set& extensions) const char** tokens, unsigned int numTokens, unsigned int searchBytes /* = 200 */, - bool tokensSol /* false */) + bool tokensSol /* false */, + bool noAlphaBeforeTokens /* false */) { - ai_assert( NULL != tokens ); + ai_assert( nullptr != tokens ); ai_assert( 0 != numTokens ); ai_assert( 0 != searchBytes); - if (!pIOHandler) + if ( nullptr == pIOHandler ) { return false; + } std::unique_ptr pStream (pIOHandler->Open(pFile)); if (pStream.get() ) { // read 200 characters from the file std::unique_ptr _buffer (new char[searchBytes+1 /* for the '\0' */]); - char* buffer = _buffer.get(); - if( NULL == buffer ) { - return false; - } - - const size_t read = pStream->Read(buffer,1,searchBytes); - if( !read ) { + char *buffer( _buffer.get() ); + const size_t read( pStream->Read(buffer,1,searchBytes) ); + if( 0 == read ) { return false; } for( size_t i = 0; i < read; ++i ) { - buffer[ i ] = ::tolower( buffer[ i ] ); + buffer[ i ] = static_cast( ::tolower( buffer[ i ] ) ); } // It is not a proper handling of unicode files here ... @@ -180,16 +181,29 @@ void BaseImporter::GetExtensionList(std::set& extensions) } *cur2 = '\0'; - for (unsigned int i = 0; i < numTokens;++i) { - ai_assert(NULL != tokens[i]); - const char* r = strstr(buffer,tokens[i]); + std::string token; + for (unsigned int i = 0; i < numTokens; ++i ) { + ai_assert( nullptr != tokens[i] ); + const size_t len( strlen( tokens[ i ] ) ); + token.clear(); + const char *ptr( tokens[ i ] ); + for ( size_t tokIdx = 0; tokIdx < len; ++tokIdx ) { + token.push_back( static_cast( tolower( *ptr ) ) ); + ++ptr; + } + const char* r = strstr( buffer, token.c_str() ); if( !r ) { continue; } + // We need to make sure that we didn't accidentially identify the end of another token as our token, + // e.g. in a previous version the "gltf " present in some gltf files was detected as "f " + if (noAlphaBeforeTokens && (r != buffer && isalpha(r[-1]))) { + continue; + } // We got a match, either we don't care where it is, or it happens to // be in the beginning of the file / line if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') { - DefaultLogger::get()->debug(std::string("Found positive match for header keyword: ") + tokens[i]); + ASSIMP_LOG_DEBUG_F( "Found positive match for header keyword: ", tokens[i] ); return true; } } @@ -227,16 +241,19 @@ void BaseImporter::GetExtensionList(std::set& extensions) // ------------------------------------------------------------------------------------------------ // Get file extension from path -/*static*/ std::string BaseImporter::GetExtension (const std::string& pFile) -{ - std::string::size_type pos = pFile.find_last_of('.'); +std::string BaseImporter::GetExtension( const std::string& file ) { + std::string::size_type pos = file.find_last_of('.'); // no file extension at all - if( pos == std::string::npos) + if (pos == std::string::npos) { return ""; + } + + + // thanks to Andy Maloney for the hint + std::string ret = file.substr( pos + 1 ); + std::transform( ret.begin(), ret.end(), ret.begin(), ToLower); - std::string ret = pFile.substr(pos+1); - std::transform(ret.begin(),ret.end(),ret.begin(),::tolower); // thanks to Andy Maloney for the hint return ret; } @@ -245,7 +262,8 @@ void BaseImporter::GetExtensionList(std::set& extensions) /* static */ bool BaseImporter::CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile, const void* _magic, unsigned int num, unsigned int offset, unsigned int size) { - ai_assert(size <= 16 && _magic); + ai_assert( size <= 16 ); + ai_assert( _magic ); if (!pIOHandler) { return false; @@ -315,7 +333,7 @@ void BaseImporter::ConvertToUTF8(std::vector& data) // UTF 8 with BOM if((uint8_t)data[0] == 0xEF && (uint8_t)data[1] == 0xBB && (uint8_t)data[2] == 0xBF) { - DefaultLogger::get()->debug("Found UTF-8 BOM ..."); + ASSIMP_LOG_DEBUG("Found UTF-8 BOM ..."); std::copy(data.begin()+3,data.end(),data.begin()); data.resize(data.size()-3); @@ -334,7 +352,7 @@ void BaseImporter::ConvertToUTF8(std::vector& data) // UTF 32 LE with BOM if(*((uint32_t*)&data.front()) == 0x0000FFFE) { - DefaultLogger::get()->debug("Found UTF-32 BOM ..."); + ASSIMP_LOG_DEBUG("Found UTF-32 BOM ..."); std::vector output; int *ptr = (int*)&data[ 0 ]; @@ -354,7 +372,7 @@ void BaseImporter::ConvertToUTF8(std::vector& data) // UTF 16 LE with BOM if(*((uint16_t*)&data.front()) == 0xFEFF) { - DefaultLogger::get()->debug("Found UTF-16 BOM ..."); + ASSIMP_LOG_DEBUG("Found UTF-16 BOM ..."); std::vector output; utf8::utf16to8(data.begin(), data.end(), back_inserter(output)); @@ -379,16 +397,14 @@ void BaseImporter::ConvertUTF8toISO8859_1(std::string& data) data[j] = ((unsigned char) data[++i] + 0x40); } else { std::stringstream stream; - stream << "UTF8 code " << std::hex << data[i] << data[i + 1] << " can not be converted into ISA-8859-1."; - - DefaultLogger::get()->error(stream.str()); + ASSIMP_LOG_ERROR( stream.str() ); data[j++] = data[i++]; data[j] = data[i]; } } else { - DefaultLogger::get()->error("UTF8 code but only one character remaining"); + ASSIMP_LOG_ERROR("UTF8 code but only one character remaining"); data[j] = data[i]; } @@ -404,7 +420,7 @@ void BaseImporter::TextFileToBuffer(IOStream* stream, std::vector& data, TextFileMode mode) { - ai_assert(NULL != stream); + ai_assert(nullptr != stream); const size_t fileSize = stream->FileSize(); if (mode == FORBID_EMPTY) { @@ -465,14 +481,14 @@ struct Assimp::BatchData { , pImporter( nullptr ) , next_id(0xffff) , validate( validate ) { - ai_assert( NULL != pIO ); + ai_assert( nullptr != pIO ); pImporter = new Importer(); pImporter->SetIOHandler( pIO ); } ~BatchData() { - pImporter->SetIOHandler( NULL ); /* get pointer back into our possession */ + pImporter->SetIOHandler( nullptr ); /* get pointer back into our possession */ delete pImporter; } @@ -498,9 +514,8 @@ struct Assimp::BatchData { typedef std::list::iterator LoadReqIt; // ------------------------------------------------------------------------------------------------ -BatchLoader::BatchLoader(IOSystem* pIO, bool validate ) -{ - ai_assert(NULL != pIO); +BatchLoader::BatchLoader(IOSystem* pIO, bool validate ) { + ai_assert(nullptr != pIO); m_data = new BatchData( pIO, validate ); } @@ -566,7 +581,7 @@ aiScene* BatchLoader::GetImport( unsigned int which ) return sc; } } - return NULL; + return nullptr; } // ------------------------------------------------------------------------------------------------ @@ -589,13 +604,13 @@ void BatchLoader::LoadAll() if (!DefaultLogger::isNullLogger()) { - DefaultLogger::get()->info("%%% BEGIN EXTERNAL FILE %%%"); - DefaultLogger::get()->info("File: " + (*it).file); + ASSIMP_LOG_INFO("%%% BEGIN EXTERNAL FILE %%%"); + ASSIMP_LOG_INFO_F("File: ", (*it).file); } m_data->pImporter->ReadFile((*it).file,pp); (*it).scene = m_data->pImporter->GetOrphanedScene(); (*it).loaded = true; - DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%"); + ASSIMP_LOG_INFO("%%% END EXTERNAL FILE %%%"); } } diff --git a/Engine/lib/assimp/code/BaseProcess.cpp b/Engine/lib/assimp/code/BaseProcess.cpp index 9e175d315..18872c369 100644 --- a/Engine/lib/assimp/code/BaseProcess.cpp +++ b/Engine/lib/assimp/code/BaseProcess.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -42,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Implementation of BaseProcess */ -#include "BaseImporter.h" +#include #include "BaseProcess.h" #include #include @@ -52,7 +53,7 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -BaseProcess::BaseProcess() +BaseProcess::BaseProcess() AI_NO_EXCEPT : shared() , progress() { @@ -84,7 +85,7 @@ void BaseProcess::ExecuteOnScene( Importer* pImp) // extract error description pImp->Pimpl()->mErrorString = err.what(); - DefaultLogger::get()->error(pImp->Pimpl()->mErrorString); + ASSIMP_LOG_ERROR(pImp->Pimpl()->mErrorString); // and kill the partially imported data delete pImp->Pimpl()->mScene; diff --git a/Engine/lib/assimp/code/BaseProcess.h b/Engine/lib/assimp/code/BaseProcess.h index aa873f717..4d5c7a76b 100644 --- a/Engine/lib/assimp/code/BaseProcess.h +++ b/Engine/lib/assimp/code/BaseProcess.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -44,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INCLUDED_AI_BASEPROCESS_H #include -#include "GenericProperty.h" +#include struct aiScene; @@ -210,20 +211,16 @@ private: * should be executed. If the function returns true, the class' Execute() * function is called subsequently. */ -class ASSIMP_API_WINONLY BaseProcess -{ +class ASSIMP_API_WINONLY BaseProcess { friend class Importer; public: - /** Constructor to be privately used by Importer */ - BaseProcess(); + BaseProcess() AI_NO_EXCEPT; /** Destructor, private as well */ virtual ~BaseProcess(); -public: - // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag. * @param pFlags The processing flags the importer was called with. A diff --git a/Engine/lib/assimp/code/Bitmap.cpp b/Engine/lib/assimp/code/Bitmap.cpp index 76994513e..b22b71ea9 100644 --- a/Engine/lib/assimp/code/Bitmap.cpp +++ b/Engine/lib/assimp/code/Bitmap.cpp @@ -3,7 +3,8 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -47,10 +48,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "Bitmap.h" +#include #include #include -#include "ByteSwapper.h" +#include namespace Assimp { @@ -84,7 +85,8 @@ namespace Assimp { } template - inline std::size_t Copy(uint8_t* data, T& field) { + inline + std::size_t Copy(uint8_t* data, const T &field) { #ifdef AI_BUILD_BIG_ENDIAN T field_swapped=AI_BE(field); std::memcpy(data, &field_swapped, sizeof(field)); return sizeof(field); diff --git a/Engine/lib/assimp/code/BlenderBMesh.h b/Engine/lib/assimp/code/BlenderBMesh.h index 0d58b818c..5b65fb503 100644 --- a/Engine/lib/assimp/code/BlenderBMesh.h +++ b/Engine/lib/assimp/code/BlenderBMesh.h @@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef INCLUDED_AI_BLEND_BMESH_H #define INCLUDED_AI_BLEND_BMESH_H -#include "LogAux.h" +#include namespace Assimp { diff --git a/Engine/lib/assimp/code/BlenderCustomData.cpp b/Engine/lib/assimp/code/BlenderCustomData.cpp new file mode 100644 index 000000000..6561eaf22 --- /dev/null +++ b/Engine/lib/assimp/code/BlenderCustomData.cpp @@ -0,0 +1,189 @@ +#include "BlenderCustomData.h" +#include "BlenderDNA.h" +#include +#include + +namespace Assimp { + namespace Blender { + /** + * @brief read/convert of Structure array to memory + */ + template + bool read(const Structure &s, T *p, const size_t cnt, const FileDatabase &db) { + for (size_t i = 0; i < cnt; ++i) { + T read; + s.Convert(read, db); + *p = read; + p++; + } + return true; + } + + /** + * @brief pointer to function read memory for n CustomData types + */ + typedef bool (*PRead)(ElemBase *pOut, const size_t cnt, const FileDatabase &db); + typedef ElemBase * (*PCreate)(const size_t cnt); + typedef void(*PDestroy)(ElemBase *); + +#define IMPL_STRUCT_READ(ty) \ + bool read##ty(ElemBase *v, const size_t cnt, const FileDatabase &db) { \ + ty *ptr = dynamic_cast(v); \ + if (nullptr == ptr) { \ + return false; \ + } \ + return read(db.dna[#ty], ptr, cnt, db); \ + } + +#define IMPL_STRUCT_CREATE(ty) \ + ElemBase *create##ty(const size_t cnt) { \ + return new ty[cnt]; \ + } + +#define IMPL_STRUCT_DESTROY(ty) \ + void destroy##ty(ElemBase *pE) { \ + ty *p = dynamic_cast(pE); \ + delete[]p; \ + } + + /** + * @brief helper macro to define Structure functions + */ +#define IMPL_STRUCT(ty) \ + IMPL_STRUCT_READ(ty) \ + IMPL_STRUCT_CREATE(ty) \ + IMPL_STRUCT_DESTROY(ty) + + // supported structures for CustomData + IMPL_STRUCT(MVert) + IMPL_STRUCT(MEdge) + IMPL_STRUCT(MFace) + IMPL_STRUCT(MTFace) + IMPL_STRUCT(MTexPoly) + IMPL_STRUCT(MLoopUV) + IMPL_STRUCT(MLoopCol) + IMPL_STRUCT(MPoly) + IMPL_STRUCT(MLoop) + + /** + * @brief describes the size of data and the read function to be used for single CustomerData.type + */ + struct CustomDataTypeDescription { + PRead Read; ///< function to read one CustomData type element + PCreate Create; ///< function to allocate n type elements + PDestroy Destroy; + + CustomDataTypeDescription(PRead read, PCreate create, PDestroy destroy) + : Read(read) + , Create(create) + , Destroy(destroy) + {} + }; + + + /** + * @brief helper macro to define Structure type specific CustomDataTypeDescription + * @note IMPL_STRUCT_READ for same ty must be used earlier to implement the typespecific read function + */ +#define DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(ty) \ + CustomDataTypeDescription{&read##ty, &create##ty, &destroy##ty} + + /** + * @brief helper macro to define CustomDataTypeDescription for UNSUPPORTED type + */ +#define DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION \ + CustomDataTypeDescription{nullptr, nullptr, nullptr} + + /** + * @brief descriptors for data pointed to from CustomDataLayer.data + * @note some of the CustomData uses already well defined Structures + * other (like CD_ORCO, ...) uses arrays of rawtypes or even arrays of Structures + * use a special readfunction for that cases + */ + std::array customDataTypeDescriptions = { { + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MVert), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MEdge), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MFace), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MTFace), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MTexPoly), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MLoopUV), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MLoopCol), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MPoly), + DECL_STRUCT_CUSTOMDATATYPEDESCRIPTION(MLoop), + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION, + DECL_UNSUPPORTED_CUSTOMDATATYPEDESCRIPTION + }}; + + + bool isValidCustomDataType(const int cdtype) { + return cdtype >= 0 && cdtype < CD_NUMTYPES; + } + + bool readCustomData(std::shared_ptr &out, const int cdtype, const size_t cnt, const FileDatabase &db) { + if (!isValidCustomDataType(cdtype)) { + throw Error((Formatter::format(), "CustomData.type ", cdtype, " out of index")); + } + + const CustomDataTypeDescription cdtd = customDataTypeDescriptions[cdtype]; + if (cdtd.Read && cdtd.Create && cdtd.Destroy && cnt > 0) { + // allocate cnt elements and parse them from file + out.reset(cdtd.Create(cnt), cdtd.Destroy); + return cdtd.Read(out.get(), cnt, db); + } + return false; + } + + std::shared_ptr getCustomDataLayer(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) { + for (auto it = customdata.layers.begin(); it != customdata.layers.end(); ++it) { + if (it->get()->type == cdtype && name == it->get()->name) { + return *it; + } + } + return nullptr; + } + + const ElemBase * getCustomDataLayerData(const CustomData &customdata, const CustomDataType cdtype, const std::string &name) + { + const std::shared_ptr pLayer = getCustomDataLayer(customdata, cdtype, name); + if (pLayer && pLayer->data) { + return pLayer->data.get(); + } + return nullptr; + } + } +} diff --git a/Engine/lib/assimp/code/BlenderCustomData.h b/Engine/lib/assimp/code/BlenderCustomData.h new file mode 100644 index 000000000..f61d79a26 --- /dev/null +++ b/Engine/lib/assimp/code/BlenderCustomData.h @@ -0,0 +1,89 @@ +#pragma once + +#include "BlenderDNA.h" +#include "BlenderScene.h" +#include + +namespace Assimp { + namespace Blender { + /* CustomData.type from Blender (2.79b) */ + enum CustomDataType { + CD_AUTO_FROM_NAME = -1, + CD_MVERT = 0, +#ifdef DNA_DEPRECATED + CD_MSTICKY = 1, /* DEPRECATED */ +#endif + CD_MDEFORMVERT = 2, + CD_MEDGE = 3, + CD_MFACE = 4, + CD_MTFACE = 5, + CD_MCOL = 6, + CD_ORIGINDEX = 7, + CD_NORMAL = 8, + /* CD_POLYINDEX = 9, */ + CD_PROP_FLT = 10, + CD_PROP_INT = 11, + CD_PROP_STR = 12, + CD_ORIGSPACE = 13, /* for modifier stack face location mapping */ + CD_ORCO = 14, + CD_MTEXPOLY = 15, + CD_MLOOPUV = 16, + CD_MLOOPCOL = 17, + CD_TANGENT = 18, + CD_MDISPS = 19, + CD_PREVIEW_MCOL = 20, /* for displaying weightpaint colors */ + /* CD_ID_MCOL = 21, */ + CD_TEXTURE_MLOOPCOL = 22, + CD_CLOTH_ORCO = 23, + CD_RECAST = 24, + + /* BMESH ONLY START */ + CD_MPOLY = 25, + CD_MLOOP = 26, + CD_SHAPE_KEYINDEX = 27, + CD_SHAPEKEY = 28, + CD_BWEIGHT = 29, + CD_CREASE = 30, + CD_ORIGSPACE_MLOOP = 31, + CD_PREVIEW_MLOOPCOL = 32, + CD_BM_ELEM_PYPTR = 33, + /* BMESH ONLY END */ + + CD_PAINT_MASK = 34, + CD_GRID_PAINT_MASK = 35, + CD_MVERT_SKIN = 36, + CD_FREESTYLE_EDGE = 37, + CD_FREESTYLE_FACE = 38, + CD_MLOOPTANGENT = 39, + CD_TESSLOOPNORMAL = 40, + CD_CUSTOMLOOPNORMAL = 41, + + CD_NUMTYPES = 42 + }; + + /** + * @brief check if given cdtype is valid (ie >= 0 and < CD_NUMTYPES) + * @param[in] cdtype to check + * @return true when valid + */ + bool isValidCustomDataType(const int cdtype); + + /** + * @brief returns CustomDataLayer ptr for given cdtype and name + * @param[in] customdata CustomData to search for wanted layer + * @param[in] cdtype to search for + * @param[in] name to search for + * @return CustomDataLayer * or nullptr if not found + */ + std::shared_ptr getCustomDataLayer(const CustomData &customdata, CustomDataType cdtype, const std::string &name); + + /** + * @brief returns CustomDataLayer data ptr for given cdtype and name + * @param[in] customdata CustomData to search for wanted layer + * @param[in] cdtype to search for + * @param[in] name to search for + * @return * to struct data or nullptr if not found + */ + const ElemBase * getCustomDataLayerData(const CustomData &customdata, CustomDataType cdtype, const std::string &name); + } +} diff --git a/Engine/lib/assimp/code/BlenderDNA.cpp b/Engine/lib/assimp/code/BlenderDNA.cpp index 23ece913f..f274e02f9 100644 --- a/Engine/lib/assimp/code/BlenderDNA.cpp +++ b/Engine/lib/assimp/code/BlenderDNA.cpp @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -47,9 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER #include "BlenderDNA.h" -#include "StreamReader.h" -#include "fast_atof.h" -#include "TinyFormatter.h" +#include +#include +#include using namespace Assimp; using namespace Assimp::Blender; @@ -57,12 +58,11 @@ using namespace Assimp::Formatter; static bool match4(StreamReaderAny& stream, const char* string) { ai_assert( nullptr != string ); - char tmp[] = { - (const char)(stream).GetI1(), - (const char)(stream).GetI1(), - (const char)(stream).GetI1(), - (const char)(stream).GetI1() - }; + char tmp[4]; + tmp[ 0 ] = ( stream ).GetI1(); + tmp[ 1 ] = ( stream ).GetI1(); + tmp[ 2 ] = ( stream ).GetI1(); + tmp[ 3 ] = ( stream ).GetI1(); return (tmp[0]==string[0] && tmp[1]==string[1] && tmp[2]==string[2] && tmp[3]==string[3]); } @@ -210,8 +210,7 @@ void DNAParser::Parse () s.size = offset; } - DefaultLogger::get()->debug((format(),"BlenderDNA: Got ",dna.structures.size(), - " structures with totally ",fields," fields")); + ASSIMP_LOG_DEBUG_F( "BlenderDNA: Got ", dna.structures.size()," structures with totally ",fields," fields"); #ifdef ASSIMP_BUILD_BLENDER_DEBUG dna.DumpToFile(); @@ -228,12 +227,12 @@ void DNAParser::Parse () // ------------------------------------------------------------------------------------------------ void DNA :: DumpToFile() { - // we dont't bother using the VFS here for this is only for debugging. + // we don't bother using the VFS here for this is only for debugging. // (and all your bases are belong to us). std::ofstream f("dna.txt"); if (f.fail()) { - DefaultLogger::get()->error("Could not dump dna to dna.txt"); + ASSIMP_LOG_ERROR("Could not dump dna to dna.txt"); return; } f << "Field format: type name offset size" << "\n"; @@ -248,7 +247,7 @@ void DNA :: DumpToFile() } f << std::flush; - DefaultLogger::get()->info("BlenderDNA: Dumped dna to dna.txt"); + ASSIMP_LOG_INFO("BlenderDNA: Dumped dna to dna.txt"); } #endif @@ -367,7 +366,7 @@ void SectionParser :: Next() } #ifdef ASSIMP_BUILD_BLENDER_DEBUG - DefaultLogger::get()->debug(current.id); + ASSIMP_LOG_DEBUG(current.id); #endif } diff --git a/Engine/lib/assimp/code/BlenderDNA.h b/Engine/lib/assimp/code/BlenderDNA.h index bac8d78bc..5d3a4f6ea 100644 --- a/Engine/lib/assimp/code/BlenderDNA.h +++ b/Engine/lib/assimp/code/BlenderDNA.h @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -46,8 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef INCLUDED_AI_BLEND_DNA_H #define INCLUDED_AI_BLEND_DNA_H -#include "BaseImporter.h" -#include "StreamReader.h" +#include +#include #include #include #include @@ -204,7 +205,7 @@ enum ErrorPolicy { // ------------------------------------------------------------------------------- /** Represents a data structure in a BLEND file. A Structure defines n fields - * and their locatios and encodings the input stream. Usually, every + * and their locations and encodings the input stream. Usually, every * Structure instance pertains to one equally-named data structure in the * BlenderScene.h header. This class defines various utilities to map a * binary `blob` read from the file to such a structure instance with @@ -308,6 +309,28 @@ public: void ReadField(T& out, const char* name, const FileDatabase& db) const; + // -------------------------------------------------------- + /** + * @brief field parsing for dynamic vectors + * @param[in] out vector of struct to be filled + * @param[in] name of field + * @param[in] db to access the file, dna, ... + * @return true when read was successful + */ + template class TOUT, typename T> + bool ReadFieldPtrVector(vector>&out, const char* name, const FileDatabase& db) const; + + /** + * @brief parses raw customdata + * @param[in] out shared_ptr to be filled + * @param[in] cdtype customdata type to read + * @param[in] name of field ptr + * @param[in] db to access the file, dna, ... + * @return true when read was successful + */ + template + bool ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const char* name, const FileDatabase& db) const; + private: // -------------------------------------------------------- @@ -380,7 +403,7 @@ template <> struct Structure :: _defaultInitializer { template void operator ()(T& out, const char* reason = "") { - DefaultLogger::get()->warn(reason); + ASSIMP_LOG_WARN(reason); // ... and let the show go on _defaultInitializer<0 /*ErrorPolicy_Igno*/>()(out); @@ -662,7 +685,7 @@ public: /** Check whether a specific item is in the cache. * @param s Data type of the item * @param out Output pointer. Unchanged if the - * cache doens't know the item yet. + * cache doesn't know the item yet. * @param ptr Item address to look for. */ template void get ( const Structure& s, @@ -802,6 +825,17 @@ private: FileDatabase& db; }; +/** +* @brief read CustomData's data to ptr to mem +* @param[out] out memory ptr to set +* @param[in] cdtype to read +* @param[in] cnt cnt of elements to read +* @param[in] db to read elements from +* @return true when ok +*/ +bool readCustomData(std::shared_ptr &out, int cdtype, size_t cnt, const FileDatabase &db); + + } // end Blend } // end Assimp diff --git a/Engine/lib/assimp/code/BlenderDNA.inl b/Engine/lib/assimp/code/BlenderDNA.inl index c65ea81bc..65bc1374c 100644 --- a/Engine/lib/assimp/code/BlenderDNA.inl +++ b/Engine/lib/assimp/code/BlenderDNA.inl @@ -2,7 +2,8 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2017, assimp team +Copyright (c) 2006-2019, assimp team + All rights reserved. @@ -47,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INCLUDED_AI_BLEND_DNA_INL #include -#include "TinyFormatter.h" +#include namespace Assimp { namespace Blender { @@ -306,6 +307,108 @@ void Structure :: ReadField(T& out, const char* name, const FileDatabase& db) co } +//-------------------------------------------------------------------------------- +// field parsing for raw untyped data (like CustomDataLayer.data) +template +bool Structure::ReadCustomDataPtr(std::shared_ptr&out, int cdtype, const char* name, const FileDatabase& db) const { + + const StreamReaderAny::pos old = db.reader->GetCurrentPos(); + + Pointer ptrval; + const Field* f; + try { + f = &(*this)[name]; + + // sanity check, should never happen if the genblenddna script is right + if (!(f->flags & FieldFlag_Pointer)) { + throw Error((Formatter::format(), "Field `", name, "` of structure `", + this->name, "` ought to be a pointer")); + } + + db.reader->IncPtr(f->offset); + Convert(ptrval, db); + // actually it is meaningless on which Structure the Convert is called + // because the `Pointer` argument triggers a special implementation. + } + catch (const Error& e) { + _defaultInitializer()(out, e.what()); + out.reset(); + } + + bool readOk = true; + if (ptrval.val) { + // get block for ptr + const FileBlockHead* block = LocateFileBlockForAddress(ptrval, db); + db.reader->SetCurrentPos(block->start + static_cast((ptrval.val - block->address.val))); + // read block->num instances of given type to out + readOk = readCustomData(out, cdtype, block->num, db); + } + + // and recover the previous stream position + db.reader->SetCurrentPos(old); + +#ifndef ASSIMP_BUILD_BLENDER_NO_STATS + ++db.stats().fields_read; +#endif + + return readOk; +} + +//-------------------------------------------------------------------------------- +template class TOUT, typename T> +bool Structure::ReadFieldPtrVector(vector>&out, const char* name, const FileDatabase& db) const { + out.clear(); + + const StreamReaderAny::pos old = db.reader->GetCurrentPos(); + + Pointer ptrval; + const Field* f; + try { + f = &(*this)[name]; + + // sanity check, should never happen if the genblenddna script is right + if (!(f->flags & FieldFlag_Pointer)) { + throw Error((Formatter::format(), "Field `", name, "` of structure `", + this->name, "` ought to be a pointer")); + } + + db.reader->IncPtr(f->offset); + Convert(ptrval, db); + // actually it is meaningless on which Structure the Convert is called + // because the `Pointer` argument triggers a special implementation. + } + catch (const Error& e) { + _defaultInitializer()(out, e.what()); + out.clear(); + return false; + } + + + if (ptrval.val) { + // find the file block the pointer is pointing to + const FileBlockHead* block = LocateFileBlockForAddress(ptrval, db); + db.reader->SetCurrentPos(block->start + static_cast((ptrval.val - block->address.val))); + // FIXME: basically, this could cause problems with 64 bit pointers on 32 bit systems. + // I really ought to improve StreamReader to work with 64 bit indices exclusively. + + const Structure& s = db.dna[f->type]; + for (size_t i = 0; i < block->num; ++i) { + TOUT p(new T); + s.Convert(*p, db); + out.push_back(p); + } + } + + db.reader->SetCurrentPos(old); + +#ifndef ASSIMP_BUILD_BLENDER_NO_STATS + ++db.stats().fields_read; +#endif + + return true; +} + + //-------------------------------------------------------------------------------- template