summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <nezticle@gmail.com>2024-04-25 11:42:06 +0200
committerAndy Nichols <nezticle@gmail.com>2024-04-25 11:42:06 +0200
commit5967dee48b0b8ed32a41579559570e380462a1dd (patch)
tree72b52967864f0c09b342b0708355cb167ebba14d
parente21b73ab492fefb0cab229da75e385ba0befbffc (diff)
parent8b9ed34eaa3e6ad24254cb7e058fb9150f66b865 (diff)
Merge tag 'v5.4.0' into qt6_assimp
-rw-r--r--.github/workflows/ccpp.yml29
-rw-r--r--.github/workflows/cifuzz.yml2
-rw-r--r--Build.md1
-rw-r--r--CMakeLists.txt57
-rw-r--r--Dockerfile1
-rw-r--r--Readme.md42
-rw-r--r--code/AssetLib/3DS/3DSConverter.cpp14
-rw-r--r--code/AssetLib/3DS/3DSExporter.cpp2
-rw-r--r--code/AssetLib/3DS/3DSExporter.h8
-rw-r--r--code/AssetLib/3DS/3DSHelper.h2
-rw-r--r--code/AssetLib/3DS/3DSLoader.cpp14
-rw-r--r--code/AssetLib/3DS/3DSLoader.h5
-rw-r--r--code/AssetLib/3MF/3MFTypes.h18
-rw-r--r--code/AssetLib/3MF/3MFXmlTags.h7
-rw-r--r--code/AssetLib/3MF/D3MFExporter.cpp2
-rw-r--r--code/AssetLib/3MF/D3MFExporter.h2
-rw-r--r--code/AssetLib/3MF/D3MFImporter.cpp19
-rw-r--r--code/AssetLib/3MF/D3MFImporter.h6
-rw-r--r--code/AssetLib/3MF/D3MFOpcPackage.cpp19
-rw-r--r--code/AssetLib/3MF/D3MFOpcPackage.h2
-rw-r--r--code/AssetLib/3MF/XmlSerializer.cpp158
-rw-r--r--code/AssetLib/3MF/XmlSerializer.h5
-rw-r--r--code/AssetLib/AC/ACLoader.cpp219
-rw-r--r--code/AssetLib/AC/ACLoader.h6
-rw-r--r--code/AssetLib/AMF/AMFImporter.cpp4
-rw-r--r--code/AssetLib/AMF/AMFImporter.hpp103
-rw-r--r--code/AssetLib/AMF/AMFImporter_Geometry.cpp2
-rw-r--r--code/AssetLib/AMF/AMFImporter_Material.cpp2
-rw-r--r--code/AssetLib/AMF/AMFImporter_Node.hpp2
-rw-r--r--code/AssetLib/AMF/AMFImporter_Postprocess.cpp2
-rw-r--r--code/AssetLib/ASE/ASELoader.cpp10
-rw-r--r--code/AssetLib/ASE/ASELoader.h2
-rw-r--r--code/AssetLib/ASE/ASEParser.cpp67
-rw-r--r--code/AssetLib/ASE/ASEParser.h5
-rw-r--r--code/AssetLib/Assbin/AssbinExporter.cpp2
-rw-r--r--code/AssetLib/Assbin/AssbinExporter.h2
-rw-r--r--code/AssetLib/Assbin/AssbinFileWriter.cpp8
-rw-r--r--code/AssetLib/Assbin/AssbinFileWriter.h2
-rw-r--r--code/AssetLib/Assbin/AssbinLoader.cpp4
-rw-r--r--code/AssetLib/Assbin/AssbinLoader.h2
-rw-r--r--code/AssetLib/Assxml/AssxmlExporter.cpp2
-rw-r--r--code/AssetLib/Assxml/AssxmlExporter.h2
-rw-r--r--code/AssetLib/Assxml/AssxmlFileWriter.cpp2
-rw-r--r--code/AssetLib/Assxml/AssxmlFileWriter.h2
-rw-r--r--code/AssetLib/B3D/B3DImporter.cpp24
-rw-r--r--code/AssetLib/B3D/B3DImporter.h2
-rw-r--r--code/AssetLib/BVH/BVHLoader.cpp52
-rw-r--r--code/AssetLib/BVH/BVHLoader.h2
-rw-r--r--code/AssetLib/Blender/BlenderBMesh.cpp2
-rw-r--r--code/AssetLib/Blender/BlenderBMesh.h2
-rw-r--r--code/AssetLib/Blender/BlenderDNA.cpp2
-rw-r--r--code/AssetLib/Blender/BlenderDNA.h2
-rw-r--r--code/AssetLib/Blender/BlenderDNA.inl2
-rw-r--r--code/AssetLib/Blender/BlenderIntermediate.h2
-rw-r--r--code/AssetLib/Blender/BlenderLoader.cpp9
-rw-r--r--code/AssetLib/Blender/BlenderLoader.h2
-rw-r--r--code/AssetLib/Blender/BlenderModifier.cpp7
-rw-r--r--code/AssetLib/Blender/BlenderModifier.h2
-rw-r--r--code/AssetLib/Blender/BlenderScene.cpp2
-rw-r--r--code/AssetLib/Blender/BlenderScene.h2
-rw-r--r--code/AssetLib/Blender/BlenderTessellator.cpp2
-rw-r--r--code/AssetLib/Blender/BlenderTessellator.h2
-rw-r--r--code/AssetLib/C4D/C4DImporter.cpp18
-rw-r--r--code/AssetLib/C4D/C4DImporter.h2
-rw-r--r--code/AssetLib/COB/COBLoader.cpp56
-rw-r--r--code/AssetLib/COB/COBLoader.h20
-rw-r--r--code/AssetLib/COB/COBScene.h2
-rw-r--r--code/AssetLib/CSM/CSMLoader.cpp94
-rw-r--r--code/AssetLib/CSM/CSMLoader.h9
-rw-r--r--code/AssetLib/Collada/ColladaExporter.cpp2
-rw-r--r--code/AssetLib/Collada/ColladaExporter.h2
-rw-r--r--code/AssetLib/Collada/ColladaHelper.cpp2
-rw-r--r--code/AssetLib/Collada/ColladaHelper.h2
-rw-r--r--code/AssetLib/Collada/ColladaLoader.cpp8
-rw-r--r--code/AssetLib/Collada/ColladaLoader.h4
-rw-r--r--code/AssetLib/Collada/ColladaParser.cpp174
-rw-r--r--code/AssetLib/Collada/ColladaParser.h2
-rw-r--r--code/AssetLib/DXF/DXFHelper.h2
-rw-r--r--code/AssetLib/DXF/DXFLoader.cpp291
-rw-r--r--code/AssetLib/DXF/DXFLoader.h2
-rw-r--r--code/AssetLib/FBX/FBXAnimation.cpp2
-rw-r--r--code/AssetLib/FBX/FBXBinaryTokenizer.cpp3
-rw-r--r--code/AssetLib/FBX/FBXCommon.h2
-rw-r--r--code/AssetLib/FBX/FBXCompileConfig.h2
-rw-r--r--code/AssetLib/FBX/FBXConverter.cpp80
-rw-r--r--code/AssetLib/FBX/FBXConverter.h2
-rw-r--r--code/AssetLib/FBX/FBXDeformer.cpp4
-rw-r--r--code/AssetLib/FBX/FBXDocument.cpp4
-rw-r--r--code/AssetLib/FBX/FBXDocument.h2
-rw-r--r--code/AssetLib/FBX/FBXDocumentUtil.cpp2
-rw-r--r--code/AssetLib/FBX/FBXExportNode.cpp2
-rw-r--r--code/AssetLib/FBX/FBXExportNode.h2
-rw-r--r--code/AssetLib/FBX/FBXExportProperty.cpp2
-rw-r--r--code/AssetLib/FBX/FBXExportProperty.h2
-rw-r--r--code/AssetLib/FBX/FBXExporter.cpp57
-rw-r--r--code/AssetLib/FBX/FBXExporter.h2
-rw-r--r--code/AssetLib/FBX/FBXImportSettings.h2
-rw-r--r--code/AssetLib/FBX/FBXImporter.cpp33
-rw-r--r--code/AssetLib/FBX/FBXImporter.h4
-rw-r--r--code/AssetLib/FBX/FBXMaterial.cpp6
-rw-r--r--code/AssetLib/FBX/FBXMeshGeometry.cpp6
-rw-r--r--code/AssetLib/FBX/FBXMeshGeometry.h2
-rw-r--r--code/AssetLib/FBX/FBXModel.cpp2
-rw-r--r--code/AssetLib/FBX/FBXNodeAttribute.cpp2
-rw-r--r--code/AssetLib/FBX/FBXParser.cpp7
-rw-r--r--code/AssetLib/FBX/FBXParser.h2
-rw-r--r--code/AssetLib/FBX/FBXProperties.cpp2
-rw-r--r--code/AssetLib/FBX/FBXProperties.h2
-rw-r--r--code/AssetLib/FBX/FBXTokenizer.cpp2
-rw-r--r--code/AssetLib/FBX/FBXTokenizer.h2
-rw-r--r--code/AssetLib/FBX/FBXUtil.cpp4
-rw-r--r--code/AssetLib/FBX/FBXUtil.h2
-rw-r--r--code/AssetLib/HMP/HMPFileData.h4
-rw-r--r--code/AssetLib/HMP/HMPLoader.cpp4
-rw-r--r--code/AssetLib/HMP/HMPLoader.h2
-rw-r--r--code/AssetLib/HMP/HalfLifeFileData.h2
-rw-r--r--code/AssetLib/IFC/IFCBoolean.cpp2
-rw-r--r--code/AssetLib/IFC/IFCCurve.cpp2
-rw-r--r--code/AssetLib/IFC/IFCGeometry.cpp2
-rw-r--r--code/AssetLib/IFC/IFCLoader.cpp6
-rw-r--r--code/AssetLib/IFC/IFCLoader.h2
-rw-r--r--code/AssetLib/IFC/IFCMaterial.cpp2
-rw-r--r--code/AssetLib/IFC/IFCOpenings.cpp4
-rw-r--r--code/AssetLib/IFC/IFCProfile.cpp2
-rw-r--r--code/AssetLib/IFC/IFCReaderGen1_2x3.cpp4
-rw-r--r--code/AssetLib/IFC/IFCUtil.cpp2
-rw-r--r--code/AssetLib/IFC/IFCUtil.h2
-rw-r--r--code/AssetLib/IQM/IQMImporter.cpp10
-rw-r--r--code/AssetLib/Irr/IRRLoader.cpp13
-rw-r--r--code/AssetLib/Irr/IRRLoader.h2
-rw-r--r--code/AssetLib/Irr/IRRMeshLoader.cpp105
-rw-r--r--code/AssetLib/Irr/IRRMeshLoader.h11
-rw-r--r--code/AssetLib/Irr/IRRShared.cpp14
-rw-r--r--code/AssetLib/LWO/LWOAnimation.cpp2
-rw-r--r--code/AssetLib/LWO/LWOAnimation.h2
-rw-r--r--code/AssetLib/LWO/LWOBLoader.cpp391
-rw-r--r--code/AssetLib/LWO/LWOFileData.h2
-rw-r--r--code/AssetLib/LWO/LWOLoader.cpp2
-rw-r--r--code/AssetLib/LWO/LWOLoader.h2
-rw-r--r--code/AssetLib/LWO/LWOMaterial.cpp2
-rw-r--r--code/AssetLib/LWS/LWSLoader.cpp173
-rw-r--r--code/AssetLib/LWS/LWSLoader.h6
-rw-r--r--code/AssetLib/M3D/M3DExporter.cpp2
-rw-r--r--code/AssetLib/M3D/M3DExporter.h2
-rw-r--r--code/AssetLib/M3D/M3DImporter.cpp4
-rw-r--r--code/AssetLib/M3D/M3DImporter.h2
-rw-r--r--code/AssetLib/M3D/M3DMaterials.h2
-rw-r--r--code/AssetLib/M3D/M3DWrapper.cpp2
-rw-r--r--code/AssetLib/M3D/M3DWrapper.h2
-rw-r--r--code/AssetLib/MD2/MD2FileData.h4
-rw-r--r--code/AssetLib/MD2/MD2Loader.cpp13
-rw-r--r--code/AssetLib/MD2/MD2Loader.h4
-rw-r--r--code/AssetLib/MD2/MD2NormalTable.h2
-rw-r--r--code/AssetLib/MD3/MD3FileData.h4
-rw-r--r--code/AssetLib/MD3/MD3Loader.cpp36
-rw-r--r--code/AssetLib/MD3/MD3Loader.h2
-rw-r--r--code/AssetLib/MD5/MD5Loader.cpp24
-rw-r--r--code/AssetLib/MD5/MD5Loader.h8
-rw-r--r--code/AssetLib/MD5/MD5Parser.cpp230
-rw-r--r--code/AssetLib/MD5/MD5Parser.h120
-rw-r--r--code/AssetLib/MDC/MDCFileData.h4
-rw-r--r--code/AssetLib/MDC/MDCLoader.cpp8
-rw-r--r--code/AssetLib/MDC/MDCLoader.h4
-rw-r--r--code/AssetLib/MDL/HalfLife/HL1FileData.h2
-rw-r--r--code/AssetLib/MDL/HalfLife/HL1ImportDefinitions.h2
-rw-r--r--code/AssetLib/MDL/HalfLife/HL1ImportSettings.h2
-rw-r--r--code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp2
-rw-r--r--code/AssetLib/MDL/HalfLife/HL1MDLLoader.h2
-rw-r--r--code/AssetLib/MDL/HalfLife/HL1MeshTrivert.h2
-rw-r--r--code/AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h2
-rw-r--r--code/AssetLib/MDL/HalfLife/LogFunctions.h2
-rw-r--r--code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp2
-rw-r--r--code/AssetLib/MDL/HalfLife/UniqueNameGenerator.h2
-rw-r--r--code/AssetLib/MDL/MDLDefaultColorMap.h2
-rw-r--r--code/AssetLib/MDL/MDLFileData.h4
-rw-r--r--code/AssetLib/MDL/MDLLoader.cpp8
-rw-r--r--code/AssetLib/MDL/MDLLoader.h13
-rw-r--r--code/AssetLib/MDL/MDLMaterialLoader.cpp7
-rw-r--r--code/AssetLib/MMD/MMDCpp14.h2
-rw-r--r--code/AssetLib/MMD/MMDImporter.cpp8
-rw-r--r--code/AssetLib/MMD/MMDImporter.h28
-rw-r--r--code/AssetLib/MMD/MMDPmdParser.h2
-rw-r--r--code/AssetLib/MMD/MMDPmxParser.cpp10
-rw-r--r--code/AssetLib/MMD/MMDPmxParser.h2
-rw-r--r--code/AssetLib/MMD/MMDVmdParser.h2
-rw-r--r--code/AssetLib/MS3D/MS3DLoader.cpp7
-rw-r--r--code/AssetLib/MS3D/MS3DLoader.h5
-rw-r--r--code/AssetLib/NDO/NDOLoader.cpp14
-rw-r--r--code/AssetLib/NDO/NDOLoader.h6
-rw-r--r--code/AssetLib/NFF/NFFLoader.cpp104
-rw-r--r--code/AssetLib/NFF/NFFLoader.h6
-rw-r--r--code/AssetLib/OFF/OFFLoader.cpp260
-rw-r--r--code/AssetLib/OFF/OFFLoader.h6
-rw-r--r--code/AssetLib/Obj/ObjExporter.cpp34
-rw-r--r--code/AssetLib/Obj/ObjExporter.h13
-rw-r--r--code/AssetLib/Obj/ObjFileData.h2
-rw-r--r--code/AssetLib/Obj/ObjFileImporter.cpp15
-rw-r--r--code/AssetLib/Obj/ObjFileParser.cpp25
-rw-r--r--code/AssetLib/Obj/ObjFileParser.h13
-rw-r--r--code/AssetLib/Obj/ObjTools.h2
-rw-r--r--code/AssetLib/Ogre/OgreBinarySerializer.cpp2
-rw-r--r--code/AssetLib/Ogre/OgreBinarySerializer.h2
-rw-r--r--code/AssetLib/Ogre/OgreImporter.cpp4
-rw-r--r--code/AssetLib/Ogre/OgreImporter.h2
-rw-r--r--code/AssetLib/Ogre/OgreMaterial.cpp2
-rw-r--r--code/AssetLib/Ogre/OgreParsingUtils.h2
-rw-r--r--code/AssetLib/Ogre/OgreStructs.cpp2
-rw-r--r--code/AssetLib/Ogre/OgreStructs.h2
-rw-r--r--code/AssetLib/Ogre/OgreXmlSerializer.cpp2
-rw-r--r--code/AssetLib/Ogre/OgreXmlSerializer.h2
-rw-r--r--code/AssetLib/OpenGEX/OpenGEXExporter.cpp2
-rw-r--r--code/AssetLib/OpenGEX/OpenGEXExporter.h2
-rw-r--r--code/AssetLib/OpenGEX/OpenGEXImporter.cpp78
-rw-r--r--code/AssetLib/OpenGEX/OpenGEXImporter.h2
-rw-r--r--code/AssetLib/OpenGEX/OpenGEXStructs.h2
-rw-r--r--code/AssetLib/Ply/PlyExporter.cpp2
-rw-r--r--code/AssetLib/Ply/PlyExporter.h2
-rw-r--r--code/AssetLib/Ply/PlyLoader.cpp61
-rw-r--r--code/AssetLib/Ply/PlyLoader.h4
-rw-r--r--code/AssetLib/Ply/PlyParser.cpp64
-rw-r--r--code/AssetLib/Ply/PlyParser.h6
-rw-r--r--code/AssetLib/Q3BSP/Q3BSPFileData.h2
-rw-r--r--code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp22
-rw-r--r--code/AssetLib/Q3BSP/Q3BSPFileImporter.h3
-rw-r--r--code/AssetLib/Q3BSP/Q3BSPFileParser.cpp2
-rw-r--r--code/AssetLib/Q3BSP/Q3BSPFileParser.h2
-rw-r--r--code/AssetLib/Q3D/Q3DLoader.cpp27
-rw-r--r--code/AssetLib/Q3D/Q3DLoader.h2
-rw-r--r--code/AssetLib/Raw/RawLoader.cpp25
-rw-r--r--code/AssetLib/Raw/RawLoader.h6
-rw-r--r--code/AssetLib/SIB/SIBImporter.cpp25
-rw-r--r--code/AssetLib/SIB/SIBImporter.h6
-rw-r--r--code/AssetLib/SMD/SMDLoader.cpp150
-rw-r--r--code/AssetLib/SMD/SMDLoader.h41
-rw-r--r--code/AssetLib/STEPParser/STEPFileEncoding.cpp8
-rw-r--r--code/AssetLib/STEPParser/STEPFileEncoding.h2
-rw-r--r--code/AssetLib/STEPParser/STEPFileReader.cpp61
-rw-r--r--code/AssetLib/STEPParser/STEPFileReader.h5
-rw-r--r--code/AssetLib/STL/STLExporter.cpp2
-rw-r--r--code/AssetLib/STL/STLExporter.h2
-rw-r--r--code/AssetLib/STL/STLLoader.cpp67
-rw-r--r--code/AssetLib/STL/STLLoader.h2
-rw-r--r--code/AssetLib/Step/STEPFile.h34
-rw-r--r--code/AssetLib/Step/StepExporter.cpp2
-rw-r--r--code/AssetLib/Step/StepExporter.h2
-rw-r--r--code/AssetLib/Terragen/TerragenLoader.cpp12
-rw-r--r--code/AssetLib/Terragen/TerragenLoader.h4
-rw-r--r--code/AssetLib/Unreal/UnrealLoader.cpp33
-rw-r--r--code/AssetLib/Unreal/UnrealLoader.h2
-rw-r--r--code/AssetLib/X/XFileExporter.cpp2
-rw-r--r--code/AssetLib/X/XFileExporter.h2
-rw-r--r--code/AssetLib/X/XFileHelper.h2
-rw-r--r--code/AssetLib/X/XFileImporter.cpp444
-rw-r--r--code/AssetLib/X/XFileImporter.h4
-rw-r--r--code/AssetLib/X/XFileParser.cpp2
-rw-r--r--code/AssetLib/X/XFileParser.h2
-rw-r--r--code/AssetLib/X3D/X3DGeoHelper.cpp81
-rw-r--r--code/AssetLib/X3D/X3DGeoHelper.h2
-rw-r--r--code/AssetLib/X3D/X3DImporter.cpp2
-rw-r--r--code/AssetLib/X3D/X3DImporter.hpp2
-rw-r--r--code/AssetLib/X3D/X3DImporter_Geometry2D.cpp2
-rw-r--r--code/AssetLib/X3D/X3DImporter_Postprocess.cpp2
-rw-r--r--code/AssetLib/XGL/XGLLoader.cpp238
-rw-r--r--code/AssetLib/XGL/XGLLoader.h34
-rw-r--r--code/AssetLib/glTF/glTFAsset.h2
-rw-r--r--code/AssetLib/glTF/glTFAsset.inl2
-rw-r--r--code/AssetLib/glTF/glTFAssetWriter.h2
-rw-r--r--code/AssetLib/glTF/glTFAssetWriter.inl2
-rw-r--r--code/AssetLib/glTF/glTFCommon.cpp2
-rw-r--r--code/AssetLib/glTF/glTFCommon.h2
-rw-r--r--code/AssetLib/glTF/glTFExporter.cpp11
-rw-r--r--code/AssetLib/glTF/glTFExporter.h5
-rw-r--r--code/AssetLib/glTF/glTFImporter.cpp8
-rw-r--r--code/AssetLib/glTF/glTFImporter.h2
-rw-r--r--code/AssetLib/glTF2/glTF2Asset.h8
-rw-r--r--code/AssetLib/glTF2/glTF2Asset.inl70
-rw-r--r--code/AssetLib/glTF2/glTF2AssetWriter.h2
-rw-r--r--code/AssetLib/glTF2/glTF2AssetWriter.inl7
-rw-r--r--code/AssetLib/glTF2/glTF2Exporter.cpp189
-rw-r--r--code/AssetLib/glTF2/glTF2Exporter.h4
-rw-r--r--code/AssetLib/glTF2/glTF2Importer.cpp8
-rw-r--r--code/AssetLib/glTF2/glTF2Importer.h2
-rw-r--r--code/CApi/AssimpCExport.cpp2
-rw-r--r--code/CApi/CInterfaceIOWrapper.cpp2
-rw-r--r--code/CApi/CInterfaceIOWrapper.h2
-rw-r--r--code/CMakeLists.txt17
-rw-r--r--code/Common/AssertHandler.cpp2
-rw-r--r--code/Common/Assimp.cpp2
-rw-r--r--code/Common/Base64.cpp2
-rw-r--r--code/Common/BaseImporter.cpp12
-rw-r--r--code/Common/BaseProcess.cpp6
-rw-r--r--code/Common/BaseProcess.h8
-rw-r--r--code/Common/Bitmap.cpp2
-rw-r--r--code/Common/Compression.cpp8
-rw-r--r--code/Common/Compression.h8
-rw-r--r--code/Common/CreateAnimMesh.cpp2
-rw-r--r--code/Common/DefaultIOStream.cpp2
-rw-r--r--code/Common/DefaultIOSystem.cpp12
-rw-r--r--code/Common/DefaultLogger.cpp2
-rw-r--r--code/Common/DefaultProgressHandler.h2
-rw-r--r--code/Common/Exceptional.cpp2
-rw-r--r--code/Common/Exporter.cpp2
-rw-r--r--code/Common/FileLogStream.h2
-rw-r--r--code/Common/IOSystem.cpp2
-rw-r--r--code/Common/Importer.cpp2
-rw-r--r--code/Common/Importer.h18
-rw-r--r--code/Common/ImporterRegistry.cpp2
-rw-r--r--code/Common/Maybe.h2
-rw-r--r--code/Common/PolyTools.h2
-rw-r--r--code/Common/PostStepRegistry.cpp2
-rw-r--r--code/Common/RemoveComments.cpp2
-rw-r--r--code/Common/SGSpatialSort.cpp11
-rw-r--r--code/Common/SceneCombiner.cpp2
-rw-r--r--code/Common/ScenePreprocessor.cpp2
-rw-r--r--code/Common/ScenePreprocessor.h8
-rw-r--r--code/Common/ScenePrivate.h2
-rw-r--r--code/Common/SkeletonMeshBuilder.cpp2
-rw-r--r--code/Common/SpatialSort.cpp2
-rw-r--r--code/Common/StackAllocator.h7
-rw-r--r--code/Common/StackAllocator.inl8
-rw-r--r--code/Common/StandardShapes.cpp2
-rw-r--r--code/Common/StbCommon.h20
-rw-r--r--code/Common/StdOStreamLogStream.h2
-rw-r--r--code/Common/Subdivision.cpp3
-rw-r--r--code/Common/TargetAnimation.cpp3
-rw-r--r--code/Common/TargetAnimation.h7
-rw-r--r--code/Common/Version.cpp4
-rw-r--r--code/Common/VertexTriangleAdjacency.cpp4
-rw-r--r--code/Common/VertexTriangleAdjacency.h2
-rw-r--r--code/Common/Win32DebugLogStream.h2
-rw-r--r--code/Common/ZipArchiveIOSystem.cpp50
-rw-r--r--code/Common/material.cpp2
-rw-r--r--code/Common/scene.cpp2
-rw-r--r--code/Common/simd.cpp2
-rw-r--r--code/Common/simd.h2
-rw-r--r--code/Geometry/GeometryUtils.cpp2
-rw-r--r--code/Geometry/GeometryUtils.h2
-rw-r--r--code/Material/MaterialSystem.cpp2
-rw-r--r--code/Material/MaterialSystem.h2
-rw-r--r--code/Pbrt/PbrtExporter.cpp32
-rw-r--r--code/Pbrt/PbrtExporter.h54
-rw-r--r--code/PostProcessing/ArmaturePopulate.cpp2
-rw-r--r--code/PostProcessing/ArmaturePopulate.h2
-rw-r--r--code/PostProcessing/CalcTangentsProcess.cpp2
-rw-r--r--code/PostProcessing/CalcTangentsProcess.h2
-rw-r--r--code/PostProcessing/ComputeUVMappingProcess.cpp2
-rw-r--r--code/PostProcessing/ComputeUVMappingProcess.h2
-rw-r--r--code/PostProcessing/ConvertToLHProcess.cpp2
-rw-r--r--code/PostProcessing/ConvertToLHProcess.h2
-rw-r--r--code/PostProcessing/DeboneProcess.cpp2
-rw-r--r--code/PostProcessing/DeboneProcess.h2
-rw-r--r--code/PostProcessing/DropFaceNormalsProcess.cpp2
-rw-r--r--code/PostProcessing/DropFaceNormalsProcess.h2
-rw-r--r--code/PostProcessing/EmbedTexturesProcess.cpp2
-rw-r--r--code/PostProcessing/EmbedTexturesProcess.h2
-rw-r--r--code/PostProcessing/FindDegenerates.cpp2
-rw-r--r--code/PostProcessing/FindDegenerates.h2
-rw-r--r--code/PostProcessing/FindInstancesProcess.cpp2
-rw-r--r--code/PostProcessing/FindInstancesProcess.h2
-rw-r--r--code/PostProcessing/FindInvalidDataProcess.cpp5
-rw-r--r--code/PostProcessing/FindInvalidDataProcess.h2
-rw-r--r--code/PostProcessing/FixNormalsStep.cpp2
-rw-r--r--code/PostProcessing/FixNormalsStep.h2
-rw-r--r--code/PostProcessing/GenBoundingBoxesProcess.cpp2
-rw-r--r--code/PostProcessing/GenBoundingBoxesProcess.h2
-rw-r--r--code/PostProcessing/GenFaceNormalsProcess.cpp2
-rw-r--r--code/PostProcessing/GenFaceNormalsProcess.h2
-rw-r--r--code/PostProcessing/GenVertexNormalsProcess.cpp2
-rw-r--r--code/PostProcessing/GenVertexNormalsProcess.h2
-rw-r--r--code/PostProcessing/ImproveCacheLocality.cpp213
-rw-r--r--code/PostProcessing/ImproveCacheLocality.h2
-rw-r--r--code/PostProcessing/JoinVerticesProcess.cpp57
-rw-r--r--code/PostProcessing/JoinVerticesProcess.h2
-rw-r--r--code/PostProcessing/LimitBoneWeightsProcess.cpp2
-rw-r--r--code/PostProcessing/LimitBoneWeightsProcess.h2
-rw-r--r--code/PostProcessing/MakeVerboseFormat.cpp2
-rw-r--r--code/PostProcessing/MakeVerboseFormat.h2
-rw-r--r--code/PostProcessing/OptimizeGraph.cpp2
-rw-r--r--code/PostProcessing/OptimizeGraph.h2
-rw-r--r--code/PostProcessing/OptimizeMeshes.cpp2
-rw-r--r--code/PostProcessing/OptimizeMeshes.h2
-rw-r--r--code/PostProcessing/PretransformVertices.cpp13
-rw-r--r--code/PostProcessing/PretransformVertices.h2
-rw-r--r--code/PostProcessing/ProcessHelper.cpp11
-rw-r--r--code/PostProcessing/ProcessHelper.h2
-rw-r--r--code/PostProcessing/RemoveRedundantMaterials.cpp211
-rw-r--r--code/PostProcessing/RemoveRedundantMaterials.h2
-rw-r--r--code/PostProcessing/RemoveVCProcess.cpp2
-rw-r--r--code/PostProcessing/RemoveVCProcess.h2
-rw-r--r--code/PostProcessing/ScaleProcess.cpp2
-rw-r--r--code/PostProcessing/ScaleProcess.h2
-rw-r--r--code/PostProcessing/SortByPTypeProcess.cpp2
-rw-r--r--code/PostProcessing/SortByPTypeProcess.h2
-rw-r--r--code/PostProcessing/SplitByBoneCountProcess.cpp2
-rw-r--r--code/PostProcessing/SplitByBoneCountProcess.h2
-rw-r--r--code/PostProcessing/SplitLargeMeshes.cpp2
-rw-r--r--code/PostProcessing/SplitLargeMeshes.h2
-rw-r--r--code/PostProcessing/TextureTransform.cpp2
-rw-r--r--code/PostProcessing/TextureTransform.h2
-rw-r--r--code/PostProcessing/TriangulateProcess.cpp2
-rw-r--r--code/PostProcessing/TriangulateProcess.h2
-rw-r--r--code/PostProcessing/ValidateDataStructure.cpp2
-rw-r--r--code/PostProcessing/ValidateDataStructure.h2
-rw-r--r--contrib/clipper/clipper.cpp8
-rw-r--r--contrib/poly2tri/poly2tri/sweep/sweep.cc3
-rw-r--r--contrib/pugixml/readme.txt4
-rw-r--r--contrib/pugixml/src/pugiconfig.hpp4
-rw-r--r--contrib/pugixml/src/pugixml.cpp4
-rw-r--r--contrib/pugixml/src/pugixml.hpp4
-rw-r--r--contrib/rapidjson/include/rapidjson/allocators.h513
-rw-r--r--contrib/rapidjson/include/rapidjson/document.h446
-rw-r--r--contrib/rapidjson/include/rapidjson/error/en.h70
-rw-r--r--contrib/rapidjson/include/rapidjson/error/error.h85
-rw-r--r--contrib/rapidjson/include/rapidjson/internal/biginteger.h21
-rw-r--r--contrib/rapidjson/include/rapidjson/internal/diyfp.h6
-rw-r--r--contrib/rapidjson/include/rapidjson/internal/dtoa.h10
-rw-r--r--contrib/rapidjson/include/rapidjson/internal/regex.h2
-rw-r--r--contrib/rapidjson/include/rapidjson/internal/strfunc.h14
-rw-r--r--contrib/rapidjson/include/rapidjson/internal/strtod.h15
-rw-r--r--contrib/rapidjson/include/rapidjson/pointer.h107
-rw-r--r--contrib/rapidjson/include/rapidjson/rapidjson.h89
-rw-r--r--contrib/rapidjson/include/rapidjson/reader.h42
-rw-r--r--contrib/rapidjson/include/rapidjson/schema.h1116
-rw-r--r--contrib/rapidjson/include/rapidjson/uri.h481
-rw-r--r--contrib/rapidjson/include/rapidjson/writer.h13
-rw-r--r--contrib/rapidjson/readme.md54
-rw-r--r--contrib/unzip/ioapi.h2
-rw-r--r--doc/Fileformats.md4
-rw-r--r--doc/dox.h2
-rw-r--r--fuzz/assimp_fuzzer.cc2
-rw-r--r--include/assimp/Base64.hpp2
-rw-r--r--include/assimp/BaseImporter.h8
-rw-r--r--include/assimp/Bitmap.h2
-rw-r--r--include/assimp/BlobIOSystem.h2
-rw-r--r--include/assimp/ByteSwapper.h18
-rw-r--r--include/assimp/ColladaMetaData.h2
-rw-r--r--include/assimp/CreateAnimMesh.h2
-rw-r--r--include/assimp/DefaultIOStream.h2
-rw-r--r--include/assimp/DefaultIOSystem.h2
-rw-r--r--include/assimp/DefaultLogger.hpp2
-rw-r--r--include/assimp/Exceptional.h2
-rw-r--r--include/assimp/Exporter.hpp2
-rw-r--r--include/assimp/GenericProperty.h2
-rw-r--r--include/assimp/GltfMaterial.h2
-rw-r--r--include/assimp/Hash.h2
-rw-r--r--include/assimp/IOStream.hpp15
-rw-r--r--include/assimp/IOStreamBuffer.h9
-rw-r--r--include/assimp/IOSystem.hpp12
-rw-r--r--include/assimp/Importer.hpp4
-rw-r--r--include/assimp/LineSplitter.h24
-rw-r--r--include/assimp/LogAux.h2
-rw-r--r--include/assimp/LogStream.hpp2
-rw-r--r--include/assimp/Logger.hpp2
-rw-r--r--include/assimp/MathFunctions.h2
-rw-r--r--include/assimp/MemoryIOWrapper.h2
-rw-r--r--include/assimp/NullLogger.hpp2
-rw-r--r--include/assimp/ObjMaterial.h2
-rw-r--r--include/assimp/ParsingUtils.h37
-rw-r--r--include/assimp/Profiler.h2
-rw-r--r--include/assimp/ProgressHandler.hpp2
-rw-r--r--include/assimp/RemoveComments.h2
-rw-r--r--include/assimp/SGSpatialSort.h9
-rw-r--r--include/assimp/SceneCombiner.h2
-rw-r--r--include/assimp/SkeletonMeshBuilder.h2
-rw-r--r--include/assimp/SmallVector.h2
-rw-r--r--include/assimp/SmoothingGroups.h2
-rw-r--r--include/assimp/SmoothingGroups.inl2
-rw-r--r--include/assimp/SpatialSort.h2
-rw-r--r--include/assimp/StandardShapes.h2
-rw-r--r--include/assimp/StreamReader.h8
-rw-r--r--include/assimp/StreamWriter.h8
-rw-r--r--include/assimp/StringComparison.h2
-rw-r--r--include/assimp/StringUtils.h2
-rw-r--r--include/assimp/Subdivision.h2
-rw-r--r--include/assimp/TinyFormatter.h2
-rw-r--r--include/assimp/Vertex.h2
-rw-r--r--include/assimp/XMLTools.h2
-rw-r--r--include/assimp/XmlParser.h2
-rw-r--r--include/assimp/ZipArchiveIOSystem.h5
-rw-r--r--include/assimp/aabb.h12
-rw-r--r--include/assimp/ai_assert.h2
-rw-r--r--include/assimp/anim.h3
-rw-r--r--include/assimp/camera.h2
-rw-r--r--include/assimp/cexport.h2
-rw-r--r--include/assimp/cfileio.h2
-rw-r--r--include/assimp/cimport.h2
-rw-r--r--include/assimp/color4.h2
-rw-r--r--include/assimp/color4.inl2
-rw-r--r--include/assimp/commonMetaData.h2
-rw-r--r--include/assimp/config.h.in40
-rw-r--r--include/assimp/defs.h2
-rw-r--r--include/assimp/importerdesc.h2
-rw-r--r--include/assimp/light.h2
-rw-r--r--include/assimp/material.h2
-rw-r--r--include/assimp/material.inl2
-rw-r--r--include/assimp/matrix3x3.h2
-rw-r--r--include/assimp/matrix3x3.inl2
-rw-r--r--include/assimp/matrix4x4.h9
-rw-r--r--include/assimp/matrix4x4.inl11
-rw-r--r--include/assimp/mesh.h10
-rw-r--r--include/assimp/metadata.h2
-rw-r--r--include/assimp/pbrmaterial.h2
-rw-r--r--include/assimp/postprocess.h2
-rw-r--r--include/assimp/qnan.h2
-rw-r--r--include/assimp/quaternion.h6
-rw-r--r--include/assimp/quaternion.inl2
-rw-r--r--include/assimp/scene.h2
-rw-r--r--include/assimp/texture.h2
-rw-r--r--include/assimp/types.h19
-rw-r--r--include/assimp/vector2.h2
-rw-r--r--include/assimp/vector2.inl2
-rw-r--r--include/assimp/vector3.h4
-rw-r--r--include/assimp/vector3.inl2
-rw-r--r--include/assimp/version.h2
-rw-r--r--packaging/windows-mkzip/bin_readme.txt29
-rw-r--r--packaging/windows-mkzip/mkfinal.bat169
-rw-r--r--packaging/windows-mkzip/mkrev.bat27
-rw-r--r--port/PyAssimp/LICENSE17
-rw-r--r--port/PyAssimp/pyassimp/helper.py12
-rw-r--r--samples/SimpleTexturedDirectx11/CMakeLists.txt1
-rw-r--r--samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp1
-rw-r--r--samples/SimpleTexturedOpenGL/CMakeLists.txt1
-rw-r--r--samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp1
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/models/AC/SphereWithLight.acc535
-rw-r--r--test/models/IRR/EpisodeII_TheDwarfesStrikeBack.irr44
-rw-r--r--test/models/IRR/EpisodeII_TheDwarfesStrikeBack_UTF16LE.irrbin95826 -> 95934 bytes
-rw-r--r--test/models/IRR/EpisodeI_ANewDwarf.irr38
-rw-r--r--test/models/IRR/EpisodeI_ANewDwarf_UTF16LE.irrbin72352 -> 72618 bytes
-rw-r--r--test/models/IRR/animMesh.irr6
-rw-r--r--test/models/IRR/animMesh_UTF16LE.irrbin12908 -> 12950 bytes
-rw-r--r--test/models/IRR/assets/1.png (renamed from test/models/IRR/1.png)bin28975 -> 28975 bytes
-rw-r--r--test/models/IRR/assets/SpiderTex.jpg (renamed from test/models/IRR/SpiderTex.jpg)bin15750 -> 15750 bytes
-rw-r--r--test/models/IRR/assets/UVTransformTestImg.png (renamed from test/models/IRR/UVTransformTestImg.png)bin34368 -> 34368 bytes
-rw-r--r--test/models/IRR/assets/axe.jpg (renamed from test/models/IRR/axe.jpg)bin65191 -> 65191 bytes
-rw-r--r--test/models/IRR/assets/brownground_1-1.jpg (renamed from test/models/IRR/brownground_1-1.jpg)bin66623 -> 66623 bytes
-rw-r--r--test/models/IRR/assets/crackedground_1-6.jpg (renamed from test/models/IRR/crackedground_1-6.jpg)bin41455 -> 41455 bytes
-rw-r--r--test/models/IRR/assets/default.pngbin0 -> 50279 bytes
-rw-r--r--test/models/IRR/assets/default_texture.pngbin0 -> 264673 bytes
-rw-r--r--test/models/IRR/assets/drkwood2.jpg (renamed from test/models/IRR/drkwood2.jpg)bin203856 -> 203856 bytes
-rw-r--r--test/models/IRR/assets/dwarf.jpg (renamed from test/models/IRR/dwarf.jpg)bin84158 -> 84158 bytes
-rw-r--r--test/models/IRR/assets/dwarf.x (renamed from test/models/IRR/dwarf.x)0
-rw-r--r--test/models/IRR/assets/earthSpherical.jpg (renamed from test/models/IRR/earthSpherical.jpg)bin422120 -> 422120 bytes
-rw-r--r--test/models/IRR/assets/engineflare1.jpg (renamed from test/models/IRR/engineflare1.jpg)bin3630 -> 3630 bytes
-rw-r--r--test/models/IRR/assets/skybox/credits.txt11
-rw-r--r--test/models/IRR/assets/skybox/default_skybox0.jpgbin0 -> 51271 bytes
-rw-r--r--test/models/IRR/assets/skybox/default_skybox1.jpgbin0 -> 21534 bytes
-rw-r--r--test/models/IRR/assets/skybox/default_skybox2.jpgbin0 -> 30183 bytes
-rw-r--r--test/models/IRR/assets/skybox/default_skybox3.jpgbin0 -> 36117 bytes
-rw-r--r--test/models/IRR/assets/skybox/default_skyboxdn.jpgbin0 -> 11149 bytes
-rw-r--r--test/models/IRR/assets/skybox/default_skyboxup.jpgbin0 -> 9452 bytes
-rw-r--r--test/models/IRR/assets/spider.mtl (renamed from test/models/IRR/spider.mtl)0
-rw-r--r--test/models/IRR/assets/wal67ar_small.jpg (renamed from test/models/IRR/wal67ar_small.jpg)bin9287 -> 9287 bytes
-rw-r--r--test/models/IRR/assets/wal69ar_small.jpg (renamed from test/models/IRR/wal69ar_small.jpg)bin7929 -> 7929 bytes
-rw-r--r--test/models/IRR/box.irr2
-rw-r--r--test/models/IRR/box_UTF16LE.irrbin5368 -> 5382 bytes
-rw-r--r--test/models/IRR/cellar.irrmesh8
-rw-r--r--test/models/IRR/dawfInCellar_ChildOfCellar.irr14
-rw-r--r--test/models/IRR/dawfInCellar_ChildOfCellar_UTF16LE.irrbin21752 -> 21850 bytes
-rw-r--r--test/models/IRR/dawfInCellar_SameHierarchy.irr14
-rw-r--r--test/models/IRR/dawfInCellar_SameHierarchy_UTF16LE.irrbin21490 -> 21588 bytes
-rw-r--r--test/models/IRR/instancing.irr34
-rw-r--r--test/models/IRR/scenegraphAnim.irr20
-rw-r--r--test/models/IRR/scenegraphAnimMod.irr20
-rw-r--r--test/models/IRR/scenegraphAnimMod_UTF16LE.irrbin47672 -> 47812 bytes
-rw-r--r--test/models/IRR/scenegraphAnim_UTF16LE.irrbin47404 -> 47544 bytes
-rw-r--r--test/models/IRR/sphere.irr2
-rw-r--r--test/models/IRR/sphere_UTF16LE.irrbin5538 -> 5552 bytes
-rw-r--r--test/models/IRRMesh/assets/1.png (renamed from test/models/IRRMesh/1.png)bin28975 -> 28975 bytes
-rw-r--r--test/models/IRRMesh/assets/SpiderTex.jpg (renamed from test/models/IRRMesh/SpiderTex.jpg)bin15750 -> 15750 bytes
-rw-r--r--test/models/IRRMesh/assets/UVTransformTestImg.pngbin0 -> 34368 bytes
-rw-r--r--test/models/IRRMesh/assets/UVTransform_OffsetUV0.5-mirrorUV.pngbin0 -> 48965 bytes
-rw-r--r--test/models/IRRMesh/assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72.pngbin0 -> 105643 bytes
-rw-r--r--test/models/IRRMesh/assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.pngbin0 -> 130740 bytes
-rw-r--r--test/models/IRRMesh/assets/UVTransform_ScaleUV2x_Rotate45.pngbin0 -> 111075 bytes
-rw-r--r--test/models/IRRMesh/assets/brownground_1-1.jpg (renamed from test/models/IRRMesh/brownground_1-1.jpg)bin66623 -> 66623 bytes
-rw-r--r--test/models/IRRMesh/assets/crackedground_1-6.jpg (renamed from test/models/IRRMesh/crackedground_1-6.jpg)bin41455 -> 41455 bytes
-rw-r--r--test/models/IRRMesh/assets/drkwood2.jpg (renamed from test/models/IRRMesh/drkwood2.jpg)bin203856 -> 203856 bytes
-rw-r--r--test/models/IRRMesh/assets/engineflare1.jpg (renamed from test/models/IRRMesh/engineflare1.jpg)bin3630 -> 3630 bytes
-rw-r--r--test/models/IRRMesh/assets/wal67ar_small.jpg (renamed from test/models/IRRMesh/wal67ar_small.jpg)bin9287 -> 9287 bytes
-rw-r--r--test/models/IRRMesh/assets/wal69ar_small.jpg (renamed from test/models/IRRMesh/wal69ar_small.jpg)bin7929 -> 7929 bytes
-rw-r--r--test/models/IRRMesh/cellar.irrmesh8
-rw-r--r--test/models/IRRMesh/cellar_UTF16LE.irrmeshbin188818 -> 188874 bytes
-rw-r--r--test/models/IRRMesh/spider.irrmesh8
-rw-r--r--test/models/IRRMesh/spider_UTF16LE.irrmeshbin293134 -> 293176 bytes
-rw-r--r--test/models/IRRMesh/testFormatDetection.xml10
-rw-r--r--test/models/IRRMesh/testFormatDetection_UTF16LE.xmlbin53842 -> 54312 bytes
-rw-r--r--test/models/X3D/IndexedLineSet.x3d19
-rw-r--r--test/models/glTF2/simple_skin/quad_skin.glbbin0 -> 10048 bytes
-rw-r--r--test/models/invalid/box_nested_animation_4286.dae196
-rw-r--r--test/models/invalid/crash-30d6d0f7c529b3b66b4131700b7a4580cd7082df.plybin0 -> 159 bytes
-rw-r--r--test/models/invalid/readme.txt3
-rw-r--r--test/unit/AbstractImportExportBase.cpp2
-rw-r--r--test/unit/AssimpAPITest.cpp2
-rw-r--r--test/unit/AssimpAPITest_aiMatrix3x3.cpp2
-rw-r--r--test/unit/AssimpAPITest_aiMatrix4x4.cpp11
-rw-r--r--test/unit/AssimpAPITest_aiQuaternion.cpp2
-rw-r--r--test/unit/AssimpAPITest_aiVector2D.cpp2
-rw-r--r--test/unit/AssimpAPITest_aiVector3D.cpp2
-rw-r--r--test/unit/Common/uiScene.cpp2
-rw-r--r--test/unit/Common/utAssertHandler.cpp2
-rw-r--r--test/unit/Common/utBase64.cpp2
-rw-r--r--test/unit/Common/utBaseProcess.cpp2
-rw-r--r--test/unit/Common/utHash.cpp2
-rw-r--r--test/unit/Common/utLineSplitter.cpp2
-rw-r--r--test/unit/Common/utMaybe.cpp2
-rw-r--r--test/unit/Common/utMesh.cpp2
-rw-r--r--test/unit/Common/utSpatialSort.cpp2
-rw-r--r--test/unit/Common/utStandardShapes.cpp2
-rw-r--r--test/unit/Common/utXmlParser.cpp2
-rw-r--r--test/unit/Geometry/utGeometryUtils.cpp2
-rw-r--r--test/unit/ImportExport/MDL/MDLHL1TestFiles.h2
-rw-r--r--test/unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp2
-rw-r--r--test/unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp2
-rw-r--r--test/unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp2
-rw-r--r--test/unit/ImportExport/Pbrt/utPbrtImportExport.cpp70
-rw-r--r--test/unit/ImportExport/RAW/utRAWImportExport.cpp2
-rw-r--r--test/unit/ImportExport/Terragen/utTerragenImportExport.cpp2
-rw-r--r--test/unit/ImportExport/utAssjsonImportExport.cpp2
-rw-r--r--test/unit/ImportExport/utCOBImportExport.cpp2
-rw-r--r--test/unit/ImportExport/utExporter.cpp2
-rw-r--r--test/unit/ImportExport/utMD2Importer.cpp2
-rw-r--r--test/unit/ImportExport/utMD5Importer.cpp2
-rw-r--r--test/unit/ImportExport/utMDLImporter.cpp2
-rw-r--r--test/unit/ImportExport/utNFFImportExport.cpp2
-rw-r--r--test/unit/ImportExport/utOFFImportExport.cpp2
-rw-r--r--test/unit/ImportExport/utOgreImportExport.cpp2
-rw-r--r--test/unit/ImportExport/utQ3BSPFileImportExport.cpp2
-rw-r--r--test/unit/ImportExport/utXGLImportExport.cpp2
-rw-r--r--test/unit/MathTest.cpp2
-rw-r--r--test/unit/MathTest.h2
-rw-r--r--test/unit/RandomNumberGeneration.h2
-rw-r--r--test/unit/SceneDiffer.cpp2
-rw-r--r--test/unit/SceneDiffer.h2
-rw-r--r--test/unit/TestIOSystem.h2
-rw-r--r--test/unit/TestModelFactory.h2
-rw-r--r--test/unit/UTLogStream.h2
-rw-r--r--test/unit/UnitTestFileGenerator.h8
-rw-r--r--test/unit/ut3DImportExport.cpp2
-rw-r--r--test/unit/ut3DSImportExport.cpp2
-rw-r--r--test/unit/utACImportExport.cpp8
-rw-r--r--test/unit/utAMFImportExport.cpp2
-rw-r--r--test/unit/utASEImportExport.cpp2
-rw-r--r--test/unit/utAnim.cpp2
-rw-r--r--test/unit/utArmaturePopulate.cpp2
-rw-r--r--test/unit/utAssbinImportExport.cpp2
-rw-r--r--test/unit/utB3DImportExport.cpp2
-rw-r--r--test/unit/utBVHImportExport.cpp2
-rw-r--r--test/unit/utBatchLoader.cpp2
-rw-r--r--test/unit/utBlendImportAreaLight.cpp5
-rw-r--r--test/unit/utBlendImportMaterials.cpp2
-rw-r--r--test/unit/utBlenderImportExport.cpp2
-rw-r--r--test/unit/utBlenderIntermediate.cpp2
-rw-r--r--test/unit/utBlenderWork.cpp9
-rw-r--r--test/unit/utCSMImportExport.cpp2
-rw-r--r--test/unit/utColladaExport.cpp2
-rw-r--r--test/unit/utColladaImportExport.cpp10
-rw-r--r--test/unit/utD3MFImportExport.cpp2
-rw-r--r--test/unit/utDXFImporterExporter.cpp2
-rw-r--r--test/unit/utDefaultIOStream.cpp2
-rw-r--r--test/unit/utExport.cpp2
-rw-r--r--test/unit/utFBXImporterExporter.cpp2
-rw-r--r--test/unit/utFastAtof.cpp2
-rw-r--r--test/unit/utFindDegenerates.cpp2
-rw-r--r--test/unit/utFindInvalidData.cpp2
-rw-r--r--test/unit/utFixInfacingNormals.cpp2
-rw-r--r--test/unit/utGenBoundingBoxesProcess.cpp2
-rw-r--r--test/unit/utGenNormals.cpp2
-rw-r--r--test/unit/utHMPImportExport.cpp2
-rw-r--r--test/unit/utIFCImportExport.cpp2
-rw-r--r--test/unit/utIOStreamBuffer.cpp2
-rw-r--r--test/unit/utIOSystem.cpp2
-rw-r--r--test/unit/utImporter.cpp2
-rw-r--r--test/unit/utImproveCacheLocality.cpp2
-rw-r--r--test/unit/utIssues.cpp2
-rw-r--r--test/unit/utJoinVertices.cpp2
-rw-r--r--test/unit/utLWOImportExport.cpp2
-rw-r--r--test/unit/utLWSImportExport.cpp2
-rw-r--r--test/unit/utLimitBoneWeights.cpp2
-rw-r--r--test/unit/utMDCImportExport.cpp2
-rw-r--r--test/unit/utMaterialSystem.cpp2
-rw-r--r--test/unit/utMatrix3x3.cpp2
-rw-r--r--test/unit/utMatrix4x4.cpp16
-rw-r--r--test/unit/utMetadata.cpp2
-rw-r--r--test/unit/utObjImportExport.cpp2
-rw-r--r--test/unit/utObjTools.cpp2
-rw-r--r--test/unit/utOpenGEXImportExport.cpp2
-rw-r--r--test/unit/utPLYImportExport.cpp9
-rw-r--r--test/unit/utPMXImporter.cpp2
-rw-r--r--test/unit/utPretransformVertices.cpp2
-rw-r--r--test/unit/utProfiler.cpp2
-rw-r--r--test/unit/utQ3DImportExport.cpp2
-rw-r--r--test/unit/utRemoveComments.cpp2
-rw-r--r--test/unit/utRemoveComponent.cpp2
-rw-r--r--test/unit/utRemoveRedundantMaterials.cpp2
-rw-r--r--test/unit/utRemoveVCProcess.cpp2
-rw-r--r--test/unit/utSIBImporter.cpp2
-rw-r--r--test/unit/utSMDImportExport.cpp2
-rw-r--r--test/unit/utSTLImportExport.cpp2
-rw-r--r--test/unit/utScaleProcess.cpp2
-rw-r--r--test/unit/utSceneCombiner.cpp2
-rw-r--r--test/unit/utScenePreprocessor.cpp2
-rw-r--r--test/unit/utSharedPPData.cpp2
-rw-r--r--test/unit/utSimd.cpp2
-rw-r--r--test/unit/utSortByPType.cpp2
-rw-r--r--test/unit/utSplitLargeMeshes.cpp2
-rw-r--r--test/unit/utStringUtils.cpp2
-rw-r--r--test/unit/utTargetAnimation.cpp2
-rw-r--r--test/unit/utTextureTransform.cpp2
-rw-r--r--test/unit/utTriangulate.cpp2
-rw-r--r--test/unit/utTypes.cpp2
-rw-r--r--test/unit/utVector3.cpp2
-rw-r--r--test/unit/utVersion.cpp12
-rw-r--r--test/unit/utVertexTriangleAdjacency.cpp2
-rw-r--r--test/unit/utX3DImportExport.cpp16
-rw-r--r--test/unit/utXImporterExporter.cpp2
-rw-r--r--test/unit/utglTF2ImportExport.cpp164
-rw-r--r--test/unit/utglTFImportExport.cpp2
-rw-r--r--tools/assimp_cmd/CMakeLists.txt2
-rw-r--r--tools/assimp_cmd/CompareDump.cpp2
-rw-r--r--tools/assimp_cmd/Export.cpp2
-rw-r--r--tools/assimp_cmd/ImageExtractor.cpp2
-rw-r--r--tools/assimp_cmd/Info.cpp2
-rw-r--r--tools/assimp_cmd/Main.cpp2
-rw-r--r--tools/assimp_cmd/Main.h2
-rw-r--r--tools/assimp_cmd/WriteDump.cpp2
-rw-r--r--tools/assimp_view/AnimEvaluator.cpp2
-rw-r--r--tools/assimp_view/AnimEvaluator.h2
-rw-r--r--tools/assimp_view/AssetHelper.h2
-rw-r--r--tools/assimp_view/Background.cpp2
-rw-r--r--tools/assimp_view/CMakeLists.txt2
-rw-r--r--tools/assimp_view/Display.cpp75
-rw-r--r--tools/assimp_view/HelpDialog.cpp2
-rw-r--r--tools/assimp_view/Input.cpp2
-rw-r--r--tools/assimp_view/LogDisplay.cpp2
-rw-r--r--tools/assimp_view/LogWindow.cpp2
-rw-r--r--tools/assimp_view/Material.cpp2
-rw-r--r--tools/assimp_view/MaterialManager.h2
-rw-r--r--tools/assimp_view/MeshRenderer.cpp2
-rw-r--r--tools/assimp_view/MessageProc.cpp2
-rw-r--r--tools/assimp_view/Normals.cpp2
-rw-r--r--tools/assimp_view/SceneAnimator.cpp2
-rw-r--r--tools/assimp_view/SceneAnimator.h2
-rw-r--r--tools/assimp_view/Shaders.cpp2
-rw-r--r--tools/assimp_view/assimp_view.cpp4
-rw-r--r--tools/assimp_view/assimp_view.h2
-rw-r--r--tools/make/build_env_win32.bat57
-rw-r--r--tools/make/make_all_win32_x64.bat18
748 files changed, 7925 insertions, 4370 deletions
diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml
index 2c5ca438b..db152b813 100644
--- a/.github/workflows/ccpp.yml
+++ b/.github/workflows/ccpp.yml
@@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- name: [ubuntu-latest-g++, macos-latest-clang++, windows-latest-cl.exe, ubuntu-latest-clang++, ubuntu-gcc-hunter, macos-clang-hunter, windows-msvc-hunter]
+ name: [ubuntu-latest-g++, macos-latest-clang++, windows-latest-cl.exe, ubuntu-latest-clang++]
# For Windows msvc, for Linux and macOS let's use the clang compiler, use gcc for Linux.
include:
- name: windows-latest-cl.exe
@@ -35,15 +35,6 @@ jobs:
os: ubuntu-latest
cxx: g++
cc: gcc
- - name: ubuntu-gcc-hunter
- os: ubuntu-latest
- toolchain: ninja-gcc-cxx17-fpic
- - name: macos-clang-hunter
- os: macos-latest
- toolchain: ninja-clang-cxx17-fpic
- - name: windows-msvc-hunter
- os: windows-latest
- toolchain: ninja-vs-win64-cxx17
steps:
- uses: actions/checkout@v4
@@ -55,29 +46,15 @@ jobs:
- uses: ilammy/msvc-dev-cmd@v1
- name: Set Compiler Environment
- if: "!endsWith(matrix.name, 'hunter')"
uses: lukka/set-shell-env@v1
with:
CXX: ${{ matrix.cxx }}
CC: ${{ matrix.cc }}
- - name: Set Compiler Environment for Hunter on Windows
- if: startsWith(matrix.name, 'windows') && endsWith(matrix.name, 'hunter')
- uses: lukka/set-shell-env@v1
- with:
- VS160COMNTOOLS: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools
-
- - name: Checkout Hunter toolchains
- if: endsWith(matrix.name, 'hunter')
- uses: actions/checkout@v4
- with:
- repository: cpp-pm/polly
- path: cmake/polly
-
- name: Cache DX SDK
id: dxcache
if: contains(matrix.name, 'windows')
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: '${{ github.workspace }}/DX_SDK'
key: ${{ runner.os }}-DX_SDK
@@ -121,7 +98,7 @@ jobs:
run: cd build/bin && ./unit ${{ steps.hunter_extra_test_args.outputs.args }}
shell: bash
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
if: matrix.name == 'windows-msvc'
with:
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}'
diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml
index a84be8cbc..38f54ce06 100644
--- a/.github/workflows/cifuzz.yml
+++ b/.github/workflows/cifuzz.yml
@@ -19,7 +19,7 @@ jobs:
dry-run: false
language: c++
- name: Upload Crash
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
diff --git a/Build.md b/Build.md
index 957031b5f..9440a0073 100644
--- a/Build.md
+++ b/Build.md
@@ -43,6 +43,7 @@ cd assimp
cmake CMakeLists.txt
cmake --build .
```
+Note that by default this builds a shared library into the `bin` directory. If you want to build it as a static library see the build options at the bottom of this file.
### Build instructions for Windows with Visual-Studio
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75b160c6f..31c5e6615 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
# Open Asset Import Library (assimp)
# ----------------------------------------------------------------------
-# Copyright (c) 2006-2023, assimp team
+# Copyright (c) 2006-2024, assimp team
#
# All rights reserved.
#
@@ -38,9 +38,9 @@ SET(CMAKE_POLICY_DEFAULT_CMP0012 NEW)
SET(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
SET(CMAKE_POLICY_DEFAULT_CMP0092 NEW)
-CMAKE_MINIMUM_REQUIRED( VERSION 3.10 )
+CMAKE_MINIMUM_REQUIRED( VERSION 3.22 )
-# Disabled importers: m3d for 5.1
+# Disabled importers: m3d for 5.1 or later
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_IMPORTER)
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_EXPORTER)
# Toggles the use of the hunter package manager
@@ -49,13 +49,13 @@ option(ASSIMP_HUNTER_ENABLED "Enable Hunter package manager support" OFF)
IF(ASSIMP_HUNTER_ENABLED)
include("cmake-modules/HunterGate.cmake")
HunterGate(
- URL "https://github.com/cpp-pm/hunter/archive/v0.24.18.tar.gz"
- SHA1 "1292e4d661e1770d6d6ca08c12c07cf34a0bf718"
+ URL "https://github.com/cpp-pm/hunter/archive/v0.25.5.tar.gz"
+ SHA1 "a20151e4c0740ee7d0f9994476856d813cdead29"
)
add_definitions(-DASSIMP_USE_HUNTER)
ENDIF()
-PROJECT(Assimp VERSION 5.3.0)
+PROJECT(Assimp VERSION 5.4.0)
# All supported options ###############################################
@@ -131,18 +131,18 @@ OPTION ( ASSIMP_IGNORE_GIT_HASH
IF (WIN32)
OPTION( ASSIMP_BUILD_ZLIB
- "Build your own zlib"
+ "Build your zlib"
ON
)
ELSE()
OPTION( ASSIMP_BUILD_ZLIB
- "Build your own zlib"
- ON
+ "Build your zlib"
+ OFF
)
ENDIF()
IF (WIN32)
- # Use subset of Windows.h
+ # Use a subset of Windows.h
ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN )
IF(MSVC)
@@ -150,16 +150,16 @@ IF (WIN32)
"Install MSVC debug files."
ON )
IF(NOT (MSVC_VERSION LESS 1900))
- # Multibyte character set is deprecated since at least MSVC2015 (possibly earlier)
+ # Multibyte character set has been deprecated since at least MSVC2015 (possibly earlier)
ADD_DEFINITIONS( -DUNICODE -D_UNICODE )
ENDIF()
- # Link statically against c/c++ lib to avoid missing redistriburable such as
+ # Link statically against c/c++ lib to avoid missing redistributable such as
# "VCRUNTIME140.dll not found. Try reinstalling the app.", but give users
# a choice to opt for the shared runtime if they want.
option(USE_STATIC_CRT "Link against the static runtime libraries." OFF)
- # The CMAKE_CXX_FLAGS vars can be overriden by some Visual Studio generators, so we use an alternative
+ # The CMAKE_CXX_FLAGS vars can be overridden by some Visual Studio generators, so we use an alternative
# global method here:
if (${USE_STATIC_CRT})
add_compile_options(
@@ -249,16 +249,16 @@ SET(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
IF( UNIX )
# Use GNUInstallDirs for Unix predefined directories
INCLUDE(GNUInstallDirs)
- # Ensure that we do not run into issues like http://www.tcm.phy.cam.ac.uk/sw/inodes64.html on 32 bit linux
+ # Ensure that we do not run into issues like http://www.tcm.phy.cam.ac.uk/sw/inodes64.html on 32 bit Linux
IF(NOT ${OPERATING_SYSTEM} MATCHES "Android")
- IF ( CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux
+ IF ( CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit Linux
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 )
ENDIF()
ENDIF()
ENDIF()
# Grouped compiler settings ########################################
-IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW)
+IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW AND NOT HAIKU)
IF(NOT ASSIMP_HUNTER_ENABLED)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
ENDIF()
@@ -289,7 +289,7 @@ ELSEIF(MSVC)
IF(MSVC12)
ADD_COMPILE_OPTIONS(/wd4351)
ENDIF()
- # supress warning for double to float conversion if Double precission is activated
+ # supress warning for double to float conversion if Double precision is activated
ADD_COMPILE_OPTIONS(/wd4244)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
@@ -311,9 +311,9 @@ ELSEIF( MINGW )
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
ENDIF()
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
- SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -Wa,-mbig-obj -g ${CMAKE_CXX_FLAGS}")
+ SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wno-dangling-reference -Wall -Wno-long-long -Wa,-mbig-obj -g ${CMAKE_CXX_FLAGS}")
ELSE()
- SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -Wa,-mbig-obj -O3 ${CMAKE_CXX_FLAGS}")
+ SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wno-dangling-reference -Wall -Wno-long-long -Wa,-mbig-obj -O3 ${CMAKE_CXX_FLAGS}")
ENDIF()
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
ENDIF()
@@ -563,9 +563,9 @@ SET ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER OFF CACHE BOOL
)
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
- IF ( MSVC )
- SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/includes")
+ SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/includes")
+ IF (WIN32)
# pick the correct prebuilt library
IF(MSVC143)
SET(C4D_LIB_POSTFIX "_2022")
@@ -583,7 +583,7 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
SET(C4D_LIB_POSTFIX "_2010")
ELSE()
MESSAGE( FATAL_ERROR
- "C4D is currently only supported with MSVC 10, 11, 12, 14, 14.2, 14.3"
+ "C4D for Windows is currently only supported with MSVC 10, 11, 12, 14, 14.2, 14.3"
)
ENDIF()
@@ -601,9 +601,20 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
# winsock and winmm are necessary (and undocumented) dependencies of Cineware SDK because
# it can be used to communicate with a running Cinema 4D instance
SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib)
+ ELSEIF (APPLE)
+ SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/libraries/osx")
+
+ SET(C4D_DEBUG_LIBRARIES
+ "${C4D_LIB_BASE_PATH}/debug/libcinewarelib.a"
+ "${C4D_LIB_BASE_PATH}/debug/libjpeglib.a"
+ )
+ SET(C4D_RELEASE_LIBRARIES
+ "${C4D_LIB_BASE_PATH}/release/libcinewarelib.a"
+ "${C4D_LIB_BASE_PATH}/release/libjpeglib.a"
+ )
ELSE ()
MESSAGE( FATAL_ERROR
- "C4D is currently only available on Windows with Cineware SDK installed in contrib/Cineware"
+ "C4D is currently only available on Windows and macOS with Cineware SDK installed in contrib/Cineware"
)
ENDIF ()
ELSE ()
diff --git a/Dockerfile b/Dockerfile
index 5da5458f8..eb5715d0f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y ninja-build \
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update
WORKDIR /opt
+RUN apt install zlib1g-dev
# Build Assimp
RUN git clone https://github.com/assimp/assimp.git /opt/assimp
diff --git a/Readme.md b/Readme.md
index 9a8ac7c33..eae0cf00a 100644
--- a/Readme.md
+++ b/Readme.md
@@ -6,42 +6,37 @@ Open Asset Import Library is a library to load various 3d file formats into a sh
### Current project status ###
[![Financial Contributors on Open Collective](https://opencollective.com/assimp/all/badge.svg?label=financial+contributors)](https://opencollective.com/assimp)
![C/C++ CI](https://github.com/assimp/assimp/workflows/C/C++%20CI/badge.svg)
-<a href="https://scan.coverity.com/projects/5607">
- <img alt="Coverity Scan Build Status"
- src="https://scan.coverity.com/projects/5607/badge.svg"/>
-</a>
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9973693b7bdd4543b07084d5d9cf4745)](https://www.codacy.com/gh/assimp/assimp/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=assimp/assimp&amp;utm_campaign=Badge_Grade)
-
-[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
[![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Percentage of issues still open")
<br>
APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS.
-Additionally, assimp features various __mesh post processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more.
+Additionally, assimp features various __mesh post-processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more.
-### Latest Doc's ###
-Please check the latest documents at [Asset-Importer-Lib-Doc](https://assimp-docs.readthedocs.io/en/latest/).
+### Documentation ###
+Read [our latest documentation](https://assimp-docs.readthedocs.io/en/latest/).
-### Prebuild binaries ###
-Please check our [Itchi Projectspace](https://kimkulling.itch.io/the-asset-importer-lib)
+### Pre-built binaries ###
+Download binaries from [our Itchi Projectspace](https://kimkulling.itch.io/the-asset-importer-lib).
-If you want to check our Model-Database, use the following repo: https://github.com/assimp/assimp-mdb
+### Test data ###
+Clone [our model database](https://github.com/assimp/assimp-mdb).
### Communities ###
-- Ask a question at [The Assimp-Discussion Board](https://github.com/assimp/assimp/discussions)
-- Ask on [Assimp-Community on Reddit](https://www.reddit.com/r/Assimp/)
+- Ask questions at [the Assimp Discussion Board](https://github.com/assimp/assimp/discussions).
+- Ask [the Assimp community on Reddit](https://www.reddit.com/r/Assimp/).
- Ask on [StackOverflow with the assimp-tag](http://stackoverflow.com/questions/tagged/assimp?sort=newest).
- Nothing has worked? File a question or an issue-report at [The Assimp-Issue Tracker](https://github.com/assimp/assimp/issues)
And we also have a Gitter-channel:Gitter [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)<br>
#### Supported file formats ####
-You can find the complete list of supported file-formats [here](https://github.com/assimp/assimp/blob/master/doc/Fileformats.md)
+See [the complete list of supported formats](https://github.com/assimp/assimp/blob/master/doc/Fileformats.md).
### Building ###
-Take a look into the https://github.com/assimp/assimp/blob/master/Build.md file. We are available in vcpkg, and our build system is CMake; if you used CMake before there is a good chance you know what to do.
+Start by reading [our build instructions](https://github.com/assimp/assimp/blob/master/Build.md). We are available in vcpkg, and our build system is CMake; if you used CMake before there is a good chance you know what to do.
### Ports ###
* [Android](port/AndroidJNI/README.md)
@@ -58,20 +53,21 @@ Take a look into the https://github.com/assimp/assimp/blob/master/Build.md file.
### Other tools ###
[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.
+[Assimp-Viewer](https://github.com/assimp/assimp_view) is an experimental implementation for an Asset-Viewer based on ImGUI and Assimp (experimental).
#### Repository structure ####
-Open Asset Import Library is implemented in C++. The directory structure looks like:
+Open Asset Import Library is implemented in C++. The directory structure looks like this:
/code Source code
/contrib Third-party libraries
/doc Documentation (doxysource and pre-compiled docs)
- /fuzz Contains the test-code for the Google-Fuzzer project
+ /fuzz Contains the test code for the Google Fuzzer project
/include Public header C and C++ header files
- /scripts Scripts used to generate the loading code for some formats
+ /scripts Scripts are used to generate the loading code for some formats
/port Ports to other languages and scripts to maintain those.
/test Unit- and regression tests, test suite of models
/tools Tools (old assimp viewer, command line `assimp`)
- /samples A small number of samples to illustrate possible use-cases for Assimp
+ /samples A small number of samples to illustrate possible use cases for Assimp
The source code is organized in the following way:
@@ -79,9 +75,9 @@ The source code is organized in the following way:
code/CApi Special implementations which are only used for the C-API
code/Geometry A collection of geometry tools
code/Material The material system
- code/PBR An exporter for physical based models
+ code/PBR An exporter for physical-based models
code/PostProcessing The post-processing steps
- code/AssetLib/<FormatName> Implementation for import and export for the format
+ code/AssetLib/<FormatName> Implementation for import and export of the format
### Contributing ###
Contributions to assimp are highly appreciated. The easiest way to get involved is to submit
@@ -118,4 +114,4 @@ and don't sue us if our code doesn't work. Note that, unlike LGPLed code, you ma
For the legal details, see the `LICENSE` file.
### Why this name ###
-Sorry, we're germans :-), no english native speakers ...
+Sorry, we're germans :-), no English native speakers ...
diff --git a/code/AssetLib/3DS/3DSConverter.cpp b/code/AssetLib/3DS/3DSConverter.cpp
index b4f625b76..7ae756668 100644
--- a/code/AssetLib/3DS/3DSConverter.cpp
+++ b/code/AssetLib/3DS/3DSConverter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -52,9 +52,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cctype>
#include <memory>
-using namespace Assimp;
+namespace Assimp {
-static const unsigned int NotSet = 0xcdcdcdcd;
+static constexpr unsigned int NotSet = 0xcdcdcdcd;
// ------------------------------------------------------------------------------------------------
// Setup final material indices, generae a default material if necessary
@@ -68,7 +68,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;
- for (char & it : s) {
+ for (char &it : s) {
it = static_cast<char>(::tolower(static_cast<unsigned char>(it)));
}
@@ -262,7 +262,7 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material &oldMat,
unsigned int iWire = 1;
mat.AddProperty<int>((int *)&iWire, 1, AI_MATKEY_ENABLE_WIREFRAME);
}
- [[fallthrough]];
+ [[fallthrough]];
case D3DS::Discreet3DS::Gouraud:
eShading = aiShadingMode_Gouraud;
@@ -593,7 +593,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene *pcSOut, aiNode *pcOut,
// Cameras or lights define their transformation in their parent node and in the
// corresponding light or camera chunks. However, we read and process the latter
- // to to be able to return valid cameras/lights even if no scenegraph is given.
+ // to be able to return valid cameras/lights even if no scenegraph is given.
for (unsigned int n = 0; n < pcSOut->mNumCameras; ++n) {
if (pcSOut->mCameras[n]->mName == pcOut->mName) {
pcSOut->mCameras[n]->mLookAt = aiVector3D(0.f, 0.f, 1.f);
@@ -805,4 +805,6 @@ void Discreet3DSImporter::ConvertScene(aiScene *pcOut) {
}
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
diff --git a/code/AssetLib/3DS/3DSExporter.cpp b/code/AssetLib/3DS/3DSExporter.cpp
index 1b335a272..8477ed09f 100644
--- a/code/AssetLib/3DS/3DSExporter.cpp
+++ b/code/AssetLib/3DS/3DSExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/3DS/3DSExporter.h b/code/AssetLib/3DS/3DSExporter.h
index 82ec3512f..9e3e42911 100644
--- a/code/AssetLib/3DS/3DSExporter.h
+++ b/code/AssetLib/3DS/3DSExporter.h
@@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -57,8 +56,7 @@ struct aiNode;
struct aiMaterial;
struct aiMesh;
-namespace Assimp
-{
+namespace Assimp {
// ------------------------------------------------------------------------------------------------
/**
@@ -88,7 +86,7 @@ private:
std::map<const aiNode*, aiMatrix4x4> trafos;
- typedef std::multimap<const aiNode*, unsigned int> MeshesByNodeMap;
+ using MeshesByNodeMap = std::multimap<const aiNode*, unsigned int>;
MeshesByNodeMap meshes;
};
diff --git a/code/AssetLib/3DS/3DSHelper.h b/code/AssetLib/3DS/3DSHelper.h
index 2279d105c..8f85f2e4d 100644
--- a/code/AssetLib/3DS/3DSHelper.h
+++ b/code/AssetLib/3DS/3DSHelper.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/3DS/3DSLoader.cpp b/code/AssetLib/3DS/3DSLoader.cpp
index aa29956df..3317017be 100644
--- a/code/AssetLib/3DS/3DSLoader.cpp
+++ b/code/AssetLib/3DS/3DSLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -54,9 +54,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp>
-using namespace Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Discreet 3DS Importer",
"",
"",
@@ -104,10 +104,6 @@ Discreet3DSImporter::Discreet3DSImporter() :
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-Discreet3DSImporter::~Discreet3DSImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool Discreet3DSImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const uint16_t token[] = { 0x4d4d, 0x3dc2 /*, 0x3daa */ };
@@ -369,7 +365,7 @@ void Discreet3DSImporter::ParseChunk(const char *name, unsigned int num) {
// IMPLEMENTATION NOTE;
// Cameras or lights define their transformation in their parent node and in the
// corresponding light or camera chunks. However, we read and process the latter
- // to to be able to return valid cameras/lights even if no scenegraph is given.
+ // to be able to return valid cameras/lights even if no scenegraph is given.
// get chunk type
switch (chunk.Flag) {
@@ -1339,4 +1335,6 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D *out, bool acceptPercent) {
(void)bGamma;
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
diff --git a/code/AssetLib/3DS/3DSLoader.h b/code/AssetLib/3DS/3DSLoader.h
index 6bd73f412..1d6953e29 100644
--- a/code/AssetLib/3DS/3DSLoader.h
+++ b/code/AssetLib/3DS/3DSLoader.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -59,7 +59,6 @@ struct aiNode;
namespace Assimp {
-
using namespace D3DS;
// ---------------------------------------------------------------------------------
@@ -68,7 +67,7 @@ using namespace D3DS;
class Discreet3DSImporter : public BaseImporter {
public:
Discreet3DSImporter();
- ~Discreet3DSImporter() override;
+ ~Discreet3DSImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/3MF/3MFTypes.h b/code/AssetLib/3MF/3MFTypes.h
index 8207b568b..57d2b281a 100644
--- a/code/AssetLib/3MF/3MFTypes.h
+++ b/code/AssetLib/3MF/3MFTypes.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -57,6 +57,7 @@ enum class ResourceType {
RT_BaseMaterials,
RT_EmbeddedTexture2D,
RT_Texture2DGroup,
+ RT_ColorGroup,
RT_Unknown
}; // To be extended with other resource types (eg. material extension resources like Texture2d, Texture2dGroup...)
@@ -117,6 +118,21 @@ public:
}
};
+class ColorGroup : public Resource {
+public:
+ std::vector<aiColor4D> mColors;
+ ColorGroup(int id) :
+ Resource(id){
+ // empty
+ }
+
+ ~ColorGroup() override = default;
+
+ ResourceType getType() const override {
+ return ResourceType::RT_ColorGroup;
+ }
+};
+
class BaseMaterials : public Resource {
public:
std::vector<unsigned int> mMaterialIndex;
diff --git a/code/AssetLib/3MF/3MFXmlTags.h b/code/AssetLib/3MF/3MFXmlTags.h
index 333d169aa..aea66667b 100644
--- a/code/AssetLib/3MF/3MFXmlTags.h
+++ b/code/AssetLib/3MF/3MFXmlTags.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -98,6 +98,11 @@ namespace XmlTag {
const char *const texture_cuurd_u = "u";
const char *const texture_cuurd_v = "v";
+ // vertex color definitions
+ const char *const colorgroup = "m:colorgroup";
+ const char *const color_item = "m:color";
+ const char *const color_vaule = "color";
+
// Meta info tags
const char* const CONTENT_TYPES_ARCHIVE = "[Content_Types].xml";
const char* const ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels";
diff --git a/code/AssetLib/3MF/D3MFExporter.cpp b/code/AssetLib/3MF/D3MFExporter.cpp
index 4ba3bbf24..6caa4c84e 100644
--- a/code/AssetLib/3MF/D3MFExporter.cpp
+++ b/code/AssetLib/3MF/D3MFExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/3MF/D3MFExporter.h b/code/AssetLib/3MF/D3MFExporter.h
index 680d54f91..6be0c32ca 100644
--- a/code/AssetLib/3MF/D3MFExporter.h
+++ b/code/AssetLib/3MF/D3MFExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/3MF/D3MFImporter.cpp b/code/AssetLib/3MF/D3MFImporter.cpp
index 5d9644fa5..987cdd492 100644
--- a/code/AssetLib/3MF/D3MFImporter.cpp
+++ b/code/AssetLib/3MF/D3MFImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -68,7 +68,7 @@ namespace Assimp {
using namespace D3MF;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"3mf Importer",
"",
"",
@@ -81,16 +81,17 @@ static const aiImporterDesc desc = {
"3mf"
};
-D3MFImporter::D3MFImporter() = default;
-
-D3MFImporter::~D3MFImporter() = default;
-
-bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool /*checkSig*/) const {
+bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool ) const {
if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) {
return false;
}
- D3MF::D3MFOpcPackage opcPackage(pIOHandler, filename);
- return opcPackage.validate();
+ static const char *const ModelRef = "3D/3dmodel.model";
+ ZipArchiveIOSystem archive(pIOHandler, filename);
+ if (!archive.Exists(ModelRef)) {
+ return false;
+ }
+
+ return true;
}
void D3MFImporter::SetupProperties(const Importer*) {
diff --git a/code/AssetLib/3MF/D3MFImporter.h b/code/AssetLib/3MF/D3MFImporter.h
index a39ae790f..82a1546cd 100644
--- a/code/AssetLib/3MF/D3MFImporter.h
+++ b/code/AssetLib/3MF/D3MFImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -56,10 +56,10 @@ namespace Assimp {
class D3MFImporter : public BaseImporter {
public:
/// @brief The default class constructor.
- D3MFImporter();
+ D3MFImporter() = default;
/// @brief The class destructor.
- ~D3MFImporter() override;
+ ~D3MFImporter() override = default;
/// @brief Performs the data format detection.
/// @param pFile The filename to check.
diff --git a/code/AssetLib/3MF/D3MFOpcPackage.cpp b/code/AssetLib/3MF/D3MFOpcPackage.cpp
index 934305d49..be0615904 100644
--- a/code/AssetLib/3MF/D3MFOpcPackage.cpp
+++ b/code/AssetLib/3MF/D3MFOpcPackage.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -68,7 +68,7 @@ using OpcPackageRelationshipPtr = std::shared_ptr<OpcPackageRelationship>;
class OpcPackageRelationshipReader {
public:
OpcPackageRelationshipReader(XmlParser &parser) :
- m_relationShips() {
+ mRelations() {
XmlNode root = parser.getRootNode();
ParseRootNode(root);
}
@@ -108,20 +108,20 @@ public:
relPtr->type = currentNode.attribute(XmlTag::RELS_ATTRIB_TYPE).as_string();
relPtr->target = currentNode.attribute(XmlTag::RELS_ATTRIB_TARGET).as_string();
if (validateRels(relPtr)) {
- m_relationShips.push_back(relPtr);
+ mRelations.push_back(relPtr);
}
}
}
}
- std::vector<OpcPackageRelationshipPtr> m_relationShips;
+ std::vector<OpcPackageRelationshipPtr> mRelations;
};
static bool IsEmbeddedTexture( const std::string &filename ) {
const std::string extension = BaseImporter::GetExtension(filename);
- if (extension == "jpg" || extension == "png") {
+ if (extension == "jpg" || extension == "png" || extension == "jpeg") {
std::string::size_type pos = filename.find("thumbnail");
- if (pos == std::string::npos) {
+ if (pos != std::string::npos) {
return false;
}
return true;
@@ -186,9 +186,6 @@ D3MFOpcPackage::D3MFOpcPackage(IOSystem *pIOHandler, const std::string &rFile) :
D3MFOpcPackage::~D3MFOpcPackage() {
mZipArchive->Close(mRootStream);
delete mZipArchive;
- for (auto tex : mEmbeddedTextures) {
- delete tex;
- }
}
IOStream *D3MFOpcPackage::RootStream() const {
@@ -217,11 +214,11 @@ std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream *stream) {
OpcPackageRelationshipReader reader(xmlParser);
- auto itr = std::find_if(reader.m_relationShips.begin(), reader.m_relationShips.end(), [](const OpcPackageRelationshipPtr &rel) {
+ auto itr = std::find_if(reader.mRelations.begin(), reader.mRelations.end(), [](const OpcPackageRelationshipPtr &rel) {
return rel->type == XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE;
});
- if (itr == reader.m_relationShips.end()) {
+ if (itr == reader.mRelations.end()) {
throw DeadlyImportError("Cannot find ", XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE);
}
diff --git a/code/AssetLib/3MF/D3MFOpcPackage.h b/code/AssetLib/3MF/D3MFOpcPackage.h
index f6803a0ef..9782752bf 100644
--- a/code/AssetLib/3MF/D3MFOpcPackage.h
+++ b/code/AssetLib/3MF/D3MFOpcPackage.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/3MF/XmlSerializer.cpp b/code/AssetLib/3MF/XmlSerializer.cpp
index c77111728..354ed19bb 100644
--- a/code/AssetLib/3MF/XmlSerializer.cpp
+++ b/code/AssetLib/3MF/XmlSerializer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -49,12 +49,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace D3MF {
-static const int IdNotSet = -1;
+static constexpr int IdNotSet = -1;
namespace {
-static const size_t ColRGBA_Len = 9;
-static const size_t ColRGB_Len = 7;
+static constexpr size_t ColRGBA_Len = 9;
+static constexpr size_t ColRGB_Len = 7;
// format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1)
bool validateColorString(const char *color) {
@@ -75,7 +75,7 @@ aiFace ReadTriangle(XmlNode &node, int &texId0, int &texId1, int &texId2) {
face.mIndices[1] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v2).as_string()));
face.mIndices[2] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v3).as_string()));
- texId0 = texId1 = texId2 = -1;
+ texId0 = texId1 = texId2 = IdNotSet;
XmlParser::getIntAttribute(node, XmlTag::p1, texId0);
XmlParser::getIntAttribute(node, XmlTag::p2, texId1);
XmlParser::getIntAttribute(node, XmlTag::p3, texId2);
@@ -236,6 +236,8 @@ void XmlSerializer::ImportXml(aiScene *scene) {
ReadBaseMaterials(currentNode);
} else if (currentNodeName == XmlTag::meta) {
ReadMetadata(currentNode);
+ } else if (currentNodeName == XmlTag::colorgroup) {
+ ReadColorGroup(currentNode);
}
}
StoreMaterialsInScene(scene);
@@ -331,9 +333,49 @@ void XmlSerializer::ReadObject(XmlNode &node) {
if (hasPid) {
auto it = mResourcesDictionnary.find(pid);
- if (hasPindex && it != mResourcesDictionnary.end() && it->second->getType() == ResourceType::RT_BaseMaterials) {
- BaseMaterials *materials = static_cast<BaseMaterials *>(it->second);
- mesh->mMaterialIndex = materials->mMaterialIndex[pindex];
+ if (hasPindex && it != mResourcesDictionnary.end()) {
+ if (it->second->getType() == ResourceType::RT_BaseMaterials) {
+ BaseMaterials *materials = static_cast<BaseMaterials *>(it->second);
+ mesh->mMaterialIndex = materials->mMaterialIndex[pindex];
+ } else if (it->second->getType() == ResourceType::RT_Texture2DGroup) {
+ Texture2DGroup *group = static_cast<Texture2DGroup *>(it->second);
+ if (mesh->mTextureCoords[0] == nullptr) {
+ mesh->mNumUVComponents[0] = 2;
+ for (unsigned int i = 1; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
+ mesh->mNumUVComponents[i] = 0;
+ }
+
+ const std::string name = ai_to_string(group->mTexId);
+ for (size_t i = 0; i < mMaterials.size(); ++i) {
+ if (name == mMaterials[i]->GetName().C_Str()) {
+ mesh->mMaterialIndex = static_cast<unsigned int>(i);
+ }
+ }
+
+ mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
+ for (unsigned int vertex_idx = 0; vertex_idx < mesh->mNumVertices; vertex_idx++) {
+ mesh->mTextureCoords[0][vertex_idx] =
+ aiVector3D(group->mTex2dCoords[pindex].x, group->mTex2dCoords[pindex].y, 0.0f);
+ }
+ } else {
+ for (unsigned int vertex_idx = 0; vertex_idx < mesh->mNumVertices; vertex_idx++) {
+ if (mesh->mTextureCoords[0][vertex_idx].z < 0) {
+ // use default
+ mesh->mTextureCoords[0][vertex_idx] =
+ aiVector3D(group->mTex2dCoords[pindex].x, group->mTex2dCoords[pindex].y, 0.0f);
+ }
+ }
+ }
+ }else if (it->second->getType() == ResourceType::RT_ColorGroup) {
+ if (mesh->mColors[0] == nullptr) {
+ mesh->mColors[0] = new aiColor4D[mesh->mNumVertices];
+
+ ColorGroup *group = static_cast<ColorGroup *>(it->second);
+ for (unsigned int vertex_idx = 0; vertex_idx < mesh->mNumVertices; vertex_idx++) {
+ mesh->mColors[0][vertex_idx] = group->mColors[pindex];
+ }
+ }
+ }
}
}
@@ -415,27 +457,36 @@ void XmlSerializer::ImportTriangles(XmlNode &node, aiMesh *mesh) {
for (XmlNode &currentNode : node.children()) {
const std::string currentName = currentNode.name();
if (currentName == XmlTag::triangle) {
- int pid = IdNotSet, p1 = IdNotSet;
+ int pid = IdNotSet;
bool hasPid = getNodeAttribute(currentNode, D3MF::XmlTag::pid, pid);
- bool hasP1 = getNodeAttribute(currentNode, D3MF::XmlTag::p1, p1);
- int texId[3];
- Texture2DGroup *group = nullptr;
- aiFace face = ReadTriangle(currentNode, texId[0], texId[1], texId[2]);
- if (hasPid && hasP1) {
+ int pindex[3];
+ aiFace face = ReadTriangle(currentNode, pindex[0], pindex[1], pindex[2]);
+ if (hasPid && (pindex[0] != IdNotSet || pindex[1] != IdNotSet || pindex[2] != IdNotSet)) {
auto it = mResourcesDictionnary.find(pid);
if (it != mResourcesDictionnary.end()) {
if (it->second->getType() == ResourceType::RT_BaseMaterials) {
BaseMaterials *baseMaterials = static_cast<BaseMaterials *>(it->second);
- mesh->mMaterialIndex = baseMaterials->mMaterialIndex[p1];
+
+ auto update_material = [&](int idx) {
+ if (pindex[idx] != IdNotSet) {
+ mesh->mMaterialIndex = baseMaterials->mMaterialIndex[pindex[idx]];
+ }
+ };
+
+ update_material(0);
+ update_material(1);
+ update_material(2);
+
} else if (it->second->getType() == ResourceType::RT_Texture2DGroup) {
+ // Load texture coordinates into mesh, when any
+ Texture2DGroup *group = static_cast<Texture2DGroup *>(it->second); // fix bug
if (mesh->mTextureCoords[0] == nullptr) {
mesh->mNumUVComponents[0] = 2;
for (unsigned int i = 1; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
mesh->mNumUVComponents[i] = 0;
}
- group = static_cast<Texture2DGroup *>(it->second);
const std::string name = ai_to_string(group->mTexId);
for (size_t i = 0; i < mMaterials.size(); ++i) {
if (name == mMaterials[i]->GetName().C_Str()) {
@@ -443,21 +494,44 @@ void XmlSerializer::ImportTriangles(XmlNode &node, aiMesh *mesh) {
}
}
mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
+ for (unsigned int vertex_index = 0; vertex_index < mesh->mNumVertices; vertex_index++) {
+ mesh->mTextureCoords[0][vertex_index].z = IdNotSet;//mark not set
+ }
}
+
+ auto update_texture = [&](int idx) {
+ if (pindex[idx] != IdNotSet) {
+ size_t vertex_index = face.mIndices[idx];
+ mesh->mTextureCoords[0][vertex_index] =
+ aiVector3D(group->mTex2dCoords[pindex[idx]].x, group->mTex2dCoords[pindex[idx]].y, 0.0f);
+ }
+ };
+
+ update_texture(0);
+ update_texture(1);
+ update_texture(2);
+
+ } else if (it->second->getType() == ResourceType::RT_ColorGroup) {
+ // Load vertex color into mesh, when any
+ ColorGroup *group = static_cast<ColorGroup *>(it->second);
+ if (mesh->mColors[0] == nullptr) {
+ mesh->mColors[0] = new aiColor4D[mesh->mNumVertices];
+ }
+
+ auto update_color = [&](int idx) {
+ if (pindex[idx] != IdNotSet) {
+ size_t vertex_index = face.mIndices[idx];
+ mesh->mColors[0][vertex_index] = group->mColors[pindex[idx]];
+ }
+ };
+
+ update_color(0);
+ update_color(1);
+ update_color(2);
}
}
}
- // Load texture coordinates into mesh, when any
- if (group != nullptr) {
- size_t i0 = face.mIndices[0];
- size_t i1 = face.mIndices[1];
- size_t i2 = face.mIndices[2];
- mesh->mTextureCoords[0][i0] = aiVector3D(group->mTex2dCoords[texId[0]].x, group->mTex2dCoords[texId[0]].y, 0.0f);
- mesh->mTextureCoords[0][i1] = aiVector3D(group->mTex2dCoords[texId[1]].x, group->mTex2dCoords[texId[1]].y, 0.0f);
- mesh->mTextureCoords[0][i2] = aiVector3D(group->mTex2dCoords[texId[2]].x, group->mTex2dCoords[texId[2]].y, 0.0f);
- }
-
faces.push_back(face);
}
}
@@ -598,6 +672,38 @@ aiMaterial *XmlSerializer::readMaterialDef(XmlNode &node, unsigned int basemater
return material;
}
+void XmlSerializer::ReadColor(XmlNode &node, ColorGroup *colorGroup) {
+ if (node.empty() || nullptr == colorGroup) {
+ return;
+ }
+
+ for (XmlNode currentNode : node.children()) {
+ const std::string currentName = currentNode.name();
+ if (currentName == XmlTag::color_item) {
+ const char *color = currentNode.attribute(XmlTag::color_vaule).as_string();
+ aiColor4D color_value;
+ if (parseColor(color, color_value)) {
+ colorGroup->mColors.push_back(color_value);
+ }
+ }
+ }
+}
+
+void XmlSerializer::ReadColorGroup(XmlNode &node) {
+ if (node.empty()) {
+ return;
+ }
+
+ int id = IdNotSet;
+ if (!XmlParser::getIntAttribute(node, XmlTag::id, id)) {
+ return;
+ }
+
+ ColorGroup *group = new ColorGroup(id);
+ ReadColor(node, group);
+ mResourcesDictionnary.insert(std::make_pair(id, group));
+}
+
void XmlSerializer::StoreMaterialsInScene(aiScene *scene) {
if (nullptr == scene) {
return;
diff --git a/code/AssetLib/3MF/XmlSerializer.h b/code/AssetLib/3MF/XmlSerializer.h
index 6cf6a70a9..d0700a631 100644
--- a/code/AssetLib/3MF/XmlSerializer.h
+++ b/code/AssetLib/3MF/XmlSerializer.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -57,6 +57,7 @@ class D3MFOpcPackage;
class Object;
class Texture2DGroup;
class EmbeddedTexture;
+class ColorGroup;
class XmlSerializer {
public:
@@ -78,6 +79,8 @@ private:
void ReadTextureGroup(XmlNode &node);
aiMaterial *readMaterialDef(XmlNode &node, unsigned int basematerialsId);
void StoreMaterialsInScene(aiScene *scene);
+ void ReadColorGroup(XmlNode &node);
+ void ReadColor(XmlNode &node, ColorGroup *colorGroup);
private:
struct MetaEntry {
diff --git a/code/AssetLib/AC/ACLoader.cpp b/code/AssetLib/AC/ACLoader.cpp
index e93fba5f0..dbcb39b30 100644
--- a/code/AssetLib/AC/ACLoader.cpp
+++ b/code/AssetLib/AC/ACLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -60,9 +60,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Importer.hpp>
#include <memory>
-using namespace Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"AC3D Importer",
"",
"",
@@ -77,8 +77,8 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// skip to the next token
-inline const char *AcSkipToNextToken(const char *buffer) {
- if (!SkipSpaces(&buffer)) {
+inline const char *AcSkipToNextToken(const char *buffer, const char *end) {
+ if (!SkipSpaces(&buffer, end)) {
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL");
}
return buffer;
@@ -86,13 +86,13 @@ inline const char *AcSkipToNextToken(const char *buffer) {
// ------------------------------------------------------------------------------------------------
// read a string (may be enclosed in double quotation marks). buffer must point to "
-inline const char *AcGetString(const char *buffer, std::string &out) {
+inline const char *AcGetString(const char *buffer, const char *end, std::string &out) {
if (*buffer == '\0') {
throw DeadlyImportError("AC3D: Unexpected EOF in string");
}
++buffer;
const char *sz = buffer;
- while ('\"' != *buffer) {
+ while ('\"' != *buffer && buffer != end) {
if (IsLineEnd(*buffer)) {
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL in string");
out = "ERROR";
@@ -112,8 +112,8 @@ inline const char *AcGetString(const char *buffer, std::string &out) {
// ------------------------------------------------------------------------------------------------
// read 1 to n floats prefixed with an optional predefined identifier
template <class T>
-inline const char *TAcCheckedLoadFloatArray(const char *buffer, const char *name, size_t name_length, size_t num, T *out) {
- buffer = AcSkipToNextToken(buffer);
+inline const char *TAcCheckedLoadFloatArray(const char *buffer, const char *end, const char *name, size_t name_length, size_t num, T *out) {
+ buffer = AcSkipToNextToken(buffer, end);
if (0 != name_length) {
if (0 != strncmp(buffer, name, name_length) || !IsSpace(buffer[name_length])) {
ASSIMP_LOG_ERROR("AC3D: Unexpected token. ", name, " was expected.");
@@ -122,7 +122,7 @@ inline const char *TAcCheckedLoadFloatArray(const char *buffer, const char *name
buffer += name_length + 1;
}
for (unsigned int _i = 0; _i < num; ++_i) {
- buffer = AcSkipToNextToken(buffer);
+ buffer = AcSkipToNextToken(buffer, end);
buffer = fast_atoreal_move<float>(buffer, ((float *)out)[_i]);
}
@@ -132,7 +132,7 @@ inline const char *TAcCheckedLoadFloatArray(const char *buffer, const char *name
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
AC3DImporter::AC3DImporter() :
- buffer(),
+ mBuffer(),
configSplitBFCull(),
configEvalSubdivision(),
mNumMeshes(),
@@ -164,17 +164,17 @@ const aiImporterDesc *AC3DImporter::GetInfo() const {
// ------------------------------------------------------------------------------------------------
// Get a pointer to the next line from the file
bool AC3DImporter::GetNextLine() {
- SkipLine(&buffer);
- return SkipSpaces(&buffer);
+ SkipLine(&mBuffer.data, mBuffer.end);
+ return SkipSpaces(&mBuffer.data, mBuffer.end);
}
// ------------------------------------------------------------------------------------------------
// Parse an object section in an AC file
-void AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
- if (!TokenMatch(buffer, "OBJECT", 6))
- return;
+bool AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
+ if (!TokenMatch(mBuffer.data, "OBJECT", 6))
+ return false;
- SkipSpaces(&buffer);
+ SkipSpaces(&mBuffer.data, mBuffer.end);
++mNumMeshes;
@@ -182,7 +182,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
Object &obj = objects.back();
aiLight *light = nullptr;
- if (!ASSIMP_strincmp(buffer, "light", 5)) {
+ if (!ASSIMP_strincmp(mBuffer.data, "light", 5)) {
// This is a light source. Add it to the list
mLights->push_back(light = new aiLight());
@@ -198,62 +198,66 @@ void AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
ASSIMP_LOG_VERBOSE_DEBUG("AC3D: Light source encountered");
obj.type = Object::Light;
- } else if (!ASSIMP_strincmp(buffer, "group", 5)) {
+ } else if (!ASSIMP_strincmp(mBuffer.data, "group", 5)) {
obj.type = Object::Group;
- } else if (!ASSIMP_strincmp(buffer, "world", 5)) {
+ } else if (!ASSIMP_strincmp(mBuffer.data, "world", 5)) {
obj.type = Object::World;
} else
obj.type = Object::Poly;
while (GetNextLine()) {
- if (TokenMatch(buffer, "kids", 4)) {
- SkipSpaces(&buffer);
- unsigned int num = strtoul10(buffer, &buffer);
+ if (TokenMatch(mBuffer.data, "kids", 4)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ unsigned int num = strtoul10(mBuffer.data, &mBuffer.data);
GetNextLine();
if (num) {
// load the children of this object recursively
obj.children.reserve(num);
- for (unsigned int i = 0; i < num; ++i)
- LoadObjectSection(obj.children);
+ for (unsigned int i = 0; i < num; ++i) {
+ if (!LoadObjectSection(obj.children)) {
+ ASSIMP_LOG_WARN("AC3D: wrong number of kids");
+ break;
+ }
+ }
}
- return;
- } else if (TokenMatch(buffer, "name", 4)) {
- SkipSpaces(&buffer);
- buffer = AcGetString(buffer, obj.name);
+ return true;
+ } else if (TokenMatch(mBuffer.data, "name", 4)) {
+ SkipSpaces(&mBuffer.data, mBuffer.data);
+ mBuffer.data = AcGetString(mBuffer.data, mBuffer.end, obj.name);
// If this is a light source, we'll also need to store
// the name of the node in it.
if (light) {
light->mName.Set(obj.name);
}
- } else if (TokenMatch(buffer, "texture", 7)) {
- SkipSpaces(&buffer);
+ } else if (TokenMatch(mBuffer.data, "texture", 7)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
std::string texture;
- buffer = AcGetString(buffer, texture);
+ mBuffer.data = AcGetString(mBuffer.data, mBuffer.end, texture);
obj.textures.push_back(texture);
- } else if (TokenMatch(buffer, "texrep", 6)) {
- SkipSpaces(&buffer);
- buffer = TAcCheckedLoadFloatArray(buffer, "", 0, 2, &obj.texRepeat);
+ } else if (TokenMatch(mBuffer.data, "texrep", 6)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "", 0, 2, &obj.texRepeat);
if (!obj.texRepeat.x || !obj.texRepeat.y)
obj.texRepeat = aiVector2D(1.f, 1.f);
- } else if (TokenMatch(buffer, "texoff", 6)) {
- SkipSpaces(&buffer);
- buffer = TAcCheckedLoadFloatArray(buffer, "", 0, 2, &obj.texOffset);
- } else if (TokenMatch(buffer, "rot", 3)) {
- SkipSpaces(&buffer);
- buffer = TAcCheckedLoadFloatArray(buffer, "", 0, 9, &obj.rotation);
- } else if (TokenMatch(buffer, "loc", 3)) {
- SkipSpaces(&buffer);
- buffer = TAcCheckedLoadFloatArray(buffer, "", 0, 3, &obj.translation);
- } else if (TokenMatch(buffer, "subdiv", 6)) {
- SkipSpaces(&buffer);
- obj.subDiv = strtoul10(buffer, &buffer);
- } else if (TokenMatch(buffer, "crease", 6)) {
- SkipSpaces(&buffer);
- obj.crease = fast_atof(buffer);
- } else if (TokenMatch(buffer, "numvert", 7)) {
- SkipSpaces(&buffer);
-
- unsigned int t = strtoul10(buffer, &buffer);
+ } else if (TokenMatch(mBuffer.data, "texoff", 6)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "", 0, 2, &obj.texOffset);
+ } else if (TokenMatch(mBuffer.data, "rot", 3)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "", 0, 9, &obj.rotation);
+ } else if (TokenMatch(mBuffer.data, "loc", 3)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "", 0, 3, &obj.translation);
+ } else if (TokenMatch(mBuffer.data, "subdiv", 6)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ obj.subDiv = strtoul10(mBuffer.data, &mBuffer.data);
+ } else if (TokenMatch(mBuffer.data, "crease", 6)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ obj.crease = fast_atof(mBuffer.data);
+ } else if (TokenMatch(mBuffer.data, "numvert", 7)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+
+ unsigned int t = strtoul10(mBuffer.data, &mBuffer.data);
if (t >= AI_MAX_ALLOC(aiVector3D)) {
throw DeadlyImportError("AC3D: Too many vertices, would run out of memory");
}
@@ -262,59 +266,59 @@ void AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
if (!GetNextLine()) {
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: not all vertices have been parsed yet");
break;
- } else if (!IsNumeric(*buffer)) {
+ } else if (!IsNumeric(*mBuffer.data)) {
ASSIMP_LOG_ERROR("AC3D: Unexpected token: not all vertices have been parsed yet");
- --buffer; // make sure the line is processed a second time
+ --mBuffer.data; // make sure the line is processed a second time
break;
}
obj.vertices.emplace_back();
aiVector3D &v = obj.vertices.back();
- buffer = TAcCheckedLoadFloatArray(buffer, "", 0, 3, &v.x);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "", 0, 3, &v.x);
}
- } else if (TokenMatch(buffer, "numsurf", 7)) {
- SkipSpaces(&buffer);
+ } else if (TokenMatch(mBuffer.data, "numsurf", 7)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
bool Q3DWorkAround = false;
- const unsigned int t = strtoul10(buffer, &buffer);
+ const unsigned int t = strtoul10(mBuffer.data, &mBuffer.data);
obj.surfaces.reserve(t);
for (unsigned int i = 0; i < t; ++i) {
GetNextLine();
- if (!TokenMatch(buffer, "SURF", 4)) {
+ if (!TokenMatch(mBuffer.data, "SURF", 4)) {
// FIX: this can occur for some files - Quick 3D for
// example writes no surf chunks
if (!Q3DWorkAround) {
ASSIMP_LOG_WARN("AC3D: SURF token was expected");
ASSIMP_LOG_VERBOSE_DEBUG("Continuing with Quick3D Workaround enabled");
}
- --buffer; // make sure the line is processed a second time
+ --mBuffer.data; // make sure the line is processed a second time
// break; --- see fix notes above
Q3DWorkAround = true;
}
- SkipSpaces(&buffer);
+ SkipSpaces(&mBuffer.data, mBuffer.end);
obj.surfaces.emplace_back();
Surface &surf = obj.surfaces.back();
- surf.flags = strtoul_cppstyle(buffer);
+ surf.flags = strtoul_cppstyle(mBuffer.data);
while (true) {
if (!GetNextLine()) {
throw DeadlyImportError("AC3D: Unexpected EOF: surface is incomplete");
}
- if (TokenMatch(buffer, "mat", 3)) {
- SkipSpaces(&buffer);
- surf.mat = strtoul10(buffer);
- } else if (TokenMatch(buffer, "refs", 4)) {
+ if (TokenMatch(mBuffer.data, "mat", 3)) {
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ surf.mat = strtoul10(mBuffer.data);
+ } else if (TokenMatch(mBuffer.data, "refs", 4)) {
// --- see fix notes above
if (Q3DWorkAround) {
if (!surf.entries.empty()) {
- buffer -= 6;
+ mBuffer.data -= 6;
break;
}
}
- SkipSpaces(&buffer);
- const unsigned int m = strtoul10(buffer);
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ const unsigned int m = strtoul10(mBuffer.data);
surf.entries.reserve(m);
obj.numRefs += m;
@@ -327,12 +331,12 @@ void AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
surf.entries.emplace_back();
Surface::SurfaceEntry &entry = surf.entries.back();
- entry.first = strtoul10(buffer, &buffer);
- SkipSpaces(&buffer);
- buffer = TAcCheckedLoadFloatArray(buffer, "", 0, 2, &entry.second);
+ entry.first = strtoul10(mBuffer.data, &mBuffer.data);
+ SkipSpaces(&mBuffer.data, mBuffer.end);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "", 0, 2, &entry.second);
}
} else {
- --buffer; // make sure the line is processed a second time
+ --mBuffer.data; // make sure the line is processed a second time
break;
}
}
@@ -340,6 +344,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
}
}
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: \'kids\' line was expected");
+ return false;
}
// ------------------------------------------------------------------------------------------------
@@ -445,7 +450,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
idx = 0;
}
if ((*it).entries.empty()) {
- ASSIMP_LOG_WARN("AC3D: surface her zero vertex references");
+ ASSIMP_LOG_WARN("AC3D: surface has zero vertex references");
}
// validate all vertex indices to make sure we won't crash here
@@ -463,16 +468,15 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
}
switch ((*it).GetType()) {
- // closed line
- case Surface::ClosedLine:
- needMat[idx].first += (unsigned int)(*it).entries.size();
- needMat[idx].second += (unsigned int)(*it).entries.size() << 1u;
+ case Surface::ClosedLine: // closed line
+ needMat[idx].first += static_cast<unsigned int>((*it).entries.size());
+ needMat[idx].second += static_cast<unsigned int>((*it).entries.size() << 1u);
break;
// unclosed line
case Surface::OpenLine:
- needMat[idx].first += (unsigned int)(*it).entries.size() - 1;
- needMat[idx].second += ((unsigned int)(*it).entries.size() - 1) << 1u;
+ needMat[idx].first += static_cast<unsigned int>((*it).entries.size() - 1);
+ needMat[idx].second += static_cast<unsigned int>(((*it).entries.size() - 1) << 1u);
break;
// triangle strip
@@ -574,15 +578,6 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
const Surface::SurfaceEntry &entry2 = src.entries[i + 1];
const Surface::SurfaceEntry &entry3 = src.entries[i + 2];
- // skip degenerate triangles
- if (object.vertices[entry1.first] == object.vertices[entry2.first] ||
- object.vertices[entry1.first] == object.vertices[entry3.first] ||
- object.vertices[entry2.first] == object.vertices[entry3.first]) {
- mesh->mNumFaces--;
- mesh->mNumVertices -= 3;
- continue;
- }
-
aiFace &face = *faces++;
face.mNumIndices = 3;
face.mIndices = new unsigned int[face.mNumIndices];
@@ -760,17 +755,18 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
std::vector<char> mBuffer2;
TextFileToBuffer(file.get(), mBuffer2);
- buffer = &mBuffer2[0];
+ mBuffer.data = &mBuffer2[0];
+ mBuffer.end = &mBuffer2[0] + mBuffer2.size();
mNumMeshes = 0;
mLightsCounter = mPolysCounter = mWorldsCounter = mGroupsCounter = 0;
- if (::strncmp(buffer, "AC3D", 4)) {
+ if (::strncmp(mBuffer.data, "AC3D", 4)) {
throw DeadlyImportError("AC3D: No valid AC3D file, magic sequence not found");
}
// print the file format version to the console
- unsigned int version = HexDigitToDecimal(buffer[4]);
+ unsigned int version = HexDigitToDecimal(mBuffer.data[4]);
char msg[3];
ASSIMP_itoa10(msg, 3, version);
ASSIMP_LOG_INFO("AC3D file format version: ", msg);
@@ -785,30 +781,31 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
mLights = &lights;
while (GetNextLine()) {
- if (TokenMatch(buffer, "MATERIAL", 8)) {
+ if (TokenMatch(mBuffer.data, "MATERIAL", 8)) {
materials.emplace_back();
Material &mat = materials.back();
// manually parse the material ... sscanf would use the buldin atof ...
// Format: (name) rgb %f %f %f amb %f %f %f emis %f %f %f spec %f %f %f shi %d trans %f
- buffer = AcSkipToNextToken(buffer);
- if ('\"' == *buffer) {
- buffer = AcGetString(buffer, mat.name);
- buffer = AcSkipToNextToken(buffer);
+ mBuffer.data = AcSkipToNextToken(mBuffer.data, mBuffer.end);
+ if ('\"' == *mBuffer.data) {
+ mBuffer.data = AcGetString(mBuffer.data, mBuffer.end, mat.name);
+ mBuffer.data = AcSkipToNextToken(mBuffer.data, mBuffer.end);
}
- buffer = TAcCheckedLoadFloatArray(buffer, "rgb", 3, 3, &mat.rgb);
- buffer = TAcCheckedLoadFloatArray(buffer, "amb", 3, 3, &mat.amb);
- buffer = TAcCheckedLoadFloatArray(buffer, "emis", 4, 3, &mat.emis);
- buffer = TAcCheckedLoadFloatArray(buffer, "spec", 4, 3, &mat.spec);
- buffer = TAcCheckedLoadFloatArray(buffer, "shi", 3, 1, &mat.shin);
- buffer = TAcCheckedLoadFloatArray(buffer, "trans", 5, 1, &mat.trans);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "rgb", 3, 3, &mat.rgb);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "amb", 3, 3, &mat.amb);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "emis", 4, 3, &mat.emis);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "spec", 4, 3, &mat.spec);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "shi", 3, 1, &mat.shin);
+ mBuffer.data = TAcCheckedLoadFloatArray(mBuffer.data, mBuffer.end, "trans", 5, 1, &mat.trans);
+ } else {
+ LoadObjectSection(rootObjects);
}
- LoadObjectSection(rootObjects);
}
- if (rootObjects.empty() || !mNumMeshes) {
+ if (rootObjects.empty() || mNumMeshes == 0u) {
throw DeadlyImportError("AC3D: No meshes have been loaded");
}
if (materials.empty()) {
@@ -824,7 +821,7 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
materials.reserve(mNumMeshes);
// generate a dummy root if there are multiple objects on the top layer
- Object *root;
+ Object *root = nullptr;
if (1 == rootObjects.size())
root = &rootObjects[0];
else {
@@ -837,7 +834,7 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
delete root;
}
- if (!::strncmp(pScene->mRootNode->mName.data, "Node", 4)) {
+ if (::strncmp(pScene->mRootNode->mName.data, "Node", 4) == 0) {
pScene->mRootNode->mName.Set("<AC3DWorld>");
}
@@ -856,10 +853,12 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
// copy lights
pScene->mNumLights = (unsigned int)lights.size();
- if (lights.size()) {
+ if (!lights.empty()) {
pScene->mLights = new aiLight *[lights.size()];
::memcpy(pScene->mLights, &lights[0], lights.size() * sizeof(void *));
}
}
+} // namespace Assimp
+
#endif //!defined ASSIMP_BUILD_NO_AC_IMPORTER
diff --git a/code/AssetLib/AC/ACLoader.h b/code/AssetLib/AC/ACLoader.h
index 7f8dfd03c..22f7d0d09 100644
--- a/code/AssetLib/AC/ACLoader.h
+++ b/code/AssetLib/AC/ACLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -216,7 +216,7 @@ private:
* load subobjects, the method returns after a 'kids 0' was
* encountered.
* @objects List of output objects*/
- void LoadObjectSection(std::vector<Object> &objects);
+ bool LoadObjectSection(std::vector<Object> &objects);
// -------------------------------------------------------------------
/** Convert all objects into meshes and nodes.
@@ -242,7 +242,7 @@ private:
private:
// points to the next data line
- const char *buffer;
+ aiBuffer mBuffer;
// Configuration option: if enabled, up to two meshes
// are generated per material: those faces who have
diff --git a/code/AssetLib/AMF/AMFImporter.cpp b/code/AssetLib/AMF/AMFImporter.cpp
index ff581b492..7c0d3b4e9 100644
--- a/code/AssetLib/AMF/AMFImporter.cpp
+++ b/code/AssetLib/AMF/AMFImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -53,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
-const aiImporterDesc AMFImporter::Description = {
+static constexpr aiImporterDesc Description = {
"Additive manufacturing file format(AMF) Importer",
"smalcom",
"",
diff --git a/code/AssetLib/AMF/AMFImporter.hpp b/code/AssetLib/AMF/AMFImporter.hpp
index 27f733043..50be465ce 100644
--- a/code/AssetLib/AMF/AMFImporter.hpp
+++ b/code/AssetLib/AMF/AMFImporter.hpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -98,8 +98,12 @@ namespace Assimp {
/// old - <map> and children <u1>, <u2>, <u3>, <v1>, <v2>, <v3>
///
class AMFImporter : public BaseImporter {
-private:
- struct SPP_Material; // forward declaration
+ using AMFMetaDataArray = std::vector<AMFMetadata *>;
+ using MeshArray = std::vector<aiMesh *>;
+ using NodeArray = std::vector<aiNode *>;
+
+public:
+ struct SPP_Material;
/// Data type for post-processing step. More suitable container for part of material's composition.
struct SPP_Composite {
@@ -107,7 +111,22 @@ private:
std::string Formula; ///< Formula for calculating ratio of \ref Material.
};
- /// \struct SPP_Material
+ /// 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 AMFColor *Color; ///< Face color. Equal to nullptr if color is not set for the face.
+ const AMFTexMap *TexMap; ///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face.
+ };
+
/// Data type for post-processing step. More suitable container for material.
struct SPP_Material {
std::string ID; ///< Material ID.
@@ -123,26 +142,37 @@ private:
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;
- };
+ /// Default constructor.
+ AMFImporter() AI_NO_EXCEPT;
- /// Data type for post-processing step. Contain face data.
- struct SComplexFace {
- aiFace Face; ///< Face vertices.
- const AMFColor *Color; ///< Face color. Equal to nullptr if color is not set for the face.
- const AMFTexMap *TexMap; ///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face.
- };
+ /// Default destructor.
+ ~AMFImporter() override;
- using AMFMetaDataArray = std::vector<AMFMetadata*>;
- using MeshArray = std::vector<aiMesh*>;
- using NodeArray = std::vector<aiNode*>;
+ /// 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 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);
+ void ParseHelper_Node_Enter(AMFNodeElementBase *child);
+ void ParseHelper_Node_Exit();
+ bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const override;
+ void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
+ const aiImporterDesc *GetInfo() const override;
+ bool Find_NodeElement(const std::string &pID, const AMFNodeElementBase::EType pType, AMFNodeElementBase **pNodeElement) const;
+ bool Find_ConvertedNode(const std::string &pID, NodeArray &nodeArray, aiNode **pNode) const;
+ bool Find_ConvertedMaterial(const std::string &pID, const SPP_Material **pConvertedMaterial) const;
+ AI_WONT_RETURN void Throw_CloseNotFound(const std::string &nodeName) AI_WONT_RETURN_SUFFIX;
+ AI_WONT_RETURN void Throw_IncorrectAttr(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX;
+ AI_WONT_RETURN void Throw_IncorrectAttrValue(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX;
+ AI_WONT_RETURN void Throw_MoreThanOnceDefined(const std::string &nodeName, const std::string &pNodeType, const std::string &pDescription) AI_WONT_RETURN_SUFFIX;
+ AI_WONT_RETURN void Throw_ID_NotFound(const std::string &pID) const AI_WONT_RETURN_SUFFIX;
+ void XML_CheckNode_MustHaveChildren(pugi::xml_node &node);
+ bool XML_SearchNode(const std::string &nodeName);
+ void ParseHelper_FixTruncatedFloatString(const char *pInStr, std::string &pOutString);
+ AMFImporter(const AMFImporter &pScene) = delete;
+ AMFImporter &operator=(const AMFImporter &pScene) = delete;
+private:
/// Clear all temporary data.
void Clear();
@@ -262,40 +292,9 @@ private:
/// \param [in] pUseOldName - if true then use old name of node(and children) - <map>, instead of new name - <texmap>.
void ParseNode_TexMap(XmlNode &node, const bool pUseOldName = false);
-public:
- /// Default constructor.
- AMFImporter() AI_NO_EXCEPT;
- /// Default destructor.
- ~AMFImporter() override;
-
- /// 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 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);
- void ParseHelper_Node_Enter(AMFNodeElementBase *child);
- void ParseHelper_Node_Exit();
- bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const override;
- void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
- const aiImporterDesc *GetInfo() const override;
- bool Find_NodeElement(const std::string &pID, const AMFNodeElementBase::EType pType, AMFNodeElementBase **pNodeElement) const;
- bool Find_ConvertedNode(const std::string &pID, NodeArray &nodeArray, aiNode **pNode) const;
- bool Find_ConvertedMaterial(const std::string &pID, const SPP_Material **pConvertedMaterial) const;
- AI_WONT_RETURN void Throw_CloseNotFound(const std::string &nodeName) AI_WONT_RETURN_SUFFIX;
- AI_WONT_RETURN void Throw_IncorrectAttr(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX;
- AI_WONT_RETURN void Throw_IncorrectAttrValue(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX;
- AI_WONT_RETURN void Throw_MoreThanOnceDefined(const std::string &nodeName, const std::string &pNodeType, const std::string &pDescription) AI_WONT_RETURN_SUFFIX;
- AI_WONT_RETURN void Throw_ID_NotFound(const std::string &pID) const AI_WONT_RETURN_SUFFIX;
- void XML_CheckNode_MustHaveChildren(pugi::xml_node &node);
- bool XML_SearchNode(const std::string &nodeName);
- void ParseHelper_FixTruncatedFloatString(const char *pInStr, std::string &pOutString);
- AMFImporter(const AMFImporter &pScene) = delete;
- AMFImporter &operator=(const AMFImporter &pScene) = delete;
private:
- static const aiImporterDesc Description;
-
AMFNodeElementBase *mNodeElement_Cur; ///< Current element.
std::list<AMFNodeElementBase *> mNodeElement_List; ///< All elements of scene graph.
XmlParser *mXmlParser;
diff --git a/code/AssetLib/AMF/AMFImporter_Geometry.cpp b/code/AssetLib/AMF/AMFImporter_Geometry.cpp
index 341999f56..db262dfbd 100644
--- a/code/AssetLib/AMF/AMFImporter_Geometry.cpp
+++ b/code/AssetLib/AMF/AMFImporter_Geometry.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/AMF/AMFImporter_Material.cpp b/code/AssetLib/AMF/AMFImporter_Material.cpp
index 676e74856..ae27f5d37 100644
--- a/code/AssetLib/AMF/AMFImporter_Material.cpp
+++ b/code/AssetLib/AMF/AMFImporter_Material.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/AMF/AMFImporter_Node.hpp b/code/AssetLib/AMF/AMFImporter_Node.hpp
index dd27316d3..21068a9ba 100644
--- a/code/AssetLib/AMF/AMFImporter_Node.hpp
+++ b/code/AssetLib/AMF/AMFImporter_Node.hpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/AMF/AMFImporter_Postprocess.cpp b/code/AssetLib/AMF/AMFImporter_Postprocess.cpp
index d5160870a..969c64bd2 100644
--- a/code/AssetLib/AMF/AMFImporter_Postprocess.cpp
+++ b/code/AssetLib/AMF/AMFImporter_Postprocess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/ASE/ASELoader.cpp b/code/AssetLib/ASE/ASELoader.cpp
index 4617c9ed4..7e411fc03 100644
--- a/code/AssetLib/ASE/ASELoader.cpp
+++ b/code/AssetLib/ASE/ASELoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -63,10 +63,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// utilities
#include <assimp/fast_atof.h>
-using namespace Assimp;
+namespace Assimp {
using namespace Assimp::ASE;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"ASE Importer",
"",
"",
@@ -904,7 +904,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh &mesh, std::vector<aiMesh *> &avOutMes
ASSIMP_LOG_WARN("Material index is out of range");
}
- // If the material the mesh is assigned to is consisting of submeshes, split it
+ // If the material the mesh is assigned to consists of submeshes, split it
if (!mParser->m_vMaterials[mesh.iMaterialIndex].avSubMaterials.empty()) {
std::vector<ASE::Material> vSubMaterials = mParser->m_vMaterials[mesh.iMaterialIndex].avSubMaterials;
@@ -1262,6 +1262,8 @@ bool ASEImporter::GenerateNormals(ASE::Mesh &mesh) {
return false;
}
+}
+
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER
#endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER
diff --git a/code/AssetLib/ASE/ASELoader.h b/code/AssetLib/ASE/ASELoader.h
index 2509671ef..5654fa630 100644
--- a/code/AssetLib/ASE/ASELoader.h
+++ b/code/AssetLib/ASE/ASELoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/ASE/ASEParser.cpp b/code/AssetLib/ASE/ASEParser.cpp
index c43eb42ff..e3c358aa5 100644
--- a/code/AssetLib/ASE/ASEParser.cpp
+++ b/code/AssetLib/ASE/ASEParser.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -53,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/fast_atof.h>
#include <assimp/DefaultLogger.hpp>
-using namespace Assimp;
+namespace Assimp {
using namespace Assimp::ASE;
// ------------------------------------------------------------------------------------------------
@@ -110,10 +110,12 @@ using namespace Assimp::ASE;
++filePtr;
// ------------------------------------------------------------------------------------------------
-Parser::Parser(const char *szFile, unsigned int fileFormatDefault) {
+Parser::Parser(const char *szFile, unsigned int fileFormatDefault) :
+ filePtr(nullptr), mEnd (nullptr) {
ai_assert(nullptr != szFile);
filePtr = szFile;
+ mEnd = filePtr + std::strlen(filePtr);
iFileFormat = fileFormatDefault;
// make sure that the color values are invalid
@@ -179,14 +181,22 @@ bool Parser::SkipToNextToken() {
while (true) {
char me = *filePtr;
+ if (filePtr == mEnd) {
+ return false;
+ }
+
// increase the line number counter if necessary
if (IsLineEnd(me) && !bLastWasEndLine) {
++iLineNumber;
bLastWasEndLine = true;
} else
bLastWasEndLine = false;
- if ('*' == me || '}' == me || '{' == me) return true;
- if ('\0' == me) return false;
+ if ('*' == me || '}' == me || '{' == me) {
+ return true;
+ }
+ if ('\0' == me) {
+ return false;
+ }
++filePtr;
}
@@ -344,8 +354,9 @@ void Parser::ParseLV1SoftSkinBlock() {
unsigned int numVerts = 0;
const char *sz = filePtr;
- while (!IsSpaceOrNewLine(*filePtr))
+ while (!IsSpaceOrNewLine(*filePtr)) {
++filePtr;
+ }
const unsigned int diff = (unsigned int)(filePtr - sz);
if (diff) {
@@ -363,24 +374,24 @@ void Parser::ParseLV1SoftSkinBlock() {
// Skip the mesh data - until we find a new mesh
// or the end of the *MESH_SOFTSKINVERTS section
while (true) {
- SkipSpacesAndLineEnd(&filePtr);
+ SkipSpacesAndLineEnd(&filePtr, mEnd);
if (*filePtr == '}') {
++filePtr;
return;
} else if (!IsNumeric(*filePtr))
break;
- SkipLine(&filePtr);
+ SkipLine(&filePtr, mEnd);
}
} else {
- SkipSpacesAndLineEnd(&filePtr);
+ SkipSpacesAndLineEnd(&filePtr, mEnd);
ParseLV4MeshLong(numVerts);
// Reserve enough storage
curMesh->mBoneVertices.reserve(numVerts);
for (unsigned int i = 0; i < numVerts; ++i) {
- SkipSpacesAndLineEnd(&filePtr);
+ SkipSpacesAndLineEnd(&filePtr, mEnd);
unsigned int numWeights;
ParseLV4MeshLong(numWeights);
@@ -422,7 +433,7 @@ void Parser::ParseLV1SoftSkinBlock() {
if (*filePtr == '\0')
return;
++filePtr;
- SkipSpacesAndLineEnd(&filePtr);
+ SkipSpacesAndLineEnd(&filePtr, mEnd);
}
}
@@ -743,7 +754,7 @@ void Parser::ParseLV3MapBlock(Texture &map) {
// ------------------------------------------------------------------------------------------------
bool Parser::ParseString(std::string &out, const char *szName) {
char szBuffer[1024];
- if (!SkipSpaces(&filePtr)) {
+ if (!SkipSpaces(&filePtr, mEnd)) {
ai_snprintf(szBuffer, 1024, "Unable to parse %s block: Unexpected EOL", szName);
LogWarning(szBuffer);
@@ -1355,7 +1366,7 @@ void Parser::ParseLV4MeshBones(unsigned int iNumBones, ASE::Mesh &mesh) {
// Mesh bone with name ...
if (TokenMatch(filePtr, "MESH_BONE_NAME", 14)) {
// parse an index ...
- if (SkipSpaces(&filePtr)) {
+ if (SkipSpaces(&filePtr, mEnd)) {
unsigned int iIndex = strtoul10(filePtr, &filePtr);
if (iIndex >= iNumBones) {
LogWarning("Bone index is out of bounds");
@@ -1395,11 +1406,11 @@ void Parser::ParseLV4MeshBonesVertices(unsigned int iNumVertices, ASE::Mesh &mes
std::pair<int, float> pairOut;
while (true) {
// first parse the bone index ...
- if (!SkipSpaces(&filePtr)) break;
+ if (!SkipSpaces(&filePtr, mEnd)) break;
pairOut.first = strtoul10(filePtr, &filePtr);
// then parse the vertex weight
- if (!SkipSpaces(&filePtr)) break;
+ if (!SkipSpaces(&filePtr, mEnd)) break;
filePtr = fast_atoreal_move<float>(filePtr, pairOut.second);
// -1 marks unused entries
@@ -1675,7 +1686,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh &sMesh) {
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshFace(ASE::Face &out) {
// skip spaces and tabs
- if (!SkipSpaces(&filePtr)) {
+ if (!SkipSpaces(&filePtr, mEnd)) {
LogWarning("Unable to parse *MESH_FACE Element: Unexpected EOL [#1]");
SkipToNextToken();
return;
@@ -1685,7 +1696,7 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) {
out.iFace = strtoul10(filePtr, &filePtr);
// next character should be ':'
- if (!SkipSpaces(&filePtr)) {
+ if (!SkipSpaces(&filePtr, mEnd)) {
// FIX: there are some ASE files which haven't got : here ....
LogWarning("Unable to parse *MESH_FACE Element: Unexpected EOL. \':\' expected [#2]");
SkipToNextToken();
@@ -1697,7 +1708,7 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) {
// Parse all mesh indices
for (unsigned int i = 0; i < 3; ++i) {
unsigned int iIndex = 0;
- if (!SkipSpaces(&filePtr)) {
+ if (!SkipSpaces(&filePtr, mEnd)) {
LogWarning("Unable to parse *MESH_FACE Element: Unexpected EOL");
SkipToNextToken();
return;
@@ -1723,7 +1734,7 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) {
++filePtr;
// next character should be ':'
- if (!SkipSpaces(&filePtr) || ':' != *filePtr) {
+ if (!SkipSpaces(&filePtr, mEnd) || ':' != *filePtr) {
LogWarning("Unable to parse *MESH_FACE Element: "
"Unexpected EOL. \':\' expected [#2]");
SkipToNextToken();
@@ -1731,9 +1742,9 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) {
}
++filePtr;
- if (!SkipSpaces(&filePtr)) {
+ if (!SkipSpaces(&filePtr, mEnd)) {
LogWarning("Unable to parse *MESH_FACE Element: Unexpected EOL. "
- "Vertex index ecpected [#4]");
+ "Vertex index expected [#4]");
SkipToNextToken();
return;
}
@@ -1752,7 +1763,7 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) {
// parse the smoothing group of the face
if (TokenMatch(filePtr, "*MESH_SMOOTHING", 15)) {
- if (!SkipSpaces(&filePtr)) {
+ if (!SkipSpaces(&filePtr, mEnd)) {
LogWarning("Unable to parse *MESH_SMOOTHING Element: "
"Unexpected EOL. Smoothing group(s) expected [#5]");
SkipToNextToken();
@@ -1771,12 +1782,12 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) {
LogWarning(message.c_str());
}
}
- SkipSpaces(&filePtr);
+ SkipSpaces(&filePtr, mEnd);
if (',' != *filePtr) {
break;
}
++filePtr;
- SkipSpaces(&filePtr);
+ SkipSpaces(&filePtr, mEnd);
}
}
@@ -1792,7 +1803,7 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) {
}
if (TokenMatch(filePtr, "*MESH_MTLID", 11)) {
- if (!SkipSpaces(&filePtr)) {
+ if (!SkipSpaces(&filePtr, mEnd)) {
LogWarning("Unable to parse *MESH_MTLID Element: Unexpected EOL. "
"Material index expected [#6]");
SkipToNextToken();
@@ -1840,7 +1851,7 @@ void Parser::ParseLV4MeshFloatTriple(ai_real *apOut) {
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshFloat(ai_real &fOut) {
// skip spaces and tabs
- if (!SkipSpaces(&filePtr)) {
+ if (!SkipSpaces(&filePtr, mEnd)) {
// LOG
LogWarning("Unable to parse float: unexpected EOL [#1]");
fOut = 0.0;
@@ -1853,7 +1864,7 @@ void Parser::ParseLV4MeshFloat(ai_real &fOut) {
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshLong(unsigned int &iOut) {
// Skip spaces and tabs
- if (!SkipSpaces(&filePtr)) {
+ if (!SkipSpaces(&filePtr, mEnd)) {
// LOG
LogWarning("Unable to parse long: unexpected EOL [#1]");
iOut = 0;
@@ -1864,6 +1875,8 @@ void Parser::ParseLV4MeshLong(unsigned int &iOut) {
iOut = strtoul10(filePtr, &filePtr);
}
+}
+
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER
#endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER
diff --git a/code/AssetLib/ASE/ASEParser.h b/code/AssetLib/ASE/ASEParser.h
index c41cd59d3..263b5ca73 100644
--- a/code/AssetLib/ASE/ASEParser.h
+++ b/code/AssetLib/ASE/ASEParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -620,6 +620,9 @@ public:
//! Pointer to current data
const char *filePtr;
+ /// The end pointer of the file data
+ const char *mEnd;
+
//! background color to be passed to the viewer
//! QNAN if none was found
aiColor3D m_clrBackground;
diff --git a/code/AssetLib/Assbin/AssbinExporter.cpp b/code/AssetLib/Assbin/AssbinExporter.cpp
index 149b3c5f3..b8465f866 100644
--- a/code/AssetLib/Assbin/AssbinExporter.cpp
+++ b/code/AssetLib/Assbin/AssbinExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Assbin/AssbinExporter.h b/code/AssetLib/Assbin/AssbinExporter.h
index 8b721994d..271b6b833 100644
--- a/code/AssetLib/Assbin/AssbinExporter.h
+++ b/code/AssetLib/Assbin/AssbinExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Assbin/AssbinFileWriter.cpp b/code/AssetLib/Assbin/AssbinFileWriter.cpp
index e9d857a84..90bcccf90 100644
--- a/code/AssetLib/Assbin/AssbinFileWriter.cpp
+++ b/code/AssetLib/Assbin/AssbinFileWriter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -50,11 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/version.h>
#include <assimp/IOStream.hpp>
-#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
-#include <zlib.h>
-#else
-#include "../contrib/zlib/zlib.h"
-#endif
+#include "zlib.h"
#include <ctime>
diff --git a/code/AssetLib/Assbin/AssbinFileWriter.h b/code/AssetLib/Assbin/AssbinFileWriter.h
index cfed3b400..84641df46 100644
--- a/code/AssetLib/Assbin/AssbinFileWriter.h
+++ b/code/AssetLib/Assbin/AssbinFileWriter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Assbin/AssbinLoader.cpp b/code/AssetLib/Assbin/AssbinLoader.cpp
index f7b35636c..d2566a85c 100644
--- a/code/AssetLib/Assbin/AssbinLoader.cpp
+++ b/code/AssetLib/Assbin/AssbinLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -65,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Assimp Binary Importer",
"Gargaj / Conspiracy",
"",
diff --git a/code/AssetLib/Assbin/AssbinLoader.h b/code/AssetLib/Assbin/AssbinLoader.h
index f922b91fd..2b85e6655 100644
--- a/code/AssetLib/Assbin/AssbinLoader.h
+++ b/code/AssetLib/Assbin/AssbinLoader.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Assxml/AssxmlExporter.cpp b/code/AssetLib/Assxml/AssxmlExporter.cpp
index 731916a25..b9691b822 100644
--- a/code/AssetLib/Assxml/AssxmlExporter.cpp
+++ b/code/AssetLib/Assxml/AssxmlExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Assxml/AssxmlExporter.h b/code/AssetLib/Assxml/AssxmlExporter.h
index 6fcdebfab..28a9b7f35 100644
--- a/code/AssetLib/Assxml/AssxmlExporter.h
+++ b/code/AssetLib/Assxml/AssxmlExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Assxml/AssxmlFileWriter.cpp b/code/AssetLib/Assxml/AssxmlFileWriter.cpp
index 8f8e76bd2..f6fdc4a0c 100644
--- a/code/AssetLib/Assxml/AssxmlFileWriter.cpp
+++ b/code/AssetLib/Assxml/AssxmlFileWriter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Assxml/AssxmlFileWriter.h b/code/AssetLib/Assxml/AssxmlFileWriter.h
index 0620c9db7..1051a03a0 100644
--- a/code/AssetLib/Assxml/AssxmlFileWriter.h
+++ b/code/AssetLib/Assxml/AssxmlFileWriter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/B3D/B3DImporter.cpp b/code/AssetLib/B3D/B3DImporter.cpp
index bf8145798..d0029277c 100644
--- a/code/AssetLib/B3D/B3DImporter.cpp
+++ b/code/AssetLib/B3D/B3DImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -59,10 +59,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory>
-using namespace Assimp;
+namespace Assimp {
using namespace std;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"BlitzBasic 3D Importer",
"",
"",
@@ -79,9 +79,9 @@ static const aiImporterDesc desc = {
#pragma warning(disable : 4018)
#endif
-//#define DEBUG_B3D
+// #define DEBUG_B3D
-template<typename T>
+template <typename T>
void DeleteAllBarePointers(std::vector<T> &x) {
for (auto p : x) {
delete p;
@@ -329,7 +329,7 @@ void B3DImporter::ReadBRUS() {
mat->AddProperty(&i, 1, AI_MATKEY_TWOSIDED);
}
- //Textures
+ // Textures
for (int i = 0; i < n_texs; ++i) {
int texid = ReadInt();
if (texid < -1 || (texid >= 0 && texid >= static_cast<int>(_textures.size()))) {
@@ -372,7 +372,7 @@ void B3DImporter::ReadVRTS() {
}
if (_vflags & 2) {
- ReadQuat(); //skip v 4bytes...
+ ReadQuat(); // skip v 4bytes...
}
for (int j = 0; j < _tcsets; ++j) {
@@ -704,22 +704,22 @@ void B3DImporter::ReadBB3D(aiScene *scene) {
}
}
- //nodes
+ // nodes
scene->mRootNode = _nodes[0];
_nodes.clear(); // node ownership now belongs to scene
- //material
+ // material
if (!_materials.size()) {
_materials.emplace_back(std::unique_ptr<aiMaterial>(new aiMaterial));
}
scene->mNumMaterials = static_cast<unsigned int>(_materials.size());
scene->mMaterials = unique_to_array(_materials);
- //meshes
+ // meshes
scene->mNumMeshes = static_cast<unsigned int>(_meshes.size());
scene->mMeshes = unique_to_array(_meshes);
- //animations
+ // animations
if (_animations.size() == 1 && _nodeAnims.size()) {
aiAnimation *anim = _animations.back().get();
@@ -738,4 +738,6 @@ void B3DImporter::ReadBB3D(aiScene *scene) {
flip.Execute(scene);
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_B3D_IMPORTER
diff --git a/code/AssetLib/B3D/B3DImporter.h b/code/AssetLib/B3D/B3DImporter.h
index e47d9078b..0fcfae620 100644
--- a/code/AssetLib/B3D/B3DImporter.h
+++ b/code/AssetLib/B3D/B3DImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/BVH/BVHLoader.cpp b/code/AssetLib/BVH/BVHLoader.cpp
index d92887c9e..2b37286ea 100644
--- a/code/AssetLib/BVH/BVHLoader.cpp
+++ b/code/AssetLib/BVH/BVHLoader.cpp
@@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
@@ -55,10 +55,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <map>
#include <memory>
-using namespace Assimp;
+namespace Assimp {
+
using namespace Assimp::Formatter;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"BVH Importer (MoCap)",
"",
"",
@@ -73,8 +74,8 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Aborts the file reading with an exception
-template<typename... T>
-AI_WONT_RETURN void BVHLoader::ThrowException(T&&... args) {
+template <typename... T>
+AI_WONT_RETURN void BVHLoader::ThrowException(T &&...args) {
throw DeadlyImportError(mFileName, ":", mLine, " - ", args...);
}
@@ -426,7 +427,7 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
nodeAnim->mNodeName.Set(nodeName);
std::map<BVHLoader::ChannelType, int> channelMap;
- //Build map of channels
+ // Build map of channels
for (unsigned int channel = 0; channel < node.mChannels.size(); ++channel) {
channelMap[node.mChannels[channel]] = channel;
}
@@ -441,7 +442,7 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
// Now compute all translations
for (BVHLoader::ChannelType channel = Channel_PositionX; channel <= Channel_PositionZ; channel = (BVHLoader::ChannelType)(channel + 1)) {
- //Find channel in node
+ // Find channel in node
std::map<BVHLoader::ChannelType, int>::iterator mapIter = channelMap.find(channel);
if (mapIter == channelMap.end())
@@ -485,30 +486,27 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
for (unsigned int fr = 0; fr < mAnimNumFrames; ++fr) {
aiMatrix4x4 temp;
aiMatrix3x3 rotMatrix;
- for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++ channelIdx) {
- switch (node.mChannels[channelIdx]) {
- case Channel_RotationX:
- {
+ for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++channelIdx) {
+ switch (node.mChannels[channelIdx]) {
+ case Channel_RotationX: {
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
- aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp);
- }
- break;
- case Channel_RotationY:
- {
+ aiMatrix4x4::RotationX(angle, temp);
+ rotMatrix *= aiMatrix3x3(temp);
+ } break;
+ case Channel_RotationY: {
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
- aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp);
- }
- break;
- case Channel_RotationZ:
- {
+ aiMatrix4x4::RotationY(angle, temp);
+ rotMatrix *= aiMatrix3x3(temp);
+ } break;
+ case Channel_RotationZ: {
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
- aiMatrix4x4::RotationZ( angle, temp); rotMatrix *= aiMatrix3x3( temp);
- }
- break;
+ aiMatrix4x4::RotationZ(angle, temp);
+ rotMatrix *= aiMatrix3x3(temp);
+ } break;
default:
break;
- }
- }
+ }
+ }
rotkey->mTime = double(fr);
rotkey->mValue = aiQuaternion(rotMatrix);
++rotkey;
@@ -525,4 +523,6 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
}
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_BVH_IMPORTER
diff --git a/code/AssetLib/BVH/BVHLoader.h b/code/AssetLib/BVH/BVHLoader.h
index 56c32bd99..2c5e24114 100644
--- a/code/AssetLib/BVH/BVHLoader.h
+++ b/code/AssetLib/BVH/BVHLoader.h
@@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Blender/BlenderBMesh.cpp b/code/AssetLib/Blender/BlenderBMesh.cpp
index a82e7c678..0660967bd 100644
--- a/code/AssetLib/Blender/BlenderBMesh.cpp
+++ b/code/AssetLib/Blender/BlenderBMesh.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/Blender/BlenderBMesh.h b/code/AssetLib/Blender/BlenderBMesh.h
index 7d2f71717..1798aaf74 100644
--- a/code/AssetLib/Blender/BlenderBMesh.h
+++ b/code/AssetLib/Blender/BlenderBMesh.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/Blender/BlenderDNA.cpp b/code/AssetLib/Blender/BlenderDNA.cpp
index d22c4bfd7..311911249 100644
--- a/code/AssetLib/Blender/BlenderDNA.cpp
+++ b/code/AssetLib/Blender/BlenderDNA.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Blender/BlenderDNA.h b/code/AssetLib/Blender/BlenderDNA.h
index 494dc4b34..f6a691fd6 100644
--- a/code/AssetLib/Blender/BlenderDNA.h
+++ b/code/AssetLib/Blender/BlenderDNA.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Blender/BlenderDNA.inl b/code/AssetLib/Blender/BlenderDNA.inl
index 4f64987a5..9bcb602ba 100644
--- a/code/AssetLib/Blender/BlenderDNA.inl
+++ b/code/AssetLib/Blender/BlenderDNA.inl
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Blender/BlenderIntermediate.h b/code/AssetLib/Blender/BlenderIntermediate.h
index 546b79f09..700beb7b0 100644
--- a/code/AssetLib/Blender/BlenderIntermediate.h
+++ b/code/AssetLib/Blender/BlenderIntermediate.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Blender/BlenderLoader.cpp b/code/AssetLib/Blender/BlenderLoader.cpp
index 5c6e7bc5b..1a40a2fe5 100644
--- a/code/AssetLib/Blender/BlenderLoader.cpp
+++ b/code/AssetLib/Blender/BlenderLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -69,11 +69,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// zlib is needed for compressed blend files
#ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND
#include "Common/Compression.h"
-/* #ifdef ASSIMP_BUILD_NO_OWN_ZLIB
-# include <zlib.h>
-# else
-# include "../contrib/zlib/zlib.h"
-# endif*/
#endif
namespace Assimp {
@@ -89,7 +84,7 @@ using namespace Assimp;
using namespace Assimp::Blender;
using namespace Assimp::Formatter;
-static const aiImporterDesc blenderDesc = {
+static constexpr aiImporterDesc blenderDesc = {
"Blender 3D Importer (http://www.blender3d.org)",
"",
"",
diff --git a/code/AssetLib/Blender/BlenderLoader.h b/code/AssetLib/Blender/BlenderLoader.h
index 2bdc24ae2..5c800c627 100644
--- a/code/AssetLib/Blender/BlenderLoader.h
+++ b/code/AssetLib/Blender/BlenderLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Blender/BlenderModifier.cpp b/code/AssetLib/Blender/BlenderModifier.cpp
index 6cc11ec8e..2cd8bda7c 100644
--- a/code/AssetLib/Blender/BlenderModifier.cpp
+++ b/code/AssetLib/Blender/BlenderModifier.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -283,6 +283,11 @@ void BlenderModifier_Subdivision ::DoIt(aiNode &out, ConversionData &conv_data,
if (conv_data.meshes->empty()) {
return;
}
+ const size_t meshIndex = conv_data.meshes->size() - out.mNumMeshes;
+ if (meshIndex >= conv_data.meshes->size()) {
+ ASSIMP_LOG_ERROR("Invalid index detected.");
+ return;
+ }
aiMesh **const meshes = &conv_data.meshes[conv_data.meshes->size() - out.mNumMeshes];
std::unique_ptr<aiMesh *[]> tempmeshes(new aiMesh *[out.mNumMeshes]());
diff --git a/code/AssetLib/Blender/BlenderModifier.h b/code/AssetLib/Blender/BlenderModifier.h
index 180a456a1..2d6940357 100644
--- a/code/AssetLib/Blender/BlenderModifier.h
+++ b/code/AssetLib/Blender/BlenderModifier.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Blender/BlenderScene.cpp b/code/AssetLib/Blender/BlenderScene.cpp
index a2e4c30f2..e25dc450b 100644
--- a/code/AssetLib/Blender/BlenderScene.cpp
+++ b/code/AssetLib/Blender/BlenderScene.cpp
@@ -297,7 +297,7 @@ void Structure ::Convert<Base>(
const FileDatabase &db) const {
// note: as per https://github.com/assimp/assimp/issues/128,
// reading the Object linked list recursively is prone to stack overflow.
- // This structure converter is therefore an hand-written exception that
+ // This structure converter is therefore a hand-written exception that
// does it iteratively.
const int initial_pos = db.reader->GetCurrentPos();
diff --git a/code/AssetLib/Blender/BlenderScene.h b/code/AssetLib/Blender/BlenderScene.h
index ba7ded909..671891c68 100644
--- a/code/AssetLib/Blender/BlenderScene.h
+++ b/code/AssetLib/Blender/BlenderScene.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Blender/BlenderTessellator.cpp b/code/AssetLib/Blender/BlenderTessellator.cpp
index 84bc2ea1a..f51cf9780 100644
--- a/code/AssetLib/Blender/BlenderTessellator.cpp
+++ b/code/AssetLib/Blender/BlenderTessellator.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Blender/BlenderTessellator.h b/code/AssetLib/Blender/BlenderTessellator.h
index 21a4f4701..e43535f6c 100644
--- a/code/AssetLib/Blender/BlenderTessellator.h
+++ b/code/AssetLib/Blender/BlenderTessellator.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/C4D/C4DImporter.cpp b/code/AssetLib/C4D/C4DImporter.cpp
index c11ec0280..daef6ebe4 100644
--- a/code/AssetLib/C4D/C4DImporter.cpp
+++ b/code/AssetLib/C4D/C4DImporter.cpp
@@ -46,10 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// no #ifdefing here, Cinema4D support is carried out in a branch of assimp
// where it is turned on in the CMake settings.
-#ifndef _MSC_VER
-# error C4D support is currently MSVC only
-#endif
-
#include "C4DImporter.h"
#include <memory>
#include <assimp/IOSystem.hpp>
@@ -111,7 +107,7 @@ C4DImporter::C4DImporter() = default;
C4DImporter::~C4DImporter() = default;
// ------------------------------------------------------------------------------------------------
-bool C4DImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const {
+bool C4DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
const std::string& extension = GetExtension(pFile);
if (extension == "c4d") {
return true;
@@ -305,7 +301,7 @@ void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent) {
// based on Cineware sample code
while (object) {
- const LONG type = object->GetType();
+ const Int32 type = object->GetType();
const Matrix& ml = object->GetMl();
aiNode* const nd = new aiNode();
@@ -368,8 +364,8 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) {
PolygonObject* const polyObject = dynamic_cast<PolygonObject*>(object);
ai_assert(polyObject != nullptr);
- const LONG pointCount = polyObject->GetPointCount();
- const LONG polyCount = polyObject->GetPolygonCount();
+ const Int32 pointCount = polyObject->GetPointCount();
+ const Int32 polyCount = polyObject->GetPolygonCount();
if(!polyObject || !pointCount) {
LogWarn("ignoring mesh with zero vertices or faces");
return nullptr;
@@ -391,7 +387,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) {
unsigned int vcount = 0;
// first count vertices
- for (LONG i = 0; i < polyCount; i++)
+ for (Int32 i = 0; i < polyCount; i++)
{
vcount += 3;
@@ -434,7 +430,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) {
}
// copy vertices and extra channels over and populate faces
- for (LONG i = 0; i < polyCount; ++i, ++face) {
+ for (Int32 i = 0; i < polyCount; ++i, ++face) {
ai_assert(polys[i].a < pointCount && polys[i].a >= 0);
const Vector& pointA = points[polys[i].a];
verts->x = pointA.x;
@@ -511,7 +507,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) {
if (tangents_src) {
for(unsigned int k = 0; k < face->mNumIndices; ++k) {
- LONG l;
+ Int32 l;
switch(k) {
case 0:
l = polys[i].a;
diff --git a/code/AssetLib/C4D/C4DImporter.h b/code/AssetLib/C4D/C4DImporter.h
index c44cf5e37..effd2af09 100644
--- a/code/AssetLib/C4D/C4DImporter.h
+++ b/code/AssetLib/C4D/C4DImporter.h
@@ -78,6 +78,8 @@ namespace Assimp {
// -------------------------------------------------------------------------------------------
class C4DImporter : public BaseImporter, public LogFunctions<C4DImporter> {
public:
+ C4DImporter();
+ ~C4DImporter() override;
bool CanRead( const std::string& pFile, IOSystem*, bool checkSig) const override;
protected:
diff --git a/code/AssetLib/COB/COBLoader.cpp b/code/AssetLib/COB/COBLoader.cpp
index 20df53f75..f0899bddd 100644
--- a/code/AssetLib/COB/COBLoader.cpp
+++ b/code/AssetLib/COB/COBLoader.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -61,11 +61,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory>
-using namespace Assimp;
+namespace Assimp {
using namespace Assimp::COB;
using namespace Assimp::Formatter;
-static const float units[] = {
+static constexpr float units[] = {
1000.f,
100.f,
1.f,
@@ -76,7 +76,7 @@ static const float units[] = {
1.f / 1609.344f
};
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"TrueSpace Object Importer",
"",
"",
@@ -90,14 +90,6 @@ static const aiImporterDesc desc = {
};
// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-COBImporter::COBImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-COBImporter::~COBImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool COBImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const char *tokens[] = { "Caligary" };
@@ -481,8 +473,9 @@ void COBImporter::ReadBasicNodeInfo_Ascii(Node &msh, LineSplitter &splitter, con
} else if (splitter.match_start("Transform")) {
for (unsigned int y = 0; y < 4 && ++splitter; ++y) {
const char *s = splitter->c_str();
+ const char *end = s + splitter->size();
for (unsigned int x = 0; x < 4; ++x) {
- SkipSpaces(&s);
+ SkipSpaces(&s, end);
msh.transform[y][x] = fast_atof(&s);
}
}
@@ -494,12 +487,12 @@ void COBImporter::ReadBasicNodeInfo_Ascii(Node &msh, LineSplitter &splitter, con
// ------------------------------------------------------------------------------------------------
template <typename T>
-void COBImporter::ReadFloat3Tuple_Ascii(T &fill, const char **in) {
+void COBImporter::ReadFloat3Tuple_Ascii(T &fill, const char **in, const char *end) {
const char *rgb = *in;
for (unsigned int i = 0; i < 3; ++i) {
- SkipSpaces(&rgb);
+ SkipSpaces(&rgb, end);
if (*rgb == ',') ++rgb;
- SkipSpaces(&rgb);
+ SkipSpaces(&rgb, end);
fill[i] = fast_atof(&rgb);
}
@@ -546,7 +539,7 @@ void COBImporter::ReadMat1_Ascii(Scene &out, LineSplitter &splitter, const Chunk
}
const char *rgb = splitter[1];
- ReadFloat3Tuple_Ascii(mat.rgb, &rgb);
+ ReadFloat3Tuple_Ascii(mat.rgb, &rgb, splitter.getEnd());
++splitter;
if (!splitter.match_start("alpha ")) {
@@ -625,20 +618,21 @@ void COBImporter::ReadLght_Ascii(Scene &out, LineSplitter &splitter, const Chunk
}
const char *rgb = splitter[1];
- ReadFloat3Tuple_Ascii(msh.color, &rgb);
+ const char *end = splitter.getEnd();
+ ReadFloat3Tuple_Ascii(msh.color, &rgb, end);
- SkipSpaces(&rgb);
+ SkipSpaces(&rgb, end);
if (strncmp(rgb, "cone angle", 10) != 0) {
ASSIMP_LOG_WARN("Expected `cone angle` entity in `color` line in `Lght` chunk ", nfo.id);
}
- SkipSpaces(rgb + 10, &rgb);
+ SkipSpaces(rgb + 10, &rgb, end);
msh.angle = fast_atof(&rgb);
- SkipSpaces(&rgb);
+ SkipSpaces(&rgb, end);
if (strncmp(rgb, "inner angle", 11) != 0) {
ASSIMP_LOG_WARN("Expected `inner angle` entity in `color` line in `Lght` chunk ", nfo.id);
}
- SkipSpaces(rgb + 11, &rgb);
+ SkipSpaces(rgb + 11, &rgb, end);
msh.inner_angle = fast_atof(&rgb);
// skip the rest for we can't handle this kind of physically-based lighting information.
@@ -711,14 +705,14 @@ void COBImporter::ReadPolH_Ascii(Scene &out, LineSplitter &splitter, const Chunk
for (unsigned int cur = 0; cur < cnt && ++splitter; ++cur) {
const char *s = splitter->c_str();
-
+ const char *end = splitter.getEnd();
aiVector3D &v = msh.vertex_positions[cur];
- SkipSpaces(&s);
+ SkipSpaces(&s, end);
v.x = fast_atof(&s);
- SkipSpaces(&s);
+ SkipSpaces(&s, end);
v.y = fast_atof(&s);
- SkipSpaces(&s);
+ SkipSpaces(&s, end);
v.z = fast_atof(&s);
}
} else if (splitter.match_start("Texture Vertices")) {
@@ -727,12 +721,13 @@ void COBImporter::ReadPolH_Ascii(Scene &out, LineSplitter &splitter, const Chunk
for (unsigned int cur = 0; cur < cnt && ++splitter; ++cur) {
const char *s = splitter->c_str();
+ const char *end = splitter.getEnd();
aiVector2D &v = msh.texture_coords[cur];
- SkipSpaces(&s);
+ SkipSpaces(&s, end);
v.x = fast_atof(&s);
- SkipSpaces(&s);
+ SkipSpaces(&s, end);
v.y = fast_atof(&s);
}
} else if (splitter.match_start("Faces")) {
@@ -757,8 +752,9 @@ void COBImporter::ReadPolH_Ascii(Scene &out, LineSplitter &splitter, const Chunk
face.material = strtoul10(splitter[6]);
const char *s = (++splitter)->c_str();
+ const char *end = splitter.getEnd();
for (size_t i = 0; i < face.indices.size(); ++i) {
- if (!SkipSpaces(&s)) {
+ if (!SkipSpaces(&s, end)) {
ThrowException("Expected EOL token in Face entry");
}
if ('<' != *s++) {
@@ -1172,4 +1168,6 @@ void COBImporter::ReadUnit_Binary(COB::Scene &out, StreamReaderLE &reader, const
ASSIMP_LOG_WARN("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
}
+}
+
#endif // ASSIMP_BUILD_NO_COB_IMPORTER
diff --git a/code/AssetLib/COB/COBLoader.h b/code/AssetLib/COB/COBLoader.h
index e6eb96dc1..ec3c7756b 100644
--- a/code/AssetLib/COB/COBLoader.h
+++ b/code/AssetLib/COB/COBLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -56,16 +56,16 @@ class LineSplitter;
// TinyFormatter.h
namespace Formatter {
-template <typename T, typename TR, typename A>
-class basic_formatter;
-typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>> format;
+ template <typename T, typename TR, typename A>
+ class basic_formatter;
+ typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>> format;
} // namespace Formatter
// COBScene.h
namespace COB {
-struct ChunkInfo;
-struct Node;
-struct Scene;
+ struct ChunkInfo;
+ struct Node;
+ struct Scene;
} // namespace COB
// -------------------------------------------------------------------------------------------
@@ -75,8 +75,8 @@ struct Scene;
// -------------------------------------------------------------------------------------------
class COBImporter : public BaseImporter {
public:
- COBImporter();
- ~COBImporter() override;
+ COBImporter() = default;
+ ~COBImporter() override = default;
// --------------------
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
@@ -120,7 +120,7 @@ private:
void ReadChunkInfo_Ascii(COB::ChunkInfo &out, const LineSplitter &splitter);
void ReadBasicNodeInfo_Ascii(COB::Node &msh, LineSplitter &splitter, const COB::ChunkInfo &nfo);
template <typename T>
- void ReadFloat3Tuple_Ascii(T &fill, const char **in);
+ void ReadFloat3Tuple_Ascii(T &fill, const char **in, const char *end);
void ReadPolH_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
void ReadBitM_Ascii(COB::Scene &out, LineSplitter &splitter, const COB::ChunkInfo &nfo);
diff --git a/code/AssetLib/COB/COBScene.h b/code/AssetLib/COB/COBScene.h
index cc49de276..ea4c01251 100644
--- a/code/AssetLib/COB/COBScene.h
+++ b/code/AssetLib/COB/COBScene.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/CSM/CSMLoader.cpp b/code/AssetLib/CSM/CSMLoader.cpp
index db152f453..47beee514 100644
--- a/code/AssetLib/CSM/CSMLoader.cpp
+++ b/code/AssetLib/CSM/CSMLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
@@ -44,9 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** @file CSMLoader.cpp
* Implementation of the CSM importer class.
*/
-
-
-
#ifndef ASSIMP_BUILD_NO_CSM_IMPORTER
#include "CSMLoader.h"
@@ -63,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"CharacterStudio Motion Importer (MoCap)",
"",
"",
@@ -79,33 +76,26 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
-CSMImporter::CSMImporter()
-: noSkeletonMesh()
-{}
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-CSMImporter::~CSMImporter() = default;
+CSMImporter::CSMImporter() : noSkeletonMesh(){
+ // empty
+}
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
-bool CSMImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
-{
+bool CSMImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const {
static const char* tokens[] = {"$Filename"};
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,AI_COUNT_OF(tokens));
}
// ------------------------------------------------------------------------------------------------
// Build a string of all file extensions supported
-const aiImporterDesc* CSMImporter::GetInfo () const
-{
+const aiImporterDesc* CSMImporter::GetInfo () const {
return &desc;
}
// ------------------------------------------------------------------------------------------------
// Setup configuration properties for the loader
-void CSMImporter::SetupProperties(const Importer* pImp)
-{
+void CSMImporter::SetupProperties(const Importer* pImp) {
noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0;
}
@@ -125,29 +115,29 @@ void CSMImporter::InternReadFile( const std::string& pFile,
std::vector<char> mBuffer2;
TextFileToBuffer(file.get(),mBuffer2);
const char* buffer = &mBuffer2[0];
-
+ const char *end = &mBuffer2[mBuffer2.size() - 1] + 1;
std::unique_ptr<aiAnimation> anim(new aiAnimation());
int first = 0, last = 0x00ffffff;
// now process the file and look out for '$' sections
while (true) {
- SkipSpaces(&buffer);
+ SkipSpaces(&buffer, end);
if ('\0' == *buffer)
break;
if ('$' == *buffer) {
++buffer;
if (TokenMatchI(buffer,"firstframe",10)) {
- SkipSpaces(&buffer);
+ SkipSpaces(&buffer, end);
first = strtol10(buffer,&buffer);
}
else if (TokenMatchI(buffer,"lastframe",9)) {
- SkipSpaces(&buffer);
+ SkipSpaces(&buffer, end);
last = strtol10(buffer,&buffer);
}
else if (TokenMatchI(buffer,"rate",4)) {
- SkipSpaces(&buffer);
- float d;
+ SkipSpaces(&buffer, end);
+ float d = { 0.0f };
buffer = fast_atoreal_move<float>(buffer,d);
anim->mTicksPerSecond = d;
}
@@ -155,8 +145,8 @@ void CSMImporter::InternReadFile( const std::string& pFile,
std::vector< aiNodeAnim* > anims_temp;
anims_temp.reserve(30);
while (true) {
- SkipSpaces(&buffer);
- if (IsLineEnd(*buffer) && SkipSpacesAndLineEnd(&buffer) && *buffer == '$')
+ SkipSpaces(&buffer, end);
+ if (IsLineEnd(*buffer) && SkipSpacesAndLineEnd(&buffer, end) && *buffer == '$')
break; // next section
// Construct a new node animation channel and setup its name
@@ -164,41 +154,43 @@ void CSMImporter::InternReadFile( const std::string& pFile,
aiNodeAnim* nda = anims_temp.back();
char* ot = nda->mNodeName.data;
- while (!IsSpaceOrNewLine(*buffer))
+ while (!IsSpaceOrNewLine(*buffer)) {
*ot++ = *buffer++;
+ }
*ot = '\0';
nda->mNodeName.length = static_cast<ai_uint32>(ot-nda->mNodeName.data);
}
anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
- if (!anim->mNumChannels)
+ if (!anim->mNumChannels) {
throw DeadlyImportError("CSM: Empty $order section");
+ }
// copy over to the output animation
anim->mChannels = new aiNodeAnim*[anim->mNumChannels];
::memcpy(anim->mChannels,&anims_temp[0],sizeof(aiNodeAnim*)*anim->mNumChannels);
- }
- else if (TokenMatchI(buffer,"points",6)) {
- if (!anim->mNumChannels)
+ } else if (TokenMatchI(buffer,"points",6)) {
+ if (!anim->mNumChannels) {
throw DeadlyImportError("CSM: \'$order\' section is required to appear prior to \'$points\'");
+ }
// If we know how many frames we'll read, we can preallocate some storage
unsigned int alloc = 100;
- if (last != 0x00ffffff)
- {
+ if (last != 0x00ffffff) {
alloc = last-first;
alloc += alloc>>2u; // + 25%
- for (unsigned int i = 0; i < anim->mNumChannels;++i)
+ for (unsigned int i = 0; i < anim->mNumChannels; ++i) {
anim->mChannels[i]->mPositionKeys = new aiVectorKey[alloc];
+ }
}
unsigned int filled = 0;
// Now read all point data.
while (true) {
- SkipSpaces(&buffer);
- if (IsLineEnd(*buffer) && (!SkipSpacesAndLineEnd(&buffer) || *buffer == '$')) {
+ SkipSpaces(&buffer, end);
+ if (IsLineEnd(*buffer) && (!SkipSpacesAndLineEnd(&buffer, end) || *buffer == '$')) {
break; // next section
}
@@ -209,8 +201,8 @@ void CSMImporter::InternReadFile( const std::string& pFile,
for (unsigned int i = 0; i < anim->mNumChannels;++i) {
aiNodeAnim* s = anim->mChannels[i];
- if (s->mNumPositionKeys == alloc) { /* need to reallocate? */
-
+ if (s->mNumPositionKeys == alloc) {
+ // need to reallocate?
aiVectorKey* old = s->mPositionKeys;
s->mPositionKeys = new aiVectorKey[s->mNumPositionKeys = alloc*2];
::memcpy(s->mPositionKeys,old,sizeof(aiVectorKey)*alloc);
@@ -218,24 +210,26 @@ void CSMImporter::InternReadFile( const std::string& pFile,
}
// read x,y,z
- if(!SkipSpacesAndLineEnd(&buffer))
+ if (!SkipSpacesAndLineEnd(&buffer, end)) {
throw DeadlyImportError("CSM: Unexpected EOF occurred reading sample x coord");
+ }
if (TokenMatchI(buffer, "DROPOUT", 7)) {
// seems this is invalid marker data; at least the doc says it's possible
ASSIMP_LOG_WARN("CSM: Encountered invalid marker data (DROPOUT)");
- }
- else {
+ } else {
aiVectorKey* sub = s->mPositionKeys + s->mNumPositionKeys;
sub->mTime = (double)frame;
buffer = fast_atoreal_move<float>(buffer, (float&)sub->mValue.x);
- if(!SkipSpacesAndLineEnd(&buffer))
+ if (!SkipSpacesAndLineEnd(&buffer, end)) {
throw DeadlyImportError("CSM: Unexpected EOF occurred reading sample y coord");
+ }
buffer = fast_atoreal_move<float>(buffer, (float&)sub->mValue.y);
- if(!SkipSpacesAndLineEnd(&buffer))
+ if (!SkipSpacesAndLineEnd(&buffer, end)) {
throw DeadlyImportError("CSM: Unexpected EOF occurred reading sample z coord");
+ }
buffer = fast_atoreal_move<float>(buffer, (float&)sub->mValue.z);
++s->mNumPositionKeys;
@@ -243,22 +237,22 @@ void CSMImporter::InternReadFile( const std::string& pFile,
}
// update allocation granularity
- if (filled == alloc)
+ if (filled == alloc) {
alloc *= 2;
+ }
++filled;
}
// all channels must be complete in order to continue safely.
for (unsigned int i = 0; i < anim->mNumChannels;++i) {
-
- if (!anim->mChannels[i]->mNumPositionKeys)
+ if (!anim->mChannels[i]->mNumPositionKeys) {
throw DeadlyImportError("CSM: Invalid marker track");
+ }
}
}
- }
- else {
+ } else {
// advance to the next line
- SkipLine(&buffer);
+ SkipLine(&buffer, end);
}
}
@@ -272,7 +266,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
pScene->mRootNode->mNumChildren = anim->mNumChannels;
pScene->mRootNode->mChildren = new aiNode* [anim->mNumChannels];
- for (unsigned int i = 0; i < anim->mNumChannels;++i) {
+ for (unsigned int i = 0; i < anim->mNumChannels;++i) {
aiNodeAnim* na = anim->mChannels[i];
aiNode* nd = pScene->mRootNode->mChildren[i] = new aiNode();
diff --git a/code/AssetLib/CSM/CSMLoader.h b/code/AssetLib/CSM/CSMLoader.h
index e9c4cd5ee..2bad73717 100644
--- a/code/AssetLib/CSM/CSMLoader.h
+++ b/code/AssetLib/CSM/CSMLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -61,7 +61,7 @@ namespace Assimp {
class CSMImporter : public BaseImporter {
public:
CSMImporter();
- ~CSMImporter() override;
+ ~CSMImporter() override = default;
// -------------------------------------------------------------------
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
@@ -81,9 +81,8 @@ protected:
private:
bool noSkeletonMesh;
-}; // end of class CSMImporter
+};
-} // end of namespace Assimp
+} // namespace Assimp
#endif // AI_AC3DIMPORTER_H_INC
-
diff --git a/code/AssetLib/Collada/ColladaExporter.cpp b/code/AssetLib/Collada/ColladaExporter.cpp
index 29b714bd7..3fc3a6e15 100644
--- a/code/AssetLib/Collada/ColladaExporter.cpp
+++ b/code/AssetLib/Collada/ColladaExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Collada/ColladaExporter.h b/code/AssetLib/Collada/ColladaExporter.h
index e372a5c5c..05e076034 100644
--- a/code/AssetLib/Collada/ColladaExporter.h
+++ b/code/AssetLib/Collada/ColladaExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Collada/ColladaHelper.cpp b/code/AssetLib/Collada/ColladaHelper.cpp
index 0fb172fbb..b5de70624 100644
--- a/code/AssetLib/Collada/ColladaHelper.cpp
+++ b/code/AssetLib/Collada/ColladaHelper.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Collada/ColladaHelper.h b/code/AssetLib/Collada/ColladaHelper.h
index c5b6a2d13..6662d7354 100644
--- a/code/AssetLib/Collada/ColladaHelper.h
+++ b/code/AssetLib/Collada/ColladaHelper.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Collada/ColladaLoader.cpp b/code/AssetLib/Collada/ColladaLoader.cpp
index e1f19a5ed..17c4f4b28 100644
--- a/code/AssetLib/Collada/ColladaLoader.cpp
+++ b/code/AssetLib/Collada/ColladaLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -64,7 +64,7 @@ namespace Assimp {
using namespace Assimp::Formatter;
using namespace Assimp::Collada;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Collada Importer",
"",
"",
@@ -102,10 +102,6 @@ ColladaLoader::ColladaLoader() :
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-ColladaLoader::~ColladaLoader() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool ColladaLoader::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
// Look for a DAE file inside, but don't extract it
diff --git a/code/AssetLib/Collada/ColladaLoader.h b/code/AssetLib/Collada/ColladaLoader.h
index 74b5c06b7..0603d419c 100644
--- a/code/AssetLib/Collada/ColladaLoader.h
+++ b/code/AssetLib/Collada/ColladaLoader.h
@@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -86,7 +86,7 @@ public:
ColladaLoader();
/// The class destructor.
- ~ColladaLoader() override;
+ ~ColladaLoader() override = default;
/// Returns whether the class can handle the format of the given file.
/// @see BaseImporter::CanRead() for more details.
diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp
index fcadd08a7..c5163fe39 100644
--- a/code/AssetLib/Collada/ColladaParser.cpp
+++ b/code/AssetLib/Collada/ColladaParser.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -654,12 +654,13 @@ void ColladaParser::ReadController(XmlNode &node, Collada::Controller &controlle
std::string v;
XmlParser::getValueAsString(currentNode, v);
const char *content = v.c_str();
+ const char *end = content + v.size();
for (unsigned int a = 0; a < 16; a++) {
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
// read a number
content = fast_atoreal_move<ai_real>(content, controller.mBindShapeMatrix[a]);
// skip whitespace after it
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
}
} else if (currentName == "source") {
ReadSource(currentNode);
@@ -740,7 +741,9 @@ void ColladaParser::ReadControllerWeights(XmlNode &node, Collada::Controller &pC
throw DeadlyImportError("Unknown semantic \"", attrSemantic, "\" in <vertex_weights> data <input> element");
}
} else if (currentName == "vcount" && vertexCount > 0) {
- const char *text = currentNode.text().as_string();
+ const std::string stdText = currentNode.text().as_string();
+ const char *text = stdText.c_str();
+ const char *end = text + stdText.size();
size_t numWeights = 0;
for (std::vector<size_t>::iterator it = pController.mWeightCounts.begin(); it != pController.mWeightCounts.end(); ++it) {
if (*text == 0) {
@@ -749,7 +752,7 @@ void ColladaParser::ReadControllerWeights(XmlNode &node, Collada::Controller &pC
*it = strtoul10(text, &text);
numWeights += *it;
- SkipSpacesAndLineEnd(&text);
+ SkipSpacesAndLineEnd(&text, end);
}
// reserve weight count
pController.mWeights.resize(numWeights);
@@ -758,18 +761,19 @@ void ColladaParser::ReadControllerWeights(XmlNode &node, Collada::Controller &pC
std::string stdText;
XmlParser::getValueAsString(currentNode, stdText);
const char *text = stdText.c_str();
+ const char *end = text + stdText.size();
for (std::vector<std::pair<size_t, size_t>>::iterator it = pController.mWeights.begin(); it != pController.mWeights.end(); ++it) {
if (text == nullptr) {
throw DeadlyImportError("Out of data while reading <vertex_weights>");
}
- SkipSpacesAndLineEnd(&text);
+ SkipSpacesAndLineEnd(&text, end);
it->first = strtoul10(text, &text);
- SkipSpacesAndLineEnd(&text);
+ SkipSpacesAndLineEnd(&text, end);
if (*text == 0) {
throw DeadlyImportError("Out of data while reading <vertex_weights>");
}
it->second = strtoul10(text, &text);
- SkipSpacesAndLineEnd(&text);
+ SkipSpacesAndLineEnd(&text, end);
}
}
}
@@ -814,38 +818,38 @@ void ColladaParser::ReadImage(XmlNode &node, Collada::Image &pImage) {
if (!pImage.mFileName.length()) {
pImage.mFileName = "unknown_texture";
}
- }
- } else if (mFormat == FV_1_5_n) {
- std::string value;
- XmlNode refChild = currentNode.child("ref");
- XmlNode hexChild = currentNode.child("hex");
- if (refChild) {
- // element content is filename - hopefully
- if (XmlParser::getValueAsString(refChild, value)) {
- aiString filepath(value);
- UriDecodePath(filepath);
- pImage.mFileName = filepath.C_Str();
- }
- } else if (hexChild && !pImage.mFileName.length()) {
- // embedded image. get format
- pImage.mEmbeddedFormat = hexChild.attribute("format").as_string();
- if (pImage.mEmbeddedFormat.empty()) {
- ASSIMP_LOG_WARN("Collada: Unknown image file format");
- }
+ } else if (mFormat == FV_1_5_n) {
+ std::string value;
+ XmlNode refChild = currentNode.child("ref");
+ XmlNode hexChild = currentNode.child("hex");
+ if (refChild) {
+ // element content is filename - hopefully
+ if (XmlParser::getValueAsString(refChild, value)) {
+ aiString filepath(value);
+ UriDecodePath(filepath);
+ pImage.mFileName = filepath.C_Str();
+ }
+ } else if (hexChild && !pImage.mFileName.length()) {
+ // embedded image. get format
+ pImage.mEmbeddedFormat = hexChild.attribute("format").as_string();
+ if (pImage.mEmbeddedFormat.empty()) {
+ ASSIMP_LOG_WARN("Collada: Unknown image file format");
+ }
- XmlParser::getValueAsString(hexChild, value);
- const char *data = value.c_str();
- // hexadecimal-encoded binary octets. First of all, find the
- // required buffer size to reserve enough storage.
- const char *cur = data;
- while (!IsSpaceOrNewLine(*cur)) {
- ++cur;
- }
+ XmlParser::getValueAsString(hexChild, value);
+ const char *data = value.c_str();
+ // hexadecimal-encoded binary octets. First of all, find the
+ // required buffer size to reserve enough storage.
+ const char *cur = data;
+ while (!IsSpaceOrNewLine(*cur)) {
+ ++cur;
+ }
- const unsigned int size = (unsigned int)(cur - data) * 2;
- pImage.mImageData.resize(size);
- for (unsigned int i = 0; i < size; ++i) {
- pImage.mImageData[i] = HexOctetToDecimal(data + (i << 1));
+ const unsigned int size = (unsigned int)(cur - data) * 2;
+ pImage.mImageData.resize(size);
+ for (unsigned int i = 0; i < size; ++i) {
+ pImage.mImageData[i] = HexOctetToDecimal(data + (i << 1));
+ }
}
}
}
@@ -952,15 +956,16 @@ void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
std::string v;
XmlParser::getValueAsString(currentNode, v);
const char *content = v.c_str();
+ const char *end = content + v.size();
content = fast_atoreal_move<ai_real>(content, (ai_real &)pLight.mColor.r);
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
content = fast_atoreal_move<ai_real>(content, (ai_real &)pLight.mColor.g);
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
content = fast_atoreal_move<ai_real>(content, (ai_real &)pLight.mColor.b);
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
} else if (currentName == "constant_attenuation") {
XmlParser::getValueAsFloat(currentNode, pLight.mAttConstant);
} else if (currentName == "linear_attenuation") {
@@ -1220,18 +1225,19 @@ void ColladaParser::ReadEffectColor(XmlNode &node, aiColor4D &pColor, Sampler &p
std::string v;
XmlParser::getValueAsString(currentNode, v);
const char *content = v.c_str();
+ const char *end = v.c_str() + v.size() + 1;
content = fast_atoreal_move<ai_real>(content, (ai_real &)pColor.r);
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
content = fast_atoreal_move<ai_real>(content, (ai_real &)pColor.g);
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
content = fast_atoreal_move<ai_real>(content, (ai_real &)pColor.b);
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
content = fast_atoreal_move<ai_real>(content, (ai_real &)pColor.a);
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
} else if (currentName == "texture") {
// get name of source texture/sampler
XmlParser::getStdStrAttribute(currentNode, "texture", pSampler.mName);
@@ -1274,9 +1280,7 @@ void ColladaParser::ReadEffectParam(XmlNode &node, Collada::EffectParam &pParam)
return;
}
- XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
- XmlNode currentNode;
- while (xmlIt.getNext(currentNode)) {
+ for (XmlNode &currentNode : node.children()) {
const std::string &currentName = currentNode.name();
if (currentName == "surface") {
// image ID given inside <init_from> tags
@@ -1289,22 +1293,24 @@ void ColladaParser::ReadEffectParam(XmlNode &node, Collada::EffectParam &pParam)
}
} else if (currentName == "sampler2D" && (FV_1_4_n == mFormat || FV_1_3_n == mFormat)) {
// surface ID is given inside <source> tags
- const char *content = currentNode.value();
- pParam.mType = Param_Sampler;
- pParam.mReference = content;
+ XmlNode source = currentNode.child("source");
+ if (source) {
+ std::string v;
+ XmlParser::getValueAsString(source, v);
+ pParam.mType = Param_Sampler;
+ pParam.mReference = v.c_str();
+ }
} else if (currentName == "sampler2D") {
// surface ID is given inside <instance_image> tags
- std::string url;
- XmlParser::getStdStrAttribute(currentNode, "url", url);
- if (url[0] != '#') {
- throw DeadlyImportError("Unsupported URL format in instance_image");
- }
- pParam.mType = Param_Sampler;
- pParam.mReference = url.c_str() + 1;
- } else if (currentName == "source") {
- const char *source = currentNode.child_value();
- if (nullptr != source) {
- pParam.mReference = source;
+ XmlNode instance_image = currentNode.child("instance_image");
+ if (instance_image) {
+ std::string url;
+ XmlParser::getStdStrAttribute(instance_image, "url", url);
+ if (url[0] != '#') {
+ throw DeadlyImportError("Unsupported URL format in instance_image");
+ }
+ pParam.mType = Param_Sampler;
+ pParam.mReference = url.c_str() + 1;
}
}
}
@@ -1345,6 +1351,7 @@ void ColladaParser::ReadGeometry(XmlNode &node, Collada::Mesh &pMesh) {
if (node.empty()) {
return;
}
+
for (XmlNode &currentNode : node.children()) {
const std::string &currentName = currentNode.name();
if (currentName == "mesh") {
@@ -1415,6 +1422,7 @@ void ColladaParser::ReadDataArray(XmlNode &node) {
XmlParser::getValueAsString(node, v);
v = ai_trim(v);
const char *content = v.c_str();
+ const char *end = content + v.size();
// read values and store inside an array in the data library
mDataLibrary[id] = Data();
@@ -1433,11 +1441,13 @@ void ColladaParser::ReadDataArray(XmlNode &node) {
}
s.clear();
- while (!IsSpaceOrNewLine(*content))
- s += *content++;
+ while (!IsSpaceOrNewLine(*content)) {
+ s += *content;
+ content++;
+ }
data.mStrings.push_back(s);
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
}
} else {
data.mValues.reserve(count);
@@ -1452,7 +1462,7 @@ void ColladaParser::ReadDataArray(XmlNode &node) {
content = fast_atoreal_move<ai_real>(content, value);
data.mValues.push_back(value);
// skip whitespace after it
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
}
}
}
@@ -1617,8 +1627,10 @@ void ColladaParser::ReadIndexData(XmlNode &node, Mesh &pMesh) {
std::string v;
XmlParser::getValueAsString(currentNode, v);
const char *content = v.c_str();
+ const char *end = content + v.size();
+
vcount.reserve(numPrimitives);
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
for (unsigned int a = 0; a < numPrimitives; a++) {
if (*content == 0) {
throw DeadlyImportError("Expected more values while reading <vcount> contents.");
@@ -1626,7 +1638,7 @@ void ColladaParser::ReadIndexData(XmlNode &node, Mesh &pMesh) {
// read a number
vcount.push_back((size_t)strtoul10(content, &content));
// skip whitespace after it
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
}
}
}
@@ -1735,14 +1747,16 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector<Inp
std::string v;
XmlParser::getValueAsString(node, v);
const char *content = v.c_str();
- SkipSpacesAndLineEnd(&content);
+ const char *end = content + v.size();
+
+ SkipSpacesAndLineEnd(&content, end);
while (*content != 0) {
// read a value.
// Hack: (thom) Some exporters put negative indices sometimes. We just try to carry on anyways.
int value = std::max(0, strtol10(content, &content));
indices.push_back(size_t(value));
// skip whitespace after it
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
}
}
@@ -1772,6 +1786,10 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector<Inp
const Accessor *acc = input.mResolved;
if (!acc->mData) {
acc->mData = &ResolveLibraryReference(mDataLibrary, acc->mSource);
+ const size_t dataSize = acc->mOffset + acc->mCount * acc->mStride;
+ if (dataSize > acc->mData->mValues.size()) {
+ throw DeadlyImportError("Not enough data for accessor");
+ }
}
}
// and the same for the per-index channels
@@ -1796,13 +1814,19 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector<Inp
const Accessor *acc = input.mResolved;
if (!acc->mData) {
acc->mData = &ResolveLibraryReference(mDataLibrary, acc->mSource);
+ const size_t dataSize = acc->mOffset + acc->mCount * acc->mStride;
+ if (dataSize > acc->mData->mValues.size()) {
+ throw DeadlyImportError("Not enough data for accessor");
+ }
}
}
// For continued primitives, the given count does not come all in one <p>, but only one primitive per <p>
size_t numPrimitives = pNumPrimitives;
- if (pPrimType == Prim_TriFans || pPrimType == Prim_Polygon)
+ if (pPrimType == Prim_TriFans || pPrimType == Prim_Polygon) {
numPrimitives = 1;
+ }
+
// For continued primitives, the given count is actually the number of <p>'s inside the parent tag
if (pPrimType == Prim_TriStrips) {
size_t numberOfVertices = indices.size() / numOffsets;
@@ -1867,7 +1891,7 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector<Inp
///@note This function won't work correctly if both PerIndex and PerVertex channels have same channels.
///For example if TEXCOORD present in both <vertices> and <polylist> tags this function will create wrong uv coordinates.
-///It's not clear from COLLADA documentation is this allowed or not. For now only exporter fixed to avoid such behavior
+///It's not clear from COLLADA documentation whether this is allowed or not. For now only exporter fixed to avoid such behavior
void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset, Mesh &pMesh,
std::vector<InputChannel> &pPerIndexChannels, size_t currentPrimitive, const std::vector<size_t> &indices) {
// calculate the base offset of the vertex whose attributes we ant to copy
@@ -2166,15 +2190,15 @@ void ColladaParser::ReadNodeTransformation(XmlNode &node, Node *pNode, Transform
}
// how many parameters to read per transformation type
- static const unsigned int sNumParameters[] = { 9, 4, 3, 3, 7, 16 };
+ static constexpr unsigned int sNumParameters[] = { 9, 4, 3, 3, 7, 16 };
std::string value;
XmlParser::getValueAsString(node, value);
const char *content = value.c_str();
-
+ const char *end = value.c_str() + value.size();
// read as many parameters and store in the transformation
for (unsigned int a = 0; a < sNumParameters[pType]; a++) {
// skip whitespace before the number
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
// read a number
content = fast_atoreal_move<ai_real>(content, tf.f[a]);
}
diff --git a/code/AssetLib/Collada/ColladaParser.h b/code/AssetLib/Collada/ColladaParser.h
index 15982934f..d428ad674 100644
--- a/code/AssetLib/Collada/ColladaParser.h
+++ b/code/AssetLib/Collada/ColladaParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
- Copyright (c) 2006-2022, assimp team
+ Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/DXF/DXFHelper.h b/code/AssetLib/DXF/DXFHelper.h
index 4d7893cc4..0bbecdc9e 100644
--- a/code/AssetLib/DXF/DXFHelper.h
+++ b/code/AssetLib/DXF/DXFHelper.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp
index dae665388..0f3da2626 100644
--- a/code/AssetLib/DXF/DXFLoader.cpp
+++ b/code/AssetLib/DXF/DXFLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Implementation of the DXF importer class
*/
-
#ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
#include "AssetLib/DXF/DXFLoader.h"
@@ -68,25 +67,267 @@ static constexpr size_t AI_DXF_BINARY_IDENT_LEN = sizeof AI_DXF_BINARY_IDENT;
// default vertex color that all uncolored vertices will receive
static const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
-// color indices for DXF - 16 are supported, the table is
-// taken directly from the DXF spec.
-static aiColor4D g_aclrDxfIndexColors[] = {
- aiColor4D(0.6f, 0.6f, 0.6f, 1.0f),
- aiColor4D (1.0f, 0.0f, 0.0f, 1.0f), // red
- aiColor4D (0.0f, 1.0f, 0.0f, 1.0f), // green
- aiColor4D (0.0f, 0.0f, 1.0f, 1.0f), // blue
- aiColor4D (0.3f, 1.0f, 0.3f, 1.0f), // light green
- aiColor4D (0.3f, 0.3f, 1.0f, 1.0f), // light blue
- aiColor4D (1.0f, 0.3f, 0.3f, 1.0f), // light red
- aiColor4D (1.0f, 0.0f, 1.0f, 1.0f), // pink
- aiColor4D (1.0f, 0.6f, 0.0f, 1.0f), // orange
- aiColor4D (0.6f, 0.3f, 0.0f, 1.0f), // dark orange
- aiColor4D (1.0f, 1.0f, 0.0f, 1.0f), // yellow
- aiColor4D (0.3f, 0.3f, 0.3f, 1.0f), // dark gray
- aiColor4D (0.8f, 0.8f, 0.8f, 1.0f), // light gray
- aiColor4D (0.0f, 00.f, 0.0f, 1.0f), // black
- aiColor4D (1.0f, 1.0f, 1.0f, 1.0f), // white
- aiColor4D (0.6f, 0.0f, 1.0f, 1.0f) // violet
+// color indices for DXF - 256 are supported, the table is
+// taken directly from the AutoCad Index (ACI) table
+// https://gohtx.com/acadcolors.php
+//STH 2024-0126
+static const aiColor4D g_aclrDxfIndexColors[256] = {
+ aiColor4D (0.0f, 0.0f ,0.0f, 1.0f), //dxf color code 0
+ aiColor4D (1.0f, 0.0f ,0.0f, 1.0f), //dxf color code 1
+ aiColor4D (1.0f, 1.0f ,0.0f, 1.0f), //dxf color code 2
+ aiColor4D (0.0f, 1.0f ,0.0f, 1.0f), //dxf color code 3
+ aiColor4D (0.0f, 1.0f ,1.0f, 1.0f), //dxf color code 4
+ aiColor4D (0.0f, 0.0f ,1.0f, 1.0f), //dxf color code 5
+ aiColor4D (1.0f, 0.0f ,1.0f, 1.0f), //dxf color code 6
+ aiColor4D (1.0f, 1.0f ,1.0f, 1.0f), //dxf color code 7
+ aiColor4D (0.3f, 0.3f ,0.3f, 1.0f), //dxf color code 8
+ aiColor4D (0.5f, 0.5f ,0.5f, 1.0f), //dxf color code 9
+ aiColor4D (1.0f, 0.0f ,0.0f, 1.0f), //dxf color code 10
+ aiColor4D (1.0f, 0.7f ,0.7f, 1.0f), //dxf color code 11
+ aiColor4D (0.7f, 0.0f ,0.0f, 1.0f), //dxf color code 12
+ aiColor4D (0.7f, 0.5f ,0.5f, 1.0f), //dxf color code 13
+ aiColor4D (0.5f, 0.0f ,0.0f, 1.0f), //dxf color code 14
+ aiColor4D (0.5f, 0.3f ,0.3f, 1.0f), //dxf color code 15
+ aiColor4D (0.4f, 0.0f ,0.0f, 1.0f), //dxf color code 16
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 17
+ aiColor4D (0.3f, 0.0f ,0.0f, 1.0f), //dxf color code 18
+ aiColor4D (0.3f, 0.2f ,0.2f, 1.0f), //dxf color code 19
+ aiColor4D (1.0f, 0.2f ,0.0f, 1.0f), //dxf color code 20
+ aiColor4D (1.0f, 0.7f ,0.7f, 1.0f), //dxf color code 21
+ aiColor4D (0.7f, 0.2f ,0.0f, 1.0f), //dxf color code 22
+ aiColor4D (0.7f, 0.6f ,0.5f, 1.0f), //dxf color code 23
+ aiColor4D (0.5f, 0.1f ,0.0f, 1.0f), //dxf color code 24
+ aiColor4D (0.5f, 0.4f ,0.3f, 1.0f), //dxf color code 25
+ aiColor4D (0.4f, 0.1f ,0.0f, 1.0f), //dxf color code 26
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 27
+ aiColor4D (0.3f, 0.1f ,0.0f, 1.0f), //dxf color code 28
+ aiColor4D (0.3f, 0.2f ,0.2f, 1.0f), //dxf color code 29
+ aiColor4D (1.0f, 0.5f ,0.0f, 1.0f), //dxf color code 30
+ aiColor4D (1.0f, 0.8f ,0.7f, 1.0f), //dxf color code 31
+ aiColor4D (0.7f, 0.4f ,0.0f, 1.0f), //dxf color code 32
+ aiColor4D (0.7f, 0.6f ,0.5f, 1.0f), //dxf color code 33
+ aiColor4D (0.5f, 0.3f ,0.0f, 1.0f), //dxf color code 34
+ aiColor4D (0.5f, 0.4f ,0.3f, 1.0f), //dxf color code 35
+ aiColor4D (0.4f, 0.2f ,0.0f, 1.0f), //dxf color code 36
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 37
+ aiColor4D (0.3f, 0.2f ,0.0f, 1.0f), //dxf color code 38
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 39
+ aiColor4D (1.0f, 0.7f ,0.0f, 1.0f), //dxf color code 40
+ aiColor4D (1.0f, 0.9f ,0.7f, 1.0f), //dxf color code 41
+ aiColor4D (0.7f, 0.6f ,0.0f, 1.0f), //dxf color code 42
+ aiColor4D (0.7f, 0.7f ,0.5f, 1.0f), //dxf color code 43
+ aiColor4D (0.5f, 0.4f ,0.0f, 1.0f), //dxf color code 44
+ aiColor4D (0.5f, 0.5f ,0.3f, 1.0f), //dxf color code 45
+ aiColor4D (0.4f, 0.3f ,0.0f, 1.0f), //dxf color code 46
+ aiColor4D (0.4f, 0.4f ,0.3f, 1.0f), //dxf color code 47
+ aiColor4D (0.3f, 0.2f ,0.0f, 1.0f), //dxf color code 48
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 49
+ aiColor4D (1.0f, 1.0f ,0.0f, 1.0f), //dxf color code 50
+ aiColor4D (1.0f, 1.0f ,0.7f, 1.0f), //dxf color code 51
+ aiColor4D (0.7f, 0.7f ,0.0f, 1.0f), //dxf color code 52
+ aiColor4D (0.7f, 0.7f ,0.5f, 1.0f), //dxf color code 53
+ aiColor4D (0.5f, 0.5f ,0.0f, 1.0f), //dxf color code 54
+ aiColor4D (0.5f, 0.5f ,0.3f, 1.0f), //dxf color code 55
+ aiColor4D (0.4f, 0.4f ,0.0f, 1.0f), //dxf color code 56
+ aiColor4D (0.4f, 0.4f ,0.3f, 1.0f), //dxf color code 57
+ aiColor4D (0.3f, 0.3f ,0.0f, 1.0f), //dxf color code 58
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 59
+ aiColor4D (0.7f, 1.0f ,0.0f, 1.0f), //dxf color code 60
+ aiColor4D (0.9f, 1.0f ,0.7f, 1.0f), //dxf color code 61
+ aiColor4D (0.6f, 0.7f ,0.0f, 1.0f), //dxf color code 62
+ aiColor4D (0.7f, 0.7f ,0.5f, 1.0f), //dxf color code 63
+ aiColor4D (0.4f, 0.5f ,0.0f, 1.0f), //dxf color code 64
+ aiColor4D (0.5f, 0.5f ,0.3f, 1.0f), //dxf color code 65
+ aiColor4D (0.3f, 0.4f ,0.0f, 1.0f), //dxf color code 66
+ aiColor4D (0.4f, 0.4f ,0.3f, 1.0f), //dxf color code 67
+ aiColor4D (0.2f, 0.3f ,0.0f, 1.0f), //dxf color code 68
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 69
+ aiColor4D (0.5f, 1.0f ,0.0f, 1.0f), //dxf color code 70
+ aiColor4D (0.8f, 1.0f ,0.7f, 1.0f), //dxf color code 71
+ aiColor4D (0.4f, 0.7f ,0.0f, 1.0f), //dxf color code 72
+ aiColor4D (0.6f, 0.7f ,0.5f, 1.0f), //dxf color code 73
+ aiColor4D (0.3f, 0.5f ,0.0f, 1.0f), //dxf color code 74
+ aiColor4D (0.4f, 0.5f ,0.3f, 1.0f), //dxf color code 75
+ aiColor4D (0.2f, 0.4f ,0.0f, 1.0f), //dxf color code 76
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 77
+ aiColor4D (0.2f, 0.3f ,0.0f, 1.0f), //dxf color code 78
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 79
+ aiColor4D (0.2f, 1.0f ,0.0f, 1.0f), //dxf color code 80
+ aiColor4D (0.7f, 1.0f ,0.7f, 1.0f), //dxf color code 81
+ aiColor4D (0.2f, 0.7f ,0.0f, 1.0f), //dxf color code 82
+ aiColor4D (0.6f, 0.7f ,0.5f, 1.0f), //dxf color code 83
+ aiColor4D (0.1f, 0.5f ,0.0f, 1.0f), //dxf color code 84
+ aiColor4D (0.4f, 0.5f ,0.3f, 1.0f), //dxf color code 85
+ aiColor4D (0.1f, 0.4f ,0.0f, 1.0f), //dxf color code 86
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 87
+ aiColor4D (0.1f, 0.3f ,0.0f, 1.0f), //dxf color code 88
+ aiColor4D (0.2f, 0.3f ,0.2f, 1.0f), //dxf color code 89
+ aiColor4D (0.0f, 1.0f ,0.0f, 1.0f), //dxf color code 90
+ aiColor4D (0.7f, 1.0f ,0.7f, 1.0f), //dxf color code 91
+ aiColor4D (0.0f, 0.7f ,0.0f, 1.0f), //dxf color code 92
+ aiColor4D (0.5f, 0.7f ,0.5f, 1.0f), //dxf color code 93
+ aiColor4D (0.0f, 0.5f ,0.0f, 1.0f), //dxf color code 94
+ aiColor4D (0.3f, 0.5f ,0.3f, 1.0f), //dxf color code 95
+ aiColor4D (0.0f, 0.4f ,0.0f, 1.0f), //dxf color code 96
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 97
+ aiColor4D (0.0f, 0.3f ,0.0f, 1.0f), //dxf color code 98
+ aiColor4D (0.2f, 0.3f ,0.2f, 1.0f), //dxf color code 99
+ aiColor4D (0.0f, 1.0f ,0.2f, 1.0f), //dxf color code 100
+ aiColor4D (0.7f, 1.0f ,0.7f, 1.0f), //dxf color code 101
+ aiColor4D (0.0f, 0.7f ,0.2f, 1.0f), //dxf color code 102
+ aiColor4D (0.5f, 0.7f ,0.6f, 1.0f), //dxf color code 103
+ aiColor4D (0.0f, 0.5f ,0.1f, 1.0f), //dxf color code 104
+ aiColor4D (0.3f, 0.5f ,0.4f, 1.0f), //dxf color code 105
+ aiColor4D (0.0f, 0.4f ,0.1f, 1.0f), //dxf color code 106
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 107
+ aiColor4D (0.0f, 0.3f ,0.1f, 1.0f), //dxf color code 108
+ aiColor4D (0.2f, 0.3f ,0.2f, 1.0f), //dxf color code 109
+ aiColor4D (0.0f, 1.0f ,0.5f, 1.0f), //dxf color code 110
+ aiColor4D (0.7f, 1.0f ,0.8f, 1.0f), //dxf color code 111
+ aiColor4D (0.0f, 0.7f ,0.4f, 1.0f), //dxf color code 112
+ aiColor4D (0.5f, 0.7f ,0.6f, 1.0f), //dxf color code 113
+ aiColor4D (0.0f, 0.5f ,0.3f, 1.0f), //dxf color code 114
+ aiColor4D (0.3f, 0.5f ,0.4f, 1.0f), //dxf color code 115
+ aiColor4D (0.0f, 0.4f ,0.2f, 1.0f), //dxf color code 116
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 117
+ aiColor4D (0.0f, 0.3f ,0.2f, 1.0f), //dxf color code 118
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 119
+ aiColor4D (0.0f, 1.0f ,0.7f, 1.0f), //dxf color code 120
+ aiColor4D (0.7f, 1.0f ,0.9f, 1.0f), //dxf color code 121
+ aiColor4D (0.0f, 0.7f ,0.6f, 1.0f), //dxf color code 122
+ aiColor4D (0.5f, 0.7f ,0.7f, 1.0f), //dxf color code 123
+ aiColor4D (0.0f, 0.5f ,0.4f, 1.0f), //dxf color code 124
+ aiColor4D (0.3f, 0.5f ,0.5f, 1.0f), //dxf color code 125
+ aiColor4D (0.0f, 0.4f ,0.3f, 1.0f), //dxf color code 126
+ aiColor4D (0.3f, 0.4f ,0.4f, 1.0f), //dxf color code 127
+ aiColor4D (0.0f, 0.3f ,0.2f, 1.0f), //dxf color code 128
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 129
+ aiColor4D (0.0f, 1.0f ,1.0f, 1.0f), //dxf color code 130
+ aiColor4D (0.7f, 1.0f ,1.0f, 1.0f), //dxf color code 131
+ aiColor4D (0.0f, 0.7f ,0.7f, 1.0f), //dxf color code 132
+ aiColor4D (0.5f, 0.7f ,0.7f, 1.0f), //dxf color code 133
+ aiColor4D (0.0f, 0.5f ,0.5f, 1.0f), //dxf color code 134
+ aiColor4D (0.3f, 0.5f ,0.5f, 1.0f), //dxf color code 135
+ aiColor4D (0.0f, 0.4f ,0.4f, 1.0f), //dxf color code 136
+ aiColor4D (0.3f, 0.4f ,0.4f, 1.0f), //dxf color code 137
+ aiColor4D (0.0f, 0.3f ,0.3f, 1.0f), //dxf color code 138
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 139
+ aiColor4D (0.0f, 0.7f ,1.0f, 1.0f), //dxf color code 140
+ aiColor4D (0.7f, 0.9f ,1.0f, 1.0f), //dxf color code 141
+ aiColor4D (0.0f, 0.6f ,0.7f, 1.0f), //dxf color code 142
+ aiColor4D (0.5f, 0.7f ,0.7f, 1.0f), //dxf color code 143
+ aiColor4D (0.0f, 0.4f ,0.5f, 1.0f), //dxf color code 144
+ aiColor4D (0.3f, 0.5f ,0.5f, 1.0f), //dxf color code 145
+ aiColor4D (0.0f, 0.3f ,0.4f, 1.0f), //dxf color code 146
+ aiColor4D (0.3f, 0.4f ,0.4f, 1.0f), //dxf color code 147
+ aiColor4D (0.0f, 0.2f ,0.3f, 1.0f), //dxf color code 148
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 149
+ aiColor4D (0.0f, 0.5f ,1.0f, 1.0f), //dxf color code 150
+ aiColor4D (0.7f, 0.8f ,1.0f, 1.0f), //dxf color code 151
+ aiColor4D (0.0f, 0.4f ,0.7f, 1.0f), //dxf color code 152
+ aiColor4D (0.5f, 0.6f ,0.7f, 1.0f), //dxf color code 153
+ aiColor4D (0.0f, 0.3f ,0.5f, 1.0f), //dxf color code 154
+ aiColor4D (0.3f, 0.4f ,0.5f, 1.0f), //dxf color code 155
+ aiColor4D (0.0f, 0.2f ,0.4f, 1.0f), //dxf color code 156
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 157
+ aiColor4D (0.0f, 0.2f ,0.3f, 1.0f), //dxf color code 158
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 159
+ aiColor4D (0.0f, 0.2f ,1.0f, 1.0f), //dxf color code 160
+ aiColor4D (0.7f, 0.7f ,1.0f, 1.0f), //dxf color code 161
+ aiColor4D (0.0f, 0.2f ,0.7f, 1.0f), //dxf color code 162
+ aiColor4D (0.5f, 0.6f ,0.7f, 1.0f), //dxf color code 163
+ aiColor4D (0.0f, 0.1f ,0.5f, 1.0f), //dxf color code 164
+ aiColor4D (0.3f, 0.4f ,0.5f, 1.0f), //dxf color code 165
+ aiColor4D (0.0f, 0.1f ,0.4f, 1.0f), //dxf color code 166
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 167
+ aiColor4D (0.0f, 0.1f ,0.3f, 1.0f), //dxf color code 168
+ aiColor4D (0.2f, 0.2f ,0.3f, 1.0f), //dxf color code 169
+ aiColor4D (0.0f, 0.0f ,1.0f, 1.0f), //dxf color code 170
+ aiColor4D (0.7f, 0.7f ,1.0f, 1.0f), //dxf color code 171
+ aiColor4D (0.0f, 0.0f ,0.7f, 1.0f), //dxf color code 172
+ aiColor4D (0.5f, 0.5f ,0.7f, 1.0f), //dxf color code 173
+ aiColor4D (0.0f, 0.0f ,0.5f, 1.0f), //dxf color code 174
+ aiColor4D (0.3f, 0.3f ,0.5f, 1.0f), //dxf color code 175
+ aiColor4D (0.0f, 0.0f ,0.4f, 1.0f), //dxf color code 176
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 177
+ aiColor4D (0.0f, 0.0f ,0.3f, 1.0f), //dxf color code 178
+ aiColor4D (0.2f, 0.2f ,0.3f, 1.0f), //dxf color code 179
+ aiColor4D (0.2f, 0.0f ,1.0f, 1.0f), //dxf color code 180
+ aiColor4D (0.7f, 0.7f ,1.0f, 1.0f), //dxf color code 181
+ aiColor4D (0.2f, 0.0f ,0.7f, 1.0f), //dxf color code 182
+ aiColor4D (0.6f, 0.5f ,0.7f, 1.0f), //dxf color code 183
+ aiColor4D (0.1f, 0.0f ,0.5f, 1.0f), //dxf color code 184
+ aiColor4D (0.4f, 0.3f ,0.5f, 1.0f), //dxf color code 185
+ aiColor4D (0.1f, 0.0f ,0.4f, 1.0f), //dxf color code 186
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 187
+ aiColor4D (0.1f, 0.0f ,0.3f, 1.0f), //dxf color code 188
+ aiColor4D (0.2f, 0.2f ,0.3f, 1.0f), //dxf color code 189
+ aiColor4D (0.5f, 0.0f ,1.0f, 1.0f), //dxf color code 190
+ aiColor4D (0.8f, 0.7f ,1.0f, 1.0f), //dxf color code 191
+ aiColor4D (0.4f, 0.0f ,0.7f, 1.0f), //dxf color code 192
+ aiColor4D (0.6f, 0.5f ,0.7f, 1.0f), //dxf color code 193
+ aiColor4D (0.3f, 0.0f ,0.5f, 1.0f), //dxf color code 194
+ aiColor4D (0.4f, 0.3f ,0.5f, 1.0f), //dxf color code 195
+ aiColor4D (0.2f, 0.0f ,0.4f, 1.0f), //dxf color code 196
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 197
+ aiColor4D (0.2f, 0.0f ,0.3f, 1.0f), //dxf color code 198
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 199
+ aiColor4D (0.7f, 0.0f ,1.0f, 1.0f), //dxf color code 200
+ aiColor4D (0.9f, 0.7f ,1.0f, 1.0f), //dxf color code 201
+ aiColor4D (0.6f, 0.0f ,0.7f, 1.0f), //dxf color code 202
+ aiColor4D (0.7f, 0.5f ,0.7f, 1.0f), //dxf color code 203
+ aiColor4D (0.4f, 0.0f ,0.5f, 1.0f), //dxf color code 204
+ aiColor4D (0.5f, 0.3f ,0.5f, 1.0f), //dxf color code 205
+ aiColor4D (0.3f, 0.0f ,0.4f, 1.0f), //dxf color code 206
+ aiColor4D (0.4f, 0.3f ,0.4f, 1.0f), //dxf color code 207
+ aiColor4D (0.2f, 0.0f ,0.3f, 1.0f), //dxf color code 208
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 209
+ aiColor4D (1.0f, 0.0f ,1.0f, 1.0f), //dxf color code 210
+ aiColor4D (1.0f, 0.7f ,1.0f, 1.0f), //dxf color code 211
+ aiColor4D (0.7f, 0.0f ,0.7f, 1.0f), //dxf color code 212
+ aiColor4D (0.7f, 0.5f ,0.7f, 1.0f), //dxf color code 213
+ aiColor4D (0.5f, 0.0f ,0.5f, 1.0f), //dxf color code 214
+ aiColor4D (0.5f, 0.3f ,0.5f, 1.0f), //dxf color code 215
+ aiColor4D (0.4f, 0.0f ,0.4f, 1.0f), //dxf color code 216
+ aiColor4D (0.4f, 0.3f ,0.4f, 1.0f), //dxf color code 217
+ aiColor4D (0.3f, 0.0f ,0.3f, 1.0f), //dxf color code 218
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 219
+ aiColor4D (1.0f, 0.0f ,0.7f, 1.0f), //dxf color code 220
+ aiColor4D (1.0f, 0.7f ,0.9f, 1.0f), //dxf color code 221
+ aiColor4D (0.7f, 0.0f ,0.6f, 1.0f), //dxf color code 222
+ aiColor4D (0.7f, 0.5f ,0.7f, 1.0f), //dxf color code 223
+ aiColor4D (0.5f, 0.0f ,0.4f, 1.0f), //dxf color code 224
+ aiColor4D (0.5f, 0.3f ,0.5f, 1.0f), //dxf color code 225
+ aiColor4D (0.4f, 0.0f ,0.3f, 1.0f), //dxf color code 226
+ aiColor4D (0.4f, 0.3f ,0.4f, 1.0f), //dxf color code 227
+ aiColor4D (0.3f, 0.0f ,0.2f, 1.0f), //dxf color code 228
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 229
+ aiColor4D (1.0f, 0.0f ,0.5f, 1.0f), //dxf color code 230
+ aiColor4D (1.0f, 0.7f ,0.8f, 1.0f), //dxf color code 231
+ aiColor4D (0.7f, 0.0f ,0.4f, 1.0f), //dxf color code 232
+ aiColor4D (0.7f, 0.5f ,0.6f, 1.0f), //dxf color code 233
+ aiColor4D (0.5f, 0.0f ,0.3f, 1.0f), //dxf color code 234
+ aiColor4D (0.5f, 0.3f ,0.4f, 1.0f), //dxf color code 235
+ aiColor4D (0.4f, 0.0f ,0.2f, 1.0f), //dxf color code 236
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 237
+ aiColor4D (0.3f, 0.0f ,0.2f, 1.0f), //dxf color code 238
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 239
+ aiColor4D (1.0f, 0.0f ,0.2f, 1.0f), //dxf color code 240
+ aiColor4D (1.0f, 0.7f ,0.7f, 1.0f), //dxf color code 241
+ aiColor4D (0.7f, 0.0f ,0.2f, 1.0f), //dxf color code 242
+ aiColor4D (0.7f, 0.5f ,0.6f, 1.0f), //dxf color code 243
+ aiColor4D (0.5f, 0.0f ,0.1f, 1.0f), //dxf color code 244
+ aiColor4D (0.5f, 0.3f ,0.4f, 1.0f), //dxf color code 245
+ aiColor4D (0.4f, 0.0f ,0.1f, 1.0f), //dxf color code 246
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 247
+ aiColor4D (0.3f, 0.0f ,0.1f, 1.0f), //dxf color code 248
+ aiColor4D (0.3f, 0.2f ,0.2f, 1.0f), //dxf color code 249
+ aiColor4D (0.2f, 0.2f ,0.2f, 1.0f), //dxf color code 250
+ aiColor4D (0.3f, 0.3f ,0.3f, 1.0f), //dxf color code 251
+ aiColor4D (0.4f, 0.4f ,0.4f, 1.0f), //dxf color code 252
+ aiColor4D (0.5f, 0.5f ,0.5f, 1.0f), //dxf color code 253
+ aiColor4D (0.7f, 0.7f ,0.7f, 1.0f), //dxf color code 254
+ aiColor4D (1.0f, 1.0f ,1.0f, 1.0f) //dxf color code 255
};
#define AI_DXF_NUM_INDEX_COLORS (sizeof(g_aclrDxfIndexColors)/sizeof(g_aclrDxfIndexColors[0]))
@@ -97,7 +338,7 @@ static const int GroupCode_XComp = 10;
static const int GroupCode_YComp = 20;
static const int GroupCode_ZComp = 30;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Drawing Interchange Format (DXF) Importer",
"",
"",
@@ -372,8 +613,12 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
// XXX order
aiMatrix4x4 trafo, tmp;
aiMatrix4x4::Translation(-bl_src.base,trafo);
- trafo *= aiMatrix4x4::Scaling(insert.scale,tmp);
+ //Need to translate position before scaling the insert
+ //otherwise the position ends up being the position*scaling
+ //STH 2024.01.17
trafo *= aiMatrix4x4::Translation(insert.pos,tmp);
+ trafo *= aiMatrix4x4::Scaling(insert.scale,tmp);
+ //trafo *= aiMatrix4x4::Translation(insert.pos,tmp);
// XXX rotation currently ignored - I didn't find an appropriate sample model.
if (insert.angle != 0.f) {
diff --git a/code/AssetLib/DXF/DXFLoader.h b/code/AssetLib/DXF/DXFLoader.h
index 89a0b79c2..9230bccbd 100644
--- a/code/AssetLib/DXF/DXFLoader.h
+++ b/code/AssetLib/DXF/DXFLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXAnimation.cpp b/code/AssetLib/FBX/FBXAnimation.cpp
index af92ebe51..fdde37f24 100644
--- a/code/AssetLib/FBX/FBXAnimation.cpp
+++ b/code/AssetLib/FBX/FBXAnimation.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
index 8d79e2339..b828090e5 100644
--- a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
+++ b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXUtil.h"
#include <assimp/defs.h>
#include <stdint.h>
+#include <cstdint>
#include <assimp/Exceptional.h>
#include <assimp/ByteSwapper.h>
#include <assimp/DefaultLogger.hpp>
diff --git a/code/AssetLib/FBX/FBXCommon.h b/code/AssetLib/FBX/FBXCommon.h
index c3d715892..7e0fb2553 100644
--- a/code/AssetLib/FBX/FBXCommon.h
+++ b/code/AssetLib/FBX/FBXCommon.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXCompileConfig.h b/code/AssetLib/FBX/FBXCompileConfig.h
index 927a3c5f6..9885ca346 100644
--- a/code/AssetLib/FBX/FBXCompileConfig.h
+++ b/code/AssetLib/FBX/FBXCompileConfig.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp
index 498da43ca..cc73756fb 100644
--- a/code/AssetLib/FBX/FBXConverter.cpp
+++ b/code/AssetLib/FBX/FBXConverter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -55,9 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/MathFunctions.h>
#include <assimp/StringComparison.h>
-
#include <assimp/scene.h>
-
#include <assimp/CreateAnimMesh.h>
#include <assimp/StringUtils.h>
#include <assimp/commonMetaData.h>
@@ -78,6 +76,53 @@ using namespace Util;
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000LL
+static void correctRootTransform(const aiScene *scene) {
+ if (scene == nullptr) {
+ return;
+ }
+
+ if (scene->mMetaData == nullptr) {
+ return;
+ }
+
+ int32_t UpAxis = 1, UpAxisSign = 1, FrontAxis = 2, FrontAxisSign = 1, CoordAxis = 0, CoordAxisSign = 1;
+ double UnitScaleFactor = 1.0;
+ for (unsigned MetadataIndex = 0; MetadataIndex < scene->mMetaData->mNumProperties; ++MetadataIndex) {
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "UpAxis") == 0) {
+ scene->mMetaData->Get<int32_t>(MetadataIndex, UpAxis);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "UpAxisSign") == 0) {
+ scene->mMetaData->Get<int32_t>(MetadataIndex, UpAxisSign);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "FrontAxis") == 0) {
+ scene->mMetaData->Get<int32_t>(MetadataIndex, FrontAxis);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "FrontAxisSign") == 0) {
+ scene->mMetaData->Get<int32_t>(MetadataIndex, FrontAxisSign);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "CoordAxis") == 0) {
+ scene->mMetaData->Get<int32_t>(MetadataIndex, CoordAxis);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "CoordAxisSign") == 0) {
+ scene->mMetaData->Get<int32_t>(MetadataIndex, CoordAxisSign);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "UnitScaleFactor") == 0) {
+ scene->mMetaData->Get<double>(MetadataIndex, UnitScaleFactor);
+ }
+ }
+
+ aiVector3D upVec, forwardVec, rightVec;
+ upVec[UpAxis] = UpAxisSign * static_cast<float>(UnitScaleFactor);
+ forwardVec[FrontAxis] = FrontAxisSign * static_cast<float>(UnitScaleFactor);
+ rightVec[CoordAxis] = CoordAxisSign * (float)UnitScaleFactor;
+
+ aiMatrix4x4 mat(rightVec.x, rightVec.y, rightVec.z, 0.0f,
+ upVec.x, upVec.y, upVec.z, 0.0f,
+ forwardVec.x, forwardVec.y, forwardVec.z, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f);
+ scene->mRootNode->mTransformation *= mat;
+}
+
FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBones) :
defaultMaterialIndex(),
mMeshes(),
@@ -135,6 +180,8 @@ FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBo
// need not contain geometry (i.e. camera animations, raw armatures).
if (out->mNumMeshes == 0) {
out->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
+ } else {
+ correctRootTransform(mSceneOut);
}
}
@@ -577,16 +624,17 @@ void FBXConverter::GetRotationMatrix(Model::RotOrder mode, const aiVector3D &rot
bool is_id[3] = { true, true, true };
aiMatrix4x4 temp[3];
- if (std::fabs(rotation.z) > angle_epsilon) {
- aiMatrix4x4::RotationZ(AI_DEG_TO_RAD(rotation.z), temp[2]);
+ const auto rot = AI_DEG_TO_RAD(rotation);
+ if (std::fabs(rot.z) > angle_epsilon) {
+ aiMatrix4x4::RotationZ(rot.z, temp[2]);
is_id[2] = false;
}
- if (std::fabs(rotation.y) > angle_epsilon) {
- aiMatrix4x4::RotationY(AI_DEG_TO_RAD(rotation.y), temp[1]);
+ if (std::fabs(rot.y) > angle_epsilon) {
+ aiMatrix4x4::RotationY(rot.y, temp[1]);
is_id[1] = false;
}
- if (std::fabs(rotation.x) > angle_epsilon) {
- aiMatrix4x4::RotationX(AI_DEG_TO_RAD(rotation.x), temp[0]);
+ if (std::fabs(rot.x) > angle_epsilon) {
+ aiMatrix4x4::RotationX(rot.x, temp[0]);
is_id[0] = false;
}
@@ -1205,7 +1253,7 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
const auto &curNormals = shapeGeometry->GetNormals();
const auto &curIndices = shapeGeometry->GetIndices();
//losing channel name if using shapeGeometry->Name()
- // if blendShapeChannel Name is empty or don't have a ".", add geoMetryName;
+ // if blendShapeChannel Name is empty or doesn't have a ".", add geoMetryName;
auto aniName = FixAnimMeshName(blendShapeChannel->Name());
auto geoMetryName = FixAnimMeshName(shapeGeometry->Name());
if (aniName.empty()) {
@@ -1603,7 +1651,7 @@ void FBXConverter::ConvertWeights(aiMesh *out, const MeshGeometry &geo, const ai
void FBXConverter::ConvertCluster(std::vector<aiBone*> &local_mesh_bones, const Cluster *cluster,
std::vector<size_t> &out_indices, std::vector<size_t> &index_out_indices,
- std::vector<size_t> &count_out_indices, const aiMatrix4x4 & /* absolute_transform*/,
+ std::vector<size_t> &count_out_indices, const aiMatrix4x4 &absolute_transform,
aiNode *) {
ai_assert(cluster != nullptr); // make sure cluster valid
@@ -1620,16 +1668,16 @@ void FBXConverter::ConvertCluster(std::vector<aiBone*> &local_mesh_bones, const
bone = new aiBone();
bone->mName = bone_name;
- bone->mOffsetMatrix = cluster->Transform();
+ //bone->mOffsetMatrix = cluster->Transform();
// store local transform link for post processing
- /*
+
bone->mOffsetMatrix = cluster->TransformLink();
bone->mOffsetMatrix.Inverse();
- aiMatrix4x4 matrix = (aiMatrix4x4)absolute_transform;
+ const aiMatrix4x4 matrix = (aiMatrix4x4)absolute_transform;
bone->mOffsetMatrix = bone->mOffsetMatrix * matrix; // * mesh_offset
- */
+
//
// Now calculate the aiVertexWeights
//
@@ -3225,7 +3273,6 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
aiVector3D defTranslate = PropertyGet(props, "Lcl Translation", aiVector3D(0.f, 0.f, 0.f));
aiVector3D defRotation = PropertyGet(props, "Lcl Rotation", aiVector3D(0.f, 0.f, 0.f));
aiVector3D defScale = PropertyGet(props, "Lcl Scaling", aiVector3D(1.f, 1.f, 1.f));
- aiQuaternion defQuat = EulerToQuaternion(defRotation, rotOrder);
aiVectorKey* outTranslations = new aiVectorKey[keyCount];
aiQuatKey* outRotations = new aiQuatKey[keyCount];
@@ -3243,6 +3290,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
if (keyframeLists[TransformationComp_Rotation].size() > 0) {
InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder);
} else {
+ aiQuaternion defQuat = EulerToQuaternion(defRotation, rotOrder);
for (size_t i = 0; i < keyCount; ++i) {
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
outRotations[i].mValue = defQuat;
diff --git a/code/AssetLib/FBX/FBXConverter.h b/code/AssetLib/FBX/FBXConverter.h
index 41acb6ffe..73dc9e5a7 100644
--- a/code/AssetLib/FBX/FBXConverter.h
+++ b/code/AssetLib/FBX/FBXConverter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXDeformer.cpp b/code/AssetLib/FBX/FBXDeformer.cpp
index 1aab55ea9..582042360 100644
--- a/code/AssetLib/FBX/FBXDeformer.cpp
+++ b/code/AssetLib/FBX/FBXDeformer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -84,7 +84,7 @@ Cluster::Cluster(uint64_t id, const Element& element, const Document& doc, const
transform = ReadMatrix(Transform);
transformLink = ReadMatrix(TransformLink);
- // it is actually possible that there be Deformer's with no weights
+ // it is actually possible that there are Deformer's with no weights
if (!!Indexes != !!Weights) {
DOMError("either Indexes or Weights are missing from Cluster",&element);
}
diff --git a/code/AssetLib/FBX/FBXDocument.cpp b/code/AssetLib/FBX/FBXDocument.cpp
index 657f30f8c..3fb0964c4 100644
--- a/code/AssetLib/FBX/FBXDocument.cpp
+++ b/code/AssetLib/FBX/FBXDocument.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -390,7 +390,7 @@ void Document::ReadObjects() {
const auto foundObject = objects.find(id);
if(foundObject != objects.end()) {
DOMWarning("encountered duplicate object id, ignoring first occurrence",el.second);
- delete foundObject->second;
+ delete_LazyObject(foundObject->second);
}
objects[id] = new_LazyObject(id, *el.second, *this);
diff --git a/code/AssetLib/FBX/FBXDocument.h b/code/AssetLib/FBX/FBXDocument.h
index 3af757a19..a103321c0 100644
--- a/code/AssetLib/FBX/FBXDocument.h
+++ b/code/AssetLib/FBX/FBXDocument.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXDocumentUtil.cpp b/code/AssetLib/FBX/FBXDocumentUtil.cpp
index c41eb2747..64105f351 100644
--- a/code/AssetLib/FBX/FBXDocumentUtil.cpp
+++ b/code/AssetLib/FBX/FBXDocumentUtil.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExportNode.cpp b/code/AssetLib/FBX/FBXExportNode.cpp
index 21e591425..ae9586968 100644
--- a/code/AssetLib/FBX/FBXExportNode.cpp
+++ b/code/AssetLib/FBX/FBXExportNode.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExportNode.h b/code/AssetLib/FBX/FBXExportNode.h
index 99644b216..7661ab1be 100644
--- a/code/AssetLib/FBX/FBXExportNode.h
+++ b/code/AssetLib/FBX/FBXExportNode.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExportProperty.cpp b/code/AssetLib/FBX/FBXExportProperty.cpp
index 3216d7d85..5fbe84fa7 100644
--- a/code/AssetLib/FBX/FBXExportProperty.cpp
+++ b/code/AssetLib/FBX/FBXExportProperty.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExportProperty.h b/code/AssetLib/FBX/FBXExportProperty.h
index 26d0cf223..93f8cfbe0 100644
--- a/code/AssetLib/FBX/FBXExportProperty.h
+++ b/code/AssetLib/FBX/FBXExportProperty.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExporter.cpp b/code/AssetLib/FBX/FBXExporter.cpp
index 31bea76b5..ae210eb1a 100644
--- a/code/AssetLib/FBX/FBXExporter.cpp
+++ b/code/AssetLib/FBX/FBXExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -69,13 +69,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <unordered_set>
#include <utility>
#include <vector>
+#include <cmath>
// RESOURCES:
// https://code.blender.org/2013/08/fbx-binary-file-format-specification/
// https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure
-const ai_real DEG = ai_real( 57.29577951308232087679815481 ); // degrees per radian
-
using namespace Assimp;
using namespace Assimp::FBX;
@@ -1063,14 +1062,14 @@ aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene)
return transform;
}
-int64_t to_ktime(double ticks, const aiAnimation* anim) {
- if (anim->mTicksPerSecond <= 0) {
+inline int64_t to_ktime(double ticks, const aiAnimation* anim) {
+ if (FP_ZERO == std::fpclassify(anim->mTicksPerSecond)) {
return static_cast<int64_t>(ticks) * FBX::SECOND;
}
- return (static_cast<int64_t>(ticks) / static_cast<int64_t>(anim->mTicksPerSecond)) * FBX::SECOND;
+ return (static_cast<int64_t>(ticks / anim->mTicksPerSecond)) * FBX::SECOND;
}
-int64_t to_ktime(double time) {
+inline int64_t to_ktime(double time) {
return (static_cast<int64_t>(time * FBX::SECOND));
}
@@ -1090,6 +1089,8 @@ void FBXExporter::WriteObjects ()
bool bJoinIdenticalVertices = mProperties->GetPropertyBool("bJoinIdenticalVertices", true);
std::vector<std::vector<int32_t>> vVertexIndice;//save vertex_indices as it is needed later
+ const auto bTransparencyFactorReferencedToOpacity = mProperties->GetPropertyBool(AI_CONFIG_EXPORT_FBX_TRANSPARENCY_FACTOR_REFER_TO_OPACITY, false);
+
// geometry (aiMesh)
mesh_uids.clear();
indent = 1;
@@ -1391,7 +1392,7 @@ void FBXExporter::WriteObjects ()
aiMaterial* m = mScene->mMaterials[i];
// these are used to receive material data
- float f; aiColor3D c;
+ ai_real f; aiColor3D c;
// start the node record
FBX::Node n("Material");
@@ -1446,13 +1447,21 @@ void FBXExporter::WriteObjects ()
// "TransparentColor" / "TransparencyFactor"...
// thanks FBX, for your insightful interpretation of consistency
p.AddP70colorA("TransparentColor", c.r, c.g, c.b);
- // TransparencyFactor defaults to 0.0, so set it to 1.0.
- // note: Maya always sets this to 1.0,
- // so we can't use it sensibly as "Opacity".
- // In stead we rely on the legacy "Opacity" value, below.
- // Blender also relies on "Opacity" not "TransparencyFactor",
- // probably for a similar reason.
- p.AddP70numberA("TransparencyFactor", 1.0);
+
+ if (!bTransparencyFactorReferencedToOpacity) {
+ // TransparencyFactor defaults to 0.0, so set it to 1.0.
+ // note: Maya always sets this to 1.0,
+ // so we can't use it sensibly as "Opacity".
+ // In stead we rely on the legacy "Opacity" value, below.
+ // Blender also relies on "Opacity" not "TransparencyFactor",
+ // probably for a similar reason.
+ p.AddP70numberA("TransparencyFactor", 1.0);
+ }
+ }
+ if (bTransparencyFactorReferencedToOpacity) {
+ if (m->Get(AI_MATKEY_OPACITY, f) == aiReturn_SUCCESS) {
+ p.AddP70numberA("TransparencyFactor", 1.0 - f);
+ }
}
if (m->Get(AI_MATKEY_COLOR_REFLECTIVE, c) == aiReturn_SUCCESS) {
p.AddP70colorA("ReflectionColor", c.r, c.g, c.b);
@@ -1750,7 +1759,7 @@ void FBXExporter::WriteObjects ()
int64_t blendshape_uid = generate_uid();
mesh_uids.push_back(blendshape_uid);
bsnode.AddProperty(blendshape_uid);
- bsnode.AddProperty(blendshape_name + FBX::SEPARATOR + "Blendshape");
+ bsnode.AddProperty(blendshape_name + FBX::SEPARATOR + "Geometry");
bsnode.AddProperty("Shape");
bsnode.AddChild("Version", int32_t(100));
bsnode.Begin(outstream, binary, indent);
@@ -1809,7 +1818,7 @@ void FBXExporter::WriteObjects ()
p.AddP70numberA("DeformPercent", 0.0);
sdnode.AddChild(p);
// TODO: Normally just one weight per channel, adding stub for later development
- std::vector<float>fFullWeights;
+ std::vector<double>fFullWeights;
fFullWeights.push_back(100.);
sdnode.AddChild("FullWeights", fFullWeights);
sdnode.Dump(outstream, binary, indent);
@@ -2415,7 +2424,7 @@ void FBXExporter::WriteObjects ()
// position/translation
for (size_t ki = 0; ki < na->mNumPositionKeys; ++ki) {
const aiVectorKey& k = na->mPositionKeys[ki];
- times.push_back(to_ktime(k.mTime));
+ times.push_back(to_ktime(k.mTime, anim));
xval.push_back(k.mValue.x);
yval.push_back(k.mValue.y);
zval.push_back(k.mValue.z);
@@ -2429,12 +2438,12 @@ void FBXExporter::WriteObjects ()
times.clear(); xval.clear(); yval.clear(); zval.clear();
for (size_t ki = 0; ki < na->mNumRotationKeys; ++ki) {
const aiQuatKey& k = na->mRotationKeys[ki];
- times.push_back(to_ktime(k.mTime));
+ times.push_back(to_ktime(k.mTime, anim));
// TODO: aiQuaternion method to convert to Euler...
aiMatrix4x4 m(k.mValue.GetMatrix());
aiVector3D qs, qr, qt;
m.Decompose(qs, qr, qt);
- qr *= DEG;
+ qr = AI_RAD_TO_DEG(qr);
xval.push_back(qr.x);
yval.push_back(qr.y);
zval.push_back(qr.z);
@@ -2447,7 +2456,7 @@ void FBXExporter::WriteObjects ()
times.clear(); xval.clear(); yval.clear(); zval.clear();
for (size_t ki = 0; ki < na->mNumScalingKeys; ++ki) {
const aiVectorKey& k = na->mScalingKeys[ki];
- times.push_back(to_ktime(k.mTime));
+ times.push_back(to_ktime(k.mTime, anim));
xval.push_back(k.mValue.x);
yval.push_back(k.mValue.y);
zval.push_back(k.mValue.z);
@@ -2515,9 +2524,10 @@ void FBXExporter::WriteModelNode(
);
}
if (r != zero) {
+ r = AI_RAD_TO_DEG(r);
p.AddP70(
"Lcl Rotation", "Lcl Rotation", "", "A",
- double(DEG*r.x), double(DEG*r.y), double(DEG*r.z)
+ double(r.x), double(r.y), double(r.z)
);
}
if (s != one) {
@@ -2601,8 +2611,7 @@ void FBXExporter::WriteModelNodes(
transform_chain.emplace_back(elem->first, t);
break;
case 'r': // rotation
- r *= float(DEG);
- transform_chain.emplace_back(elem->first, r);
+ transform_chain.emplace_back(elem->first, AI_RAD_TO_DEG(r));
break;
case 's': // scale
transform_chain.emplace_back(elem->first, s);
diff --git a/code/AssetLib/FBX/FBXExporter.h b/code/AssetLib/FBX/FBXExporter.h
index 659f9368a..df9029196 100644
--- a/code/AssetLib/FBX/FBXExporter.h
+++ b/code/AssetLib/FBX/FBXExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXImportSettings.h b/code/AssetLib/FBX/FBXImportSettings.h
index 698901180..74290f7e0 100644
--- a/code/AssetLib/FBX/FBXImportSettings.h
+++ b/code/AssetLib/FBX/FBXImportSettings.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXImporter.cpp b/code/AssetLib/FBX/FBXImporter.cpp
index 56e0f38e9..3a8fb8b8a 100644
--- a/code/AssetLib/FBX/FBXImporter.cpp
+++ b/code/AssetLib/FBX/FBXImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -72,30 +72,25 @@ using namespace Assimp::Formatter;
using namespace Assimp::FBX;
namespace {
-
-static const aiImporterDesc desc = {
- "Autodesk FBX Importer",
- "",
- "",
- "",
- aiImporterFlags_SupportTextFlavour,
- 0,
- 0,
- 0,
- 0,
- "fbx"
-};
+ static constexpr aiImporterDesc desc = {
+ "Autodesk FBX Importer",
+ "",
+ "",
+ "",
+ aiImporterFlags_SupportTextFlavour,
+ 0,
+ 0,
+ 0,
+ 0,
+ "fbx"
+ };
}
// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by #Importer
-FBXImporter::FBXImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool FBXImporter::CanRead(const std::string & pFile, IOSystem * pIOHandler, bool /*checkSig*/) const {
// at least ASCII-FBX files usually have a 'FBX' somewhere in their head
- static const char *tokens[] = { "fbx" };
+ static const char *tokens[] = { " \n\r\n " };
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens));
}
diff --git a/code/AssetLib/FBX/FBXImporter.h b/code/AssetLib/FBX/FBXImporter.h
index 9acabaddd..8e8a7db78 100644
--- a/code/AssetLib/FBX/FBXImporter.h
+++ b/code/AssetLib/FBX/FBXImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -70,7 +70,7 @@ typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>
class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter> {
public:
/// @brief The class constructor.
- FBXImporter();
+ FBXImporter() = default;
/// @brief The class destructor, default implementation.
~FBXImporter() override = default;
diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp
index 2f575a511..3872a4b38 100644
--- a/code/AssetLib/FBX/FBXMaterial.cpp
+++ b/code/AssetLib/FBX/FBXMaterial.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -367,7 +367,9 @@ Video::Video(uint64_t id, const Element &element, const Document &doc, const std
}
Video::~Video() {
- delete[] content;
+ if (contentLength > 0) {
+ delete[] content;
+ }
}
} //!FBX
diff --git a/code/AssetLib/FBX/FBXMeshGeometry.cpp b/code/AssetLib/FBX/FBXMeshGeometry.cpp
index fcbaac169..3b706727a 100644
--- a/code/AssetLib/FBX/FBXMeshGeometry.cpp
+++ b/code/AssetLib/FBX/FBXMeshGeometry.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -467,9 +467,9 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
std::vector<int> uvIndices;
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
- if (uvIndices.size() != vertex_count) {
+ if (uvIndices.size() != mapping_offsets.size()) {
FBXImporter::LogError("length of input data unexpected for ByVertice mapping: ",
- uvIndices.size(), ", expected ", vertex_count);
+ uvIndices.size(), ", expected ", mapping_offsets.size());
return;
}
diff --git a/code/AssetLib/FBX/FBXMeshGeometry.h b/code/AssetLib/FBX/FBXMeshGeometry.h
index 3d67ec567..980d1a334 100644
--- a/code/AssetLib/FBX/FBXMeshGeometry.h
+++ b/code/AssetLib/FBX/FBXMeshGeometry.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXModel.cpp b/code/AssetLib/FBX/FBXModel.cpp
index d731d2e29..c108dd78b 100644
--- a/code/AssetLib/FBX/FBXModel.cpp
+++ b/code/AssetLib/FBX/FBXModel.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXNodeAttribute.cpp b/code/AssetLib/FBX/FBXNodeAttribute.cpp
index 34fcdcf77..1e7dfa8c0 100644
--- a/code/AssetLib/FBX/FBXNodeAttribute.cpp
+++ b/code/AssetLib/FBX/FBXNodeAttribute.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXParser.cpp b/code/AssetLib/FBX/FBXParser.cpp
index 955e811cb..d0482e067 100644
--- a/code/AssetLib/FBX/FBXParser.cpp
+++ b/code/AssetLib/FBX/FBXParser.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -45,12 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
-//#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
#include "Common/Compression.h"
-//# include <zlib.h>
-//#else
-//# include "../contrib/zlib/zlib.h"
-//#endif
#include "FBXTokenizer.h"
#include "FBXParser.h"
diff --git a/code/AssetLib/FBX/FBXParser.h b/code/AssetLib/FBX/FBXParser.h
index 5f231738d..63dbb023b 100644
--- a/code/AssetLib/FBX/FBXParser.h
+++ b/code/AssetLib/FBX/FBXParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXProperties.cpp b/code/AssetLib/FBX/FBXProperties.cpp
index 1c050617d..df39098fa 100644
--- a/code/AssetLib/FBX/FBXProperties.cpp
+++ b/code/AssetLib/FBX/FBXProperties.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXProperties.h b/code/AssetLib/FBX/FBXProperties.h
index 18816117a..4799b8056 100644
--- a/code/AssetLib/FBX/FBXProperties.h
+++ b/code/AssetLib/FBX/FBXProperties.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXTokenizer.cpp b/code/AssetLib/FBX/FBXTokenizer.cpp
index 45d5e7750..007e08d46 100644
--- a/code/AssetLib/FBX/FBXTokenizer.cpp
+++ b/code/AssetLib/FBX/FBXTokenizer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXTokenizer.h b/code/AssetLib/FBX/FBXTokenizer.h
index 05a0725bd..dedfab66a 100644
--- a/code/AssetLib/FBX/FBXTokenizer.h
+++ b/code/AssetLib/FBX/FBXTokenizer.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXUtil.cpp b/code/AssetLib/FBX/FBXUtil.cpp
index ac465d6e9..a787a9f1d 100644
--- a/code/AssetLib/FBX/FBXUtil.cpp
+++ b/code/AssetLib/FBX/FBXUtil.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -155,7 +155,7 @@ size_t DecodeBase64(const char* in, size_t inLength, uint8_t* out, size_t maxOut
const size_t realLength = inLength - size_t(in[inLength - 1] == '=') - size_t(in[inLength - 2] == '=');
size_t dst_offset = 0;
int val = 0, valb = -8;
- for (size_t src_offset = 0; src_offset < realLength; ++src_offset)
+ for (size_t src_offset = 0; src_offset < realLength && dst_offset < maxOutLength; ++src_offset)
{
const uint8_t table_value = Util::DecodeBase64(in[src_offset]);
if (table_value == 255)
diff --git a/code/AssetLib/FBX/FBXUtil.h b/code/AssetLib/FBX/FBXUtil.h
index 4674a5054..eb9ae14ed 100644
--- a/code/AssetLib/FBX/FBXUtil.h
+++ b/code/AssetLib/FBX/FBXUtil.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/HMP/HMPFileData.h b/code/AssetLib/HMP/HMPFileData.h
index b297136ba..5f6ca4f55 100644
--- a/code/AssetLib/HMP/HMPFileData.h
+++ b/code/AssetLib/HMP/HMPFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -49,7 +49,7 @@ namespace HMP {
#include <assimp/Compiler/pushpack1.h>
#include <stdint.h>
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
#define AI_HMP_MAGIC_NUMBER_BE_4 AI_MAKE_MAGIC("HMP4")
#define AI_HMP_MAGIC_NUMBER_LE_4 AI_MAKE_MAGIC("4PMH")
diff --git a/code/AssetLib/HMP/HMPLoader.cpp b/code/AssetLib/HMP/HMPLoader.cpp
index 431783a6a..30931a920 100644
--- a/code/AssetLib/HMP/HMPLoader.cpp
+++ b/code/AssetLib/HMP/HMPLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"3D GameStudio Heightmap (HMP) Importer",
"",
"",
diff --git a/code/AssetLib/HMP/HMPLoader.h b/code/AssetLib/HMP/HMPLoader.h
index 4d5f5f22f..e665b8d18 100644
--- a/code/AssetLib/HMP/HMPLoader.h
+++ b/code/AssetLib/HMP/HMPLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/HMP/HalfLifeFileData.h b/code/AssetLib/HMP/HalfLifeFileData.h
index f47862b7a..687b6108c 100644
--- a/code/AssetLib/HMP/HalfLifeFileData.h
+++ b/code/AssetLib/HMP/HalfLifeFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCBoolean.cpp b/code/AssetLib/IFC/IFCBoolean.cpp
index f4d53990e..559bd7b2f 100644
--- a/code/AssetLib/IFC/IFCBoolean.cpp
+++ b/code/AssetLib/IFC/IFCBoolean.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/IFC/IFCCurve.cpp b/code/AssetLib/IFC/IFCCurve.cpp
index 44165befc..847803dfa 100644
--- a/code/AssetLib/IFC/IFCCurve.cpp
+++ b/code/AssetLib/IFC/IFCCurve.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCGeometry.cpp b/code/AssetLib/IFC/IFCGeometry.cpp
index 83afd2b59..d488b2376 100644
--- a/code/AssetLib/IFC/IFCGeometry.cpp
+++ b/code/AssetLib/IFC/IFCGeometry.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/IFC/IFCLoader.cpp b/code/AssetLib/IFC/IFCLoader.cpp
index 89012902c..9414697df 100644
--- a/code/AssetLib/IFC/IFCLoader.cpp
+++ b/code/AssetLib/IFC/IFCLoader.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -103,7 +103,7 @@ void ConvertUnit(const ::Assimp::STEP::EXPRESS::DataType &dt, ConversionData &co
} // namespace
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Industry Foundation Classes (IFC) Importer",
"",
"",
@@ -185,7 +185,7 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
size_t total = 0;
int read = 0;
do {
- int bufferSize = fileInfo.uncompressed_size < INT16_MAX ? fileInfo.uncompressed_size : INT16_MAX;
+ unsigned bufferSize = fileInfo.uncompressed_size < INT16_MAX ? static_cast<unsigned>(fileInfo.uncompressed_size) : INT16_MAX;
void *buffer = malloc(bufferSize);
read = unzReadCurrentFile(zip, buffer, bufferSize);
if (read > 0) {
diff --git a/code/AssetLib/IFC/IFCLoader.h b/code/AssetLib/IFC/IFCLoader.h
index 9651b633a..d518650b7 100644
--- a/code/AssetLib/IFC/IFCLoader.h
+++ b/code/AssetLib/IFC/IFCLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCMaterial.cpp b/code/AssetLib/IFC/IFCMaterial.cpp
index 0b7b83e7c..fd4003a67 100644
--- a/code/AssetLib/IFC/IFCMaterial.cpp
+++ b/code/AssetLib/IFC/IFCMaterial.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCOpenings.cpp b/code/AssetLib/IFC/IFCOpenings.cpp
index 48b843aa1..1d37dd8ef 100644
--- a/code/AssetLib/IFC/IFCOpenings.cpp
+++ b/code/AssetLib/IFC/IFCOpenings.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -1372,7 +1372,7 @@ std::vector<IfcVector2> GetContourInPlane2D(const std::shared_ptr<TempMesh>& mes
const std::vector<IfcVector3>& va = mesh->mVerts;
if(va.size() <= 2) {
std::stringstream msg;
- msg << "Skipping: Only " << va.size() << " verticies in opening mesh.";
+ msg << "Skipping: Only " << va.size() << " vertices in opening mesh.";
IFCImporter::LogDebug(msg.str().c_str());
ok = false;
return contour;
diff --git a/code/AssetLib/IFC/IFCProfile.cpp b/code/AssetLib/IFC/IFCProfile.cpp
index 0e4670560..72a96c29b 100644
--- a/code/AssetLib/IFC/IFCProfile.cpp
+++ b/code/AssetLib/IFC/IFCProfile.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp b/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp
index 73e3c91d8..c625f1daf 100644
--- a/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp
+++ b/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp
@@ -2725,6 +2725,10 @@ template <> size_t GenericFill<IfcSpatialStructureElement>(const DB& db, const L
do { // convert the 'CompositionType' argument
std::shared_ptr<const DataType> arg = params[base++];
if (dynamic_cast<const ISDERIVED*>(&*arg)) { in->ObjectHelper<Assimp::IFC::Schema_2x3::IfcSpatialStructureElement,2>::aux_is_derived[1]=true; break; }
+ if (dynamic_cast<const UNSET *>(&*arg)) {
+ // Consider assigning the default value as in->CompositionType = "ELEMENT".
+ break;
+ }
try { GenericConvert( in->CompositionType, arg, db ); break; }
catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to IfcSpatialStructureElement to be a `IfcElementCompositionEnum`")); }
} while (false);
diff --git a/code/AssetLib/IFC/IFCUtil.cpp b/code/AssetLib/IFC/IFCUtil.cpp
index 27f3141c8..3977e22b5 100644
--- a/code/AssetLib/IFC/IFCUtil.cpp
+++ b/code/AssetLib/IFC/IFCUtil.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCUtil.h b/code/AssetLib/IFC/IFCUtil.h
index f9063ce22..885bcb48f 100644
--- a/code/AssetLib/IFC/IFCUtil.h
+++ b/code/AssetLib/IFC/IFCUtil.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IQM/IQMImporter.cpp b/code/AssetLib/IQM/IQMImporter.cpp
index 139b490d8..432c12113 100644
--- a/code/AssetLib/IQM/IQMImporter.cpp
+++ b/code/AssetLib/IQM/IQMImporter.cpp
@@ -59,7 +59,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// http://sauerbraten.org/iqm/
// https://github.com/lsalzman/iqm
-
inline void swap_block( uint32_t *block, size_t size ){
(void)block; // suppress 'unreferenced formal parameter' MSVC warning
size >>= 2;
@@ -67,7 +66,7 @@ inline void swap_block( uint32_t *block, size_t size ){
AI_SWAP4( block[ i ] );
}
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Inter-Quake Model Importer",
"",
"",
@@ -100,13 +99,6 @@ bool IQMImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
if (!pIOHandler) {
return true;
}
- /*
- * don't use CheckMagicToken because that checks with swapped bytes too, leading to false
- * positives. This magic is not uint32_t, but char[4], so memcmp is the best way
-
- const char* tokens[] = {"3DMO", "3dmo"};
- return CheckMagicToken(pIOHandler,pFile,tokens,2,0,4);
- */
std::unique_ptr<IOStream> pStream(pIOHandler->Open(pFile, "rb"));
unsigned char data[15];
if (!pStream || 15 != pStream->Read(data, 1, 15)) {
diff --git a/code/AssetLib/Irr/IRRLoader.cpp b/code/AssetLib/Irr/IRRLoader.cpp
index ba6ebc964..f41a2543d 100644
--- a/code/AssetLib/Irr/IRRLoader.cpp
+++ b/code/AssetLib/Irr/IRRLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -66,7 +66,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Irrlicht Scene Reader",
"",
"",
@@ -575,8 +575,8 @@ void SetupMapping(aiMaterial *mat, aiTextureMapping mode, const aiVector3D &axis
m->mSemantic = prop->mSemantic;
m->mType = aiPTI_Float;
- m->mDataLength = 12;
- m->mData = new char[12];
+ m->mDataLength = sizeof(aiVector3D);
+ m->mData = new char[m->mDataLength];
*((aiVector3D *)m->mData) = axis;
p.push_back(m);
}
@@ -1234,7 +1234,10 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// Parse the XML
// Find the scene root from document root.
const pugi::xml_node &sceneRoot = documentRoot.child("irr_scene");
- if (!sceneRoot) throw new DeadlyImportError("IRR: <irr_scene> not found in file");
+ if (!sceneRoot) {
+ delete root;
+ throw new DeadlyImportError("IRR: <irr_scene> not found in file");
+ }
for (pugi::xml_node &child : sceneRoot.children()) {
// XML elements are either nodes, animators, attributes, or materials
if (!ASSIMP_stricmp(child.name(), "node")) {
diff --git a/code/AssetLib/Irr/IRRLoader.h b/code/AssetLib/Irr/IRRLoader.h
index 72ad5d35e..2a8bfd562 100644
--- a/code/AssetLib/Irr/IRRLoader.h
+++ b/code/AssetLib/Irr/IRRLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Irr/IRRMeshLoader.cpp b/code/AssetLib/Irr/IRRMeshLoader.cpp
index 8161a2997..4a2f70882 100644
--- a/code/AssetLib/Irr/IRRMeshLoader.cpp
+++ b/code/AssetLib/Irr/IRRMeshLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Irrlicht Mesh Reader",
"",
"",
@@ -70,14 +70,6 @@ static const aiImporterDesc desc = {
};
// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-IRRMeshImporter::IRRMeshImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-IRRMeshImporter::~IRRMeshImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool IRRMeshImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
/* NOTE: A simple check for the file extension is not enough
@@ -116,8 +108,9 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile));
// Check whether we can read from the file
- if (file == nullptr)
+ if (file == nullptr) {
throw DeadlyImportError("Failed to open IRRMESH file ", pFile);
+ }
// Construct the irrXML parser
XmlParser parser;
@@ -148,13 +141,11 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
// int vertexFormat = 0; // 0 = normal; 1 = 2 tcoords, 2 = tangents
bool useColors = false;
- /*
- ** irrmesh files have a top level <mesh> owning multiple <buffer> nodes.
- ** Each <buffer> contains <material>, <vertices>, and <indices>
- ** <material> tags here directly owns the material data specs
- ** <vertices> are a vertex per line, contains position, UV1 coords, maybe UV2, normal, tangent, bitangent
- ** <boundingbox> is ignored, I think assimp recalculates those?
- */
+ // irrmesh files have a top level <mesh> owning multiple <buffer> nodes.
+ // Each <buffer> contains <material>, <vertices>, and <indices>
+ // <material> tags here directly owns the material data specs
+ // <vertices> are a vertex per line, contains position, UV1 coords, maybe UV2, normal, tangent, bitangent
+ // <boundingbox> is ignored, I think assimp recalculates those?
// Parse the XML file
pugi::xml_node const &meshNode = root.child("mesh");
@@ -201,7 +192,6 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
// This is possible ... remove the mesh from the list and skip further reading
ASSIMP_LOG_WARN("IRRMESH: Found mesh with zero vertices");
releaseMaterial(&curMat);
- // releaseMesh(&curMesh);
continue; // Bail out early
};
@@ -250,7 +240,9 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
};
// We know what format buffer is, collect numbers
- ParseBufferVertices(verticesNode.text().get(), vertexFormat,
+ std::string v = verticesNode.text().get();
+ const char *end = v.c_str() + v.size();
+ ParseBufferVertices(v.c_str(), end, vertexFormat,
curVertices, curNormals,
curTangents, curBitangents,
curUVs, curUV2s, curColors, useColors);
@@ -329,8 +321,10 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
// NOTE this might explode for UTF-16 and wchars
const char *sz = indicesNode.text().get();
+ const char *end = sz + std::strlen(sz);
+
// For each index loop over aiMesh faces
- while (SkipSpacesAndLineEnd(&sz)) {
+ while (SkipSpacesAndLineEnd(&sz, end)) {
if (curFace >= faceEnd) {
ASSIMP_LOG_ERROR("IRRMESH: Too many indices");
break;
@@ -354,12 +348,18 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
// Copy over data to aiMesh
*pcV++ = curVertices[idx];
- if (pcN) *pcN++ = curNormals[idx];
- if (pcT) *pcT++ = curTangents[idx];
- if (pcB) *pcB++ = curBitangents[idx];
- if (pcC0) *pcC0++ = curColors[idx];
- if (pcT0) *pcT0++ = curUVs[idx];
- if (pcT1) *pcT1++ = curUV2s[idx];
+ if (pcN)
+ *pcN++ = curNormals[idx];
+ if (pcT)
+ *pcT++ = curTangents[idx];
+ if (pcB)
+ *pcB++ = curBitangents[idx];
+ if (pcC0)
+ *pcC0++ = curColors[idx];
+ if (pcT0)
+ *pcT0++ = curUVs[idx];
+ if (pcT1)
+ *pcT1++ = curUV2s[idx];
// start new face
if (++curIdx == 3) {
@@ -368,8 +368,9 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
}
}
// We should be at the end of mFaces
- if (curFace != faceEnd)
+ if (curFace != faceEnd) {
ASSIMP_LOG_ERROR("IRRMESH: Not enough indices");
+ }
}
// Finish processing the mesh - do some small material workarounds
@@ -379,8 +380,7 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
aiMaterial *mat = (aiMaterial *)curMat;
mat->AddProperty(&curColors[0].a, 1, AI_MATKEY_OPACITY);
}
- // textMeaning = 2;
-
+
// end of previous buffer. A material and a mesh should be there
if (!curMat || !curMesh) {
ASSIMP_LOG_ERROR("IRRMESH: A buffer must contain a mesh and a material");
@@ -421,37 +421,37 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
};
}
-void IRRMeshImporter::ParseBufferVertices(const char *sz, VertexFormat vertexFormat,
+void IRRMeshImporter::ParseBufferVertices(const char *sz, const char *end, VertexFormat vertexFormat,
std::vector<aiVector3D> &vertices, std::vector<aiVector3D> &normals,
std::vector<aiVector3D> &tangents, std::vector<aiVector3D> &bitangents,
std::vector<aiVector3D> &UVs, std::vector<aiVector3D> &UV2s,
std::vector<aiColor4D> &colors, bool &useColors) {
// read vertices
do {
- SkipSpacesAndLineEnd(&sz);
+ SkipSpacesAndLineEnd(&sz, end);
aiVector3D temp;
aiColor4D c;
// Read the vertex position
sz = fast_atoreal_move<float>(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.z);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
vertices.push_back(temp);
// Read the vertex normals
sz = fast_atoreal_move<float>(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.z);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
normals.push_back(temp);
// read the vertex colors
@@ -463,14 +463,14 @@ void IRRMeshImporter::ParseBufferVertices(const char *sz, VertexFormat vertexFor
useColors = true;
colors.push_back(c);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
// read the first UV coordinate set
sz = fast_atoreal_move<float>(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
temp.z = 0.f;
temp.y = 1.f - temp.y; // DX to OGL
UVs.push_back(temp);
@@ -480,7 +480,7 @@ void IRRMeshImporter::ParseBufferVertices(const char *sz, VertexFormat vertexFor
// read the (optional) second UV coordinate set
if (vertexFormat == VertexFormat::t2coord) {
sz = fast_atoreal_move<float>(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.y);
temp.y = 1.f - temp.y; // DX to OGL
@@ -490,33 +490,32 @@ void IRRMeshImporter::ParseBufferVertices(const char *sz, VertexFormat vertexFor
else if (vertexFormat == VertexFormat::tangent) {
// tangents
sz = fast_atoreal_move<float>(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.z);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
temp.y *= -1.0f;
tangents.push_back(temp);
// bitangents
sz = fast_atoreal_move<float>(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.z);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move<float>(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
temp.y *= -1.0f;
bitangents.push_back(temp);
}
- } while (SkipLine(&sz));
- /* IMPORTANT: We assume that each vertex is specified in one
- line. So we can skip the rest of the line - unknown vertex
- elements are ignored.
- */
+ } while (SkipLine(&sz, end));
+ // IMPORTANT: We assume that each vertex is specified in one
+ // line. So we can skip the rest of the line - unknown vertex
+ // elements are ignored.
}
#endif // !! ASSIMP_BUILD_NO_IRRMESH_IMPORTER
diff --git a/code/AssetLib/Irr/IRRMeshLoader.h b/code/AssetLib/Irr/IRRMeshLoader.h
index 620e40dba..4ab3615ee 100644
--- a/code/AssetLib/Irr/IRRMeshLoader.h
+++ b/code/AssetLib/Irr/IRRMeshLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -62,8 +62,11 @@ namespace Assimp {
*/
class IRRMeshImporter : public BaseImporter, public IrrlichtBase {
public:
- IRRMeshImporter();
- ~IRRMeshImporter() override;
+ /// @brief The class constructor.
+ IRRMeshImporter() = default;
+
+ /// @brief The class destructor.
+ ~IRRMeshImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
@@ -93,7 +96,7 @@ private:
tangent = 2, // "tangents" - standard + tangents and bitangents
};
- void ParseBufferVertices(const char *sz, VertexFormat vertexFormat,
+ void ParseBufferVertices(const char *sz, const char *end, VertexFormat vertexFormat,
std::vector<aiVector3D> &vertices, std::vector<aiVector3D> &normals,
std::vector<aiVector3D> &tangents, std::vector<aiVector3D> &bitangents,
std::vector<aiVector3D> &UVs, std::vector<aiVector3D> &UV2s,
diff --git a/code/AssetLib/Irr/IRRShared.cpp b/code/AssetLib/Irr/IRRShared.cpp
index a47aeccba..20d56bb02 100644
--- a/code/AssetLib/Irr/IRRShared.cpp
+++ b/code/AssetLib/Irr/IRRShared.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -135,21 +135,23 @@ void IrrlichtBase::ReadVectorProperty(VectorProperty &out, pugi::xml_node& vecto
} else if (!ASSIMP_stricmp(attrib.name(), "value")) {
// three floats, separated with commas
const char *ptr = attrib.value();
+ size_t len = std::strlen(ptr);
+ const char *end = ptr + len;
- SkipSpaces(&ptr);
+ SkipSpaces(&ptr, end);
ptr = fast_atoreal_move<float>(ptr, (float &)out.value.x);
- SkipSpaces(&ptr);
+ SkipSpaces(&ptr, end);
if (',' != *ptr) {
ASSIMP_LOG_ERROR("IRR(MESH): Expected comma in vector definition");
} else {
- SkipSpaces(ptr + 1, &ptr);
+ SkipSpaces(ptr + 1, &ptr, end);
}
ptr = fast_atoreal_move<float>(ptr, (float &)out.value.y);
- SkipSpaces(&ptr);
+ SkipSpaces(&ptr, end);
if (',' != *ptr) {
ASSIMP_LOG_ERROR("IRR(MESH): Expected comma in vector definition");
} else {
- SkipSpaces(ptr + 1, &ptr);
+ SkipSpaces(ptr + 1, &ptr, end);
}
ptr = fast_atoreal_move<float>(ptr, (float &)out.value.z);
}
diff --git a/code/AssetLib/LWO/LWOAnimation.cpp b/code/AssetLib/LWO/LWOAnimation.cpp
index 8dda4586f..5b9c6882e 100644
--- a/code/AssetLib/LWO/LWOAnimation.cpp
+++ b/code/AssetLib/LWO/LWOAnimation.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOAnimation.h b/code/AssetLib/LWO/LWOAnimation.h
index 1e419d461..9daa7009c 100644
--- a/code/AssetLib/LWO/LWOAnimation.h
+++ b/code/AssetLib/LWO/LWOAnimation.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOBLoader.cpp b/code/AssetLib/LWO/LWOBLoader.cpp
index e49adcf98..b5c14f158 100644
--- a/code/AssetLib/LWO/LWOBLoader.cpp
+++ b/code/AssetLib/LWO/LWOBLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
@@ -51,64 +51,56 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "LWOLoader.h"
using namespace Assimp;
-
// ------------------------------------------------------------------------------------------------
-void LWOImporter::LoadLWOBFile()
-{
+void LWOImporter::LoadLWOBFile() {
LE_NCONST uint8_t* const end = mFileBuffer + fileSize;
bool running = true;
- while (running)
- {
- if (mFileBuffer + sizeof(IFF::ChunkHeader) > end)break;
+ while (running) {
+ if (mFileBuffer + sizeof(IFF::ChunkHeader) > end)
+ break;
const IFF::ChunkHeader head = IFF::LoadChunk(mFileBuffer);
- if (mFileBuffer + head.length > end)
- {
+ if (mFileBuffer + head.length > end) {
throw DeadlyImportError("LWOB: Invalid chunk length");
}
uint8_t* const next = mFileBuffer+head.length;
- switch (head.type)
- {
+ switch (head.type) {
// vertex list
- case AI_LWO_PNTS:
- {
+ case AI_LWO_PNTS: {
if (!mCurLayer->mTempPoints.empty())
ASSIMP_LOG_WARN("LWO: PNTS chunk encountered twice");
- else LoadLWOPoints(head.length);
- break;
- }
- // face list
- case AI_LWO_POLS:
- {
+ else
+ LoadLWOPoints(head.length);
+ } break;
+ case AI_LWO_POLS: { // face list
+ if (!mCurLayer->mFaces.empty())
+ ASSIMP_LOG_WARN("LWO: POLS chunk encountered twice");
+ else
+ LoadLWOBPolygons(head.length);
+ } break;
+
+ case AI_LWO_SRFS: // list of tags
+ {
+ if (!mTags->empty())
+ ASSIMP_LOG_WARN("LWO: SRFS chunk encountered twice");
+ else
+ LoadLWOTags(head.length);
+ } break;
- if (!mCurLayer->mFaces.empty())
- ASSIMP_LOG_WARN("LWO: POLS chunk encountered twice");
- else LoadLWOBPolygons(head.length);
- break;
- }
- // list of tags
- case AI_LWO_SRFS:
- {
- if (!mTags->empty())
- ASSIMP_LOG_WARN("LWO: SRFS chunk encountered twice");
- else LoadLWOTags(head.length);
- break;
- }
+ case AI_LWO_SURF: // surface chunk
+ {
+ LoadLWOBSurface(head.length);
+ } break;
- // surface chunk
- case AI_LWO_SURF:
- {
- LoadLWOBSurface(head.length);
+ default:
break;
- }
}
mFileBuffer = next;
}
}
// ------------------------------------------------------------------------------------------------
-void LWOImporter::LoadLWOBPolygons(unsigned int length)
-{
+void LWOImporter::LoadLWOBPolygons(unsigned int length) {
// first find out how many faces and vertices we'll finally need
LE_NCONST uint16_t* const end = (LE_NCONST uint16_t*)(mFileBuffer+length);
LE_NCONST uint16_t* cursor = (LE_NCONST uint16_t*)mFileBuffer;
@@ -123,8 +115,7 @@ void LWOImporter::LoadLWOBPolygons(unsigned int length)
CountVertsAndFacesLWOB(iNumVertices,iNumFaces,cursor,end);
// allocate the output array and copy face indices
- if (iNumFaces)
- {
+ if (iNumFaces) {
cursor = (LE_NCONST uint16_t*)mFileBuffer;
mCurLayer->mFaces.resize(iNumFaces);
@@ -135,10 +126,8 @@ void LWOImporter::LoadLWOBPolygons(unsigned int length)
// ------------------------------------------------------------------------------------------------
void LWOImporter::CountVertsAndFacesLWOB(unsigned int& verts, unsigned int& faces,
- LE_NCONST uint16_t*& cursor, const uint16_t* const end, unsigned int max)
-{
- while (cursor < end && max--)
- {
+ LE_NCONST uint16_t*& cursor, const uint16_t* const end, unsigned int max) {
+ while (cursor < end && max--) {
uint16_t numIndices;
// must have 2 shorts left for numIndices and surface
if (end - cursor < 2) {
@@ -154,8 +143,7 @@ void LWOImporter::CountVertsAndFacesLWOB(unsigned int& verts, unsigned int& face
cursor += numIndices;
int16_t surface;
::memcpy(&surface, cursor++, 2);
- if (surface < 0)
- {
+ if (surface < 0) {
// there are detail polygons
::memcpy(&numIndices, cursor++, 2);
CountVertsAndFacesLWOB(verts,faces,cursor,end,numIndices);
@@ -164,21 +152,17 @@ void LWOImporter::CountVertsAndFacesLWOB(unsigned int& verts, unsigned int& face
}
// ------------------------------------------------------------------------------------------------
-void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
+void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator &it,
LE_NCONST uint16_t*& cursor,
const uint16_t* const end,
- unsigned int max)
-{
- while (cursor < end && max--)
- {
+ unsigned int max) {
+ while (cursor < end && max--) {
LWO::Face& face = *it;++it;
uint16_t numIndices;
::memcpy(&numIndices, cursor++, 2);
face.mNumIndices = numIndices;
- if(face.mNumIndices)
- {
- if (cursor + face.mNumIndices >= end)
- {
+ if(face.mNumIndices) {
+ if (cursor + face.mNumIndices >= end) {
break;
}
face.mIndices = new unsigned int[face.mNumIndices];
@@ -187,8 +171,7 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
uint16_t index;
::memcpy(&index, cursor++, 2);
mi = index;
- if (mi > mCurLayer->mTempPoints.size())
- {
+ if (mi > mCurLayer->mTempPoints.size()) {
ASSIMP_LOG_WARN("LWOB: face index is out of range");
mi = (unsigned int)mCurLayer->mTempPoints.size()-1;
}
@@ -198,15 +181,13 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
}
int16_t surface;
::memcpy(&surface, cursor++, 2);
- if (surface < 0)
- {
+ if (surface < 0) {
surface = -surface;
// there are detail polygons.
uint16_t numPolygons;
::memcpy(&numPolygons, cursor++, 2);
- if (cursor < end)
- {
+ if (cursor < end) {
CopyFaceIndicesLWOB(it,cursor,end,numPolygons);
}
}
@@ -215,8 +196,7 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
}
// ------------------------------------------------------------------------------------------------
-LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned int size)
-{
+LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned int size) {
list.emplace_back();
LWO::Texture* tex = &list.back();
@@ -224,8 +204,7 @@ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned i
GetS0(type,size);
const char* s = type.c_str();
- if(strstr(s, "Image Map"))
- {
+ if(strstr(s, "Image Map")) {
// Determine mapping type
if(strstr(s, "Planar"))
tex->mapMode = LWO::Texture::Planar;
@@ -237,9 +216,7 @@ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned i
tex->mapMode = LWO::Texture::Cubic;
else if(strstr(s, "Front"))
tex->mapMode = LWO::Texture::FrontProjection;
- }
- else
- {
+ } else {
// procedural or gradient, not supported
ASSIMP_LOG_ERROR("LWOB: Unsupported legacy texture: ", type);
}
@@ -248,8 +225,7 @@ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned i
}
// ------------------------------------------------------------------------------------------------
-void LWOImporter::LoadLWOBSurface(unsigned int size)
-{
+void LWOImporter::LoadLWOBSurface(unsigned int size) {
LE_NCONST uint8_t* const end = mFileBuffer + size;
mSurfaces->push_back( LWO::Surface () );
@@ -277,148 +253,147 @@ void LWOImporter::LoadLWOBSurface(unsigned int size)
}
uint8_t* const next = mFileBuffer+head.length;
- switch (head.type)
- {
- // diffuse color
- case AI_LWO_COLR:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,COLR,3);
- surf.mColor.r = GetU1() / 255.0f;
- surf.mColor.g = GetU1() / 255.0f;
- surf.mColor.b = GetU1() / 255.0f;
- break;
- }
- // diffuse strength ...
- case AI_LWO_DIFF:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,DIFF,2);
- surf.mDiffuseValue = GetU2() / 255.0f;
- break;
- }
- // specular strength ...
- case AI_LWO_SPEC:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SPEC,2);
- surf.mSpecularValue = GetU2() / 255.0f;
- break;
- }
- // luminosity ...
- case AI_LWO_LUMI:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,LUMI,2);
- surf.mLuminosity = GetU2() / 255.0f;
- break;
- }
- // transparency
- case AI_LWO_TRAN:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TRAN,2);
- surf.mTransparency = GetU2() / 255.0f;
- break;
- }
- // surface flags
- case AI_LWO_FLAG:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,FLAG,2);
- uint16_t flag = GetU2();
- if (flag & 0x4 ) surf.mMaximumSmoothAngle = 1.56207f;
- if (flag & 0x8 ) surf.mColorHighlights = 1.f;
- if (flag & 0x100) surf.bDoubleSided = true;
- break;
- }
- // maximum smoothing angle
- case AI_LWO_SMAN:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SMAN,4);
- surf.mMaximumSmoothAngle = std::fabs( GetF4() );
- break;
- }
- // glossiness
- case AI_LWO_GLOS:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,GLOS,2);
- surf.mGlossiness = (float)GetU2();
- break;
- }
- // color texture
- case AI_LWO_CTEX:
- {
- pTex = SetupNewTextureLWOB(surf.mColorTextures,
- head.length);
- break;
- }
- // diffuse texture
- case AI_LWO_DTEX:
- {
- pTex = SetupNewTextureLWOB(surf.mDiffuseTextures,
- head.length);
- break;
- }
- // specular texture
- case AI_LWO_STEX:
- {
- pTex = SetupNewTextureLWOB(surf.mSpecularTextures,
- head.length);
- break;
- }
- // bump texture
- case AI_LWO_BTEX:
- {
- pTex = SetupNewTextureLWOB(surf.mBumpTextures,
- head.length);
- break;
- }
- // transparency texture
- case AI_LWO_TTEX:
- {
- pTex = SetupNewTextureLWOB(surf.mOpacityTextures,
- head.length);
- break;
- }
- // texture path
- case AI_LWO_TIMG:
- {
- if (pTex) {
- GetS0(pTex->mFileName,head.length);
- } else {
- ASSIMP_LOG_WARN("LWOB: Unexpected TIMG chunk");
+ switch (head.type) {
+ // diffuse color
+ case AI_LWO_COLR:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,COLR,3);
+ surf.mColor.r = GetU1() / 255.0f;
+ surf.mColor.g = GetU1() / 255.0f;
+ surf.mColor.b = GetU1() / 255.0f;
+ break;
}
- break;
- }
- // texture strength
- case AI_LWO_TVAL:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TVAL,1);
- if (pTex) {
- pTex->mStrength = (float)GetU1()/ 255.f;
- } else {
- ASSIMP_LOG_ERROR("LWOB: Unexpected TVAL chunk");
+ // diffuse strength ...
+ case AI_LWO_DIFF:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,DIFF,2);
+ surf.mDiffuseValue = GetU2() / 255.0f;
+ break;
}
- break;
- }
- // texture flags
- case AI_LWO_TFLG:
- {
- AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TFLG,2);
-
- if (nullptr != pTex) {
- const uint16_t s = GetU2();
- if (s & 1)
- pTex->majorAxis = LWO::Texture::AXIS_X;
- else if (s & 2)
- pTex->majorAxis = LWO::Texture::AXIS_Y;
- else if (s & 4)
- pTex->majorAxis = LWO::Texture::AXIS_Z;
-
- if (s & 16) {
- ASSIMP_LOG_WARN("LWOB: Ignoring \'negate\' flag on texture");
+ // specular strength ...
+ case AI_LWO_SPEC:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SPEC,2);
+ surf.mSpecularValue = GetU2() / 255.0f;
+ break;
+ }
+ // luminosity ...
+ case AI_LWO_LUMI:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,LUMI,2);
+ surf.mLuminosity = GetU2() / 255.0f;
+ break;
+ }
+ // transparency
+ case AI_LWO_TRAN:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TRAN,2);
+ surf.mTransparency = GetU2() / 255.0f;
+ break;
+ }
+ // surface flags
+ case AI_LWO_FLAG:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,FLAG,2);
+ uint16_t flag = GetU2();
+ if (flag & 0x4 ) surf.mMaximumSmoothAngle = 1.56207f;
+ if (flag & 0x8 ) surf.mColorHighlights = 1.f;
+ if (flag & 0x100) surf.bDoubleSided = true;
+ break;
+ }
+ // maximum smoothing angle
+ case AI_LWO_SMAN:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SMAN,4);
+ surf.mMaximumSmoothAngle = std::fabs( GetF4() );
+ break;
+ }
+ // glossiness
+ case AI_LWO_GLOS:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,GLOS,2);
+ surf.mGlossiness = (float)GetU2();
+ break;
+ }
+ // color texture
+ case AI_LWO_CTEX:
+ {
+ pTex = SetupNewTextureLWOB(surf.mColorTextures,
+ head.length);
+ break;
+ }
+ // diffuse texture
+ case AI_LWO_DTEX:
+ {
+ pTex = SetupNewTextureLWOB(surf.mDiffuseTextures,
+ head.length);
+ break;
+ }
+ // specular texture
+ case AI_LWO_STEX:
+ {
+ pTex = SetupNewTextureLWOB(surf.mSpecularTextures,
+ head.length);
+ break;
+ }
+ // bump texture
+ case AI_LWO_BTEX:
+ {
+ pTex = SetupNewTextureLWOB(surf.mBumpTextures,
+ head.length);
+ break;
+ }
+ // transparency texture
+ case AI_LWO_TTEX:
+ {
+ pTex = SetupNewTextureLWOB(surf.mOpacityTextures,
+ head.length);
+ break;
+ }
+ // texture path
+ case AI_LWO_TIMG:
+ {
+ if (pTex) {
+ GetS0(pTex->mFileName,head.length);
+ } else {
+ ASSIMP_LOG_WARN("LWOB: Unexpected TIMG chunk");
}
+ break;
}
- else {
- ASSIMP_LOG_WARN("LWOB: Unexpected TFLG chunk");
+ // texture strength
+ case AI_LWO_TVAL:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TVAL,1);
+ if (pTex) {
+ pTex->mStrength = (float)GetU1()/ 255.f;
+ } else {
+ ASSIMP_LOG_ERROR("LWOB: Unexpected TVAL chunk");
+ }
+ break;
+ }
+ // texture flags
+ case AI_LWO_TFLG:
+ {
+ AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TFLG,2);
+
+ if (nullptr != pTex) {
+ const uint16_t s = GetU2();
+ if (s & 1)
+ pTex->majorAxis = LWO::Texture::AXIS_X;
+ else if (s & 2)
+ pTex->majorAxis = LWO::Texture::AXIS_Y;
+ else if (s & 4)
+ pTex->majorAxis = LWO::Texture::AXIS_Z;
+
+ if (s & 16) {
+ ASSIMP_LOG_WARN("LWOB: Ignoring \'negate\' flag on texture");
+ }
+ }
+ else {
+ ASSIMP_LOG_WARN("LWOB: Unexpected TFLG chunk");
+ }
+ break;
}
- break;
- }
}
mFileBuffer = next;
}
diff --git a/code/AssetLib/LWO/LWOFileData.h b/code/AssetLib/LWO/LWOFileData.h
index 656dd4529..c81111251 100644
--- a/code/AssetLib/LWO/LWOFileData.h
+++ b/code/AssetLib/LWO/LWOFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp
index 7e93b65f8..025ca7408 100644
--- a/code/AssetLib/LWO/LWOLoader.cpp
+++ b/code/AssetLib/LWO/LWOLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOLoader.h b/code/AssetLib/LWO/LWOLoader.h
index 9e116a3cc..3f81ff449 100644
--- a/code/AssetLib/LWO/LWOLoader.h
+++ b/code/AssetLib/LWO/LWOLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOMaterial.cpp b/code/AssetLib/LWO/LWOMaterial.cpp
index 8d83dfb67..1d7d137e1 100644
--- a/code/AssetLib/LWO/LWOMaterial.cpp
+++ b/code/AssetLib/LWO/LWOMaterial.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp
index c41ff9cac..4c3a44785 100644
--- a/code/AssetLib/LWS/LWSLoader.cpp
+++ b/code/AssetLib/LWS/LWSLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"LightWave Scene Importer",
"",
"",
@@ -78,14 +78,14 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Recursive parsing of LWS files
-void LWS::Element::Parse(const char *&buffer) {
- for (; SkipSpacesAndLineEnd(&buffer); SkipLine(&buffer)) {
+void LWS::Element::Parse(const char *&buffer, const char *end) {
+ for (; SkipSpacesAndLineEnd(&buffer, end); SkipLine(&buffer, end)) {
// begin of a new element with children
bool sub = false;
if (*buffer == '{') {
++buffer;
- SkipSpaces(&buffer);
+ SkipSpaces(&buffer, end);
sub = true;
} else if (*buffer == '}')
return;
@@ -98,16 +98,15 @@ void LWS::Element::Parse(const char *&buffer) {
while (!IsSpaceOrNewLine(*buffer))
++buffer;
children.back().tokens[0] = std::string(cur, (size_t)(buffer - cur));
- SkipSpaces(&buffer);
+ SkipSpaces(&buffer, end);
if (children.back().tokens[0] == "Plugin") {
ASSIMP_LOG_VERBOSE_DEBUG("LWS: Skipping over plugin-specific data");
// strange stuff inside Plugin/Endplugin blocks. Needn't
// follow LWS syntax, so we skip over it
- for (; SkipSpacesAndLineEnd(&buffer); SkipLine(&buffer)) {
+ for (; SkipSpacesAndLineEnd(&buffer, end); SkipLine(&buffer, end)) {
if (!::strncmp(buffer, "EndPlugin", 9)) {
- //SkipLine(&buffer);
break;
}
}
@@ -122,7 +121,7 @@ void LWS::Element::Parse(const char *&buffer) {
// parse more elements recursively
if (sub) {
- children.back().Parse(buffer);
+ children.back().Parse(buffer, end);
}
}
}
@@ -140,10 +139,6 @@ LWSImporter::LWSImporter() :
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-LWSImporter::~LWSImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool LWSImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const uint32_t tokens[] = {
@@ -159,6 +154,8 @@ const aiImporterDesc *LWSImporter::GetInfo() const {
return &desc;
}
+static constexpr int MagicHackNo = 150392;
+
// ------------------------------------------------------------------------------------------------
// Setup configuration properties
void LWSImporter::SetupProperties(const Importer *pImp) {
@@ -167,11 +164,11 @@ void LWSImporter::SetupProperties(const Importer *pImp) {
// AI_CONFIG_IMPORT_LWS_ANIM_START
first = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_LWS_ANIM_START,
- 150392 /* magic hack */);
+ MagicHackNo /* magic hack */);
// AI_CONFIG_IMPORT_LWS_ANIM_END
last = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_LWS_ANIM_END,
- 150392 /* magic hack */);
+ MagicHackNo /* magic hack */);
if (last < first) {
std::swap(last, first);
@@ -195,15 +192,16 @@ void LWSImporter::ReadEnvelope(const LWS::Element &dad, LWO::Envelope &fill) {
for (++it; it != dad.children.end(); ++it) {
const char *c = (*it).tokens[1].c_str();
+ const char *end = c + (*it).tokens[1].size();
if ((*it).tokens[0] == "Key") {
fill.keys.emplace_back();
LWO::Key &key = fill.keys.back();
float f;
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move<float>(c, key.value);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move<float>(c, f);
key.time = f;
@@ -235,13 +233,13 @@ void LWSImporter::ReadEnvelope(const LWS::Element &dad, LWO::Envelope &fill) {
ASSIMP_LOG_ERROR("LWS: Unknown span type");
}
for (unsigned int i = 0; i < num; ++i) {
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move<float>(c, key.params[i]);
}
} else if ((*it).tokens[0] == "Behaviors") {
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
fill.pre = (LWO::PrePostBehaviour)strtoul10(c, &c);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
fill.post = (LWO::PrePostBehaviour)strtoul10(c, &c);
}
}
@@ -249,47 +247,45 @@ void LWSImporter::ReadEnvelope(const LWS::Element &dad, LWO::Envelope &fill) {
// ------------------------------------------------------------------------------------------------
// Read animation channels in the old LightWave animation format
-void LWSImporter::ReadEnvelope_Old(
- std::list<LWS::Element>::const_iterator &it,
- const std::list<LWS::Element>::const_iterator &end,
- LWS::NodeDesc &nodes,
- unsigned int /*version*/) {
- unsigned int num, sub_num;
- if (++it == end) goto unexpected_end;
-
- num = strtoul10((*it).tokens[0].c_str());
- for (unsigned int i = 0; i < num; ++i) {
+void LWSImporter::ReadEnvelope_Old(std::list<LWS::Element>::const_iterator &it,const std::list<LWS::Element>::const_iterator &endIt,
+ LWS::NodeDesc &nodes, unsigned int) {
+ if (++it == endIt) {
+ ASSIMP_LOG_ERROR("LWS: Encountered unexpected end of file while parsing object motion");
+ return;
+ }
+ const unsigned int num = strtoul10((*it).tokens[0].c_str());
+ for (unsigned int i = 0; i < num; ++i) {
nodes.channels.emplace_back();
LWO::Envelope &envl = nodes.channels.back();
envl.index = i;
envl.type = (LWO::EnvelopeType)(i + 1);
- if (++it == end) {
- goto unexpected_end;
+ if (++it == endIt) {
+ ASSIMP_LOG_ERROR("LWS: Encountered unexpected end of file while parsing object motion");
+ return;
}
- sub_num = strtoul10((*it).tokens[0].c_str());
-
+
+ const unsigned int sub_num = strtoul10((*it).tokens[0].c_str());
for (unsigned int n = 0; n < sub_num; ++n) {
-
- if (++it == end) goto unexpected_end;
+ if (++it == endIt) {
+ ASSIMP_LOG_ERROR("LWS: Encountered unexpected end of file while parsing object motion");
+ return;
+ }
// parse value and time, skip the rest for the moment.
LWO::Key key;
const char *c = fast_atoreal_move<float>((*it).tokens[0].c_str(), key.value);
- SkipSpaces(&c);
+ const char *end = c + (*it).tokens[0].size();
+ SkipSpaces(&c, end);
float f;
fast_atoreal_move<float>((*it).tokens[0].c_str(), f);
key.time = f;
- envl.keys.push_back(key);
+ envl.keys.emplace_back(key);
}
}
- return;
-
-unexpected_end:
- ASSIMP_LOG_ERROR("LWS: Encountered unexpected end of file while parsing object motion");
}
// ------------------------------------------------------------------------------------------------
@@ -300,7 +296,6 @@ void LWSImporter::SetupNodeName(aiNode *nd, LWS::NodeDesc &src) {
// the name depends on the type. We break LWS's strange naming convention
// and return human-readable, but still machine-parsable and unique, strings.
if (src.type == LWS::NodeDesc::OBJECT) {
-
if (src.path.length()) {
std::string::size_type s = src.path.find_last_of("\\/");
if (s == std::string::npos) {
@@ -505,7 +500,8 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// Parse the file structure
LWS::Element root;
const char *dummy = &mBuffer[0];
- root.Parse(dummy);
+ const char *dummyEnd = dummy + mBuffer.size();
+ root.Parse(dummy, dummyEnd);
// Construct a Batch-importer to read more files recursively
BatchLoader batch(pIOHandler);
@@ -544,6 +540,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// Now read all elements in a very straightforward manner
for (; it != root.children.end(); ++it) {
const char *c = (*it).tokens[1].c_str();
+ const char *end = c + (*it).tokens[1].size();
// 'FirstFrame': begin of animation slice
if ((*it).tokens[0] == "FirstFrame") {
@@ -571,14 +568,14 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
LWS::NodeDesc d;
d.type = LWS::NodeDesc::OBJECT;
if (version >= 4) { // handle LWSC 4 explicit ID
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
d.number = strtoul16(c, &c) & AI_LWS_MASK;
} else {
d.number = cur_object++;
}
// and add the file to the import list
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
std::string path = FindLWOFile(c);
d.path = path;
d.id = batch.AddLoadRequest(path, 0, &props);
@@ -592,7 +589,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (version >= 4) { // handle LWSC 4 explicit ID
d.number = strtoul16(c, &c) & AI_LWS_MASK;
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
} else {
d.number = cur_object++;
}
@@ -608,7 +605,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
d.type = LWS::NodeDesc::OBJECT;
if (version >= 4) { // handle LWSC 4 explicit ID
d.number = strtoul16(c, &c) & AI_LWS_MASK;
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
} else {
d.number = cur_object++;
}
@@ -672,26 +669,25 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// two ints per envelope
LWO::Envelope &env = *envelopeIt;
env.pre = (LWO::PrePostBehaviour)strtoul10(c, &c);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
env.post = (LWO::PrePostBehaviour)strtoul10(c, &c);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
}
}
}
// 'ParentItem': specifies the parent of the current element
else if ((*it).tokens[0] == "ParentItem") {
- if (nodes.empty())
+ if (nodes.empty()) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'ParentItem\'");
-
- else
+ } else {
nodes.back().parent = strtoul16(c, &c);
+ }
}
// 'ParentObject': deprecated one for older formats
else if (version < 3 && (*it).tokens[0] == "ParentObject") {
- if (nodes.empty())
+ if (nodes.empty()) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'ParentObject\'");
-
- else {
+ } else {
nodes.back().parent = strtoul10(c, &c) | (1u << 28u);
}
}
@@ -704,19 +700,20 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (version >= 4) { // handle LWSC 4 explicit ID
d.number = strtoul16(c, &c) & AI_LWS_MASK;
- } else
+ } else {
d.number = cur_camera++;
+ }
nodes.push_back(d);
num_camera++;
}
// 'CameraName': set name of currently active camera
else if ((*it).tokens[0] == "CameraName") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::CAMERA)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::CAMERA) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'CameraName\'");
-
- else
+ } else {
nodes.back().name = c;
+ }
}
// 'AddLight': add a light to the scenegraph
else if ((*it).tokens[0] == "AddLight") {
@@ -727,19 +724,20 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (version >= 4) { // handle LWSC 4 explicit ID
d.number = strtoul16(c, &c) & AI_LWS_MASK;
- } else
+ } else {
d.number = cur_light++;
+ }
nodes.push_back(d);
num_light++;
}
// 'LightName': set name of currently active light
else if ((*it).tokens[0] == "LightName") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightName\'");
-
- else
+ } else {
nodes.back().name = c;
+ }
}
// 'LightIntensity': set intensity of currently active light
else if ((*it).tokens[0] == "LightIntensity" || (*it).tokens[0] == "LgtIntensity") {
@@ -757,62 +755,58 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
}
// 'LightType': set type of currently active light
else if ((*it).tokens[0] == "LightType") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightType\'");
-
- else
+ } else {
nodes.back().lightType = strtoul10(c);
-
+ }
}
// 'LightFalloffType': set falloff type of currently active light
else if ((*it).tokens[0] == "LightFalloffType") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightFalloffType\'");
- else
+ } else {
nodes.back().lightFalloffType = strtoul10(c);
-
+ }
}
// 'LightConeAngle': set cone angle of currently active light
else if ((*it).tokens[0] == "LightConeAngle") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightConeAngle\'");
-
- else
+ } else {
nodes.back().lightConeAngle = fast_atof(c);
-
+ }
}
// 'LightEdgeAngle': set area where we're smoothing from min to max intensity
else if ((*it).tokens[0] == "LightEdgeAngle") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightEdgeAngle\'");
-
- else
+ } else {
nodes.back().lightEdgeAngle = fast_atof(c);
-
+ }
}
// 'LightColor': set color of currently active light
else if ((*it).tokens[0] == "LightColor") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightColor\'");
-
- else {
+ } else {
c = fast_atoreal_move<float>(c, (float &)nodes.back().lightColor.r);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move<float>(c, (float &)nodes.back().lightColor.g);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move<float>(c, (float &)nodes.back().lightColor.b);
}
}
// 'PivotPosition': position of local transformation origin
else if ((*it).tokens[0] == "PivotPosition" || (*it).tokens[0] == "PivotPoint") {
- if (nodes.empty())
+ if (nodes.empty()) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'PivotPosition\'");
- else {
+ } else {
c = fast_atoreal_move<float>(c, (float &)nodes.back().pivotPos.x);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move<float>(c, (float &)nodes.back().pivotPos.y);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move<float>(c, (float &)nodes.back().pivotPos.z);
// Mark pivotPos as set
nodes.back().isPivotSet = true;
@@ -822,7 +816,6 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// resolve parenting
for (std::list<LWS::NodeDesc>::iterator ndIt = nodes.begin(); ndIt != nodes.end(); ++ndIt) {
-
// check whether there is another node which calls us a parent
for (std::list<LWS::NodeDesc>::iterator dit = nodes.begin(); dit != nodes.end(); ++dit) {
if (dit != ndIt && *ndIt == (*dit).parent) {
@@ -858,7 +851,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
aiNode *nd = master->mRootNode = new aiNode();
// allocate storage for cameras&lights
- if (num_camera) {
+ if (num_camera > 0u) {
master->mCameras = new aiCamera *[master->mNumCameras = num_camera];
}
aiCamera **cams = master->mCameras;
diff --git a/code/AssetLib/LWS/LWSLoader.h b/code/AssetLib/LWS/LWSLoader.h
index 3df9fe9d9..f66688249 100644
--- a/code/AssetLib/LWS/LWSLoader.h
+++ b/code/AssetLib/LWS/LWSLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -76,7 +76,7 @@ public:
std::list<Element> children;
//! Recursive parsing function
- void Parse(const char *&buffer);
+ void Parse(const char *&buffer, const char *end);
};
#define AI_LWS_MASK (0xffffffff >> 4u)
@@ -174,7 +174,7 @@ struct NodeDesc {
class LWSImporter : public BaseImporter {
public:
LWSImporter();
- ~LWSImporter() override;
+ ~LWSImporter() override = default;
// -------------------------------------------------------------------
// Check whether we can read a specific file
diff --git a/code/AssetLib/M3D/M3DExporter.cpp b/code/AssetLib/M3D/M3DExporter.cpp
index cf87b6221..5545be415 100644
--- a/code/AssetLib/M3D/M3DExporter.cpp
+++ b/code/AssetLib/M3D/M3DExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DExporter.h b/code/AssetLib/M3D/M3DExporter.h
index d77743f56..0e9ab4305 100644
--- a/code/AssetLib/M3D/M3DExporter.h
+++ b/code/AssetLib/M3D/M3DExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DImporter.cpp b/code/AssetLib/M3D/M3DImporter.cpp
index 895b2bf70..b74b72dc8 100644
--- a/code/AssetLib/M3D/M3DImporter.cpp
+++ b/code/AssetLib/M3D/M3DImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
@@ -85,7 +85,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
are listed in aiScene->mRootNode->children, but all without meshes
*/
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Model 3D Importer",
"",
"",
diff --git a/code/AssetLib/M3D/M3DImporter.h b/code/AssetLib/M3D/M3DImporter.h
index 9ca8f9211..d9e546f39 100644
--- a/code/AssetLib/M3D/M3DImporter.h
+++ b/code/AssetLib/M3D/M3DImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DMaterials.h b/code/AssetLib/M3D/M3DMaterials.h
index a1b0fd742..dc87a99c7 100644
--- a/code/AssetLib/M3D/M3DMaterials.h
+++ b/code/AssetLib/M3D/M3DMaterials.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DWrapper.cpp b/code/AssetLib/M3D/M3DWrapper.cpp
index 05087d592..3741bbca3 100644
--- a/code/AssetLib/M3D/M3DWrapper.cpp
+++ b/code/AssetLib/M3D/M3DWrapper.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DWrapper.h b/code/AssetLib/M3D/M3DWrapper.h
index 880aca996..8a3fd92be 100644
--- a/code/AssetLib/M3D/M3DWrapper.h
+++ b/code/AssetLib/M3D/M3DWrapper.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/MD2/MD2FileData.h b/code/AssetLib/MD2/MD2FileData.h
index 3bce8feee..0dba71e56 100644
--- a/code/AssetLib/MD2/MD2FileData.h
+++ b/code/AssetLib/MD2/MD2FileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -55,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace MD2 {
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
#define AI_MD2_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDP2")
#define AI_MD2_MAGIC_NUMBER_LE AI_MAKE_MAGIC("2PDI")
diff --git a/code/AssetLib/MD2/MD2Loader.cpp b/code/AssetLib/MD2/MD2Loader.cpp
index ee7dbc6a6..99dc70d08 100644
--- a/code/AssetLib/MD2/MD2Loader.cpp
+++ b/code/AssetLib/MD2/MD2Loader.cpp
@@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -41,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
-
#ifndef ASSIMP_BUILD_NO_MD2_IMPORTER
/** @file Implementation of the MD2 importer class */
@@ -65,7 +62,7 @@ using namespace Assimp::MD2;
# define ARRAYSIZE(_array) (int(sizeof(_array) / sizeof(_array[0])))
#endif
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Quake II Mesh Importer",
"",
"",
@@ -79,7 +76,7 @@ static const aiImporterDesc desc = {
};
// ------------------------------------------------------------------------------------------------
-// Helper function to lookup a normal in Quake 2's precalculated table
+// Helper function to lookup a normal in Quake 2's pre-calculated table
void MD2::LookupNormalIndex(uint8_t iNormalIndex,aiVector3D& vOut)
{
// make sure the normal index has a valid value
@@ -101,10 +98,6 @@ MD2Importer::MD2Importer()
{}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-MD2Importer::~MD2Importer() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool MD2Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
{
diff --git a/code/AssetLib/MD2/MD2Loader.h b/code/AssetLib/MD2/MD2Loader.h
index a49ccb2fd..5ac34ad4c 100644
--- a/code/AssetLib/MD2/MD2Loader.h
+++ b/code/AssetLib/MD2/MD2Loader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -63,7 +63,7 @@ using namespace MD2;
class MD2Importer : public BaseImporter {
public:
MD2Importer();
- ~MD2Importer() override;
+ ~MD2Importer() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/MD2/MD2NormalTable.h b/code/AssetLib/MD2/MD2NormalTable.h
index 1837939e8..7d13b9ad1 100644
--- a/code/AssetLib/MD2/MD2NormalTable.h
+++ b/code/AssetLib/MD2/MD2NormalTable.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MD3/MD3FileData.h b/code/AssetLib/MD3/MD3FileData.h
index 01475e679..86d2647b6 100644
--- a/code/AssetLib/MD3/MD3FileData.h
+++ b/code/AssetLib/MD3/MD3FileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -62,7 +62,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace MD3 {
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
#define AI_MD3_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDP3")
#define AI_MD3_MAGIC_NUMBER_LE AI_MAKE_MAGIC("3PDI")
diff --git a/code/AssetLib/MD3/MD3Loader.cpp b/code/AssetLib/MD3/MD3Loader.cpp
index fcb8d0c35..3dd8d9c66 100644
--- a/code/AssetLib/MD3/MD3Loader.cpp
+++ b/code/AssetLib/MD3/MD3Loader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
@@ -70,7 +70,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Quake III Mesh Importer",
"",
"",
@@ -123,12 +123,12 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
// remove comments from it (C++ style)
CommentRemover::RemoveLineComments("//", &_buff[0]);
const char *buff = &_buff[0];
-
+ const char *end = buff + _buff.size();
Q3Shader::ShaderDataBlock *curData = nullptr;
Q3Shader::ShaderMapBlock *curMap = nullptr;
// read line per line
- for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) {
+ for (; SkipSpacesAndLineEnd(&buff, end); SkipLine(&buff, end)) {
if (*buff == '{') {
++buff;
@@ -140,21 +140,21 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
}
// read this data section
- for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) {
+ for (; SkipSpacesAndLineEnd(&buff, end); SkipLine(&buff, end)) {
if (*buff == '{') {
++buff;
// add new map section
curData->maps.emplace_back();
curMap = &curData->maps.back();
- for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) {
+ for (; SkipSpacesAndLineEnd(&buff, end); SkipLine(&buff, end)) {
// 'map' - Specifies texture file name
if (TokenMatchI(buff, "map", 3) || TokenMatchI(buff, "clampmap", 8)) {
- curMap->name = GetNextToken(buff);
+ curMap->name = GetNextToken(buff, end);
}
// 'blendfunc' - Alpha blending mode
else if (TokenMatchI(buff, "blendfunc", 9)) {
- const std::string blend_src = GetNextToken(buff);
+ const std::string blend_src = GetNextToken(buff, end);
if (blend_src == "add") {
curMap->blend_src = Q3Shader::BLEND_GL_ONE;
curMap->blend_dest = Q3Shader::BLEND_GL_ONE;
@@ -166,12 +166,12 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
curMap->blend_dest = Q3Shader::BLEND_GL_ONE_MINUS_SRC_ALPHA;
} else {
curMap->blend_src = StringToBlendFunc(blend_src);
- curMap->blend_dest = StringToBlendFunc(GetNextToken(buff));
+ curMap->blend_dest = StringToBlendFunc(GetNextToken(buff, end));
}
}
// 'alphafunc' - Alpha testing mode
else if (TokenMatchI(buff, "alphafunc", 9)) {
- const std::string at = GetNextToken(buff);
+ const std::string at = GetNextToken(buff, end);
if (at == "GT0") {
curMap->alpha_test = Q3Shader::AT_GT0;
} else if (at == "LT128") {
@@ -186,7 +186,6 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
break;
}
}
-
} else if (*buff == '}') {
++buff;
curData = nullptr;
@@ -195,7 +194,7 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
// 'cull' specifies culling behaviour for the model
else if (TokenMatchI(buff, "cull", 4)) {
- SkipSpaces(&buff);
+ SkipSpaces(&buff, end);
if (!ASSIMP_strincmp(buff, "back", 4)) { // render face's backside, does not function in Q3 engine (bug)
curData->cull = Q3Shader::CULL_CCW;
} else if (!ASSIMP_strincmp(buff, "front", 5)) { // is not valid keyword in Q3, but occurs in shaders
@@ -213,9 +212,10 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
curData = &fill.blocks.back();
// get the name of this section
- curData->name = GetNextToken(buff);
+ curData->name = GetNextToken(buff, end);
}
}
+
return true;
}
@@ -232,6 +232,7 @@ bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io)
const size_t s = file->FileSize();
std::vector<char> _buff(s + 1);
const char *buff = &_buff[0];
+ const char *end = buff + _buff.size();
file->Read(&_buff[0], s, 1);
_buff[s] = 0;
@@ -240,10 +241,10 @@ bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io)
// read token by token and fill output table
for (; *buff;) {
- SkipSpacesAndLineEnd(&buff);
+ SkipSpacesAndLineEnd(&buff, end);
// get first identifier
- std::string ss = GetNextToken(buff);
+ std::string ss = GetNextToken(buff, end);
// ignore tokens starting with tag_
if (!::strncmp(&ss[0], "tag_", std::min((size_t)4, ss.length())))
@@ -253,8 +254,9 @@ bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io)
SkinData::TextureEntry &entry = fill.textures.back();
entry.first = ss;
- entry.second = GetNextToken(buff);
+ entry.second = GetNextToken(buff, end);
}
+
return true;
}
@@ -293,7 +295,7 @@ void Q3Shader::ConvertShaderToMaterial(aiMaterial *out, const ShaderDataBlock &s
// - in any case: set it as diffuse texture
//
// If the texture is using 'filter' blending
- // - take as lightmap
+ // - take as light-map
//
// Textures with alpha funcs
// - aiTextureFlags_UseAlpha is set (otherwise aiTextureFlags_NoAlpha is explicitly set)
diff --git a/code/AssetLib/MD3/MD3Loader.h b/code/AssetLib/MD3/MD3Loader.h
index d911bb1da..eee66a3df 100644
--- a/code/AssetLib/MD3/MD3Loader.h
+++ b/code/AssetLib/MD3/MD3Loader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MD5/MD5Loader.cpp b/code/AssetLib/MD5/MD5Loader.cpp
index 4236f32e9..0976484a4 100644
--- a/code/AssetLib/MD5/MD5Loader.cpp
+++ b/code/AssetLib/MD5/MD5Loader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -64,7 +64,7 @@ using namespace Assimp;
// Minimum weight value. Weights inside [-n ... n] are ignored
#define AI_MD5_WEIGHT_EPSILON Math::getEpsilon<float>()
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Doom 3 / MD5 Mesh Importer",
"",
"",
@@ -93,10 +93,6 @@ MD5Importer::MD5Importer() :
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-MD5Importer::~MD5Importer() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool MD5Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const char *tokens[] = { "MD5Version" };
@@ -214,7 +210,7 @@ void MD5Importer::MakeDataUnique(MD5::MeshDesc &meshSrc) {
const unsigned int guess = (unsigned int)(fWeightsPerVert * iNewNum);
meshSrc.mWeights.reserve(guess + (guess >> 3)); // + 12.5% as buffer
- for (FaceList::const_iterator iter = meshSrc.mFaces.begin(), iterEnd = meshSrc.mFaces.end(); iter != iterEnd; ++iter) {
+ for (FaceArray::const_iterator iter = meshSrc.mFaces.begin(), iterEnd = meshSrc.mFaces.end(); iter != iterEnd; ++iter) {
const aiFace &face = *iter;
for (unsigned int i = 0; i < 3; ++i) {
if (face.mIndices[0] >= meshSrc.mVertices.size()) {
@@ -235,7 +231,7 @@ void MD5Importer::MakeDataUnique(MD5::MeshDesc &meshSrc) {
// ------------------------------------------------------------------------------------------------
// Recursive node graph construction from a MD5MESH
-void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &bones) {
+void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneArray &bones) {
ai_assert(nullptr != piParent);
ai_assert(!piParent->mNumChildren);
@@ -286,7 +282,7 @@ void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &b
// ------------------------------------------------------------------------------------------------
// Recursive node graph construction from a MD5ANIM
-void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneList &bones, const aiNodeAnim **node_anims) {
+void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneArray &bones, const aiNodeAnim **node_anims) {
ai_assert(nullptr != piParent);
ai_assert(!piParent->mNumChildren);
@@ -406,7 +402,7 @@ void MD5Importer::LoadMD5MeshFile() {
// copy texture coordinates
aiVector3D *pv = mesh->mTextureCoords[0];
- for (MD5::VertexList::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
+ for (MD5::VertexArray::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
pv->x = (*iter).mUV.x;
pv->y = 1.0f - (*iter).mUV.y; // D3D to OpenGL
pv->z = 0.0f;
@@ -416,7 +412,7 @@ void MD5Importer::LoadMD5MeshFile() {
unsigned int *piCount = new unsigned int[meshParser.mJoints.size()];
::memset(piCount, 0, sizeof(unsigned int) * meshParser.mJoints.size());
- for (MD5::VertexList::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
+ for (MD5::VertexArray::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w) {
MD5::WeightDesc &weightDesc = meshSrc.mWeights[w];
/* FIX for some invalid exporters */
@@ -451,7 +447,7 @@ void MD5Importer::LoadMD5MeshFile() {
}
pv = mesh->mVertices;
- for (MD5::VertexList::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
+ for (MD5::VertexArray::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
// compute the final vertex position from all single weights
*pv = aiVector3D();
@@ -589,14 +585,14 @@ void MD5Importer::LoadMD5AnimFile() {
// 1 tick == 1 frame
anim->mTicksPerSecond = animParser.fFrameRate;
- for (FrameList::const_iterator iter = animParser.mFrames.begin(), iterEnd = animParser.mFrames.end(); iter != iterEnd; ++iter) {
+ for (FrameArray::const_iterator iter = animParser.mFrames.begin(), iterEnd = animParser.mFrames.end(); iter != iterEnd; ++iter) {
double dTime = (double)(*iter).iIndex;
aiNodeAnim **pcAnimNode = anim->mChannels;
if (!(*iter).mValues.empty() || iter == animParser.mFrames.begin()) /* be sure we have at least one frame */
{
// now process all values in there ... read all joints
MD5::BaseFrameDesc *pcBaseFrame = &animParser.mBaseFrames[0];
- for (AnimBoneList::const_iterator iter2 = animParser.mAnimatedBones.begin(); iter2 != animParser.mAnimatedBones.end(); ++iter2,
+ for (AnimBoneArray::const_iterator iter2 = animParser.mAnimatedBones.begin(); iter2 != animParser.mAnimatedBones.end(); ++iter2,
++pcAnimNode, ++pcBaseFrame) {
if ((*iter2).iFirstKeyIndex >= (*iter).mValues.size()) {
diff --git a/code/AssetLib/MD5/MD5Loader.h b/code/AssetLib/MD5/MD5Loader.h
index 63fb1c36b..d64d6f5b8 100644
--- a/code/AssetLib/MD5/MD5Loader.h
+++ b/code/AssetLib/MD5/MD5Loader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -65,7 +65,7 @@ using namespace Assimp::MD5;
class MD5Importer : public BaseImporter {
public:
MD5Importer();
- ~MD5Importer() override;
+ ~MD5Importer() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
@@ -118,7 +118,7 @@ protected:
* @param node_anims Generated node animations
*/
void AttachChilds_Anim(int iParentID, aiNode *piParent,
- AnimBoneList &bones, const aiNodeAnim **node_anims);
+ AnimBoneArray &bones, const aiNodeAnim **node_anims);
// -------------------------------------------------------------------
/** Construct node hierarchy from a given MD5MESH
@@ -126,7 +126,7 @@ protected:
* @param piParent Parent node to attach to
* @param bones Input bones
*/
- void AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &bones);
+ void AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneArray &bones);
// -------------------------------------------------------------------
/** Build unique vertex buffers from a given MD5ANIM
diff --git a/code/AssetLib/MD5/MD5Parser.cpp b/code/AssetLib/MD5/MD5Parser.cpp
index 7d0b41c24..24882af7e 100644
--- a/code/AssetLib/MD5/MD5Parser.cpp
+++ b/code/AssetLib/MD5/MD5Parser.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -87,7 +87,7 @@ MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) : buffer(_buffer), b
// ------------------------------------------------------------------------------------------------
// Report error to the log stream
-/*static*/ AI_WONT_RETURN void MD5Parser::ReportError(const char *error, unsigned int line) {
+AI_WONT_RETURN void MD5Parser::ReportError(const char *error, unsigned int line) {
char szBuffer[1024];
::ai_snprintf(szBuffer, 1024, "[MD5] Line %u: %s", line, error);
throw DeadlyImportError(szBuffer);
@@ -95,7 +95,7 @@ MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) : buffer(_buffer), b
// ------------------------------------------------------------------------------------------------
// Report warning to the log stream
-/*static*/ void MD5Parser::ReportWarning(const char *warn, unsigned int line) {
+void MD5Parser::ReportWarning(const char *warn, unsigned int line) {
char szBuffer[1024];
::snprintf(szBuffer, sizeof(szBuffer), "[MD5] Line %u: %s", line, warn);
ASSIMP_LOG_WARN(szBuffer);
@@ -122,8 +122,8 @@ void MD5Parser::ParseHeader() {
// print the command line options to the console
// FIX: can break the log length limit, so we need to be careful
char *sz = buffer;
- while (!IsLineEnd(*buffer++))
- ;
+ while (!IsLineEnd(*buffer++));
+
ASSIMP_LOG_INFO(std::string(sz, std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer - sz))));
SkipSpacesAndLineEnd();
}
@@ -138,14 +138,16 @@ bool MD5Parser::ParseSection(Section &out) {
char *sz = buffer;
while (!IsSpaceOrNewLine(*buffer)) {
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
out.mName = std::string(sz, (uintptr_t)(buffer - sz));
while (IsSpace(*buffer)) {
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
bool running = true;
@@ -153,14 +155,16 @@ bool MD5Parser::ParseSection(Section &out) {
if ('{' == *buffer) {
// it is a normal section so read all lines
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
bool run = true;
while (run) {
while (IsSpaceOrNewLine(*buffer)) {
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
if ('\0' == *buffer) {
return false; // seems this was the last section
@@ -175,18 +179,21 @@ bool MD5Parser::ParseSection(Section &out) {
elem.iLineNumber = lineNumber;
elem.szStart = buffer;
+ elem.end = bufferEnd;
// terminate the line with zero
while (!IsLineEnd(*buffer)) {
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
if (*buffer) {
++lineNumber;
*buffer++ = '\0';
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
}
break;
@@ -194,89 +201,107 @@ bool MD5Parser::ParseSection(Section &out) {
// it is an element at global scope. Parse its value and go on
sz = buffer;
while (!IsSpaceOrNewLine(*buffer++)) {
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
out.mGlobalValue = std::string(sz, (uintptr_t)(buffer - sz));
continue;
}
break;
}
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
while (IsSpaceOrNewLine(*buffer)) {
+ if (buffer == bufferEnd) {
+ break;
+ }
++buffer;
- if (buffer == bufferEnd)
- return false;
}
return '\0' != *buffer;
}
-// ------------------------------------------------------------------------------------------------
-// Some dirty macros just because they're so funny and easy to debug
-
// skip all spaces ... handle EOL correctly
-#define AI_MD5_SKIP_SPACES() \
- if (!SkipSpaces(&sz)) \
- MD5Parser::ReportWarning("Unexpected end of line", elem.iLineNumber);
+inline void AI_MD5_SKIP_SPACES(const char **sz, const char *bufferEnd, int linenumber) {
+ if (!SkipSpaces(sz, bufferEnd)) {
+ MD5Parser::ReportWarning("Unexpected end of line", linenumber);
+ }
+}
// read a triple float in brackets: (1.0 1.0 1.0)
-#define AI_MD5_READ_TRIPLE(vec) \
- AI_MD5_SKIP_SPACES(); \
- if ('(' != *sz++) \
- MD5Parser::ReportWarning("Unexpected token: ( was expected", elem.iLineNumber); \
- AI_MD5_SKIP_SPACES(); \
- sz = fast_atoreal_move<float>(sz, (float &)vec.x); \
- AI_MD5_SKIP_SPACES(); \
- sz = fast_atoreal_move<float>(sz, (float &)vec.y); \
- AI_MD5_SKIP_SPACES(); \
- sz = fast_atoreal_move<float>(sz, (float &)vec.z); \
- AI_MD5_SKIP_SPACES(); \
- if (')' != *sz++) \
- MD5Parser::ReportWarning("Unexpected token: ) was expected", elem.iLineNumber);
+inline void AI_MD5_READ_TRIPLE(aiVector3D &vec, const char **sz, const char *bufferEnd, int linenumber) {
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ if ('(' != **sz) {
+ MD5Parser::ReportWarning("Unexpected token: ( was expected", linenumber);
+ ++*sz;
+ }
+ ++*sz;
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ *sz = fast_atoreal_move<float>(*sz, (float &)vec.x);
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ *sz = fast_atoreal_move<float>(*sz, (float &)vec.y);
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ *sz = fast_atoreal_move<float>(*sz, (float &)vec.z);
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ if (')' != **sz) {
+ MD5Parser::ReportWarning("Unexpected token: ) was expected", linenumber);
+ }
+ ++*sz;
+}
// parse a string, enclosed in quotation marks or not
-#define AI_MD5_PARSE_STRING(out) \
- bool bQuota = (*sz == '\"'); \
- const char *szStart = sz; \
- while (!IsSpaceOrNewLine(*sz)) \
- ++sz; \
- const char *szEnd = sz; \
- if (bQuota) { \
- szStart++; \
- if ('\"' != *(szEnd -= 1)) { \
- MD5Parser::ReportWarning("Expected closing quotation marks in string", \
- elem.iLineNumber); \
- continue; \
- } \
- } \
- out.length = (size_t)(szEnd - szStart); \
- ::memcpy(out.data, szStart, out.length); \
+inline bool AI_MD5_PARSE_STRING(const char **sz, const char *bufferEnd, aiString &out, int linenumber) {
+ bool bQuota = (**sz == '\"');
+ const char *szStart = *sz;
+ while (!IsSpaceOrNewLine(**sz)) {
+ ++*sz;
+ if (*sz == bufferEnd) break;
+ }
+ const char *szEnd = *sz;
+ if (bQuota) {
+ szStart++;
+ if ('\"' != *(szEnd -= 1)) {
+ MD5Parser::ReportWarning("Expected closing quotation marks in string", linenumber);
+ ++*sz;
+ }
+ }
+ out.length = (ai_uint32)(szEnd - szStart);
+ ::memcpy(out.data, szStart, out.length);
out.data[out.length] = '\0';
+ return true;
+}
+
// parse a string, enclosed in quotation marks
-#define AI_MD5_PARSE_STRING_IN_QUOTATION(out) \
- out.length = 0; \
- while ('\"' != *sz && '\0' != *sz) \
- ++sz; \
- if ('\0' != *sz) { \
- const char *szStart = ++sz; \
- while ('\"' != *sz && '\0' != *sz) \
- ++sz; \
- if ('\0' != *sz) { \
- const char *szEnd = (sz++); \
- out.length = (ai_uint32)(szEnd - szStart); \
- ::memcpy(out.data, szStart, out.length); \
- } \
- } \
+inline void AI_MD5_PARSE_STRING_IN_QUOTATION(const char **sz, const char *bufferEnd, aiString &out) {
+ out.length = 0u;
+ while (('\"' != **sz && '\0' != **sz) && *sz != bufferEnd) {
+ ++*sz;
+ }
+ if ('\0' != **sz) {
+ const char *szStart = ++(*sz);
+
+ while (('\"' != **sz && '\0' != **sz) && *sz != bufferEnd) {
+ ++*sz;
+ }
+ if ('\0' != **sz) {
+ const char *szEnd = *sz;
+ ++*sz;
+ out.length = (ai_uint32)(szEnd - szStart);
+ ::memcpy(out.data, szStart, out.length);
+ }
+ }
out.data[out.length] = '\0';
+}
+
// ------------------------------------------------------------------------------------------------
// .MD5MESH parsing function
-MD5MeshParser::MD5MeshParser(SectionList &mSections) {
+MD5MeshParser::MD5MeshParser(SectionArray &mSections) {
ASSIMP_LOG_DEBUG("MD5MeshParser begin");
// now parse all sections
- for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
+ for (SectionArray::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
if ((*iter).mName == "numMeshes") {
mMeshes.reserve(::strtoul10((*iter).mGlobalValue.c_str()));
} else if ((*iter).mName == "numJoints") {
@@ -288,14 +313,15 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) {
BoneDesc &desc = mJoints.back();
const char *sz = elem.szStart;
- AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_PARSE_STRING_IN_QUOTATION(&sz, elem.end, desc.mName);
+
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
// negative values, at least -1, is allowed here
desc.mParentIndex = (int)strtol10(sz, &sz);
- AI_MD5_READ_TRIPLE(desc.mPositionXYZ);
- AI_MD5_READ_TRIPLE(desc.mRotationQuat); // normalized quaternion, so w is not there
+ AI_MD5_READ_TRIPLE(desc.mPositionXYZ, &sz, elem.end, elem.iLineNumber);
+ AI_MD5_READ_TRIPLE(desc.mRotationQuat, &sz, elem.end, elem.iLineNumber); // normalized quaternion, so w is not there
}
} else if ((*iter).mName == "mesh") {
mMeshes.emplace_back();
@@ -306,52 +332,52 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) {
// shader attribute
if (TokenMatch(sz, "shader", 6)) {
- AI_MD5_SKIP_SPACES();
- AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mShader);
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
+ AI_MD5_PARSE_STRING_IN_QUOTATION(&sz, elem.end, desc.mShader);
}
// numverts attribute
else if (TokenMatch(sz, "numverts", 8)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
desc.mVertices.resize(strtoul10(sz));
}
// numtris attribute
else if (TokenMatch(sz, "numtris", 7)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
desc.mFaces.resize(strtoul10(sz));
}
// numweights attribute
else if (TokenMatch(sz, "numweights", 10)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
desc.mWeights.resize(strtoul10(sz));
}
// vert attribute
// "vert 0 ( 0.394531 0.513672 ) 0 1"
else if (TokenMatch(sz, "vert", 4)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
const unsigned int idx = ::strtoul10(sz, &sz);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
if (idx >= desc.mVertices.size())
desc.mVertices.resize(idx + 1);
VertexDesc &vert = desc.mVertices[idx];
if ('(' != *sz++)
MD5Parser::ReportWarning("Unexpected token: ( was expected", elem.iLineNumber);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
sz = fast_atoreal_move<float>(sz, (float &)vert.mUV.x);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
sz = fast_atoreal_move<float>(sz, (float &)vert.mUV.y);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
if (')' != *sz++)
MD5Parser::ReportWarning("Unexpected token: ) was expected", elem.iLineNumber);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
vert.mFirstWeight = ::strtoul10(sz, &sz);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
vert.mNumWeights = ::strtoul10(sz, &sz);
}
// tri attribute
// "tri 0 15 13 12"
else if (TokenMatch(sz, "tri", 3)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
const unsigned int idx = strtoul10(sz, &sz);
if (idx >= desc.mFaces.size())
desc.mFaces.resize(idx + 1);
@@ -359,24 +385,24 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) {
aiFace &face = desc.mFaces[idx];
face.mIndices = new unsigned int[face.mNumIndices = 3];
for (unsigned int i = 0; i < 3; ++i) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
face.mIndices[i] = strtoul10(sz, &sz);
}
}
// weight attribute
// "weight 362 5 0.500000 ( -3.553583 11.893474 9.719339 )"
else if (TokenMatch(sz, "weight", 6)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
const unsigned int idx = strtoul10(sz, &sz);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
if (idx >= desc.mWeights.size())
desc.mWeights.resize(idx + 1);
WeightDesc &weight = desc.mWeights[idx];
weight.mBone = strtoul10(sz, &sz);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
sz = fast_atoreal_move<float>(sz, weight.mWeight);
- AI_MD5_READ_TRIPLE(weight.vOffsetPosition);
+ AI_MD5_READ_TRIPLE(weight.vOffsetPosition, &sz, elem.end, elem.iLineNumber);
}
}
}
@@ -386,12 +412,12 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) {
// ------------------------------------------------------------------------------------------------
// .MD5ANIM parsing function
-MD5AnimParser::MD5AnimParser(SectionList &mSections) {
+MD5AnimParser::MD5AnimParser(SectionArray &mSections) {
ASSIMP_LOG_DEBUG("MD5AnimParser begin");
fFrameRate = 24.0f;
mNumAnimatedComponents = UINT_MAX;
- for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
+ for (SectionArray::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
if ((*iter).mName == "hierarchy") {
// "sheath" 0 63 6
for (const auto &elem : (*iter).mElements) {
@@ -399,18 +425,18 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) {
AnimBoneDesc &desc = mAnimatedBones.back();
const char *sz = elem.szStart;
- AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_PARSE_STRING_IN_QUOTATION(&sz, elem.end, desc.mName);
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
// parent index - negative values are allowed (at least -1)
desc.mParentIndex = ::strtol10(sz, &sz);
// flags (highest is 2^6-1)
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
if (63 < (desc.iFlags = ::strtoul10(sz, &sz))) {
MD5Parser::ReportWarning("Invalid flag combination in hierarchy section", elem.iLineNumber);
}
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(& sz, elem.end, elem.iLineNumber);
// index of the first animation keyframe component for this joint
desc.iFirstKeyIndex = ::strtoul10(sz, &sz);
@@ -423,8 +449,8 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) {
mBaseFrames.emplace_back();
BaseFrameDesc &desc = mBaseFrames.back();
- AI_MD5_READ_TRIPLE(desc.vPositionXYZ);
- AI_MD5_READ_TRIPLE(desc.vRotationQuat);
+ AI_MD5_READ_TRIPLE(desc.vPositionXYZ, &sz, elem.end, elem.iLineNumber);
+ AI_MD5_READ_TRIPLE(desc.vRotationQuat, &sz, elem.end, elem.iLineNumber);
}
} else if ((*iter).mName == "frame") {
if (!(*iter).mGlobalValue.length()) {
@@ -444,7 +470,7 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) {
// now read all elements (continuous list of floats)
for (const auto &elem : (*iter).mElements) {
const char *sz = elem.szStart;
- while (SkipSpacesAndLineEnd(&sz)) {
+ while (SkipSpacesAndLineEnd(&sz, elem.end)) {
float f;
sz = fast_atoreal_move<float>(sz, f);
desc.mValues.push_back(f);
@@ -471,11 +497,11 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) {
// ------------------------------------------------------------------------------------------------
// .MD5CAMERA parsing function
-MD5CameraParser::MD5CameraParser(SectionList &mSections) {
+MD5CameraParser::MD5CameraParser(SectionArray &mSections) {
ASSIMP_LOG_DEBUG("MD5CameraParser begin");
fFrameRate = 24.0f;
- for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
+ for (SectionArray::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
if ((*iter).mName == "numFrames") {
frames.reserve(strtoul10((*iter).mGlobalValue.c_str()));
} else if ((*iter).mName == "frameRate") {
@@ -492,9 +518,9 @@ MD5CameraParser::MD5CameraParser(SectionList &mSections) {
frames.emplace_back();
CameraAnimFrameDesc &cur = frames.back();
- AI_MD5_READ_TRIPLE(cur.vPositionXYZ);
- AI_MD5_READ_TRIPLE(cur.vRotationQuat);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_READ_TRIPLE(cur.vPositionXYZ, &sz, elem.end, elem.iLineNumber);
+ AI_MD5_READ_TRIPLE(cur.vRotationQuat, &sz, elem.end, elem.iLineNumber);
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
cur.fFOV = fast_atof(sz);
}
}
diff --git a/code/AssetLib/MD5/MD5Parser.h b/code/AssetLib/MD5/MD5Parser.h
index ad7367e2a..75e3c22f2 100644
--- a/code/AssetLib/MD5/MD5Parser.h
+++ b/code/AssetLib/MD5/MD5Parser.h
@@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -69,12 +68,14 @@ struct Element {
//! Elements are terminated with \0
char* szStart;
+ const char *end;
+
//! Original line number (can be used in error messages
//! if a parsing error occurs)
unsigned int iLineNumber;
};
-using ElementList = std::vector<Element>;
+using ElementArray = std::vector<Element>;
// ---------------------------------------------------------------------------
/** Represents a section of a MD5 file (such as the mesh or the joints section)
@@ -87,17 +88,17 @@ struct Section {
unsigned int iLineNumber;
//! List of all elements which have been parsed in this section.
- ElementList mElements;
+ ElementArray mElements;
//! Name of the section
std::string mName;
//! For global elements: the value of the element as string
- //! Iif !length() the section is not a global element
+ //! if !length() the section is not a global element
std::string mGlobalValue;
};
-using SectionList = std::vector<Section>;
+using SectionArray = std::vector<Section>;
// ---------------------------------------------------------------------------
/** Basic information about a joint
@@ -133,7 +134,7 @@ struct BoneDesc : BaseJointDescription {
unsigned int mMap;
};
-using BoneList = std::vector<BoneDesc>;
+using BoneArray = std::vector<BoneDesc>;
// ---------------------------------------------------------------------------
/** Represents a bone (joint) descriptor in a MD5Anim file
@@ -146,7 +147,7 @@ struct AnimBoneDesc : BaseJointDescription {
unsigned int iFirstKeyIndex;
};
-using AnimBoneList = std::vector< AnimBoneDesc >;
+using AnimBoneArray = std::vector< AnimBoneDesc >;
// ---------------------------------------------------------------------------
/** Represents a base frame descriptor in a MD5Anim file
@@ -156,7 +157,7 @@ struct BaseFrameDesc {
aiVector3D vRotationQuat;
};
-using BaseFrameList = std::vector<BaseFrameDesc>;
+using BaseFrameArray = std::vector<BaseFrameDesc>;
// ---------------------------------------------------------------------------
/** Represents a camera animation frame in a MDCamera file
@@ -165,7 +166,7 @@ struct CameraAnimFrameDesc : BaseFrameDesc {
float fFOV;
};
-using CameraFrameList = std::vector<CameraAnimFrameDesc>;
+using CameraFrameArray = std::vector<CameraAnimFrameDesc>;
// ---------------------------------------------------------------------------
/** Represents a frame descriptor in a MD5Anim file
@@ -178,14 +179,14 @@ struct FrameDesc {
std::vector< float > mValues;
};
-using FrameList = std::vector<FrameDesc>;
+using FrameArray = std::vector<FrameDesc>;
// ---------------------------------------------------------------------------
/** Represents a vertex descriptor in a MD5 file
*/
struct VertexDesc {
VertexDesc() AI_NO_EXCEPT
- : mFirstWeight(0), mNumWeights(0) {
+ : mFirstWeight(0), mNumWeights(0) {
// empty
}
@@ -200,7 +201,7 @@ struct VertexDesc {
unsigned int mNumWeights;
};
-using VertexList = std::vector<VertexDesc>;
+using VertexArray = std::vector<VertexDesc>;
// ---------------------------------------------------------------------------
/** Represents a vertex weight descriptor in a MD5 file
@@ -217,27 +218,27 @@ struct WeightDesc {
aiVector3D vOffsetPosition;
};
-using WeightList = std::vector<WeightDesc>;
-using FaceList = std::vector<aiFace>;
+using WeightArray = std::vector<WeightDesc>;
+using FaceArray = std::vector<aiFace>;
// ---------------------------------------------------------------------------
/** Represents a mesh in a MD5 file
*/
struct MeshDesc {
//! Weights of the mesh
- WeightList mWeights;
+ WeightArray mWeights;
//! Vertices of the mesh
- VertexList mVertices;
+ VertexArray mVertices;
//! Faces of the mesh
- FaceList mFaces;
+ FaceArray mFaces;
//! Name of the shader (=texture) to be assigned to the mesh
aiString mShader;
};
-using MeshList = std::vector<MeshDesc>;
+using MeshArray = std::vector<MeshDesc>;
// ---------------------------------------------------------------------------
// Convert a quaternion to its usual representation
@@ -270,13 +271,13 @@ public:
*
* @param mSections List of file sections (output of MD5Parser)
*/
- explicit MD5MeshParser(SectionList& mSections);
+ explicit MD5MeshParser(SectionArray& mSections);
//! List of all meshes
- MeshList mMeshes;
+ MeshArray mMeshes;
//! List of all joints
- BoneList mJoints;
+ BoneArray mJoints;
};
// remove this flag if you need to the bounding box data
@@ -293,20 +294,20 @@ public:
*
* @param mSections List of file sections (output of MD5Parser)
*/
- explicit MD5AnimParser(SectionList& mSections);
+ explicit MD5AnimParser(SectionArray& mSections);
//! Output frame rate
float fFrameRate;
//! List of animation bones
- AnimBoneList mAnimatedBones;
+ AnimBoneArray mAnimatedBones;
//! List of base frames
- BaseFrameList mBaseFrames;
+ BaseFrameArray mBaseFrames;
//! List of animation frames
- FrameList mFrames;
+ FrameArray mFrames;
//! Number of animated components
unsigned int mNumAnimatedComponents;
@@ -323,7 +324,7 @@ public:
*
* @param mSections List of file sections (output of MD5Parser)
*/
- explicit MD5CameraParser(SectionList& mSections);
+ explicit MD5CameraParser(SectionArray& mSections);
//! Output frame rate
float fFrameRate;
@@ -332,7 +333,7 @@ public:
std::vector<unsigned int> cuts;
//! Frames
- CameraFrameList frames;
+ CameraFrameArray frames;
};
// ---------------------------------------------------------------------------
@@ -349,66 +350,65 @@ public:
*/
MD5Parser(char* buffer, unsigned int fileSize);
-
// -------------------------------------------------------------------
/** Report a specific error message and throw an exception
* @param error Error message to be reported
* @param line Index of the line where the error occurred
*/
- AI_WONT_RETURN static void ReportError (const char* error, unsigned int line) AI_WONT_RETURN_SUFFIX;
+ AI_WONT_RETURN static void ReportError(const char* error, unsigned int line) AI_WONT_RETURN_SUFFIX;
// -------------------------------------------------------------------
/** Report a specific warning
* @param warn Warn message to be reported
* @param line Index of the line where the error occurred
*/
- static void ReportWarning (const char* warn, unsigned int line);
-
+ static void ReportWarning(const char* warn, unsigned int line);
+ // -------------------------------------------------------------------
+ /** Report a specific error
+ * @param error Error message to be reported
+ */
AI_WONT_RETURN void ReportError (const char* error) AI_WONT_RETURN_SUFFIX;
- void ReportWarning (const char* warn) {
- return ReportWarning(warn, lineNumber);
- }
+ // -------------------------------------------------------------------
+ /** Report a specific warning
+ * @param error Warn message to be reported
+ */
+ void ReportWarning (const char* warn);
//! List of all sections which have been read
- SectionList mSections;
+ SectionArray mSections;
private:
- // -------------------------------------------------------------------
- /** Parses a file section. The current file pointer must be outside
- * of a section.
- * @param out Receives the section data
- * @return true if the end of the file has been reached
- * @throws ImportErrorException if an error occurs
- */
bool ParseSection(Section& out);
-
- // -------------------------------------------------------------------
- /** Parses the file header
- * @throws ImportErrorException if an error occurs
- */
void ParseHeader();
-
bool SkipLine(const char* in, const char** out);
bool SkipLine( );
bool SkipSpacesAndLineEnd( const char* in, const char** out);
bool SkipSpacesAndLineEnd();
bool SkipSpaces();
+private:
char* buffer;
- char* bufferEnd;
+ const char* bufferEnd;
unsigned int fileSize;
unsigned int lineNumber;
};
+// -------------------------------------------------------------------
+inline void MD5Parser::ReportWarning (const char* warn) {
+ return ReportWarning(warn, lineNumber);
+}
+
+// -------------------------------------------------------------------
inline void MD5Parser::ReportError(const char* error) {
ReportError(error, lineNumber);
}
+
// -------------------------------------------------------------------
inline bool MD5Parser::SkipLine(const char* in, const char** out) {
++lineNumber;
- return Assimp::SkipLine(in ,out);
+ return Assimp::SkipLine(in, out, bufferEnd);
}
// -------------------------------------------------------------------
@@ -418,18 +418,24 @@ inline bool MD5Parser::SkipLine( ) {
// -------------------------------------------------------------------
inline bool MD5Parser::SkipSpacesAndLineEnd( const char* in, const char** out) {
- bool bHad = false;
- bool running = true;
+ if (in == bufferEnd) {
+ *out = in;
+ return false;
+ }
+
+ bool bHad = false, running = true;
while (running) {
if( *in == '\r' || *in == '\n') {
- // we open files in binary mode, so there could be \r\n sequences ...
+ // we open files in binary mode, so there could be \r\n sequences ...
if (!bHad) {
bHad = true;
++lineNumber;
}
+ } else if (*in == '\t' || *in == ' ') {
+ bHad = false;
+ } else {
+ break;
}
- else if (*in == '\t' || *in == ' ')bHad = false;
- else break;
++in;
if (in == bufferEnd) {
break;
@@ -446,7 +452,7 @@ inline bool MD5Parser::SkipSpacesAndLineEnd() {
// -------------------------------------------------------------------
inline bool MD5Parser::SkipSpaces() {
- return Assimp::SkipSpaces((const char**)&buffer);
+ return Assimp::SkipSpaces((const char**)&buffer, bufferEnd);
}
} // namespace Assimp
diff --git a/code/AssetLib/MDC/MDCFileData.h b/code/AssetLib/MDC/MDCFileData.h
index 36c589e91..4c5b4127c 100644
--- a/code/AssetLib/MDC/MDCFileData.h
+++ b/code/AssetLib/MDC/MDCFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -61,7 +61,7 @@ http://themdcfile.planetwolfenstein.gamespy.com/MDC_File_Format.pdf
namespace Assimp {
namespace MDC {
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
#define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI")
#define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC")
diff --git a/code/AssetLib/MDC/MDCLoader.cpp b/code/AssetLib/MDC/MDCLoader.cpp
index 10ea618b9..c81ba67a6 100644
--- a/code/AssetLib/MDC/MDCLoader.cpp
+++ b/code/AssetLib/MDC/MDCLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
using namespace Assimp::MDC;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Return To Castle Wolfenstein Mesh Importer",
"",
"",
@@ -104,10 +104,6 @@ MDCImporter::MDCImporter() :
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-MDCImporter::~MDCImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool MDCImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const uint32_t tokens[] = { AI_MDC_MAGIC_NUMBER_LE };
diff --git a/code/AssetLib/MDC/MDCLoader.h b/code/AssetLib/MDC/MDCLoader.h
index 6e67cd12f..09ecc6865 100644
--- a/code/AssetLib/MDC/MDCLoader.h
+++ b/code/AssetLib/MDC/MDCLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -62,7 +62,7 @@ using namespace MDC;
class MDCImporter : public BaseImporter {
public:
MDCImporter();
- ~MDCImporter() override;
+ ~MDCImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/MDL/HalfLife/HL1FileData.h b/code/AssetLib/MDL/HalfLife/HL1FileData.h
index 28b1b2822..485f538ab 100644
--- a/code/AssetLib/MDL/HalfLife/HL1FileData.h
+++ b/code/AssetLib/MDL/HalfLife/HL1FileData.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1ImportDefinitions.h b/code/AssetLib/MDL/HalfLife/HL1ImportDefinitions.h
index d412aeede..344574d24 100644
--- a/code/AssetLib/MDL/HalfLife/HL1ImportDefinitions.h
+++ b/code/AssetLib/MDL/HalfLife/HL1ImportDefinitions.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1ImportSettings.h b/code/AssetLib/MDL/HalfLife/HL1ImportSettings.h
index 340ba2da5..52f98cb58 100644
--- a/code/AssetLib/MDL/HalfLife/HL1ImportSettings.h
+++ b/code/AssetLib/MDL/HalfLife/HL1ImportSettings.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
index a8141fcc1..2d7f6a7c2 100644
--- a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
+++ b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h
index 286b6e64c..ab5bb6942 100644
--- a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h
+++ b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1MeshTrivert.h b/code/AssetLib/MDL/HalfLife/HL1MeshTrivert.h
index 4ef8a13ce..9c389a659 100644
--- a/code/AssetLib/MDL/HalfLife/HL1MeshTrivert.h
+++ b/code/AssetLib/MDL/HalfLife/HL1MeshTrivert.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h b/code/AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h
index c7808c401..25ef27bca 100644
--- a/code/AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h
+++ b/code/AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/LogFunctions.h b/code/AssetLib/MDL/HalfLife/LogFunctions.h
index 003774dc1..c8cdf9b15 100644
--- a/code/AssetLib/MDL/HalfLife/LogFunctions.h
+++ b/code/AssetLib/MDL/HalfLife/LogFunctions.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp
index 3cca8c558..b79ec3613 100644
--- a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp
+++ b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.h b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.h
index 73b6f9e74..cf190bc3b 100644
--- a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.h
+++ b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/MDLDefaultColorMap.h b/code/AssetLib/MDL/MDLDefaultColorMap.h
index 2eecac2dc..cbdc977ad 100644
--- a/code/AssetLib/MDL/MDLDefaultColorMap.h
+++ b/code/AssetLib/MDL/MDLDefaultColorMap.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/MDLFileData.h b/code/AssetLib/MDL/MDLFileData.h
index 7ec2afe9a..2aff59856 100644
--- a/code/AssetLib/MDL/MDLFileData.h
+++ b/code/AssetLib/MDL/MDLFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -67,7 +67,7 @@ namespace Assimp {
namespace MDL {
// -------------------------------------------------------------------------------------
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
// magic bytes used in Quake 1 MDL meshes
#define AI_MDL_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDPO")
diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp
index 7b2ec7115..99b0145af 100644
--- a/code/AssetLib/MDL/MDLLoader.cpp
+++ b/code/AssetLib/MDL/MDLLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -65,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Quake Mesh / 3D GameStudio Mesh Importer",
"",
"",
@@ -97,10 +97,6 @@ MDLImporter::MDLImporter() :
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-MDLImporter::~MDLImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool MDLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const uint32_t tokens[] = {
diff --git a/code/AssetLib/MDL/MDLLoader.h b/code/AssetLib/MDL/MDLLoader.h
index 44ff21e3e..f99f061ce 100644
--- a/code/AssetLib/MDL/MDLLoader.h
+++ b/code/AssetLib/MDL/MDLLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -39,10 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-
-/** @file MDLLoader.h
- * @brief Declaration of the loader for MDL files
- */
+/// @file MDLLoader.h
+/// @brief Declaration of the loader for MDL files
#pragma once
#ifndef AI_MDLLOADER_H_INCLUDED
#define AI_MDLLOADER_H_INCLUDED
@@ -83,11 +81,10 @@ using namespace MDL;
* them all with a single 1000-line function-beast. However, it has been
* split into several code paths to make the code easier to read and maintain.
*/
-class MDLImporter : public BaseImporter
-{
+class MDLImporter : public BaseImporter {
public:
MDLImporter();
- ~MDLImporter() override;
+ ~MDLImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/MDL/MDLMaterialLoader.cpp b/code/AssetLib/MDL/MDLMaterialLoader.cpp
index 3d39fa645..38c42c1a5 100644
--- a/code/AssetLib/MDL/MDLMaterialLoader.cpp
+++ b/code/AssetLib/MDL/MDLMaterialLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -123,9 +123,8 @@ aiColor4D MDLImporter::ReplaceTextureWithColor(const aiTexture *pcTexture) {
// Read a texture from a MDL3 file
void MDLImporter::CreateTextureARGB8_3DGS_MDL3(const unsigned char *szData) {
const MDL::Header *pcHeader = (const MDL::Header *)mBuffer; //the endianness is already corrected in the InternReadFile_3DGS_MDL345 function
-
- VALIDATE_FILE_SIZE(szData + pcHeader->skinwidth *
- pcHeader->skinheight);
+ const size_t len = pcHeader->skinwidth * pcHeader->skinheight;
+ VALIDATE_FILE_SIZE(szData + len);
// allocate a new texture object
aiTexture *pcNew = new aiTexture();
diff --git a/code/AssetLib/MMD/MMDCpp14.h b/code/AssetLib/MMD/MMDCpp14.h
index 10d376829..4a04bf69e 100644
--- a/code/AssetLib/MMD/MMDCpp14.h
+++ b/code/AssetLib/MMD/MMDCpp14.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MMD/MMDImporter.cpp b/code/AssetLib/MMD/MMDImporter.cpp
index 0905ce1e0..1e88cefd2 100644
--- a/code/AssetLib/MMD/MMDImporter.cpp
+++ b/code/AssetLib/MMD/MMDImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory>
#include <sstream>
-static const aiImporterDesc desc = { "MMD Importer",
+static constexpr aiImporterDesc desc = { "MMD Importer",
"",
"",
"surfaces supported?",
@@ -82,10 +82,6 @@ MMDImporter::MMDImporter() :
}
// ------------------------------------------------------------------------------------------------
-// Destructor.
-MMDImporter::~MMDImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns true, if file is an pmx file.
bool MMDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler,
bool /*checkSig*/) const {
diff --git a/code/AssetLib/MMD/MMDImporter.h b/code/AssetLib/MMD/MMDImporter.h
index 36f384829..71fc534a4 100644
--- a/code/AssetLib/MMD/MMDImporter.h
+++ b/code/AssetLib/MMD/MMDImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -50,46 +50,34 @@ struct aiMesh;
namespace Assimp {
// ------------------------------------------------------------------------------------------------
-/// \class MMDImporter
-/// \brief Imports MMD a pmx/pmd/vmd file
+/// @class MMDImporter
+/// @brief Imports MMD a pmx/pmd/vmd file
// ------------------------------------------------------------------------------------------------
class MMDImporter : public BaseImporter {
public:
- /// \brief Default constructor
+ /// @brief Default constructor
MMDImporter();
- /// \brief Destructor
- ~MMDImporter() override;
+ /// @brief Destructor
+ ~MMDImporter() override = default;
public:
- /// \brief Returns whether the class can handle the format of the given file.
- /// \remark See BaseImporter::CanRead() for details.
+ /// @brief Returns whether the class can handle the format of the given file.
+ /// @remark See BaseImporter::CanRead() for details.
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override;
private:
- //! \brief Appends the supported extension.
const aiImporterDesc* GetInfo() const override;
-
- //! \brief File import implementation.
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
-
- //! \brief Create the data from imported content.
void CreateDataFromImport(const pmx::PmxModel* pModel, aiScene* pScene);
-
- //! \brief Create the mesh
aiMesh* CreateMesh(const pmx::PmxModel* pModel, const int indexStart, const int indexCount);
-
- //! \brief Create the material
aiMaterial* CreateMaterial(const pmx::PmxMaterial* pMat, const pmx::PmxModel* pModel);
private:
- //! Data buffer
std::vector<char> m_Buffer;
- //! Absolute pathname of model in file system
std::string m_strAbsPath;
};
-// ------------------------------------------------------------------------------------------------
} // Namespace Assimp
diff --git a/code/AssetLib/MMD/MMDPmdParser.h b/code/AssetLib/MMD/MMDPmdParser.h
index 23aaac555..b11c72f8d 100644
--- a/code/AssetLib/MMD/MMDPmdParser.h
+++ b/code/AssetLib/MMD/MMDPmdParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MMD/MMDPmxParser.cpp b/code/AssetLib/MMD/MMDPmxParser.cpp
index ca37ba199..5a3e61dcd 100644
--- a/code/AssetLib/MMD/MMDPmxParser.cpp
+++ b/code/AssetLib/MMD/MMDPmxParser.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -42,11 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <utility>
#include "MMDPmxParser.h"
#include <assimp/StringUtils.h>
-#ifdef ASSIMP_USE_HUNTER
-# include <utf8.h>
-#else
-# include "../contrib/utf8cpp/source/utf8.h"
-#endif
+#include "utf8.h"
#include <assimp/Exceptional.h>
namespace pmx
@@ -93,7 +89,7 @@ namespace pmx
{
return std::string();
}
- buffer.reserve(size);
+ buffer.resize(size);
stream->read((char*) buffer.data(), size);
if (encoding == 0)
{
diff --git a/code/AssetLib/MMD/MMDPmxParser.h b/code/AssetLib/MMD/MMDPmxParser.h
index 424fc725a..e90e554e7 100644
--- a/code/AssetLib/MMD/MMDPmxParser.h
+++ b/code/AssetLib/MMD/MMDPmxParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MMD/MMDVmdParser.h b/code/AssetLib/MMD/MMDVmdParser.h
index d5c7dedff..2ba9fb931 100644
--- a/code/AssetLib/MMD/MMDVmdParser.h
+++ b/code/AssetLib/MMD/MMDVmdParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MS3D/MS3DLoader.cpp b/code/AssetLib/MS3D/MS3DLoader.cpp
index d4dd2be75..fac102f5f 100644
--- a/code/AssetLib/MS3D/MS3DLoader.cpp
+++ b/code/AssetLib/MS3D/MS3DLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
@@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Milkshape 3D Importer",
"",
"",
@@ -85,9 +85,6 @@ MS3DImporter::MS3DImporter()
{}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-MS3DImporter::~MS3DImporter() = default;
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool MS3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
{
diff --git a/code/AssetLib/MS3D/MS3DLoader.h b/code/AssetLib/MS3D/MS3DLoader.h
index 4bd417566..5a28391eb 100644
--- a/code/AssetLib/MS3D/MS3DLoader.h
+++ b/code/AssetLib/MS3D/MS3DLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/BaseImporter.h>
#include <assimp/StreamReader.h>
+
struct aiNode;
namespace Assimp {
@@ -58,7 +59,7 @@ namespace Assimp {
class MS3DImporter : public BaseImporter {
public:
MS3DImporter();
- ~MS3DImporter() override;
+ ~MS3DImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/NDO/NDOLoader.cpp b/code/AssetLib/NDO/NDOLoader.cpp
index edccc1624..3515c14b4 100644
--- a/code/AssetLib/NDO/NDOLoader.cpp
+++ b/code/AssetLib/NDO/NDOLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -43,8 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Implementation of the NDO importer class.
*/
-
#ifndef ASSIMP_BUILD_NO_NDO_IMPORTER
+
#include "NDOLoader.h"
#include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp>
@@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Nendo Mesh Importer",
"",
"",
@@ -70,14 +70,6 @@ static const aiImporterDesc desc = {
};
// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-NDOImporter::NDOImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-NDOImporter::~NDOImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool NDOImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
{
diff --git a/code/AssetLib/NDO/NDOLoader.h b/code/AssetLib/NDO/NDOLoader.h
index 61dd93981..c3ab15230 100644
--- a/code/AssetLib/NDO/NDOLoader.h
+++ b/code/AssetLib/NDO/NDOLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -65,8 +65,8 @@ class Importer;
*/
class NDOImporter : public BaseImporter {
public:
- NDOImporter();
- ~NDOImporter() override;
+ NDOImporter() = default;
+ ~NDOImporter() override = default;
//! Represents a single edge
struct Edge {
diff --git a/code/AssetLib/NFF/NFFLoader.cpp b/code/AssetLib/NFF/NFFLoader.cpp
index ce7007155..481a4bc19 100644
--- a/code/AssetLib/NFF/NFFLoader.cpp
+++ b/code/AssetLib/NFF/NFFLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -56,9 +56,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp>
#include <memory>
-using namespace Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Neutral File Format Importer",
"",
"",
@@ -72,14 +72,6 @@ static const aiImporterDesc desc = {
};
// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-NFFImporter::NFFImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-NFFImporter::~NFFImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool NFFImporter::CanRead(const std::string & pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
return SimpleExtensionCheck(pFile, "nff", "enff");
@@ -93,8 +85,8 @@ const aiImporterDesc *NFFImporter::GetInfo() const {
// ------------------------------------------------------------------------------------------------
#define AI_NFF_PARSE_FLOAT(f) \
- SkipSpaces(&sz); \
- if (!::IsLineEnd(*sz)) sz = fast_atoreal_move<ai_real>(sz, (ai_real &)f);
+ SkipSpaces(&sz, lineEnd); \
+ if (!IsLineEnd(*sz)) sz = fast_atoreal_move<ai_real>(sz, (ai_real &)f);
// ------------------------------------------------------------------------------------------------
#define AI_NFF_PARSE_TRIPLE(v) \
@@ -119,7 +111,7 @@ const aiImporterDesc *NFFImporter::GetInfo() const {
ASSIMP_LOG_WARN("NFF2: Unexpected EOF, can't read next token"); \
break; \
} \
- SkipSpaces(line, &sz); \
+ SkipSpaces(line, &sz, lineEnd); \
} while (IsLineEnd(*sz))
// ------------------------------------------------------------------------------------------------
@@ -156,9 +148,9 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector<ShadingInfo> &output,
// No read the file line per line
char line[4096];
- const char *sz;
+ const char *sz, *lineEnd = &line[2095]+1;
while (GetNextLine(buffer, line)) {
- SkipSpaces(line, &sz);
+ SkipSpaces(line, &sz, lineEnd);
// 'version' defines the version of the file format
if (TokenMatch(sz, "version", 7)) {
@@ -206,18 +198,16 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector<ShadingInfo> &output,
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
-void NFFImporter::InternReadFile(const std::string &pFile,
- aiScene *pScene, IOSystem *pIOHandler) {
- std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
-
- // Check whether we can read from the file
- if (!file)
- throw DeadlyImportError("Failed to open NFF file ", pFile, ".");
+void NFFImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) {
+ std::unique_ptr<IOStream> stream(pIOHandler->Open(file, "rb"));
+ if (!stream) {
+ throw DeadlyImportError("Failed to open NFF file ", file, ".");
+ }
// allocate storage and copy the contents of the file to a memory buffer
// (terminate it with zero)
std::vector<char> mBuffer2;
- TextFileToBuffer(file.get(), mBuffer2);
+ TextFileToBuffer(stream.get(), mBuffer2);
const char *buffer = &mBuffer2[0];
// mesh arrays - separate here to make the handling of the pointers below easier.
@@ -227,8 +217,10 @@ void NFFImporter::InternReadFile(const std::string &pFile,
std::vector<MeshInfo> meshesLocked;
char line[4096];
+ const char *lineEnd = &line[4096];
const char *sz;
+
// camera parameters
aiVector3D camPos, camUp(0.f, 1.f, 0.f), camLookAt(0.f, 0.f, 1.f);
ai_real angle = 45.f;
@@ -273,7 +265,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
CommentRemover::RemoveLineComments("//", &mBuffer2[0]);
while (GetNextLine(buffer, line)) {
- SkipSpaces(line, &sz);
+ SkipSpaces(line, &sz, lineEnd);
if (TokenMatch(sz, "version", 7)) {
ASSIMP_LOG_INFO("NFF (Sense8) file format: ", sz);
} else if (TokenMatch(sz, "viewpos", 7)) {
@@ -303,7 +295,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// material table - an external file
if (TokenMatch(sz, "mtable", 6)) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz3 = sz;
while (!IsSpaceOrNewLine(*sz))
++sz;
@@ -324,12 +316,12 @@ void NFFImporter::InternReadFile(const std::string &pFile,
std::string::size_type sepPos;
if ((std::string::npos == (sepPos = path.find_last_of('\\')) || !sepPos) &&
(std::string::npos == (sepPos = path.find_last_of('/')) || !sepPos)) {
- sepPos = pFile.find_last_of('\\');
+ sepPos = file.find_last_of('\\');
if (std::string::npos == sepPos) {
- sepPos = pFile.find_last_of('/');
+ sepPos = file.find_last_of('/');
}
if (std::string::npos != sepPos) {
- path = pFile.substr(0, sepPos + 1) + path;
+ path = file.substr(0, sepPos + 1) + path;
}
}
LoadNFF2MaterialTable(materialTable, path, pIOHandler);
@@ -338,8 +330,8 @@ void NFFImporter::InternReadFile(const std::string &pFile,
break;
}
- // read the numbr of vertices
- unsigned int num = ::strtoul10(sz, &sz);
+ // read the number of vertices
+ unsigned int num = strtoul10(sz, &sz);
// temporary storage
std::vector<aiColor4D> tempColors;
@@ -359,13 +351,13 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// parse all other attributes in the line
while (true) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
if (IsLineEnd(*sz)) break;
// color definition
if (TokenMatch(sz, "0x", 2)) {
hasColor = true;
- unsigned int numIdx = ::strtoul16(sz, &sz);
+ unsigned int numIdx = strtoul16(sz, &sz);
aiColor4D clr;
clr.a = 1.f;
@@ -403,30 +395,28 @@ void NFFImporter::InternReadFile(const std::string &pFile,
}
AI_NFF2_GET_NEXT_TOKEN();
- if (!num) throw DeadlyImportError("NFF2: There are zero vertices");
- num = ::strtoul10(sz, &sz);
+ if (!num)
+ throw DeadlyImportError("NFF2: There are zero vertices");
+ num = strtoul10(sz, &sz);
std::vector<unsigned int> tempIdx;
tempIdx.reserve(10);
for (unsigned int i = 0; i < num; ++i) {
AI_NFF2_GET_NEXT_TOKEN();
- SkipSpaces(line, &sz);
- unsigned int numIdx = ::strtoul10(sz, &sz);
+ SkipSpaces(line, &sz, lineEnd);
+ unsigned int numIdx = strtoul10(sz, &sz);
// read all faces indices
if (numIdx) {
- // mesh.faces.push_back(numIdx);
- // tempIdx.erase(tempIdx.begin(),tempIdx.end());
tempIdx.resize(numIdx);
for (unsigned int a = 0; a < numIdx; ++a) {
- SkipSpaces(sz, &sz);
- unsigned int m = ::strtoul10(sz, &sz);
+ SkipSpaces(sz, &sz, lineEnd);
+ unsigned int m = strtoul10(sz, &sz);
if (m >= (unsigned int)tempPositions.size()) {
ASSIMP_LOG_ERROR("NFF2: Vertex index overflow");
m = 0;
}
- // mesh.vertices.push_back (tempPositions[idx]);
tempIdx[a] = m;
}
}
@@ -439,14 +429,14 @@ void NFFImporter::InternReadFile(const std::string &pFile,
shader.color = aiColor3D(1.f, 1.f, 1.f);
aiColor4D c = aiColor4D(1.f, 1.f, 1.f, 1.f);
while (true) {
- SkipSpaces(sz, &sz);
+ SkipSpaces(sz, &sz, lineEnd);
if (IsLineEnd(*sz)) break;
// per-polygon colors
if (TokenMatch(sz, "0x", 2)) {
hasColor = true;
const char *sz2 = sz;
- numIdx = ::strtoul16(sz, &sz);
+ numIdx = strtoul16(sz, &sz);
const unsigned int diff = (unsigned int)(sz - sz2);
// 0xRRGGBB
@@ -517,8 +507,8 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// Material ID?
else if (!materialTable.empty() && TokenMatch(sz, "matid", 5)) {
- SkipSpaces(&sz);
- matIdx = ::strtoul10(sz, &sz);
+ SkipSpaces(&sz, lineEnd);
+ matIdx = strtoul10(sz, &sz);
if (matIdx >= materialTable.size()) {
ASSIMP_LOG_ERROR("NFF2: Material index overflow.");
matIdx = 0;
@@ -534,7 +524,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
shader.specular = mat.specular;
shader.shininess = mat.shininess;
} else
- SkipToken(sz);
+ SkipToken(sz, lineEnd);
}
// search the list of all shaders we have for this object whether
@@ -656,7 +646,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
sz = &line[1];
out = currentMesh;
}
- SkipSpaces(sz, &sz);
+ SkipSpaces(sz, &sz, lineEnd);
unsigned int m = strtoul10(sz);
// ---- flip the face order
@@ -684,13 +674,13 @@ void NFFImporter::InternReadFile(const std::string &pFile,
}
if (out == currentMeshWithUVCoords) {
// FIX: in one test file this wraps over multiple lines
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
if (IsLineEnd(*sz)) {
GetNextLine(buffer, line);
sz = line;
}
AI_NFF_PARSE_FLOAT(v.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
if (IsLineEnd(*sz)) {
GetNextLine(buffer, line);
sz = line;
@@ -724,7 +714,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// if the next one is NOT a number we assume it is a texture file name
// this feature is used by some NFF files on the internet and it has
// been implemented as it can be really useful
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
if (!IsNumeric(*sz)) {
// TODO: Support full file names with spaces and quotation marks ...
const char *p = sz;
@@ -738,10 +728,8 @@ void NFFImporter::InternReadFile(const std::string &pFile,
} else {
AI_NFF_PARSE_FLOAT(s.ambient); // optional
}
- }
- // 'shader' - other way to specify a texture
- else if (TokenMatch(sz, "shader", 6)) {
- SkipSpaces(&sz);
+ } else if (TokenMatch(sz, "shader", 6)) { // 'shader' - other way to specify a texture
+ SkipSpaces(&sz, lineEnd);
const char *old = sz;
while (!IsSpaceOrNewLine(*sz))
++sz;
@@ -896,7 +884,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
}
// 'tess' - tessellation
else if (TokenMatch(sz, "tess", 4)) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
iTesselation = strtoul10(sz);
}
// 'from' - camera position
@@ -936,7 +924,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// '' - comment
else if ('#' == line[0]) {
const char *space;
- SkipSpaces(&line[1], &space);
+ SkipSpaces(&line[1], &space, lineEnd);
if (!IsLineEnd(*space)) {
ASSIMP_LOG_INFO(space);
}
@@ -1165,4 +1153,6 @@ void NFFImporter::InternReadFile(const std::string &pFile,
pScene->mRootNode = root;
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_NFF_IMPORTER
diff --git a/code/AssetLib/NFF/NFFLoader.h b/code/AssetLib/NFF/NFFLoader.h
index 7fd094306..dfa6a882f 100644
--- a/code/AssetLib/NFF/NFFLoader.h
+++ b/code/AssetLib/NFF/NFFLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -63,8 +63,8 @@ namespace Assimp {
*/
class NFFImporter : public BaseImporter {
public:
- NFFImporter();
- ~NFFImporter() override;
+ NFFImporter() = default;
+ ~NFFImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/OFF/OFFLoader.cpp b/code/AssetLib/OFF/OFFLoader.cpp
index f50afb57b..566e3212e 100644
--- a/code/AssetLib/OFF/OFFLoader.cpp
+++ b/code/AssetLib/OFF/OFFLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Implementation of the OFF importer class
*/
-
#ifndef ASSIMP_BUILD_NO_OFF_IMPORTER
// internal headers
@@ -56,9 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp>
#include <assimp/importerdesc.h>
-using namespace Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"OFF Importer",
"",
"",
@@ -72,98 +71,91 @@ static const aiImporterDesc desc = {
};
// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-OFFImporter::OFFImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-OFFImporter::~OFFImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
-bool OFFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
-{
- static const char* tokens[] = { "off" };
- return SearchFileHeaderForToken(pIOHandler,pFile,tokens,AI_COUNT_OF(tokens),3);
+bool OFFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
+ static const char *tokens[] = { "off" };
+ return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens), 3);
}
// ------------------------------------------------------------------------------------------------
-const aiImporterDesc* OFFImporter::GetInfo () const
-{
+const aiImporterDesc *OFFImporter::GetInfo() const {
return &desc;
}
-
// skip blank space, lines and comments
-static void NextToken(const char **car, const char* end) {
- SkipSpacesAndLineEnd(car);
- while (*car < end && (**car == '#' || **car == '\n' || **car == '\r')) {
- SkipLine(car);
- SkipSpacesAndLineEnd(car);
- }
+static void NextToken(const char **car, const char *end) {
+ SkipSpacesAndLineEnd(car, end);
+ while (*car < end && (**car == '#' || **car == '\n' || **car == '\r')) {
+ SkipLine(car, end);
+ SkipSpacesAndLineEnd(car, end);
+ }
}
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
-void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
- std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
+void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
+ std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
// Check whether we can read from the file
if (file == nullptr) {
- throw DeadlyImportError("Failed to open OFF file ", pFile, ".");
+ throw DeadlyImportError("Failed to open OFF file ", pFile, ".");
}
// allocate storage and copy the contents of the file to a memory buffer
std::vector<char> mBuffer2;
- TextFileToBuffer(file.get(),mBuffer2);
- const char* buffer = &mBuffer2[0];
+ TextFileToBuffer(file.get(), mBuffer2);
+ const char *buffer = &mBuffer2[0];
// Proper OFF header parser. We only implement normal loading for now.
bool hasTexCoord = false, hasNormals = false, hasColors = false;
bool hasHomogenous = false, hasDimension = false;
unsigned int dimensions = 3;
- const char* car = buffer;
- const char* end = buffer + mBuffer2.size();
+ const char *car = buffer;
+ const char *end = buffer + mBuffer2.size();
NextToken(&car, end);
if (car < end - 2 && car[0] == 'S' && car[1] == 'T') {
- hasTexCoord = true; car += 2;
+ hasTexCoord = true;
+ car += 2;
}
if (car < end - 1 && car[0] == 'C') {
- hasColors = true; car++;
+ hasColors = true;
+ car++;
}
- if (car < end- 1 && car[0] == 'N') {
- hasNormals = true; car++;
+ if (car < end - 1 && car[0] == 'N') {
+ hasNormals = true;
+ car++;
}
if (car < end - 1 && car[0] == '4') {
- hasHomogenous = true; car++;
+ hasHomogenous = true;
+ car++;
}
if (car < end - 1 && car[0] == 'n') {
- hasDimension = true; car++;
+ hasDimension = true;
+ car++;
}
if (car < end - 3 && car[0] == 'O' && car[1] == 'F' && car[2] == 'F') {
car += 3;
- NextToken(&car, end);
+ NextToken(&car, end);
} else {
- // in case there is no OFF header (which is allowed by the
- // specification...), then we might have unintentionally read an
- // additional dimension from the primitive count fields
- dimensions = 3;
- hasHomogenous = false;
- NextToken(&car, end);
-
- // at this point the next token should be an integer number
- if (car >= end - 1 || *car < '0' || *car > '9') {
- throw DeadlyImportError("OFF: Header is invalid");
- }
+ // in case there is no OFF header (which is allowed by the
+ // specification...), then we might have unintentionally read an
+ // additional dimension from the primitive count fields
+ dimensions = 3;
+ hasHomogenous = false;
+ NextToken(&car, end);
+
+ // at this point the next token should be an integer number
+ if (car >= end - 1 || *car < '0' || *car > '9') {
+ throw DeadlyImportError("OFF: Header is invalid");
+ }
}
if (hasDimension) {
dimensions = strtoul10(car, &car);
- NextToken(&car, end);
+ NextToken(&car, end);
}
if (dimensions > 3) {
- throw DeadlyImportError
- ("OFF: Number of vertex coordinates higher than 3 unsupported");
+ throw DeadlyImportError("OFF: Number of vertex coordinates higher than 3 unsupported");
}
NextToken(&car, end);
@@ -171,7 +163,7 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
NextToken(&car, end);
const unsigned int numFaces = strtoul10(car, &car);
NextToken(&car, end);
- strtoul10(car, &car); // skip edge count
+ strtoul10(car, &car); // skip edge count
NextToken(&car, end);
if (!numVertices) {
@@ -182,13 +174,13 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
}
pScene->mNumMeshes = 1;
- pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
+ pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
- aiMesh* mesh = new aiMesh();
+ aiMesh *mesh = new aiMesh();
pScene->mMeshes[0] = mesh;
mesh->mNumFaces = numFaces;
- aiFace* faces = new aiFace[mesh->mNumFaces];
+ aiFace *faces = new aiFace[mesh->mNumFaces];
mesh->mFaces = faces;
mesh->mNumVertices = numVertices;
@@ -203,103 +195,105 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
char line[4096];
buffer = car;
const char *sz = car;
+ const char *lineEnd = &line[4096];
// now read all vertex lines
for (unsigned int i = 0; i < numVertices; ++i) {
- if(!GetNextLine(buffer, line)) {
+ if (!GetNextLine(buffer, line)) {
ASSIMP_LOG_ERROR("OFF: The number of verts in the header is incorrect");
break;
}
- aiVector3D& v = mesh->mVertices[i];
+ aiVector3D &v = mesh->mVertices[i];
sz = line;
- // helper array to write a for loop over possible dimension values
- ai_real* vec[3] = {&v.x, &v.y, &v.z};
-
- // stop at dimensions: this allows loading 1D or 2D coordinate vertices
- for (unsigned int dim = 0; dim < dimensions; ++dim ) {
- SkipSpaces(&sz);
- sz = fast_atoreal_move<ai_real>(sz, *vec[dim]);
- }
-
- // if has homogeneous coordinate, divide others by this one
- if (hasHomogenous) {
- SkipSpaces(&sz);
- ai_real w = 1.;
- sz = fast_atoreal_move<ai_real>(sz, w);
- for (unsigned int dim = 0; dim < dimensions; ++dim ) {
- *(vec[dim]) /= w;
- }
- }
-
- // read optional normals
- if (hasNormals) {
- aiVector3D& n = mesh->mNormals[i];
- SkipSpaces(&sz);
- sz = fast_atoreal_move<ai_real>(sz,(ai_real&)n.x);
- SkipSpaces(&sz);
- sz = fast_atoreal_move<ai_real>(sz,(ai_real&)n.y);
- SkipSpaces(&sz);
- fast_atoreal_move<ai_real>(sz,(ai_real&)n.z);
- }
-
- // reading colors is a pain because the specification says it can be
- // integers or floats, and any number of them between 1 and 4 included,
- // until the next comment or end of line
- // in theory should be testing type !
- if (hasColors) {
- aiColor4D& c = mesh->mColors[0][i];
- SkipSpaces(&sz);
- sz = fast_atoreal_move<ai_real>(sz,(ai_real&)c.r);
+ // helper array to write a for loop over possible dimension values
+ ai_real *vec[3] = { &v.x, &v.y, &v.z };
+
+ // stop at dimensions: this allows loading 1D or 2D coordinate vertices
+ for (unsigned int dim = 0; dim < dimensions; ++dim) {
+ SkipSpaces(&sz, lineEnd);
+ sz = fast_atoreal_move<ai_real>(sz, *vec[dim]);
+ }
+
+ // if has homogeneous coordinate, divide others by this one
+ if (hasHomogenous) {
+ SkipSpaces(&sz, lineEnd);
+ ai_real w = 1.;
+ sz = fast_atoreal_move<ai_real>(sz, w);
+ for (unsigned int dim = 0; dim < dimensions; ++dim) {
+ *(vec[dim]) /= w;
+ }
+ }
+
+ // read optional normals
+ if (hasNormals) {
+ aiVector3D &n = mesh->mNormals[i];
+ SkipSpaces(&sz, lineEnd);
+ sz = fast_atoreal_move<ai_real>(sz, (ai_real &)n.x);
+ SkipSpaces(&sz, lineEnd);
+ sz = fast_atoreal_move<ai_real>(sz, (ai_real &)n.y);
+ SkipSpaces(&sz, lineEnd);
+ fast_atoreal_move<ai_real>(sz, (ai_real &)n.z);
+ }
+
+ // reading colors is a pain because the specification says it can be
+ // integers or floats, and any number of them between 1 and 4 included,
+ // until the next comment or end of line
+ // in theory should be testing type !
+ if (hasColors) {
+ aiColor4D &c = mesh->mColors[0][i];
+ SkipSpaces(&sz, lineEnd);
+ sz = fast_atoreal_move<ai_real>(sz, (ai_real &)c.r);
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
- SkipSpaces(&sz);
- sz = fast_atoreal_move<ai_real>(sz,(ai_real&)c.g);
+ SkipSpaces(&sz, lineEnd);
+ sz = fast_atoreal_move<ai_real>(sz, (ai_real &)c.g);
} else {
- c.g = 0.;
- }
+ c.g = 0.;
+ }
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
- SkipSpaces(&sz);
- sz = fast_atoreal_move<ai_real>(sz,(ai_real&)c.b);
+ SkipSpaces(&sz, lineEnd);
+ sz = fast_atoreal_move<ai_real>(sz, (ai_real &)c.b);
} else {
- c.b = 0.;
- }
+ c.b = 0.;
+ }
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
- SkipSpaces(&sz);
- sz = fast_atoreal_move<ai_real>(sz,(ai_real&)c.a);
+ SkipSpaces(&sz, lineEnd);
+ sz = fast_atoreal_move<ai_real>(sz, (ai_real &)c.a);
} else {
- c.a = 1.;
- }
- }
+ c.a = 1.;
+ }
+ }
if (hasTexCoord) {
- aiVector3D& t = mesh->mTextureCoords[0][i];
- SkipSpaces(&sz);
- sz = fast_atoreal_move<ai_real>(sz,(ai_real&)t.x);
- SkipSpaces(&sz);
- fast_atoreal_move<ai_real>(sz,(ai_real&)t.y);
- }
+ aiVector3D &t = mesh->mTextureCoords[0][i];
+ SkipSpaces(&sz, lineEnd);
+ sz = fast_atoreal_move<ai_real>(sz, (ai_real &)t.x);
+ SkipSpaces(&sz, lineEnd);
+ fast_atoreal_move<ai_real>(sz, (ai_real &)t.y);
+ }
}
// load faces with their indices
faces = mesh->mFaces;
- for (unsigned int i = 0; i < numFaces; ) {
- if(!GetNextLine(buffer,line)) {
+ for (unsigned int i = 0; i < numFaces;) {
+ if (!GetNextLine(buffer, line)) {
ASSIMP_LOG_ERROR("OFF: The number of faces in the header is incorrect");
throw DeadlyImportError("OFF: The number of faces in the header is incorrect");
}
unsigned int idx;
- sz = line; SkipSpaces(&sz);
- idx = strtoul10(sz,&sz);
- if(!idx || idx > 9) {
- ASSIMP_LOG_ERROR("OFF: Faces with zero indices aren't allowed");
+ sz = line;
+ SkipSpaces(&sz, lineEnd);
+ idx = strtoul10(sz, &sz);
+ if (!idx || idx > 9) {
+ ASSIMP_LOG_ERROR("OFF: Faces with zero indices aren't allowed");
--mesh->mNumFaces;
++i;
continue;
- }
- faces->mNumIndices = idx;
+ }
+ faces->mNumIndices = idx;
faces->mIndices = new unsigned int[faces->mNumIndices];
- for (unsigned int m = 0; m < faces->mNumIndices;++m) {
- SkipSpaces(&sz);
- idx = strtoul10(sz,&sz);
+ for (unsigned int m = 0; m < faces->mNumIndices; ++m) {
+ SkipSpaces(&sz, lineEnd);
+ idx = strtoul10(sz, &sz);
if (idx >= numVertices) {
ASSIMP_LOG_ERROR("OFF: Vertex index is out of range");
idx = numVertices - 1;
@@ -314,20 +308,22 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
pScene->mRootNode = new aiNode();
pScene->mRootNode->mName.Set("<OFFRoot>");
pScene->mRootNode->mNumMeshes = 1;
- pScene->mRootNode->mMeshes = new unsigned int [pScene->mRootNode->mNumMeshes];
+ pScene->mRootNode->mMeshes = new unsigned int[pScene->mRootNode->mNumMeshes];
pScene->mRootNode->mMeshes[0] = 0;
// generate a default material
pScene->mNumMaterials = 1;
- pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
- aiMaterial* pcMat = new aiMaterial();
+ pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
+ aiMaterial *pcMat = new aiMaterial();
- aiColor4D clr( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 1.0 ) );
- pcMat->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
+ aiColor4D clr(ai_real(0.6), ai_real(0.6), ai_real(0.6), ai_real(1.0));
+ pcMat->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
pScene->mMaterials[0] = pcMat;
const int twosided = 1;
pcMat->AddProperty(&twosided, 1, AI_MATKEY_TWOSIDED);
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_OFF_IMPORTER
diff --git a/code/AssetLib/OFF/OFFLoader.h b/code/AssetLib/OFF/OFFLoader.h
index 04bb7f481..02829d360 100644
--- a/code/AssetLib/OFF/OFFLoader.h
+++ b/code/AssetLib/OFF/OFFLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -57,8 +57,8 @@ namespace Assimp {
*/
class OFFImporter : public BaseImporter {
public:
- OFFImporter();
- ~OFFImporter() override;
+ OFFImporter() = default;
+ ~OFFImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/Obj/ObjExporter.cpp b/code/AssetLib/Obj/ObjExporter.cpp
index a5d8325fc..7c5c051f3 100644
--- a/code/AssetLib/Obj/ObjExporter.cpp
+++ b/code/AssetLib/Obj/ObjExporter.cpp
@@ -59,9 +59,9 @@ namespace Assimp {
// ------------------------------------------------------------------------------------------------
// Worker function for exporting a scene to Wavefront OBJ. Prototyped and registered in Exporter.cpp
-void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) {
+void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* props) {
// invoke the exporter
- ObjExporter exporter(pFile, pScene);
+ ObjExporter exporter(pFile, pScene, false, props);
if (exporter.mOutput.fail() || exporter.mOutputMat.fail()) {
throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile));
@@ -86,9 +86,9 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
// ------------------------------------------------------------------------------------------------
// Worker function for exporting a scene to Wavefront OBJ without the material file. Prototyped and registered in Exporter.cpp
-void ExportSceneObjNoMtl(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* ) {
+void ExportSceneObjNoMtl(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* props) {
// invoke the exporter
- ObjExporter exporter(pFile, pScene, true);
+ ObjExporter exporter(pFile, pScene, true, props);
if (exporter.mOutput.fail() || exporter.mOutputMat.fail()) {
throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile));
@@ -111,7 +111,7 @@ void ExportSceneObjNoMtl(const char* pFile,IOSystem* pIOSystem, const aiScene* p
static const std::string MaterialExt = ".mtl";
// ------------------------------------------------------------------------------------------------
-ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMtl)
+ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMtl, const ExportProperties* props)
: filename(_filename)
, pScene(pScene)
, vn()
@@ -130,7 +130,10 @@ ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMt
mOutputMat.imbue(l);
mOutputMat.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
- WriteGeometryFile(noMtl);
+ WriteGeometryFile(
+ noMtl,
+ props == nullptr ? true : props->GetPropertyBool("bJoinIdenticalVertices", true)
+ );
if ( !noMtl ) {
WriteMaterialFile();
}
@@ -255,14 +258,14 @@ void ObjExporter::WriteMaterialFile() {
}
}
-void ObjExporter::WriteGeometryFile(bool noMtl) {
+void ObjExporter::WriteGeometryFile(bool noMtl, bool merge_identical_vertices) {
WriteHeader(mOutput);
if (!noMtl)
mOutput << "mtllib " << GetMaterialLibName() << endl << endl;
// collect mesh geometry
aiMatrix4x4 mBase;
- AddNode(pScene->mRootNode, mBase);
+ AddNode(pScene->mRootNode, mBase, merge_identical_vertices);
// write vertex positions with colors, if any
mVpMap.getKeys( vp );
@@ -330,7 +333,7 @@ void ObjExporter::WriteGeometryFile(bool noMtl) {
}
// ------------------------------------------------------------------------------------------------
-void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat) {
+void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat, bool merge_identical_vertices) {
mMeshes.emplace_back();
MeshInstance& mesh = mMeshes.back();
@@ -362,13 +365,14 @@ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4
for(unsigned int a = 0; a < f.mNumIndices; ++a) {
const unsigned int idx = f.mIndices[a];
+ const unsigned int fi = merge_identical_vertices ? 0 : idx;
aiVector3D vert = mat * m->mVertices[idx];
if ( nullptr != m->mColors[ 0 ] ) {
aiColor4D col4 = m->mColors[ 0 ][ idx ];
- face.indices[a].vp = mVpMap.getIndex({vert, aiColor3D(col4.r, col4.g, col4.b)});
+ face.indices[a].vp = mVpMap.getIndex({vert, aiColor3D(col4.r, col4.g, col4.b), fi});
} else {
- face.indices[a].vp = mVpMap.getIndex({vert, aiColor3D(0,0,0)});
+ face.indices[a].vp = mVpMap.getIndex({vert, aiColor3D(0,0,0), fi});
}
if (m->mNormals) {
@@ -388,21 +392,21 @@ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4
}
// ------------------------------------------------------------------------------------------------
-void ObjExporter::AddNode(const aiNode* nd, const aiMatrix4x4& mParent) {
+void ObjExporter::AddNode(const aiNode* nd, const aiMatrix4x4& mParent, bool merge_identical_vertices) {
const aiMatrix4x4& mAbs = mParent * nd->mTransformation;
aiMesh *cm( nullptr );
for(unsigned int i = 0; i < nd->mNumMeshes; ++i) {
cm = pScene->mMeshes[nd->mMeshes[i]];
if (nullptr != cm) {
- AddMesh(cm->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs);
+ AddMesh(cm->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs, merge_identical_vertices);
} else {
- AddMesh(nd->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs);
+ AddMesh(nd->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs, merge_identical_vertices);
}
}
for(unsigned int i = 0; i < nd->mNumChildren; ++i) {
- AddNode(nd->mChildren[i], mAbs);
+ AddNode(nd->mChildren[i], mAbs, merge_identical_vertices);
}
}
diff --git a/code/AssetLib/Obj/ObjExporter.h b/code/AssetLib/Obj/ObjExporter.h
index a64f38f74..4c92aa16f 100644
--- a/code/AssetLib/Obj/ObjExporter.h
+++ b/code/AssetLib/Obj/ObjExporter.h
@@ -51,6 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include <map>
+#include <assimp/Exporter.hpp>
+
struct aiScene;
struct aiNode;
struct aiMesh;
@@ -63,7 +65,7 @@ namespace Assimp {
class ObjExporter {
public:
/// Constructor for a specific scene to export
- ObjExporter(const char* filename, const aiScene* pScene, bool noMtl=false);
+ ObjExporter(const char* filename, const aiScene* pScene, bool noMtl=false, const ExportProperties* props = nullptr);
~ObjExporter();
std::string GetMaterialLibName();
std::string GetMaterialLibFileName();
@@ -97,10 +99,10 @@ private:
void WriteHeader(std::ostringstream& out);
void WriteMaterialFile();
- void WriteGeometryFile(bool noMtl=false);
+ void WriteGeometryFile(bool noMtl=false, bool merge_identical_vertices = false);
std::string GetMaterialName(unsigned int index);
- void AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat);
- void AddNode(const aiNode* nd, const aiMatrix4x4& mParent);
+ void AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat, bool merge_identical_vertices);
+ void AddNode(const aiNode* nd, const aiMatrix4x4& mParent, bool merge_identical_vertices);
private:
std::string filename;
@@ -109,6 +111,7 @@ private:
struct vertexData {
aiVector3D vp;
aiColor3D vc; // OBJ does not support 4D color
+ uint32_t index = 0;
};
std::vector<aiVector3D> vn, vt;
@@ -133,7 +136,7 @@ private:
if (a.vc.g > b.vc.g) return false;
if (a.vc.b < b.vc.b) return true;
if (a.vc.b > b.vc.b) return false;
- return false;
+ return a.index < b.index;
}
};
diff --git a/code/AssetLib/Obj/ObjFileData.h b/code/AssetLib/Obj/ObjFileData.h
index 22090e63e..3dc20c799 100644
--- a/code/AssetLib/Obj/ObjFileData.h
+++ b/code/AssetLib/Obj/ObjFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Obj/ObjFileImporter.cpp b/code/AssetLib/Obj/ObjFileImporter.cpp
index 173ef2074..e956f83d4 100644
--- a/code/AssetLib/Obj/ObjFileImporter.cpp
+++ b/code/AssetLib/Obj/ObjFileImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -54,7 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/ObjMaterial.h>
#include <memory>
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Wavefront Object Importer",
"",
"",
@@ -78,7 +78,9 @@ using namespace std;
ObjFileImporter::ObjFileImporter() :
m_Buffer(),
m_pRootObject(nullptr),
- m_strAbsPath(std::string(1, DefaultIOSystem().getOsSeparator())) {}
+ m_strAbsPath(std::string(1, DefaultIOSystem().getOsSeparator())) {
+ // empty
+}
// ------------------------------------------------------------------------------------------------
// Destructor.
@@ -101,8 +103,13 @@ const aiImporterDesc *ObjFileImporter::GetInfo() const {
// ------------------------------------------------------------------------------------------------
// Obj-file import implementation
void ObjFileImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) {
+ if (m_pRootObject != nullptr) {
+ delete m_pRootObject;
+ m_pRootObject = nullptr;
+ }
+
// Read file into memory
- static const std::string mode = "rb";
+ static constexpr char mode[] = "rb";
auto streamCloser = [&](IOStream *pStream) {
pIOHandler->Close(pStream);
};
diff --git a/code/AssetLib/Obj/ObjFileParser.cpp b/code/AssetLib/Obj/ObjFileParser.cpp
index 09602e882..c0f1fc483 100644
--- a/code/AssetLib/Obj/ObjFileParser.cpp
+++ b/code/AssetLib/Obj/ObjFileParser.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -52,7 +52,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdlib>
#include <memory>
#include <utility>
-#include <string_view>
namespace Assimp {
@@ -64,6 +63,7 @@ ObjFileParser::ObjFileParser() :
m_pModel(nullptr),
m_uiLine(0),
m_buffer(),
+ mEnd(&m_buffer[Buffersize]),
m_pIO(nullptr),
m_progress(nullptr),
m_originalObjFileName() {
@@ -97,8 +97,6 @@ ObjFileParser::ObjFileParser(IOStreamBuffer<char> &streamBuffer, const std::stri
parseFile(streamBuffer);
}
-ObjFileParser::~ObjFileParser() = default;
-
void ObjFileParser::setBuffer(std::vector<char> &buffer) {
m_DataIt = buffer.begin();
m_DataItEnd = buffer.end();
@@ -121,6 +119,7 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
while (streamBuffer.getNextDataLine(buffer, '\\')) {
m_DataIt = buffer.begin();
m_DataItEnd = buffer.end();
+ mEnd = &buffer[buffer.size() - 1] + 1;
// Handle progress reporting
const size_t filePos(streamBuffer.getFilePos());
@@ -130,7 +129,7 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
m_progress->UpdateFileRead(processed, progressTotal);
}
- // handle cstype section end (http://paulbourke.net/dataformats/obj/)
+ // handle c-stype section end (http://paulbourke.net/dataformats/obj/)
if (insideCstype) {
switch (*m_DataIt) {
case 'e': {
@@ -301,18 +300,19 @@ size_t ObjFileParser::getNumComponentsInDataDefinition() {
} else if (IsLineEnd(*tmp)) {
end_of_definition = true;
}
- if (!SkipSpaces(&tmp)) {
+ if (!SkipSpaces(&tmp, mEnd)) {
break;
}
const bool isNum(IsNumeric(*tmp) || isNanOrInf(tmp));
- SkipToken(tmp);
+ SkipToken(tmp, mEnd);
if (isNum) {
++numComponents;
}
- if (!SkipSpaces(&tmp)) {
+ if (!SkipSpaces(&tmp, mEnd)) {
break;
}
}
+
return numComponents;
}
@@ -487,8 +487,9 @@ void ObjFileParser::getFace(aiPrimitiveType type) {
++iStep;
}
- if (iPos == 1 && !vt && vn)
+ if (iPos == 1 && !vt && vn) {
iPos = 2; // skip texture coords for normals if there are no tex coords
+ }
if (iVal > 0) {
// Store parsed index
@@ -577,8 +578,9 @@ void ObjFileParser::getMaterialDesc() {
// Get name
std::string strName(pStart, &(*m_DataIt));
strName = trim_whitespaces(strName);
- if (strName.empty())
+ if (strName.empty()) {
skip = true;
+ }
// If the current mesh has the same material, we simply ignore that 'usemtl' command
// There is no need to create another object or even mesh here
@@ -605,7 +607,8 @@ void ObjFileParser::getMaterialDesc() {
}
if (needsNewMesh(strName)) {
- createMesh(strName);
+ auto newMeshName = m_pModel->mActiveGroup.empty() ? strName : m_pModel->mActiveGroup;
+ createMesh(newMeshName);
}
m_pModel->mCurrentMesh->m_uiMaterialIndex = getMaterialIndex(strName);
diff --git a/code/AssetLib/Obj/ObjFileParser.h b/code/AssetLib/Obj/ObjFileParser.h
index 0ed724461..f3e149838 100644
--- a/code/AssetLib/Obj/ObjFileParser.h
+++ b/code/AssetLib/Obj/ObjFileParser.h
@@ -41,6 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef OBJ_FILEPARSER_H_INC
#define OBJ_FILEPARSER_H_INC
+#include "ObjFileData.h"
+
#include <assimp/IOStreamBuffer.h>
#include <assimp/material.h>
#include <assimp/mesh.h>
@@ -53,14 +55,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
-namespace ObjFile {
-struct Model;
-struct Object;
-struct Material;
-struct Point3;
-struct Point2;
-} // namespace ObjFile
-
class ObjFileImporter;
class IOSystem;
class ProgressHandler;
@@ -79,7 +73,7 @@ public:
/// @brief Constructor with data array.
ObjFileParser(IOStreamBuffer<char> &streamBuffer, const std::string &modelName, IOSystem *io, ProgressHandler *progress, const std::string &originalObjFileName);
/// @brief Destructor
- ~ObjFileParser();
+ ~ObjFileParser() = default;
/// @brief If you want to load in-core data.
void setBuffer(std::vector<char> &buffer);
/// @brief Model getter.
@@ -149,6 +143,7 @@ private:
unsigned int m_uiLine;
//! Helper buffer
char m_buffer[Buffersize];
+ const char *mEnd;
/// Pointer to IO system instance.
IOSystem *m_pIO;
//! Pointer to progress handler
diff --git a/code/AssetLib/Obj/ObjTools.h b/code/AssetLib/Obj/ObjTools.h
index ca173de0a..664402ee3 100644
--- a/code/AssetLib/Obj/ObjTools.h
+++ b/code/AssetLib/Obj/ObjTools.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ogre/OgreBinarySerializer.cpp b/code/AssetLib/Ogre/OgreBinarySerializer.cpp
index 738e1181e..ee92785ef 100644
--- a/code/AssetLib/Ogre/OgreBinarySerializer.cpp
+++ b/code/AssetLib/Ogre/OgreBinarySerializer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ogre/OgreBinarySerializer.h b/code/AssetLib/Ogre/OgreBinarySerializer.h
index eb026ea70..7bba8b768 100644
--- a/code/AssetLib/Ogre/OgreBinarySerializer.h
+++ b/code/AssetLib/Ogre/OgreBinarySerializer.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ogre/OgreImporter.cpp b/code/AssetLib/Ogre/OgreImporter.cpp
index 860aed727..8e58179bc 100644
--- a/code/AssetLib/Ogre/OgreImporter.cpp
+++ b/code/AssetLib/Ogre/OgreImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Importer.hpp>
#include <memory>
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Ogre3D Mesh Importer",
"",
"",
diff --git a/code/AssetLib/Ogre/OgreImporter.h b/code/AssetLib/Ogre/OgreImporter.h
index 3a72ae70e..2347956f2 100644
--- a/code/AssetLib/Ogre/OgreImporter.h
+++ b/code/AssetLib/Ogre/OgreImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ogre/OgreMaterial.cpp b/code/AssetLib/Ogre/OgreMaterial.cpp
index 0def59b79..d1244ada3 100644
--- a/code/AssetLib/Ogre/OgreMaterial.cpp
+++ b/code/AssetLib/Ogre/OgreMaterial.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ogre/OgreParsingUtils.h b/code/AssetLib/Ogre/OgreParsingUtils.h
index 60dd5cf76..2591644e3 100644
--- a/code/AssetLib/Ogre/OgreParsingUtils.h
+++ b/code/AssetLib/Ogre/OgreParsingUtils.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ogre/OgreStructs.cpp b/code/AssetLib/Ogre/OgreStructs.cpp
index ed8b9be79..29a8d768d 100644
--- a/code/AssetLib/Ogre/OgreStructs.cpp
+++ b/code/AssetLib/Ogre/OgreStructs.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ogre/OgreStructs.h b/code/AssetLib/Ogre/OgreStructs.h
index dcdf0670f..1ba8e840f 100644
--- a/code/AssetLib/Ogre/OgreStructs.h
+++ b/code/AssetLib/Ogre/OgreStructs.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ogre/OgreXmlSerializer.cpp b/code/AssetLib/Ogre/OgreXmlSerializer.cpp
index 8a1b88510..2eaa74c01 100644
--- a/code/AssetLib/Ogre/OgreXmlSerializer.cpp
+++ b/code/AssetLib/Ogre/OgreXmlSerializer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ogre/OgreXmlSerializer.h b/code/AssetLib/Ogre/OgreXmlSerializer.h
index 406681f55..c6f8e23a2 100644
--- a/code/AssetLib/Ogre/OgreXmlSerializer.h
+++ b/code/AssetLib/Ogre/OgreXmlSerializer.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/OpenGEX/OpenGEXExporter.cpp b/code/AssetLib/OpenGEX/OpenGEXExporter.cpp
index f812d0ddb..cbea5f39b 100644
--- a/code/AssetLib/OpenGEX/OpenGEXExporter.cpp
+++ b/code/AssetLib/OpenGEX/OpenGEXExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/OpenGEX/OpenGEXExporter.h b/code/AssetLib/OpenGEX/OpenGEXExporter.h
index 8e31b9ae3..93e5ffc74 100644
--- a/code/AssetLib/OpenGEX/OpenGEXExporter.h
+++ b/code/AssetLib/OpenGEX/OpenGEXExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp
index 16268ead5..20b2e77ac 100644
--- a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp
+++ b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -52,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h>
#include <openddlparser/OpenDDLParser.h>
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Open Game Engine Exchange",
"",
"",
@@ -66,42 +66,42 @@ static const aiImporterDesc desc = {
};
namespace Grammar {
- static const char* MetricType = "Metric";
- static const char *Metric_DistanceType = "distance";
- static const char *Metric_AngleType = "angle";
- static const char *Metric_TimeType = "time";
- static const char *Metric_UpType = "up";
- static const char *NameType = "Name";
- static const char *ObjectRefType = "ObjectRef";
- static const char *MaterialRefType = "MaterialRef";
- static const char *MetricKeyType = "key";
- static const char *GeometryNodeType = "GeometryNode";
- static const char *CameraNodeType = "CameraNode";
- static const char *LightNodeType = "LightNode";
- static const char *GeometryObjectType = "GeometryObject";
- static const char *CameraObjectType = "CameraObject";
- static const char *LightObjectType = "LightObject";
- static const char *TransformType = "Transform";
- static const char *MeshType = "Mesh";
- static const char *VertexArrayType = "VertexArray";
- static const char *IndexArrayType = "IndexArray";
- static const char *MaterialType = "Material";
- static const char *ColorType = "Color";
- static const char *ParamType = "Param";
- static const char *TextureType = "Texture";
- static const char *AttenType = "Atten";
-
- static const char *DiffuseColorToken = "diffuse";
- static const char *SpecularColorToken = "specular";
- static const char *EmissionColorToken = "emission";
-
- static const char *DiffuseTextureToken = "diffuse";
- static const char *DiffuseSpecularTextureToken = "specular";
- static const char *SpecularPowerTextureToken = "specular_power";
- static const char *EmissionTextureToken = "emission";
- static const char *OpacyTextureToken = "opacity";
- static const char *TransparencyTextureToken = "transparency";
- static const char *NormalTextureToken = "normal";
+ static constexpr char MetricType[] = "Metric";
+ static constexpr char Metric_DistanceType[] = "distance";
+ static constexpr char Metric_AngleType[] = "angle";
+ static constexpr char Metric_TimeType[] = "time";
+ static constexpr char Metric_UpType[] = "up";
+ static constexpr char NameType[] = "Name";
+ static constexpr char ObjectRefType[] = "ObjectRef";
+ static constexpr char MaterialRefType[] = "MaterialRef";
+ static constexpr char MetricKeyType[] = "key";
+ static constexpr char GeometryNodeType[] = "GeometryNode";
+ static constexpr char CameraNodeType[] = "CameraNode";
+ static constexpr char LightNodeType[] = "LightNode";
+ static constexpr char GeometryObjectType[] = "GeometryObject";
+ static constexpr char CameraObjectType[] = "CameraObject";
+ static constexpr char LightObjectType[] = "LightObject";
+ static constexpr char TransformType[] = "Transform";
+ static constexpr char MeshType[] = "Mesh";
+ static constexpr char VertexArrayType[] = "VertexArray";
+ static constexpr char IndexArrayType[] = "IndexArray";
+ static constexpr char MaterialType[] = "Material";
+ static constexpr char ColorType[] = "Color";
+ static constexpr char ParamType[] = "Param";
+ static constexpr char TextureType[] = "Texture";
+ static constexpr char AttenType[] = "Atten";
+
+ static constexpr char DiffuseColorToken[] = "diffuse";
+ static constexpr char SpecularColorToken[] = "specular";
+ static constexpr char EmissionColorToken[] = "emission";
+
+ static constexpr char DiffuseTextureToken[] = "diffuse";
+ static constexpr char DiffuseSpecularTextureToken[] = "specular";
+ static constexpr char SpecularPowerTextureToken[] = "specular_power";
+ static constexpr char EmissionTextureToken[] = "emission";
+ static constexpr char OpacyTextureToken[] = "opacity";
+ static constexpr char TransparencyTextureToken[] = "transparency";
+ static constexpr char NormalTextureToken[] = "normal";
enum TokenType {
NoneType = -1,
@@ -139,7 +139,7 @@ namespace Grammar {
return false;
}
- int idx(-1);
+ int idx = -1;
for (size_t i = 0; i < 4; i++) {
if (ValidMetricToken[i] == token) {
idx = (int)i;
diff --git a/code/AssetLib/OpenGEX/OpenGEXImporter.h b/code/AssetLib/OpenGEX/OpenGEXImporter.h
index 997d58af9..cf5773387 100644
--- a/code/AssetLib/OpenGEX/OpenGEXImporter.h
+++ b/code/AssetLib/OpenGEX/OpenGEXImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/OpenGEX/OpenGEXStructs.h b/code/AssetLib/OpenGEX/OpenGEXStructs.h
index 5f845483d..91b31a41a 100644
--- a/code/AssetLib/OpenGEX/OpenGEXStructs.h
+++ b/code/AssetLib/OpenGEX/OpenGEXStructs.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ply/PlyExporter.cpp b/code/AssetLib/Ply/PlyExporter.cpp
index 9453e0d4d..2dc3311ff 100644
--- a/code/AssetLib/Ply/PlyExporter.cpp
+++ b/code/AssetLib/Ply/PlyExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ply/PlyExporter.h b/code/AssetLib/Ply/PlyExporter.h
index ff3a54cb6..810626d69 100644
--- a/code/AssetLib/Ply/PlyExporter.h
+++ b/code/AssetLib/Ply/PlyExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Ply/PlyLoader.cpp b/code/AssetLib/Ply/PlyLoader.cpp
index 783c7f1c6..3e92339fb 100644
--- a/code/AssetLib/Ply/PlyLoader.cpp
+++ b/code/AssetLib/Ply/PlyLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -53,9 +53,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp>
#include <memory>
-using namespace ::Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Stanford Polygon Library (PLY) Importer",
"",
"",
@@ -71,16 +71,16 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Internal stuff
namespace {
-// ------------------------------------------------------------------------------------------------
-// Checks that property index is within range
-template <class T>
-inline const T &GetProperty(const std::vector<T> &props, int idx) {
- if (static_cast<size_t>(idx) >= props.size()) {
- throw DeadlyImportError("Invalid .ply file: Property index is out of range.");
- }
+ // ------------------------------------------------------------------------------------------------
+ // Checks that property index is within range
+ template <class T>
+ inline const T &GetProperty(const std::vector<T> &props, int idx) {
+ if (static_cast<size_t>(idx) >= props.size()) {
+ throw DeadlyImportError("Invalid .ply file: Property index is out of range.");
+ }
- return props[idx];
-}
+ return props[idx];
+ }
} // namespace
// ------------------------------------------------------------------------------------------------
@@ -93,10 +93,6 @@ PLYImporter::PLYImporter() :
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-PLYImporter::~PLYImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const char *tokens[] = { "ply" };
@@ -163,7 +159,8 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
mBuffer = (unsigned char *)&mBuffer2[0];
char *szMe = (char *)&this->mBuffer[0];
- SkipSpacesAndLineEnd(szMe, (const char **)&szMe);
+ const char *end = &mBuffer2[0] + mBuffer2.size();
+ SkipSpacesAndLineEnd(szMe, (const char **)&szMe, end);
// determine the format of the file data and construct the aiMesh
PLY::DOM sPlyDom;
@@ -171,7 +168,7 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (TokenMatch(szMe, "format", 6)) {
if (TokenMatch(szMe, "ascii", 5)) {
- SkipLine(szMe, (const char **)&szMe);
+ SkipLine(szMe, (const char **)&szMe, end);
if (!PLY::DOM::ParseInstance(streamedBuffer, &sPlyDom, this)) {
if (mGeneratedMesh != nullptr) {
delete (mGeneratedMesh);
@@ -215,7 +212,7 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
throw DeadlyImportError("Invalid .ply file: Missing format specification");
}
- //free the file buffer
+ // free the file buffer
streamedBuffer.close();
if (mGeneratedMesh == nullptr) {
@@ -376,7 +373,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
haveNormal = true;
}
- //Colors
+ // Colors
aiColor4D cOut;
bool haveColor = false;
if (0xFFFFFFFF != aiColors[0]) {
@@ -415,7 +412,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
haveColor = true;
}
- //Texture coordinates
+ // Texture coordinates
aiVector3D tOut;
tOut.z = 0;
bool haveTextureCoords = false;
@@ -431,7 +428,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
haveTextureCoords = true;
}
- //create aiMesh if needed
+ // create aiMesh if needed
if (nullptr == mGeneratedMesh) {
mGeneratedMesh = new aiMesh();
mGeneratedMesh->mMaterialIndex = 0;
@@ -512,8 +509,8 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
bool bIsTriStrip = false;
// index of the material index property
- //unsigned int iMaterialIndex = 0xFFFFFFFF;
- //PLY::EDataType eType2 = EDT_Char;
+ // unsigned int iMaterialIndex = 0xFFFFFFFF;
+ // PLY::EDataType eType2 = EDT_Char;
// texture coordinates
unsigned int iTextureCoord = 0xFFFFFFFF;
@@ -595,7 +592,7 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
if (0xFFFFFFFF != iTextureCoord) {
const unsigned int iNum = (unsigned int)GetProperty(instElement->alProperties, iTextureCoord).avList.size();
- //should be 6 coords
+ // should be 6 coords
std::vector<PLY::PropertyInstance::ValueUnion>::const_iterator p =
GetProperty(instElement->alProperties, iTextureCoord).avList.begin();
@@ -625,7 +622,7 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
// a value of -1 indicates a restart of the strip
bool flip = false;
const std::vector<PLY::PropertyInstance::ValueUnion> &quak = GetProperty(instElement->alProperties, iProperty).avList;
- //pvOut->reserve(pvOut->size() + quak.size() + (quak.size()>>2u)); //Limits memory consumption
+ // pvOut->reserve(pvOut->size() + quak.size() + (quak.size()>>2u)); //Limits memory consumption
int aiTable[2] = { -1, -1 };
for (std::vector<PLY::PropertyInstance::ValueUnion>::const_iterator a = quak.begin(); a != quak.end(); ++a) {
@@ -863,7 +860,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
const int two_sided = 1;
pcHelper->AddProperty(&two_sided, 1, AI_MATKEY_TWOSIDED);
- //default texture
+ // default texture
if (!defaultTexture.empty()) {
const aiString name(defaultTexture.c_str());
pcHelper->AddProperty(&name, _AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE, 0);
@@ -873,7 +870,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
pcHelper->AddProperty(&two_sided, 1, AI_MATKEY_TWOSIDED);
}
- //set to wireframe, so when using this material info we can switch to points rendering
+ // set to wireframe, so when using this material info we can switch to points rendering
if (pointsOnly) {
const int wireframe = 1;
pcHelper->AddProperty(&wireframe, 1, AI_MATKEY_ENABLE_WIREFRAME);
@@ -890,7 +887,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
int iMode = (int)aiShadingMode_Gouraud;
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
- //generate white material most 3D engine just multiply ambient / diffuse color with actual ambient / light color
+ // generate white material most 3D engine just multiply ambient / diffuse color with actual ambient / light color
aiColor3D clr;
clr.b = clr.g = clr.r = 1.0f;
pcHelper->AddProperty<aiColor3D>(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
@@ -906,13 +903,13 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
pcHelper->AddProperty(&two_sided, 1, AI_MATKEY_TWOSIDED);
}
- //default texture
+ // default texture
if (!defaultTexture.empty()) {
const aiString name(defaultTexture.c_str());
pcHelper->AddProperty(&name, _AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE, 0);
}
- //set to wireframe, so when using this material info we can switch to points rendering
+ // set to wireframe, so when using this material info we can switch to points rendering
if (pointsOnly) {
const int wireframe = 1;
pcHelper->AddProperty(&wireframe, 1, AI_MATKEY_ENABLE_WIREFRAME);
@@ -922,4 +919,6 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
}
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_PLY_IMPORTER
diff --git a/code/AssetLib/Ply/PlyLoader.h b/code/AssetLib/Ply/PlyLoader.h
index e29da1db6..048f40e3f 100644
--- a/code/AssetLib/Ply/PlyLoader.h
+++ b/code/AssetLib/Ply/PlyLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -65,7 +65,7 @@ using namespace PLY;
class PLYImporter : public BaseImporter {
public:
PLYImporter();
- ~PLYImporter() override;
+ ~PLYImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/Ply/PlyParser.cpp b/code/AssetLib/Ply/PlyParser.cpp
index 6edba71fc..dbbabc03f 100644
--- a/code/AssetLib/Ply/PlyParser.cpp
+++ b/code/AssetLib/Ply/PlyParser.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp>
#include <utility>
-using namespace Assimp;
+namespace Assimp {
// ------------------------------------------------------------------------------------------------
PLY::EDataType PLY::Property::ParseDataType(std::vector<char> &buffer) {
@@ -296,7 +296,7 @@ bool PLY::Element::ParseElement(IOStreamBuffer<char> &streamBuffer, std::vector<
return true;
}
- //parse the number of occurrences of this element
+ // parse the number of occurrences of this element
const char *pCur = (char *)&buffer[0];
pOut->NumOccur = strtoul10(pCur, &pCur);
@@ -321,13 +321,13 @@ bool PLY::Element::ParseElement(IOStreamBuffer<char> &streamBuffer, std::vector<
return true;
}
-// ------------------------------------------------------------------------------------------------
bool PLY::DOM::SkipSpaces(std::vector<char> &buffer) {
const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0];
+ const char *end = pCur + buffer.size();
bool ret = false;
if (pCur) {
const char *szCur = pCur;
- ret = Assimp::SkipSpaces(pCur, &pCur);
+ ret = Assimp::SkipSpaces(pCur, &pCur, end);
uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
buffer.erase(buffer.begin(), buffer.begin() + iDiff);
@@ -339,10 +339,11 @@ bool PLY::DOM::SkipSpaces(std::vector<char> &buffer) {
bool PLY::DOM::SkipLine(std::vector<char> &buffer) {
const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0];
+ const char *end = pCur + buffer.size();
bool ret = false;
if (pCur) {
const char *szCur = pCur;
- ret = Assimp::SkipLine(pCur, &pCur);
+ ret = Assimp::SkipLine(pCur, &pCur, end);
uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
buffer.erase(buffer.begin(), buffer.begin() + iDiff);
@@ -369,10 +370,11 @@ bool PLY::DOM::TokenMatch(std::vector<char> &buffer, const char *token, unsigned
bool PLY::DOM::SkipSpacesAndLineEnd(std::vector<char> &buffer) {
const char *pCur = buffer.empty() ? nullptr : (char *)&buffer[0];
+ const char *end = pCur + buffer.size();
bool ret = false;
if (pCur) {
const char *szCur = pCur;
- ret = Assimp::SkipSpacesAndLineEnd(pCur, &pCur);
+ ret = Assimp::SkipSpacesAndLineEnd(pCur, &pCur, end);
uintptr_t iDiff = (uintptr_t)pCur - (uintptr_t)szCur;
buffer.erase(buffer.begin(), buffer.begin() + iDiff);
@@ -425,7 +427,8 @@ bool PLY::DOM::ParseHeader(IOStreamBuffer<char> &streamBuffer, std::vector<char>
break;
} else {
// ignore unknown header elements
- streamBuffer.getNextLine(buffer);
+ if (!streamBuffer.getNextLine(buffer))
+ return false;
}
}
@@ -445,7 +448,7 @@ bool PLY::DOM::ParseElementInstanceLists(IOStreamBuffer<char> &streamBuffer, std
std::vector<PLY::ElementInstanceList>::iterator a = alElementData.begin();
// parse all element instances
- //construct vertices and faces
+ // construct vertices and faces
for (; i != alElements.end(); ++i, ++a) {
if ((*i).eSemantic == EEST_Vertex || (*i).eSemantic == EEST_Face || (*i).eSemantic == EEST_TriStrip) {
PLY::ElementInstanceList::ParseInstanceList(streamBuffer, buffer, &(*i), nullptr, loader);
@@ -527,7 +530,7 @@ bool PLY::DOM::ParseInstance(IOStreamBuffer<char> &streamBuffer, DOM *p_pcOut, P
return false;
}
- //get next line after header
+ // get next line after header
streamBuffer.getNextLine(buffer);
if (!p_pcOut->ParseElementInstanceLists(streamBuffer, buffer, loader)) {
ASSIMP_LOG_VERBOSE_DEBUG("PLY::DOM::ParseInstance() failure");
@@ -557,23 +560,24 @@ bool PLY::ElementInstanceList::ParseInstanceList(
}
} else {
const char *pCur = (const char *)&buffer[0];
+ const char *end = pCur + buffer.size();
// be sure to have enough storage
for (unsigned int i = 0; i < pcElement->NumOccur; ++i) {
if (p_pcOut)
- PLY::ElementInstance::ParseInstance(pCur, pcElement, &p_pcOut->alInstances[i]);
+ PLY::ElementInstance::ParseInstance(pCur, end, pcElement, &p_pcOut->alInstances[i]);
else {
ElementInstance elt;
- PLY::ElementInstance::ParseInstance(pCur, pcElement, &elt);
+ PLY::ElementInstance::ParseInstance(pCur, end, pcElement, &elt);
// Create vertex or face
if (pcElement->eSemantic == EEST_Vertex) {
- //call loader instance from here
+ // call loader instance from here
loader->LoadVertex(pcElement, &elt, i);
} else if (pcElement->eSemantic == EEST_Face) {
- //call loader instance from here
+ // call loader instance from here
loader->LoadFace(pcElement, &elt, i);
} else if (pcElement->eSemantic == EEST_TriStrip) {
- //call loader instance from here
+ // call loader instance from here
loader->LoadFace(pcElement, &elt, i);
}
}
@@ -610,13 +614,13 @@ bool PLY::ElementInstanceList::ParseInstanceListBinary(
// Create vertex or face
if (pcElement->eSemantic == EEST_Vertex) {
- //call loader instance from here
+ // call loader instance from here
loader->LoadVertex(pcElement, &elt, i);
} else if (pcElement->eSemantic == EEST_Face) {
- //call loader instance from here
+ // call loader instance from here
loader->LoadFace(pcElement, &elt, i);
} else if (pcElement->eSemantic == EEST_TriStrip) {
- //call loader instance from here
+ // call loader instance from here
loader->LoadFace(pcElement, &elt, i);
}
}
@@ -625,7 +629,7 @@ bool PLY::ElementInstanceList::ParseInstanceListBinary(
}
// ------------------------------------------------------------------------------------------------
-bool PLY::ElementInstance::ParseInstance(const char *&pCur,
+bool PLY::ElementInstance::ParseInstance(const char *&pCur, const char *end,
const PLY::Element *pcElement,
PLY::ElementInstance *p_pcOut) {
ai_assert(nullptr != pcElement);
@@ -637,7 +641,7 @@ bool PLY::ElementInstance::ParseInstance(const char *&pCur,
std::vector<PLY::PropertyInstance>::iterator i = p_pcOut->alProperties.begin();
std::vector<PLY::Property>::const_iterator a = pcElement->alProperties.begin();
for (; i != p_pcOut->alProperties.end(); ++i, ++a) {
- if (!(PLY::PropertyInstance::ParseInstance(pCur, &(*a), &(*i)))) {
+ if (!(PLY::PropertyInstance::ParseInstance(pCur, end, &(*a), &(*i)))) {
ASSIMP_LOG_WARN("Unable to parse property instance. "
"Skipping this element instance");
@@ -677,13 +681,13 @@ bool PLY::ElementInstance::ParseInstanceBinary(
}
// ------------------------------------------------------------------------------------------------
-bool PLY::PropertyInstance::ParseInstance(const char *&pCur,
- const PLY::Property *prop, PLY::PropertyInstance *p_pcOut) {
+bool PLY::PropertyInstance::ParseInstance(const char *&pCur, const char *end, const PLY::Property *prop,
+ PLY::PropertyInstance *p_pcOut) {
ai_assert(nullptr != prop);
ai_assert(nullptr != p_pcOut);
// skip spaces at the beginning
- if (!SkipSpaces(&pCur)) {
+ if (!SkipSpaces(&pCur, end)) {
return false;
}
@@ -698,7 +702,7 @@ bool PLY::PropertyInstance::ParseInstance(const char *&pCur,
// parse all list elements
p_pcOut->avList.resize(iNum);
for (unsigned int i = 0; i < iNum; ++i) {
- if (!SkipSpaces(&pCur))
+ if (!SkipSpaces(&pCur, end))
return false;
PLY::PropertyInstance::ParseValue(pCur, prop->eType, &p_pcOut->avList[i]);
@@ -710,7 +714,7 @@ bool PLY::PropertyInstance::ParseInstance(const char *&pCur,
PLY::PropertyInstance::ParseValue(pCur, prop->eType, &v);
p_pcOut->avList.push_back(v);
}
- SkipSpacesAndLineEnd(&pCur);
+ SkipSpacesAndLineEnd(&pCur, end);
return true;
}
@@ -773,7 +777,7 @@ bool PLY::PropertyInstance::ParseValue(const char *&pCur,
ai_assert(nullptr != pCur);
ai_assert(nullptr != out);
- //calc element size
+ // calc element size
bool ret = true;
switch (eType) {
case EDT_UInt:
@@ -823,7 +827,7 @@ bool PLY::PropertyInstance::ParseValueBinary(IOStreamBuffer<char> &streamBuffer,
bool p_bBE) {
ai_assert(nullptr != out);
- //calc element size
+ // calc element size
unsigned int lsize = 0;
switch (eType) {
case EDT_Char:
@@ -851,11 +855,11 @@ bool PLY::PropertyInstance::ParseValueBinary(IOStreamBuffer<char> &streamBuffer,
break;
}
- //read the next file block if needed
+ // read the next file block if needed
if (bufferSize < lsize) {
std::vector<char> nbuffer;
if (streamBuffer.getNextBlock(nbuffer)) {
- //concat buffer contents
+ // concat buffer contents
buffer = std::vector<char>(buffer.end() - bufferSize, buffer.end());
buffer.insert(buffer.end(), nbuffer.begin(), nbuffer.end());
nbuffer.clear();
@@ -957,4 +961,6 @@ bool PLY::PropertyInstance::ParseValueBinary(IOStreamBuffer<char> &streamBuffer,
return ret;
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_PLY_IMPORTER
diff --git a/code/AssetLib/Ply/PlyParser.h b/code/AssetLib/Ply/PlyParser.h
index 593791e92..fc6f346af 100644
--- a/code/AssetLib/Ply/PlyParser.h
+++ b/code/AssetLib/Ply/PlyParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -324,7 +324,7 @@ public:
// -------------------------------------------------------------------
//! Parse a property instance
- static bool ParseInstance(const char* &pCur,
+ static bool ParseInstance(const char* &pCur, const char *end,
const Property* prop, PropertyInstance* p_pcOut);
// -------------------------------------------------------------------
@@ -364,7 +364,7 @@ public:
// -------------------------------------------------------------------
//! Parse an element instance
- static bool ParseInstance(const char* &pCur,
+ static bool ParseInstance(const char *&pCur, const char *end,
const Element* pcElement, ElementInstance* p_pcOut);
// -------------------------------------------------------------------
diff --git a/code/AssetLib/Q3BSP/Q3BSPFileData.h b/code/AssetLib/Q3BSP/Q3BSPFileData.h
index 086cf7842..2d86ce564 100644
--- a/code/AssetLib/Q3BSP/Q3BSPFileData.h
+++ b/code/AssetLib/Q3BSP/Q3BSPFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp
index 924949eeb..d2ab59eb4 100644
--- a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp
+++ b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -48,11 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp>
-#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
-#include <zlib.h>
-#else
-#include "../contrib/zlib/zlib.h"
-#endif
+#include "zlib.h"
#include <assimp/DefaultIOSystem.h>
#include <assimp/StringComparison.h>
@@ -65,7 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sstream>
#include <vector>
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Quake III BSP Importer",
"",
"",
@@ -146,7 +142,11 @@ Q3BSPFileImporter::Q3BSPFileImporter() :
// ------------------------------------------------------------------------------------------------
// Destructor.
Q3BSPFileImporter::~Q3BSPFileImporter() {
- // Clear face-to-material map
+ clear();
+}
+
+// ------------------------------------------------------------------------------------------------
+void Q3BSPFileImporter::clear() {
for (FaceMap::iterator it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it) {
const std::string &matName = it->first;
if (!matName.empty()) {
@@ -173,6 +173,7 @@ const aiImporterDesc *Q3BSPFileImporter::GetInfo() const {
// ------------------------------------------------------------------------------------------------
// Import method.
void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene *scene, IOSystem *ioHandler) {
+ clear();
ZipArchiveIOSystem Archive(ioHandler, rFile);
if (!Archive.isOpen()) {
throw DeadlyImportError("Failed to open file ", rFile, ".");
@@ -394,7 +395,10 @@ void Q3BSPFileImporter::createTriangleTopology(const Q3BSP::Q3BSPModel *pModel,
m_pCurrentFace->mIndices = new unsigned int[3];
m_pCurrentFace->mIndices[idx] = vertIdx;
}
- }
+ } else {
+ m_pCurrentFace->mIndices[idx] = vertIdx;
+ }
+
pMesh->mVertices[vertIdx].Set(pVertex->vPosition.x, pVertex->vPosition.y, pVertex->vPosition.z);
pMesh->mNormals[vertIdx].Set(pVertex->vNormal.x, pVertex->vNormal.y, pVertex->vNormal.z);
diff --git a/code/AssetLib/Q3BSP/Q3BSPFileImporter.h b/code/AssetLib/Q3BSP/Q3BSPFileImporter.h
index fdcfff876..b779c55a5 100644
--- a/code/AssetLib/Q3BSP/Q3BSPFileImporter.h
+++ b/code/AssetLib/Q3BSP/Q3BSPFileImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -81,6 +81,7 @@ protected:
using FaceMapIt = std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>* >::iterator;
using FaceMapConstIt = std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>*>::const_iterator;
+ void clear();
const aiImporterDesc* GetInfo () const override;
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
void separateMapName( const std::string &rImportName, std::string &rArchiveName, std::string &rMapName );
diff --git a/code/AssetLib/Q3BSP/Q3BSPFileParser.cpp b/code/AssetLib/Q3BSP/Q3BSPFileParser.cpp
index 910da5b36..c9c3d24cf 100644
--- a/code/AssetLib/Q3BSP/Q3BSPFileParser.cpp
+++ b/code/AssetLib/Q3BSP/Q3BSPFileParser.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Q3BSP/Q3BSPFileParser.h b/code/AssetLib/Q3BSP/Q3BSPFileParser.h
index 15cc751cc..de4d609e4 100644
--- a/code/AssetLib/Q3BSP/Q3BSPFileParser.h
+++ b/code/AssetLib/Q3BSP/Q3BSPFileParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp
index 22d1065de..435b92e82 100644
--- a/code/AssetLib/Q3D/Q3DLoader.cpp
+++ b/code/AssetLib/Q3D/Q3DLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -55,9 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp>
-using namespace Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Quick3D Importer",
"",
"",
@@ -127,7 +127,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
std::vector<Material> materials;
try {
materials.reserve(numMats);
- } catch(const std::bad_alloc&) {
+ } catch (const std::bad_alloc &) {
ASSIMP_LOG_ERROR("Invalid alloc for materials.");
throw DeadlyImportError("Invalid Quick3D-file, material allocation failed.");
}
@@ -135,7 +135,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
std::vector<Mesh> meshes;
try {
meshes.reserve(numMeshes);
- } catch(const std::bad_alloc&) {
+ } catch (const std::bad_alloc &) {
ASSIMP_LOG_ERROR("Invalid alloc for meshes.");
throw DeadlyImportError("Invalid Quick3D-file, mesh allocation failed.");
}
@@ -237,7 +237,6 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
if (minor > '0' && major == '3')
stream.IncPtr(mesh.faces.size());
}
- // stream.IncPtr(4); // unknown value here
} break;
// materials chunk
@@ -275,8 +274,6 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
// read the transparency
mat.transparency = stream.GetF4();
- // unknown value here
- // stream.IncPtr(4);
// FIX: it could be the texture index ...
mat.texIdx = (unsigned int)stream.GetI4();
}
@@ -425,7 +422,8 @@ outer:
pScene->mMeshes = new aiMesh *[pScene->mNumMaterials];
for (unsigned int i = 0, real = 0; i < (unsigned int)materials.size(); ++i) {
- if (fidx[i].empty()) continue;
+ if (fidx[i].empty())
+ continue;
// Allocate a mesh and a material
aiMesh *mesh = pScene->mMeshes[real] = new aiMesh();
@@ -548,14 +546,9 @@ outer:
// Now we need to attach the meshes to the root node of the scene
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
- for (unsigned int i = 0; i < pScene->mNumMeshes; ++i)
+ for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
pScene->mRootNode->mMeshes[i] = i;
-
- /*pScene->mRootNode->mTransformation *= aiMatrix4x4(
- 1.f, 0.f, 0.f, 0.f,
- 0.f, -1.f,0.f, 0.f,
- 0.f, 0.f, 1.f, 0.f,
- 0.f, 0.f, 0.f, 1.f);*/
+ }
// Add cameras and light sources to the scene root node
pScene->mRootNode->mNumChildren = pScene->mNumLights + pScene->mNumCameras;
@@ -577,4 +570,6 @@ outer:
}
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_Q3D_IMPORTER
diff --git a/code/AssetLib/Q3D/Q3DLoader.h b/code/AssetLib/Q3D/Q3DLoader.h
index 54af86dc2..ed33ed7ca 100644
--- a/code/AssetLib/Q3D/Q3DLoader.h
+++ b/code/AssetLib/Q3D/Q3DLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Raw/RawLoader.cpp b/code/AssetLib/Raw/RawLoader.cpp
index 1791a5c52..6c04680b8 100644
--- a/code/AssetLib/Raw/RawLoader.cpp
+++ b/code/AssetLib/Raw/RawLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -55,9 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp>
#include <memory>
-using namespace Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Raw Importer",
"",
"",
@@ -71,14 +71,6 @@ static const aiImporterDesc desc = {
};
// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-RAWImporter::RAWImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-RAWImporter::~RAWImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool RAWImporter::CanRead(const std::string &filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
return SimpleExtensionCheck(filename, "raw");
@@ -112,11 +104,12 @@ void RAWImporter::InternReadFile(const std::string &pFile,
// now read all lines
char line[4096];
+ const char *end = &line[4096];
while (GetNextLine(buffer, line)) {
// if the line starts with a non-numeric identifier, it marks
// the beginning of a new group
const char *sz = line;
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
if (IsLineEnd(*sz)) continue;
if (!IsNumeric(*sz)) {
const char *sz2 = sz;
@@ -125,8 +118,8 @@ void RAWImporter::InternReadFile(const std::string &pFile,
const unsigned int length = (unsigned int)(sz2 - sz);
// find an existing group with this name
- for (std::vector<GroupInformation>::iterator it = outGroups.begin(), end = outGroups.end();
- it != end; ++it) {
+ for (std::vector<GroupInformation>::iterator it = outGroups.begin(), endIt = outGroups.end();
+ it != endIt; ++it) {
if (length == (*it).name.length() && !::strcmp(sz, (*it).name.c_str())) {
curGroup = it;
sz2 = nullptr;
@@ -142,7 +135,7 @@ void RAWImporter::InternReadFile(const std::string &pFile,
float data[12];
unsigned int num;
for (num = 0; num < 12; ++num) {
- if (!SkipSpaces(&sz) || !IsNumeric(*sz)) break;
+ if (!SkipSpaces(&sz, end) || !IsNumeric(*sz)) break;
sz = fast_atoreal_move<float>(sz, data[num]);
}
if (num != 12 && num != 9) {
@@ -295,4 +288,6 @@ void RAWImporter::InternReadFile(const std::string &pFile,
}
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_RAW_IMPORTER
diff --git a/code/AssetLib/Raw/RawLoader.h b/code/AssetLib/Raw/RawLoader.h
index 54314f728..aa0fbdf81 100644
--- a/code/AssetLib/Raw/RawLoader.h
+++ b/code/AssetLib/Raw/RawLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -57,8 +57,8 @@ namespace Assimp {
*/
class RAWImporter : public BaseImporter {
public:
- RAWImporter();
- ~RAWImporter() override;
+ RAWImporter() = default;
+ ~RAWImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/SIB/SIBImporter.cpp b/code/AssetLib/SIB/SIBImporter.cpp
index 9f299180b..e55e67541 100644
--- a/code/AssetLib/SIB/SIBImporter.cpp
+++ b/code/AssetLib/SIB/SIBImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -56,11 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/ByteSwapper.h>
#include <assimp/StreamReader.h>
#include <assimp/TinyFormatter.h>
-#ifdef ASSIMP_USE_HUNTER
-#include <utf8.h>
-#else
-#include "../contrib/utf8cpp/source/utf8.h"
-#endif
+#include "utf8.h"
#include <assimp/importerdesc.h>
#include <assimp/scene.h>
#include <assimp/DefaultLogger.hpp>
@@ -69,9 +65,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <map>
-using namespace Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Silo SIB Importer",
"Richard Mitton (http://www.codersnotes.com/about)",
"",
@@ -94,7 +90,7 @@ enum {
N
};
-typedef std::pair<uint32_t, uint32_t> SIBPair;
+using SIBPair = std::pair<uint32_t, uint32_t>;
struct SIBEdge {
uint32_t faceA, faceB;
@@ -199,15 +195,6 @@ static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) {
return result;
}
-
-// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-SIBImporter::SIBImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-SIBImporter::~SIBImporter() = default;
-
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool SIBImporter::CanRead(const std::string &filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
@@ -882,4 +869,6 @@ void SIBImporter::InternReadFile(const std::string &pFile,
}
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_SIB_IMPORTER
diff --git a/code/AssetLib/SIB/SIBImporter.h b/code/AssetLib/SIB/SIBImporter.h
index 2b197ddca..9dd0c0095 100644
--- a/code/AssetLib/SIB/SIBImporter.h
+++ b/code/AssetLib/SIB/SIBImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -57,8 +57,8 @@ namespace Assimp {
*/
class ASSIMP_API SIBImporter : public BaseImporter {
public:
- SIBImporter();
- ~SIBImporter() override;
+ SIBImporter() = default;
+ ~SIBImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp
index 9af871cee..df598e5c7 100644
--- a/code/AssetLib/SMD/SMDLoader.cpp
+++ b/code/AssetLib/SMD/SMDLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -64,9 +64,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define strtok_s strtok_r
#endif
-using namespace Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Valve SMD Importer",
"",
"",
@@ -82,8 +82,10 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
SMDImporter::SMDImporter() :
- configFrameID(),
- pScene( nullptr ),
+ configFrameID(),
+ mBuffer(),
+ mEnd(nullptr),
+ pScene(nullptr),
iFileSize( 0 ),
iSmallestFrame( INT_MAX ),
dLengthOfAnim( 0.0 ),
@@ -92,9 +94,6 @@ SMDImporter::SMDImporter() :
// empty
}
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-SMDImporter::~SMDImporter() = default;
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
@@ -632,13 +631,13 @@ void SMDImporter::ParseFile() {
// read line per line ...
for ( ;; ) {
- if(!SkipSpacesAndLineEnd(szCurrent,&szCurrent)) {
+ if(!SkipSpacesAndLineEnd(szCurrent,&szCurrent, mEnd)) {
break;
}
// "version <n> \n", <n> should be 1 for hl and hl2 SMD files
if (TokenMatch(szCurrent,"version",7)) {
- if(!SkipSpaces(szCurrent,&szCurrent)) break;
+ if(!SkipSpaces(szCurrent,&szCurrent, mEnd)) break;
if (1 != strtoul10(szCurrent,&szCurrent)) {
ASSIMP_LOG_WARN("SMD.version is not 1. This "
"file format is not known. Continuing happily ...");
@@ -647,26 +646,26 @@ void SMDImporter::ParseFile() {
}
// "nodes\n" - Starts the node section
if (TokenMatch(szCurrent,"nodes",5)) {
- ParseNodesSection(szCurrent,&szCurrent);
+ ParseNodesSection(szCurrent, &szCurrent, mEnd);
continue;
}
// "triangles\n" - Starts the triangle section
if (TokenMatch(szCurrent,"triangles",9)) {
- ParseTrianglesSection(szCurrent,&szCurrent);
+ ParseTrianglesSection(szCurrent, &szCurrent, mEnd);
continue;
}
// "vertexanimation\n" - Starts the vertex animation section
if (TokenMatch(szCurrent,"vertexanimation",15)) {
bHasUVs = false;
- ParseVASection(szCurrent,&szCurrent);
+ ParseVASection(szCurrent, &szCurrent, mEnd);
continue;
}
// "skeleton\n" - Starts the skeleton section
if (TokenMatch(szCurrent,"skeleton",8)) {
- ParseSkeletonSection(szCurrent,&szCurrent);
+ ParseSkeletonSection(szCurrent, &szCurrent, mEnd);
continue;
}
- SkipLine(szCurrent,&szCurrent);
+ SkipLine(szCurrent, &szCurrent, mEnd);
}
}
@@ -683,6 +682,7 @@ void SMDImporter::ReadSmd(const std::string &pFile, IOSystem* pIOHandler) {
// Allocate storage and copy the contents of the file to a memory buffer
mBuffer.resize(iFileSize + 1);
TextFileToBuffer(file.get(), mBuffer);
+ mEnd = &mBuffer[mBuffer.size() - 1] + 1;
iSmallestFrame = INT_MAX;
bHasUVs = true;
@@ -723,26 +723,26 @@ unsigned int SMDImporter::GetTextureIndex(const std::string& filename) {
// ------------------------------------------------------------------------------------------------
// Parse the nodes section of the file
-void SMDImporter::ParseNodesSection(const char* szCurrent, const char** szCurrentOut) {
+void SMDImporter::ParseNodesSection(const char* szCurrent, const char** szCurrentOut, const char *end) {
for ( ;; ) {
// "end\n" - Ends the nodes section
- if (0 == ASSIMP_strincmp(szCurrent,"end",3) && IsSpaceOrNewLine(*(szCurrent+3))) {
+ if (0 == ASSIMP_strincmp(szCurrent, "end", 3) && IsSpaceOrNewLine(*(szCurrent+3))) {
szCurrent += 4;
break;
}
- ParseNodeInfo(szCurrent,&szCurrent);
+ ParseNodeInfo(szCurrent,&szCurrent, end);
}
- SkipSpacesAndLineEnd(szCurrent,&szCurrent);
+ SkipSpacesAndLineEnd(szCurrent, &szCurrent, end);
*szCurrentOut = szCurrent;
}
// ------------------------------------------------------------------------------------------------
// Parse the triangles section of the file
-void SMDImporter::ParseTrianglesSection(const char* szCurrent, const char** szCurrentOut) {
+void SMDImporter::ParseTrianglesSection(const char *szCurrent, const char **szCurrentOut, const char *end) {
// Parse a triangle, parse another triangle, parse the next triangle ...
// and so on until we reach a token that looks quite similar to "end"
for ( ;; ) {
- if(!SkipSpacesAndLineEnd(szCurrent,&szCurrent)) {
+ if(!SkipSpacesAndLineEnd(szCurrent,&szCurrent, end)) {
break;
}
@@ -750,17 +750,17 @@ void SMDImporter::ParseTrianglesSection(const char* szCurrent, const char** szCu
if (TokenMatch(szCurrent,"end",3)) {
break;
}
- ParseTriangle(szCurrent,&szCurrent);
+ ParseTriangle(szCurrent,&szCurrent, end);
}
- SkipSpacesAndLineEnd(szCurrent,&szCurrent);
+ SkipSpacesAndLineEnd(szCurrent,&szCurrent, end);
*szCurrentOut = szCurrent;
}
// ------------------------------------------------------------------------------------------------
// Parse the vertex animation section of the file
-void SMDImporter::ParseVASection(const char* szCurrent, const char** szCurrentOut) {
+void SMDImporter::ParseVASection(const char *szCurrent, const char **szCurrentOut, const char *end) {
unsigned int iCurIndex = 0;
for ( ;; ) {
- if (!SkipSpacesAndLineEnd(szCurrent,&szCurrent)) {
+ if (!SkipSpacesAndLineEnd(szCurrent,&szCurrent, end)) {
break;
}
@@ -774,10 +774,10 @@ void SMDImporter::ParseVASection(const char* szCurrent, const char** szCurrentOu
// NOTE: The doc says that time values COULD be negative ...
// NOTE2: this is the shape key -> valve docs
int iTime = 0;
- if(!ParseSignedInt(szCurrent,&szCurrent,iTime) || configFrameID != (unsigned int)iTime) {
+ if (!ParseSignedInt(szCurrent, &szCurrent, end, iTime) || configFrameID != (unsigned int)iTime) {
break;
}
- SkipLine(szCurrent,&szCurrent);
+ SkipLine(szCurrent,&szCurrent, end);
} else {
if(0 == iCurIndex) {
asTriangles.emplace_back();
@@ -785,7 +785,7 @@ void SMDImporter::ParseVASection(const char* szCurrent, const char** szCurrentOu
if (++iCurIndex == 3) {
iCurIndex = 0;
}
- ParseVertex(szCurrent,&szCurrent,asTriangles.back().avVertices[iCurIndex],true);
+ ParseVertex(szCurrent,&szCurrent, end, asTriangles.back().avVertices[iCurIndex],true);
}
}
@@ -794,16 +794,16 @@ void SMDImporter::ParseVASection(const char* szCurrent, const char** szCurrentOu
asTriangles.pop_back();
}
- SkipSpacesAndLineEnd(szCurrent,&szCurrent);
+ SkipSpacesAndLineEnd(szCurrent,&szCurrent, end);
*szCurrentOut = szCurrent;
}
// ------------------------------------------------------------------------------------------------
// Parse the skeleton section of the file
-void SMDImporter::ParseSkeletonSection(const char* szCurrent, const char** szCurrentOut) {
+void SMDImporter::ParseSkeletonSection(const char *szCurrent, const char **szCurrentOut, const char *end) {
int iTime = 0;
for ( ;; ) {
- if (!SkipSpacesAndLineEnd(szCurrent,&szCurrent)) {
+ if (!SkipSpacesAndLineEnd(szCurrent,&szCurrent, end)) {
break;
}
@@ -811,15 +811,15 @@ void SMDImporter::ParseSkeletonSection(const char* szCurrent, const char** szCur
if (TokenMatch(szCurrent,"end",3)) {
break;
} else if (TokenMatch(szCurrent,"time",4)) {
- // "time <n>\n" - Specifies the current animation frame
- if(!ParseSignedInt(szCurrent,&szCurrent,iTime)) {
+ // "time <n>\n" - Specifies the current animation frame
+ if (!ParseSignedInt(szCurrent, &szCurrent, end, iTime)) {
break;
}
iSmallestFrame = std::min(iSmallestFrame,iTime);
- SkipLine(szCurrent,&szCurrent);
+ SkipLine(szCurrent, &szCurrent, end);
} else {
- ParseSkeletonElement(szCurrent,&szCurrent,iTime);
+ ParseSkeletonElement(szCurrent, &szCurrent, end, iTime);
}
}
*szCurrentOut = szCurrent;
@@ -827,16 +827,16 @@ void SMDImporter::ParseSkeletonSection(const char* szCurrent, const char** szCur
// ------------------------------------------------------------------------------------------------
#define SMDI_PARSE_RETURN { \
- SkipLine(szCurrent,&szCurrent); \
+ SkipLine(szCurrent,&szCurrent, end); \
*szCurrentOut = szCurrent; \
return; \
}
// ------------------------------------------------------------------------------------------------
// Parse a node line
-void SMDImporter::ParseNodeInfo(const char* szCurrent, const char** szCurrentOut) {
+void SMDImporter::ParseNodeInfo(const char *szCurrent, const char **szCurrentOut, const char *end) {
unsigned int iBone = 0;
- SkipSpacesAndLineEnd(szCurrent,&szCurrent);
- if ( !ParseUnsignedInt(szCurrent,&szCurrent,iBone) || !SkipSpaces(szCurrent,&szCurrent)) {
+ SkipSpacesAndLineEnd(szCurrent, &szCurrent, end);
+ if ( !ParseUnsignedInt(szCurrent, &szCurrent, end, iBone) || !SkipSpaces(szCurrent,&szCurrent, end)) {
throw DeadlyImportError("Unexpected EOF/EOL while parsing bone index");
}
if (iBone == UINT_MAX) {
@@ -877,7 +877,7 @@ void SMDImporter::ParseNodeInfo(const char* szCurrent, const char** szCurrentOut
szCurrent = szEnd;
// the only negative bone parent index that could occur is -1 AFAIK
- if(!ParseSignedInt(szCurrent,&szCurrent,(int&)bone.iParent)) {
+ if(!ParseSignedInt(szCurrent, &szCurrent, end, (int&)bone.iParent)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone parent index. Assuming -1");
SMDI_PARSE_RETURN;
}
@@ -888,12 +888,12 @@ void SMDImporter::ParseNodeInfo(const char* szCurrent, const char** szCurrentOut
// ------------------------------------------------------------------------------------------------
// Parse a skeleton element
-void SMDImporter::ParseSkeletonElement(const char* szCurrent, const char** szCurrentOut,int iTime) {
+void SMDImporter::ParseSkeletonElement(const char *szCurrent, const char **szCurrentOut, const char *end, int iTime) {
aiVector3D vPos;
aiVector3D vRot;
unsigned int iBone = 0;
- if(!ParseUnsignedInt(szCurrent,&szCurrent,iBone)) {
+ if (!ParseUnsignedInt(szCurrent, &szCurrent, end, iBone)) {
ASSIMP_LOG_ERROR("Unexpected EOF/EOL while parsing bone index");
SMDI_PARSE_RETURN;
}
@@ -907,27 +907,27 @@ void SMDImporter::ParseSkeletonElement(const char* szCurrent, const char** szCur
SMD::Bone::Animation::MatrixKey& key = bone.sAnim.asKeys.back();
key.dTime = (double)iTime;
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vPos.x)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vPos.x)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.pos.x");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vPos.y)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vPos.y)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.pos.y");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vPos.z)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vPos.z)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.pos.z");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vRot.x)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vRot.x)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.rot.x");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vRot.y)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vRot.y)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.rot.y");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vRot.z)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vRot.z)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.rot.z");
SMDI_PARSE_RETURN;
}
@@ -947,11 +947,11 @@ void SMDImporter::ParseSkeletonElement(const char* szCurrent, const char** szCur
// ------------------------------------------------------------------------------------------------
// Parse a triangle
-void SMDImporter::ParseTriangle(const char* szCurrent, const char** szCurrentOut) {
+void SMDImporter::ParseTriangle(const char *szCurrent, const char **szCurrentOut, const char *end) {
asTriangles.emplace_back();
SMD::Face& face = asTriangles.back();
- if(!SkipSpaces(szCurrent,&szCurrent)) {
+ if(!SkipSpaces(szCurrent, &szCurrent, end)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing a triangle");
return;
}
@@ -963,19 +963,19 @@ void SMDImporter::ParseTriangle(const char* szCurrent, const char** szCurrentOut
// ... and get the index that belongs to this file name
face.iTexture = GetTextureIndex(std::string(szLast,(uintptr_t)szCurrent-(uintptr_t)szLast));
- SkipSpacesAndLineEnd(szCurrent,&szCurrent);
+ SkipSpacesAndLineEnd(szCurrent, &szCurrent, end);
// load three vertices
for (auto &avVertex : face.avVertices) {
- ParseVertex(szCurrent,&szCurrent, avVertex);
+ ParseVertex(szCurrent, &szCurrent, end, avVertex);
}
*szCurrentOut = szCurrent;
}
// ------------------------------------------------------------------------------------------------
// Parse a float
-bool SMDImporter::ParseFloat(const char* szCurrent, const char** szCurrentOut, float& out) {
- if(!SkipSpaces(&szCurrent)) {
+bool SMDImporter::ParseFloat(const char *szCurrent, const char **szCurrentOut, const char *end, float &out) {
+ if (!SkipSpaces(&szCurrent, end)) {
return false;
}
@@ -985,8 +985,8 @@ bool SMDImporter::ParseFloat(const char* szCurrent, const char** szCurrentOut, f
// ------------------------------------------------------------------------------------------------
// Parse an unsigned int
-bool SMDImporter::ParseUnsignedInt(const char* szCurrent, const char** szCurrentOut, unsigned int& out) {
- if(!SkipSpaces(&szCurrent)) {
+bool SMDImporter::ParseUnsignedInt(const char *szCurrent, const char **szCurrentOut, const char *end, unsigned int &out) {
+ if(!SkipSpaces(&szCurrent, end)) {
return false;
}
@@ -996,8 +996,8 @@ bool SMDImporter::ParseUnsignedInt(const char* szCurrent, const char** szCurrent
// ------------------------------------------------------------------------------------------------
// Parse a signed int
-bool SMDImporter::ParseSignedInt(const char* szCurrent, const char** szCurrentOut, int& out) {
- if(!SkipSpaces(&szCurrent)) {
+bool SMDImporter::ParseSignedInt(const char *szCurrent, const char **szCurrentOut, const char *end, int &out) {
+ if(!SkipSpaces(&szCurrent, end)) {
return false;
}
@@ -1008,37 +1008,37 @@ bool SMDImporter::ParseSignedInt(const char* szCurrent, const char** szCurrentOu
// ------------------------------------------------------------------------------------------------
// Parse a vertex
void SMDImporter::ParseVertex(const char* szCurrent,
- const char** szCurrentOut, SMD::Vertex& vertex,
+ const char **szCurrentOut, const char *end, SMD::Vertex &vertex,
bool bVASection /*= false*/) {
- if (SkipSpaces(&szCurrent) && IsLineEnd(*szCurrent)) {
- SkipSpacesAndLineEnd(szCurrent,&szCurrent);
- return ParseVertex(szCurrent,szCurrentOut,vertex,bVASection);
+ if (SkipSpaces(&szCurrent, end) && IsLineEnd(*szCurrent)) {
+ SkipSpacesAndLineEnd(szCurrent,&szCurrent, end);
+ return ParseVertex(szCurrent, szCurrentOut, end, vertex, bVASection);
}
- if(!ParseSignedInt(szCurrent,&szCurrent,(int&)vertex.iParentNode)) {
+ if(!ParseSignedInt(szCurrent, &szCurrent, end, (int&)vertex.iParentNode)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.parent");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.pos.x)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vertex.pos.x)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.pos.x");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.pos.y)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vertex.pos.y)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.pos.y");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.pos.z)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vertex.pos.z)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.pos.z");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.nor.x)) {
+ if(!ParseFloat(szCurrent,&szCurrent,end, (float&)vertex.nor.x)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.nor.x");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.nor.y)) {
+ if(!ParseFloat(szCurrent,&szCurrent, end, (float&)vertex.nor.y)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.nor.y");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.nor.z)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vertex.nor.z)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.nor.z");
SMDI_PARSE_RETURN;
}
@@ -1047,11 +1047,11 @@ void SMDImporter::ParseVertex(const char* szCurrent,
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.uv.x)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vertex.uv.x)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.uv.x");
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.uv.y)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, (float&)vertex.uv.y)) {
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.uv.y");
SMDI_PARSE_RETURN;
}
@@ -1059,16 +1059,16 @@ void SMDImporter::ParseVertex(const char* szCurrent,
// now read the number of bones affecting this vertex
// all elements from now are fully optional, we don't need them
unsigned int iSize = 0;
- if(!ParseUnsignedInt(szCurrent,&szCurrent,iSize)) {
+ if(!ParseUnsignedInt(szCurrent, &szCurrent, end, iSize)) {
SMDI_PARSE_RETURN;
}
vertex.aiBoneLinks.resize(iSize,std::pair<unsigned int, float>(0,0.0f));
for (auto &aiBoneLink : vertex.aiBoneLinks) {
- if(!ParseUnsignedInt(szCurrent,&szCurrent,aiBoneLink.first)) {
+ if(!ParseUnsignedInt(szCurrent, &szCurrent, end, aiBoneLink.first)) {
SMDI_PARSE_RETURN;
}
- if(!ParseFloat(szCurrent,&szCurrent,aiBoneLink.second)) {
+ if(!ParseFloat(szCurrent, &szCurrent, end, aiBoneLink.second)) {
SMDI_PARSE_RETURN;
}
}
@@ -1077,4 +1077,6 @@ void SMDImporter::ParseVertex(const char* szCurrent,
SMDI_PARSE_RETURN;
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_SMD_IMPORTER
diff --git a/code/AssetLib/SMD/SMDLoader.h b/code/AssetLib/SMD/SMDLoader.h
index adf80ba14..c2f2f0a49 100644
--- a/code/AssetLib/SMD/SMDLoader.h
+++ b/code/AssetLib/SMD/SMDLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -162,7 +162,7 @@ struct Bone {
class ASSIMP_API SMDImporter : public BaseImporter {
public:
SMDImporter();
- ~SMDImporter() override;
+ ~SMDImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
@@ -206,7 +206,7 @@ protected:
* the next section (or to EOF)
*/
void ParseTrianglesSection(const char* szCurrent,
- const char** szCurrentOut);
+ const char **szCurrentOut, const char *end);
// -------------------------------------------------------------------
/** Parse the vertex animation section in VTA files
@@ -216,7 +216,7 @@ protected:
* the next section (or to EOF)
*/
void ParseVASection(const char* szCurrent,
- const char** szCurrentOut);
+ const char **szCurrentOu, const char *end);
// -------------------------------------------------------------------
/** Parse the nodes section of the SMD file
@@ -226,7 +226,7 @@ protected:
* the next section (or to EOF)
*/
void ParseNodesSection(const char* szCurrent,
- const char** szCurrentOut);
+ const char **szCurrentOut, const char *end);
// -------------------------------------------------------------------
/** Parse the skeleton section of the SMD file
@@ -236,7 +236,7 @@ protected:
* the next section (or to EOF)
*/
void ParseSkeletonSection(const char* szCurrent,
- const char** szCurrentOut);
+ const char **szCurrentOut, const char *end);
// -------------------------------------------------------------------
/** Parse a single triangle in the SMD file
@@ -245,8 +245,7 @@ protected:
* \param szCurrentOut Receives the output cursor position
*/
void ParseTriangle(const char* szCurrent,
- const char** szCurrentOut);
-
+ const char **szCurrentOut, const char *end);
// -------------------------------------------------------------------
/** Parse a single vertex in the SMD file
@@ -256,7 +255,7 @@ protected:
* \param vertex Vertex to be filled
*/
void ParseVertex(const char* szCurrent,
- const char** szCurrentOut, SMD::Vertex& vertex,
+ const char **szCurrentOut, const char *end, SMD::Vertex &vertex,
bool bVASection = false);
// -------------------------------------------------------------------
@@ -271,32 +270,31 @@ protected:
/** Parse a line in the skeleton section
*/
void ParseSkeletonElement(const char* szCurrent,
- const char** szCurrentOut,int iTime);
+ const char **szCurrentOut, const char *end, int iTime);
// -------------------------------------------------------------------
/** Parse a line in the nodes section
*/
void ParseNodeInfo(const char* szCurrent,
- const char** szCurrentOut);
-
+ const char **szCurrentOut, const char *end);
// -------------------------------------------------------------------
/** Parse a floating-point value
*/
bool ParseFloat(const char* szCurrent,
- const char** szCurrentOut, float& out);
+ const char **szCurrentOut, const char *end, float &out);
// -------------------------------------------------------------------
/** Parse an unsigned integer. There may be no sign!
*/
bool ParseUnsignedInt(const char* szCurrent,
- const char** szCurrentOut, unsigned int& out);
+ const char **szCurrentOut, const char *end, unsigned int &out);
// -------------------------------------------------------------------
/** Parse a signed integer. Signs (+,-) are handled.
*/
bool ParseSignedInt(const char* szCurrent,
- const char** szCurrentOut, int& out);
+ const char **szCurrentOut, const char *end, int &out);
// -------------------------------------------------------------------
/** Fix invalid time values in the file
@@ -304,7 +302,7 @@ protected:
void FixTimeValues();
// -------------------------------------------------------------------
- /** Add all children of a bone as subnodes to a node
+ /** Add all children of a bone as sub-nodes to a node
* \param pcNode Parent node
* \param iParent Parent bone index
*/
@@ -329,17 +327,15 @@ protected:
// -------------------------------------------------------------------
- inline bool SkipLine( const char* in, const char** out)
- {
- Assimp::SkipLine(in,out);
+ inline bool SkipLine( const char* in, const char** out, const char *end) {
+ Assimp::SkipLine(in, out, end);
++iLineNumber;
return true;
}
// -------------------------------------------------------------------
- inline bool SkipSpacesAndLineEnd( const char* in, const char** out)
- {
+ inline bool SkipSpacesAndLineEnd(const char *in, const char **out, const char *end) {
++iLineNumber;
- return Assimp::SkipSpacesAndLineEnd(in,out);
+ return Assimp::SkipSpacesAndLineEnd(in, out, end);
}
private:
@@ -349,6 +345,7 @@ private:
/** Buffer to hold the loaded file */
std::vector<char> mBuffer;
+ char *mEnd;
/** Output scene to be filled
*/
diff --git a/code/AssetLib/STEPParser/STEPFileEncoding.cpp b/code/AssetLib/STEPParser/STEPFileEncoding.cpp
index d4456e674..d7f512cbb 100644
--- a/code/AssetLib/STEPParser/STEPFileEncoding.cpp
+++ b/code/AssetLib/STEPParser/STEPFileEncoding.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -45,11 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "STEPFileEncoding.h"
#include <assimp/fast_atof.h>
-#ifdef ASSIMP_USE_HUNTER
-# include <utf8.h>
-#else
-# include <contrib/utf8cpp/source/utf8.h>
-#endif
+#include "utf8.h"
#include <memory>
diff --git a/code/AssetLib/STEPParser/STEPFileEncoding.h b/code/AssetLib/STEPParser/STEPFileEncoding.h
index 950c9b3e2..6988a5822 100644
--- a/code/AssetLib/STEPParser/STEPFileEncoding.h
+++ b/code/AssetLib/STEPParser/STEPFileEncoding.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/STEPParser/STEPFileReader.cpp b/code/AssetLib/STEPParser/STEPFileReader.cpp
index 2bcfa1755..6bc8981f1 100644
--- a/code/AssetLib/STEPParser/STEPFileReader.cpp
+++ b/code/AssetLib/STEPParser/STEPFileReader.cpp
@@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -40,9 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file STEPFileReader.cpp
+/**
+ * @file STEPFileReader.cpp
* @brief Implementation of the STEP file parser, which fills a
- * STEP::DB with data read from a file.
+ * STEP::DB with data read from a file.
*/
#include "STEPFileReader.h"
@@ -58,34 +58,28 @@ using namespace Assimp;
namespace EXPRESS = STEP::EXPRESS;
// ------------------------------------------------------------------------------------------------
-std::string AddLineNumber(const std::string& s,uint64_t line /*= LINE_NOT_SPECIFIED*/, const std::string& prefix = std::string())
-{
+std::string AddLineNumber(const std::string& s,uint64_t line /*= LINE_NOT_SPECIFIED*/, const std::string& prefix = std::string()) {
return line == STEP::SyntaxError::LINE_NOT_SPECIFIED ? prefix+s : static_cast<std::string>( (Formatter::format(),prefix,"(line ",line,") ",s) );
}
// ------------------------------------------------------------------------------------------------
-std::string AddEntityID(const std::string& s,uint64_t entity /*= ENTITY_NOT_SPECIFIED*/, const std::string& prefix = std::string())
-{
+std::string AddEntityID(const std::string& s,uint64_t entity /*= ENTITY_NOT_SPECIFIED*/, const std::string& prefix = std::string()) {
return entity == STEP::TypeError::ENTITY_NOT_SPECIFIED ? prefix+s : static_cast<std::string>( (Formatter::format(),prefix,"(entity #",entity,") ",s));
}
// ------------------------------------------------------------------------------------------------
-STEP::SyntaxError::SyntaxError (const std::string& s,uint64_t line /* = LINE_NOT_SPECIFIED */)
-: DeadlyImportError(AddLineNumber(s,line))
-{
-
+STEP::SyntaxError::SyntaxError (const std::string& s,uint64_t line) : DeadlyImportError(AddLineNumber(s,line)) {
+ // empty
}
// ------------------------------------------------------------------------------------------------
-STEP::TypeError::TypeError (const std::string& s,uint64_t entity /* = ENTITY_NOT_SPECIFIED */,uint64_t line /*= LINE_NOT_SPECIFIED*/)
-: DeadlyImportError(AddLineNumber(AddEntityID(s,entity),line))
-{
-
+STEP::TypeError::TypeError (const std::string& s,uint64_t entity, uint64_t line) : DeadlyImportError(AddLineNumber(AddEntityID(s,entity),line)) {
+ // empty
}
-static const char *ISO_Token = "ISO-10303-21;";
-static const char *FILE_SCHEMA_Token = "FILE_SCHEMA";
+static constexpr char ISO_Token[] = "ISO-10303-21;";
+static constexpr char FILE_SCHEMA_Token[] = "FILE_SCHEMA";
// ------------------------------------------------------------------------------------------------
STEP::DB* STEP::ReadFileHeader(std::shared_ptr<IOStream> stream) {
std::shared_ptr<StreamReaderLE> reader = std::shared_ptr<StreamReaderLE>(new StreamReaderLE(std::move(stream)));
@@ -110,8 +104,9 @@ STEP::DB* STEP::ReadFileHeader(std::shared_ptr<IOStream> stream) {
if (s.substr(0,11) == FILE_SCHEMA_Token) {
const char* sz = s.c_str()+11;
- SkipSpaces(sz,&sz);
- std::shared_ptr< const EXPRESS::DataType > schema = EXPRESS::DataType::Parse(sz);
+ const char *end = s.c_str() + s.size();
+ SkipSpaces(sz,&sz, end);
+ std::shared_ptr< const EXPRESS::DataType > schema = EXPRESS::DataType::Parse(sz, end);
// the file schema should be a regular list entity, although it usually contains exactly one entry
// since the list itself is contained in a regular parameter list, we actually have
@@ -304,10 +299,10 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
}
// ------------------------------------------------------------------------------------------------
-std::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= nullptr*/)
+std::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*& inout, const char *end, uint64_t line, const EXPRESS::ConversionSchema* schema /*= nullptr*/)
{
const char* cur = inout;
- SkipSpaces(&cur);
+ SkipSpaces(&cur, end);
if (*cur == ',' || IsSpaceOrNewLine(*cur)) {
throw STEP::SyntaxError("unexpected token, expected parameter",line);
}
@@ -325,7 +320,7 @@ std::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*& i
std::transform(s.begin(),s.end(),s.begin(),&ai_tolower<char> );
if (schema->IsKnownToken(s)) {
for(cur = t+1;*cur++ != '(';);
- std::shared_ptr<const EXPRESS::DataType> dt = Parse(cur);
+ std::shared_ptr<const EXPRESS::DataType> dt = Parse(cur, end);
inout = *cur ? cur+1 : cur;
return dt;
}
@@ -348,7 +343,7 @@ std::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*& i
else if (*cur == '(' ) {
// start of an aggregate, further parsing is done by the LIST factory constructor
inout = cur;
- return EXPRESS::LIST::Parse(inout,line,schema);
+ return EXPRESS::LIST::Parse(inout, end, line, schema);
}
else if (*cur == '.' ) {
// enum (includes boolean)
@@ -427,9 +422,10 @@ std::shared_ptr<const EXPRESS::DataType> EXPRESS::DataType::Parse(const char*& i
}
// ------------------------------------------------------------------------------------------------
-std::shared_ptr<const EXPRESS::LIST> EXPRESS::LIST::Parse(const char*& inout,uint64_t line, const EXPRESS::ConversionSchema* schema /*= nullptr*/) {
+std::shared_ptr<const EXPRESS::LIST> EXPRESS::LIST::Parse(const char*& inout, const char *end,
+ uint64_t line, const EXPRESS::ConversionSchema* schema) {
const std::shared_ptr<EXPRESS::LIST> list = std::make_shared<EXPRESS::LIST>();
- EXPRESS::LIST::MemberList& members = list->members;
+ EXPRESS::LIST::MemberList& cur_members = list->members;
const char* cur = inout;
if (*cur++ != '(') {
@@ -442,19 +438,19 @@ std::shared_ptr<const EXPRESS::LIST> EXPRESS::LIST::Parse(const char*& inout,uin
count += (*c == ',' ? 1 : 0);
}
- members.reserve(count);
+ cur_members.reserve(count);
for(;;++cur) {
if (!*cur) {
throw STEP::SyntaxError("unexpected end of line while reading list");
}
- SkipSpaces(cur,&cur);
+ SkipSpaces(cur,&cur, end);
if (*cur == ')') {
break;
}
- members.push_back( EXPRESS::DataType::Parse(cur,line,schema));
- SkipSpaces(cur,&cur);
+ cur_members.push_back(EXPRESS::DataType::Parse(cur, end, line, schema));
+ SkipSpaces(cur, &cur, end);
if (*cur != ',') {
if (*cur == ')') {
@@ -464,7 +460,7 @@ std::shared_ptr<const EXPRESS::LIST> EXPRESS::LIST::Parse(const char*& inout,uin
}
}
- inout = cur+1;
+ inout = cur + 1;
return list;
}
@@ -543,7 +539,8 @@ void STEP::LazyObject::LazyInit() const {
}
const char* acopy = args;
- std::shared_ptr<const EXPRESS::LIST> conv_args = EXPRESS::LIST::Parse(acopy,(uint64_t)STEP::SyntaxError::LINE_NOT_SPECIFIED,&db.GetSchema());
+ const char *end = acopy + std::strlen(args);
+ std::shared_ptr<const EXPRESS::LIST> conv_args = EXPRESS::LIST::Parse(acopy, end, (uint64_t)STEP::SyntaxError::LINE_NOT_SPECIFIED,&db.GetSchema());
delete[] args;
args = nullptr;
diff --git a/code/AssetLib/STEPParser/STEPFileReader.h b/code/AssetLib/STEPParser/STEPFileReader.h
index 8a57937c0..85a7c5cb0 100644
--- a/code/AssetLib/STEPParser/STEPFileReader.h
+++ b/code/AssetLib/STEPParser/STEPFileReader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -60,8 +60,7 @@ void ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, const char* const*
/// @brief Helper to read a file.
template <size_t N, size_t N2>
-inline
-void ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, const char* const (&arr)[N], const char* const (&arr2)[N2]) {
+inline void ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, const char* const (&arr)[N], const char* const (&arr2)[N2]) {
return ReadFile(db,scheme,arr,N,arr2,N2);
}
diff --git a/code/AssetLib/STL/STLExporter.cpp b/code/AssetLib/STL/STLExporter.cpp
index 9bbc2063f..0ff96296a 100644
--- a/code/AssetLib/STL/STLExporter.cpp
+++ b/code/AssetLib/STL/STLExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/STL/STLExporter.h b/code/AssetLib/STL/STLExporter.h
index 066dcfefd..b751e196c 100644
--- a/code/AssetLib/STL/STLExporter.h
+++ b/code/AssetLib/STL/STLExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/STL/STLLoader.cpp b/code/AssetLib/STL/STLLoader.cpp
index 9c0fb4f59..38cd2a0b8 100644
--- a/code/AssetLib/STL/STLLoader.cpp
+++ b/code/AssetLib/STL/STLLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -52,11 +52,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp>
#include <memory>
-using namespace Assimp;
+namespace Assimp {
namespace {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Stereolithography (STL) Importer",
"",
"",
@@ -98,7 +98,7 @@ static bool IsAsciiSTL(const char *buffer, size_t fileSize) {
const char *bufferEnd = buffer + fileSize;
- if (!SkipSpaces(&buffer)) {
+ if (!SkipSpaces(&buffer, bufferEnd)) {
return false;
}
@@ -129,7 +129,7 @@ STLImporter::STLImporter() :
mBuffer(),
mFileSize(0),
mScene() {
- // empty
+ // empty
}
// ------------------------------------------------------------------------------------------------
@@ -244,19 +244,19 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
aiNode *node = new aiNode;
node->mParent = root;
nodes.push_back(node);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, bufferEnd);
ai_assert(!IsLineEnd(sz));
sz += 5; // skip the "solid"
- SkipSpaces(&sz);
+ SkipSpaces(&sz, bufferEnd);
const char *szMe = sz;
- while (!::IsSpaceOrNewLine(*sz)) {
+ while (!IsSpaceOrNewLine(*sz)) {
sz++;
}
size_t temp = (size_t)(sz - szMe);
// setup the name of the node
- if ( temp ) {
+ if (temp) {
if (temp >= MAXLEN) {
throw DeadlyImportError("STL: Node name too long");
}
@@ -270,7 +270,7 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
unsigned int faceVertexCounter = 3;
for (;;) {
// go to the next token
- if (!SkipSpacesAndLineEnd(&sz)) {
+ if (!SkipSpacesAndLineEnd(&sz, bufferEnd)) {
// seems we're finished although there was no end marker
ASSIMP_LOG_WARN("STL: unexpected EOF. \'endsolid\' keyword was expected");
break;
@@ -284,7 +284,7 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
faceVertexCounter = 0;
sz += 6;
- SkipSpaces(&sz);
+ SkipSpaces(&sz, bufferEnd);
if (strncmp(sz, "normal", 6)) {
ASSIMP_LOG_WARN("STL: a facet normal vector was expected but not found");
} else {
@@ -293,17 +293,17 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
}
aiVector3D vn;
sz += 7;
- SkipSpaces(&sz);
+ SkipSpaces(&sz, bufferEnd);
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)vn.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, bufferEnd);
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)vn.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, bufferEnd);
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)vn.z);
normalBuffer.emplace_back(vn);
normalBuffer.emplace_back(vn);
normalBuffer.emplace_back(vn);
}
- } else if (!strncmp(sz, "vertex", 6) && ::IsSpaceOrNewLine(*(sz + 6))) { // vertex 1.50000 1.50000 0.00000
+ } else if (!strncmp(sz, "vertex", 6) && IsSpaceOrNewLine(*(sz + 6))) { // vertex 1.50000 1.50000 0.00000
if (faceVertexCounter >= 3) {
ASSIMP_LOG_ERROR("STL: a facet with more than 3 vertices has been found");
++sz;
@@ -312,27 +312,27 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
throw DeadlyImportError("STL: unexpected EOF while parsing facet");
}
sz += 7;
- SkipSpaces(&sz);
+ SkipSpaces(&sz, bufferEnd);
positionBuffer.emplace_back();
aiVector3D *vn = &positionBuffer.back();
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)vn->x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, bufferEnd);
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)vn->y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, bufferEnd);
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)vn->z);
faceVertexCounter++;
}
} else if (!::strncmp(sz, "endsolid", 8)) {
do {
++sz;
- } while (!::IsLineEnd(*sz));
- SkipSpacesAndLineEnd(&sz);
+ } while (!IsLineEnd(*sz));
+ SkipSpacesAndLineEnd(&sz, bufferEnd);
// finished!
break;
} else { // else skip the whole identifier
do {
++sz;
- } while (!::IsSpaceOrNewLine(*sz));
+ } while (!IsSpaceOrNewLine(*sz));
}
}
@@ -349,14 +349,14 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
throw DeadlyImportError("Normal buffer size does not match position buffer size");
}
- // only process positionbuffer when filled, else exception when accessing with index operator
+ // only process position buffer when filled, else exception when accessing with index operator
// see line 353: only warning is triggered
- // see line 373(now): access to empty positionbuffer with index operator forced exception
+ // see line 373(now): access to empty position buffer with index operator forced exception
if (!positionBuffer.empty()) {
pMesh->mNumFaces = static_cast<unsigned int>(positionBuffer.size() / 3);
pMesh->mNumVertices = static_cast<unsigned int>(positionBuffer.size());
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
- for (size_t i=0; i<pMesh->mNumVertices; ++i ) {
+ for (size_t i = 0; i < pMesh->mNumVertices; ++i) {
pMesh->mVertices[i].x = positionBuffer[i].x;
pMesh->mVertices[i].y = positionBuffer[i].y;
pMesh->mVertices[i].z = positionBuffer[i].z;
@@ -366,7 +366,7 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
// also only process normalBuffer when filled, else exception when accessing with index operator
if (!normalBuffer.empty()) {
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
- for (size_t i=0; i<pMesh->mNumVertices; ++i ) {
+ for (size_t i = 0; i < pMesh->mNumVertices; ++i) {
pMesh->mNormals[i].x = normalBuffer[i].x;
pMesh->mNormals[i].y = normalBuffer[i].y;
pMesh->mNormals[i].z = normalBuffer[i].z;
@@ -450,9 +450,8 @@ bool STLImporter::LoadBinaryFile() {
aiVector3D *vp = pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
aiVector3D *vn = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
- typedef aiVector3t<float> aiVector3F;
- aiVector3F *theVec;
- aiVector3F theVec3F;
+ aiVector3f *theVec;
+ aiVector3f theVec3F;
for (unsigned int i = 0; i < pMesh->mNumFaces; ++i) {
// NOTE: Blender sometimes writes empty normals ... this is not
@@ -460,8 +459,8 @@ bool STLImporter::LoadBinaryFile() {
// There's one normal for the face in the STL; use it three times
// for vertex normals
- theVec = (aiVector3F *)sz;
- ::memcpy(&theVec3F, theVec, sizeof(aiVector3F));
+ theVec = (aiVector3f *)sz;
+ ::memcpy(&theVec3F, theVec, sizeof(aiVector3f));
vn->x = theVec3F.x;
vn->y = theVec3F.y;
vn->z = theVec3F.z;
@@ -471,7 +470,7 @@ bool STLImporter::LoadBinaryFile() {
vn += 3;
// vertex 1
- ::memcpy(&theVec3F, theVec, sizeof(aiVector3F));
+ ::memcpy(&theVec3F, theVec, sizeof(aiVector3f));
vp->x = theVec3F.x;
vp->y = theVec3F.y;
vp->z = theVec3F.z;
@@ -479,7 +478,7 @@ bool STLImporter::LoadBinaryFile() {
++vp;
// vertex 2
- ::memcpy(&theVec3F, theVec, sizeof(aiVector3F));
+ ::memcpy(&theVec3F, theVec, sizeof(aiVector3f));
vp->x = theVec3F.x;
vp->y = theVec3F.y;
vp->z = theVec3F.z;
@@ -487,7 +486,7 @@ bool STLImporter::LoadBinaryFile() {
++vp;
// vertex 3
- ::memcpy(&theVec3F, theVec, sizeof(aiVector3F));
+ ::memcpy(&theVec3F, theVec, sizeof(aiVector3f));
vp->x = theVec3F.x;
vp->y = theVec3F.y;
vp->z = theVec3F.z;
@@ -570,4 +569,6 @@ void STLImporter::pushMeshesToNode(std::vector<unsigned int> &meshIndices, aiNod
meshIndices.clear();
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_STL_IMPORTER
diff --git a/code/AssetLib/STL/STLLoader.h b/code/AssetLib/STL/STLLoader.h
index 0be6a95f0..cc6ab9607 100644
--- a/code/AssetLib/STL/STLLoader.h
+++ b/code/AssetLib/STL/STLLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Step/STEPFile.h b/code/AssetLib/Step/STEPFile.h
index 76a9370f5..d8bc0ac49 100644
--- a/code/AssetLib/Step/STEPFile.h
+++ b/code/AssetLib/Step/STEPFile.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -199,35 +199,27 @@ public:
}
public:
- /** parse a variable from a string and set 'inout' to the character
- * behind the last consumed character. An optional schema enables,
- * if specified, automatic conversion of custom data types.
- *
- * @throw SyntaxError
- */
- static std::shared_ptr<const EXPRESS::DataType> Parse(const char *&inout,
- uint64_t line = SyntaxError::LINE_NOT_SPECIFIED,
- const EXPRESS::ConversionSchema *schema = nullptr);
+ /// @brief Parse a variable from a string and set 'inout' to the character behind the last consumed character.
+ ///
+ /// An optional schema enables, if specified, automatic conversion of custom data types.
+ ///
+ /// @throw SyntaxError
+ static std::shared_ptr<const EXPRESS::DataType> Parse(const char *&inout, const char *end,
+ uint64_t line = SyntaxError::LINE_NOT_SPECIFIED, const EXPRESS::ConversionSchema *schema = nullptr);
};
typedef DataType SELECT;
typedef DataType LOGICAL;
// -------------------------------------------------------------------------------
-/** Sentinel class to represent explicitly unset (optional) fields ($) */
+/// Sentinel class to represent explicitly unset (optional) fields ($)
// -------------------------------------------------------------------------------
-class UNSET : public DataType {
-public:
-private:
-};
+class UNSET : public DataType {};
// -------------------------------------------------------------------------------
-/** Sentinel class to represent explicitly derived fields (*) */
+/// Sentinel class to represent explicitly derived fields (*)
// -------------------------------------------------------------------------------
-class ISDERIVED : public DataType {
-public:
-private:
-};
+class ISDERIVED : public DataType {};
// -------------------------------------------------------------------------------
/** Shared implementation for some of the primitive data type, i.e. int, float
@@ -304,7 +296,7 @@ public:
public:
/** @see DaraType::Parse
*/
- static std::shared_ptr<const EXPRESS::LIST> Parse(const char *&inout,
+ static std::shared_ptr<const EXPRESS::LIST> Parse(const char *&inout, const char *end,
uint64_t line = SyntaxError::LINE_NOT_SPECIFIED,
const EXPRESS::ConversionSchema *schema = nullptr);
diff --git a/code/AssetLib/Step/StepExporter.cpp b/code/AssetLib/Step/StepExporter.cpp
index e13c9edab..2188ddfec 100644
--- a/code/AssetLib/Step/StepExporter.cpp
+++ b/code/AssetLib/Step/StepExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Step/StepExporter.h b/code/AssetLib/Step/StepExporter.h
index a02262659..9ae5fb820 100644
--- a/code/AssetLib/Step/StepExporter.h
+++ b/code/AssetLib/Step/StepExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Terragen/TerragenLoader.cpp b/code/AssetLib/Terragen/TerragenLoader.cpp
index 738ad8e27..150ebd011 100644
--- a/code/AssetLib/Terragen/TerragenLoader.cpp
+++ b/code/AssetLib/Terragen/TerragenLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -51,9 +51,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp>
#include <assimp/Importer.hpp>
-using namespace Assimp;
+namespace Assimp {
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Terragen Heightmap Importer",
"",
"",
@@ -74,10 +74,6 @@ TerragenImporter::TerragenImporter() :
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-TerragenImporter::~TerragenImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const char *tokens[] = { "terragen" };
@@ -244,4 +240,6 @@ void TerragenImporter::InternReadFile(const std::string &pFile,
pScene->mFlags |= AI_SCENE_FLAGS_TERRAIN;
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
diff --git a/code/AssetLib/Terragen/TerragenLoader.h b/code/AssetLib/Terragen/TerragenLoader.h
index cb9ff9166..2d529464b 100644
--- a/code/AssetLib/Terragen/TerragenLoader.h
+++ b/code/AssetLib/Terragen/TerragenLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -73,7 +73,7 @@ namespace Assimp {
class TerragenImporter : public BaseImporter {
public:
TerragenImporter();
- ~TerragenImporter() override;
+ ~TerragenImporter() override = default;
// -------------------------------------------------------------------
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
diff --git a/code/AssetLib/Unreal/UnrealLoader.cpp b/code/AssetLib/Unreal/UnrealLoader.cpp
index f2b0ab118..3810e5bf4 100644
--- a/code/AssetLib/Unreal/UnrealLoader.cpp
+++ b/code/AssetLib/Unreal/UnrealLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdint>
#include <memory>
-using namespace Assimp;
+namespace Assimp {
namespace Unreal {
@@ -152,7 +152,7 @@ inline void DecompressVertex(aiVector3D &v, int32_t in) {
} // end namespace Unreal
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Unreal Mesh Importer",
"",
"",
@@ -178,7 +178,7 @@ UnrealImporter::~UnrealImporter() = default;
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
-bool UnrealImporter::CanRead(const std::string & filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
+bool UnrealImporter::CanRead(const std::string &filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
return SimpleExtensionCheck(filename, "3d", "uc");
}
@@ -320,42 +320,44 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
std::vector<char> _data;
TextFileToBuffer(pb.get(), _data);
const char *data = &_data[0];
+ const char *end = &_data[_data.size() - 1] + 1;
std::vector<std::pair<std::string, std::string>> tempTextures;
// do a quick search in the UC file for some known, usually texture-related, tags
for (; *data; ++data) {
if (TokenMatchI(data, "#exec", 5)) {
- SkipSpacesAndLineEnd(&data);
+ SkipSpacesAndLineEnd(&data, end);
// #exec TEXTURE IMPORT [...] NAME=jjjjj [...] FILE=jjjj.pcx [...]
if (TokenMatchI(data, "TEXTURE", 7)) {
- SkipSpacesAndLineEnd(&data);
+ SkipSpacesAndLineEnd(&data, end);
if (TokenMatchI(data, "IMPORT", 6)) {
tempTextures.emplace_back();
std::pair<std::string, std::string> &me = tempTextures.back();
for (; !IsLineEnd(*data); ++data) {
- if (!::ASSIMP_strincmp(data, "NAME=", 5)) {
+ if (!ASSIMP_strincmp(data, "NAME=", 5)) {
const char *d = data += 5;
for (; !IsSpaceOrNewLine(*data); ++data)
;
me.first = std::string(d, (size_t)(data - d));
- } else if (!::ASSIMP_strincmp(data, "FILE=", 5)) {
+ } else if (!ASSIMP_strincmp(data, "FILE=", 5)) {
const char *d = data += 5;
for (; !IsSpaceOrNewLine(*data); ++data)
;
me.second = std::string(d, (size_t)(data - d));
}
}
- if (!me.first.length() || !me.second.length())
+ if (!me.first.length() || !me.second.length()) {
tempTextures.pop_back();
+ }
}
}
// #exec MESHMAP SETTEXTURE MESHMAP=box NUM=1 TEXTURE=Jtex1
// #exec MESHMAP SCALE MESHMAP=box X=0.1 Y=0.1 Z=0.2
else if (TokenMatchI(data, "MESHMAP", 7)) {
- SkipSpacesAndLineEnd(&data);
+ SkipSpacesAndLineEnd(&data, end);
if (TokenMatchI(data, "SETTEXTURE", 10)) {
@@ -363,14 +365,13 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
std::pair<unsigned int, std::string> &me = textures.back();
for (; !IsLineEnd(*data); ++data) {
- if (!::ASSIMP_strincmp(data, "NUM=", 4)) {
+ if (!ASSIMP_strincmp(data, "NUM=", 4)) {
data += 4;
me.first = strtoul10(data, &data);
- } else if (!::ASSIMP_strincmp(data, "TEXTURE=", 8)) {
+ } else if (!ASSIMP_strincmp(data, "TEXTURE=", 8)) {
data += 8;
const char *d = data;
- for (; !IsSpaceOrNewLine(*data); ++data)
- ;
+ for (; !IsSpaceOrNewLine(*data); ++data);
me.second = std::string(d, (size_t)(data - d));
// try to find matching path names, doesn't care if we don't find them
@@ -408,7 +409,7 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
// find out how many output meshes and materials we'll have and build material indices
for (Unreal::Triangle &tri : triangles) {
Unreal::TempMat mat(tri);
- std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(), materials.end(), mat);
+ auto nt = std::find(materials.begin(), materials.end(), mat);
if (nt == materials.end()) {
// add material
tri.matIndex = static_cast<unsigned int>(materials.size());
@@ -516,4 +517,6 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
flipper.Execute(pScene);
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_3D_IMPORTER
diff --git a/code/AssetLib/Unreal/UnrealLoader.h b/code/AssetLib/Unreal/UnrealLoader.h
index fda784cfb..b32a5fc74 100644
--- a/code/AssetLib/Unreal/UnrealLoader.h
+++ b/code/AssetLib/Unreal/UnrealLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/X/XFileExporter.cpp b/code/AssetLib/X/XFileExporter.cpp
index f0b1608c1..15ecf9464 100644
--- a/code/AssetLib/X/XFileExporter.cpp
+++ b/code/AssetLib/X/XFileExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/X/XFileExporter.h b/code/AssetLib/X/XFileExporter.h
index 1d9a5ae77..744944062 100644
--- a/code/AssetLib/X/XFileExporter.h
+++ b/code/AssetLib/X/XFileExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/X/XFileHelper.h b/code/AssetLib/X/XFileHelper.h
index 4b95672f3..e3fff2b66 100644
--- a/code/AssetLib/X/XFileHelper.h
+++ b/code/AssetLib/X/XFileHelper.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/X/XFileImporter.cpp b/code/AssetLib/X/XFileImporter.cpp
index 1474ad808..b386ff959 100644
--- a/code/AssetLib/X/XFileImporter.cpp
+++ b/code/AssetLib/X/XFileImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -57,10 +57,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cctype>
#include <memory>
-using namespace Assimp;
+namespace Assimp {
+
using namespace Assimp::Formatter;
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"Direct3D XFile Importer",
"",
"",
@@ -74,141 +75,136 @@ static const aiImporterDesc desc = {
};
// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-XFileImporter::XFileImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
-bool XFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const {
+bool XFileImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const uint32_t token[] = { AI_MAKE_MAGIC("xof ") };
- return CheckMagicToken(pIOHandler,pFile,token,AI_COUNT_OF(token));
+ return CheckMagicToken(pIOHandler, pFile, token, AI_COUNT_OF(token));
}
// ------------------------------------------------------------------------------------------------
// Get file extension list
-const aiImporterDesc* XFileImporter::GetInfo () const {
+const aiImporterDesc *XFileImporter::GetInfo() const {
return &desc;
}
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
-void XFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
+void XFileImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
// read file into memory
- std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
+ std::unique_ptr<IOStream> file(pIOHandler->Open(pFile));
if (file == nullptr) {
- throw DeadlyImportError( "Failed to open file ", pFile, "." );
+ throw DeadlyImportError("Failed to open file ", pFile, ".");
}
static const size_t MinSize = 16;
size_t fileSize = file->FileSize();
- if ( fileSize < MinSize ) {
- throw DeadlyImportError( "XFile is too small." );
+ if (fileSize < MinSize) {
+ throw DeadlyImportError("XFile is too small.");
}
// in the hope that binary files will never start with a BOM ...
- mBuffer.resize( fileSize + 1);
- file->Read( &mBuffer.front(), 1, fileSize);
+ mBuffer.resize(fileSize + 1);
+ file->Read(&mBuffer.front(), 1, fileSize);
ConvertToUTF8(mBuffer);
// parse the file into a temporary representation
- XFileParser parser( mBuffer);
+ XFileParser parser(mBuffer);
// and create the proper return structures out of it
- CreateDataRepresentationFromImport( pScene, parser.GetImportedData());
+ CreateDataRepresentationFromImport(pScene, parser.GetImportedData());
// if nothing came from it, report it as error
- if ( !pScene->mRootNode ) {
- throw DeadlyImportError( "XFile is ill-formatted - no content imported." );
+ if (!pScene->mRootNode) {
+ throw DeadlyImportError("XFile is ill-formatted - no content imported.");
}
}
// ------------------------------------------------------------------------------------------------
// Constructs the return data structure out of the imported data.
-void XFileImporter::CreateDataRepresentationFromImport( aiScene* pScene, XFile::Scene* pData)
-{
+void XFileImporter::CreateDataRepresentationFromImport(aiScene *pScene, XFile::Scene *pData) {
// Read the global materials first so that meshes referring to them can find them later
- ConvertMaterials( pScene, pData->mGlobalMaterials);
+ ConvertMaterials(pScene, pData->mGlobalMaterials);
// copy nodes, extracting meshes and materials on the way
- pScene->mRootNode = CreateNodes( pScene, nullptr, pData->mRootNode);
+ pScene->mRootNode = CreateNodes(pScene, nullptr, pData->mRootNode);
// extract animations
- CreateAnimations( pScene, pData);
+ CreateAnimations(pScene, pData);
// read the global meshes that were stored outside of any node
- if( !pData->mGlobalMeshes.empty() ) {
+ if (!pData->mGlobalMeshes.empty()) {
// create a root node to hold them if there isn't any, yet
- if( pScene->mRootNode == nullptr ) {
+ if (pScene->mRootNode == nullptr) {
pScene->mRootNode = new aiNode;
- pScene->mRootNode->mName.Set( "$dummy_node");
+ pScene->mRootNode->mName.Set("$dummy_node");
}
// convert all global meshes and store them in the root node.
// If there was one before, the global meshes now suddenly have its transformation matrix...
// Don't know what to do there, I don't want to insert another node under the present root node
// just to avoid this.
- CreateMeshes( pScene, pScene->mRootNode, pData->mGlobalMeshes);
+ CreateMeshes(pScene, pScene->mRootNode, pData->mGlobalMeshes);
}
if (!pScene->mRootNode) {
- throw DeadlyImportError( "No root node" );
+ throw DeadlyImportError("No root node");
}
// Convert everything to OpenGL space... it's the same operation as the conversion back, so we can reuse the step directly
MakeLeftHandedProcess convertProcess;
- convertProcess.Execute( pScene);
+ convertProcess.Execute(pScene);
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
// finally: create a dummy material if not material was imported
- if( pScene->mNumMaterials == 0) {
+ if (pScene->mNumMaterials == 0) {
pScene->mNumMaterials = 1;
// create the Material
- aiMaterial* mat = new aiMaterial;
- int shadeMode = (int) aiShadingMode_Gouraud;
- mat->AddProperty<int>( &shadeMode, 1, AI_MATKEY_SHADING_MODEL);
+ aiMaterial *mat = new aiMaterial;
+ int shadeMode = (int)aiShadingMode_Gouraud;
+ mat->AddProperty<int>(&shadeMode, 1, AI_MATKEY_SHADING_MODEL);
// material colours
int specExp = 1;
- aiColor3D clr = aiColor3D( 0, 0, 0);
- mat->AddProperty( &clr, 1, AI_MATKEY_COLOR_EMISSIVE);
- mat->AddProperty( &clr, 1, AI_MATKEY_COLOR_SPECULAR);
+ aiColor3D clr = aiColor3D(0, 0, 0);
+ mat->AddProperty(&clr, 1, AI_MATKEY_COLOR_EMISSIVE);
+ mat->AddProperty(&clr, 1, AI_MATKEY_COLOR_SPECULAR);
- clr = aiColor3D( 0.5f, 0.5f, 0.5f);
- mat->AddProperty( &clr, 1, AI_MATKEY_COLOR_DIFFUSE);
- mat->AddProperty( &specExp, 1, AI_MATKEY_SHININESS);
+ clr = aiColor3D(0.5f, 0.5f, 0.5f);
+ mat->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
+ mat->AddProperty(&specExp, 1, AI_MATKEY_SHININESS);
- pScene->mMaterials = new aiMaterial*[1];
+ pScene->mMaterials = new aiMaterial *[1];
pScene->mMaterials[0] = mat;
}
}
// ------------------------------------------------------------------------------------------------
// Recursively creates scene nodes from the imported hierarchy.
-aiNode* XFileImporter::CreateNodes( aiScene* pScene, aiNode* pParent, const XFile::Node* pNode) {
- if ( !pNode ) {
+aiNode *XFileImporter::CreateNodes(aiScene *pScene, aiNode *pParent, const XFile::Node *pNode) {
+ if (!pNode) {
return nullptr;
}
// create node
- aiNode* node = new aiNode;
+ aiNode *node = new aiNode;
node->mName.length = (ai_uint32)pNode->mName.length();
node->mParent = pParent;
- memcpy( node->mName.data, pNode->mName.c_str(), pNode->mName.length());
+ memcpy(node->mName.data, pNode->mName.c_str(), pNode->mName.length());
node->mName.data[node->mName.length] = 0;
node->mTransformation = pNode->mTrafoMatrix;
// convert meshes from the source node
- CreateMeshes( pScene, node, pNode->mMeshes);
+ CreateMeshes(pScene, node, pNode->mMeshes);
// handle children
- if( !pNode->mChildren.empty() ) {
+ if (!pNode->mChildren.empty()) {
node->mNumChildren = (unsigned int)pNode->mChildren.size();
- node->mChildren = new aiNode* [node->mNumChildren];
+ node->mChildren = new aiNode *[node->mNumChildren];
- for ( unsigned int a = 0; a < pNode->mChildren.size(); ++a ) {
- node->mChildren[ a ] = CreateNodes( pScene, node, pNode->mChildren[ a ] );
+ for (unsigned int a = 0; a < pNode->mChildren.size(); ++a) {
+ node->mChildren[a] = CreateNodes(pScene, node, pNode->mChildren[a]);
}
}
@@ -217,55 +213,55 @@ aiNode* XFileImporter::CreateNodes( aiScene* pScene, aiNode* pParent, const XFil
// ------------------------------------------------------------------------------------------------
// Creates the meshes for the given node.
-void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vector<XFile::Mesh*>& pMeshes) {
+void XFileImporter::CreateMeshes(aiScene *pScene, aiNode *pNode, const std::vector<XFile::Mesh *> &pMeshes) {
if (pMeshes.empty()) {
return;
}
// create a mesh for each mesh-material combination in the source node
- std::vector<aiMesh*> meshes;
- for( unsigned int a = 0; a < pMeshes.size(); ++a ) {
- XFile::Mesh* sourceMesh = pMeshes[a];
- if ( nullptr == sourceMesh ) {
+ std::vector<aiMesh *> meshes;
+ for (unsigned int a = 0; a < pMeshes.size(); ++a) {
+ XFile::Mesh *sourceMesh = pMeshes[a];
+ if (nullptr == sourceMesh) {
continue;
}
// first convert its materials so that we can find them with their index afterwards
- ConvertMaterials( pScene, sourceMesh->mMaterials);
+ ConvertMaterials(pScene, sourceMesh->mMaterials);
- unsigned int numMaterials = std::max( (unsigned int)sourceMesh->mMaterials.size(), 1u);
- for( unsigned int b = 0; b < numMaterials; ++b ) {
+ unsigned int numMaterials = std::max((unsigned int)sourceMesh->mMaterials.size(), 1u);
+ for (unsigned int b = 0; b < numMaterials; ++b) {
// collect the faces belonging to this material
std::vector<unsigned int> faces;
unsigned int numVertices = 0;
- if( !sourceMesh->mFaceMaterials.empty() ) {
+ if (!sourceMesh->mFaceMaterials.empty()) {
// if there is a per-face material defined, select the faces with the corresponding material
- for( unsigned int c = 0; c < sourceMesh->mFaceMaterials.size(); ++c ) {
- if( sourceMesh->mFaceMaterials[c] == b) {
- faces.push_back( c);
+ for (unsigned int c = 0; c < sourceMesh->mFaceMaterials.size(); ++c) {
+ if (sourceMesh->mFaceMaterials[c] == b) {
+ faces.push_back(c);
numVertices += (unsigned int)sourceMesh->mPosFaces[c].mIndices.size();
}
}
} else {
// if there is no per-face material, place everything into one mesh
- for( unsigned int c = 0; c < sourceMesh->mPosFaces.size(); ++c ) {
- faces.push_back( c);
+ for (unsigned int c = 0; c < sourceMesh->mPosFaces.size(); ++c) {
+ faces.push_back(c);
numVertices += (unsigned int)sourceMesh->mPosFaces[c].mIndices.size();
}
}
// no faces/vertices using this material? strange...
- if ( numVertices == 0 ) {
+ if (numVertices == 0) {
continue;
}
// create a submesh using this material
- aiMesh* mesh = new aiMesh;
- meshes.push_back( mesh);
+ aiMesh *mesh = new aiMesh;
+ meshes.push_back(mesh);
// find the material in the scene's material list. Either own material
// or referenced material, it should already have a valid index
- if( !sourceMesh->mFaceMaterials.empty() ) {
+ if (!sourceMesh->mFaceMaterials.empty()) {
mesh->mMaterialIndex = static_cast<unsigned int>(sourceMesh->mMaterials[b].sceneIndex);
} else {
mesh->mMaterialIndex = 0;
@@ -282,41 +278,41 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
mesh->mName.Set(sourceMesh->mName);
// normals?
- if ( sourceMesh->mNormals.size() > 0 ) {
- mesh->mNormals = new aiVector3D[ numVertices ];
+ if (sourceMesh->mNormals.size() > 0) {
+ mesh->mNormals = new aiVector3D[numVertices];
}
// texture coords
- for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c ) {
- if ( !sourceMesh->mTexCoords[ c ].empty() ) {
- mesh->mTextureCoords[ c ] = new aiVector3D[ numVertices ];
+ for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c) {
+ if (!sourceMesh->mTexCoords[c].empty()) {
+ mesh->mTextureCoords[c] = new aiVector3D[numVertices];
}
}
// vertex colors
- for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c ) {
- if ( !sourceMesh->mColors[ c ].empty() ) {
- mesh->mColors[ c ] = new aiColor4D[ numVertices ];
+ for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c) {
+ if (!sourceMesh->mColors[c].empty()) {
+ mesh->mColors[c] = new aiColor4D[numVertices];
}
}
// now collect the vertex data of all data streams present in the imported mesh
- unsigned int newIndex( 0 );
+ unsigned int newIndex(0);
std::vector<unsigned int> orgPoints; // from which original point each new vertex stems
- orgPoints.resize( numVertices, 0);
+ orgPoints.resize(numVertices, 0);
- for( unsigned int c = 0; c < faces.size(); ++c ) {
+ for (unsigned int c = 0; c < faces.size(); ++c) {
unsigned int f = faces[c]; // index of the source face
- const XFile::Face& pf = sourceMesh->mPosFaces[f]; // position source face
+ const XFile::Face &pf = sourceMesh->mPosFaces[f]; // position source face
// create face. either triangle or triangle fan depending on the index count
- aiFace& df = mesh->mFaces[c]; // destination face
+ aiFace &df = mesh->mFaces[c]; // destination face
df.mNumIndices = (unsigned int)pf.mIndices.size();
- df.mIndices = new unsigned int[ df.mNumIndices];
+ df.mIndices = new unsigned int[df.mNumIndices];
// collect vertex data for indices of this face
- for( unsigned int d = 0; d < df.mNumIndices; ++d ) {
- df.mIndices[ d ] = newIndex;
- const unsigned int newIdx( pf.mIndices[ d ] );
- if ( newIdx > sourceMesh->mPositions.size() ) {
+ for (unsigned int d = 0; d < df.mNumIndices; ++d) {
+ df.mIndices[d] = newIndex;
+ const unsigned int newIdx = pf.mIndices[d];
+ if (newIdx >= sourceMesh->mPositions.size()) {
continue;
}
@@ -325,24 +321,26 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
// Position
mesh->mVertices[newIndex] = sourceMesh->mPositions[pf.mIndices[d]];
// Normal, if present
- if ( mesh->HasNormals() ) {
- if ( sourceMesh->mNormFaces[ f ].mIndices.size() > d ) {
- const size_t idx( sourceMesh->mNormFaces[ f ].mIndices[ d ] );
- mesh->mNormals[ newIndex ] = sourceMesh->mNormals[ idx ];
+ if (mesh->HasNormals()) {
+ if (sourceMesh->mNormFaces[f].mIndices.size() > d) {
+ const size_t idx(sourceMesh->mNormFaces[f].mIndices[d]);
+ if (idx < sourceMesh->mNormals.size()) {
+ mesh->mNormals[newIndex] = sourceMesh->mNormals[idx];
+ }
}
}
// texture coord sets
- for( unsigned int e = 0; e < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++e ) {
- if( mesh->HasTextureCoords( e)) {
+ for (unsigned int e = 0; e < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++e) {
+ if (mesh->HasTextureCoords(e)) {
aiVector2D tex = sourceMesh->mTexCoords[e][pf.mIndices[d]];
- mesh->mTextureCoords[e][newIndex] = aiVector3D( tex.x, 1.0f - tex.y, 0.0f);
+ mesh->mTextureCoords[e][newIndex] = aiVector3D(tex.x, 1.0f - tex.y, 0.0f);
}
}
// vertex color sets
- for ( unsigned int e = 0; e < AI_MAX_NUMBER_OF_COLOR_SETS; ++e ) {
- if ( mesh->HasVertexColors( e ) ) {
- mesh->mColors[ e ][ newIndex ] = sourceMesh->mColors[ e ][ pf.mIndices[ d ] ];
+ for (unsigned int e = 0; e < AI_MAX_NUMBER_OF_COLOR_SETS; ++e) {
+ if (mesh->HasVertexColors(e)) {
+ mesh->mColors[e][newIndex] = sourceMesh->mColors[e][pf.mIndices[d]];
}
}
@@ -351,63 +349,74 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
}
// there should be as much new vertices as we calculated before
- ai_assert( newIndex == numVertices);
+ ai_assert(newIndex == numVertices);
// convert all bones of the source mesh which influence vertices in this newly created mesh
- const std::vector<XFile::Bone>& bones = sourceMesh->mBones;
- std::vector<aiBone*> newBones;
- for( unsigned int c = 0; c < bones.size(); ++c ) {
- const XFile::Bone& obone = bones[c];
+ const std::vector<XFile::Bone> &bones = sourceMesh->mBones;
+ std::vector<aiBone *> newBones;
+ for (unsigned int c = 0; c < bones.size(); ++c) {
+ const XFile::Bone &obone = bones[c];
// set up a vertex-linear array of the weights for quick searching if a bone influences a vertex
- std::vector<ai_real> oldWeights( sourceMesh->mPositions.size(), 0.0);
- for ( unsigned int d = 0; d < obone.mWeights.size(); ++d ) {
- oldWeights[ obone.mWeights[ d ].mVertex ] = obone.mWeights[ d ].mWeight;
+ std::vector<ai_real> oldWeights(sourceMesh->mPositions.size(), 0.0);
+ for (unsigned int d = 0; d < obone.mWeights.size(); ++d) {
+ // TODO The conditional against boneIdx which was added in commit f844c33
+ // TODO (https://github.com/assimp/assimp/commit/f844c3397d7726477ab0fdca8efd3df56c18366b)
+ // TODO causes massive breakage as detailed in:
+ // TODO https://github.com/assimp/assimp/issues/5332
+ // TODO In cases like this unit tests are less useful, since the model still has
+ // TODO meshes, textures, animations etc. and asserts against these values may pass;
+ // TODO when touching importer code, it is crucial that developers also run manual, visual
+ // TODO checks to ensure there's no obvious breakage _before_ commiting to main branch
+ //const unsigned int boneIdx = obone.mWeights[d].mVertex;
+ //if (boneIdx < obone.mWeights.size()) {
+ oldWeights[obone.mWeights[d].mVertex] = obone.mWeights[d].mWeight;
+ //}
}
// collect all vertex weights that influence a vertex in the new mesh
std::vector<aiVertexWeight> newWeights;
- newWeights.reserve( numVertices);
- for( unsigned int d = 0; d < orgPoints.size(); ++d ) {
+ newWeights.reserve(numVertices);
+ for (unsigned int d = 0; d < orgPoints.size(); ++d) {
// does the new vertex stem from an old vertex which was influenced by this bone?
ai_real w = oldWeights[orgPoints[d]];
- if ( w > 0.0 ) {
- newWeights.emplace_back( d, w );
+ if (w > 0.0) {
+ newWeights.emplace_back(d, w);
}
}
// if the bone has no weights in the newly created mesh, ignore it
- if ( newWeights.empty() ) {
+ if (newWeights.empty()) {
continue;
}
// create
- aiBone* nbone = new aiBone;
- newBones.push_back( nbone);
+ aiBone *nbone = new aiBone;
+ newBones.push_back(nbone);
// copy name and matrix
- nbone->mName.Set( obone.mName);
+ nbone->mName.Set(obone.mName);
nbone->mOffsetMatrix = obone.mOffsetMatrix;
nbone->mNumWeights = (unsigned int)newWeights.size();
nbone->mWeights = new aiVertexWeight[nbone->mNumWeights];
- for ( unsigned int d = 0; d < newWeights.size(); ++d ) {
- nbone->mWeights[ d ] = newWeights[ d ];
+ for (unsigned int d = 0; d < newWeights.size(); ++d) {
+ nbone->mWeights[d] = newWeights[d];
}
}
// store the bones in the mesh
mesh->mNumBones = (unsigned int)newBones.size();
- if( !newBones.empty()) {
- mesh->mBones = new aiBone*[mesh->mNumBones];
- std::copy( newBones.begin(), newBones.end(), mesh->mBones);
+ if (!newBones.empty()) {
+ mesh->mBones = new aiBone *[mesh->mNumBones];
+ std::copy(newBones.begin(), newBones.end(), mesh->mBones);
}
}
}
// reallocate scene mesh array to be large enough
- aiMesh** prevArray = pScene->mMeshes;
- pScene->mMeshes = new aiMesh*[pScene->mNumMeshes + meshes.size()];
- if( prevArray) {
- memcpy( pScene->mMeshes, prevArray, pScene->mNumMeshes * sizeof( aiMesh*));
- delete [] prevArray;
+ aiMesh **prevArray = pScene->mMeshes;
+ pScene->mMeshes = new aiMesh *[pScene->mNumMeshes + meshes.size()];
+ if (prevArray) {
+ memcpy(pScene->mMeshes, prevArray, pScene->mNumMeshes * sizeof(aiMesh *));
+ delete[] prevArray;
}
// allocate mesh index array in the node
@@ -415,7 +424,7 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
pNode->mMeshes = new unsigned int[pNode->mNumMeshes];
// store all meshes in the mesh library of the scene and store their indices in the node
- for( unsigned int a = 0; a < meshes.size(); a++) {
+ for (unsigned int a = 0; a < meshes.size(); a++) {
pScene->mMeshes[pScene->mNumMeshes] = meshes[a];
pNode->mMeshes[a] = pScene->mNumMeshes;
pScene->mNumMeshes++;
@@ -424,35 +433,34 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
// ------------------------------------------------------------------------------------------------
// Converts the animations from the given imported data and creates them in the scene.
-void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData) {
- std::vector<aiAnimation*> newAnims;
+void XFileImporter::CreateAnimations(aiScene *pScene, const XFile::Scene *pData) {
+ std::vector<aiAnimation *> newAnims;
- for( unsigned int a = 0; a < pData->mAnims.size(); ++a ) {
- const XFile::Animation* anim = pData->mAnims[a];
+ for (unsigned int a = 0; a < pData->mAnims.size(); ++a) {
+ const XFile::Animation *anim = pData->mAnims[a];
// some exporters mock me with empty animation tags.
- if ( anim->mAnims.empty() ) {
+ if (anim->mAnims.empty()) {
continue;
}
// create a new animation to hold the data
- aiAnimation* nanim = new aiAnimation;
- newAnims.push_back( nanim);
- nanim->mName.Set( anim->mName);
+ aiAnimation *nanim = new aiAnimation;
+ newAnims.push_back(nanim);
+ nanim->mName.Set(anim->mName);
// duration will be determined by the maximum length
nanim->mDuration = 0;
nanim->mTicksPerSecond = pData->mAnimTicksPerSecond;
nanim->mNumChannels = (unsigned int)anim->mAnims.size();
- nanim->mChannels = new aiNodeAnim*[nanim->mNumChannels];
+ nanim->mChannels = new aiNodeAnim *[nanim->mNumChannels];
- for( unsigned int b = 0; b < anim->mAnims.size(); ++b ) {
- const XFile::AnimBone* bone = anim->mAnims[b];
- aiNodeAnim* nbone = new aiNodeAnim;
- nbone->mNodeName.Set( bone->mBoneName);
+ for (unsigned int b = 0; b < anim->mAnims.size(); ++b) {
+ const XFile::AnimBone *bone = anim->mAnims[b];
+ aiNodeAnim *nbone = new aiNodeAnim;
+ nbone->mNodeName.Set(bone->mBoneName);
nanim->mChannels[b] = nbone;
// key-frames are given as combined transformation matrix keys
- if( !bone->mTrafoKeys.empty() )
- {
+ if (!bone->mTrafoKeys.empty()) {
nbone->mNumPositionKeys = (unsigned int)bone->mTrafoKeys.size();
nbone->mPositionKeys = new aiVectorKey[nbone->mNumPositionKeys];
nbone->mNumRotationKeys = (unsigned int)bone->mTrafoKeys.size();
@@ -460,44 +468,44 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData
nbone->mNumScalingKeys = (unsigned int)bone->mTrafoKeys.size();
nbone->mScalingKeys = new aiVectorKey[nbone->mNumScalingKeys];
- for( unsigned int c = 0; c < bone->mTrafoKeys.size(); ++c) {
+ for (unsigned int c = 0; c < bone->mTrafoKeys.size(); ++c) {
// deconstruct each matrix into separate position, rotation and scaling
double time = bone->mTrafoKeys[c].mTime;
aiMatrix4x4 trafo = bone->mTrafoKeys[c].mMatrix;
// extract position
- aiVector3D pos( trafo.a4, trafo.b4, trafo.c4);
+ aiVector3D pos(trafo.a4, trafo.b4, trafo.c4);
nbone->mPositionKeys[c].mTime = time;
nbone->mPositionKeys[c].mValue = pos;
// extract scaling
aiVector3D scale;
- scale.x = aiVector3D( trafo.a1, trafo.b1, trafo.c1).Length();
- scale.y = aiVector3D( trafo.a2, trafo.b2, trafo.c2).Length();
- scale.z = aiVector3D( trafo.a3, trafo.b3, trafo.c3).Length();
+ scale.x = aiVector3D(trafo.a1, trafo.b1, trafo.c1).Length();
+ scale.y = aiVector3D(trafo.a2, trafo.b2, trafo.c2).Length();
+ scale.z = aiVector3D(trafo.a3, trafo.b3, trafo.c3).Length();
nbone->mScalingKeys[c].mTime = time;
nbone->mScalingKeys[c].mValue = scale;
// reconstruct rotation matrix without scaling
aiMatrix3x3 rotmat(
- trafo.a1 / scale.x, trafo.a2 / scale.y, trafo.a3 / scale.z,
- trafo.b1 / scale.x, trafo.b2 / scale.y, trafo.b3 / scale.z,
- trafo.c1 / scale.x, trafo.c2 / scale.y, trafo.c3 / scale.z);
+ trafo.a1 / scale.x, trafo.a2 / scale.y, trafo.a3 / scale.z,
+ trafo.b1 / scale.x, trafo.b2 / scale.y, trafo.b3 / scale.z,
+ trafo.c1 / scale.x, trafo.c2 / scale.y, trafo.c3 / scale.z);
// and convert it into a quaternion
nbone->mRotationKeys[c].mTime = time;
- nbone->mRotationKeys[c].mValue = aiQuaternion( rotmat);
+ nbone->mRotationKeys[c].mValue = aiQuaternion(rotmat);
}
// longest lasting key sequence determines duration
- nanim->mDuration = std::max( nanim->mDuration, bone->mTrafoKeys.back().mTime);
+ nanim->mDuration = std::max(nanim->mDuration, bone->mTrafoKeys.back().mTime);
} else {
// separate key sequences for position, rotation, scaling
nbone->mNumPositionKeys = (unsigned int)bone->mPosKeys.size();
if (nbone->mNumPositionKeys != 0) {
nbone->mPositionKeys = new aiVectorKey[nbone->mNumPositionKeys];
- for( unsigned int c = 0; c < nbone->mNumPositionKeys; ++c ) {
+ for (unsigned int c = 0; c < nbone->mNumPositionKeys; ++c) {
aiVector3D pos = bone->mPosKeys[c].mValue;
nbone->mPositionKeys[c].mTime = bone->mPosKeys[c].mTime;
@@ -509,11 +517,11 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData
nbone->mNumRotationKeys = (unsigned int)bone->mRotKeys.size();
if (nbone->mNumRotationKeys != 0) {
nbone->mRotationKeys = new aiQuatKey[nbone->mNumRotationKeys];
- for( unsigned int c = 0; c < nbone->mNumRotationKeys; ++c ) {
+ for (unsigned int c = 0; c < nbone->mNumRotationKeys; ++c) {
aiMatrix3x3 rotmat = bone->mRotKeys[c].mValue.GetMatrix();
nbone->mRotationKeys[c].mTime = bone->mRotKeys[c].mTime;
- nbone->mRotationKeys[c].mValue = aiQuaternion( rotmat);
+ nbone->mRotationKeys[c].mValue = aiQuaternion(rotmat);
nbone->mRotationKeys[c].mValue.w *= -1.0f; // needs quat inversion
}
}
@@ -522,153 +530,149 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData
nbone->mNumScalingKeys = (unsigned int)bone->mScaleKeys.size();
if (nbone->mNumScalingKeys != 0) {
nbone->mScalingKeys = new aiVectorKey[nbone->mNumScalingKeys];
- for( unsigned int c = 0; c < nbone->mNumScalingKeys; c++)
+ for (unsigned int c = 0; c < nbone->mNumScalingKeys; c++)
nbone->mScalingKeys[c] = bone->mScaleKeys[c];
}
// longest lasting key sequence determines duration
- if( bone->mPosKeys.size() > 0)
- nanim->mDuration = std::max( nanim->mDuration, bone->mPosKeys.back().mTime);
- if( bone->mRotKeys.size() > 0)
- nanim->mDuration = std::max( nanim->mDuration, bone->mRotKeys.back().mTime);
- if( bone->mScaleKeys.size() > 0)
- nanim->mDuration = std::max( nanim->mDuration, bone->mScaleKeys.back().mTime);
+ if (bone->mPosKeys.size() > 0)
+ nanim->mDuration = std::max(nanim->mDuration, bone->mPosKeys.back().mTime);
+ if (bone->mRotKeys.size() > 0)
+ nanim->mDuration = std::max(nanim->mDuration, bone->mRotKeys.back().mTime);
+ if (bone->mScaleKeys.size() > 0)
+ nanim->mDuration = std::max(nanim->mDuration, bone->mScaleKeys.back().mTime);
}
}
}
// store all converted animations in the scene
- if( newAnims.size() > 0)
- {
+ if (newAnims.size() > 0) {
pScene->mNumAnimations = (unsigned int)newAnims.size();
- pScene->mAnimations = new aiAnimation* [pScene->mNumAnimations];
- for( unsigned int a = 0; a < newAnims.size(); a++)
+ pScene->mAnimations = new aiAnimation *[pScene->mNumAnimations];
+ for (unsigned int a = 0; a < newAnims.size(); a++)
pScene->mAnimations[a] = newAnims[a];
}
}
// ------------------------------------------------------------------------------------------------
// Converts all materials in the given array and stores them in the scene's material list.
-void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Material>& pMaterials)
-{
+void XFileImporter::ConvertMaterials(aiScene *pScene, std::vector<XFile::Material> &pMaterials) {
// count the non-referrer materials in the array
- unsigned int numNewMaterials( 0 );
- for ( unsigned int a = 0; a < pMaterials.size(); ++a ) {
- if ( !pMaterials[ a ].mIsReference ) {
+ unsigned int numNewMaterials(0);
+ for (unsigned int a = 0; a < pMaterials.size(); ++a) {
+ if (!pMaterials[a].mIsReference) {
++numNewMaterials;
}
}
// resize the scene's material list to offer enough space for the new materials
- if( numNewMaterials > 0 ) {
- aiMaterial** prevMats = pScene->mMaterials;
- pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials + numNewMaterials];
- if( nullptr != prevMats) {
- ::memcpy( pScene->mMaterials, prevMats, pScene->mNumMaterials * sizeof( aiMaterial*));
- delete [] prevMats;
+ if (numNewMaterials > 0) {
+ aiMaterial **prevMats = pScene->mMaterials;
+ pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials + numNewMaterials];
+ if (nullptr != prevMats) {
+ ::memcpy(pScene->mMaterials, prevMats, pScene->mNumMaterials * sizeof(aiMaterial *));
+ delete[] prevMats;
}
}
// convert all the materials given in the array
- for( unsigned int a = 0; a < pMaterials.size(); ++a ) {
- XFile::Material& oldMat = pMaterials[a];
- if( oldMat.mIsReference) {
+ for (unsigned int a = 0; a < pMaterials.size(); ++a) {
+ XFile::Material &oldMat = pMaterials[a];
+ if (oldMat.mIsReference) {
// find the material it refers to by name, and store its index
- for( size_t b = 0; b < pScene->mNumMaterials; ++b ) {
+ for (size_t b = 0; b < pScene->mNumMaterials; ++b) {
aiString name;
- pScene->mMaterials[b]->Get( AI_MATKEY_NAME, name);
- if( strcmp( name.C_Str(), oldMat.mName.data()) == 0 ) {
+ pScene->mMaterials[b]->Get(AI_MATKEY_NAME, name);
+ if (strcmp(name.C_Str(), oldMat.mName.data()) == 0) {
oldMat.sceneIndex = b;
break;
}
}
- if( oldMat.sceneIndex == SIZE_MAX ) {
- ASSIMP_LOG_WARN( "Could not resolve global material reference \"", oldMat.mName, "\"" );
+ if (oldMat.sceneIndex == SIZE_MAX) {
+ ASSIMP_LOG_WARN("Could not resolve global material reference \"", oldMat.mName, "\"");
oldMat.sceneIndex = 0;
}
continue;
}
- aiMaterial* mat = new aiMaterial;
+ aiMaterial *mat = new aiMaterial;
aiString name;
- name.Set( oldMat.mName);
- mat->AddProperty( &name, AI_MATKEY_NAME);
+ name.Set(oldMat.mName);
+ mat->AddProperty(&name, AI_MATKEY_NAME);
// Shading model: hard-coded to PHONG, there is no such information in an XFile
// FIX (aramis): If the specular exponent is 0, use gouraud shading. This is a bugfix
// for some models in the SDK (e.g. good old tiny.x)
- int shadeMode = (int)oldMat.mSpecularExponent == 0.0f
- ? aiShadingMode_Gouraud : aiShadingMode_Phong;
+ int shadeMode = (int)oldMat.mSpecularExponent == 0.0f ? aiShadingMode_Gouraud : aiShadingMode_Phong;
- mat->AddProperty<int>( &shadeMode, 1, AI_MATKEY_SHADING_MODEL);
+ mat->AddProperty<int>(&shadeMode, 1, AI_MATKEY_SHADING_MODEL);
// material colours
// Unclear: there's no ambient colour, but emissive. What to put for ambient?
// Probably nothing at all, let the user select a suitable default.
- mat->AddProperty( &oldMat.mEmissive, 1, AI_MATKEY_COLOR_EMISSIVE);
- mat->AddProperty( &oldMat.mDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
- mat->AddProperty( &oldMat.mSpecular, 1, AI_MATKEY_COLOR_SPECULAR);
- mat->AddProperty( &oldMat.mSpecularExponent, 1, AI_MATKEY_SHININESS);
-
+ mat->AddProperty(&oldMat.mEmissive, 1, AI_MATKEY_COLOR_EMISSIVE);
+ mat->AddProperty(&oldMat.mDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
+ mat->AddProperty(&oldMat.mSpecular, 1, AI_MATKEY_COLOR_SPECULAR);
+ mat->AddProperty(&oldMat.mSpecularExponent, 1, AI_MATKEY_SHININESS);
// texture, if there is one
- if (1 == oldMat.mTextures.size() ) {
- const XFile::TexEntry& otex = oldMat.mTextures.back();
+ if (1 == oldMat.mTextures.size()) {
+ const XFile::TexEntry &otex = oldMat.mTextures.back();
if (otex.mName.length()) {
// if there is only one texture assume it contains the diffuse color
- aiString tex( otex.mName);
- if ( otex.mIsNormalMap ) {
- mat->AddProperty( &tex, AI_MATKEY_TEXTURE_NORMALS( 0 ) );
+ aiString tex(otex.mName);
+ if (otex.mIsNormalMap) {
+ mat->AddProperty(&tex, AI_MATKEY_TEXTURE_NORMALS(0));
} else {
- mat->AddProperty( &tex, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
+ mat->AddProperty(&tex, AI_MATKEY_TEXTURE_DIFFUSE(0));
}
}
} else {
// Otherwise ... try to search for typical strings in the
// texture's file name like 'bump' or 'diffuse'
- unsigned int iHM = 0,iNM = 0,iDM = 0,iSM = 0,iAM = 0,iEM = 0;
- for( unsigned int b = 0; b < oldMat.mTextures.size(); ++b ) {
- const XFile::TexEntry& otex = oldMat.mTextures[b];
+ unsigned int iHM = 0, iNM = 0, iDM = 0, iSM = 0, iAM = 0, iEM = 0;
+ for (unsigned int b = 0; b < oldMat.mTextures.size(); ++b) {
+ const XFile::TexEntry &otex = oldMat.mTextures[b];
std::string sz = otex.mName;
- if ( !sz.length() ) {
+ if (!sz.length()) {
continue;
}
// find the file name
std::string::size_type s = sz.find_last_of("\\/");
- if ( std::string::npos == s ) {
+ if (std::string::npos == s) {
s = 0;
}
// cut off the file extension
std::string::size_type sExt = sz.find_last_of('.');
- if (std::string::npos != sExt){
+ if (std::string::npos != sExt) {
sz[sExt] = '\0';
}
// convert to lower case for easier comparison
- for ( unsigned int c = 0; c < sz.length(); ++c ) {
- sz[ c ] = (char) tolower( (unsigned char) sz[ c ] );
+ for (unsigned int c = 0; c < sz.length(); ++c) {
+ sz[c] = (char)tolower((unsigned char)sz[c]);
}
// Place texture filename property under the corresponding name
- aiString tex( oldMat.mTextures[b].mName);
+ aiString tex(oldMat.mTextures[b].mName);
// bump map
if (std::string::npos != sz.find("bump", s) || std::string::npos != sz.find("height", s)) {
- mat->AddProperty( &tex, AI_MATKEY_TEXTURE_HEIGHT(iHM++));
- } else if (otex.mIsNormalMap || std::string::npos != sz.find( "normal", s) || std::string::npos != sz.find("nm", s)) {
- mat->AddProperty( &tex, AI_MATKEY_TEXTURE_NORMALS(iNM++));
- } else if (std::string::npos != sz.find( "spec", s) || std::string::npos != sz.find( "glanz", s)) {
- mat->AddProperty( &tex, AI_MATKEY_TEXTURE_SPECULAR(iSM++));
- } else if (std::string::npos != sz.find( "ambi", s) || std::string::npos != sz.find( "env", s)) {
- mat->AddProperty( &tex, AI_MATKEY_TEXTURE_AMBIENT(iAM++));
- } else if (std::string::npos != sz.find( "emissive", s) || std::string::npos != sz.find( "self", s)) {
- mat->AddProperty( &tex, AI_MATKEY_TEXTURE_EMISSIVE(iEM++));
+ mat->AddProperty(&tex, AI_MATKEY_TEXTURE_HEIGHT(iHM++));
+ } else if (otex.mIsNormalMap || std::string::npos != sz.find("normal", s) || std::string::npos != sz.find("nm", s)) {
+ mat->AddProperty(&tex, AI_MATKEY_TEXTURE_NORMALS(iNM++));
+ } else if (std::string::npos != sz.find("spec", s) || std::string::npos != sz.find("glanz", s)) {
+ mat->AddProperty(&tex, AI_MATKEY_TEXTURE_SPECULAR(iSM++));
+ } else if (std::string::npos != sz.find("ambi", s) || std::string::npos != sz.find("env", s)) {
+ mat->AddProperty(&tex, AI_MATKEY_TEXTURE_AMBIENT(iAM++));
+ } else if (std::string::npos != sz.find("emissive", s) || std::string::npos != sz.find("self", s)) {
+ mat->AddProperty(&tex, AI_MATKEY_TEXTURE_EMISSIVE(iEM++));
} else {
// Assume it is a diffuse texture
- mat->AddProperty( &tex, AI_MATKEY_TEXTURE_DIFFUSE(iDM++));
+ mat->AddProperty(&tex, AI_MATKEY_TEXTURE_DIFFUSE(iDM++));
}
}
}
@@ -679,4 +683,6 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
}
}
+} // namespace Assimp
+
#endif // !! ASSIMP_BUILD_NO_X_IMPORTER
diff --git a/code/AssetLib/X/XFileImporter.h b/code/AssetLib/X/XFileImporter.h
index 28c283d37..cd741deec 100644
--- a/code/AssetLib/X/XFileImporter.h
+++ b/code/AssetLib/X/XFileImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -68,7 +68,7 @@ namespace XFile {
*/
class XFileImporter : public BaseImporter {
public:
- XFileImporter();
+ XFileImporter() = default;
~XFileImporter() override = default;
// -------------------------------------------------------------------
diff --git a/code/AssetLib/X/XFileParser.cpp b/code/AssetLib/X/XFileParser.cpp
index 770c75a77..63c654b65 100644
--- a/code/AssetLib/X/XFileParser.cpp
+++ b/code/AssetLib/X/XFileParser.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/X/XFileParser.h b/code/AssetLib/X/XFileParser.h
index 36eac2ada..32375511a 100644
--- a/code/AssetLib/X/XFileParser.h
+++ b/code/AssetLib/X/XFileParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/X3D/X3DGeoHelper.cpp b/code/AssetLib/X3D/X3DGeoHelper.cpp
index 0a62ff9b0..1c962a460 100644
--- a/code/AssetLib/X3D/X3DGeoHelper.cpp
+++ b/code/AssetLib/X3D/X3DGeoHelper.cpp
@@ -188,6 +188,51 @@ mg_m_err:
pFaces.clear();
}
+void X3DGeoHelper::coordIdx_str2lines_arr(const std::vector<int32_t> &pCoordIdx, std::vector<aiFace> &pFaces) {
+ std::vector<int32_t> f_data(pCoordIdx);
+
+ if (f_data.back() != (-1)) {
+ f_data.push_back(-1);
+ }
+
+ // reserve average size.
+ pFaces.reserve(f_data.size() / 2);
+ for (std::vector<int32_t>::const_iterator startIt = f_data.cbegin(), endIt = f_data.cbegin(); endIt != f_data.cend(); ++endIt) {
+ // check for end of current polyline
+ if (*endIt != -1)
+ continue;
+
+ // found end of polyline, check if this is a valid polyline
+ std::size_t numIndices = std::distance(startIt, endIt);
+ if (numIndices <= 1)
+ goto mg_m_err;
+
+ // create line faces out of polyline indices
+ for (int32_t idx0 = *startIt++; startIt != endIt; ++startIt) {
+ int32_t idx1 = *startIt;
+
+ aiFace tface;
+ tface.mNumIndices = 2;
+ tface.mIndices = new unsigned int[2];
+ tface.mIndices[0] = idx0;
+ tface.mIndices[1] = idx1;
+ pFaces.push_back(tface);
+
+ idx0 = idx1;
+ }
+
+ ++startIt;
+ }
+
+ return;
+
+mg_m_err:
+ for (size_t i = 0, i_e = pFaces.size(); i < i_e; i++)
+ delete[] pFaces[i].mIndices;
+
+ pFaces.clear();
+}
+
void X3DGeoHelper::add_color(aiMesh &pMesh, const std::list<aiColor3D> &pColors, const bool pColorPerVertex) {
std::list<aiColor4D> tcol;
@@ -528,4 +573,40 @@ aiMesh *X3DGeoHelper::make_mesh(const std::vector<int32_t> &pCoordIdx, const std
return tmesh;
}
+aiMesh *X3DGeoHelper::make_line_mesh(const std::vector<int32_t> &pCoordIdx, const std::list<aiVector3D> &pVertices) {
+ std::vector<aiFace> faces;
+
+ // create faces array from input string with vertices indices.
+ X3DGeoHelper::coordIdx_str2lines_arr(pCoordIdx, faces);
+ if (!faces.size()) {
+ throw DeadlyImportError("Failed to create mesh, faces list is empty.");
+ }
+
+ //
+ // Create new mesh and copy geometry data.
+ //
+ aiMesh *tmesh = new aiMesh;
+ size_t ts = faces.size();
+ // faces
+ tmesh->mFaces = new aiFace[ts];
+ tmesh->mNumFaces = static_cast<unsigned int>(ts);
+ for (size_t i = 0; i < ts; i++)
+ tmesh->mFaces[i] = faces[i];
+
+ // vertices
+ std::list<aiVector3D>::const_iterator vit = pVertices.begin();
+
+ ts = pVertices.size();
+ tmesh->mVertices = new aiVector3D[ts];
+ tmesh->mNumVertices = static_cast<unsigned int>(ts);
+ for (size_t i = 0; i < ts; i++) {
+ tmesh->mVertices[i] = *vit++;
+ }
+
+ // set primitive type and return result.
+ tmesh->mPrimitiveTypes = aiPrimitiveType_LINE;
+
+ return tmesh;
+}
+
} // namespace Assimp
diff --git a/code/AssetLib/X3D/X3DGeoHelper.h b/code/AssetLib/X3D/X3DGeoHelper.h
index 78e57f9da..c740b4288 100644
--- a/code/AssetLib/X3D/X3DGeoHelper.h
+++ b/code/AssetLib/X3D/X3DGeoHelper.h
@@ -21,6 +21,7 @@ public:
static void polylineIdx_to_lineIdx(const std::list<int32_t> &pPolylineCoordIdx, std::list<int32_t> &pLineCoordIdx);
static void rect_parallel_epiped(const aiVector3D &pSize, std::list<aiVector3D> &pVertices);
static void coordIdx_str2faces_arr(const std::vector<int32_t> &pCoordIdx, std::vector<aiFace> &pFaces, unsigned int &pPrimitiveTypes);
+ static void coordIdx_str2lines_arr(const std::vector<int32_t> &pCoordIdx, std::vector<aiFace> &pFaces);
static void add_color(aiMesh &pMesh, const std::list<aiColor3D> &pColors, const bool pColorPerVertex);
static void add_color(aiMesh &pMesh, const std::list<aiColor4D> &pColors, const bool pColorPerVertex);
static void add_color(aiMesh &pMesh, const std::vector<int32_t> &pCoordIdx, const std::vector<int32_t> &pColorIdx,
@@ -34,6 +35,7 @@ public:
const std::list<aiVector2D> &pTexCoords);
static void add_tex_coord(aiMesh &pMesh, const std::list<aiVector2D> &pTexCoords);
static aiMesh *make_mesh(const std::vector<int32_t> &pCoordIdx, const std::list<aiVector3D> &pVertices);
+ static aiMesh *make_line_mesh(const std::vector<int32_t> &pCoordIdx, const std::list<aiVector3D> &pVertices);
};
} // namespace Assimp
diff --git a/code/AssetLib/X3D/X3DImporter.cpp b/code/AssetLib/X3D/X3DImporter.cpp
index eeb20b7c1..ada388080 100644
--- a/code/AssetLib/X3D/X3DImporter.cpp
+++ b/code/AssetLib/X3D/X3DImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/X3D/X3DImporter.hpp b/code/AssetLib/X3D/X3DImporter.hpp
index 705a2472e..623160a38 100644
--- a/code/AssetLib/X3D/X3DImporter.hpp
+++ b/code/AssetLib/X3D/X3DImporter.hpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp
index 240ff14a8..b4562ace2 100644
--- a/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp
+++ b/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/X3D/X3DImporter_Postprocess.cpp b/code/AssetLib/X3D/X3DImporter_Postprocess.cpp
index 87121ef5f..216929076 100644
--- a/code/AssetLib/X3D/X3DImporter_Postprocess.cpp
+++ b/code/AssetLib/X3D/X3DImporter_Postprocess.cpp
@@ -320,7 +320,7 @@ void X3DImporter::Postprocess_BuildMesh(const X3DNodeElementBase &pNodeElement,
// at first search for <Coordinate> node and create mesh.
for (std::list<X3DNodeElementBase *>::iterator ch_it = tnemesh.Children.begin(); ch_it != tnemesh.Children.end(); ++ch_it) {
if ((*ch_it)->Type == X3DElemType::ENET_Coordinate) {
- *pMesh = X3DGeoHelper::make_mesh(tnemesh.CoordIndex, ((X3DNodeElementCoordinate *)*ch_it)->Value);
+ *pMesh = X3DGeoHelper::make_line_mesh(tnemesh.CoordIndex, ((X3DNodeElementCoordinate *)*ch_it)->Value);
}
}
diff --git a/code/AssetLib/XGL/XGLLoader.cpp b/code/AssetLib/XGL/XGLLoader.cpp
index 04e303370..614fac641 100644
--- a/code/AssetLib/XGL/XGLLoader.cpp
+++ b/code/AssetLib/XGL/XGLLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -56,64 +56,46 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory>
#include <utility>
-//#include <cctype>
-//#include <memory>
-using namespace Assimp;
+namespace Assimp {
-namespace Assimp { // this has to be in here because LogFunctions is in ::Assimp
+static constexpr uint32_t ErrorId = ~0u;
template <>
const char *LogFunctions<XGLImporter>::Prefix() {
return "XGL: ";
}
-} // namespace Assimp
-
-static const aiImporterDesc desc = {
- "XGL Importer",
- "",
- "",
- "",
- aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportCompressedFlavour,
- 0,
- 0,
- 0,
- 0,
- "xgl zgl"
-};
+static constexpr aiImporterDesc desc = {
+ "XGL Importer", "", "", "",
+ aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportCompressedFlavour,
+ 0, 0, 0, 0, "xgl zgl"};
// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-XGLImporter::XGLImporter() :
- mXmlParser(nullptr),
- m_scene(nullptr) {
+XGLImporter::XGLImporter() : mXmlParser(nullptr), m_scene(nullptr) {
// empty
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
XGLImporter::~XGLImporter() {
- delete mXmlParser;
+ clear();
}
// ------------------------------------------------------------------------------------------------
-// Returns whether the class can handle the format of the given file.
bool XGLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
static const char *tokens[] = { "<world>", "<World>", "<WORLD>" };
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens));
}
// ------------------------------------------------------------------------------------------------
-// Get a list of all file extensions which are handled by this class
const aiImporterDesc *XGLImporter::GetInfo() const {
return &desc;
}
// ------------------------------------------------------------------------------------------------
-// Imports the given file into the given scene structure.
void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
- #ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL
+ clear();
+#ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL
std::vector<char> uncompressed;
#endif
@@ -159,7 +141,7 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
std::vector<aiMesh *> &meshes = scope.meshes_linear;
std::vector<aiMaterial *> &materials = scope.materials_linear;
- if (!meshes.size() || !materials.size()) {
+ if (meshes.empty() || materials.empty()) {
ThrowException("failed to extract data from XGL file, no meshes loaded");
}
@@ -185,6 +167,13 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
}
// ------------------------------------------------------------------------------------------------
+void XGLImporter::clear() {
+ delete mXmlParser;
+ mXmlParser = nullptr;
+}
+
+
+// ------------------------------------------------------------------------------------------------
void XGLImporter::ReadWorld(XmlNode &node, TempScope &scope) {
for (XmlNode &currentNode : node.children()) {
const std::string &s = ai_stdStrToLower(currentNode.name());
@@ -199,9 +188,10 @@ void XGLImporter::ReadWorld(XmlNode &node, TempScope &scope) {
}
aiNode *const nd = ReadObject(node, scope);
- if (!nd) {
+ if (nd == nullptr) {
ThrowException("failure reading <world>");
}
+
if (nd->mName.length == 0) {
nd->mName.Set("WORLD");
}
@@ -254,15 +244,17 @@ aiNode *XGLImporter::ReadObject(XmlNode &node, TempScope &scope) {
const std::string &s = ai_stdStrToLower(child.name());
if (s == "mesh") {
const size_t prev = scope.meshes_linear.size();
- bool empty;
- if (ReadMesh(child, scope, empty)) {
+ if (ReadMesh(child, scope)) {
const size_t newc = scope.meshes_linear.size();
for (size_t i = 0; i < newc - prev; ++i) {
meshes.push_back(static_cast<unsigned int>(i + prev));
}
- }
+ }
} else if (s == "mat") {
- ReadMaterial(child, scope);
+ const uint32_t matId = ReadMaterial(child, scope);
+ if (matId == ErrorId) {
+ ThrowException("Invalid material id detected.");
+ }
} else if (s == "object") {
children.push_back(ReadObject(child, scope));
} else if (s == "objectref") {
@@ -438,18 +430,25 @@ aiMesh *XGLImporter::ToOutputMesh(const TempMaterialMesh &m) {
return mesh.release();
}
+
// ------------------------------------------------------------------------------------------------
-bool XGLImporter::ReadMesh(XmlNode &node, TempScope &scope, bool &empty) {
- TempMesh t;
+inline static unsigned int generateMeshId(unsigned int meshId, bool nor, bool uv) {
+ unsigned int currentMeshId = meshId | ((nor ? 1 : 0) << 31) | ((uv ? 1 : 0) << 30);
+ return currentMeshId;
+}
+// ------------------------------------------------------------------------------------------------
+bool XGLImporter::ReadMesh(XmlNode &node, TempScope &scope) {
+ TempMesh t;
+ uint32_t matId = 99999;
+ bool mesh_created = false;
std::map<unsigned int, TempMaterialMesh> bymat;
const unsigned int mesh_id = ReadIDAttr(node);
- bool empty_mesh = true;
for (XmlNode &child : node.children()) {
const std::string &s = ai_stdStrToLower(child.name());
if (s == "mat") {
- ReadMaterial(child, scope);
+ matId = ReadMaterial(child, scope);
} else if (s == "p") {
pugi::xml_attribute attr = child.attribute("ID");
if (attr.empty()) {
@@ -477,66 +476,41 @@ bool XGLImporter::ReadMesh(XmlNode &node, TempScope &scope, bool &empty) {
} else if (s == "f" || s == "l" || s == "p") {
const unsigned int vcount = s == "f" ? 3 : (s == "l" ? 2 : 1);
- unsigned int mid = ~0u;
- TempFace tf[3];
+ unsigned int meshId = ErrorId;
+ TempFace tempFace[3] = {};
bool has[3] = { false };
- for (XmlNode &sub_child : child.children()) {
- const std::string &scn = ai_stdStrToLower(sub_child.name());
- if (scn == "fv1" || scn == "lv1" || scn == "pv1") {
- ReadFaceVertex(sub_child, t, tf[0]);
- has[0] = true;
- } else if (scn == "fv2" || scn == "lv2") {
- ReadFaceVertex(sub_child, t, tf[1]);
- has[1] = true;
- } else if (scn == "fv3") {
- ReadFaceVertex(sub_child, t, tf[2]);
- has[2] = true;
- } else if (scn == "mat") {
- if (mid != ~0u) {
- LogWarn("only one material tag allowed per <f>");
- }
- mid = ResolveMaterialRef(sub_child, scope);
- } else if (scn == "matref") {
- if (mid != ~0u) {
- LogWarn("only one material tag allowed per <f>");
- }
- mid = ResolveMaterialRef(sub_child, scope);
- }
- }
- if (has[0] || has[1] || has[2]) {
- empty_mesh = false;
- }
-
- if (mid == ~0u) {
+ meshId = ReadVertices(child, t, tempFace, has, meshId, scope);
+ if (meshId == ErrorId) {
ThrowException("missing material index");
}
- bool nor = false;
- bool uv = false;
+ bool nor = false, uv = false;
for (unsigned int i = 0; i < vcount; ++i) {
if (!has[i]) {
ThrowException("missing face vertex data");
}
- nor = nor || tf[i].has_normal;
- uv = uv || tf[i].has_uv;
+ nor = nor || tempFace[i].has_normal;
+ uv = uv || tempFace[i].has_uv;
}
- if (mid >= (1 << 30)) {
+ if (meshId >= (1 << 30)) {
LogWarn("material indices exhausted, this may cause errors in the output");
}
- unsigned int meshId = mid | ((nor ? 1 : 0) << 31) | ((uv ? 1 : 0) << 30);
+ const unsigned int currentMeshId = generateMeshId(meshId, nor, uv);
- TempMaterialMesh &mesh = bymat[meshId];
- mesh.matid = mid;
+ // Generate the temp mesh
+ TempMaterialMesh &mesh = bymat[currentMeshId];
+ mesh.matid = meshId;
+ mesh_created = true;
for (unsigned int i = 0; i < vcount; ++i) {
- mesh.positions.push_back(tf[i].pos);
+ mesh.positions.push_back(tempFace[i].pos);
if (nor) {
- mesh.normals.push_back(tf[i].normal);
+ mesh.normals.push_back(tempFace[i].normal);
}
if (uv) {
- mesh.uvs.push_back(tf[i].uv);
+ mesh.uvs.push_back(tempFace[i].uv);
}
mesh.pflags |= 1 << (vcount - 1);
@@ -546,25 +520,59 @@ bool XGLImporter::ReadMesh(XmlNode &node, TempScope &scope, bool &empty) {
}
}
- // finally extract output meshes and add them to the scope
- using pairt = std::pair<const unsigned int, TempMaterialMesh>;
- for (const pairt &p : bymat) {
- aiMesh *const m = ToOutputMesh(p.second);
- scope.meshes_linear.push_back(m);
-
- // if this is a definition, keep it on the stack
- if (mesh_id != ~0u) {
- scope.meshes.insert(std::pair<unsigned int, aiMesh *>(mesh_id, m));
- }
- }
- if (empty_mesh) {
- LogWarn("Mesh is empty, skipping.");
- empty = empty_mesh;
- return false;
+ if (!mesh_created) {
+ TempMaterialMesh &mesh = bymat[mesh_id];
+ mesh.matid = matId;
}
+ // finally extract output meshes and add them to the scope
+ AppendOutputMeshes(bymat, scope, mesh_id);
+
// no id == not a reference, insert this mesh right *here*
- return mesh_id == ~0u;
+ return mesh_id == ErrorId;
+}
+
+// ----------------------------------------------------------------------------------------------
+void XGLImporter::AppendOutputMeshes(std::map<unsigned int, TempMaterialMesh> bymat, TempScope &scope,
+ const unsigned int mesh_id) {
+ using pairt = std::pair<const unsigned int, TempMaterialMesh>;
+ for (const pairt &p : bymat) {
+ aiMesh *const m = ToOutputMesh(p.second);
+ scope.meshes_linear.push_back(m);
+
+ // if this is a definition, keep it on the stack
+ if (mesh_id != ErrorId) {
+ scope.meshes.insert(std::pair<unsigned int, aiMesh *>(mesh_id, m));
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------------------------
+unsigned int XGLImporter::ReadVertices(XmlNode &child, TempMesh t, TempFace *tf, bool *has, unsigned int mid, TempScope &scope) {
+ for (XmlNode &sub_child : child.children()) {
+ const std::string &scn = ai_stdStrToLower(sub_child.name());
+ if (scn == "fv1" || scn == "lv1" || scn == "pv1") {
+ ReadFaceVertex(sub_child, t, tf[0]);
+ has[0] = true;
+ } else if (scn == "fv2" || scn == "lv2") {
+ ReadFaceVertex(sub_child, t, tf[1]);
+ has[1] = true;
+ } else if (scn == "fv3") {
+ ReadFaceVertex(sub_child, t, tf[2]);
+ has[2] = true;
+ } else if (scn == "mat") {
+ if (mid != ErrorId) {
+ LogWarn("only one material tag allowed per <f>");
+ }
+ mid = ResolveMaterialRef(sub_child, scope);
+ } else if (scn == "matref") {
+ if (mid != ErrorId) {
+ LogWarn("only one material tag allowed per <f>");
+ }
+ mid = ResolveMaterialRef(sub_child, scope);
+ }
+ }
+ return mid;
}
// ----------------------------------------------------------------------------------------------
@@ -598,10 +606,10 @@ unsigned int XGLImporter::ResolveMaterialRef(XmlNode &node, TempScope &scope) {
}
// ------------------------------------------------------------------------------------------------
-void XGLImporter::ReadMaterial(XmlNode &node, TempScope &scope) {
+unsigned int XGLImporter::ReadMaterial(XmlNode &node, TempScope &scope) {
const unsigned int mat_id = ReadIDAttr(node);
- auto *mat(new aiMaterial);
+ auto *mat = new aiMaterial;
for (XmlNode &child : node.children()) {
const std::string &s = ai_stdStrToLower(child.name());
if (s == "amb") {
@@ -627,6 +635,8 @@ void XGLImporter::ReadMaterial(XmlNode &node, TempScope &scope) {
scope.materials[mat_id] = mat;
scope.materials_linear.push_back(mat);
+
+ return mat_id;
}
// ----------------------------------------------------------------------------------------------
@@ -683,20 +693,21 @@ unsigned int XGLImporter::ReadIDAttr(XmlNode &node) {
}
}
- return ~0u;
+ return ErrorId;
}
// ------------------------------------------------------------------------------------------------
float XGLImporter::ReadFloat(XmlNode &node) {
std::string v;
XmlParser::getValueAsString(node, v);
- const char *s = v.c_str(), *se;
- if (!SkipSpaces(&s)) {
+ const char *s = v.c_str();
+ const char *end = v.c_str() + v.size();
+ if (!SkipSpaces(&s, end)) {
LogError("unexpected EOL, failed to parse index element");
return 0.f;
}
- float t;
- se = fast_atoreal_move(s, t);
+ float t{ 0.0f };
+ const char *se = fast_atoreal_move(s, t);
if (se == s) {
LogError("failed to read float text");
return 0.f;
@@ -710,16 +721,17 @@ unsigned int XGLImporter::ReadIndexFromText(XmlNode &node) {
std::string v;
XmlParser::getValueAsString(node, v);
const char *s = v.c_str();
- if (!SkipSpaces(&s)) {
+ const char *end = v.c_str() + v.size();
+ if (!SkipSpaces(&s, end)) {
LogError("unexpected EOL, failed to parse index element");
- return ~0u;
+ return ErrorId;
}
- const char *se;
+ const char *se = nullptr;
const unsigned int t = strtoul10(s, &se);
if (se == s) {
LogError("failed to read index");
- return ~0u;
+ return ErrorId;
}
return t;
@@ -731,16 +743,17 @@ aiVector2D XGLImporter::ReadVec2(XmlNode &node) {
std::string val;
XmlParser::getValueAsString(node, val);
const char *s = val.c_str();
+ const char *end = val.c_str() + val.size();
ai_real v[2] = {};
for (int i = 0; i < 2; ++i) {
- if (!SkipSpaces(&s)) {
+ if (!SkipSpaces(&s, end)) {
LogError("unexpected EOL, failed to parse vec2");
return vec;
}
v[i] = fast_atof(&s);
- SkipSpaces(&s);
+ SkipSpaces(&s, end);
if (i != 1 && *s != ',') {
LogError("expected comma, failed to parse vec2");
return vec;
@@ -759,14 +772,15 @@ aiVector3D XGLImporter::ReadVec3(XmlNode &node) {
std::string v;
XmlParser::getValueAsString(node, v);
const char *s = v.c_str();
+ const char *end = v.c_str() + v.size();
for (int i = 0; i < 3; ++i) {
- if (!SkipSpaces(&s)) {
+ if (!SkipSpaces(&s, end)) {
LogError("unexpected EOL, failed to parse vec3");
return vec;
}
vec[i] = fast_atof(&s);
- SkipSpaces(&s);
+ SkipSpaces(&s, end);
if (i != 2 && *s != ',') {
LogError("expected comma, failed to parse vec3");
return vec;
@@ -786,4 +800,6 @@ aiColor3D XGLImporter::ReadCol3(XmlNode &node) {
return aiColor3D(v.x, v.y, v.z);
}
+} // namespace Assimp
+
#endif // ASSIMP_BUILD_NO_XGL_IMPORTER
diff --git a/code/AssetLib/XGL/XGLLoader.h b/code/AssetLib/XGL/XGLLoader.h
index ae7ccddc2..9d39bc811 100644
--- a/code/AssetLib/XGL/XGLLoader.h
+++ b/code/AssetLib/XGL/XGLLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -69,16 +69,20 @@ namespace Assimp {
*/
class XGLImporter : public BaseImporter, public LogFunctions<XGLImporter> {
public:
+ /// @brief The class constructor.
XGLImporter();
+
+ /// @brief The class destructor.
~XGLImporter() override;
- // -------------------------------------------------------------------
- /** Returns whether the class can handle the format of the given file.
- * See BaseImporter::CanRead() for details. */
+ /// @brief Returns whether the class can handle the format of the given file.
+ /// @see BaseImporter::CanRead() for details. */
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
bool checkSig) const override;
protected:
+ void clear();
+
// -------------------------------------------------------------------
/** Return importer meta information.
* See #BaseImporter::GetInfo for the details */
@@ -92,10 +96,7 @@ protected:
private:
struct TempScope {
- TempScope() :
- light() {
- // empty
- }
+ TempScope() : light() {}
~TempScope() {
for (aiMesh *m : meshes_linear) {
@@ -145,9 +146,7 @@ private:
};
struct TempMaterialMesh {
- TempMaterialMesh() :
- pflags(),
- matid() {
+ TempMaterialMesh() : pflags(), matid() {
// empty
}
@@ -160,9 +159,7 @@ private:
};
struct TempFace {
- TempFace() :
- has_uv(),
- has_normal() {
+ TempFace() : has_uv(), has_normal() {
// empty
}
@@ -175,26 +172,25 @@ private:
private:
void Cleanup();
-
std::string GetElementName();
bool ReadElement();
bool ReadElementUpToClosing(const char *closetag);
bool SkipToText();
unsigned int ReadIDAttr(XmlNode &node);
-
void ReadWorld(XmlNode &node, TempScope &scope);
void ReadLighting(XmlNode &node, TempScope &scope);
aiLight *ReadDirectionalLight(XmlNode &node);
aiNode *ReadObject(XmlNode &node, TempScope &scope);
- bool ReadMesh(XmlNode &node, TempScope &scope, bool &empty);
- void ReadMaterial(XmlNode &node, TempScope &scope);
+ bool ReadMesh(XmlNode &node, TempScope &scope);
+ void AppendOutputMeshes(std::map<unsigned int, TempMaterialMesh> bymat, TempScope &scope, const unsigned int mesh_id);
+ unsigned int ReadVertices(XmlNode &child, TempMesh t, TempFace *tf, bool *has, unsigned int mid, TempScope &scope);
+ unsigned int ReadMaterial(XmlNode &node, TempScope &scope);
aiVector2D ReadVec2(XmlNode &node);
aiVector3D ReadVec3(XmlNode &node);
aiColor3D ReadCol3(XmlNode &node);
aiMatrix4x4 ReadTrafo(XmlNode &node);
unsigned int ReadIndexFromText(XmlNode &node);
float ReadFloat(XmlNode &node);
-
aiMesh *ToOutputMesh(const TempMaterialMesh &m);
void ReadFaceVertex(XmlNode &node, const TempMesh &t, TempFace &out);
unsigned int ResolveMaterialRef(XmlNode &node, TempScope &scope);
diff --git a/code/AssetLib/glTF/glTFAsset.h b/code/AssetLib/glTF/glTFAsset.h
index b5e6375ad..27dfae005 100644
--- a/code/AssetLib/glTF/glTFAsset.h
+++ b/code/AssetLib/glTF/glTFAsset.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/glTF/glTFAsset.inl b/code/AssetLib/glTF/glTFAsset.inl
index eddbf5706..5e554a31e 100644
--- a/code/AssetLib/glTF/glTFAsset.inl
+++ b/code/AssetLib/glTF/glTFAsset.inl
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/glTF/glTFAssetWriter.h b/code/AssetLib/glTF/glTFAssetWriter.h
index 6dbc42420..832c9e847 100644
--- a/code/AssetLib/glTF/glTFAssetWriter.h
+++ b/code/AssetLib/glTF/glTFAssetWriter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/glTF/glTFAssetWriter.inl b/code/AssetLib/glTF/glTFAssetWriter.inl
index 2d80598ac..c0b8edfa2 100644
--- a/code/AssetLib/glTF/glTFAssetWriter.inl
+++ b/code/AssetLib/glTF/glTFAssetWriter.inl
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/glTF/glTFCommon.cpp b/code/AssetLib/glTF/glTFCommon.cpp
index fea680cd3..11e038fa3 100644
--- a/code/AssetLib/glTF/glTFCommon.cpp
+++ b/code/AssetLib/glTF/glTFCommon.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/glTF/glTFCommon.h b/code/AssetLib/glTF/glTFCommon.h
index 187fbbdb5..e42d905ff 100644
--- a/code/AssetLib/glTF/glTFCommon.h
+++ b/code/AssetLib/glTF/glTFCommon.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/glTF/glTFExporter.cpp b/code/AssetLib/glTF/glTFExporter.cpp
index 91d88f1ae..0cffda024 100644
--- a/code/AssetLib/glTF/glTFExporter.cpp
+++ b/code/AssetLib/glTF/glTFExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Exporter.hpp>
#include <assimp/material.h>
#include <assimp/scene.h>
+#include <assimp/config.h>
// Header files, standard library.
#include <memory>
@@ -113,6 +114,10 @@ glTFExporter::glTFExporter(const char* filename, IOSystem* pIOSystem, const aiSc
mAsset = std::make_shared<glTF::Asset>(pIOSystem);
+ configEpsilon = mProperties->GetPropertyFloat(
+ AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON,
+ (ai_real)AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT);
+
if (isBinary) {
mAsset->SetAsBinary();
}
@@ -824,7 +829,7 @@ unsigned int glTFExporter::ExportNodeHierarchy(const aiNode* n)
{
Ref<Node> node = mAsset->nodes.Create(mAsset->FindUniqueID(n->mName.C_Str(), "node"));
- if (!n->mTransformation.IsIdentity()) {
+ if (!n->mTransformation.IsIdentity(configEpsilon)) {
node->matrix.isPresent = true;
CopyValue(n->mTransformation, node->matrix.value);
}
@@ -851,7 +856,7 @@ unsigned int glTFExporter::ExportNode(const aiNode* n, Ref<Node>& parent)
node->parent = parent;
- if (!n->mTransformation.IsIdentity()) {
+ if (!n->mTransformation.IsIdentity(configEpsilon)) {
node->matrix.isPresent = true;
CopyValue(n->mTransformation, node->matrix.value);
}
diff --git a/code/AssetLib/glTF/glTFExporter.h b/code/AssetLib/glTF/glTFExporter.h
index a52695402..adac06197 100644
--- a/code/AssetLib/glTF/glTFExporter.h
+++ b/code/AssetLib/glTF/glTFExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/material.h>
#include <assimp/types.h>
+#include <assimp/defs.h>
#include <map>
#include <memory>
@@ -98,6 +99,8 @@ private:
std::vector<unsigned char> mBodyData;
+ ai_real configEpsilon;
+
void WriteBinaryData(IOStream *outfile, std::size_t sceneLength);
void GetTexSampler(const aiMaterial *mat, glTF::TexProperty &prop);
diff --git a/code/AssetLib/glTF/glTFImporter.cpp b/code/AssetLib/glTF/glTFImporter.cpp
index 110a2a52f..1d718fd20 100644
--- a/code/AssetLib/glTF/glTFImporter.cpp
+++ b/code/AssetLib/glTF/glTFImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -62,11 +62,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
using namespace glTF;
-//
-// glTFImporter
-//
-
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"glTF Importer",
"",
"",
diff --git a/code/AssetLib/glTF/glTFImporter.h b/code/AssetLib/glTF/glTFImporter.h
index 529da53cc..384299b1f 100644
--- a/code/AssetLib/glTF/glTFImporter.h
+++ b/code/AssetLib/glTF/glTFImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/glTF2/glTF2Asset.h b/code/AssetLib/glTF2/glTF2Asset.h
index 3ae40f07e..60ed368d1 100644
--- a/code/AssetLib/glTF2/glTF2Asset.h
+++ b/code/AssetLib/glTF2/glTF2Asset.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -547,7 +547,7 @@ struct BufferView : public Object {
BufferViewTarget target; //! The target that the WebGL buffer should be bound to.
void Read(Value &obj, Asset &r);
- uint8_t *GetPointer(size_t accOffset);
+ uint8_t *GetPointerAndTailSize(size_t accOffset, size_t& outTailSize);
};
//! A typed view into a BufferView. A BufferView contains raw binary data.
@@ -629,7 +629,7 @@ struct Accessor : public Object {
std::vector<uint8_t> data; //!< Actual data, which may be defaulted to an array of zeros or the original data, with the sparse buffer view applied on top of it.
- void PopulateData(size_t numBytes, uint8_t *bytes);
+ void PopulateData(size_t numBytes, const uint8_t *bytes);
void PatchData(unsigned int elementSize);
};
};
@@ -720,7 +720,7 @@ const vec4 defaultBaseColor = { 1, 1, 1, 1 };
const vec3 defaultEmissiveFactor = { 0, 0, 0 };
const vec4 defaultDiffuseFactor = { 1, 1, 1, 1 };
const vec3 defaultSpecularFactor = { 1, 1, 1 };
-const vec3 defaultSpecularColorFactor = { 0, 0, 0 };
+const vec3 defaultSpecularColorFactor = { 1, 1, 1 };
const vec3 defaultSheenFactor = { 0, 0, 0 };
const vec3 defaultAttenuationColor = { 1, 1, 1 };
diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl
index 53ffdaf31..457fee8fa 100644
--- a/code/AssetLib/glTF2/glTF2Asset.inl
+++ b/code/AssetLib/glTF2/glTF2Asset.inl
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -785,12 +785,14 @@ inline void BufferView::Read(Value &obj, Asset &r) {
}
}
-inline uint8_t *BufferView::GetPointer(size_t accOffset) {
+inline uint8_t *BufferView::GetPointerAndTailSize(size_t accOffset, size_t& outTailSize) {
if (!buffer) {
+ outTailSize = 0;
return nullptr;
}
- uint8_t *basePtr = buffer->GetPointer();
+ uint8_t * const basePtr = buffer->GetPointer();
if (!basePtr) {
+ outTailSize = 0;
return nullptr;
}
@@ -799,17 +801,25 @@ inline uint8_t *BufferView::GetPointer(size_t accOffset) {
const size_t begin = buffer->EncodedRegion_Current->Offset;
const size_t end = begin + buffer->EncodedRegion_Current->DecodedData_Length;
if ((offset >= begin) && (offset < end)) {
+ outTailSize = end - offset;
return &buffer->EncodedRegion_Current->DecodedData[offset - begin];
}
}
+ if (offset >= buffer->byteLength)
+ {
+ outTailSize = 0;
+ return nullptr;
+ }
+
+ outTailSize = buffer->byteLength - offset;
return basePtr + offset;
}
//
// struct Accessor
//
-inline void Accessor::Sparse::PopulateData(size_t numBytes, uint8_t *bytes) {
+inline void Accessor::Sparse::PopulateData(size_t numBytes, const uint8_t *bytes) {
if (bytes) {
data.assign(bytes, bytes + numBytes);
} else {
@@ -818,11 +828,21 @@ inline void Accessor::Sparse::PopulateData(size_t numBytes, uint8_t *bytes) {
}
inline void Accessor::Sparse::PatchData(unsigned int elementSize) {
- uint8_t *pIndices = indices->GetPointer(indicesByteOffset);
+ size_t indicesTailDataSize;
+ uint8_t *pIndices = indices->GetPointerAndTailSize(indicesByteOffset, indicesTailDataSize);
const unsigned int indexSize = int(ComponentTypeSize(indicesType));
uint8_t *indicesEnd = pIndices + count * indexSize;
- uint8_t *pValues = values->GetPointer(valuesByteOffset);
+ if ((uint64_t)indicesEnd > (uint64_t)pIndices + indicesTailDataSize) {
+ throw DeadlyImportError("Invalid sparse accessor. Indices outside allocated memory.");
+ }
+
+ size_t valuesTailDataSize;
+ uint8_t* pValues = values->GetPointerAndTailSize(valuesByteOffset, valuesTailDataSize);
+
+ if (elementSize * count > valuesTailDataSize) {
+ throw DeadlyImportError("Invalid sparse accessor. Indices outside allocated memory.");
+ }
while (pIndices != indicesEnd) {
size_t offset;
switch (indicesType) {
@@ -894,6 +914,9 @@ inline void Accessor::Read(Value &obj, Asset &r) {
if (Value *indicesValue = FindObject(*sparseValue, "indices")) {
//indices bufferView
Value *indiceViewID = FindUInt(*indicesValue, "bufferView");
+ if (!indiceViewID) {
+ throw DeadlyImportError("A bufferView value is required, when reading ", id.c_str(), name.empty() ? "" : " (" + name + ")");
+ }
sparse->indices = r.bufferViews.Retrieve(indiceViewID->GetUint());
//indices byteOffset
sparse->indicesByteOffset = MemberOrDefault(*indicesValue, "byteOffset", size_t(0));
@@ -909,6 +932,9 @@ inline void Accessor::Read(Value &obj, Asset &r) {
if (Value *valuesValue = FindObject(*sparseValue, "values")) {
//value bufferView
Value *valueViewID = FindUInt(*valuesValue, "bufferView");
+ if (!valueViewID) {
+ throw DeadlyImportError("A bufferView value is required, when reading ", id.c_str(), name.empty() ? "" : " (" + name + ")");
+ }
sparse->values = r.bufferViews.Retrieve(valueViewID->GetUint());
//value byteOffset
sparse->valuesByteOffset = MemberOrDefault(*valuesValue, "byteOffset", size_t(0));
@@ -918,8 +944,18 @@ inline void Accessor::Read(Value &obj, Asset &r) {
const unsigned int elementSize = GetElementSize();
const size_t dataSize = count * elementSize;
- sparse->PopulateData(dataSize, bufferView ? bufferView->GetPointer(byteOffset) : nullptr);
- sparse->PatchData(elementSize);
+ if (bufferView) {
+ size_t bufferViewTailSize;
+ const uint8_t* bufferViewPointer = bufferView->GetPointerAndTailSize(byteOffset, bufferViewTailSize);
+ if (dataSize > bufferViewTailSize) {
+ throw DeadlyImportError("Invalid buffer when reading ", id.c_str(), name.empty() ? "" : " (" + name + ")");
+ }
+ sparse->PopulateData(dataSize, bufferViewPointer);
+ }
+ else {
+ sparse->PopulateData(dataSize, nullptr);
+ }
+ sparse->PatchData(elementSize);
}
}
@@ -1392,7 +1428,7 @@ inline void PbrSpecularGlossiness::SetDefaults() {
inline void MaterialSpecular::SetDefaults() {
//KHR_materials_specular properties
SetVector(specularColorFactor, defaultSpecularColorFactor);
- specularFactor = 0.f;
+ specularFactor = 1.f;
}
inline void MaterialSheen::SetDefaults() {
@@ -1552,6 +1588,22 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
}
}
}
+
+ if(this->targetNames.empty())
+ {
+ Value *curExtras = FindObject(primitive, "extras");
+ if (nullptr != curExtras) {
+ if (Value *curTargetNames = FindArray(*curExtras, "targetNames")) {
+ this->targetNames.resize(curTargetNames->Size());
+ for (unsigned int j = 0; j < curTargetNames->Size(); ++j) {
+ Value &targetNameValue = (*curTargetNames)[j];
+ if (targetNameValue.IsString()) {
+ this->targetNames[j] = targetNameValue.GetString();
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/code/AssetLib/glTF2/glTF2AssetWriter.h b/code/AssetLib/glTF2/glTF2AssetWriter.h
index 4e5177b4e..f57b6558d 100644
--- a/code/AssetLib/glTF2/glTF2AssetWriter.h
+++ b/code/AssetLib/glTF2/glTF2AssetWriter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/glTF2/glTF2AssetWriter.inl b/code/AssetLib/glTF2/glTF2AssetWriter.inl
index 30f2580a2..17e29d8e7 100644
--- a/code/AssetLib/glTF2/glTF2AssetWriter.inl
+++ b/code/AssetLib/glTF2/glTF2AssetWriter.inl
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -426,13 +426,14 @@ namespace glTF2 {
if (specular.specularFactor != 0.0f) {
WriteFloat(materialSpecular, specular.specularFactor, "specularFactor", w.mAl);
- WriteTex(materialSpecular, specular.specularTexture, "specularTexture", w.mAl);
}
if (specular.specularColorFactor[0] != defaultSpecularColorFactor[0] && specular.specularColorFactor[1] != defaultSpecularColorFactor[1] && specular.specularColorFactor[2] != defaultSpecularColorFactor[2]) {
WriteVec(materialSpecular, specular.specularColorFactor, "specularColorFactor", w.mAl);
- WriteTex(materialSpecular, specular.specularColorTexture, "specularColorTexture", w.mAl);
}
+ WriteTex(materialSpecular, specular.specularTexture, "specularTexture", w.mAl);
+ WriteTex(materialSpecular, specular.specularColorTexture, "specularColorTexture", w.mAl);
+
if (!materialSpecular.ObjectEmpty()) {
exts.AddMember("KHR_materials_specular", materialSpecular, w.mAl);
}
diff --git a/code/AssetLib/glTF2/glTF2Exporter.cpp b/code/AssetLib/glTF2/glTF2Exporter.cpp
index d6f778fbe..3df9d5dda 100644
--- a/code/AssetLib/glTF2/glTF2Exporter.cpp
+++ b/code/AssetLib/glTF2/glTF2Exporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/version.h>
#include <assimp/Exporter.hpp>
#include <assimp/IOSystem.hpp>
+#include <assimp/config.h>
// Header files, standard library.
#include <cinttypes>
@@ -90,6 +91,10 @@ glTF2Exporter::glTF2Exporter(const char *filename, IOSystem *pIOSystem, const ai
// Always on as our triangulation process is aware of this type of encoding
mAsset->extensionsUsed.FB_ngon_encoding = true;
+ configEpsilon = mProperties->GetPropertyFloat(
+ AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON,
+ (ai_real)AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT);
+
if (isBinary) {
mAsset->SetAsBinary();
}
@@ -172,22 +177,6 @@ static void IdentityMatrix4(mat4 &o) {
o[15] = 1;
}
-static bool IsBoneWeightFitted(vec4 &weight) {
- return weight[0] + weight[1] + weight[2] + weight[3] >= 1.f;
-}
-
-static int FitBoneWeight(vec4 &weight, float value) {
- int i = 0;
- for (; i < 4; ++i) {
- if (weight[i] < value) {
- weight[i] = value;
- return i;
- }
- }
-
- return -1;
-}
-
template <typename T>
void SetAccessorRange(Ref<Accessor> acc, void *data, size_t count,
unsigned int numCompsIn, unsigned int numCompsOut) {
@@ -575,7 +564,11 @@ void glTF2Exporter::GetMatTex(const aiMaterial &mat, Ref<Texture> &texture, unsi
aiString tex;
// Read texcoord (UV map index)
- mat.Get(AI_MATKEY_UVWSRC(tt, slot), texCoord);
+ // Note: must be an int to be successful.
+ int tmp = 0;
+ const auto ok = mat.Get(AI_MATKEY_UVWSRC(tt, slot), tmp);
+ if (ok == aiReturn_SUCCESS) texCoord = tmp;
+
if (mat.Get(AI_MATKEY_TEXTURE(tt, slot), tex) == AI_SUCCESS) {
std::string path = tex.C_Str();
@@ -742,8 +735,8 @@ bool glTF2Exporter::GetMatSpecular(const aiMaterial &mat, glTF2::MaterialSpecula
} else if (colorFactorIsZero) {
specular.specularColorFactor[0] = specular.specularColorFactor[1] = specular.specularColorFactor[2] = 1.0f;
}
- GetMatTex(mat, specular.specularColorTexture, aiTextureType_SPECULAR);
- GetMatTex(mat, specular.specularTexture, aiTextureType_SPECULAR);
+ GetMatTex(mat, specular.specularTexture, aiTextureType_SPECULAR, 0);
+ GetMatTex(mat, specular.specularColorTexture, aiTextureType_SPECULAR, 1);
return true;
}
@@ -924,6 +917,7 @@ void glTF2Exporter::ExportMaterials() {
if (GetMatSpecular(mat, specular)) {
mAsset->extensionsUsed.KHR_materials_specular = true;
m->materialSpecular = Nullable<MaterialSpecular>(specular);
+ GetMatColor(mat, m->pbrMetallicRoughness.baseColorFactor, AI_MATKEY_COLOR_DIFFUSE);
}
MaterialSheen sheen;
@@ -1009,23 +1003,29 @@ Ref<Node> FindSkeletonRootJoint(Ref<Skin> &skinRef) {
return parentNodeRef;
}
+struct boneIndexWeightPair {
+ unsigned int indexJoint;
+ float weight;
+ bool operator()(boneIndexWeightPair &a, boneIndexWeightPair &b) {
+ return a.weight > b.weight;
+ }
+};
+
void ExportSkin(Asset &mAsset, const aiMesh *aimesh, Ref<Mesh> &meshRef, Ref<Buffer> &bufferRef, Ref<Skin> &skinRef,
- std::vector<aiMatrix4x4> &inverseBindMatricesData) {
+ std::vector<aiMatrix4x4> &inverseBindMatricesData, bool unlimitedBonesPerVertex) {
if (aimesh->mNumBones < 1) {
return;
}
// Store the vertex joint and weight data.
const size_t NumVerts(aimesh->mNumVertices);
- vec4 *vertexJointData = new vec4[NumVerts];
- vec4 *vertexWeightData = new vec4[NumVerts];
int *jointsPerVertex = new int[NumVerts];
+ std::vector<std::vector<boneIndexWeightPair>> allVerticesPairs;
+ int maxJointsPerVertex = 0;
for (size_t i = 0; i < NumVerts; ++i) {
jointsPerVertex[i] = 0;
- for (size_t j = 0; j < 4; ++j) {
- vertexJointData[i][j] = 0;
- vertexWeightData[i][j] = 0;
- }
+ std::vector<boneIndexWeightPair> vertexPair;
+ allVerticesPairs.push_back(vertexPair);
}
for (unsigned int idx_bone = 0; idx_bone < aimesh->mNumBones; ++idx_bone) {
@@ -1055,61 +1055,88 @@ void ExportSkin(Asset &mAsset, const aiMesh *aimesh, Ref<Mesh> &meshRef, Ref<Buf
jointNamesIndex = static_cast<unsigned int>(inverseBindMatricesData.size() - 1);
}
- // aib->mWeights =====> vertexWeightData
- for (unsigned int idx_weights = 0; idx_weights < aib->mNumWeights; ++idx_weights) {
+ // aib->mWeights =====> temp pairs data
+ for (unsigned int idx_weights = 0; idx_weights < aib->mNumWeights;
+ ++idx_weights) {
unsigned int vertexId = aib->mWeights[idx_weights].mVertexId;
float vertWeight = aib->mWeights[idx_weights].mWeight;
+ allVerticesPairs[vertexId].push_back({jointNamesIndex, vertWeight});
+ jointsPerVertex[vertexId] += 1;
+ maxJointsPerVertex =
+ std::max(maxJointsPerVertex, jointsPerVertex[vertexId]);
+ }
+ } // End: for-loop mNumMeshes
- // A vertex can only have at most four joint weights, which ideally sum up to 1
- if (IsBoneWeightFitted(vertexWeightData[vertexId])) {
- continue;
- }
- if (jointsPerVertex[vertexId] > 3) {
- int boneIndexFitted = FitBoneWeight(vertexWeightData[vertexId], vertWeight);
- if (boneIndexFitted != -1) {
- vertexJointData[vertexId][boneIndexFitted] = static_cast<float>(jointNamesIndex);
- }
- } else {
- vertexJointData[vertexId][jointsPerVertex[vertexId]] = static_cast<float>(jointNamesIndex);
- vertexWeightData[vertexId][jointsPerVertex[vertexId]] = vertWeight;
+ if (!unlimitedBonesPerVertex){
+ // skinning limited only for 4 bones per vertex, default
+ maxJointsPerVertex = 4;
+ }
- jointsPerVertex[vertexId] += 1;
+ // temp pairs data =====> vertexWeightData
+ size_t numGroups = (maxJointsPerVertex - 1) / 4 + 1;
+ vec4 *vertexJointData = new vec4[NumVerts * numGroups];
+ vec4 *vertexWeightData = new vec4[NumVerts * numGroups];
+ for (size_t indexVertex = 0; indexVertex < NumVerts; ++indexVertex) {
+ // order pairs by weight for each vertex
+ std::sort(allVerticesPairs[indexVertex].begin(),
+ allVerticesPairs[indexVertex].end(),
+ boneIndexWeightPair());
+ for (size_t indexGroup = 0; indexGroup < numGroups; ++indexGroup) {
+ for (size_t indexJoint = 0; indexJoint < 4; ++indexJoint) {
+ size_t indexBone = indexGroup * 4 + indexJoint;
+ size_t indexData = indexVertex + NumVerts * indexGroup;
+ if (indexBone >= allVerticesPairs[indexVertex].size()) {
+ vertexJointData[indexData][indexJoint] = 0.f;
+ vertexWeightData[indexData][indexJoint] = 0.f;
+ } else {
+ vertexJointData[indexData][indexJoint] =
+ static_cast<float>(
+ allVerticesPairs[indexVertex][indexBone].indexJoint);
+ vertexWeightData[indexData][indexJoint] =
+ allVerticesPairs[indexVertex][indexBone].weight;
+ }
}
}
+ }
- } // End: for-loop mNumMeshes
+ for (size_t idx_group = 0; idx_group < numGroups; ++idx_group) {
+ Mesh::Primitive &p = meshRef->primitives.back();
+ Ref<Accessor> vertexJointAccessor = ExportData(
+ mAsset, skinRef->id, bufferRef, aimesh->mNumVertices,
+ vertexJointData + idx_group * NumVerts,
+ AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
+ if (vertexJointAccessor) {
+ size_t offset = vertexJointAccessor->bufferView->byteOffset;
+ size_t bytesLen = vertexJointAccessor->bufferView->byteLength;
+ unsigned int s_bytesPerComp =
+ ComponentTypeSize(ComponentType_UNSIGNED_SHORT);
+ unsigned int bytesPerComp =
+ ComponentTypeSize(vertexJointAccessor->componentType);
+ size_t s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp;
+ Ref<Buffer> buf = vertexJointAccessor->bufferView->buffer;
+ uint8_t *arrys = new uint8_t[bytesLen];
+ unsigned int i = 0;
+ for (unsigned int j = 0; j < bytesLen; j += bytesPerComp) {
+ size_t len_p = offset + j;
+ float f_value = *(float *)&buf->GetPointer()[len_p];
+ unsigned short c = static_cast<unsigned short>(f_value);
+ memcpy(&arrys[i * s_bytesPerComp], &c, s_bytesPerComp);
+ ++i;
+ }
+ buf->ReplaceData_joint(offset, bytesLen, arrys, bytesLen);
+ vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT;
+ vertexJointAccessor->bufferView->byteLength = s_bytesLen;
- Mesh::Primitive &p = meshRef->primitives.back();
- Ref<Accessor> vertexJointAccessor = ExportData(mAsset, skinRef->id, bufferRef, aimesh->mNumVertices,
- vertexJointData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
- if (vertexJointAccessor) {
- size_t offset = vertexJointAccessor->bufferView->byteOffset;
- size_t bytesLen = vertexJointAccessor->bufferView->byteLength;
- unsigned int s_bytesPerComp = ComponentTypeSize(ComponentType_UNSIGNED_SHORT);
- unsigned int bytesPerComp = ComponentTypeSize(vertexJointAccessor->componentType);
- size_t s_bytesLen = bytesLen * s_bytesPerComp / bytesPerComp;
- Ref<Buffer> buf = vertexJointAccessor->bufferView->buffer;
- uint8_t *arrys = new uint8_t[bytesLen];
- unsigned int i = 0;
- for (unsigned int j = 0; j < bytesLen; j += bytesPerComp) {
- size_t len_p = offset + j;
- float f_value = *(float *)&buf->GetPointer()[len_p];
- unsigned short c = static_cast<unsigned short>(f_value);
- memcpy(&arrys[i * s_bytesPerComp], &c, s_bytesPerComp);
- ++i;
+ p.attributes.joint.push_back(vertexJointAccessor);
+ delete[] arrys;
+ }
+ Ref<Accessor> vertexWeightAccessor = ExportData(
+ mAsset, skinRef->id, bufferRef, aimesh->mNumVertices,
+ vertexWeightData + idx_group * NumVerts,
+ AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
+ if (vertexWeightAccessor) {
+ p.attributes.weight.push_back(vertexWeightAccessor);
}
- buf->ReplaceData_joint(offset, bytesLen, arrys, bytesLen);
- vertexJointAccessor->componentType = ComponentType_UNSIGNED_SHORT;
- vertexJointAccessor->bufferView->byteLength = s_bytesLen;
-
- p.attributes.joint.push_back(vertexJointAccessor);
- delete[] arrys;
- }
-
- Ref<Accessor> vertexWeightAccessor = ExportData(mAsset, skinRef->id, bufferRef, aimesh->mNumVertices,
- vertexWeightData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
- if (vertexWeightAccessor) {
- p.attributes.weight.push_back(vertexWeightAccessor);
}
delete[] jointsPerVertex;
delete[] vertexWeightData;
@@ -1247,9 +1274,19 @@ void glTF2Exporter::ExportMeshes() {
break;
}
+// /*************** Skins ****************/
+// if (aim->HasBones()) {
+// ExportSkin(*mAsset, aim, m, b, skinRef, inverseBindMatricesData);
+// }
/*************** Skins ****************/
if (aim->HasBones()) {
- ExportSkin(*mAsset, aim, m, b, skinRef, inverseBindMatricesData);
+ bool unlimitedBonesPerVertex =
+ this->mProperties->HasPropertyBool(
+ AI_CONFIG_EXPORT_GLTF_UNLIMITED_SKINNING_BONES_PER_VERTEX) &&
+ this->mProperties->GetPropertyBool(
+ AI_CONFIG_EXPORT_GLTF_UNLIMITED_SKINNING_BONES_PER_VERTEX);
+ ExportSkin(*mAsset, aim, m, b, skinRef, inverseBindMatricesData,
+ unlimitedBonesPerVertex);
}
/*************** Targets for blendshapes ****************/
@@ -1423,7 +1460,7 @@ unsigned int glTF2Exporter::ExportNodeHierarchy(const aiNode *n) {
node->name = n->mName.C_Str();
- if (!n->mTransformation.IsIdentity()) {
+ if (!n->mTransformation.IsIdentity(configEpsilon)) {
node->matrix.isPresent = true;
CopyValue(n->mTransformation, node->matrix.value);
}
@@ -1453,7 +1490,7 @@ unsigned int glTF2Exporter::ExportNode(const aiNode *n, Ref<Node> &parent) {
ExportNodeExtras(n->mMetaData, node->extras);
- if (!n->mTransformation.IsIdentity()) {
+ if (!n->mTransformation.IsIdentity(configEpsilon)) {
if (mScene->mNumAnimations > 0 || (mProperties && mProperties->HasPropertyBool("GLTF2_NODE_IN_TRS"))) {
aiQuaternion quaternion;
n->mTransformation.Decompose(*reinterpret_cast<aiVector3D *>(&node->scale.value), quaternion, *reinterpret_cast<aiVector3D *>(&node->translation.value));
diff --git a/code/AssetLib/glTF2/glTF2Exporter.h b/code/AssetLib/glTF2/glTF2Exporter.h
index 7bf57b567..27e187854 100644
--- a/code/AssetLib/glTF2/glTF2Exporter.h
+++ b/code/AssetLib/glTF2/glTF2Exporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/material.h>
#include <assimp/types.h>
+#include <assimp/defs.h>
#include <map>
#include <memory>
@@ -142,6 +143,7 @@ private:
std::map<std::string, unsigned int> mTexturesByPath;
std::shared_ptr<glTF2::Asset> mAsset;
std::vector<unsigned char> mBodyData;
+ ai_real configEpsilon;
};
} // namespace Assimp
diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp
index 0fed11cef..5f895ff74 100644
--- a/code/AssetLib/glTF2/glTF2Importer.cpp
+++ b/code/AssetLib/glTF2/glTF2Importer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -82,7 +82,7 @@ struct Tangent {
// glTF2Importer
//
-static const aiImporterDesc desc = {
+static constexpr aiImporterDesc desc = {
"glTF2 Importer",
"",
"",
@@ -288,8 +288,8 @@ static aiMaterial *ImportMaterial(std::vector<int> &embeddedTexIdxs, Asset &r, M
if (std::memcmp(specular.specularColorFactor, defaultSpecularColorFactor, sizeof(glTFCommon::vec3)) != 0 || specular.specularFactor != 0.0f) {
SetMaterialColorProperty(r, specular.specularColorFactor, aimat, AI_MATKEY_COLOR_SPECULAR);
aimat->AddProperty(&specular.specularFactor, 1, AI_MATKEY_SPECULAR_FACTOR);
- SetMaterialTextureProperty(embeddedTexIdxs, r, specular.specularTexture, aimat, aiTextureType_SPECULAR);
- SetMaterialTextureProperty(embeddedTexIdxs, r, specular.specularColorTexture, aimat, aiTextureType_SPECULAR);
+ SetMaterialTextureProperty(embeddedTexIdxs, r, specular.specularTexture, aimat, aiTextureType_SPECULAR, 0);
+ SetMaterialTextureProperty(embeddedTexIdxs, r, specular.specularColorTexture, aimat, aiTextureType_SPECULAR, 1);
}
}
// pbrSpecularGlossiness
diff --git a/code/AssetLib/glTF2/glTF2Importer.h b/code/AssetLib/glTF2/glTF2Importer.h
index 2be42126c..68af0cb9c 100644
--- a/code/AssetLib/glTF2/glTF2Importer.h
+++ b/code/AssetLib/glTF2/glTF2Importer.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/CApi/AssimpCExport.cpp b/code/CApi/AssimpCExport.cpp
index 21e40205c..99ad41ab7 100644
--- a/code/CApi/AssimpCExport.cpp
+++ b/code/CApi/AssimpCExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/CApi/CInterfaceIOWrapper.cpp b/code/CApi/CInterfaceIOWrapper.cpp
index f0e46cd08..84648482b 100644
--- a/code/CApi/CInterfaceIOWrapper.cpp
+++ b/code/CApi/CInterfaceIOWrapper.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/CApi/CInterfaceIOWrapper.h b/code/CApi/CInterfaceIOWrapper.h
index 28d4c3e75..34c4a7311 100644
--- a/code/CApi/CInterfaceIOWrapper.h
+++ b/code/CApi/CInterfaceIOWrapper.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt
index 0fe2291f8..0a7be6247 100644
--- a/code/CMakeLists.txt
+++ b/code/CMakeLists.txt
@@ -1,6 +1,6 @@
# Open Asset Import Library (assimp)
# ----------------------------------------------------------------------
-# Copyright (c) 2006-2022, assimp team
+# Copyright (c) 2006-2024, assimp team
#
# All rights reserved.
#
@@ -42,7 +42,7 @@
# 3) Add libassimp using the file lists (eliminates duplication of file names between
# source groups and library command)
#
-cmake_minimum_required( VERSION 3.10 )
+cmake_minimum_required( VERSION 3.22 )
SET( HEADER_PATH ../include/assimp )
if(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)
@@ -923,7 +923,7 @@ IF(ASSIMP_HUNTER_ENABLED)
hunter_add_package(utf8)
find_package(utf8cpp CONFIG REQUIRED)
ELSE()
- # utf8 is header-only, so Assimp doesn't need to do anything.
+ INCLUDE_DIRECTORIES("../contrib/utf8cpp/source")
ENDIF()
# polyclipping
@@ -1193,6 +1193,10 @@ ENDIF ()
TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp)
+add_compile_options(
+ "$<$<CONFIG:DEBUG>:-O0;-g3;-ggdb>"
+)
+
IF (ASSIMP_WARNINGS_AS_ERRORS)
MESSAGE(STATUS "Treating all warnings as errors (for assimp library only)")
IF (MSVC)
@@ -1380,7 +1384,12 @@ ENDIF()
IF(NOT ASSIMP_HUNTER_ENABLED)
if (UNZIP_FOUND)
INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS})
- TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES})
+ # TODO if cmake required version has been updated to >3.12.0, collapse this to the second case only
+ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
+ TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES})
+ else()
+ TARGET_LINK_LIBRARIES(assimp ${UNZIP_LINK_LIBRARIES})
+ endif()
else ()
INCLUDE_DIRECTORIES("../")
endif ()
diff --git a/code/Common/AssertHandler.cpp b/code/Common/AssertHandler.cpp
index 2fd4046ad..ee2d2b95c 100644
--- a/code/Common/AssertHandler.cpp
+++ b/code/Common/AssertHandler.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/Assimp.cpp b/code/Common/Assimp.cpp
index e3b39c349..cf57bac4b 100644
--- a/code/Common/Assimp.cpp
+++ b/code/Common/Assimp.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/Base64.cpp b/code/Common/Base64.cpp
index 65308f4fd..76f9b120e 100644
--- a/code/Common/Base64.cpp
+++ b/code/Common/Base64.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp
index a169c8a10..3a4c7c329 100644
--- a/code/Common/BaseImporter.cpp
+++ b/code/Common/BaseImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -93,10 +93,6 @@ BaseImporter::BaseImporter() AI_NO_EXCEPT
// empty
}
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-BaseImporter::~BaseImporter() = default;
-
void BaseImporter::UpdateImporterScale(Importer *pImp) {
ai_assert(pImp != nullptr);
ai_assert(importerScale != 0.0);
@@ -357,11 +353,7 @@ std::string BaseImporter::GetExtension(const std::string &pFile) {
return false;
}
-#ifdef ASSIMP_USE_HUNTER
-#include <utf8.h>
-#else
-#include "../contrib/utf8cpp/source/utf8.h"
-#endif
+#include "utf8.h"
// ------------------------------------------------------------------------------------------------
// Convert to UTF8 data
diff --git a/code/Common/BaseProcess.cpp b/code/Common/BaseProcess.cpp
index 8ff7c98e9..560ee7b94 100644
--- a/code/Common/BaseProcess.cpp
+++ b/code/Common/BaseProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -58,10 +58,6 @@ BaseProcess::BaseProcess() AI_NO_EXCEPT
}
// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-BaseProcess::~BaseProcess() = default;
-
-// ------------------------------------------------------------------------------------------------
void BaseProcess::ExecuteOnScene(Importer *pImp) {
ai_assert( nullptr != pImp );
if (pImp == nullptr) {
diff --git a/code/Common/BaseProcess.h b/code/Common/BaseProcess.h
index d2af4faa6..a945ad542 100644
--- a/code/Common/BaseProcess.h
+++ b/code/Common/BaseProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -179,11 +179,11 @@ class ASSIMP_API BaseProcess {
friend class Importer;
public:
- /** @brief onstructor to be privately used by Importer */
+ /** @brief Constructor to be privately used by Importer */
BaseProcess() AI_NO_EXCEPT;
- /** @brief Destructor, private as well */
- virtual ~BaseProcess();
+ /** @brief Destructor */
+ virtual ~BaseProcess() = default;
// -------------------------------------------------------------------
/**
diff --git a/code/Common/Bitmap.cpp b/code/Common/Bitmap.cpp
index 65dfd1754..246ad9e65 100644
--- a/code/Common/Bitmap.cpp
+++ b/code/Common/Bitmap.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/Compression.cpp b/code/Common/Compression.cpp
index 3bf306dee..091171771 100644
--- a/code/Common/Compression.cpp
+++ b/code/Common/Compression.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -66,6 +66,10 @@ Compression::Compression() :
Compression::~Compression() {
ai_assert(mImpl != nullptr);
+ if (mImpl->mOpen) {
+ close();
+ }
+
delete mImpl;
}
@@ -124,7 +128,7 @@ static int getFlushMode(Compression::FlushMode flush) {
return z_flush;
}
-constexpr size_t MYBLOCK = 32786;
+static constexpr size_t MYBLOCK = 32786;
size_t Compression::decompress(const void *data, size_t in, std::vector<char> &uncompressed) {
ai_assert(mImpl != nullptr);
diff --git a/code/Common/Compression.h b/code/Common/Compression.h
index 13a79af3f..0bec91bba 100644
--- a/code/Common/Compression.h
+++ b/code/Common/Compression.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -41,11 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
-#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
-# include <zlib.h>
-#else
-# include "../contrib/zlib/zlib.h"
-#endif
+#include "zlib.h"
#include <vector>
#include <cstddef> // size_t
diff --git a/code/Common/CreateAnimMesh.cpp b/code/Common/CreateAnimMesh.cpp
index 58f3d909d..467651587 100644
--- a/code/Common/CreateAnimMesh.cpp
+++ b/code/Common/CreateAnimMesh.cpp
@@ -4,7 +4,7 @@ Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (C) 2016 The Qt Company Ltd.
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp
index f2c772187..e423eae4f 100644
--- a/code/Common/DefaultIOStream.cpp
+++ b/code/Common/DefaultIOStream.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/DefaultIOSystem.cpp b/code/Common/DefaultIOSystem.cpp
index b28910c70..e74add55f 100644
--- a/code/Common/DefaultIOSystem.cpp
+++ b/code/Common/DefaultIOSystem.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -99,12 +99,12 @@ bool DefaultIOSystem::Exists(const char *pFile) const {
return false;
}
#else
- FILE *file = ::fopen(pFile, "rb");
- if (!file) {
+ struct stat statbuf;
+ stat(pFile, &statbuf);
+ // test for a regular file
+ if (!S_ISREG(statbuf.st_mode)) {
return false;
}
-
- ::fclose(file);
#endif
return true;
@@ -116,6 +116,7 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) {
ai_assert(strFile != nullptr);
ai_assert(strMode != nullptr);
FILE *file;
+
#ifdef _WIN32
std::wstring name = Utf8ToWide(strFile);
if (name.empty()) {
@@ -126,6 +127,7 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) {
#else
file = ::fopen(strFile, strMode);
#endif
+
if (!file) {
return nullptr;
}
diff --git a/code/Common/DefaultLogger.cpp b/code/Common/DefaultLogger.cpp
index 5cb32d38f..828e326e2 100644
--- a/code/Common/DefaultLogger.cpp
+++ b/code/Common/DefaultLogger.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/Common/DefaultProgressHandler.h b/code/Common/DefaultProgressHandler.h
index ac1bb68db..2ace9e02a 100644
--- a/code/Common/DefaultProgressHandler.h
+++ b/code/Common/DefaultProgressHandler.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/Exceptional.cpp b/code/Common/Exceptional.cpp
index b25281a97..0629f716e 100644
--- a/code/Common/Exceptional.cpp
+++ b/code/Common/Exceptional.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/Exporter.cpp b/code/Common/Exporter.cpp
index 0795da65c..4da055064 100644
--- a/code/Common/Exporter.cpp
+++ b/code/Common/Exporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/FileLogStream.h b/code/Common/FileLogStream.h
index 334541485..f64f88f48 100644
--- a/code/Common/FileLogStream.h
+++ b/code/Common/FileLogStream.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/IOSystem.cpp b/code/Common/IOSystem.cpp
index 1e63827ba..aa91e9b49 100644
--- a/code/Common/IOSystem.cpp
+++ b/code/Common/IOSystem.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/Importer.cpp b/code/Common/Importer.cpp
index bdf64ac8f..284ad89cc 100644
--- a/code/Common/Importer.cpp
+++ b/code/Common/Importer.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/Importer.h b/code/Common/Importer.h
index ab7e3a6b3..2da55f173 100644
--- a/code/Common/Importer.h
+++ b/code/Common/Importer.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -74,11 +74,11 @@ public:
typedef unsigned int KeyType;
// typedefs for our configuration maps.
- typedef std::map<KeyType, int> IntPropertyMap;
- typedef std::map<KeyType, ai_real> FloatPropertyMap;
- typedef std::map<KeyType, std::string> StringPropertyMap;
- typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
- typedef std::map<KeyType, void*> PointerPropertyMap;
+ using IntPropertyMap = std::map<KeyType, int>;
+ using FloatPropertyMap = std::map<KeyType, ai_real>;
+ using StringPropertyMap = std::map<KeyType, std::string>;
+ using MatrixPropertyMap = std::map<KeyType, aiMatrix4x4>;
+ using PointerPropertyMap = std::map<KeyType, void*>;
/** IO handler to use for all file accesses. */
IOSystem* mIOHandler;
@@ -128,10 +128,12 @@ public:
/// The default class constructor.
ImporterPimpl() AI_NO_EXCEPT;
+
+ /// The class destructor.
+ ~ImporterPimpl() = default;
};
-inline
-ImporterPimpl::ImporterPimpl() AI_NO_EXCEPT :
+inline ImporterPimpl::ImporterPimpl() AI_NO_EXCEPT :
mIOHandler( nullptr ),
mIsDefaultHandler( false ),
mProgressHandler( nullptr ),
diff --git a/code/Common/ImporterRegistry.cpp b/code/Common/ImporterRegistry.cpp
index c67fee936..92a04e692 100644
--- a/code/Common/ImporterRegistry.cpp
+++ b/code/Common/ImporterRegistry.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/Maybe.h b/code/Common/Maybe.h
index 387c1bcaf..99b18b67c 100644
--- a/code/Common/Maybe.h
+++ b/code/Common/Maybe.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/PolyTools.h b/code/Common/PolyTools.h
index b53de8579..46ceb9d75 100644
--- a/code/Common/PolyTools.h
+++ b/code/Common/PolyTools.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/PostStepRegistry.cpp b/code/Common/PostStepRegistry.cpp
index de4f39083..fdf33fc40 100644
--- a/code/Common/PostStepRegistry.cpp
+++ b/code/Common/PostStepRegistry.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/Common/RemoveComments.cpp b/code/Common/RemoveComments.cpp
index 52dd37ff0..a6a472400 100644
--- a/code/Common/RemoveComments.cpp
+++ b/code/Common/RemoveComments.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/SGSpatialSort.cpp b/code/Common/SGSpatialSort.cpp
index 0ef1853c0..d24ecf1b4 100644
--- a/code/Common/SGSpatialSort.cpp
+++ b/code/Common/SGSpatialSort.cpp
@@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -50,16 +48,13 @@ the 3ds loader handling smooth groups correctly */
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
-SGSpatialSort::SGSpatialSort()
-{
+SGSpatialSort::SGSpatialSort() {
// define the reference plane. We choose some arbitrary vector away from all basic axes
// in the hope that no model spreads all its vertices along this plane.
mPlaneNormal.Set( 0.8523f, 0.34321f, 0.5736f);
mPlaneNormal.Normalize();
}
-// ------------------------------------------------------------------------------------------------
-// Destructor
-SGSpatialSort::~SGSpatialSort() = default;
+
// ------------------------------------------------------------------------------------------------
void SGSpatialSort::Add(const aiVector3D& vPosition, unsigned int index,
unsigned int smoothingGroup)
diff --git a/code/Common/SceneCombiner.cpp b/code/Common/SceneCombiner.cpp
index 0188f5dea..44897a40b 100644
--- a/code/Common/SceneCombiner.cpp
+++ b/code/Common/SceneCombiner.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/ScenePreprocessor.cpp b/code/Common/ScenePreprocessor.cpp
index 18a257ad4..b4bbe9d67 100644
--- a/code/Common/ScenePreprocessor.cpp
+++ b/code/Common/ScenePreprocessor.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/ScenePreprocessor.h b/code/Common/ScenePreprocessor.h
index 49e06ed1c..6ffd7f8bd 100644
--- a/code/Common/ScenePreprocessor.h
+++ b/code/Common/ScenePreprocessor.h
@@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -56,7 +55,7 @@ class ScenePreprocessorTest;
namespace Assimp {
// ----------------------------------------------------------------------------------
-/** ScenePreprocessor: Preprocess a scene before any post-processing
+/** ScenePreprocessor: Pre-process a scene before any post-processing
* steps are executed.
*
* The step computes data that needn't necessarily be provided by the
@@ -79,6 +78,9 @@ public:
ScenePreprocessor(aiScene *_scene) :
scene(_scene) {}
+ /// @brief The class destructor.
+ ~ScenePreprocessor() = default;
+
// ----------------------------------------------------------------
/** Assign a (new) scene to the object.
*
diff --git a/code/Common/ScenePrivate.h b/code/Common/ScenePrivate.h
index 3910db78c..b8c524aa2 100644
--- a/code/Common/ScenePrivate.h
+++ b/code/Common/ScenePrivate.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/SkeletonMeshBuilder.cpp b/code/Common/SkeletonMeshBuilder.cpp
index f3c8fb412..167652700 100644
--- a/code/Common/SkeletonMeshBuilder.cpp
+++ b/code/Common/SkeletonMeshBuilder.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/SpatialSort.cpp b/code/Common/SpatialSort.cpp
index c8c5c30ed..34cb3fb05 100644
--- a/code/Common/SpatialSort.cpp
+++ b/code/Common/SpatialSort.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/StackAllocator.h b/code/Common/StackAllocator.h
index 191010cac..a5d97c22d 100644
--- a/code/Common/StackAllocator.h
+++ b/code/Common/StackAllocator.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -61,9 +61,10 @@ namespace Assimp {
class StackAllocator {
public:
/// @brief Constructs the allocator
- inline StackAllocator();
+ StackAllocator();
+
/// @brief Destructs the allocator and frees all memory
- inline ~StackAllocator();
+ ~StackAllocator();
// non copyable
StackAllocator(const StackAllocator &) = delete;
diff --git a/code/Common/StackAllocator.inl b/code/Common/StackAllocator.inl
index e5a76c9c0..699349198 100644
--- a/code/Common/StackAllocator.inl
+++ b/code/Common/StackAllocator.inl
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -41,13 +41,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "StackAllocator.h"
#include <assimp/ai_assert.h>
+#include <algorithm>
#include <algorithm>
using namespace Assimp;
-inline StackAllocator::StackAllocator() {
-}
+inline StackAllocator::StackAllocator() : m_storageBlocks() {}
inline StackAllocator::~StackAllocator() {
FreeAll();
@@ -58,7 +58,7 @@ inline void *StackAllocator::Allocate(size_t byteSize) {
{
// double block size every time, up to maximum of g_maxBytesPerBlock.
// Block size must be at least as large as byteSize, but we want to use this for small allocations anyway.
- m_blockAllocationSize = std::max(std::min(m_blockAllocationSize * 2, g_maxBytesPerBlock), byteSize);
+ m_blockAllocationSize = std::max<std::size_t>(std::min<std::size_t>(m_blockAllocationSize * 2, g_maxBytesPerBlock), byteSize);
uint8_t *data = new uint8_t[m_blockAllocationSize];
m_storageBlocks.emplace_back(data);
m_subIndex = byteSize;
diff --git a/code/Common/StandardShapes.cpp b/code/Common/StandardShapes.cpp
index abf3c4839..4a967997e 100644
--- a/code/Common/StandardShapes.cpp
+++ b/code/Common/StandardShapes.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/StbCommon.h b/code/Common/StbCommon.h
index 5de2e176d..aef23ce17 100644
--- a/code/Common/StbCommon.h
+++ b/code/Common/StbCommon.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -64,10 +64,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The list can be regenerated using the following:
- cat <path/to/stb/stb_image.h> | fgrep STBIDEF | fgrep '(' | sed -E 's/\*|\(.+//g' | \
- awk '{print "#define " $(NF) " assimp_" $(NF) }' | sort | uniq"
+ cat "path/to/stb/stb_image.h" | fgrep STBIDEF | fgrep '(' | sed -E 's/\*|\(.+//g' | \
+ awk '{print "#define " $(NF) " assimp_" $(NF) }' | sort | uniq
*/
#define stbi_convert_iphone_png_to_rgb assimp_stbi_convert_iphone_png_to_rgb
+#define stbi_convert_iphone_png_to_rgb_thread assimp_stbi_convert_iphone_png_to_rgb_thread
#define stbi_convert_wchar_to_utf8 assimp_stbi_convert_wchar_to_utf8
#define stbi_failure_reason assimp_stbi_failure_reason
#define stbi_hdr_to_ldr_gamma assimp_stbi_hdr_to_ldr_gamma
@@ -87,22 +88,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define stbi_is_hdr_from_memory assimp_stbi_is_hdr_from_memory
#define stbi_ldr_to_hdr_gamma assimp_stbi_ldr_to_hdr_gamma
#define stbi_ldr_to_hdr_scale assimp_stbi_ldr_to_hdr_scale
+#define stbi_load assimp_stbi_load
#define stbi_load_16 assimp_stbi_load_16
#define stbi_load_16_from_callbacks assimp_stbi_load_16_from_callbacks
#define stbi_load_16_from_memory assimp_stbi_load_16_from_memory
-#define stbi_load assimp_stbi_load
-#define stbi_loadf assimp_stbi_loadf
-#define stbi_loadf_from_callbacks assimp_stbi_loadf_from_callbacks
-#define stbi_loadf_from_file assimp_stbi_loadf_from_file
-#define stbi_loadf_from_memory assimp_stbi_loadf_from_memory
#define stbi_load_from_callbacks assimp_stbi_load_from_callbacks
-#define stbi_load_from_file_16 assimp_stbi_load_from_file_16
#define stbi_load_from_file assimp_stbi_load_from_file
+#define stbi_load_from_file_16 assimp_stbi_load_from_file_16
#define stbi_load_from_memory assimp_stbi_load_from_memory
#define stbi_load_gif_from_memory assimp_stbi_load_gif_from_memory
+#define stbi_loadf assimp_stbi_loadf
+#define stbi_loadf_from_callbacks assimp_stbi_loadf_from_callbacks
+#define stbi_loadf_from_file assimp_stbi_loadf_from_file
+#define stbi_loadf_from_memory assimp_stbi_loadf_from_memory
#define stbi_set_flip_vertically_on_load assimp_stbi_set_flip_vertically_on_load
#define stbi_set_flip_vertically_on_load_thread assimp_stbi_set_flip_vertically_on_load_thread
#define stbi_set_unpremultiply_on_load assimp_stbi_set_unpremultiply_on_load
+#define stbi_set_unpremultiply_on_load_thread assimp_stbi_set_unpremultiply_on_load_thread
#define stbi_zlib_decode_buffer assimp_stbi_zlib_decode_buffer
#define stbi_zlib_decode_malloc assimp_stbi_zlib_decode_malloc
#define stbi_zlib_decode_malloc_guesssize assimp_stbi_zlib_decode_malloc_guesssize
diff --git a/code/Common/StdOStreamLogStream.h b/code/Common/StdOStreamLogStream.h
index cc0e06263..683c87d5f 100644
--- a/code/Common/StdOStreamLogStream.h
+++ b/code/Common/StdOStreamLogStream.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/Common/Subdivision.cpp b/code/Common/Subdivision.cpp
index 3aea5d4c5..fc8ab2099 100644
--- a/code/Common/Subdivision.cpp
+++ b/code/Common/Subdivision.cpp
@@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/TargetAnimation.cpp b/code/Common/TargetAnimation.cpp
index 5f6d9bad0..9ef4e5d6c 100644
--- a/code/Common/TargetAnimation.cpp
+++ b/code/Common/TargetAnimation.cpp
@@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/TargetAnimation.h b/code/Common/TargetAnimation.h
index 863406b94..116b55d2a 100644
--- a/code/Common/TargetAnimation.h
+++ b/code/Common/TargetAnimation.h
@@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -119,12 +118,16 @@ private:
* look-at target */
class TargetAnimationHelper {
public:
+ /// @brief The class constructor.
TargetAnimationHelper() :
targetPositions(nullptr),
objectPositions(nullptr) {
// empty
}
+ /// @brief The class destructor.
+ ~TargetAnimationHelper() = default;
+
// ------------------------------------------------------------------
/** Sets the target animation channel
*
diff --git a/code/Common/Version.cpp b/code/Common/Version.cpp
index 02634d753..2d744d98d 100644
--- a/code/Common/Version.cpp
+++ b/code/Common/Version.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
static constexpr char LEGAL_INFORMATION[] =
"Open Asset Import Library (Assimp).\n"
"A free C/C++ library to import various 3D file formats into applications\n\n"
- "(c) 2006-2023, Assimp team\n"
+ "(c) 2006-2024, Assimp team\n"
"License under the terms and conditions of the 3-clause BSD license\n"
"https://www.assimp.org\n";
diff --git a/code/Common/VertexTriangleAdjacency.cpp b/code/Common/VertexTriangleAdjacency.cpp
index 555e3e386..616e7e797 100644
--- a/code/Common/VertexTriangleAdjacency.cpp
+++ b/code/Common/VertexTriangleAdjacency.cpp
@@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/VertexTriangleAdjacency.h b/code/Common/VertexTriangleAdjacency.h
index 41d809450..20d3bd32c 100644
--- a/code/Common/VertexTriangleAdjacency.h
+++ b/code/Common/VertexTriangleAdjacency.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/Win32DebugLogStream.h b/code/Common/Win32DebugLogStream.h
index 34d849e83..f8bc017af 100644
--- a/code/Common/Win32DebugLogStream.h
+++ b/code/Common/Win32DebugLogStream.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/Common/ZipArchiveIOSystem.cpp b/code/Common/ZipArchiveIOSystem.cpp
index 51a250810..23d7db15d 100644
--- a/code/Common/ZipArchiveIOSystem.cpp
+++ b/code/Common/ZipArchiveIOSystem.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -62,13 +62,13 @@ namespace Assimp {
// ----------------------------------------------------------------
// A read-only file inside a ZIP
-class ZipFile : public IOStream {
+class ZipFile final : public IOStream {
friend class ZipFileInfo;
explicit ZipFile(std::string &filename, size_t size);
public:
std::string m_Filename;
- virtual ~ZipFile() override;
+ ~ZipFile() override = default;
// IOStream interface
size_t Read(void *pvBuffer, size_t pSize, size_t pCount) override;
@@ -89,6 +89,8 @@ private:
// Wraps an existing Assimp::IOSystem for unzip
class IOSystem2Unzip {
public:
+ IOSystem2Unzip() = default;
+ ~IOSystem2Unzip() = default;
static voidpf open(voidpf opaque, const char *filename, int mode);
static voidpf opendisk(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
static uLong read(voidpf opaque, voidpf stream, void *buf, uLong size);
@@ -100,6 +102,7 @@ public:
static zlib_filefunc_def get(IOSystem *pIOHandler);
};
+// ----------------------------------------------------------------
voidpf IOSystem2Unzip::open(voidpf opaque, const char *filename, int mode) {
IOSystem *io_system = reinterpret_cast<IOSystem *>(opaque);
@@ -119,6 +122,7 @@ voidpf IOSystem2Unzip::open(voidpf opaque, const char *filename, int mode) {
return (voidpf)io_system->Open(filename, mode_fopen);
}
+// ----------------------------------------------------------------
voidpf IOSystem2Unzip::opendisk(voidpf opaque, voidpf stream, uint32_t number_disk, int mode) {
ZipFile *io_stream = (ZipFile *)stream;
voidpf ret = nullptr;
@@ -141,24 +145,28 @@ voidpf IOSystem2Unzip::opendisk(voidpf opaque, voidpf stream, uint32_t number_di
return ret;
}
+// ----------------------------------------------------------------
uLong IOSystem2Unzip::read(voidpf /*opaque*/, voidpf stream, void *buf, uLong size) {
IOStream *io_stream = (IOStream *)stream;
return static_cast<uLong>(io_stream->Read(buf, 1, size));
}
+// ----------------------------------------------------------------
uLong IOSystem2Unzip::write(voidpf /*opaque*/, voidpf stream, const void *buf, uLong size) {
IOStream *io_stream = (IOStream *)stream;
return static_cast<uLong>(io_stream->Write(buf, 1, size));
}
+// ----------------------------------------------------------------
long IOSystem2Unzip::tell(voidpf /*opaque*/, voidpf stream) {
IOStream *io_stream = (IOStream *)stream;
return static_cast<long>(io_stream->Tell());
}
+// ----------------------------------------------------------------
long IOSystem2Unzip::seek(voidpf /*opaque*/, voidpf stream, uLong offset, int origin) {
IOStream *io_stream = (IOStream *)stream;
@@ -179,6 +187,7 @@ long IOSystem2Unzip::seek(voidpf /*opaque*/, voidpf stream, uLong offset, int or
return (io_stream->Seek(offset, assimp_origin) == aiReturn_SUCCESS ? 0 : -1);
}
+// ----------------------------------------------------------------
int IOSystem2Unzip::close(voidpf opaque, voidpf stream) {
IOSystem *io_system = (IOSystem *)opaque;
IOStream *io_stream = (IOStream *)stream;
@@ -188,10 +197,12 @@ int IOSystem2Unzip::close(voidpf opaque, voidpf stream) {
return 0;
}
+// ----------------------------------------------------------------
int IOSystem2Unzip::testerror(voidpf /*opaque*/, voidpf /*stream*/) {
return 0;
}
+// ----------------------------------------------------------------
zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) {
zlib_filefunc_def mapping;
@@ -213,9 +224,10 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) {
// ----------------------------------------------------------------
// Info about a read-only file inside a ZIP
-class ZipFileInfo {
+class ZipFileInfo final {
public:
explicit ZipFileInfo(unzFile zip_handle, size_t size);
+ ~ZipFileInfo() = default;
// Allocate and Extract data from the ZIP
ZipFile *Extract(std::string &filename, unzFile zip_handle) const;
@@ -225,6 +237,7 @@ private:
unz_file_pos_s m_ZipFilePos;
};
+// ----------------------------------------------------------------
ZipFileInfo::ZipFileInfo(unzFile zip_handle, size_t size) :
m_Size(size) {
ai_assert(m_Size != 0);
@@ -234,6 +247,7 @@ ZipFileInfo::ZipFileInfo(unzFile zip_handle, size_t size) :
unzGetFilePos(zip_handle, &(m_ZipFilePos));
}
+// ----------------------------------------------------------------
ZipFile *ZipFileInfo::Extract(std::string &filename, unzFile zip_handle) const {
// Find in the ZIP. This cannot fail
unz_file_pos_s *filepos = const_cast<unz_file_pos_s *>(&(m_ZipFilePos));
@@ -273,14 +287,14 @@ ZipFile *ZipFileInfo::Extract(std::string &filename, unzFile zip_handle) const {
return zip_file;
}
+// ----------------------------------------------------------------
ZipFile::ZipFile(std::string &filename, size_t size) :
m_Filename(filename), m_Size(size) {
ai_assert(m_Size != 0);
m_Buffer = std::unique_ptr<uint8_t[]>(new uint8_t[m_Size]);
}
-ZipFile::~ZipFile() = default;
-
+// ----------------------------------------------------------------
size_t ZipFile::Read(void *pvBuffer, size_t pSize, size_t pCount) {
// Should be impossible
ai_assert(m_Buffer != nullptr);
@@ -305,10 +319,12 @@ size_t ZipFile::Read(void *pvBuffer, size_t pSize, size_t pCount) {
return pCount;
}
+// ----------------------------------------------------------------
size_t ZipFile::FileSize() const {
return m_Size;
}
+// ----------------------------------------------------------------
aiReturn ZipFile::Seek(size_t pOffset, aiOrigin pOrigin) {
switch (pOrigin) {
case aiOrigin_SET: {
@@ -334,6 +350,7 @@ aiReturn ZipFile::Seek(size_t pOffset, aiOrigin pOrigin) {
return aiReturn_FAILURE;
}
+// ----------------------------------------------------------------
size_t ZipFile::Tell() const {
return m_SeekPtr;
}
@@ -365,6 +382,7 @@ private:
ZipFileInfoMap m_ArchiveMap;
};
+// ----------------------------------------------------------------
ZipArchiveIOSystem::Implement::Implement(IOSystem *pIOHandler, const char *pFilename, const char *pMode) {
ai_assert(strcmp(pMode, "r") == 0);
ai_assert(pFilename != nullptr);
@@ -376,12 +394,14 @@ ZipArchiveIOSystem::Implement::Implement(IOSystem *pIOHandler, const char *pFile
m_ZipFileHandle = unzOpen2(pFilename, &mapping);
}
+// ----------------------------------------------------------------
ZipArchiveIOSystem::Implement::~Implement() {
if (m_ZipFileHandle != nullptr) {
unzClose(m_ZipFileHandle);
}
}
+// ----------------------------------------------------------------
void ZipArchiveIOSystem::Implement::MapArchive() {
if (m_ZipFileHandle == nullptr)
return;
@@ -408,10 +428,12 @@ void ZipArchiveIOSystem::Implement::MapArchive() {
} while (unzGoToNextFile(m_ZipFileHandle) != UNZ_END_OF_LIST_OF_FILE);
}
+// ----------------------------------------------------------------
bool ZipArchiveIOSystem::Implement::isOpen() const {
return (m_ZipFileHandle != nullptr);
}
+// ----------------------------------------------------------------
void ZipArchiveIOSystem::Implement::getFileList(std::vector<std::string> &rFileList) {
MapArchive();
rFileList.clear();
@@ -421,6 +443,7 @@ void ZipArchiveIOSystem::Implement::getFileList(std::vector<std::string> &rFileL
}
}
+// ----------------------------------------------------------------
void ZipArchiveIOSystem::Implement::getFileListExtension(std::vector<std::string> &rFileList, const std::string &extension) {
MapArchive();
rFileList.clear();
@@ -431,6 +454,7 @@ void ZipArchiveIOSystem::Implement::getFileListExtension(std::vector<std::string
}
}
+// ----------------------------------------------------------------
bool ZipArchiveIOSystem::Implement::Exists(std::string &filename) {
MapArchive();
@@ -438,6 +462,7 @@ bool ZipArchiveIOSystem::Implement::Exists(std::string &filename) {
return (it != m_ArchiveMap.end());
}
+// ----------------------------------------------------------------
IOStream *ZipArchiveIOSystem::Implement::OpenFile(std::string &filename) {
MapArchive();
@@ -452,6 +477,7 @@ IOStream *ZipArchiveIOSystem::Implement::OpenFile(std::string &filename) {
return zip_file.Extract(filename, m_ZipFileHandle);
}
+// ----------------------------------------------------------------
inline void ReplaceAll(std::string &data, const std::string &before, const std::string &after) {
size_t pos = data.find(before);
while (pos != std::string::npos) {
@@ -460,6 +486,7 @@ inline void ReplaceAll(std::string &data, const std::string &before, const std::
}
}
+// ----------------------------------------------------------------
inline void ReplaceAllChar(std::string &data, const char before, const char after) {
size_t pos = data.find(before);
while (pos != std::string::npos) {
@@ -468,6 +495,7 @@ inline void ReplaceAllChar(std::string &data, const char before, const char afte
}
}
+// ----------------------------------------------------------------
void ZipArchiveIOSystem::Implement::SimplifyFilename(std::string &filename) {
ReplaceAllChar(filename, '\\', '/');
@@ -492,6 +520,7 @@ void ZipArchiveIOSystem::Implement::SimplifyFilename(std::string &filename) {
}
}
+// ----------------------------------------------------------------
ZipArchiveIOSystem::ZipArchiveIOSystem(IOSystem *pIOHandler, const char *pFilename, const char *pMode) :
pImpl(new Implement(pIOHandler, pFilename, pMode)) {
}
@@ -502,10 +531,12 @@ ZipArchiveIOSystem::ZipArchiveIOSystem(IOSystem *pIOHandler, const std::string &
pImpl(new Implement(pIOHandler, rFilename.c_str(), pMode)) {
}
+// ----------------------------------------------------------------
ZipArchiveIOSystem::~ZipArchiveIOSystem() {
delete pImpl;
}
+// ----------------------------------------------------------------
bool ZipArchiveIOSystem::Exists(const char *pFilename) const {
ai_assert(pFilename != nullptr);
@@ -517,11 +548,13 @@ bool ZipArchiveIOSystem::Exists(const char *pFilename) const {
return pImpl->Exists(filename);
}
+// ----------------------------------------------------------------
// This is always '/' in a ZIP
char ZipArchiveIOSystem::getOsSeparator() const {
return '/';
}
+// ----------------------------------------------------------------
// Only supports Reading
IOStream *ZipArchiveIOSystem::Open(const char *pFilename, const char *pMode) {
ai_assert(pFilename != nullptr);
@@ -536,22 +569,27 @@ IOStream *ZipArchiveIOSystem::Open(const char *pFilename, const char *pMode) {
return pImpl->OpenFile(filename);
}
+// ----------------------------------------------------------------
void ZipArchiveIOSystem::Close(IOStream *pFile) {
delete pFile;
}
+// ----------------------------------------------------------------
bool ZipArchiveIOSystem::isOpen() const {
return (pImpl->isOpen());
}
+// ----------------------------------------------------------------
void ZipArchiveIOSystem::getFileList(std::vector<std::string> &rFileList) const {
return pImpl->getFileList(rFileList);
}
+// ----------------------------------------------------------------
void ZipArchiveIOSystem::getFileListExtension(std::vector<std::string> &rFileList, const std::string &extension) const {
return pImpl->getFileListExtension(rFileList, extension);
}
+// ----------------------------------------------------------------
bool ZipArchiveIOSystem::isZipArchive(IOSystem *pIOHandler, const char *pFilename) {
Implement tmp(pIOHandler, pFilename, "r");
return tmp.isOpen();
diff --git a/code/Common/material.cpp b/code/Common/material.cpp
index ffc2f415b..76676ec1a 100644
--- a/code/Common/material.cpp
+++ b/code/Common/material.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/scene.cpp b/code/Common/scene.cpp
index b0e882154..e42f4b2e6 100644
--- a/code/Common/scene.cpp
+++ b/code/Common/scene.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/simd.cpp b/code/Common/simd.cpp
index 0dd437d26..6a48750b0 100644
--- a/code/Common/simd.cpp
+++ b/code/Common/simd.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Common/simd.h b/code/Common/simd.h
index a1d936629..05d27d253 100644
--- a/code/Common/simd.h
+++ b/code/Common/simd.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Geometry/GeometryUtils.cpp b/code/Geometry/GeometryUtils.cpp
index cec1e74c5..375e501d3 100644
--- a/code/Geometry/GeometryUtils.cpp
+++ b/code/Geometry/GeometryUtils.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Geometry/GeometryUtils.h b/code/Geometry/GeometryUtils.h
index b6fff99e1..2e205c872 100644
--- a/code/Geometry/GeometryUtils.h
+++ b/code/Geometry/GeometryUtils.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Material/MaterialSystem.cpp b/code/Material/MaterialSystem.cpp
index cc8ca2f88..dbae4b7e4 100644
--- a/code/Material/MaterialSystem.cpp
+++ b/code/Material/MaterialSystem.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Material/MaterialSystem.h b/code/Material/MaterialSystem.h
index 41891ad97..e7c752179 100644
--- a/code/Material/MaterialSystem.h
+++ b/code/Material/MaterialSystem.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/Pbrt/PbrtExporter.cpp b/code/Pbrt/PbrtExporter.cpp
index 67937019f..907e9a6a2 100644
--- a/code/Pbrt/PbrtExporter.cpp
+++ b/code/Pbrt/PbrtExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -89,22 +89,27 @@ using namespace Assimp;
namespace Assimp {
-void ExportScenePbrt (
- const char* pFile,
- IOSystem* pIOSystem,
- const aiScene* pScene,
- const ExportProperties* /*pProperties*/
-){
+void ExportScenePbrt(const char *pFile, IOSystem *pIOSystem, const aiScene *pScene,
+ const ExportProperties *) {
std::string path = DefaultIOSystem::absolutePath(std::string(pFile));
std::string file = DefaultIOSystem::completeBaseName(std::string(pFile));
-
+ path = path + file + ".pbrt";
// initialize the exporter
PbrtExporter exporter(pScene, pIOSystem, path, file);
}
} // end of namespace Assimp
-// Constructor
+static void create_embedded_textures_folder(const aiScene *scene, IOSystem *pIOSystem) {
+ if (scene->mNumTextures > 0) {
+ if (!pIOSystem->Exists("textures")) {
+ if (!pIOSystem->CreateDirectory("textures")) {
+ throw DeadlyExportError("Could not create textures/ directory.");
+ }
+ }
+ }
+}
+
PbrtExporter::PbrtExporter(
const aiScene *pScene, IOSystem *pIOSystem,
const std::string &path, const std::string &file) :
@@ -127,10 +132,10 @@ PbrtExporter::PbrtExporter(
0.f, 0.f, 1.f, 0.f, //
0.f, 0.f, 0.f, 1.f //
) * mRootTransform;
+
// Export embedded textures.
- if (mScene->mNumTextures > 0)
- if (!mIOSystem->CreateDirectory("textures"))
- throw DeadlyExportError("Could not create textures/ directory.");
+ create_embedded_textures_folder(mScene, mIOSystem);
+
for (unsigned int i = 0; i < mScene->mNumTextures; ++i) {
aiTexture* tex = mScene->mTextures[i];
std::string fn = CleanTextureFilename(tex->mFilename, false);
@@ -176,9 +181,6 @@ PbrtExporter::PbrtExporter(
outfile->Write(mOutput.str().c_str(), mOutput.str().length(), 1);
}
-// Destructor
-PbrtExporter::~PbrtExporter() = default;
-
void PbrtExporter::WriteMetaData() {
mOutput << "#############################\n";
mOutput << "# Scene metadata:\n";
diff --git a/code/Pbrt/PbrtExporter.h b/code/Pbrt/PbrtExporter.h
index c7e8180e2..0242ddcf0 100644
--- a/code/Pbrt/PbrtExporter.h
+++ b/code/Pbrt/PbrtExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -70,15 +70,33 @@ class ExportProperties;
// ---------------------------------------------------------------------
/** Helper class to export a given scene to a Pbrt file. */
// ---------------------------------------------------------------------
-class PbrtExporter
-{
+class PbrtExporter {
public:
/// Constructor for a specific scene to export
PbrtExporter(const aiScene *pScene, IOSystem *pIOSystem,
const std::string &path, const std::string &file);
/// Destructor
- virtual ~PbrtExporter();
+ virtual ~PbrtExporter() = default;
+
+private:
+ aiMatrix4x4 GetNodeTransform(const aiString &name) const;
+ static std::string TransformAsString(const aiMatrix4x4 &m);
+ static std::string RemoveSuffix(std::string filename);
+ std::string CleanTextureFilename(const aiString &f, bool rewriteExtension = true) const;
+ void WriteMetaData();
+ void WriteWorldDefinition();
+ void WriteCameras();
+ void WriteCamera(int i);
+ void WriteLights();
+ void WriteTextures();
+ static bool TextureHasAlphaMask(const std::string &filename);
+ void WriteMaterials();
+ void WriteMaterial(int i);
+ void WriteMesh(aiMesh *mesh);
+ void WriteInstanceDefinition(int i);
+ void WriteGeometricObjects(aiNode *node, aiMatrix4x4 parentTransform,
+ std::map<int, int> &meshUses);
private:
// the scene to export
@@ -96,39 +114,11 @@ private:
/// Name of the file (without extension) where the scene will be exported
const std::string mFile;
-private:
// A private set to keep track of which textures have been declared
std::set<std::string> mTextureSet;
// Transform to apply to the root node and all root objects such as cameras, lights, etc.
aiMatrix4x4 mRootTransform;
-
- aiMatrix4x4 GetNodeTransform(const aiString& name) const;
- static std::string TransformAsString(const aiMatrix4x4& m);
-
- static std::string RemoveSuffix(std::string filename);
- std::string CleanTextureFilename(const aiString &f, bool rewriteExtension = true) const;
-
- void WriteMetaData();
-
- void WriteWorldDefinition();
-
- void WriteCameras();
- void WriteCamera(int i);
-
- void WriteLights();
-
- void WriteTextures();
- static bool TextureHasAlphaMask(const std::string &filename);
-
- void WriteMaterials();
- void WriteMaterial(int i);
-
- void WriteMesh(aiMesh* mesh);
-
- void WriteInstanceDefinition(int i);
- void WriteGeometricObjects(aiNode* node, aiMatrix4x4 parentTransform,
- std::map<int, int> &meshUses);
};
} // namespace Assimp
diff --git a/code/PostProcessing/ArmaturePopulate.cpp b/code/PostProcessing/ArmaturePopulate.cpp
index 234a00232..fa524a7fd 100644
--- a/code/PostProcessing/ArmaturePopulate.cpp
+++ b/code/PostProcessing/ArmaturePopulate.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ArmaturePopulate.h b/code/PostProcessing/ArmaturePopulate.h
index 52d3adfef..af1792fb0 100644
--- a/code/PostProcessing/ArmaturePopulate.h
+++ b/code/PostProcessing/ArmaturePopulate.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/CalcTangentsProcess.cpp b/code/PostProcessing/CalcTangentsProcess.cpp
index a23ac856b..82fde1348 100644
--- a/code/PostProcessing/CalcTangentsProcess.cpp
+++ b/code/PostProcessing/CalcTangentsProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/PostProcessing/CalcTangentsProcess.h b/code/PostProcessing/CalcTangentsProcess.h
index aaccb5307..3d7bb2a5e 100644
--- a/code/PostProcessing/CalcTangentsProcess.h
+++ b/code/PostProcessing/CalcTangentsProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ComputeUVMappingProcess.cpp b/code/PostProcessing/ComputeUVMappingProcess.cpp
index f75dc5952..2aa34de28 100644
--- a/code/PostProcessing/ComputeUVMappingProcess.cpp
+++ b/code/PostProcessing/ComputeUVMappingProcess.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ComputeUVMappingProcess.h b/code/PostProcessing/ComputeUVMappingProcess.h
index c4158f402..2a40a15b1 100644
--- a/code/PostProcessing/ComputeUVMappingProcess.h
+++ b/code/PostProcessing/ComputeUVMappingProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ConvertToLHProcess.cpp b/code/PostProcessing/ConvertToLHProcess.cpp
index 80abf84a5..77c7cb853 100644
--- a/code/PostProcessing/ConvertToLHProcess.cpp
+++ b/code/PostProcessing/ConvertToLHProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ConvertToLHProcess.h b/code/PostProcessing/ConvertToLHProcess.h
index ea001b95b..e5ef19a8d 100644
--- a/code/PostProcessing/ConvertToLHProcess.h
+++ b/code/PostProcessing/ConvertToLHProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/DeboneProcess.cpp b/code/PostProcessing/DeboneProcess.cpp
index e91196ce2..1ae79ee30 100644
--- a/code/PostProcessing/DeboneProcess.cpp
+++ b/code/PostProcessing/DeboneProcess.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/DeboneProcess.h b/code/PostProcessing/DeboneProcess.h
index ae4448e0e..cc2d43cb7 100644
--- a/code/PostProcessing/DeboneProcess.h
+++ b/code/PostProcessing/DeboneProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/DropFaceNormalsProcess.cpp b/code/PostProcessing/DropFaceNormalsProcess.cpp
index c5f6333e0..29967b74b 100644
--- a/code/PostProcessing/DropFaceNormalsProcess.cpp
+++ b/code/PostProcessing/DropFaceNormalsProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/PostProcessing/DropFaceNormalsProcess.h b/code/PostProcessing/DropFaceNormalsProcess.h
index df542f2ba..84f9dbe83 100644
--- a/code/PostProcessing/DropFaceNormalsProcess.h
+++ b/code/PostProcessing/DropFaceNormalsProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/EmbedTexturesProcess.cpp b/code/PostProcessing/EmbedTexturesProcess.cpp
index d5d2ef872..568031d8f 100644
--- a/code/PostProcessing/EmbedTexturesProcess.cpp
+++ b/code/PostProcessing/EmbedTexturesProcess.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/EmbedTexturesProcess.h b/code/PostProcessing/EmbedTexturesProcess.h
index 77d4d9c72..8210eec96 100644
--- a/code/PostProcessing/EmbedTexturesProcess.h
+++ b/code/PostProcessing/EmbedTexturesProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/FindDegenerates.cpp b/code/PostProcessing/FindDegenerates.cpp
index d9c14425c..c506b08b5 100644
--- a/code/PostProcessing/FindDegenerates.cpp
+++ b/code/PostProcessing/FindDegenerates.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/FindDegenerates.h b/code/PostProcessing/FindDegenerates.h
index 6b37a47cf..0d046df2d 100644
--- a/code/PostProcessing/FindDegenerates.h
+++ b/code/PostProcessing/FindDegenerates.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/FindInstancesProcess.cpp b/code/PostProcessing/FindInstancesProcess.cpp
index 55974b1c3..9186dd3dd 100644
--- a/code/PostProcessing/FindInstancesProcess.cpp
+++ b/code/PostProcessing/FindInstancesProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/PostProcessing/FindInstancesProcess.h b/code/PostProcessing/FindInstancesProcess.h
index 6927301ca..63e988abf 100644
--- a/code/PostProcessing/FindInstancesProcess.h
+++ b/code/PostProcessing/FindInstancesProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/FindInvalidDataProcess.cpp b/code/PostProcessing/FindInvalidDataProcess.cpp
index aa91139bc..12f345407 100644
--- a/code/PostProcessing/FindInvalidDataProcess.cpp
+++ b/code/PostProcessing/FindInvalidDataProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -273,7 +273,8 @@ void FindInvalidDataProcess::ProcessAnimation(aiAnimation *anim) {
void FindInvalidDataProcess::ProcessAnimationChannel(aiNodeAnim *anim) {
ai_assert(nullptr != anim);
if (anim->mNumPositionKeys == 0 && anim->mNumRotationKeys == 0 && anim->mNumScalingKeys == 0) {
- ai_assert_entry();
+ ASSIMP_LOG_ERROR("Invalid node anuimation instance detected.");
+
return;
}
diff --git a/code/PostProcessing/FindInvalidDataProcess.h b/code/PostProcessing/FindInvalidDataProcess.h
index 024eb9b1e..516db4272 100644
--- a/code/PostProcessing/FindInvalidDataProcess.h
+++ b/code/PostProcessing/FindInvalidDataProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/FixNormalsStep.cpp b/code/PostProcessing/FixNormalsStep.cpp
index 54ac05cc8..2bf85430f 100644
--- a/code/PostProcessing/FixNormalsStep.cpp
+++ b/code/PostProcessing/FixNormalsStep.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/PostProcessing/FixNormalsStep.h b/code/PostProcessing/FixNormalsStep.h
index 20be1958b..b25d92282 100644
--- a/code/PostProcessing/FixNormalsStep.h
+++ b/code/PostProcessing/FixNormalsStep.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/GenBoundingBoxesProcess.cpp b/code/PostProcessing/GenBoundingBoxesProcess.cpp
index ca8e4d6d0..da9fd7137 100644
--- a/code/PostProcessing/GenBoundingBoxesProcess.cpp
+++ b/code/PostProcessing/GenBoundingBoxesProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/GenBoundingBoxesProcess.h b/code/PostProcessing/GenBoundingBoxesProcess.h
index 0cf8514f4..c24009dc9 100644
--- a/code/PostProcessing/GenBoundingBoxesProcess.h
+++ b/code/PostProcessing/GenBoundingBoxesProcess.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/GenFaceNormalsProcess.cpp b/code/PostProcessing/GenFaceNormalsProcess.cpp
index 1d259ce22..79a30ca24 100644
--- a/code/PostProcessing/GenFaceNormalsProcess.cpp
+++ b/code/PostProcessing/GenFaceNormalsProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/PostProcessing/GenFaceNormalsProcess.h b/code/PostProcessing/GenFaceNormalsProcess.h
index 94794631e..a5aad13d1 100644
--- a/code/PostProcessing/GenFaceNormalsProcess.h
+++ b/code/PostProcessing/GenFaceNormalsProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/GenVertexNormalsProcess.cpp b/code/PostProcessing/GenVertexNormalsProcess.cpp
index 4869263ab..f7fef6bc4 100644
--- a/code/PostProcessing/GenVertexNormalsProcess.cpp
+++ b/code/PostProcessing/GenVertexNormalsProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/GenVertexNormalsProcess.h b/code/PostProcessing/GenVertexNormalsProcess.h
index b7db9c4f2..677c06a43 100644
--- a/code/PostProcessing/GenVertexNormalsProcess.h
+++ b/code/PostProcessing/GenVertexNormalsProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ImproveCacheLocality.cpp b/code/PostProcessing/ImproveCacheLocality.cpp
index 9336d6b17..c165b0114 100644
--- a/code/PostProcessing/ImproveCacheLocality.cpp
+++ b/code/PostProcessing/ImproveCacheLocality.cpp
@@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -59,31 +57,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h>
#include <stack>
-using namespace Assimp;
+namespace Assimp {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
-ImproveCacheLocalityProcess::ImproveCacheLocalityProcess()
-: mConfigCacheDepth(PP_ICL_PTCACHE_SIZE) {
+ImproveCacheLocalityProcess::ImproveCacheLocalityProcess() :
+ mConfigCacheDepth(PP_ICL_PTCACHE_SIZE) {
// empty
}
// ------------------------------------------------------------------------------------------------
// Returns whether the processing step is present in the given flag field.
-bool ImproveCacheLocalityProcess::IsActive( unsigned int pFlags) const {
+bool ImproveCacheLocalityProcess::IsActive(unsigned int pFlags) const {
return (pFlags & aiProcess_ImproveCacheLocality) != 0;
}
// ------------------------------------------------------------------------------------------------
// Setup configuration
-void ImproveCacheLocalityProcess::SetupProperties(const Importer* pImp) {
+void ImproveCacheLocalityProcess::SetupProperties(const Importer *pImp) {
// AI_CONFIG_PP_ICL_PTCACHE_SIZE controls the target cache size for the optimizer
- mConfigCacheDepth = pImp->GetPropertyInteger(AI_CONFIG_PP_ICL_PTCACHE_SIZE,PP_ICL_PTCACHE_SIZE);
+ mConfigCacheDepth = pImp->GetPropertyInteger(AI_CONFIG_PP_ICL_PTCACHE_SIZE, PP_ICL_PTCACHE_SIZE);
}
// ------------------------------------------------------------------------------------------------
// Executes the post processing step on the given imported data.
-void ImproveCacheLocalityProcess::Execute( aiScene* pScene) {
+void ImproveCacheLocalityProcess::Execute(aiScene *pScene) {
if (!pScene->mNumMeshes) {
ASSIMP_LOG_DEBUG("ImproveCacheLocalityProcess skipped; there are no meshes");
return;
@@ -93,11 +91,11 @@ void ImproveCacheLocalityProcess::Execute( aiScene* pScene) {
float out = 0.f;
unsigned int numf = 0, numm = 0;
- for( unsigned int a = 0; a < pScene->mNumMeshes; ++a ){
- const float res = ProcessMesh( pScene->mMeshes[a],a);
+ for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) {
+ const float res = ProcessMesh(pScene->mMeshes[a], a);
if (res) {
numf += pScene->mMeshes[a]->mNumFaces;
- out += res;
+ out += res;
++numm;
}
}
@@ -110,8 +108,53 @@ void ImproveCacheLocalityProcess::Execute( aiScene* pScene) {
}
// ------------------------------------------------------------------------------------------------
+static ai_real calculateInputACMR(aiMesh *pMesh, const aiFace *const pcEnd,
+ unsigned int configCacheDepth, unsigned int meshNum) {
+ ai_real fACMR = 0.0f;
+ unsigned int *piFIFOStack = new unsigned int[configCacheDepth];
+ memset(piFIFOStack, 0xff, configCacheDepth * sizeof(unsigned int));
+ unsigned int *piCur = piFIFOStack;
+ const unsigned int *const piCurEnd = piFIFOStack + configCacheDepth;
+
+ // count the number of cache misses
+ unsigned int iCacheMisses = 0;
+ for (const aiFace *pcFace = pMesh->mFaces; pcFace != pcEnd; ++pcFace) {
+ for (unsigned int qq = 0; qq < 3; ++qq) {
+ bool bInCache = false;
+ for (unsigned int *pp = piFIFOStack; pp < piCurEnd; ++pp) {
+ if (*pp == pcFace->mIndices[qq]) {
+ // the vertex is in cache
+ bInCache = true;
+ break;
+ }
+ }
+ if (!bInCache) {
+ ++iCacheMisses;
+ if (piCurEnd == piCur) {
+ piCur = piFIFOStack;
+ }
+ *piCur++ = pcFace->mIndices[qq];
+ }
+ }
+ }
+ delete[] piFIFOStack;
+ fACMR = (ai_real)iCacheMisses / pMesh->mNumFaces;
+ if (3.0 == fACMR) {
+ char szBuff[128]; // should be sufficiently large in every case
+
+ // the JoinIdenticalVertices process has not been executed on this
+ // mesh, otherwise this value would normally be at least minimally
+ // smaller than 3.0 ...
+ ai_snprintf(szBuff, 128, "Mesh %u: Not suitable for vcache optimization", meshNum);
+ ASSIMP_LOG_WARN(szBuff);
+ return static_cast<ai_real>(0.f);
+ }
+ return fACMR;
+}
+
+// ------------------------------------------------------------------------------------------------
// Improves the cache coherency of a specific mesh
-ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshNum) {
+ai_real ImproveCacheLocalityProcess::ProcessMesh(aiMesh *pMesh, unsigned int meshNum) {
// TODO: rewrite this to use std::vector or boost::shared_array
ai_assert(nullptr != pMesh);
@@ -126,91 +169,57 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
return static_cast<ai_real>(0.f);
}
- if(pMesh->mNumVertices <= mConfigCacheDepth) {
+ if (pMesh->mNumVertices <= mConfigCacheDepth) {
return static_cast<ai_real>(0.f);
}
ai_real fACMR = 3.f;
- const aiFace* const pcEnd = pMesh->mFaces+pMesh->mNumFaces;
+ const aiFace *const pcEnd = pMesh->mFaces + pMesh->mNumFaces;
// Input ACMR is for logging purposes only
- if (!DefaultLogger::isNullLogger()) {
-
- unsigned int* piFIFOStack = new unsigned int[mConfigCacheDepth];
- memset(piFIFOStack,0xff,mConfigCacheDepth*sizeof(unsigned int));
- unsigned int* piCur = piFIFOStack;
- const unsigned int* const piCurEnd = piFIFOStack + mConfigCacheDepth;
-
- // count the number of cache misses
- unsigned int iCacheMisses = 0;
- for (const aiFace* pcFace = pMesh->mFaces;pcFace != pcEnd;++pcFace) {
- for (unsigned int qq = 0; qq < 3;++qq) {
- bool bInCache = false;
- for (unsigned int* pp = piFIFOStack;pp < piCurEnd;++pp) {
- if (*pp == pcFace->mIndices[qq]) {
- // the vertex is in cache
- bInCache = true;
- break;
- }
- }
- if (!bInCache) {
- ++iCacheMisses;
- if (piCurEnd == piCur) {
- piCur = piFIFOStack;
- }
- *piCur++ = pcFace->mIndices[qq];
- }
- }
- }
- delete[] piFIFOStack;
- fACMR = (ai_real) iCacheMisses / pMesh->mNumFaces;
- if (3.0 == fACMR) {
- char szBuff[128]; // should be sufficiently large in every case
-
- // the JoinIdenticalVertices process has not been executed on this
- // mesh, otherwise this value would normally be at least minimally
- // smaller than 3.0 ...
- ai_snprintf(szBuff,128,"Mesh %u: Not suitable for vcache optimization",meshNum);
- ASSIMP_LOG_WARN(szBuff);
- return static_cast<ai_real>(0.f);
- }
+ if (!DefaultLogger::isNullLogger()) {
+ fACMR = calculateInputACMR(pMesh, pcEnd, mConfigCacheDepth, meshNum);
}
// first we need to build a vertex-triangle adjacency list
- VertexTriangleAdjacency adj(pMesh->mFaces,pMesh->mNumFaces, pMesh->mNumVertices,true);
+ VertexTriangleAdjacency adj(pMesh->mFaces, pMesh->mNumFaces, pMesh->mNumVertices, true);
// build a list to store per-vertex caching time stamps
- unsigned int* const piCachingStamps = new unsigned int[pMesh->mNumVertices];
- memset(piCachingStamps,0x0,pMesh->mNumVertices*sizeof(unsigned int));
+ std::vector<unsigned int> piCachingStamps;
+ piCachingStamps.resize(pMesh->mNumVertices);
+ memset(&piCachingStamps[0], 0x0, pMesh->mNumVertices * sizeof(unsigned int));
// allocate an empty output index buffer. We store the output indices in one large array.
// Since the number of triangles won't change the input faces can be reused. This is how
// we save thousands of redundant mini allocations for aiFace::mIndices
- const unsigned int iIdxCnt = pMesh->mNumFaces*3;
- unsigned int* const piIBOutput = new unsigned int[iIdxCnt];
- unsigned int* piCSIter = piIBOutput;
+ const unsigned int iIdxCnt = pMesh->mNumFaces * 3;
+ std::vector<unsigned int> piIBOutput;
+ piIBOutput.resize(iIdxCnt);
+ std::vector<unsigned int>::iterator piCSIter = piIBOutput.begin();
// allocate the flag array to hold the information
// whether a face has already been emitted or not
- std::vector<bool> abEmitted(pMesh->mNumFaces,false);
+ std::vector<bool> abEmitted(pMesh->mNumFaces, false);
// dead-end vertex index stack
- std::stack<unsigned int, std::vector<unsigned int> > sDeadEndVStack;
+ std::stack<unsigned int, std::vector<unsigned int>> sDeadEndVStack;
// create a copy of the piNumTriPtr buffer
- unsigned int* const piNumTriPtr = adj.mLiveTriangles;
+ unsigned int *const piNumTriPtr = adj.mLiveTriangles;
const std::vector<unsigned int> piNumTriPtrNoModify(piNumTriPtr, piNumTriPtr + pMesh->mNumVertices);
// get the largest number of referenced triangles and allocate the "candidate buffer"
- unsigned int iMaxRefTris = 0; {
- const unsigned int* piCur = adj.mLiveTriangles;
- const unsigned int* const piCurEnd = adj.mLiveTriangles+pMesh->mNumVertices;
- for (;piCur != piCurEnd;++piCur) {
- iMaxRefTris = std::max(iMaxRefTris,*piCur);
+ unsigned int iMaxRefTris = 0;
+ {
+ const unsigned int *piCur = adj.mLiveTriangles;
+ const unsigned int *const piCurEnd = adj.mLiveTriangles + pMesh->mNumVertices;
+ for (; piCur != piCurEnd; ++piCur) {
+ iMaxRefTris = std::max(iMaxRefTris, *piCur);
}
}
ai_assert(iMaxRefTris > 0);
- unsigned int* piCandidates = new unsigned int[iMaxRefTris*3];
+ std::vector<unsigned int> piCandidates;
+ piCandidates.resize(iMaxRefTris * 3);
unsigned int iCacheMisses = 0;
// ...................................................................................
@@ -245,23 +254,23 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
int ivdx = 0;
int ics = 1;
- int iStampCnt = mConfigCacheDepth+1;
- while (ivdx >= 0) {
+ int iStampCnt = mConfigCacheDepth + 1;
+ while (ivdx >= 0) {
unsigned int icnt = piNumTriPtrNoModify[ivdx];
- unsigned int* piList = adj.GetAdjacentTriangles(ivdx);
- unsigned int* piCurCandidate = piCandidates;
+ unsigned int *piList = adj.GetAdjacentTriangles(ivdx);
+ std::vector<unsigned int>::iterator piCurCandidate = piCandidates.begin();
// get all triangles in the neighborhood
- for (unsigned int tri = 0; tri < icnt;++tri) {
+ for (unsigned int tri = 0; tri < icnt; ++tri) {
// if they have not yet been emitted, add them to the output IB
const unsigned int fidx = *piList++;
- if (!abEmitted[fidx]) {
+ if (!abEmitted[fidx]) {
// so iterate through all vertices of the current triangle
- const aiFace* pcFace = &pMesh->mFaces[ fidx ];
- unsigned nind = pcFace->mNumIndices;
+ const aiFace *pcFace = &pMesh->mFaces[fidx];
+ const unsigned nind = pcFace->mNumIndices;
for (unsigned ind = 0; ind < nind; ind++) {
unsigned dp = pcFace->mIndices[ind];
@@ -281,7 +290,7 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
*piCSIter++ = dp;
// if the vertex is not yet in cache, set its cache count
- if (iStampCnt-piCachingStamps[dp] > mConfigCacheDepth) {
+ if (iStampCnt - piCachingStamps[dp] > mConfigCacheDepth) {
piCachingStamps[dp] = iStampCnt++;
++iCacheMisses;
}
@@ -297,16 +306,16 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
// get next fanning vertex
ivdx = -1;
int max_priority = -1;
- for (unsigned int* piCur = piCandidates;piCur != piCurCandidate;++piCur) {
+ for (std::vector<unsigned int>::iterator piCur = piCandidates.begin(); piCur != piCurCandidate; ++piCur) {
const unsigned int dp = *piCur;
// must have live triangles
- if (piNumTriPtr[dp] > 0) {
+ if (piNumTriPtr[dp] > 0) {
int priority = 0;
// will the vertex be in cache, even after fanning occurs?
unsigned int tmp;
- if ((tmp = iStampCnt-piCachingStamps[dp]) + 2*piNumTriPtr[dp] <= mConfigCacheDepth) {
+ if ((tmp = iStampCnt - piCachingStamps[dp]) + 2 * piNumTriPtr[dp] <= mConfigCacheDepth) {
priority = tmp;
}
@@ -324,7 +333,7 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
while (!sDeadEndVStack.empty()) {
unsigned int iCachedIdx = sDeadEndVStack.top();
sDeadEndVStack.pop();
- if (piNumTriPtr[ iCachedIdx ] > 0) {
+ if (piNumTriPtr[iCachedIdx] > 0) {
ivdx = iCachedIdx;
break;
}
@@ -333,9 +342,9 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
if (-1 == ivdx) {
// well, there isn't such a vertex. Simply get the next vertex in input order and
// hope it is not too bad ...
- while (ics < (int)pMesh->mNumVertices) {
+ while (ics < (int)pMesh->mNumVertices) {
++ics;
- if (piNumTriPtr[ics] > 0) {
+ if (piNumTriPtr[ics] > 0) {
ivdx = ics;
break;
}
@@ -345,29 +354,29 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
}
ai_real fACMR2 = 0.0f;
if (!DefaultLogger::isNullLogger()) {
- fACMR2 = (float)iCacheMisses / pMesh->mNumFaces;
-
+ fACMR2 = static_cast<ai_real>(iCacheMisses / pMesh->mNumFaces);
+ const ai_real averageACMR = ((fACMR - fACMR2) / fACMR) * 100.f;
// very intense verbose logging ... prepare for much text if there are many meshes
- if ( DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) {
- ASSIMP_LOG_VERBOSE_DEBUG("Mesh %u | ACMR in: ", meshNum, " out: ", fACMR, " | ~", fACMR2, ((fACMR - fACMR2) / fACMR) * 100.f);
+ if (DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) {
+ ASSIMP_LOG_VERBOSE_DEBUG("Mesh ", meshNum, "| ACMR in: ", fACMR, " out: ", fACMR2, " | average ACMR ", averageACMR);
}
-
fACMR2 *= pMesh->mNumFaces;
}
+
// sort the output index buffer back to the input array
- piCSIter = piIBOutput;
- for (aiFace* pcFace = pMesh->mFaces; pcFace != pcEnd;++pcFace) {
+ piCSIter = piIBOutput.begin();
+ for (aiFace *pcFace = pMesh->mFaces; pcFace != pcEnd; ++pcFace) {
unsigned nind = pcFace->mNumIndices;
- unsigned * ind = pcFace->mIndices;
- if (nind > 0) ind[0] = *piCSIter++;
- if (nind > 1) ind[1] = *piCSIter++;
- if (nind > 2) ind[2] = *piCSIter++;
+ unsigned *ind = pcFace->mIndices;
+ if (nind > 0)
+ ind[0] = *piCSIter++;
+ if (nind > 1)
+ ind[1] = *piCSIter++;
+ if (nind > 2)
+ ind[2] = *piCSIter++;
}
- // delete temporary storage
- delete[] piCachingStamps;
- delete[] piIBOutput;
- delete[] piCandidates;
-
return fACMR2;
}
+
+} // namespace Assimp
diff --git a/code/PostProcessing/ImproveCacheLocality.h b/code/PostProcessing/ImproveCacheLocality.h
index 6f4d55719..30fa59608 100644
--- a/code/PostProcessing/ImproveCacheLocality.h
+++ b/code/PostProcessing/ImproveCacheLocality.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/JoinVerticesProcess.cpp b/code/PostProcessing/JoinVerticesProcess.cpp
index d36915e0c..f4c623c98 100644
--- a/code/PostProcessing/JoinVerticesProcess.cpp
+++ b/code/PostProcessing/JoinVerticesProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h>
#include <unordered_set>
#include <unordered_map>
+#include <memory>
using namespace Assimp;
@@ -145,7 +146,7 @@ bool areVerticesEqual(
}
template<class XMesh>
-void updateXMeshVertices(XMesh *pMesh, std::vector<Vertex> &uniqueVertices) {
+void updateXMeshVertices(XMesh *pMesh, std::vector<int> &uniqueVertices) {
// replace vertex data with the unique data sets
pMesh->mNumVertices = (unsigned int)uniqueVertices.size();
@@ -156,53 +157,47 @@ void updateXMeshVertices(XMesh *pMesh, std::vector<Vertex> &uniqueVertices) {
// ----------------------------------------------------------------------------
// Position, if present (check made for aiAnimMesh)
- if (pMesh->mVertices) {
- delete [] pMesh->mVertices;
+ if (pMesh->mVertices) {
+ std::unique_ptr<aiVector3D[]> oldVertices(pMesh->mVertices);
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
- for (unsigned int a = 0; a < pMesh->mNumVertices; a++) {
- pMesh->mVertices[a] = uniqueVertices[a].position;
- }
+ for (unsigned int a = 0; a < pMesh->mNumVertices; a++)
+ pMesh->mVertices[a] = oldVertices[uniqueVertices[a]];
}
// Normals, if present
if (pMesh->mNormals) {
- delete [] pMesh->mNormals;
+ std::unique_ptr<aiVector3D[]> oldNormals(pMesh->mNormals);
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
- for( unsigned int a = 0; a < pMesh->mNumVertices; a++) {
- pMesh->mNormals[a] = uniqueVertices[a].normal;
- }
+ for (unsigned int a = 0; a < pMesh->mNumVertices; a++)
+ pMesh->mNormals[a] = oldNormals[uniqueVertices[a]];
}
// Tangents, if present
if (pMesh->mTangents) {
- delete [] pMesh->mTangents;
+ std::unique_ptr<aiVector3D[]> oldTangents(pMesh->mTangents);
pMesh->mTangents = new aiVector3D[pMesh->mNumVertices];
- for (unsigned int a = 0; a < pMesh->mNumVertices; a++) {
- pMesh->mTangents[a] = uniqueVertices[a].tangent;
- }
+ for (unsigned int a = 0; a < pMesh->mNumVertices; a++)
+ pMesh->mTangents[a] = oldTangents[uniqueVertices[a]];
}
// Bitangents as well
if (pMesh->mBitangents) {
- delete [] pMesh->mBitangents;
+ std::unique_ptr<aiVector3D[]> oldBitangents(pMesh->mBitangents);
pMesh->mBitangents = new aiVector3D[pMesh->mNumVertices];
- for (unsigned int a = 0; a < pMesh->mNumVertices; a++) {
- pMesh->mBitangents[a] = uniqueVertices[a].bitangent;
- }
+ for (unsigned int a = 0; a < pMesh->mNumVertices; a++)
+ pMesh->mBitangents[a] = oldBitangents[uniqueVertices[a]];
}
// Vertex colors
for (unsigned int a = 0; pMesh->HasVertexColors(a); a++) {
- delete [] pMesh->mColors[a];
+ std::unique_ptr<aiColor4D[]> oldColors(pMesh->mColors[a]);
pMesh->mColors[a] = new aiColor4D[pMesh->mNumVertices];
- for( unsigned int b = 0; b < pMesh->mNumVertices; b++) {
- pMesh->mColors[a][b] = uniqueVertices[b].colors[a];
- }
+ for (unsigned int b = 0; b < pMesh->mNumVertices; b++)
+ pMesh->mColors[a][b] = oldColors[uniqueVertices[b]];
}
// Texture coords
for (unsigned int a = 0; pMesh->HasTextureCoords(a); a++) {
- delete [] pMesh->mTextureCoords[a];
+ std::unique_ptr<aiVector3D[]> oldTextureCoords(pMesh->mTextureCoords[a]);
pMesh->mTextureCoords[a] = new aiVector3D[pMesh->mNumVertices];
- for (unsigned int b = 0; b < pMesh->mNumVertices; b++) {
- pMesh->mTextureCoords[a][b] = uniqueVertices[b].texcoords[a];
- }
+ for (unsigned int b = 0; b < pMesh->mNumVertices; b++)
+ pMesh->mTextureCoords[a][b] = oldTextureCoords[uniqueVertices[b]];
}
}
@@ -270,7 +265,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
}
// We'll never have more vertices afterwards.
- std::vector<Vertex> uniqueVertices;
+ std::vector<int> uniqueVertices;
uniqueVertices.reserve( pMesh->mNumVertices);
// For each vertex the index of the vertex it was replaced by.
@@ -311,7 +306,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
const bool hasAnimMeshes = pMesh->mNumAnimMeshes > 0;
// We'll never have more vertices afterwards.
- std::vector<std::vector<Vertex>> uniqueAnimatedVertices;
+ std::vector<std::vector<int>> uniqueAnimatedVertices;
if (hasAnimMeshes) {
uniqueAnimatedVertices.resize(pMesh->mNumAnimMeshes);
for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) {
@@ -345,10 +340,10 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
//keep track of its index and increment 1
replaceIndex[a] = newIndex++;
// add the vertex to the unique vertices
- uniqueVertices.push_back(v);
+ uniqueVertices.push_back(a);
if (hasAnimMeshes) {
for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) {
- uniqueAnimatedVertices[animMeshIndex].emplace_back(pMesh->mAnimMeshes[animMeshIndex], a);
+ uniqueAnimatedVertices[animMeshIndex].emplace_back(a);
}
}
} else{
diff --git a/code/PostProcessing/JoinVerticesProcess.h b/code/PostProcessing/JoinVerticesProcess.h
index aa8dc5794..60630dae3 100644
--- a/code/PostProcessing/JoinVerticesProcess.h
+++ b/code/PostProcessing/JoinVerticesProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/LimitBoneWeightsProcess.cpp b/code/PostProcessing/LimitBoneWeightsProcess.cpp
index 16b32143e..816914ada 100644
--- a/code/PostProcessing/LimitBoneWeightsProcess.cpp
+++ b/code/PostProcessing/LimitBoneWeightsProcess.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/LimitBoneWeightsProcess.h b/code/PostProcessing/LimitBoneWeightsProcess.h
index 8e5ebd80d..b2612c313 100644
--- a/code/PostProcessing/LimitBoneWeightsProcess.h
+++ b/code/PostProcessing/LimitBoneWeightsProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/MakeVerboseFormat.cpp b/code/PostProcessing/MakeVerboseFormat.cpp
index 1cc2fdc02..d0c5693e7 100644
--- a/code/PostProcessing/MakeVerboseFormat.cpp
+++ b/code/PostProcessing/MakeVerboseFormat.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/PostProcessing/MakeVerboseFormat.h b/code/PostProcessing/MakeVerboseFormat.h
index f21f5919e..02fe21fa7 100644
--- a/code/PostProcessing/MakeVerboseFormat.h
+++ b/code/PostProcessing/MakeVerboseFormat.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/OptimizeGraph.cpp b/code/PostProcessing/OptimizeGraph.cpp
index bcd654634..3be5ff514 100644
--- a/code/PostProcessing/OptimizeGraph.cpp
+++ b/code/PostProcessing/OptimizeGraph.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/OptimizeGraph.h b/code/PostProcessing/OptimizeGraph.h
index 23e59e67d..c32748d7f 100644
--- a/code/PostProcessing/OptimizeGraph.h
+++ b/code/PostProcessing/OptimizeGraph.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/OptimizeMeshes.cpp b/code/PostProcessing/OptimizeMeshes.cpp
index 0fd597808..44792420c 100644
--- a/code/PostProcessing/OptimizeMeshes.cpp
+++ b/code/PostProcessing/OptimizeMeshes.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/PostProcessing/OptimizeMeshes.h b/code/PostProcessing/OptimizeMeshes.h
index 0b062959a..e424ae24a 100644
--- a/code/PostProcessing/OptimizeMeshes.h
+++ b/code/PostProcessing/OptimizeMeshes.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/PretransformVertices.cpp b/code/PostProcessing/PretransformVertices.cpp
index 87af2297d..37727c968 100644
--- a/code/PostProcessing/PretransformVertices.cpp
+++ b/code/PostProcessing/PretransformVertices.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -290,12 +290,6 @@ void PretransformVertices::ComputeAbsoluteTransform(aiNode *pcNode) {
}
}
-static void normalizeVectorArray(aiVector3D *vectorArrayIn, aiVector3D *vectorArrayOut, size_t numVectors) {
- for (size_t i=0; i<numVectors; ++i) {
- vectorArrayOut[i] = vectorArrayIn[i].Normalize();
- }
-}
-
// ------------------------------------------------------------------------------------------------
// Apply the node transformation to a mesh
void PretransformVertices::ApplyTransform(aiMesh *mesh, const aiMatrix4x4 &mat) const {
@@ -322,8 +316,11 @@ void PretransformVertices::ApplyTransform(aiMesh *mesh, const aiMatrix4x4 &mat)
const aiMatrix3x3 m = aiMatrix3x3(mat).Inverse().Transpose();
if (mesh->HasNormals()) {
- normalizeVectorArray(mesh->mNormals, mesh->mNormals, mesh->mNumVertices);
+ for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
+ mesh->mNormals[i] = (m * mesh->mNormals[i]).Normalize();
+ }
}
+
if (mesh->HasTangentsAndBitangents()) {
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
mesh->mTangents[i] = (m * mesh->mTangents[i]).Normalize();
diff --git a/code/PostProcessing/PretransformVertices.h b/code/PostProcessing/PretransformVertices.h
index 69d3d8400..74c886488 100644
--- a/code/PostProcessing/PretransformVertices.h
+++ b/code/PostProcessing/PretransformVertices.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ProcessHelper.cpp b/code/PostProcessing/ProcessHelper.cpp
index e55c17648..cfbac3e80 100644
--- a/code/PostProcessing/ProcessHelper.cpp
+++ b/code/PostProcessing/ProcessHelper.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -52,8 +52,9 @@ namespace Assimp {
// -------------------------------------------------------------------------------
void ConvertListToStrings(const std::string &in, std::list<std::string> &out) {
const char *s = in.c_str();
+ const char *end = in.c_str() + in.size();
while (*s) {
- SkipSpacesAndLineEnd(&s);
+ SkipSpacesAndLineEnd(&s, end);
if (*s == '\'') {
const char *base = ++s;
while (*s != '\'') {
@@ -66,7 +67,7 @@ void ConvertListToStrings(const std::string &in, std::list<std::string> &out) {
out.emplace_back(base, (size_t)(s - base));
++s;
} else {
- out.push_back(GetNextToken(s));
+ out.push_back(GetNextToken(s, end));
}
}
}
@@ -176,8 +177,8 @@ unsigned int GetMeshVFormatUnique(const aiMesh *pcMesh) {
if (pcMesh->HasTangentsAndBitangents()) iRet |= 0x4;
- static_assert(8 >= AI_MAX_NUMBER_OF_COLOR_SETS);
- static_assert(8 >= AI_MAX_NUMBER_OF_TEXTURECOORDS);
+ static_assert(8 >= AI_MAX_NUMBER_OF_COLOR_SETS, "static_assert(8 >= AI_MAX_NUMBER_OF_COLOR_SETS)");
+ static_assert(8 >= AI_MAX_NUMBER_OF_TEXTURECOORDS, "static_assert(8 >= AI_MAX_NUMBER_OF_TEXTURECOORDS)");
// texture coordinates
unsigned int p = 0;
diff --git a/code/PostProcessing/ProcessHelper.h b/code/PostProcessing/ProcessHelper.h
index 78df94ca1..273b122ae 100644
--- a/code/PostProcessing/ProcessHelper.h
+++ b/code/PostProcessing/ProcessHelper.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/RemoveRedundantMaterials.cpp b/code/PostProcessing/RemoveRedundantMaterials.cpp
index ea8d154dc..e32fe21ac 100644
--- a/code/PostProcessing/RemoveRedundantMaterials.cpp
+++ b/code/PostProcessing/RemoveRedundantMaterials.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -75,124 +75,129 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) {
ASSIMP_LOG_DEBUG("RemoveRedundantMatsProcess begin");
unsigned int redundantRemoved = 0, unreferencedRemoved = 0;
- if (pScene->mNumMaterials) {
- // Find out which materials are referenced by meshes
- std::vector<bool> abReferenced(pScene->mNumMaterials,false);
- for (unsigned int i = 0;i < pScene->mNumMeshes;++i)
- abReferenced[pScene->mMeshes[i]->mMaterialIndex] = true;
-
- // If a list of materials to be excluded was given, match the list with
- // our imported materials and 'salt' all positive matches to ensure that
- // we get unique hashes later.
- if (mConfigFixedMaterials.length()) {
-
- std::list<std::string> strings;
- ConvertListToStrings(mConfigFixedMaterials,strings);
-
- for (unsigned int i = 0; i < pScene->mNumMaterials;++i) {
- aiMaterial* mat = pScene->mMaterials[i];
-
- aiString name;
- mat->Get(AI_MATKEY_NAME,name);
-
- if (name.length) {
- std::list<std::string>::const_iterator it = std::find(strings.begin(), strings.end(), name.data);
- if (it != strings.end()) {
-
- // Our brilliant 'salt': A single material property with ~ as first
- // character to mark it as internal and temporary.
- const int dummy = 1;
- ((aiMaterial*)mat)->AddProperty(&dummy,1,"~RRM.UniqueMaterial",0,0);
-
- // Keep this material even if no mesh references it
- abReferenced[i] = true;
- ASSIMP_LOG_VERBOSE_DEBUG( "Found positive match in exclusion list: \'", name.data, "\'");
- }
+ if (pScene->mNumMaterials == 0) {
+ return;
+ }
+
+ // Find out which materials are referenced by meshes
+ std::vector<bool> abReferenced(pScene->mNumMaterials,false);
+ for (unsigned int i = 0;i < pScene->mNumMeshes;++i)
+ abReferenced[pScene->mMeshes[i]->mMaterialIndex] = true;
+
+ // If a list of materials to be excluded was given, match the list with
+ // our imported materials and 'salt' all positive matches to ensure that
+ // we get unique hashes later.
+ if (mConfigFixedMaterials.length()) {
+
+ std::list<std::string> strings;
+ ConvertListToStrings(mConfigFixedMaterials,strings);
+
+ for (unsigned int i = 0; i < pScene->mNumMaterials;++i) {
+ aiMaterial* mat = pScene->mMaterials[i];
+
+ aiString name;
+ mat->Get(AI_MATKEY_NAME,name);
+
+ if (name.length) {
+ std::list<std::string>::const_iterator it = std::find(strings.begin(), strings.end(), name.data);
+ if (it != strings.end()) {
+
+ // Our brilliant 'salt': A single material property with ~ as first
+ // character to mark it as internal and temporary.
+ const int dummy = 1;
+ ((aiMaterial*)mat)->AddProperty(&dummy,1,"~RRM.UniqueMaterial",0,0);
+
+ // Keep this material even if no mesh references it
+ abReferenced[i] = true;
+ ASSIMP_LOG_VERBOSE_DEBUG( "Found positive match in exclusion list: \'", name.data, "\'");
}
}
}
+ }
- // TODO: re-implement this algorithm to work in-place
- unsigned int *aiMappingTable = new unsigned int[pScene->mNumMaterials];
- for ( unsigned int i=0; i<pScene->mNumMaterials; i++ ) {
- aiMappingTable[ i ] = 0;
+ // TODO: re-implement this algorithm to work in-place
+ unsigned int *aiMappingTable = new unsigned int[pScene->mNumMaterials];
+ for ( unsigned int i=0; i<pScene->mNumMaterials; i++ ) {
+ aiMappingTable[ i ] = 0;
+ }
+ unsigned int iNewNum = 0;
+
+ // Iterate through all materials and calculate a hash for them
+ // store all hashes in a list and so a quick search whether
+ // we do already have a specific hash. This allows us to
+ // determine which materials are identical.
+ uint32_t *aiHashes = new uint32_t[ pScene->mNumMaterials ];;
+ for (unsigned int i = 0; i < pScene->mNumMaterials;++i) {
+ // No mesh is referencing this material, remove it.
+ if (!abReferenced[i]) {
+ ++unreferencedRemoved;
+ delete pScene->mMaterials[i];
+ pScene->mMaterials[i] = nullptr;
+ continue;
}
- unsigned int iNewNum = 0;
- // Iterate through all materials and calculate a hash for them
- // store all hashes in a list and so a quick search whether
- // we do already have a specific hash. This allows us to
- // determine which materials are identical.
- uint32_t *aiHashes = new uint32_t[ pScene->mNumMaterials ];;
- for (unsigned int i = 0; i < pScene->mNumMaterials;++i) {
- // No mesh is referencing this material, remove it.
- if (!abReferenced[i]) {
- ++unreferencedRemoved;
+ // Check all previously mapped materials for a matching hash.
+ // On a match we can delete this material and just make it ref to the same index.
+ uint32_t me = aiHashes[i] = ComputeMaterialHash(pScene->mMaterials[i]);
+ for (unsigned int a = 0; a < i;++a) {
+ if (abReferenced[a] && me == aiHashes[a]) {
+ ++redundantRemoved;
+ me = 0;
+ aiMappingTable[i] = aiMappingTable[a];
delete pScene->mMaterials[i];
pScene->mMaterials[i] = nullptr;
+ break;
+ }
+ }
+ // This is a new material that is referenced, add to the map.
+ if (me) {
+ aiMappingTable[i] = iNewNum++;
+ }
+ }
+ // If the new material count differs from the original,
+ // we need to rebuild the material list and remap mesh material indexes.
+ if (iNewNum < 1) {
+ //throw DeadlyImportError("No materials remaining");
+ return;
+ }
+ if (iNewNum != pScene->mNumMaterials) {
+ ai_assert(iNewNum > 0);
+ aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
+ ::memset(ppcMaterials,0,sizeof(void*)*iNewNum);
+ for (unsigned int p = 0; p < pScene->mNumMaterials;++p)
+ {
+ // if the material is not referenced ... remove it
+ if (!abReferenced[p]) {
continue;
}
- // Check all previously mapped materials for a matching hash.
- // On a match we can delete this material and just make it ref to the same index.
- uint32_t me = aiHashes[i] = ComputeMaterialHash(pScene->mMaterials[i]);
- for (unsigned int a = 0; a < i;++a) {
- if (abReferenced[a] && me == aiHashes[a]) {
- ++redundantRemoved;
- me = 0;
- aiMappingTable[i] = aiMappingTable[a];
- delete pScene->mMaterials[i];
- pScene->mMaterials[i] = nullptr;
- break;
+ // generate new names for modified materials that had no names
+ const unsigned int idx = aiMappingTable[p];
+ if (ppcMaterials[idx]) {
+ aiString sz;
+ if( ppcMaterials[idx]->Get(AI_MATKEY_NAME, sz) != AI_SUCCESS ) {
+ sz.length = ::ai_snprintf(sz.data,MAXLEN,"JoinedMaterial_#%u",p);
+ ((aiMaterial*)ppcMaterials[idx])->AddProperty(&sz,AI_MATKEY_NAME);
}
- }
- // This is a new material that is referenced, add to the map.
- if (me) {
- aiMappingTable[i] = iNewNum++;
+ } else {
+ ppcMaterials[idx] = pScene->mMaterials[p];
}
}
- // If the new material count differs from the original,
- // we need to rebuild the material list and remap mesh material indexes.
- if(iNewNum < 1)
- throw DeadlyImportError("No materials remaining");
- if (iNewNum != pScene->mNumMaterials) {
- ai_assert(iNewNum > 0);
- aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
- ::memset(ppcMaterials,0,sizeof(void*)*iNewNum);
- for (unsigned int p = 0; p < pScene->mNumMaterials;++p)
- {
- // if the material is not referenced ... remove it
- if (!abReferenced[p]) {
- continue;
- }
-
- // generate new names for modified materials that had no names
- const unsigned int idx = aiMappingTable[p];
- if (ppcMaterials[idx]) {
- aiString sz;
- if( ppcMaterials[idx]->Get(AI_MATKEY_NAME, sz) != AI_SUCCESS ) {
- sz.length = ::ai_snprintf(sz.data,MAXLEN,"JoinedMaterial_#%u",p);
- ((aiMaterial*)ppcMaterials[idx])->AddProperty(&sz,AI_MATKEY_NAME);
- }
- } else {
- ppcMaterials[idx] = pScene->mMaterials[p];
- }
- }
- // update all material indices
- for (unsigned int p = 0; p < pScene->mNumMeshes;++p) {
- aiMesh* mesh = pScene->mMeshes[p];
- ai_assert(nullptr != mesh);
- mesh->mMaterialIndex = aiMappingTable[mesh->mMaterialIndex];
- }
- // delete the old material list
- delete[] pScene->mMaterials;
- pScene->mMaterials = ppcMaterials;
- pScene->mNumMaterials = iNewNum;
+ // update all material indices
+ for (unsigned int p = 0; p < pScene->mNumMeshes;++p) {
+ aiMesh* mesh = pScene->mMeshes[p];
+ ai_assert(nullptr != mesh);
+ mesh->mMaterialIndex = aiMappingTable[mesh->mMaterialIndex];
}
- // delete temporary storage
- delete[] aiHashes;
- delete[] aiMappingTable;
+ // delete the old material list
+ delete[] pScene->mMaterials;
+ pScene->mMaterials = ppcMaterials;
+ pScene->mNumMaterials = iNewNum;
}
+ // delete temporary storage
+ delete[] aiHashes;
+ delete[] aiMappingTable;
+
if (redundantRemoved == 0 && unreferencedRemoved == 0) {
ASSIMP_LOG_DEBUG("RemoveRedundantMatsProcess finished ");
} else {
diff --git a/code/PostProcessing/RemoveRedundantMaterials.h b/code/PostProcessing/RemoveRedundantMaterials.h
index 1b42bea55..107de0daa 100644
--- a/code/PostProcessing/RemoveRedundantMaterials.h
+++ b/code/PostProcessing/RemoveRedundantMaterials.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/RemoveVCProcess.cpp b/code/PostProcessing/RemoveVCProcess.cpp
index bcad65423..13ef81e23 100644
--- a/code/PostProcessing/RemoveVCProcess.cpp
+++ b/code/PostProcessing/RemoveVCProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/RemoveVCProcess.h b/code/PostProcessing/RemoveVCProcess.h
index 45c0b3a71..8d9b5167a 100644
--- a/code/PostProcessing/RemoveVCProcess.h
+++ b/code/PostProcessing/RemoveVCProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ScaleProcess.cpp b/code/PostProcessing/ScaleProcess.cpp
index 1bb9196f1..5cd7eea6e 100644
--- a/code/PostProcessing/ScaleProcess.cpp
+++ b/code/PostProcessing/ScaleProcess.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ScaleProcess.h b/code/PostProcessing/ScaleProcess.h
index ae1c3ed00..2887c7221 100644
--- a/code/PostProcessing/ScaleProcess.h
+++ b/code/PostProcessing/ScaleProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/SortByPTypeProcess.cpp b/code/PostProcessing/SortByPTypeProcess.cpp
index 47633dce5..48ebbc573 100644
--- a/code/PostProcessing/SortByPTypeProcess.cpp
+++ b/code/PostProcessing/SortByPTypeProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/SortByPTypeProcess.h b/code/PostProcessing/SortByPTypeProcess.h
index ce4f7da62..aa7774d7f 100644
--- a/code/PostProcessing/SortByPTypeProcess.h
+++ b/code/PostProcessing/SortByPTypeProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/SplitByBoneCountProcess.cpp b/code/PostProcessing/SplitByBoneCountProcess.cpp
index 969146fee..ea50f8f7f 100644
--- a/code/PostProcessing/SplitByBoneCountProcess.cpp
+++ b/code/PostProcessing/SplitByBoneCountProcess.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/SplitByBoneCountProcess.h b/code/PostProcessing/SplitByBoneCountProcess.h
index efe85824f..c90661cb5 100644
--- a/code/PostProcessing/SplitByBoneCountProcess.h
+++ b/code/PostProcessing/SplitByBoneCountProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/SplitLargeMeshes.cpp b/code/PostProcessing/SplitLargeMeshes.cpp
index b6e5b772a..3bee28521 100644
--- a/code/PostProcessing/SplitLargeMeshes.cpp
+++ b/code/PostProcessing/SplitLargeMeshes.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/SplitLargeMeshes.h b/code/PostProcessing/SplitLargeMeshes.h
index 4e0d764c1..25bf300d5 100644
--- a/code/PostProcessing/SplitLargeMeshes.h
+++ b/code/PostProcessing/SplitLargeMeshes.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/TextureTransform.cpp b/code/PostProcessing/TextureTransform.cpp
index 3de357c17..53dba3860 100644
--- a/code/PostProcessing/TextureTransform.cpp
+++ b/code/PostProcessing/TextureTransform.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/TextureTransform.h b/code/PostProcessing/TextureTransform.h
index c9f0480ba..7c0addf09 100644
--- a/code/PostProcessing/TextureTransform.h
+++ b/code/PostProcessing/TextureTransform.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/TriangulateProcess.cpp b/code/PostProcessing/TriangulateProcess.cpp
index f16de2196..ac483f215 100644
--- a/code/PostProcessing/TriangulateProcess.cpp
+++ b/code/PostProcessing/TriangulateProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/TriangulateProcess.h b/code/PostProcessing/TriangulateProcess.h
index ac31e4377..e17a10e33 100644
--- a/code/PostProcessing/TriangulateProcess.h
+++ b/code/PostProcessing/TriangulateProcess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ValidateDataStructure.cpp b/code/PostProcessing/ValidateDataStructure.cpp
index 14259e11a..a0a73e200 100644
--- a/code/PostProcessing/ValidateDataStructure.cpp
+++ b/code/PostProcessing/ValidateDataStructure.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/PostProcessing/ValidateDataStructure.h b/code/PostProcessing/ValidateDataStructure.h
index 9cfd4ced1..8bc13e60d 100644
--- a/code/PostProcessing/ValidateDataStructure.h
+++ b/code/PostProcessing/ValidateDataStructure.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/contrib/clipper/clipper.cpp b/contrib/clipper/clipper.cpp
index d75974336..c0a8565bb 100644
--- a/contrib/clipper/clipper.cpp
+++ b/contrib/clipper/clipper.cpp
@@ -4330,10 +4330,10 @@ double DistanceFromLineSqrd(
const IntPoint& pt, const IntPoint& ln1, const IntPoint& ln2)
{
//The equation of a line in general form (Ax + By + C = 0)
- //given 2 points (x�,y�) & (x�,y�) is ...
- //(y� - y�)x + (x� - x�)y + (y� - y�)x� - (x� - x�)y� = 0
- //A = (y� - y�); B = (x� - x�); C = (y� - y�)x� - (x� - x�)y�
- //perpendicular distance of point (x�,y�) = (Ax� + By� + C)/Sqrt(A� + B�)
+ //given 2 points (x_1, y_1) & (x_2, y_2) is ...
+ //(y_1 - y_2)x + (x_2 - x_1)y - (y_1 - y_2)x_1 - (x_2 - x_1)y_1 = 0
+ //A = (y_1 - y_2); B = (x_2 - x_1); C = - (y_1 - y_2)x_1 - (x_2 - x_1)y_1
+ //perpendicular distance of point (x_0, y_0) = |Ax_0 + By_0 + C| / Sqrt(A^2 + B^2)
//see http://en.wikipedia.org/wiki/Perpendicular_distance
double A = double(ln1.Y - ln2.Y);
double B = double(ln2.X - ln1.X);
diff --git a/contrib/poly2tri/poly2tri/sweep/sweep.cc b/contrib/poly2tri/poly2tri/sweep/sweep.cc
index 565a198d8..e1f23f11b 100644
--- a/contrib/poly2tri/poly2tri/sweep/sweep.cc
+++ b/contrib/poly2tri/poly2tri/sweep/sweep.cc
@@ -111,6 +111,9 @@ void Sweep::EdgeEvent(SweepContext& tcx, Edge* edge, Node* node)
void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangle, Point& point)
{
+ if (triangle == nullptr)
+ return;
+
if (IsEdgeSideOfTriangle(*triangle, ep, eq)) {
return;
}
diff --git a/contrib/pugixml/readme.txt b/contrib/pugixml/readme.txt
index 9dffb72a1..2c1865437 100644
--- a/contrib/pugixml/readme.txt
+++ b/contrib/pugixml/readme.txt
@@ -1,6 +1,6 @@
pugixml 1.13 - an XML processing library
-Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+Copyright (c) 2006-2024, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
Report bugs and download new versions at https://pugixml.org/
This is the distribution of pugixml, which is a C++ XML processing library,
@@ -26,7 +26,7 @@ The distribution contains the following folders:
This library is distributed under the MIT License:
-Copyright (c) 2006-2022 Arseny Kapoulkine
+Copyright (c) 2006-2024 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
diff --git a/contrib/pugixml/src/pugiconfig.hpp b/contrib/pugixml/src/pugiconfig.hpp
index 9bf2efd39..1a3956903 100644
--- a/contrib/pugixml/src/pugiconfig.hpp
+++ b/contrib/pugixml/src/pugiconfig.hpp
@@ -1,7 +1,7 @@
/**
* pugixml parser - version 1.13
* --------------------------------------------------------
- * Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+ * Copyright (c) 2006-2024, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
@@ -52,7 +52,7 @@
#endif
/**
- * Copyright (c) 2006-2022 Arseny Kapoulkine
+ * Copyright (c) 2006-2024 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/contrib/pugixml/src/pugixml.cpp b/contrib/pugixml/src/pugixml.cpp
index c63645b67..6d6bd0edb 100644
--- a/contrib/pugixml/src/pugixml.cpp
+++ b/contrib/pugixml/src/pugixml.cpp
@@ -1,7 +1,7 @@
/**
* pugixml parser - version 1.13
* --------------------------------------------------------
- * Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+ * Copyright (c) 2006-2024, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
@@ -13133,7 +13133,7 @@ namespace pugi
#endif
/**
- * Copyright (c) 2006-2022 Arseny Kapoulkine
+ * Copyright (c) 2006-2024 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/contrib/pugixml/src/pugixml.hpp b/contrib/pugixml/src/pugixml.hpp
index 050df154c..fde6a4a86 100644
--- a/contrib/pugixml/src/pugixml.hpp
+++ b/contrib/pugixml/src/pugixml.hpp
@@ -1,7 +1,7 @@
/**
* pugixml parser - version 1.13
* --------------------------------------------------------
- * Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+ * Copyright (c) 2006-2024, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
@@ -1481,7 +1481,7 @@ namespace std
#endif
/**
- * Copyright (c) 2006-2022 Arseny Kapoulkine
+ * Copyright (c) 2006-2024 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/contrib/rapidjson/include/rapidjson/allocators.h b/contrib/rapidjson/include/rapidjson/allocators.h
index 44ec5295c..275417bd8 100644
--- a/contrib/rapidjson/include/rapidjson/allocators.h
+++ b/contrib/rapidjson/include/rapidjson/allocators.h
@@ -16,6 +16,14 @@
#define RAPIDJSON_ALLOCATORS_H_
#include "rapidjson.h"
+#include "internal/meta.h"
+
+#include <memory>
+#include <limits>
+
+#if RAPIDJSON_HAS_CXX11
+#include <type_traits>
+#endif
RAPIDJSON_NAMESPACE_BEGIN
@@ -89,7 +97,14 @@ public:
}
return RAPIDJSON_REALLOC(originalPtr, newSize);
}
- static void Free(void *ptr) { RAPIDJSON_FREE(ptr); }
+ static void Free(void *ptr) RAPIDJSON_NOEXCEPT { RAPIDJSON_FREE(ptr); }
+
+ bool operator==(const CrtAllocator&) const RAPIDJSON_NOEXCEPT {
+ return true;
+ }
+ bool operator!=(const CrtAllocator&) const RAPIDJSON_NOEXCEPT {
+ return false;
+ }
};
///////////////////////////////////////////////////////////////////////////////
@@ -113,16 +128,64 @@ public:
*/
template <typename BaseAllocator = CrtAllocator>
class MemoryPoolAllocator {
+ //! Chunk header for perpending to each chunk.
+ /*! Chunks are stored as a singly linked list.
+ */
+ struct ChunkHeader {
+ size_t capacity; //!< Capacity of the chunk in bytes (excluding the header itself).
+ size_t size; //!< Current size of allocated memory in bytes.
+ ChunkHeader *next; //!< Next chunk in the linked list.
+ };
+
+ struct SharedData {
+ ChunkHeader *chunkHead; //!< Head of the chunk linked-list. Only the head chunk serves allocation.
+ BaseAllocator* ownBaseAllocator; //!< base allocator created by this object.
+ size_t refcount;
+ bool ownBuffer;
+ };
+
+ static const size_t SIZEOF_SHARED_DATA = RAPIDJSON_ALIGN(sizeof(SharedData));
+ static const size_t SIZEOF_CHUNK_HEADER = RAPIDJSON_ALIGN(sizeof(ChunkHeader));
+
+ static inline ChunkHeader *GetChunkHead(SharedData *shared)
+ {
+ return reinterpret_cast<ChunkHeader*>(reinterpret_cast<uint8_t*>(shared) + SIZEOF_SHARED_DATA);
+ }
+ static inline uint8_t *GetChunkBuffer(SharedData *shared)
+ {
+ return reinterpret_cast<uint8_t*>(shared->chunkHead) + SIZEOF_CHUNK_HEADER;
+ }
+
+ static const size_t kDefaultChunkCapacity = RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY; //!< Default chunk capacity.
+
public:
static const bool kNeedFree = false; //!< Tell users that no need to call Free() with this allocator. (concept Allocator)
+ static const bool kRefCounted = true; //!< Tell users that this allocator is reference counted on copy
//! Constructor with chunkSize.
/*! \param chunkSize The size of memory chunk. The default is kDefaultChunkSize.
\param baseAllocator The allocator for allocating memory chunks.
*/
+ explicit
MemoryPoolAllocator(size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :
- chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(0), baseAllocator_(baseAllocator), ownBaseAllocator_(0)
+ chunk_capacity_(chunkSize),
+ baseAllocator_(baseAllocator ? baseAllocator : RAPIDJSON_NEW(BaseAllocator)()),
+ shared_(static_cast<SharedData*>(baseAllocator_ ? baseAllocator_->Malloc(SIZEOF_SHARED_DATA + SIZEOF_CHUNK_HEADER) : 0))
{
+ RAPIDJSON_ASSERT(baseAllocator_ != 0);
+ RAPIDJSON_ASSERT(shared_ != 0);
+ if (baseAllocator) {
+ shared_->ownBaseAllocator = 0;
+ }
+ else {
+ shared_->ownBaseAllocator = baseAllocator_;
+ }
+ shared_->chunkHead = GetChunkHead(shared_);
+ shared_->chunkHead->capacity = 0;
+ shared_->chunkHead->size = 0;
+ shared_->chunkHead->next = 0;
+ shared_->ownBuffer = true;
+ shared_->refcount = 1;
}
//! Constructor with user-supplied buffer.
@@ -136,41 +199,101 @@ public:
\param baseAllocator The allocator for allocating memory chunks.
*/
MemoryPoolAllocator(void *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :
- chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(buffer), baseAllocator_(baseAllocator), ownBaseAllocator_(0)
+ chunk_capacity_(chunkSize),
+ baseAllocator_(baseAllocator),
+ shared_(static_cast<SharedData*>(AlignBuffer(buffer, size)))
+ {
+ RAPIDJSON_ASSERT(size >= SIZEOF_SHARED_DATA + SIZEOF_CHUNK_HEADER);
+ shared_->chunkHead = GetChunkHead(shared_);
+ shared_->chunkHead->capacity = size - SIZEOF_SHARED_DATA - SIZEOF_CHUNK_HEADER;
+ shared_->chunkHead->size = 0;
+ shared_->chunkHead->next = 0;
+ shared_->ownBaseAllocator = 0;
+ shared_->ownBuffer = false;
+ shared_->refcount = 1;
+ }
+
+ MemoryPoolAllocator(const MemoryPoolAllocator& rhs) RAPIDJSON_NOEXCEPT :
+ chunk_capacity_(rhs.chunk_capacity_),
+ baseAllocator_(rhs.baseAllocator_),
+ shared_(rhs.shared_)
+ {
+ RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0);
+ ++shared_->refcount;
+ }
+ MemoryPoolAllocator& operator=(const MemoryPoolAllocator& rhs) RAPIDJSON_NOEXCEPT
{
- RAPIDJSON_ASSERT(buffer != 0);
- RAPIDJSON_ASSERT(size > sizeof(ChunkHeader));
- chunkHead_ = reinterpret_cast<ChunkHeader*>(buffer);
- chunkHead_->capacity = size - sizeof(ChunkHeader);
- chunkHead_->size = 0;
- chunkHead_->next = 0;
+ RAPIDJSON_NOEXCEPT_ASSERT(rhs.shared_->refcount > 0);
+ ++rhs.shared_->refcount;
+ this->~MemoryPoolAllocator();
+ baseAllocator_ = rhs.baseAllocator_;
+ chunk_capacity_ = rhs.chunk_capacity_;
+ shared_ = rhs.shared_;
+ return *this;
}
+#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
+ MemoryPoolAllocator(MemoryPoolAllocator&& rhs) RAPIDJSON_NOEXCEPT :
+ chunk_capacity_(rhs.chunk_capacity_),
+ baseAllocator_(rhs.baseAllocator_),
+ shared_(rhs.shared_)
+ {
+ RAPIDJSON_NOEXCEPT_ASSERT(rhs.shared_->refcount > 0);
+ rhs.shared_ = 0;
+ }
+ MemoryPoolAllocator& operator=(MemoryPoolAllocator&& rhs) RAPIDJSON_NOEXCEPT
+ {
+ RAPIDJSON_NOEXCEPT_ASSERT(rhs.shared_->refcount > 0);
+ this->~MemoryPoolAllocator();
+ baseAllocator_ = rhs.baseAllocator_;
+ chunk_capacity_ = rhs.chunk_capacity_;
+ shared_ = rhs.shared_;
+ rhs.shared_ = 0;
+ return *this;
+ }
+#endif
+
//! Destructor.
/*! This deallocates all memory chunks, excluding the user-supplied buffer.
*/
- ~MemoryPoolAllocator() {
+ ~MemoryPoolAllocator() RAPIDJSON_NOEXCEPT {
+ if (!shared_) {
+ // do nothing if moved
+ return;
+ }
+ if (shared_->refcount > 1) {
+ --shared_->refcount;
+ return;
+ }
Clear();
- RAPIDJSON_DELETE(ownBaseAllocator_);
+ BaseAllocator *a = shared_->ownBaseAllocator;
+ if (shared_->ownBuffer) {
+ baseAllocator_->Free(shared_);
+ }
+ RAPIDJSON_DELETE(a);
}
- //! Deallocates all memory chunks, excluding the user-supplied buffer.
- void Clear() {
- while (chunkHead_ && chunkHead_ != userBuffer_) {
- ChunkHeader* next = chunkHead_->next;
- baseAllocator_->Free(chunkHead_);
- chunkHead_ = next;
+ //! Deallocates all memory chunks, excluding the first/user one.
+ void Clear() RAPIDJSON_NOEXCEPT {
+ RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0);
+ for (;;) {
+ ChunkHeader* c = shared_->chunkHead;
+ if (!c->next) {
+ break;
+ }
+ shared_->chunkHead = c->next;
+ baseAllocator_->Free(c);
}
- if (chunkHead_ && chunkHead_ == userBuffer_)
- chunkHead_->size = 0; // Clear user buffer
+ shared_->chunkHead->size = 0;
}
//! Computes the total capacity of allocated memory chunks.
/*! \return total capacity in bytes.
*/
- size_t Capacity() const {
+ size_t Capacity() const RAPIDJSON_NOEXCEPT {
+ RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0);
size_t capacity = 0;
- for (ChunkHeader* c = chunkHead_; c != 0; c = c->next)
+ for (ChunkHeader* c = shared_->chunkHead; c != 0; c = c->next)
capacity += c->capacity;
return capacity;
}
@@ -178,25 +301,35 @@ public:
//! Computes the memory blocks allocated.
/*! \return total used bytes.
*/
- size_t Size() const {
+ size_t Size() const RAPIDJSON_NOEXCEPT {
+ RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0);
size_t size = 0;
- for (ChunkHeader* c = chunkHead_; c != 0; c = c->next)
+ for (ChunkHeader* c = shared_->chunkHead; c != 0; c = c->next)
size += c->size;
return size;
}
+ //! Whether the allocator is shared.
+ /*! \return true or false.
+ */
+ bool Shared() const RAPIDJSON_NOEXCEPT {
+ RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0);
+ return shared_->refcount > 1;
+ }
+
//! Allocates a memory block. (concept Allocator)
void* Malloc(size_t size) {
+ RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0);
if (!size)
return NULL;
size = RAPIDJSON_ALIGN(size);
- if (chunkHead_ == 0 || chunkHead_->size + size > chunkHead_->capacity)
+ if (RAPIDJSON_UNLIKELY(shared_->chunkHead->size + size > shared_->chunkHead->capacity))
if (!AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size))
return NULL;
- void *buffer = reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size;
- chunkHead_->size += size;
+ void *buffer = GetChunkBuffer(shared_) + shared_->chunkHead->size;
+ shared_->chunkHead->size += size;
return buffer;
}
@@ -205,6 +338,7 @@ public:
if (originalPtr == 0)
return Malloc(newSize);
+ RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0);
if (newSize == 0)
return NULL;
@@ -216,10 +350,10 @@ public:
return originalPtr;
// Simply expand it if it is the last allocation and there is sufficient space
- if (originalPtr == reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size - originalSize) {
+ if (originalPtr == GetChunkBuffer(shared_) + shared_->chunkHead->size - originalSize) {
size_t increment = static_cast<size_t>(newSize - originalSize);
- if (chunkHead_->size + increment <= chunkHead_->capacity) {
- chunkHead_->size += increment;
+ if (shared_->chunkHead->size + increment <= shared_->chunkHead->capacity) {
+ shared_->chunkHead->size += increment;
return originalPtr;
}
}
@@ -235,50 +369,325 @@ public:
}
//! Frees a memory block (concept Allocator)
- static void Free(void *ptr) { (void)ptr; } // Do nothing
+ static void Free(void *ptr) RAPIDJSON_NOEXCEPT { (void)ptr; } // Do nothing
-private:
- //! Copy constructor is not permitted.
- MemoryPoolAllocator(const MemoryPoolAllocator& rhs) /* = delete */;
- //! Copy assignment operator is not permitted.
- MemoryPoolAllocator& operator=(const MemoryPoolAllocator& rhs) /* = delete */;
+ //! Compare (equality) with another MemoryPoolAllocator
+ bool operator==(const MemoryPoolAllocator& rhs) const RAPIDJSON_NOEXCEPT {
+ RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0);
+ RAPIDJSON_NOEXCEPT_ASSERT(rhs.shared_->refcount > 0);
+ return shared_ == rhs.shared_;
+ }
+ //! Compare (inequality) with another MemoryPoolAllocator
+ bool operator!=(const MemoryPoolAllocator& rhs) const RAPIDJSON_NOEXCEPT {
+ return !operator==(rhs);
+ }
+private:
//! Creates a new chunk.
/*! \param capacity Capacity of the chunk in bytes.
\return true if success.
*/
bool AddChunk(size_t capacity) {
if (!baseAllocator_)
- ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator)();
- if (ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity))) {
+ shared_->ownBaseAllocator = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator)();
+ if (ChunkHeader* chunk = static_cast<ChunkHeader*>(baseAllocator_->Malloc(SIZEOF_CHUNK_HEADER + capacity))) {
chunk->capacity = capacity;
chunk->size = 0;
- chunk->next = chunkHead_;
- chunkHead_ = chunk;
+ chunk->next = shared_->chunkHead;
+ shared_->chunkHead = chunk;
return true;
}
else
return false;
}
- static const int kDefaultChunkCapacity = RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY; //!< Default chunk capacity.
-
- //! Chunk header for perpending to each chunk.
- /*! Chunks are stored as a singly linked list.
- */
- struct ChunkHeader {
- size_t capacity; //!< Capacity of the chunk in bytes (excluding the header itself).
- size_t size; //!< Current size of allocated memory in bytes.
- ChunkHeader *next; //!< Next chunk in the linked list.
- };
+ static inline void* AlignBuffer(void* buf, size_t &size)
+ {
+ RAPIDJSON_NOEXCEPT_ASSERT(buf != 0);
+ const uintptr_t mask = sizeof(void*) - 1;
+ const uintptr_t ubuf = reinterpret_cast<uintptr_t>(buf);
+ if (RAPIDJSON_UNLIKELY(ubuf & mask)) {
+ const uintptr_t abuf = (ubuf + mask) & ~mask;
+ RAPIDJSON_ASSERT(size >= abuf - ubuf);
+ buf = reinterpret_cast<void*>(abuf);
+ size -= abuf - ubuf;
+ }
+ return buf;
+ }
- ChunkHeader *chunkHead_; //!< Head of the chunk linked-list. Only the head chunk serves allocation.
size_t chunk_capacity_; //!< The minimum capacity of chunk when they are allocated.
- void *userBuffer_; //!< User supplied buffer.
BaseAllocator* baseAllocator_; //!< base allocator for allocating memory chunks.
- BaseAllocator* ownBaseAllocator_; //!< base allocator created by this object.
+ SharedData *shared_; //!< The shared data of the allocator
};
+namespace internal {
+ template<typename, typename = void>
+ struct IsRefCounted :
+ public FalseType
+ { };
+ template<typename T>
+ struct IsRefCounted<T, typename internal::EnableIfCond<T::kRefCounted>::Type> :
+ public TrueType
+ { };
+}
+
+template<typename T, typename A>
+inline T* Realloc(A& a, T* old_p, size_t old_n, size_t new_n)
+{
+ RAPIDJSON_NOEXCEPT_ASSERT(old_n <= (std::numeric_limits<size_t>::max)() / sizeof(T) && new_n <= (std::numeric_limits<size_t>::max)() / sizeof(T));
+ return static_cast<T*>(a.Realloc(old_p, old_n * sizeof(T), new_n * sizeof(T)));
+}
+
+template<typename T, typename A>
+inline T *Malloc(A& a, size_t n = 1)
+{
+ return Realloc<T, A>(a, NULL, 0, n);
+}
+
+template<typename T, typename A>
+inline void Free(A& a, T *p, size_t n = 1)
+{
+ static_cast<void>(Realloc<T, A>(a, p, n, 0));
+}
+
+#ifdef __GNUC__
+RAPIDJSON_DIAG_PUSH
+RAPIDJSON_DIAG_OFF(effc++) // std::allocator can safely be inherited
+#endif
+
+template <typename T, typename BaseAllocator = CrtAllocator>
+class StdAllocator :
+ public std::allocator<T>
+{
+ typedef std::allocator<T> allocator_type;
+#if RAPIDJSON_HAS_CXX11
+ typedef std::allocator_traits<allocator_type> traits_type;
+#else
+ typedef allocator_type traits_type;
+#endif
+
+public:
+ typedef BaseAllocator BaseAllocatorType;
+
+ StdAllocator() RAPIDJSON_NOEXCEPT :
+ allocator_type(),
+ baseAllocator_()
+ { }
+
+ StdAllocator(const StdAllocator& rhs) RAPIDJSON_NOEXCEPT :
+ allocator_type(rhs),
+ baseAllocator_(rhs.baseAllocator_)
+ { }
+
+ template<typename U>
+ StdAllocator(const StdAllocator<U, BaseAllocator>& rhs) RAPIDJSON_NOEXCEPT :
+ allocator_type(rhs),
+ baseAllocator_(rhs.baseAllocator_)
+ { }
+
+#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
+ StdAllocator(StdAllocator&& rhs) RAPIDJSON_NOEXCEPT :
+ allocator_type(std::move(rhs)),
+ baseAllocator_(std::move(rhs.baseAllocator_))
+ { }
+#endif
+#if RAPIDJSON_HAS_CXX11
+ using propagate_on_container_move_assignment = std::true_type;
+ using propagate_on_container_swap = std::true_type;
+#endif
+
+ /* implicit */
+ StdAllocator(const BaseAllocator& baseAllocator) RAPIDJSON_NOEXCEPT :
+ allocator_type(),
+ baseAllocator_(baseAllocator)
+ { }
+
+ ~StdAllocator() RAPIDJSON_NOEXCEPT
+ { }
+
+ template<typename U>
+ struct rebind {
+ typedef StdAllocator<U, BaseAllocator> other;
+ };
+
+ typedef typename traits_type::size_type size_type;
+ typedef typename traits_type::difference_type difference_type;
+
+ typedef typename traits_type::value_type value_type;
+ typedef typename traits_type::pointer pointer;
+ typedef typename traits_type::const_pointer const_pointer;
+
+#if RAPIDJSON_HAS_CXX11
+
+ typedef typename std::add_lvalue_reference<value_type>::type &reference;
+ typedef typename std::add_lvalue_reference<typename std::add_const<value_type>::type>::type &const_reference;
+
+ pointer address(reference r) const RAPIDJSON_NOEXCEPT
+ {
+ return std::addressof(r);
+ }
+ const_pointer address(const_reference r) const RAPIDJSON_NOEXCEPT
+ {
+ return std::addressof(r);
+ }
+
+ size_type max_size() const RAPIDJSON_NOEXCEPT
+ {
+ return traits_type::max_size(*this);
+ }
+
+ template <typename ...Args>
+ void construct(pointer p, Args&&... args)
+ {
+ traits_type::construct(*this, p, std::forward<Args>(args)...);
+ }
+ void destroy(pointer p)
+ {
+ traits_type::destroy(*this, p);
+ }
+
+#else // !RAPIDJSON_HAS_CXX11
+
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+
+ pointer address(reference r) const RAPIDJSON_NOEXCEPT
+ {
+ return allocator_type::address(r);
+ }
+ const_pointer address(const_reference r) const RAPIDJSON_NOEXCEPT
+ {
+ return allocator_type::address(r);
+ }
+
+ size_type max_size() const RAPIDJSON_NOEXCEPT
+ {
+ return allocator_type::max_size();
+ }
+
+ void construct(pointer p, const_reference r)
+ {
+ allocator_type::construct(p, r);
+ }
+ void destroy(pointer p)
+ {
+ allocator_type::destroy(p);
+ }
+
+#endif // !RAPIDJSON_HAS_CXX11
+
+ template <typename U>
+ U* allocate(size_type n = 1, const void* = 0)
+ {
+ return RAPIDJSON_NAMESPACE::Malloc<U>(baseAllocator_, n);
+ }
+ template <typename U>
+ void deallocate(U* p, size_type n = 1)
+ {
+ RAPIDJSON_NAMESPACE::Free<U>(baseAllocator_, p, n);
+ }
+
+ pointer allocate(size_type n = 1, const void* = 0)
+ {
+ return allocate<value_type>(n);
+ }
+ void deallocate(pointer p, size_type n = 1)
+ {
+ deallocate<value_type>(p, n);
+ }
+
+#if RAPIDJSON_HAS_CXX11
+ using is_always_equal = std::is_empty<BaseAllocator>;
+#endif
+
+ template<typename U>
+ bool operator==(const StdAllocator<U, BaseAllocator>& rhs) const RAPIDJSON_NOEXCEPT
+ {
+ return baseAllocator_ == rhs.baseAllocator_;
+ }
+ template<typename U>
+ bool operator!=(const StdAllocator<U, BaseAllocator>& rhs) const RAPIDJSON_NOEXCEPT
+ {
+ return !operator==(rhs);
+ }
+
+ //! rapidjson Allocator concept
+ static const bool kNeedFree = BaseAllocator::kNeedFree;
+ static const bool kRefCounted = internal::IsRefCounted<BaseAllocator>::Value;
+ void* Malloc(size_t size)
+ {
+ return baseAllocator_.Malloc(size);
+ }
+ void* Realloc(void* originalPtr, size_t originalSize, size_t newSize)
+ {
+ return baseAllocator_.Realloc(originalPtr, originalSize, newSize);
+ }
+ static void Free(void *ptr) RAPIDJSON_NOEXCEPT
+ {
+ BaseAllocator::Free(ptr);
+ }
+
+private:
+ template <typename, typename>
+ friend class StdAllocator; // access to StdAllocator<!T>.*
+
+ BaseAllocator baseAllocator_;
+};
+
+#if !RAPIDJSON_HAS_CXX17 // std::allocator<void> deprecated in C++17
+template <typename BaseAllocator>
+class StdAllocator<void, BaseAllocator> :
+ public std::allocator<void>
+{
+ typedef std::allocator<void> allocator_type;
+
+public:
+ typedef BaseAllocator BaseAllocatorType;
+
+ StdAllocator() RAPIDJSON_NOEXCEPT :
+ allocator_type(),
+ baseAllocator_()
+ { }
+
+ StdAllocator(const StdAllocator& rhs) RAPIDJSON_NOEXCEPT :
+ allocator_type(rhs),
+ baseAllocator_(rhs.baseAllocator_)
+ { }
+
+ template<typename U>
+ StdAllocator(const StdAllocator<U, BaseAllocator>& rhs) RAPIDJSON_NOEXCEPT :
+ allocator_type(rhs),
+ baseAllocator_(rhs.baseAllocator_)
+ { }
+
+ /* implicit */
+ StdAllocator(const BaseAllocator& baseAllocator) RAPIDJSON_NOEXCEPT :
+ allocator_type(),
+ baseAllocator_(baseAllocator)
+ { }
+
+ ~StdAllocator() RAPIDJSON_NOEXCEPT
+ { }
+
+ template<typename U>
+ struct rebind {
+ typedef StdAllocator<U, BaseAllocator> other;
+ };
+
+ typedef typename allocator_type::value_type value_type;
+
+private:
+ template <typename, typename>
+ friend class StdAllocator; // access to StdAllocator<!T>.*
+
+ BaseAllocator baseAllocator_;
+};
+#endif
+
+#ifdef __GNUC__
+RAPIDJSON_DIAG_POP
+#endif
+
RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_ENCODINGS_H_
diff --git a/contrib/rapidjson/include/rapidjson/document.h b/contrib/rapidjson/include/rapidjson/document.h
index 028235ec6..f183749ad 100644
--- a/contrib/rapidjson/include/rapidjson/document.h
+++ b/contrib/rapidjson/include/rapidjson/document.h
@@ -42,12 +42,21 @@ RAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible lo
RAPIDJSON_DIAG_OFF(effc++)
#endif // __GNUC__
+#ifdef GetObject
+// see https://github.com/Tencent/rapidjson/issues/1448
+// a former included windows.h might have defined a macro called GetObject, which affects
+// GetObject defined here. This ensures the macro does not get applied
+#pragma push_macro("GetObject")
+#define RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
+#undef GetObject
+#endif
+
#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
#include <iterator> // std::random_access_iterator_tag
#endif
-#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
-#include <utility> // std::move
+#if RAPIDJSON_USE_MEMBERSMAP
+#include <map> // std::multimap
#endif
RAPIDJSON_NAMESPACE_BEGIN
@@ -66,7 +75,7 @@ class GenericDocument;
User can define this to use CrtAllocator or MemoryPoolAllocator.
*/
#ifndef RAPIDJSON_DEFAULT_ALLOCATOR
-#define RAPIDJSON_DEFAULT_ALLOCATOR MemoryPoolAllocator<CrtAllocator>
+#define RAPIDJSON_DEFAULT_ALLOCATOR ::RAPIDJSON_NAMESPACE::MemoryPoolAllocator<::RAPIDJSON_NAMESPACE::CrtAllocator>
#endif
/*! \def RAPIDJSON_DEFAULT_STACK_ALLOCATOR
@@ -76,7 +85,7 @@ class GenericDocument;
User can define this to use CrtAllocator or MemoryPoolAllocator.
*/
#ifndef RAPIDJSON_DEFAULT_STACK_ALLOCATOR
-#define RAPIDJSON_DEFAULT_STACK_ALLOCATOR CrtAllocator
+#define RAPIDJSON_DEFAULT_STACK_ALLOCATOR ::RAPIDJSON_NAMESPACE::CrtAllocator
#endif
/*! \def RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY
@@ -732,18 +741,8 @@ public:
template <typename SourceAllocator>
GenericValue(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator& allocator, bool copyConstStrings = false) {
switch (rhs.GetType()) {
- case kObjectType: {
- SizeType count = rhs.data_.o.size;
- Member* lm = reinterpret_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
- const typename GenericValue<Encoding,SourceAllocator>::Member* rm = rhs.GetMembersPointer();
- for (SizeType i = 0; i < count; i++) {
- new (&lm[i].name) GenericValue(rm[i].name, allocator, copyConstStrings);
- new (&lm[i].value) GenericValue(rm[i].value, allocator, copyConstStrings);
- }
- data_.f.flags = kObjectFlag;
- data_.o.size = data_.o.capacity = count;
- SetMembersPointer(lm);
- }
+ case kObjectType:
+ DoCopyMembers(rhs, allocator, copyConstStrings);
break;
case kArrayType: {
SizeType count = rhs.data_.a.size;
@@ -879,25 +878,30 @@ public:
/*! Need to destruct elements of array, members of object, or copy-string.
*/
~GenericValue() {
- if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
+ // With RAPIDJSON_USE_MEMBERSMAP, the maps need to be destroyed to release
+ // their Allocator if it's refcounted (e.g. MemoryPoolAllocator).
+ if (Allocator::kNeedFree || (RAPIDJSON_USE_MEMBERSMAP+0 &&
+ internal::IsRefCounted<Allocator>::Value)) {
switch(data_.f.flags) {
case kArrayFlag:
{
GenericValue* e = GetElementsPointer();
for (GenericValue* v = e; v != e + data_.a.size; ++v)
v->~GenericValue();
- Allocator::Free(e);
+ if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
+ Allocator::Free(e);
+ }
}
break;
case kObjectFlag:
- for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
- m->~Member();
- Allocator::Free(GetMembersPointer());
+ DoFreeMembers();
break;
case kCopyStringFlag:
- Allocator::Free(const_cast<Ch*>(GetStringPointer()));
+ if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
+ Allocator::Free(const_cast<Ch*>(GetStringPointer()));
+ }
break;
default:
@@ -916,8 +920,13 @@ public:
*/
GenericValue& operator=(GenericValue& rhs) RAPIDJSON_NOEXCEPT {
if (RAPIDJSON_LIKELY(this != &rhs)) {
+ // Can't destroy "this" before assigning "rhs", otherwise "rhs"
+ // could be used after free if it's an sub-Value of "this",
+ // hence the temporary danse.
+ GenericValue temp;
+ temp.RawAssign(rhs);
this->~GenericValue();
- RawAssign(rhs);
+ RawAssign(temp);
}
return *this;
}
@@ -1024,7 +1033,7 @@ public:
return false;
for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
- if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
+ if (rhsMemberItr == rhs.MemberEnd() || (!(lhsMemberItr->value == rhsMemberItr->value)))
return false;
}
return true;
@@ -1033,7 +1042,7 @@ public:
if (data_.a.size != rhs.data_.a.size)
return false;
for (SizeType i = 0; i < data_.a.size; i++)
- if ((*this)[i] != rhs[i])
+ if (!((*this)[i] == rhs[i]))
return false;
return true;
@@ -1069,6 +1078,7 @@ public:
*/
template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,internal::IsGenericValue<T> >), (bool)) operator==(const T& rhs) const { return *this == GenericValue(rhs); }
+#ifndef __cpp_impl_three_way_comparison
//! Not-equal-to operator
/*! \return !(*this == rhs)
*/
@@ -1093,6 +1103,7 @@ public:
*/
template <typename T> friend RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& lhs, const GenericValue& rhs) { return !(rhs == lhs); }
//@}
+#endif
//!@name Type
//@{
@@ -1219,13 +1230,28 @@ public:
else {
RAPIDJSON_ASSERT(false); // see above note
- // This will generate -Wexit-time-destructors in clang
- // static GenericValue NullValue;
- // return NullValue;
-
- // Use static buffer and placement-new to prevent destruction
- static char buffer[sizeof(GenericValue)];
+#if RAPIDJSON_HAS_CXX11
+ // Use thread-local storage to prevent races between threads.
+ // Use static buffer and placement-new to prevent destruction, with
+ // alignas() to ensure proper alignment.
+ alignas(GenericValue) thread_local static char buffer[sizeof(GenericValue)];
+ return *new (buffer) GenericValue();
+#elif defined(_MSC_VER) && _MSC_VER < 1900
+ // There's no way to solve both thread locality and proper alignment
+ // simultaneously.
+ __declspec(thread) static char buffer[sizeof(GenericValue)];
return *new (buffer) GenericValue();
+#elif defined(__GNUC__) || defined(__clang__)
+ // This will generate -Wexit-time-destructors in clang, but that's
+ // better than having under-alignment.
+ __thread static GenericValue buffer;
+ return buffer;
+#else
+ // Don't know what compiler this is, so don't know how to ensure
+ // thread-locality.
+ static GenericValue buffer;
+ return buffer;
+#endif
}
}
template <typename SourceAllocator>
@@ -1258,10 +1284,7 @@ public:
*/
GenericValue& MemberReserve(SizeType newCapacity, Allocator &allocator) {
RAPIDJSON_ASSERT(IsObject());
- if (newCapacity > data_.o.capacity) {
- SetMembersPointer(reinterpret_cast<Member*>(allocator.Realloc(GetMembersPointer(), data_.o.capacity * sizeof(Member), newCapacity * sizeof(Member))));
- data_.o.capacity = newCapacity;
- }
+ DoReserveMembers(newCapacity, allocator);
return *this;
}
@@ -1335,11 +1358,7 @@ public:
MemberIterator FindMember(const GenericValue<Encoding, SourceAllocator>& name) {
RAPIDJSON_ASSERT(IsObject());
RAPIDJSON_ASSERT(name.IsString());
- MemberIterator member = MemberBegin();
- for ( ; member != MemberEnd(); ++member)
- if (name.StringEqual(member->name))
- break;
- return member;
+ return DoFindMember(name);
}
template <typename SourceAllocator> ConstMemberIterator FindMember(const GenericValue<Encoding, SourceAllocator>& name) const { return const_cast<GenericValue&>(*this).FindMember(name); }
@@ -1368,14 +1387,7 @@ public:
GenericValue& AddMember(GenericValue& name, GenericValue& value, Allocator& allocator) {
RAPIDJSON_ASSERT(IsObject());
RAPIDJSON_ASSERT(name.IsString());
-
- ObjectData& o = data_.o;
- if (o.size >= o.capacity)
- MemberReserve(o.capacity == 0 ? kDefaultObjectCapacity : (o.capacity + (o.capacity + 1) / 2), allocator);
- Member* members = GetMembersPointer();
- members[o.size].name.RawAssign(name);
- members[o.size].value.RawAssign(value);
- o.size++;
+ DoAddMember(name, value, allocator);
return *this;
}
@@ -1509,9 +1521,7 @@ public:
*/
void RemoveAllMembers() {
RAPIDJSON_ASSERT(IsObject());
- for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
- m->~Member();
- data_.o.size = 0;
+ DoClearMembers();
}
//! Remove a member in object by its name.
@@ -1555,14 +1565,7 @@ public:
RAPIDJSON_ASSERT(data_.o.size > 0);
RAPIDJSON_ASSERT(GetMembersPointer() != 0);
RAPIDJSON_ASSERT(m >= MemberBegin() && m < MemberEnd());
-
- MemberIterator last(GetMembersPointer() + (data_.o.size - 1));
- if (data_.o.size > 1 && m != last)
- *m = *last; // Move the last one to this place
- else
- m->~Member(); // Only one left, just destroy
- --data_.o.size;
- return m;
+ return DoRemoveMember(m);
}
//! Remove a member from an object by iterator.
@@ -1594,13 +1597,7 @@ public:
RAPIDJSON_ASSERT(first >= MemberBegin());
RAPIDJSON_ASSERT(first <= last);
RAPIDJSON_ASSERT(last <= MemberEnd());
-
- MemberIterator pos = MemberBegin() + (first - MemberBegin());
- for (MemberIterator itr = pos; itr != last; ++itr)
- itr->~Member();
- std::memmove(static_cast<void*>(&*pos), &*last, static_cast<size_t>(MemberEnd() - last) * sizeof(Member));
- data_.o.size -= static_cast<SizeType>(last - first);
- return pos;
+ return DoEraseMembers(first, last);
}
//! Erase a member in object by its name.
@@ -1629,7 +1626,9 @@ public:
}
Object GetObject() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); }
+ Object GetObj() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); }
ConstObject GetObject() const { RAPIDJSON_ASSERT(IsObject()); return ConstObject(*this); }
+ ConstObject GetObj() const { RAPIDJSON_ASSERT(IsObject()); return ConstObject(*this); }
//@}
@@ -1851,12 +1850,12 @@ public:
//!@name String
//@{
- const Ch* GetString() const { RAPIDJSON_ASSERT(IsString()); return (data_.f.flags & kInlineStrFlag) ? data_.ss.str : GetStringPointer(); }
+ const Ch* GetString() const { RAPIDJSON_ASSERT(IsString()); return DataString(data_); }
//! Get the length of string.
/*! Since rapidjson permits "\\u0000" in the json string, strlen(v.GetString()) may not equal to v.GetStringLength().
*/
- SizeType GetStringLength() const { RAPIDJSON_ASSERT(IsString()); return ((data_.f.flags & kInlineStrFlag) ? (data_.ss.GetLength()) : data_.s.length); }
+ SizeType GetStringLength() const { RAPIDJSON_ASSERT(IsString()); return DataStringLength(data_); }
//! Set this value as a string without copying source string.
/*! This version has better performance with supplied length, and also support string containing null character.
@@ -1967,7 +1966,7 @@ public:
case kArrayType:
if (RAPIDJSON_UNLIKELY(!handler.StartArray()))
return false;
- for (const GenericValue* v = Begin(); v != End(); ++v)
+ for (ConstValueIterator v = Begin(); v != End(); ++v)
if (RAPIDJSON_UNLIKELY(!v->Accept(handler)))
return false;
return handler.EndArray(data_.a.size);
@@ -2105,6 +2104,13 @@ private:
Flag f;
}; // 16 bytes in 32-bit mode, 24 bytes in 64-bit mode, 16 bytes in 64-bit with RAPIDJSON_48BITPOINTER_OPTIMIZATION
+ static RAPIDJSON_FORCEINLINE const Ch* DataString(const Data& data) {
+ return (data.f.flags & kInlineStrFlag) ? data.ss.str : RAPIDJSON_GETPOINTER(Ch, data.s.str);
+ }
+ static RAPIDJSON_FORCEINLINE SizeType DataStringLength(const Data& data) {
+ return (data.f.flags & kInlineStrFlag) ? data.ss.GetLength() : data.s.length;
+ }
+
RAPIDJSON_FORCEINLINE const Ch* GetStringPointer() const { return RAPIDJSON_GETPOINTER(Ch, data_.s.str); }
RAPIDJSON_FORCEINLINE const Ch* SetStringPointer(const Ch* str) { return RAPIDJSON_SETPOINTER(Ch, data_.s.str, str); }
RAPIDJSON_FORCEINLINE GenericValue* GetElementsPointer() const { return RAPIDJSON_GETPOINTER(GenericValue, data_.a.elements); }
@@ -2112,6 +2118,286 @@ private:
RAPIDJSON_FORCEINLINE Member* GetMembersPointer() const { return RAPIDJSON_GETPOINTER(Member, data_.o.members); }
RAPIDJSON_FORCEINLINE Member* SetMembersPointer(Member* members) { return RAPIDJSON_SETPOINTER(Member, data_.o.members, members); }
+#if RAPIDJSON_USE_MEMBERSMAP
+
+ struct MapTraits {
+ struct Less {
+ bool operator()(const Data& s1, const Data& s2) const {
+ SizeType n1 = DataStringLength(s1), n2 = DataStringLength(s2);
+ int cmp = std::memcmp(DataString(s1), DataString(s2), sizeof(Ch) * (n1 < n2 ? n1 : n2));
+ return cmp < 0 || (cmp == 0 && n1 < n2);
+ }
+ };
+ typedef std::pair<const Data, SizeType> Pair;
+ typedef std::multimap<Data, SizeType, Less, StdAllocator<Pair, Allocator> > Map;
+ typedef typename Map::iterator Iterator;
+ };
+ typedef typename MapTraits::Map Map;
+ typedef typename MapTraits::Less MapLess;
+ typedef typename MapTraits::Pair MapPair;
+ typedef typename MapTraits::Iterator MapIterator;
+
+ //
+ // Layout of the members' map/array, re(al)located according to the needed capacity:
+ //
+ // {Map*}<>{capacity}<>{Member[capacity]}<>{MapIterator[capacity]}
+ //
+ // (where <> stands for the RAPIDJSON_ALIGN-ment, if needed)
+ //
+
+ static RAPIDJSON_FORCEINLINE size_t GetMapLayoutSize(SizeType capacity) {
+ return RAPIDJSON_ALIGN(sizeof(Map*)) +
+ RAPIDJSON_ALIGN(sizeof(SizeType)) +
+ RAPIDJSON_ALIGN(capacity * sizeof(Member)) +
+ capacity * sizeof(MapIterator);
+ }
+
+ static RAPIDJSON_FORCEINLINE SizeType &GetMapCapacity(Map* &map) {
+ return *reinterpret_cast<SizeType*>(reinterpret_cast<uintptr_t>(&map) +
+ RAPIDJSON_ALIGN(sizeof(Map*)));
+ }
+
+ static RAPIDJSON_FORCEINLINE Member* GetMapMembers(Map* &map) {
+ return reinterpret_cast<Member*>(reinterpret_cast<uintptr_t>(&map) +
+ RAPIDJSON_ALIGN(sizeof(Map*)) +
+ RAPIDJSON_ALIGN(sizeof(SizeType)));
+ }
+
+ static RAPIDJSON_FORCEINLINE MapIterator* GetMapIterators(Map* &map) {
+ return reinterpret_cast<MapIterator*>(reinterpret_cast<uintptr_t>(&map) +
+ RAPIDJSON_ALIGN(sizeof(Map*)) +
+ RAPIDJSON_ALIGN(sizeof(SizeType)) +
+ RAPIDJSON_ALIGN(GetMapCapacity(map) * sizeof(Member)));
+ }
+
+ static RAPIDJSON_FORCEINLINE Map* &GetMap(Member* members) {
+ RAPIDJSON_ASSERT(members != 0);
+ return *reinterpret_cast<Map**>(reinterpret_cast<uintptr_t>(members) -
+ RAPIDJSON_ALIGN(sizeof(SizeType)) -
+ RAPIDJSON_ALIGN(sizeof(Map*)));
+ }
+
+ // Some compilers' debug mechanisms want all iterators to be destroyed, for their accounting..
+ RAPIDJSON_FORCEINLINE MapIterator DropMapIterator(MapIterator& rhs) {
+#if RAPIDJSON_HAS_CXX11
+ MapIterator ret = std::move(rhs);
+#else
+ MapIterator ret = rhs;
+#endif
+ rhs.~MapIterator();
+ return ret;
+ }
+
+ Map* &DoReallocMap(Map** oldMap, SizeType newCapacity, Allocator& allocator) {
+ Map **newMap = static_cast<Map**>(allocator.Malloc(GetMapLayoutSize(newCapacity)));
+ GetMapCapacity(*newMap) = newCapacity;
+ if (!oldMap) {
+ *newMap = new (allocator.Malloc(sizeof(Map))) Map(MapLess(), allocator);
+ }
+ else {
+ *newMap = *oldMap;
+ size_t count = (*oldMap)->size();
+ std::memcpy(static_cast<void*>(GetMapMembers(*newMap)),
+ static_cast<void*>(GetMapMembers(*oldMap)),
+ count * sizeof(Member));
+ MapIterator *oldIt = GetMapIterators(*oldMap),
+ *newIt = GetMapIterators(*newMap);
+ while (count--) {
+ new (&newIt[count]) MapIterator(DropMapIterator(oldIt[count]));
+ }
+ Allocator::Free(oldMap);
+ }
+ return *newMap;
+ }
+
+ RAPIDJSON_FORCEINLINE Member* DoAllocMembers(SizeType capacity, Allocator& allocator) {
+ return GetMapMembers(DoReallocMap(0, capacity, allocator));
+ }
+
+ void DoReserveMembers(SizeType newCapacity, Allocator& allocator) {
+ ObjectData& o = data_.o;
+ if (newCapacity > o.capacity) {
+ Member* oldMembers = GetMembersPointer();
+ Map **oldMap = oldMembers ? &GetMap(oldMembers) : 0,
+ *&newMap = DoReallocMap(oldMap, newCapacity, allocator);
+ RAPIDJSON_SETPOINTER(Member, o.members, GetMapMembers(newMap));
+ o.capacity = newCapacity;
+ }
+ }
+
+ template <typename SourceAllocator>
+ MemberIterator DoFindMember(const GenericValue<Encoding, SourceAllocator>& name) {
+ if (Member* members = GetMembersPointer()) {
+ Map* &map = GetMap(members);
+ MapIterator mit = map->find(reinterpret_cast<const Data&>(name.data_));
+ if (mit != map->end()) {
+ return MemberIterator(&members[mit->second]);
+ }
+ }
+ return MemberEnd();
+ }
+
+ void DoClearMembers() {
+ if (Member* members = GetMembersPointer()) {
+ Map* &map = GetMap(members);
+ MapIterator* mit = GetMapIterators(map);
+ for (SizeType i = 0; i < data_.o.size; i++) {
+ map->erase(DropMapIterator(mit[i]));
+ members[i].~Member();
+ }
+ data_.o.size = 0;
+ }
+ }
+
+ void DoFreeMembers() {
+ if (Member* members = GetMembersPointer()) {
+ GetMap(members)->~Map();
+ for (SizeType i = 0; i < data_.o.size; i++) {
+ members[i].~Member();
+ }
+ if (Allocator::kNeedFree) { // Shortcut by Allocator's trait
+ Map** map = &GetMap(members);
+ Allocator::Free(*map);
+ Allocator::Free(map);
+ }
+ }
+ }
+
+#else // !RAPIDJSON_USE_MEMBERSMAP
+
+ RAPIDJSON_FORCEINLINE Member* DoAllocMembers(SizeType capacity, Allocator& allocator) {
+ return Malloc<Member>(allocator, capacity);
+ }
+
+ void DoReserveMembers(SizeType newCapacity, Allocator& allocator) {
+ ObjectData& o = data_.o;
+ if (newCapacity > o.capacity) {
+ Member* newMembers = Realloc<Member>(allocator, GetMembersPointer(), o.capacity, newCapacity);
+ RAPIDJSON_SETPOINTER(Member, o.members, newMembers);
+ o.capacity = newCapacity;
+ }
+ }
+
+ template <typename SourceAllocator>
+ MemberIterator DoFindMember(const GenericValue<Encoding, SourceAllocator>& name) {
+ MemberIterator member = MemberBegin();
+ for ( ; member != MemberEnd(); ++member)
+ if (name.StringEqual(member->name))
+ break;
+ return member;
+ }
+
+ void DoClearMembers() {
+ for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
+ m->~Member();
+ data_.o.size = 0;
+ }
+
+ void DoFreeMembers() {
+ for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
+ m->~Member();
+ Allocator::Free(GetMembersPointer());
+ }
+
+#endif // !RAPIDJSON_USE_MEMBERSMAP
+
+ void DoAddMember(GenericValue& name, GenericValue& value, Allocator& allocator) {
+ ObjectData& o = data_.o;
+ if (o.size >= o.capacity)
+ DoReserveMembers(o.capacity ? (o.capacity + (o.capacity + 1) / 2) : kDefaultObjectCapacity, allocator);
+ Member* members = GetMembersPointer();
+ Member* m = members + o.size;
+ m->name.RawAssign(name);
+ m->value.RawAssign(value);
+#if RAPIDJSON_USE_MEMBERSMAP
+ Map* &map = GetMap(members);
+ MapIterator* mit = GetMapIterators(map);
+ new (&mit[o.size]) MapIterator(map->insert(MapPair(m->name.data_, o.size)));
+#endif
+ ++o.size;
+ }
+
+ MemberIterator DoRemoveMember(MemberIterator m) {
+ ObjectData& o = data_.o;
+ Member* members = GetMembersPointer();
+#if RAPIDJSON_USE_MEMBERSMAP
+ Map* &map = GetMap(members);
+ MapIterator* mit = GetMapIterators(map);
+ SizeType mpos = static_cast<SizeType>(&*m - members);
+ map->erase(DropMapIterator(mit[mpos]));
+#endif
+ MemberIterator last(members + (o.size - 1));
+ if (o.size > 1 && m != last) {
+#if RAPIDJSON_USE_MEMBERSMAP
+ new (&mit[mpos]) MapIterator(DropMapIterator(mit[&*last - members]));
+ mit[mpos]->second = mpos;
+#endif
+ *m = *last; // Move the last one to this place
+ }
+ else {
+ m->~Member(); // Only one left, just destroy
+ }
+ --o.size;
+ return m;
+ }
+
+ MemberIterator DoEraseMembers(ConstMemberIterator first, ConstMemberIterator last) {
+ ObjectData& o = data_.o;
+ MemberIterator beg = MemberBegin(),
+ pos = beg + (first - beg),
+ end = MemberEnd();
+#if RAPIDJSON_USE_MEMBERSMAP
+ Map* &map = GetMap(GetMembersPointer());
+ MapIterator* mit = GetMapIterators(map);
+#endif
+ for (MemberIterator itr = pos; itr != last; ++itr) {
+#if RAPIDJSON_USE_MEMBERSMAP
+ map->erase(DropMapIterator(mit[itr - beg]));
+#endif
+ itr->~Member();
+ }
+#if RAPIDJSON_USE_MEMBERSMAP
+ if (first != last) {
+ // Move remaining members/iterators
+ MemberIterator next = pos + (last - first);
+ for (MemberIterator itr = pos; next != end; ++itr, ++next) {
+ std::memcpy(static_cast<void*>(&*itr), &*next, sizeof(Member));
+ SizeType mpos = static_cast<SizeType>(itr - beg);
+ new (&mit[mpos]) MapIterator(DropMapIterator(mit[next - beg]));
+ mit[mpos]->second = mpos;
+ }
+ }
+#else
+ std::memmove(static_cast<void*>(&*pos), &*last,
+ static_cast<size_t>(end - last) * sizeof(Member));
+#endif
+ o.size -= static_cast<SizeType>(last - first);
+ return pos;
+ }
+
+ template <typename SourceAllocator>
+ void DoCopyMembers(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator& allocator, bool copyConstStrings) {
+ RAPIDJSON_ASSERT(rhs.GetType() == kObjectType);
+
+ data_.f.flags = kObjectFlag;
+ SizeType count = rhs.data_.o.size;
+ Member* lm = DoAllocMembers(count, allocator);
+ const typename GenericValue<Encoding,SourceAllocator>::Member* rm = rhs.GetMembersPointer();
+#if RAPIDJSON_USE_MEMBERSMAP
+ Map* &map = GetMap(lm);
+ MapIterator* mit = GetMapIterators(map);
+#endif
+ for (SizeType i = 0; i < count; i++) {
+ new (&lm[i].name) GenericValue(rm[i].name, allocator, copyConstStrings);
+ new (&lm[i].value) GenericValue(rm[i].value, allocator, copyConstStrings);
+#if RAPIDJSON_USE_MEMBERSMAP
+ new (&mit[i]) MapIterator(map->insert(MapPair(lm[i].name.data_, i)));
+#endif
+ }
+ data_.o.size = data_.o.capacity = count;
+ SetMembersPointer(lm);
+ }
+
// Initialize this value as array with initial data, without calling destructor.
void SetArrayRaw(GenericValue* values, SizeType count, Allocator& allocator) {
data_.f.flags = kArrayFlag;
@@ -2129,9 +2415,16 @@ private:
void SetObjectRaw(Member* members, SizeType count, Allocator& allocator) {
data_.f.flags = kObjectFlag;
if (count) {
- Member* m = static_cast<Member*>(allocator.Malloc(count * sizeof(Member)));
+ Member* m = DoAllocMembers(count, allocator);
SetMembersPointer(m);
std::memcpy(static_cast<void*>(m), members, count * sizeof(Member));
+#if RAPIDJSON_USE_MEMBERSMAP
+ Map* &map = GetMap(m);
+ MapIterator* mit = GetMapIterators(map);
+ for (SizeType i = 0; i < count; i++) {
+ new (&mit[i]) MapIterator(map->insert(MapPair(m[i].name.data_, i)));
+ }
+#endif
}
else
SetMembersPointer(0);
@@ -2208,6 +2501,7 @@ public:
typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding.
typedef GenericValue<Encoding, Allocator> ValueType; //!< Value type of the document.
typedef Allocator AllocatorType; //!< Allocator type from template parameter.
+ typedef StackAllocator StackAllocatorType; //!< StackAllocator type from template parameter.
//! Constructor
/*! Creates an empty document of specified type.
@@ -2252,6 +2546,13 @@ public:
#endif
~GenericDocument() {
+ // Clear the ::ValueType before ownAllocator is destroyed, ~ValueType()
+ // runs last and may access its elements or members which would be freed
+ // with an allocator like MemoryPoolAllocator (CrtAllocator does not
+ // free its data when destroyed, but MemoryPoolAllocator does).
+ if (ownAllocator_) {
+ ValueType::SetNull();
+ }
Destroy();
}
@@ -2734,4 +3035,9 @@ private:
RAPIDJSON_NAMESPACE_END
RAPIDJSON_DIAG_POP
+#ifdef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
+#pragma pop_macro("GetObject")
+#undef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
+#endif
+
#endif // RAPIDJSON_DOCUMENT_H_
diff --git a/contrib/rapidjson/include/rapidjson/error/en.h b/contrib/rapidjson/include/rapidjson/error/en.h
index 5d2e57b7f..c87b04eb1 100644
--- a/contrib/rapidjson/include/rapidjson/error/en.h
+++ b/contrib/rapidjson/include/rapidjson/error/en.h
@@ -1,5 +1,5 @@
// Tencent is pleased to support the open source community by making RapidJSON available.
-//
+//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
//
// Licensed under the MIT License (the "License"); you may not use this file except
@@ -7,9 +7,9 @@
//
// http://opensource.org/licenses/MIT
//
-// Unless required by applicable law or agreed to in writing, software distributed
-// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-// CONDITIONS OF ANY KIND, either express or implied. See the License for the
+// Unless required by applicable law or agreed to in writing, software distributed
+// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#ifndef RAPIDJSON_ERROR_EN_H_
@@ -39,13 +39,13 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErro
case kParseErrorDocumentEmpty: return RAPIDJSON_ERROR_STRING("The document is empty.");
case kParseErrorDocumentRootNotSingular: return RAPIDJSON_ERROR_STRING("The document root must not be followed by other values.");
-
+
case kParseErrorValueInvalid: return RAPIDJSON_ERROR_STRING("Invalid value.");
-
+
case kParseErrorObjectMissName: return RAPIDJSON_ERROR_STRING("Missing a name for object member.");
case kParseErrorObjectMissColon: return RAPIDJSON_ERROR_STRING("Missing a colon after a name of object member.");
case kParseErrorObjectMissCommaOrCurlyBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or '}' after an object member.");
-
+
case kParseErrorArrayMissCommaOrSquareBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or ']' after an array element.");
case kParseErrorStringUnicodeEscapeInvalidHex: return RAPIDJSON_ERROR_STRING("Incorrect hex digit after \\u escape in string.");
@@ -104,15 +104,69 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetValidateError_En(ValidateErrorCode val
case kValidateErrorType: return RAPIDJSON_ERROR_STRING("Property has a type '%actual' that is not in the following list: '%expected'.");
case kValidateErrorOneOf: return RAPIDJSON_ERROR_STRING("Property did not match any of the sub-schemas specified by 'oneOf', refer to following errors.");
- case kValidateErrorOneOfMatch: return RAPIDJSON_ERROR_STRING("Property matched more than one of the sub-schemas specified by 'oneOf'.");
+ case kValidateErrorOneOfMatch: return RAPIDJSON_ERROR_STRING("Property matched more than one of the sub-schemas specified by 'oneOf', indices '%matches'.");
case kValidateErrorAllOf: return RAPIDJSON_ERROR_STRING("Property did not match all of the sub-schemas specified by 'allOf', refer to following errors.");
case kValidateErrorAnyOf: return RAPIDJSON_ERROR_STRING("Property did not match any of the sub-schemas specified by 'anyOf', refer to following errors.");
case kValidateErrorNot: return RAPIDJSON_ERROR_STRING("Property matched the sub-schema specified by 'not'.");
+ case kValidateErrorReadOnly: return RAPIDJSON_ERROR_STRING("Property is read-only but has been provided when validation is for writing.");
+ case kValidateErrorWriteOnly: return RAPIDJSON_ERROR_STRING("Property is write-only but has been provided when validation is for reading.");
+
default: return RAPIDJSON_ERROR_STRING("Unknown error.");
}
}
+//! Maps error code of schema document compilation into error message.
+/*!
+ \ingroup RAPIDJSON_ERRORS
+ \param schemaErrorCode Error code obtained from compiling the schema document.
+ \return the error message.
+ \note User can make a copy of this function for localization.
+ Using switch-case is safer for future modification of error codes.
+*/
+ inline const RAPIDJSON_ERROR_CHARTYPE* GetSchemaError_En(SchemaErrorCode schemaErrorCode) {
+ switch (schemaErrorCode) {
+ case kSchemaErrorNone: return RAPIDJSON_ERROR_STRING("No error.");
+
+ case kSchemaErrorStartUnknown: return RAPIDJSON_ERROR_STRING("Pointer '%value' to start of schema does not resolve to a location in the document.");
+ case kSchemaErrorRefPlainName: return RAPIDJSON_ERROR_STRING("$ref fragment '%value' must be a JSON pointer.");
+ case kSchemaErrorRefInvalid: return RAPIDJSON_ERROR_STRING("$ref must not be an empty string.");
+ case kSchemaErrorRefPointerInvalid: return RAPIDJSON_ERROR_STRING("$ref fragment '%value' is not a valid JSON pointer at offset '%offset'.");
+ case kSchemaErrorRefUnknown: return RAPIDJSON_ERROR_STRING("$ref '%value' does not resolve to a location in the target document.");
+ case kSchemaErrorRefCyclical: return RAPIDJSON_ERROR_STRING("$ref '%value' is cyclical.");
+ case kSchemaErrorRefNoRemoteProvider: return RAPIDJSON_ERROR_STRING("$ref is remote but there is no remote provider.");
+ case kSchemaErrorRefNoRemoteSchema: return RAPIDJSON_ERROR_STRING("$ref '%value' is remote but the remote provider did not return a schema.");
+ case kSchemaErrorRegexInvalid: return RAPIDJSON_ERROR_STRING("Invalid regular expression '%value' in 'pattern' or 'patternProperties'.");
+ case kSchemaErrorSpecUnknown: return RAPIDJSON_ERROR_STRING("JSON schema draft or OpenAPI version is not recognized.");
+ case kSchemaErrorSpecUnsupported: return RAPIDJSON_ERROR_STRING("JSON schema draft or OpenAPI version is not supported.");
+ case kSchemaErrorSpecIllegal: return RAPIDJSON_ERROR_STRING("Both JSON schema draft and OpenAPI version found in document.");
+ case kSchemaErrorReadOnlyAndWriteOnly: return RAPIDJSON_ERROR_STRING("Property must not be both 'readOnly' and 'writeOnly'.");
+
+ default: return RAPIDJSON_ERROR_STRING("Unknown error.");
+ }
+ }
+
+//! Maps error code of pointer parse into error message.
+/*!
+ \ingroup RAPIDJSON_ERRORS
+ \param pointerParseErrorCode Error code obtained from pointer parse.
+ \return the error message.
+ \note User can make a copy of this function for localization.
+ Using switch-case is safer for future modification of error codes.
+*/
+inline const RAPIDJSON_ERROR_CHARTYPE* GetPointerParseError_En(PointerParseErrorCode pointerParseErrorCode) {
+ switch (pointerParseErrorCode) {
+ case kPointerParseErrorNone: return RAPIDJSON_ERROR_STRING("No error.");
+
+ case kPointerParseErrorTokenMustBeginWithSolidus: return RAPIDJSON_ERROR_STRING("A token must begin with a '/'.");
+ case kPointerParseErrorInvalidEscape: return RAPIDJSON_ERROR_STRING("Invalid escape.");
+ case kPointerParseErrorInvalidPercentEncoding: return RAPIDJSON_ERROR_STRING("Invalid percent encoding in URI fragment.");
+ case kPointerParseErrorCharacterMustPercentEncode: return RAPIDJSON_ERROR_STRING("A character must be percent encoded in a URI fragment.");
+
+ default: return RAPIDJSON_ERROR_STRING("Unknown error.");
+ }
+}
+
RAPIDJSON_NAMESPACE_END
#ifdef __clang__
diff --git a/contrib/rapidjson/include/rapidjson/error/error.h b/contrib/rapidjson/include/rapidjson/error/error.h
index 6270da11a..cae345db3 100644
--- a/contrib/rapidjson/include/rapidjson/error/error.h
+++ b/contrib/rapidjson/include/rapidjson/error/error.h
@@ -1,5 +1,5 @@
// Tencent is pleased to support the open source community by making RapidJSON available.
-//
+//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
//
// Licensed under the MIT License (the "License"); you may not use this file except
@@ -7,9 +7,9 @@
//
// http://opensource.org/licenses/MIT
//
-// Unless required by applicable law or agreed to in writing, software distributed
-// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-// CONDITIONS OF ANY KIND, either express or implied. See the License for the
+// Unless required by applicable law or agreed to in writing, software distributed
+// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#ifndef RAPIDJSON_ERROR_ERROR_H_
@@ -42,7 +42,7 @@ RAPIDJSON_DIAG_OFF(padded)
///////////////////////////////////////////////////////////////////////////////
// RAPIDJSON_ERROR_STRING
-//! Macro for converting string literial to \ref RAPIDJSON_ERROR_CHARTYPE[].
+//! Macro for converting string literal to \ref RAPIDJSON_ERROR_CHARTYPE[].
/*! \ingroup RAPIDJSON_ERRORS
By default this conversion macro does nothing.
On Windows, user can define this macro as \c _T(x) for supporting both
@@ -185,14 +185,17 @@ enum ValidateErrorCode {
kValidateErrorPatternProperties, //!< See other errors.
kValidateErrorDependencies, //!< Object has missing property or schema dependencies.
- kValidateErrorEnum, //!< Property has a value that is not one of its allowed enumerated values
- kValidateErrorType, //!< Property has a type that is not allowed by the schema..
+ kValidateErrorEnum, //!< Property has a value that is not one of its allowed enumerated values.
+ kValidateErrorType, //!< Property has a type that is not allowed by the schema.
kValidateErrorOneOf, //!< Property did not match any of the sub-schemas specified by 'oneOf'.
kValidateErrorOneOfMatch, //!< Property matched more than one of the sub-schemas specified by 'oneOf'.
kValidateErrorAllOf, //!< Property did not match all of the sub-schemas specified by 'allOf'.
kValidateErrorAnyOf, //!< Property did not match any of the sub-schemas specified by 'anyOf'.
- kValidateErrorNot //!< Property matched the sub-schema specified by 'not'.
+ kValidateErrorNot, //!< Property matched the sub-schema specified by 'not'.
+
+ kValidateErrorReadOnly, //!< Property is read-only but has been provided when validation is for writing
+ kValidateErrorWriteOnly //!< Property is write-only but has been provided when validation is for reading
};
//! Function pointer type of GetValidateError().
@@ -207,6 +210,72 @@ enum ValidateErrorCode {
*/
typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetValidateErrorFunc)(ValidateErrorCode);
+///////////////////////////////////////////////////////////////////////////////
+// SchemaErrorCode
+
+//! Error codes when validating.
+/*! \ingroup RAPIDJSON_ERRORS
+ \see GenericSchemaValidator
+*/
+enum SchemaErrorCode {
+ kSchemaErrorNone = 0, //!< No error.
+
+ kSchemaErrorStartUnknown, //!< Pointer to start of schema does not resolve to a location in the document
+ kSchemaErrorRefPlainName, //!< $ref fragment must be a JSON pointer
+ kSchemaErrorRefInvalid, //!< $ref must not be an empty string
+ kSchemaErrorRefPointerInvalid, //!< $ref fragment is not a valid JSON pointer at offset
+ kSchemaErrorRefUnknown, //!< $ref does not resolve to a location in the target document
+ kSchemaErrorRefCyclical, //!< $ref is cyclical
+ kSchemaErrorRefNoRemoteProvider, //!< $ref is remote but there is no remote provider
+ kSchemaErrorRefNoRemoteSchema, //!< $ref is remote but the remote provider did not return a schema
+ kSchemaErrorRegexInvalid, //!< Invalid regular expression in 'pattern' or 'patternProperties'
+ kSchemaErrorSpecUnknown, //!< JSON schema draft or OpenAPI version is not recognized
+ kSchemaErrorSpecUnsupported, //!< JSON schema draft or OpenAPI version is not supported
+ kSchemaErrorSpecIllegal, //!< Both JSON schema draft and OpenAPI version found in document
+ kSchemaErrorReadOnlyAndWriteOnly //!< Property must not be both 'readOnly' and 'writeOnly'
+};
+
+//! Function pointer type of GetSchemaError().
+/*! \ingroup RAPIDJSON_ERRORS
+
+ This is the prototype for \c GetSchemaError_X(), where \c X is a locale.
+ User can dynamically change locale in runtime, e.g.:
+\code
+ GetSchemaErrorFunc GetSchemaError = GetSchemaError_En; // or whatever
+ const RAPIDJSON_ERROR_CHARTYPE* s = GetSchemaError(validator.GetInvalidSchemaCode());
+\endcode
+*/
+typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetSchemaErrorFunc)(SchemaErrorCode);
+
+///////////////////////////////////////////////////////////////////////////////
+// PointerParseErrorCode
+
+//! Error code of JSON pointer parsing.
+/*! \ingroup RAPIDJSON_ERRORS
+ \see GenericPointer::GenericPointer, GenericPointer::GetParseErrorCode
+*/
+enum PointerParseErrorCode {
+ kPointerParseErrorNone = 0, //!< The parse is successful
+
+ kPointerParseErrorTokenMustBeginWithSolidus, //!< A token must begin with a '/'
+ kPointerParseErrorInvalidEscape, //!< Invalid escape
+ kPointerParseErrorInvalidPercentEncoding, //!< Invalid percent encoding in URI fragment
+ kPointerParseErrorCharacterMustPercentEncode //!< A character must percent encoded in URI fragment
+};
+
+//! Function pointer type of GetPointerParseError().
+/*! \ingroup RAPIDJSON_ERRORS
+
+ This is the prototype for \c GetPointerParseError_X(), where \c X is a locale.
+ User can dynamically change locale in runtime, e.g.:
+\code
+ GetPointerParseErrorFunc GetPointerParseError = GetPointerParseError_En; // or whatever
+ const RAPIDJSON_ERROR_CHARTYPE* s = GetPointerParseError(pointer.GetParseErrorCode());
+\endcode
+*/
+typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetPointerParseErrorFunc)(PointerParseErrorCode);
+
+
RAPIDJSON_NAMESPACE_END
#ifdef __clang__
diff --git a/contrib/rapidjson/include/rapidjson/internal/biginteger.h b/contrib/rapidjson/include/rapidjson/internal/biginteger.h
index 12455788f..4930043dc 100644
--- a/contrib/rapidjson/include/rapidjson/internal/biginteger.h
+++ b/contrib/rapidjson/include/rapidjson/internal/biginteger.h
@@ -19,7 +19,11 @@
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && defined(_M_AMD64)
#include <intrin.h> // for _umul128
+#if !defined(_ARM64EC_)
#pragma intrinsic(_umul128)
+#else
+#pragma comment(lib,"softintrin")
+#endif
#endif
RAPIDJSON_NAMESPACE_BEGIN
@@ -37,7 +41,8 @@ public:
digits_[0] = u;
}
- BigInteger(const char* decimals, size_t length) : count_(1) {
+ template<typename Ch>
+ BigInteger(const Ch* decimals, size_t length) : count_(1) {
RAPIDJSON_ASSERT(length > 0);
digits_[0] = 0;
size_t i = 0;
@@ -221,7 +226,8 @@ public:
bool IsZero() const { return count_ == 1 && digits_[0] == 0; }
private:
- void AppendDecimal64(const char* begin, const char* end) {
+ template<typename Ch>
+ void AppendDecimal64(const Ch* begin, const Ch* end) {
uint64_t u = ParseUint64(begin, end);
if (IsZero())
*this = u;
@@ -236,11 +242,12 @@ private:
digits_[count_++] = digit;
}
- static uint64_t ParseUint64(const char* begin, const char* end) {
+ template<typename Ch>
+ static uint64_t ParseUint64(const Ch* begin, const Ch* end) {
uint64_t r = 0;
- for (const char* p = begin; p != end; ++p) {
- RAPIDJSON_ASSERT(*p >= '0' && *p <= '9');
- r = r * 10u + static_cast<unsigned>(*p - '0');
+ for (const Ch* p = begin; p != end; ++p) {
+ RAPIDJSON_ASSERT(*p >= Ch('0') && *p <= Ch('9'));
+ r = r * 10u + static_cast<unsigned>(*p - Ch('0'));
}
return r;
}
@@ -252,7 +259,7 @@ private:
if (low < k)
(*outHigh)++;
return low;
-#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
+#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
__extension__ typedef unsigned __int128 uint128;
uint128 p = static_cast<uint128>(a) * static_cast<uint128>(b);
p += k;
diff --git a/contrib/rapidjson/include/rapidjson/internal/diyfp.h b/contrib/rapidjson/include/rapidjson/internal/diyfp.h
index a40797ec2..1f60fb60c 100644
--- a/contrib/rapidjson/include/rapidjson/internal/diyfp.h
+++ b/contrib/rapidjson/include/rapidjson/internal/diyfp.h
@@ -25,7 +25,11 @@
#if defined(_MSC_VER) && defined(_M_AMD64) && !defined(__INTEL_COMPILER)
#include <intrin.h>
+#if !defined(_ARM64EC_)
#pragma intrinsic(_umul128)
+#else
+#pragma comment(lib,"softintrin")
+#endif
#endif
RAPIDJSON_NAMESPACE_BEGIN
@@ -75,7 +79,7 @@ struct DiyFp {
if (l & (uint64_t(1) << 63)) // rounding
h++;
return DiyFp(h, e + rhs.e + 64);
-#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
+#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
__extension__ typedef unsigned __int128 uint128;
uint128 p = static_cast<uint128>(f) * static_cast<uint128>(rhs.f);
uint64_t h = static_cast<uint64_t>(p >> 64);
diff --git a/contrib/rapidjson/include/rapidjson/internal/dtoa.h b/contrib/rapidjson/include/rapidjson/internal/dtoa.h
index 621402fd3..cd456721a 100644
--- a/contrib/rapidjson/include/rapidjson/internal/dtoa.h
+++ b/contrib/rapidjson/include/rapidjson/internal/dtoa.h
@@ -58,7 +58,11 @@ inline int CountDecimalDigit32(uint32_t n) {
}
inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int* len, int* K) {
- static const uint32_t kPow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
+ static const uint64_t kPow10[] = { 1ULL, 10ULL, 100ULL, 1000ULL, 10000ULL, 100000ULL, 1000000ULL, 10000000ULL, 100000000ULL,
+ 1000000000ULL, 10000000000ULL, 100000000000ULL, 1000000000000ULL,
+ 10000000000000ULL, 100000000000000ULL, 1000000000000000ULL,
+ 10000000000000000ULL, 100000000000000000ULL, 1000000000000000000ULL,
+ 10000000000000000000ULL };
const DiyFp one(uint64_t(1) << -Mp.e, Mp.e);
const DiyFp wp_w = Mp - W;
uint32_t p1 = static_cast<uint32_t>(Mp.f >> -one.e);
@@ -86,7 +90,7 @@ inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buff
uint64_t tmp = (static_cast<uint64_t>(p1) << -one.e) + p2;
if (tmp <= delta) {
*K += kappa;
- GrisuRound(buffer, *len, delta, tmp, static_cast<uint64_t>(kPow10[kappa]) << -one.e, wp_w.f);
+ GrisuRound(buffer, *len, delta, tmp, kPow10[kappa] << -one.e, wp_w.f);
return;
}
}
@@ -103,7 +107,7 @@ inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buff
if (p2 < delta) {
*K += kappa;
int index = -kappa;
- GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * (index < 9 ? kPow10[index] : 0));
+ GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * (index < 20 ? kPow10[index] : 0));
return;
}
}
diff --git a/contrib/rapidjson/include/rapidjson/internal/regex.h b/contrib/rapidjson/include/rapidjson/internal/regex.h
index 6446c403a..7740dcd52 100644
--- a/contrib/rapidjson/include/rapidjson/internal/regex.h
+++ b/contrib/rapidjson/include/rapidjson/internal/regex.h
@@ -615,7 +615,7 @@ public:
RAPIDJSON_ASSERT(regex_.IsValid());
if (!allocator_)
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
- stateSet_ = static_cast<unsigned*>(allocator_->Malloc(GetStateSetSize()));
+ stateSet_ = static_cast<uint32_t*>(allocator_->Malloc(GetStateSetSize()));
state0_.template Reserve<SizeType>(regex_.stateCount_);
state1_.template Reserve<SizeType>(regex_.stateCount_);
}
diff --git a/contrib/rapidjson/include/rapidjson/internal/strfunc.h b/contrib/rapidjson/include/rapidjson/internal/strfunc.h
index baecb6cc8..b698a8f43 100644
--- a/contrib/rapidjson/include/rapidjson/internal/strfunc.h
+++ b/contrib/rapidjson/include/rapidjson/internal/strfunc.h
@@ -45,6 +45,20 @@ inline SizeType StrLen(const wchar_t* s) {
return SizeType(std::wcslen(s));
}
+//! Custom strcmpn() which works on different character types.
+/*! \tparam Ch Character type (e.g. char, wchar_t, short)
+ \param s1 Null-terminated input string.
+ \param s2 Null-terminated input string.
+ \return 0 if equal
+*/
+template<typename Ch>
+inline int StrCmp(const Ch* s1, const Ch* s2) {
+ RAPIDJSON_ASSERT(s1 != 0);
+ RAPIDJSON_ASSERT(s2 != 0);
+ while(*s1 && (*s1 == *s2)) { s1++; s2++; }
+ return static_cast<unsigned>(*s1) < static_cast<unsigned>(*s2) ? -1 : static_cast<unsigned>(*s1) > static_cast<unsigned>(*s2);
+}
+
//! Returns number of code points in a encoded string.
template<typename Encoding>
bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) {
diff --git a/contrib/rapidjson/include/rapidjson/internal/strtod.h b/contrib/rapidjson/include/rapidjson/internal/strtod.h
index d61a67a49..55f0e380b 100644
--- a/contrib/rapidjson/include/rapidjson/internal/strtod.h
+++ b/contrib/rapidjson/include/rapidjson/internal/strtod.h
@@ -128,17 +128,18 @@ inline bool StrtodFast(double d, int p, double* result) {
}
// Compute an approximation and see if it is within 1/2 ULP
-inline bool StrtodDiyFp(const char* decimals, int dLen, int dExp, double* result) {
+template<typename Ch>
+inline bool StrtodDiyFp(const Ch* decimals, int dLen, int dExp, double* result) {
uint64_t significand = 0;
int i = 0; // 2^64 - 1 = 18446744073709551615, 1844674407370955161 = 0x1999999999999999
for (; i < dLen; i++) {
if (significand > RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) ||
- (significand == RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) && decimals[i] > '5'))
+ (significand == RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) && decimals[i] > Ch('5')))
break;
- significand = significand * 10u + static_cast<unsigned>(decimals[i] - '0');
+ significand = significand * 10u + static_cast<unsigned>(decimals[i] - Ch('0'));
}
- if (i < dLen && decimals[i] >= '5') // Rounding
+ if (i < dLen && decimals[i] >= Ch('5')) // Rounding
significand++;
int remaining = dLen - i;
@@ -205,7 +206,8 @@ inline bool StrtodDiyFp(const char* decimals, int dLen, int dExp, double* result
return halfWay - static_cast<unsigned>(error) >= precisionBits || precisionBits >= halfWay + static_cast<unsigned>(error);
}
-inline double StrtodBigInteger(double approx, const char* decimals, int dLen, int dExp) {
+template<typename Ch>
+inline double StrtodBigInteger(double approx, const Ch* decimals, int dLen, int dExp) {
RAPIDJSON_ASSERT(dLen >= 0);
const BigInteger dInt(decimals, static_cast<unsigned>(dLen));
Double a(approx);
@@ -223,7 +225,8 @@ inline double StrtodBigInteger(double approx, const char* decimals, int dLen, in
return a.NextPositiveDouble();
}
-inline double StrtodFullPrecision(double d, int p, const char* decimals, size_t length, size_t decimalPosition, int exp) {
+template<typename Ch>
+inline double StrtodFullPrecision(double d, int p, const Ch* decimals, size_t length, size_t decimalPosition, int exp) {
RAPIDJSON_ASSERT(d >= 0.0);
RAPIDJSON_ASSERT(length >= 1);
diff --git a/contrib/rapidjson/include/rapidjson/pointer.h b/contrib/rapidjson/include/rapidjson/pointer.h
index 90e5903bc..6f4ef3892 100644
--- a/contrib/rapidjson/include/rapidjson/pointer.h
+++ b/contrib/rapidjson/include/rapidjson/pointer.h
@@ -16,7 +16,9 @@
#define RAPIDJSON_POINTER_H_
#include "document.h"
+#include "uri.h"
#include "internal/itoa.h"
+#include "error/error.h" // PointerParseErrorCode
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
@@ -30,19 +32,6 @@ RAPIDJSON_NAMESPACE_BEGIN
static const SizeType kPointerInvalidIndex = ~SizeType(0); //!< Represents an invalid index in GenericPointer::Token
-//! Error code of parsing.
-/*! \ingroup RAPIDJSON_ERRORS
- \see GenericPointer::GenericPointer, GenericPointer::GetParseErrorCode
-*/
-enum PointerParseErrorCode {
- kPointerParseErrorNone = 0, //!< The parse is successful
-
- kPointerParseErrorTokenMustBeginWithSolidus, //!< A token must begin with a '/'
- kPointerParseErrorInvalidEscape, //!< Invalid escape
- kPointerParseErrorInvalidPercentEncoding, //!< Invalid percent encoding in URI fragment
- kPointerParseErrorCharacterMustPercentEncode //!< A character must percent encoded in URI fragment
-};
-
///////////////////////////////////////////////////////////////////////////////
// GenericPointer
@@ -68,10 +57,10 @@ enum PointerParseErrorCode {
supplied tokens eliminates these.
GenericPointer depends on GenericDocument and GenericValue.
-
+
\tparam ValueType The value type of the DOM tree. E.g. GenericValue<UTF8<> >
\tparam Allocator The allocator type for allocating memory for internal representation.
-
+
\note GenericPointer uses same encoding of ValueType.
However, Allocator of GenericPointer is independent of Allocator of Value.
*/
@@ -80,8 +69,10 @@ class GenericPointer {
public:
typedef typename ValueType::EncodingType EncodingType; //!< Encoding type from Value
typedef typename ValueType::Ch Ch; //!< Character type from Value
+ typedef GenericUri<ValueType, Allocator> UriType;
- //! A token is the basic units of internal representation.
+
+ //! A token is the basic units of internal representation.
/*!
A JSON pointer string representation "/foo/123" is parsed to two tokens:
"foo" and 123. 123 will be represented in both numeric form and string form.
@@ -163,7 +154,7 @@ public:
GenericPointer(const Token* tokens, size_t tokenCount) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(const_cast<Token*>(tokens)), tokenCount_(tokenCount), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {}
//! Copy constructor.
- GenericPointer(const GenericPointer& rhs) : allocator_(rhs.allocator_), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
+ GenericPointer(const GenericPointer& rhs) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
*this = rhs;
}
@@ -520,6 +511,70 @@ public:
//@}
+ //!@name Compute URI
+ //@{
+
+ //! Compute the in-scope URI for a subtree.
+ // For use with JSON pointers into JSON schema documents.
+ /*!
+ \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.
+ \param rootUri Root URI
+ \param unresolvedTokenIndex If the pointer cannot resolve a token in the pointer, this parameter can obtain the index of unresolved token.
+ \param allocator Allocator for Uris
+ \return Uri if it can be resolved. Otherwise null.
+
+ \note
+ There are only 3 situations when a URI cannot be resolved:
+ 1. A value in the path is not an array nor object.
+ 2. An object value does not contain the token.
+ 3. A token is out of range of an array value.
+
+ Use unresolvedTokenIndex to retrieve the token index.
+ */
+ UriType GetUri(ValueType& root, const UriType& rootUri, size_t* unresolvedTokenIndex = 0, Allocator* allocator = 0) const {
+ static const Ch kIdString[] = { 'i', 'd', '\0' };
+ static const ValueType kIdValue(kIdString, 2);
+ UriType base = UriType(rootUri, allocator);
+ RAPIDJSON_ASSERT(IsValid());
+ ValueType* v = &root;
+ for (const Token *t = tokens_; t != tokens_ + tokenCount_; ++t) {
+ switch (v->GetType()) {
+ case kObjectType:
+ {
+ // See if we have an id, and if so resolve with the current base
+ typename ValueType::MemberIterator m = v->FindMember(kIdValue);
+ if (m != v->MemberEnd() && (m->value).IsString()) {
+ UriType here = UriType(m->value, allocator).Resolve(base, allocator);
+ base = here;
+ }
+ m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length)));
+ if (m == v->MemberEnd())
+ break;
+ v = &m->value;
+ }
+ continue;
+ case kArrayType:
+ if (t->index == kPointerInvalidIndex || t->index >= v->Size())
+ break;
+ v = &((*v)[t->index]);
+ continue;
+ default:
+ break;
+ }
+
+ // Error: unresolved token
+ if (unresolvedTokenIndex)
+ *unresolvedTokenIndex = static_cast<size_t>(t - tokens_);
+ return UriType(allocator);
+ }
+ return base;
+ }
+
+ UriType GetUri(const ValueType& root, const UriType& rootUri, size_t* unresolvedTokenIndex = 0, Allocator* allocator = 0) const {
+ return GetUri(const_cast<ValueType&>(root), rootUri, unresolvedTokenIndex, allocator);
+ }
+
+
//!@name Query value
//@{
@@ -634,7 +689,7 @@ public:
ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const Ch* defaultValue) const {
return GetWithDefault(document, defaultValue, document.GetAllocator());
}
-
+
#if RAPIDJSON_HAS_STDSTRING
//! Query a value in a document with default std::basic_string.
template <typename stackAllocator>
@@ -835,10 +890,16 @@ private:
std::memcpy(nameBuffer_, rhs.nameBuffer_, nameBufferSize * sizeof(Ch));
}
- // Adjust pointers to name buffer
- std::ptrdiff_t diff = nameBuffer_ - rhs.nameBuffer_;
- for (Token *t = tokens_; t != tokens_ + rhs.tokenCount_; ++t)
- t->name += diff;
+ // The names of each token point to a string in the nameBuffer_. The
+ // previous memcpy copied over string pointers into the rhs.nameBuffer_,
+ // but they should point to the strings in the new nameBuffer_.
+ for (size_t i = 0; i < rhs.tokenCount_; ++i) {
+ // The offset between the string address and the name buffer should
+ // still be constant, so we can just get this offset and set each new
+ // token name according the new buffer start + the known offset.
+ std::ptrdiff_t name_offset = rhs.tokens_[i].name - rhs.nameBuffer_;
+ tokens_[i].name = nameBuffer_ + name_offset;
+ }
return nameBuffer_ + nameBufferSize;
}
@@ -928,7 +989,7 @@ private:
}
i++;
-
+
// Escaping "~0" -> '~', "~1" -> '/'
if (c == '~') {
if (i < length) {
diff --git a/contrib/rapidjson/include/rapidjson/rapidjson.h b/contrib/rapidjson/include/rapidjson/rapidjson.h
index 78aa89a0e..5ea694795 100644
--- a/contrib/rapidjson/include/rapidjson/rapidjson.h
+++ b/contrib/rapidjson/include/rapidjson/rapidjson.h
@@ -1,5 +1,5 @@
// Tencent is pleased to support the open source community by making RapidJSON available.
-//
+//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
//
// Licensed under the MIT License (the "License"); you may not use this file except
@@ -7,9 +7,9 @@
//
// http://opensource.org/licenses/MIT
//
-// Unless required by applicable law or agreed to in writing, software distributed
-// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-// CONDITIONS OF ANY KIND, either express or implied. See the License for the
+// Unless required by applicable law or agreed to in writing, software distributed
+// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#ifndef RAPIDJSON_RAPIDJSON_H_
@@ -17,7 +17,7 @@
/*!\file rapidjson.h
\brief common definitions and configuration
-
+
\see RAPIDJSON_CONFIG
*/
@@ -125,6 +125,19 @@
#endif
///////////////////////////////////////////////////////////////////////////////
+// __cplusplus macro
+
+//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
+
+#if defined(_MSC_VER)
+#define RAPIDJSON_CPLUSPLUS _MSVC_LANG
+#else
+#define RAPIDJSON_CPLUSPLUS __cplusplus
+#endif
+
+//!@endcond
+
+///////////////////////////////////////////////////////////////////////////////
// RAPIDJSON_HAS_STDSTRING
#ifndef RAPIDJSON_HAS_STDSTRING
@@ -150,6 +163,24 @@
#endif // RAPIDJSON_HAS_STDSTRING
///////////////////////////////////////////////////////////////////////////////
+// RAPIDJSON_USE_MEMBERSMAP
+
+/*! \def RAPIDJSON_USE_MEMBERSMAP
+ \ingroup RAPIDJSON_CONFIG
+ \brief Enable RapidJSON support for object members handling in a \c std::multimap
+
+ By defining this preprocessor symbol to \c 1, \ref rapidjson::GenericValue object
+ members are stored in a \c std::multimap for faster lookup and deletion times, a
+ trade off with a slightly slower insertion time and a small object allocat(or)ed
+ memory overhead.
+
+ \hideinitializer
+*/
+#ifndef RAPIDJSON_USE_MEMBERSMAP
+#define RAPIDJSON_USE_MEMBERSMAP 0 // not by default
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
// RAPIDJSON_NO_INT64DEFINE
/*! \def RAPIDJSON_NO_INT64DEFINE
@@ -164,7 +195,7 @@
*/
#ifndef RAPIDJSON_NO_INT64DEFINE
//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
-#if defined(_MSC_VER) && (_MSC_VER < 1800) // Visual Studio 2013
+#if defined(_MSC_VER) && (_MSC_VER < 1800) // Visual Studio 2013
#include "msinttypes/stdint.h"
#include "msinttypes/inttypes.h"
#else
@@ -246,7 +277,7 @@
# elif defined(RAPIDJSON_DOXYGEN_RUNNING)
# define RAPIDJSON_ENDIAN
# else
-# error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN.
+# error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN.
# endif
#endif // RAPIDJSON_ENDIAN
@@ -411,7 +442,7 @@ RAPIDJSON_NAMESPACE_END
// Prefer C++11 static_assert, if available
#ifndef RAPIDJSON_STATIC_ASSERT
-#if __cplusplus >= 201103L || ( defined(_MSC_VER) && _MSC_VER >= 1800 )
+#if RAPIDJSON_CPLUSPLUS >= 201103L || ( defined(_MSC_VER) && _MSC_VER >= 1800 )
#define RAPIDJSON_STATIC_ASSERT(x) \
static_assert(x, RAPIDJSON_STRINGIFY(x))
#endif // C++11
@@ -482,7 +513,7 @@ RAPIDJSON_NAMESPACE_END
//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
-#define RAPIDJSON_MULTILINEMACRO_BEGIN do {
+#define RAPIDJSON_MULTILINEMACRO_BEGIN do {
#define RAPIDJSON_MULTILINEMACRO_END \
} while((void)0, 0)
@@ -541,8 +572,14 @@ RAPIDJSON_NAMESPACE_END
///////////////////////////////////////////////////////////////////////////////
// C++11 features
+#ifndef RAPIDJSON_HAS_CXX11
+#define RAPIDJSON_HAS_CXX11 (RAPIDJSON_CPLUSPLUS >= 201103L)
+#endif
+
#ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS
-#if defined(__clang__)
+#if RAPIDJSON_HAS_CXX11
+#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1
+#elif defined(__clang__)
#if __has_feature(cxx_rvalue_references) && \
(defined(_MSC_VER) || defined(_LIBCPP_VERSION) || defined(__GLIBCXX__) && __GLIBCXX__ >= 20080306)
#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1
@@ -559,8 +596,14 @@ RAPIDJSON_NAMESPACE_END
#endif
#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
+#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
+#include <utility> // std::move
+#endif
+
#ifndef RAPIDJSON_HAS_CXX11_NOEXCEPT
-#if defined(__clang__)
+#if RAPIDJSON_HAS_CXX11
+#define RAPIDJSON_HAS_CXX11_NOEXCEPT 1
+#elif defined(__clang__)
#define RAPIDJSON_HAS_CXX11_NOEXCEPT __has_feature(cxx_noexcept)
#elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,6,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \
(defined(_MSC_VER) && _MSC_VER >= 1900) || \
@@ -570,11 +613,13 @@ RAPIDJSON_NAMESPACE_END
#define RAPIDJSON_HAS_CXX11_NOEXCEPT 0
#endif
#endif
+#ifndef RAPIDJSON_NOEXCEPT
#if RAPIDJSON_HAS_CXX11_NOEXCEPT
#define RAPIDJSON_NOEXCEPT noexcept
#else
-#define RAPIDJSON_NOEXCEPT /* noexcept */
+#define RAPIDJSON_NOEXCEPT throw()
#endif // RAPIDJSON_HAS_CXX11_NOEXCEPT
+#endif
// no automatic detection, yet
#ifndef RAPIDJSON_HAS_CXX11_TYPETRAITS
@@ -600,9 +645,17 @@ RAPIDJSON_NAMESPACE_END
///////////////////////////////////////////////////////////////////////////////
// C++17 features
-#if defined(__has_cpp_attribute)
-# if __has_cpp_attribute(fallthrough)
-# define RAPIDJSON_DELIBERATE_FALLTHROUGH [[fallthrough]]
+#ifndef RAPIDJSON_HAS_CXX17
+#define RAPIDJSON_HAS_CXX17 (RAPIDJSON_CPLUSPLUS >= 201703L)
+#endif
+
+#if RAPIDJSON_HAS_CXX17
+# define RAPIDJSON_DELIBERATE_FALLTHROUGH [[fallthrough]]
+#elif defined(__has_cpp_attribute)
+# if __has_cpp_attribute(clang::fallthrough)
+# define RAPIDJSON_DELIBERATE_FALLTHROUGH [[clang::fallthrough]]
+# elif __has_cpp_attribute(fallthrough)
+# define RAPIDJSON_DELIBERATE_FALLTHROUGH __attribute__((fallthrough))
# else
# define RAPIDJSON_DELIBERATE_FALLTHROUGH
# endif
@@ -628,12 +681,8 @@ RAPIDJSON_NAMESPACE_END
#ifndef RAPIDJSON_NOEXCEPT_ASSERT
#ifdef RAPIDJSON_ASSERT_THROWS
-#if RAPIDJSON_HAS_CXX11_NOEXCEPT
-#define RAPIDJSON_NOEXCEPT_ASSERT(x)
-#else
#include <cassert>
#define RAPIDJSON_NOEXCEPT_ASSERT(x) assert(x)
-#endif // RAPIDJSON_HAS_CXX11_NOEXCEPT
#else
#define RAPIDJSON_NOEXCEPT_ASSERT(x) RAPIDJSON_ASSERT(x)
#endif // RAPIDJSON_ASSERT_THROWS
@@ -682,7 +731,7 @@ enum Type {
kFalseType = 1, //!< false
kTrueType = 2, //!< true
kObjectType = 3, //!< object
- kArrayType = 4, //!< array
+ kArrayType = 4, //!< array
kStringType = 5, //!< string
kNumberType = 6 //!< number
};
diff --git a/contrib/rapidjson/include/rapidjson/reader.h b/contrib/rapidjson/include/rapidjson/reader.h
index 09ace4eba..55546601e 100644
--- a/contrib/rapidjson/include/rapidjson/reader.h
+++ b/contrib/rapidjson/include/rapidjson/reader.h
@@ -1404,11 +1404,11 @@ private:
}
#endif // RAPIDJSON_NEON
- template<typename InputStream, bool backup, bool pushOnTake>
+ template<typename InputStream, typename StackCharacter, bool backup, bool pushOnTake>
class NumberStream;
- template<typename InputStream>
- class NumberStream<InputStream, false, false> {
+ template<typename InputStream, typename StackCharacter>
+ class NumberStream<InputStream, StackCharacter, false, false> {
public:
typedef typename InputStream::Ch Ch;
@@ -1421,7 +1421,7 @@ private:
size_t Tell() { return is.Tell(); }
size_t Length() { return 0; }
- const char* Pop() { return 0; }
+ const StackCharacter* Pop() { return 0; }
protected:
NumberStream& operator=(const NumberStream&);
@@ -1429,45 +1429,47 @@ private:
InputStream& is;
};
- template<typename InputStream>
- class NumberStream<InputStream, true, false> : public NumberStream<InputStream, false, false> {
- typedef NumberStream<InputStream, false, false> Base;
+ template<typename InputStream, typename StackCharacter>
+ class NumberStream<InputStream, StackCharacter, true, false> : public NumberStream<InputStream, StackCharacter, false, false> {
+ typedef NumberStream<InputStream, StackCharacter, false, false> Base;
public:
- NumberStream(GenericReader& reader, InputStream& is) : Base(reader, is), stackStream(reader.stack_) {}
+ NumberStream(GenericReader& reader, InputStream& s) : Base(reader, s), stackStream(reader.stack_) {}
RAPIDJSON_FORCEINLINE Ch TakePush() {
- stackStream.Put(static_cast<char>(Base::is.Peek()));
+ stackStream.Put(static_cast<StackCharacter>(Base::is.Peek()));
return Base::is.Take();
}
- RAPIDJSON_FORCEINLINE void Push(char c) {
+ RAPIDJSON_FORCEINLINE void Push(StackCharacter c) {
stackStream.Put(c);
}
size_t Length() { return stackStream.Length(); }
- const char* Pop() {
+ const StackCharacter* Pop() {
stackStream.Put('\0');
return stackStream.Pop();
}
private:
- StackStream<char> stackStream;
+ StackStream<StackCharacter> stackStream;
};
- template<typename InputStream>
- class NumberStream<InputStream, true, true> : public NumberStream<InputStream, true, false> {
- typedef NumberStream<InputStream, true, false> Base;
+ template<typename InputStream, typename StackCharacter>
+ class NumberStream<InputStream, StackCharacter, true, true> : public NumberStream<InputStream, StackCharacter, true, false> {
+ typedef NumberStream<InputStream, StackCharacter, true, false> Base;
public:
- NumberStream(GenericReader& reader, InputStream& is) : Base(reader, is) {}
+ NumberStream(GenericReader& reader, InputStream& s) : Base(reader, s) {}
RAPIDJSON_FORCEINLINE Ch Take() { return Base::TakePush(); }
};
template<unsigned parseFlags, typename InputStream, typename Handler>
void ParseNumber(InputStream& is, Handler& handler) {
+ typedef typename internal::SelectIf<internal::BoolType<(parseFlags & kParseNumbersAsStringsFlag) != 0>, typename TargetEncoding::Ch, char>::Type NumberCharacter;
+
internal::StreamLocalCopy<InputStream> copy(is);
- NumberStream<InputStream,
+ NumberStream<InputStream, NumberCharacter,
((parseFlags & kParseNumbersAsStringsFlag) != 0) ?
((parseFlags & kParseInsituFlag) == 0) :
((parseFlags & kParseFullPrecisionFlag) != 0),
@@ -1692,10 +1694,10 @@ private:
}
else {
SizeType numCharsToCopy = static_cast<SizeType>(s.Length());
- StringStream srcStream(s.Pop());
+ GenericStringStream<UTF8<NumberCharacter> > srcStream(s.Pop());
StackStream<typename TargetEncoding::Ch> dstStream(stack_);
while (numCharsToCopy--) {
- Transcoder<UTF8<>, TargetEncoding>::Transcode(srcStream, dstStream);
+ Transcoder<UTF8<typename TargetEncoding::Ch>, TargetEncoding>::Transcode(srcStream, dstStream);
}
dstStream.Put('\0');
const typename TargetEncoding::Ch* str = dstStream.Pop();
@@ -1705,7 +1707,7 @@ private:
}
else {
size_t length = s.Length();
- const char* decimal = s.Pop(); // Pop stack no matter if it will be used or not.
+ const NumberCharacter* decimal = s.Pop(); // Pop stack no matter if it will be used or not.
if (useDouble) {
int p = exp + expFrac;
diff --git a/contrib/rapidjson/include/rapidjson/schema.h b/contrib/rapidjson/include/rapidjson/schema.h
index 11f716096..02a6d0f9e 100644
--- a/contrib/rapidjson/include/rapidjson/schema.h
+++ b/contrib/rapidjson/include/rapidjson/schema.h
@@ -1,5 +1,5 @@
// Tencent is pleased to support the open source community by making RapidJSON available->
-//
+//
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip-> All rights reserved->
//
// Licensed under the MIT License (the "License"); you may not use this file except
@@ -7,9 +7,9 @@
//
// http://opensource->org/licenses/MIT
//
-// Unless required by applicable law or agreed to in writing, software distributed
-// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-// CONDITIONS OF ANY KIND, either express or implied-> See the License for the
+// Unless required by applicable law or agreed to in writing, software distributed
+// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+// CONDITIONS OF ANY KIND, either express or implied-> See the License for the
// specific language governing permissions and limitations under the License->
#ifndef RAPIDJSON_SCHEMA_H_
@@ -19,17 +19,14 @@
#include "pointer.h"
#include "stringbuffer.h"
#include "error/en.h"
+#include "uri.h"
#include <cmath> // abs, floor
#if !defined(RAPIDJSON_SCHEMA_USE_INTERNALREGEX)
#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 1
-#else
-#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 0
#endif
-#if !RAPIDJSON_SCHEMA_USE_INTERNALREGEX && defined(RAPIDJSON_SCHEMA_USE_STDREGEX) && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
-#define RAPIDJSON_SCHEMA_USE_STDREGEX 1
-#else
+#if !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) || !(__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
#define RAPIDJSON_SCHEMA_USE_STDREGEX 0
#endif
@@ -49,10 +46,6 @@
#define RAPIDJSON_SCHEMA_VERBOSE 0
#endif
-#if RAPIDJSON_SCHEMA_VERBOSE
-#include "stringbuffer.h"
-#endif
-
RAPIDJSON_DIAG_PUSH
#if defined(__GNUC__)
@@ -77,48 +70,94 @@ RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
-inline void PrintInvalidKeyword(const char* keyword) {
- printf("Fail keyword: %s\n", keyword);
+inline void PrintInvalidKeywordData(const char* keyword) {
+ printf(" Fail keyword: '%s'\n", keyword);
+}
+
+inline void PrintInvalidKeywordData(const wchar_t* keyword) {
+ wprintf(L" Fail keyword: '%ls'\n", keyword);
+}
+
+inline void PrintInvalidDocumentData(const char* document) {
+ printf(" Fail document: '%s'\n", document);
+}
+
+inline void PrintInvalidDocumentData(const wchar_t* document) {
+ wprintf(L" Fail document: '%ls'\n", document);
+}
+
+inline void PrintValidatorPointersData(const char* s, const char* d, unsigned depth) {
+ printf(" Sch: %*s'%s'\n Doc: %*s'%s'\n", depth * 4, " ", s, depth * 4, " ", d);
+}
+
+inline void PrintValidatorPointersData(const wchar_t* s, const wchar_t* d, unsigned depth) {
+ wprintf(L" Sch: %*ls'%ls'\n Doc: %*ls'%ls'\n", depth * 4, L" ", s, depth * 4, L" ", d);
+}
+
+inline void PrintSchemaIdsData(const char* base, const char* local, const char* resolved) {
+ printf(" Resolving id: Base: '%s', Local: '%s', Resolved: '%s'\n", base, local, resolved);
+}
+
+inline void PrintSchemaIdsData(const wchar_t* base, const wchar_t* local, const wchar_t* resolved) {
+ wprintf(L" Resolving id: Base: '%ls', Local: '%ls', Resolved: '%ls'\n", base, local, resolved);
+}
+
+inline void PrintMethodData(const char* method) {
+ printf("%s\n", method);
+}
+
+inline void PrintMethodData(const char* method, bool b) {
+ printf("%s, Data: '%s'\n", method, b ? "true" : "false");
+}
+
+inline void PrintMethodData(const char* method, int64_t i) {
+ printf("%s, Data: '%" PRId64 "'\n", method, i);
+}
+
+inline void PrintMethodData(const char* method, uint64_t u) {
+ printf("%s, Data: '%" PRIu64 "'\n", method, u);
}
-inline void PrintInvalidKeyword(const wchar_t* keyword) {
- wprintf(L"Fail keyword: %ls\n", keyword);
+inline void PrintMethodData(const char* method, double d) {
+ printf("%s, Data: '%lf'\n", method, d);
}
-inline void PrintInvalidDocument(const char* document) {
- printf("Fail document: %s\n\n", document);
+inline void PrintMethodData(const char* method, const char* s) {
+ printf("%s, Data: '%s'\n", method, s);
}
-inline void PrintInvalidDocument(const wchar_t* document) {
- wprintf(L"Fail document: %ls\n\n", document);
+inline void PrintMethodData(const char* method, const wchar_t* s) {
+ wprintf(L"%hs, Data: '%ls'\n", method, s);
}
-inline void PrintValidatorPointers(unsigned depth, const char* s, const char* d) {
- printf("S: %*s%s\nD: %*s%s\n\n", depth * 4, " ", s, depth * 4, " ", d);
+inline void PrintMethodData(const char* method, const char* s1, const char* s2) {
+ printf("%s, Data: '%s', '%s'\n", method, s1, s2);
}
-inline void PrintValidatorPointers(unsigned depth, const wchar_t* s, const wchar_t* d) {
- wprintf(L"S: %*ls%ls\nD: %*ls%ls\n\n", depth * 4, L" ", s, depth * 4, L" ", d);
+inline void PrintMethodData(const char* method, const wchar_t* s1, const wchar_t* s2) {
+ wprintf(L"%hs, Data: '%ls', '%ls'\n", method, s1, s2);
}
} // namespace internal
#endif // RAPIDJSON_SCHEMA_VERBOSE
-///////////////////////////////////////////////////////////////////////////////
-// RAPIDJSON_INVALID_KEYWORD_RETURN
-
+#ifndef RAPIDJSON_SCHEMA_PRINT
#if RAPIDJSON_SCHEMA_VERBOSE
-#define RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword) internal::PrintInvalidKeyword(keyword)
+#define RAPIDJSON_SCHEMA_PRINT(name, ...) internal::Print##name##Data(__VA_ARGS__)
#else
-#define RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword)
+#define RAPIDJSON_SCHEMA_PRINT(name, ...)
+#endif
#endif
+///////////////////////////////////////////////////////////////////////////////
+// RAPIDJSON_INVALID_KEYWORD_RETURN
+
#define RAPIDJSON_INVALID_KEYWORD_RETURN(code)\
RAPIDJSON_MULTILINEMACRO_BEGIN\
context.invalidCode = code;\
context.invalidKeyword = SchemaType::GetValidateErrorKeyword(code).GetString();\
- RAPIDJSON_INVALID_KEYWORD_VERBOSE(context.invalidKeyword);\
+ RAPIDJSON_SCHEMA_PRINT(InvalidKeyword, context.invalidKeyword);\
return false;\
RAPIDJSON_MULTILINEMACRO_END
@@ -136,15 +175,57 @@ RAPIDJSON_MULTILINEMACRO_END
#endif
//! Combination of validate flags
-/*! \see
- */
enum ValidateFlag {
kValidateNoFlags = 0, //!< No flags are set.
kValidateContinueOnErrorFlag = 1, //!< Don't stop after first validation error.
+ kValidateReadFlag = 2, //!< Validation is for a read semantic.
+ kValidateWriteFlag = 4, //!< Validation is for a write semantic.
kValidateDefaultFlags = RAPIDJSON_VALIDATE_DEFAULT_FLAGS //!< Default validate flags. Can be customized by defining RAPIDJSON_VALIDATE_DEFAULT_FLAGS
};
///////////////////////////////////////////////////////////////////////////////
+// Specification
+enum SchemaDraft {
+ kDraftUnknown = -1,
+ kDraftNone = 0,
+ kDraft03 = 3,
+ kDraftMin = 4, //!< Current minimum supported draft
+ kDraft04 = 4,
+ kDraft05 = 5,
+ kDraftMax = 5, //!< Current maximum supported draft
+ kDraft06 = 6,
+ kDraft07 = 7,
+ kDraft2019_09 = 8,
+ kDraft2020_12 = 9
+};
+
+enum OpenApiVersion {
+ kVersionUnknown = -1,
+ kVersionNone = 0,
+ kVersionMin = 2, //!< Current minimum supported version
+ kVersion20 = 2,
+ kVersion30 = 3,
+ kVersionMax = 3, //!< Current maximum supported version
+ kVersion31 = 4,
+};
+
+struct Specification {
+ Specification(SchemaDraft d) : draft(d), oapi(kVersionNone) {}
+ Specification(OpenApiVersion o) : oapi(o) {
+ if (oapi == kVersion20) draft = kDraft04;
+ else if (oapi == kVersion30) draft = kDraft05;
+ else if (oapi == kVersion31) draft = kDraft2020_12;
+ else draft = kDraft04;
+ }
+ ~Specification() {}
+ bool IsSupported() const {
+ return ((draft >= kDraftMin && draft <= kDraftMax) && ((oapi == kVersionNone) || (oapi >= kVersionMin && oapi <= kVersionMax)));
+ }
+ SchemaDraft draft;
+ OpenApiVersion oapi;
+};
+
+///////////////////////////////////////////////////////////////////////////////
// Forward declarations
template <typename ValueType, typename Allocator>
@@ -233,8 +314,11 @@ public:
virtual void EndDisallowedType(const typename SchemaType::ValueType& actualType) = 0;
virtual void NotAllOf(ISchemaValidator** subvalidators, SizeType count) = 0;
virtual void NoneOf(ISchemaValidator** subvalidators, SizeType count) = 0;
- virtual void NotOneOf(ISchemaValidator** subvalidators, SizeType count, bool matched) = 0;
+ virtual void NotOneOf(ISchemaValidator** subvalidators, SizeType count) = 0;
+ virtual void MultipleOneOf(SizeType index1, SizeType index2) = 0;
virtual void Disallowed() = 0;
+ virtual void DisallowedWhenWriting() = 0;
+ virtual void DisallowedWhenReading() = 0;
};
@@ -255,10 +339,10 @@ public:
bool Uint(unsigned u) { Number n; n.u.u = u; n.d = static_cast<double>(u); return WriteNumber(n); }
bool Int64(int64_t i) { Number n; n.u.i = i; n.d = static_cast<double>(i); return WriteNumber(n); }
bool Uint64(uint64_t u) { Number n; n.u.u = u; n.d = static_cast<double>(u); return WriteNumber(n); }
- bool Double(double d) {
- Number n;
+ bool Double(double d) {
+ Number n;
if (d < 0) n.u.i = static_cast<int64_t>(d);
- else n.u.u = static_cast<uint64_t>(d);
+ else n.u.u = static_cast<uint64_t>(d);
n.d = d;
return WriteNumber(n);
}
@@ -279,7 +363,9 @@ public:
uint64_t h = Hash(0, kObjectType);
uint64_t* kv = stack_.template Pop<uint64_t>(memberCount * 2);
for (SizeType i = 0; i < memberCount; i++)
- h ^= Hash(kv[i * 2], kv[i * 2 + 1]); // Use xor to achieve member order insensitive
+ // Issue #2205
+ // Hasing the key to avoid key=value cases with bug-prone zero-value hash
+ h ^= Hash(Hash(0, kv[i * 2]), kv[i * 2 + 1]); // Use xor to achieve member order insensitive
*stack_.template Push<uint64_t>() = h;
return true;
}
@@ -317,7 +403,7 @@ private:
bool WriteBuffer(Type type, const void* data, size_t len) {
// FNV-1a from http://isthe.com/chongo/tech/comp/fnv/
- uint64_t h = Hash(RAPIDJSON_UINT64_C2(0x84222325, 0xcbf29ce4), type);
+ uint64_t h = Hash(RAPIDJSON_UINT64_C2(0xcbf29ce4, 0x84222325), type);
const unsigned char* d = static_cast<const unsigned char*>(data);
for (size_t i = 0; i < len; i++)
h = Hash(h, d[i]);
@@ -352,10 +438,11 @@ struct SchemaValidationContext {
kPatternValidatorWithAdditionalProperty
};
- SchemaValidationContext(SchemaValidatorFactoryType& f, ErrorHandlerType& eh, const SchemaType* s) :
+ SchemaValidationContext(SchemaValidatorFactoryType& f, ErrorHandlerType& eh, const SchemaType* s, unsigned fl = 0) :
factory(f),
error_handler(eh),
schema(s),
+ flags(fl),
valueSchema(),
invalidKeyword(),
invalidCode(),
@@ -379,13 +466,19 @@ struct SchemaValidationContext {
if (hasher)
factory.DestroryHasher(hasher);
if (validators) {
- for (SizeType i = 0; i < validatorCount; i++)
- factory.DestroySchemaValidator(validators[i]);
+ for (SizeType i = 0; i < validatorCount; i++) {
+ if (validators[i]) {
+ factory.DestroySchemaValidator(validators[i]);
+ }
+ }
factory.FreeState(validators);
}
if (patternPropertiesValidators) {
- for (SizeType i = 0; i < patternPropertiesValidatorCount; i++)
- factory.DestroySchemaValidator(patternPropertiesValidators[i]);
+ for (SizeType i = 0; i < patternPropertiesValidatorCount; i++) {
+ if (patternPropertiesValidators[i]) {
+ factory.DestroySchemaValidator(patternPropertiesValidators[i]);
+ }
+ }
factory.FreeState(patternPropertiesValidators);
}
if (patternPropertiesSchemas)
@@ -397,6 +490,7 @@ struct SchemaValidationContext {
SchemaValidatorFactoryType& factory;
ErrorHandlerType& error_handler;
const SchemaType* schema;
+ unsigned flags;
const SchemaType* valueSchema;
const Ch* invalidKeyword;
ValidateErrorCode invalidCode;
@@ -432,11 +526,14 @@ public:
typedef Schema<SchemaDocumentType> SchemaType;
typedef GenericValue<EncodingType, AllocatorType> SValue;
typedef IValidationErrorHandler<Schema> ErrorHandler;
+ typedef GenericUri<ValueType, AllocatorType> UriType;
friend class GenericSchemaDocument<ValueType, AllocatorType>;
- Schema(SchemaDocumentType* schemaDocument, const PointerType& p, const ValueType& value, const ValueType& document, AllocatorType* allocator) :
+ Schema(SchemaDocumentType* schemaDocument, const PointerType& p, const ValueType& value, const ValueType& document, AllocatorType* allocator, const UriType& id = UriType()) :
allocator_(allocator),
uri_(schemaDocument->GetURI(), *allocator),
+ id_(id, allocator),
+ spec_(schemaDocument->GetSpecification()),
pointer_(p, allocator),
typeless_(schemaDocument->GetTypeless()),
enum_(),
@@ -469,14 +566,43 @@ public:
maxLength_(~SizeType(0)),
exclusiveMinimum_(false),
exclusiveMaximum_(false),
- defaultValueLength_(0)
+ defaultValueLength_(0),
+ readOnly_(false),
+ writeOnly_(false),
+ nullable_(false)
{
+ GenericStringBuffer<EncodingType> sb;
+ p.StringifyUriFragment(sb);
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::Schema", sb.GetString(), id.GetString());
+
typedef typename ValueType::ConstValueIterator ConstValueIterator;
typedef typename ValueType::ConstMemberIterator ConstMemberIterator;
+ // PR #1393
+ // Early add this Schema and its $ref(s) in schemaDocument's map to avoid infinite
+ // recursion (with recursive schemas), since schemaDocument->getSchema() is always
+ // checked before creating a new one. Don't cache typeless_, though.
+ if (this != typeless_) {
+ typedef typename SchemaDocumentType::SchemaEntry SchemaEntry;
+ SchemaEntry *entry = schemaDocument->schemaMap_.template Push<SchemaEntry>();
+ new (entry) SchemaEntry(pointer_, this, true, allocator_);
+ schemaDocument->AddSchemaRefs(this);
+ }
+
if (!value.IsObject())
return;
+ // If we have an id property, resolve it with the in-scope id
+ // Not supported for open api 2.0 or 3.0
+ if (spec_.oapi != kVersion20 && spec_.oapi != kVersion30)
+ if (const ValueType* v = GetMember(value, GetIdString())) {
+ if (v->IsString()) {
+ UriType local(*v, allocator);
+ id_ = local.Resolve(id_, allocator);
+ RAPIDJSON_SCHEMA_PRINT(SchemaIds, id.GetString(), v->GetString(), id_.GetString());
+ }
+ }
+
if (const ValueType* v = GetMember(value, GetTypeString())) {
type_ = 0;
if (v->IsString())
@@ -490,9 +616,9 @@ public:
if (v->IsArray() && v->Size() > 0) {
enum_ = static_cast<uint64_t*>(allocator_->Malloc(sizeof(uint64_t) * v->Size()));
for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) {
- typedef Hasher<EncodingType, MemoryPoolAllocator<> > EnumHasherType;
+ typedef Hasher<EncodingType, MemoryPoolAllocator<AllocatorType> > EnumHasherType;
char buffer[256u + 24];
- MemoryPoolAllocator<> hasherAllocator(buffer, sizeof(buffer));
+ MemoryPoolAllocator<AllocatorType> hasherAllocator(buffer, sizeof(buffer));
EnumHasherType h(&hasherAllocator, 256);
itr->Accept(h);
enum_[enumCount_++] = h.GetHashCode();
@@ -500,16 +626,19 @@ public:
}
}
- if (schemaDocument) {
+ if (schemaDocument)
AssignIfExist(allOf_, *schemaDocument, p, value, GetAllOfString(), document);
+
+ // AnyOf, OneOf, Not not supported for open api 2.0
+ if (schemaDocument && spec_.oapi != kVersion20) {
AssignIfExist(anyOf_, *schemaDocument, p, value, GetAnyOfString(), document);
AssignIfExist(oneOf_, *schemaDocument, p, value, GetOneOfString(), document);
- }
- if (const ValueType* v = GetMember(value, GetNotString())) {
- schemaDocument->CreateSchema(&not_, p.Append(GetNotString(), allocator_), *v, document);
- notValidatorIndex_ = validatorCount_;
- validatorCount_++;
+ if (const ValueType* v = GetMember(value, GetNotString())) {
+ schemaDocument->CreateSchema(&not_, p.Append(GetNotString(), allocator_), *v, document, id_);
+ notValidatorIndex_ = validatorCount_;
+ validatorCount_++;
+ }
}
// Object
@@ -524,12 +653,14 @@ public:
if (properties && properties->IsObject())
for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr)
AddUniqueElement(allProperties, itr->name);
-
+
if (required && required->IsArray())
for (ConstValueIterator itr = required->Begin(); itr != required->End(); ++itr)
if (itr->IsString())
AddUniqueElement(allProperties, *itr);
+ // Dependencies not supported for open api 2.0 and 3.0
+ if (spec_.oapi != kVersion20 && spec_.oapi != kVersion30)
if (dependencies && dependencies->IsObject())
for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) {
AddUniqueElement(allProperties, itr->name);
@@ -555,10 +686,12 @@ public:
for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr) {
SizeType index;
if (FindPropertyIndex(itr->name, &index))
- schemaDocument->CreateSchema(&properties_[index].schema, q.Append(itr->name, allocator_), itr->value, document);
+ schemaDocument->CreateSchema(&properties_[index].schema, q.Append(itr->name, allocator_), itr->value, document, id_);
}
}
+ // PatternProperties not supported for open api 2.0 and 3.0
+ if (spec_.oapi != kVersion20 && spec_.oapi != kVersion30)
if (const ValueType* v = GetMember(value, GetPatternPropertiesString())) {
PointerType q = p.Append(GetPatternPropertiesString(), allocator_);
patternProperties_ = static_cast<PatternProperty*>(allocator_->Malloc(sizeof(PatternProperty) * v->MemberCount()));
@@ -566,8 +699,9 @@ public:
for (ConstMemberIterator itr = v->MemberBegin(); itr != v->MemberEnd(); ++itr) {
new (&patternProperties_[patternPropertyCount_]) PatternProperty();
- patternProperties_[patternPropertyCount_].pattern = CreatePattern(itr->name);
- schemaDocument->CreateSchema(&patternProperties_[patternPropertyCount_].schema, q.Append(itr->name, allocator_), itr->value, document);
+ PointerType r = q.Append(itr->name, allocator_);
+ patternProperties_[patternPropertyCount_].pattern = CreatePattern(itr->name, schemaDocument, r);
+ schemaDocument->CreateSchema(&patternProperties_[patternPropertyCount_].schema, r, itr->value, document, id_);
patternPropertyCount_++;
}
}
@@ -582,6 +716,8 @@ public:
}
}
+ // Dependencies not supported for open api 2.0 and 3.0
+ if (spec_.oapi != kVersion20 && spec_.oapi != kVersion30)
if (dependencies && dependencies->IsObject()) {
PointerType q = p.Append(GetDependenciesString(), allocator_);
hasDependencies_ = true;
@@ -599,7 +735,7 @@ public:
}
else if (itr->value.IsObject()) {
hasSchemaDependencies_ = true;
- schemaDocument->CreateSchema(&properties_[sourceIndex].dependenciesSchema, q.Append(itr->name, allocator_), itr->value, document);
+ schemaDocument->CreateSchema(&properties_[sourceIndex].dependenciesSchema, q.Append(itr->name, allocator_), itr->value, document, id_);
properties_[sourceIndex].dependenciesValidatorIndex = validatorCount_;
validatorCount_++;
}
@@ -611,7 +747,7 @@ public:
if (v->IsBool())
additionalProperties_ = v->GetBool();
else if (v->IsObject())
- schemaDocument->CreateSchema(&additionalPropertiesSchema_, p.Append(GetAdditionalPropertiesString(), allocator_), *v, document);
+ schemaDocument->CreateSchema(&additionalPropertiesSchema_, p.Append(GetAdditionalPropertiesString(), allocator_), *v, document, id_);
}
AssignIfExist(minProperties_, value, GetMinPropertiesString());
@@ -621,23 +757,25 @@ public:
if (const ValueType* v = GetMember(value, GetItemsString())) {
PointerType q = p.Append(GetItemsString(), allocator_);
if (v->IsObject()) // List validation
- schemaDocument->CreateSchema(&itemsList_, q, *v, document);
+ schemaDocument->CreateSchema(&itemsList_, q, *v, document, id_);
else if (v->IsArray()) { // Tuple validation
itemsTuple_ = static_cast<const Schema**>(allocator_->Malloc(sizeof(const Schema*) * v->Size()));
SizeType index = 0;
for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr, index++)
- schemaDocument->CreateSchema(&itemsTuple_[itemsTupleCount_++], q.Append(index, allocator_), *itr, document);
+ schemaDocument->CreateSchema(&itemsTuple_[itemsTupleCount_++], q.Append(index, allocator_), *itr, document, id_);
}
}
AssignIfExist(minItems_, value, GetMinItemsString());
AssignIfExist(maxItems_, value, GetMaxItemsString());
+ // AdditionalItems not supported for openapi 2.0 and 3.0
+ if (spec_.oapi != kVersion20 && spec_.oapi != kVersion30)
if (const ValueType* v = GetMember(value, GetAdditionalItemsString())) {
if (v->IsBool())
additionalItems_ = v->GetBool();
else if (v->IsObject())
- schemaDocument->CreateSchema(&additionalItemsSchema_, p.Append(GetAdditionalItemsString(), allocator_), *v, document);
+ schemaDocument->CreateSchema(&additionalItemsSchema_, p.Append(GetAdditionalItemsString(), allocator_), *v, document, id_);
}
AssignIfExist(uniqueItems_, value, GetUniqueItemsString());
@@ -647,7 +785,7 @@ public:
AssignIfExist(maxLength_, value, GetMaxLengthString());
if (const ValueType* v = GetMember(value, GetPatternString()))
- pattern_ = CreatePattern(*v);
+ pattern_ = CreatePattern(*v, schemaDocument, p.Append(GetPatternString(), allocator_));
// Number
if (const ValueType* v = GetMember(value, GetMinimumString()))
@@ -670,6 +808,23 @@ public:
if (v->IsString())
defaultValueLength_ = v->GetStringLength();
+ // ReadOnly - open api only (until draft 7 supported)
+ // WriteOnly - open api 3 only (until draft 7 supported)
+ // Both can't be true
+ if (spec_.oapi != kVersionNone)
+ AssignIfExist(readOnly_, value, GetReadOnlyString());
+ if (spec_.oapi >= kVersion30)
+ AssignIfExist(writeOnly_, value, GetWriteOnlyString());
+ if (readOnly_ && writeOnly_)
+ schemaDocument->SchemaError(kSchemaErrorReadOnlyAndWriteOnly, p);
+
+ // Nullable - open api 3 only
+ // If true add 'null' as allowable type
+ if (spec_.oapi >= kVersion30) {
+ AssignIfExist(nullable_, value, GetNullableString());
+ if (nullable_)
+ AddType(GetNullString());
+ }
}
~Schema() {
@@ -697,11 +852,20 @@ public:
return uri_;
}
+ const UriType& GetId() const {
+ return id_;
+ }
+
+ const Specification& GetSpecification() const {
+ return spec_;
+ }
+
const PointerType& GetPointer() const {
return pointer_;
}
bool BeginValue(Context& context) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::BeginValue");
if (context.inArray) {
if (uniqueItems_)
context.valueUniqueness = true;
@@ -733,6 +897,8 @@ public:
}
RAPIDJSON_FORCEINLINE bool EndValue(Context& context) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::EndValue");
+ // Only check pattern properties if we have validators
if (context.patternPropertiesValidatorCount > 0) {
bool otherValid = false;
SizeType count = context.patternPropertiesValidatorCount;
@@ -775,87 +941,98 @@ public:
foundEnum:;
}
- if (allOf_.schemas)
- for (SizeType i = allOf_.begin; i < allOf_.begin + allOf_.count; i++)
- if (!context.validators[i]->IsValid()) {
- context.error_handler.NotAllOf(&context.validators[allOf_.begin], allOf_.count);
- RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorAllOf);
- }
-
- if (anyOf_.schemas) {
- for (SizeType i = anyOf_.begin; i < anyOf_.begin + anyOf_.count; i++)
- if (context.validators[i]->IsValid())
- goto foundAny;
- context.error_handler.NoneOf(&context.validators[anyOf_.begin], anyOf_.count);
- RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorAnyOf);
- foundAny:;
- }
-
- if (oneOf_.schemas) {
- bool oneValid = false;
- for (SizeType i = oneOf_.begin; i < oneOf_.begin + oneOf_.count; i++)
- if (context.validators[i]->IsValid()) {
- if (oneValid) {
- context.error_handler.NotOneOf(&context.validators[oneOf_.begin], oneOf_.count, true);
- RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorOneOfMatch);
- } else
- oneValid = true;
+ // Only check allOf etc if we have validators
+ if (context.validatorCount > 0) {
+ if (allOf_.schemas)
+ for (SizeType i = allOf_.begin; i < allOf_.begin + allOf_.count; i++)
+ if (!context.validators[i]->IsValid()) {
+ context.error_handler.NotAllOf(&context.validators[allOf_.begin], allOf_.count);
+ RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorAllOf);
+ }
+
+ if (anyOf_.schemas) {
+ for (SizeType i = anyOf_.begin; i < anyOf_.begin + anyOf_.count; i++)
+ if (context.validators[i]->IsValid())
+ goto foundAny;
+ context.error_handler.NoneOf(&context.validators[anyOf_.begin], anyOf_.count);
+ RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorAnyOf);
+ foundAny:;
+ }
+
+ if (oneOf_.schemas) {
+ bool oneValid = false;
+ SizeType firstMatch = 0;
+ for (SizeType i = oneOf_.begin; i < oneOf_.begin + oneOf_.count; i++)
+ if (context.validators[i]->IsValid()) {
+ if (oneValid) {
+ context.error_handler.MultipleOneOf(firstMatch, i - oneOf_.begin);
+ RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorOneOfMatch);
+ } else {
+ oneValid = true;
+ firstMatch = i - oneOf_.begin;
+ }
+ }
+ if (!oneValid) {
+ context.error_handler.NotOneOf(&context.validators[oneOf_.begin], oneOf_.count);
+ RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorOneOf);
}
- if (!oneValid) {
- context.error_handler.NotOneOf(&context.validators[oneOf_.begin], oneOf_.count, false);
- RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorOneOf);
}
- }
- if (not_ && context.validators[notValidatorIndex_]->IsValid()) {
- context.error_handler.Disallowed();
- RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorNot);
+ if (not_ && context.validators[notValidatorIndex_]->IsValid()) {
+ context.error_handler.Disallowed();
+ RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorNot);
+ }
}
return true;
}
bool Null(Context& context) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::Null");
if (!(type_ & (1 << kNullSchemaType))) {
DisallowedType(context, GetNullString());
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
}
return CreateParallelValidator(context);
}
-
- bool Bool(Context& context, bool) const {
- if (!(type_ & (1 << kBooleanSchemaType))) {
- DisallowedType(context, GetBooleanString());
- RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
- }
+
+ bool Bool(Context& context, bool b) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::Bool", b);
+ if (!CheckBool(context, b))
+ return false;
return CreateParallelValidator(context);
}
bool Int(Context& context, int i) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::Int", (int64_t)i);
if (!CheckInt(context, i))
return false;
return CreateParallelValidator(context);
}
bool Uint(Context& context, unsigned u) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::Uint", (uint64_t)u);
if (!CheckUint(context, u))
return false;
return CreateParallelValidator(context);
}
bool Int64(Context& context, int64_t i) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::Int64", i);
if (!CheckInt(context, i))
return false;
return CreateParallelValidator(context);
}
bool Uint64(Context& context, uint64_t u) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::Uint64", u);
if (!CheckUint(context, u))
return false;
return CreateParallelValidator(context);
}
bool Double(Context& context, double d) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::Double", d);
if (!(type_ & (1 << kNumberSchemaType))) {
DisallowedType(context, GetNumberString());
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
@@ -866,14 +1043,15 @@ public:
if (!maximum_.IsNull() && !CheckDoubleMaximum(context, d))
return false;
-
+
if (!multipleOf_.IsNull() && !CheckDoubleMultipleOf(context, d))
return false;
-
+
return CreateParallelValidator(context);
}
-
+
bool String(Context& context, const Ch* str, SizeType length, bool) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::String", str);
if (!(type_ & (1 << kStringSchemaType))) {
DisallowedType(context, GetStringString());
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
@@ -902,6 +1080,7 @@ public:
}
bool StartObject(Context& context) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::StartObject");
if (!(type_ & (1 << kObjectSchemaType))) {
DisallowedType(context, GetObjectString());
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
@@ -921,8 +1100,10 @@ public:
return CreateParallelValidator(context);
}
-
+
bool Key(Context& context, const Ch* str, SizeType len, bool) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::Key", str);
+
if (patternProperties_) {
context.patternPropertiesSchemaCount = 0;
for (SizeType i = 0; i < patternPropertyCount_; i++)
@@ -949,7 +1130,7 @@ public:
}
if (additionalPropertiesSchema_) {
- if (additionalPropertiesSchema_ && context.patternPropertiesSchemaCount > 0) {
+ if (context.patternPropertiesSchemaCount > 0) {
context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = additionalPropertiesSchema_;
context.valueSchema = typeless_;
context.valuePatternValidatorType = Context::kPatternValidatorWithAdditionalProperty;
@@ -974,6 +1155,7 @@ public:
}
bool EndObject(Context& context, SizeType memberCount) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::EndObject");
if (hasRequired_) {
context.error_handler.StartMissingProperties();
for (SizeType index = 0; index < propertyCount_; index++)
@@ -1014,13 +1196,14 @@ public:
}
}
if (context.error_handler.EndDependencyErrors())
- RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorDependencies);
+ RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorDependencies);
}
return true;
}
bool StartArray(Context& context) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::StartArray");
context.arrayElementIndex = 0;
context.inArray = true; // Ensure we note that we are in an array
@@ -1033,13 +1216,14 @@ public:
}
bool EndArray(Context& context, SizeType elementCount) const {
+ RAPIDJSON_SCHEMA_PRINT(Method, "Schema::EndArray");
context.inArray = false;
-
+
if (elementCount < minItems_) {
context.error_handler.TooFewItems(elementCount, minItems_);
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMinItems);
}
-
+
if (elementCount > maxItems_) {
context.error_handler.TooManyItems(elementCount, maxItems_);
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMaxItems);
@@ -1081,6 +1265,9 @@ public:
case kValidateErrorAnyOf: return GetAnyOfString();
case kValidateErrorNot: return GetNotString();
+ case kValidateErrorReadOnly: return GetReadOnlyString();
+ case kValidateErrorWriteOnly: return GetWriteOnlyString();
+
default: return GetNullString();
}
}
@@ -1128,6 +1315,14 @@ public:
RAPIDJSON_STRING_(ExclusiveMaximum, 'e', 'x', 'c', 'l', 'u', 's', 'i', 'v', 'e', 'M', 'a', 'x', 'i', 'm', 'u', 'm')
RAPIDJSON_STRING_(MultipleOf, 'm', 'u', 'l', 't', 'i', 'p', 'l', 'e', 'O', 'f')
RAPIDJSON_STRING_(DefaultValue, 'd', 'e', 'f', 'a', 'u', 'l', 't')
+ RAPIDJSON_STRING_(Schema, '$', 's', 'c', 'h', 'e', 'm', 'a')
+ RAPIDJSON_STRING_(Ref, '$', 'r', 'e', 'f')
+ RAPIDJSON_STRING_(Id, 'i', 'd')
+ RAPIDJSON_STRING_(Swagger, 's', 'w', 'a', 'g', 'g', 'e', 'r')
+ RAPIDJSON_STRING_(OpenApi, 'o', 'p', 'e', 'n', 'a', 'p', 'i')
+ RAPIDJSON_STRING_(ReadOnly, 'r', 'e', 'a', 'd', 'O', 'n', 'l', 'y')
+ RAPIDJSON_STRING_(WriteOnly, 'w', 'r', 'i', 't', 'e', 'O', 'n', 'l', 'y')
+ RAPIDJSON_STRING_(Nullable, 'n', 'u', 'l', 'l', 'a', 'b', 'l', 'e')
#undef RAPIDJSON_STRING_
@@ -1193,7 +1388,7 @@ private:
out.schemas = static_cast<const Schema**>(allocator_->Malloc(out.count * sizeof(const Schema*)));
memset(out.schemas, 0, sizeof(Schema*)* out.count);
for (SizeType i = 0; i < out.count; i++)
- schemaDocument.CreateSchema(&out.schemas[i], q.Append(i, allocator_), (*v)[i], document);
+ schemaDocument.CreateSchema(&out.schemas[i], q.Append(i, allocator_), (*v)[i], document, id_);
out.begin = validatorCount_;
validatorCount_ += out.count;
}
@@ -1202,10 +1397,11 @@ private:
#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX
template <typename ValueType>
- RegexType* CreatePattern(const ValueType& value) {
+ RegexType* CreatePattern(const ValueType& value, SchemaDocumentType* sd, const PointerType& p) {
if (value.IsString()) {
RegexType* r = new (allocator_->Malloc(sizeof(RegexType))) RegexType(value.GetString(), allocator_);
if (!r->IsValid()) {
+ sd->SchemaErrorValue(kSchemaErrorRegexInvalid, p, value.GetString(), value.GetStringLength());
r->~RegexType();
AllocatorType::Free(r);
r = 0;
@@ -1221,13 +1417,14 @@ private:
}
#elif RAPIDJSON_SCHEMA_USE_STDREGEX
template <typename ValueType>
- RegexType* CreatePattern(const ValueType& value) {
+ RegexType* CreatePattern(const ValueType& value, SchemaDocumentType* sd, const PointerType& p) {
if (value.IsString()) {
RegexType *r = static_cast<RegexType*>(allocator_->Malloc(sizeof(RegexType)));
try {
return new (r) RegexType(value.GetString(), std::size_t(value.GetStringLength()), std::regex_constants::ECMAScript);
}
- catch (const std::regex_error&) {
+ catch (const std::regex_error& e) {
+ sd->SchemaErrorValue(kSchemaErrorRegexInvalid, p, value.GetString(), value.GetStringLength());
AllocatorType::Free(r);
}
}
@@ -1240,7 +1437,9 @@ private:
}
#else
template <typename ValueType>
- RegexType* CreatePattern(const ValueType&) { return 0; }
+ RegexType* CreatePattern(const ValueType&) {
+ return 0;
+ }
static bool IsPatternMatch(const RegexType*, const Ch *, SizeType) { return true; }
#endif // RAPIDJSON_SCHEMA_USE_STDREGEX
@@ -1255,6 +1454,9 @@ private:
else if (type == GetNumberString() ) type_ |= (1 << kNumberSchemaType) | (1 << kIntegerSchemaType);
}
+ // Creates parallel validators for allOf, anyOf, oneOf, not and schema dependencies, if required.
+ // Also creates a hasher for enums and array uniqueness, if required.
+ // Also a useful place to add type-independent error checks.
bool CreateParallelValidator(Context& context) const {
if (enum_ || context.arrayUniqueness)
context.hasher = context.factory.CreateHasher();
@@ -1262,6 +1464,7 @@ private:
if (validatorCount_) {
RAPIDJSON_ASSERT(context.validators == 0);
context.validators = static_cast<ISchemaValidator**>(context.factory.MallocState(sizeof(ISchemaValidator*) * validatorCount_));
+ std::memset(context.validators, 0, sizeof(ISchemaValidator*) * validatorCount_);
context.validatorCount = validatorCount_;
// Always return after first failure for these sub-validators
@@ -1270,10 +1473,10 @@ private:
if (anyOf_.schemas)
CreateSchemaValidators(context, anyOf_, false);
-
+
if (oneOf_.schemas)
CreateSchemaValidators(context, oneOf_, false);
-
+
if (not_)
context.validators[notValidatorIndex_] = context.factory.CreateSchemaValidator(*not_, false);
@@ -1284,6 +1487,16 @@ private:
}
}
+ // Add any other type-independent checks here
+ if (readOnly_ && (context.flags & kValidateWriteFlag)) {
+ context.error_handler.DisallowedWhenWriting();
+ RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorReadOnly);
+ }
+ if (writeOnly_ && (context.flags & kValidateReadFlag)) {
+ context.error_handler.DisallowedWhenReading();
+ RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorWriteOnly);
+ }
+
return true;
}
@@ -1297,7 +1510,7 @@ private:
SizeType len = name.GetStringLength();
const Ch* str = name.GetString();
for (SizeType index = 0; index < propertyCount_; index++)
- if (properties_[index].name.GetStringLength() == len &&
+ if (properties_[index].name.GetStringLength() == len &&
(std::memcmp(properties_[index].name.GetString(), str, sizeof(Ch) * len) == 0))
{
*outIndex = index;
@@ -1306,6 +1519,14 @@ private:
return false;
}
+ bool CheckBool(Context& context, bool) const {
+ if (!(type_ & (1 << kBooleanSchemaType))) {
+ DisallowedType(context, GetBooleanString());
+ RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
+ }
+ return true;
+ }
+
bool CheckInt(Context& context, int64_t i) const {
if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType)))) {
DisallowedType(context, GetIntegerString());
@@ -1420,9 +1641,13 @@ private:
bool CheckDoubleMultipleOf(Context& context, double d) const {
double a = std::abs(d), b = std::abs(multipleOf_.GetDouble());
- double q = std::floor(a / b);
- double r = a - q * b;
- if (r > 0.0) {
+ double q = a / b;
+ double qRounded = std::floor(q + 0.5);
+ double scaledEpsilon = (q + qRounded) * std::numeric_limits<double>::epsilon();
+ double difference = std::abs(qRounded - q);
+ bool isMultiple = (difference <= scaledEpsilon)
+ || (difference < std::numeric_limits<double>::min());
+ if (!isMultiple) {
context.error_handler.NotMultipleOf(d, multipleOf_);
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMultipleOf);
}
@@ -1458,7 +1683,7 @@ private:
struct PatternProperty {
PatternProperty() : schema(), pattern() {}
- ~PatternProperty() {
+ ~PatternProperty() {
if (pattern) {
pattern->~RegexType();
AllocatorType::Free(pattern);
@@ -1470,6 +1695,8 @@ private:
AllocatorType* allocator_;
SValue uri_;
+ UriType id_;
+ Specification spec_;
PointerType pointer_;
const SchemaType* typeless_;
uint64_t* enum_;
@@ -1512,8 +1739,12 @@ private:
SValue multipleOf_;
bool exclusiveMinimum_;
bool exclusiveMaximum_;
-
+
SizeType defaultValueLength_;
+
+ bool readOnly_;
+ bool writeOnly_;
+ bool nullable_;
};
template<typename Stack, typename Ch>
@@ -1555,9 +1786,18 @@ template <typename SchemaDocumentType>
class IGenericRemoteSchemaDocumentProvider {
public:
typedef typename SchemaDocumentType::Ch Ch;
+ typedef typename SchemaDocumentType::ValueType ValueType;
+ typedef typename SchemaDocumentType::AllocatorType AllocatorType;
virtual ~IGenericRemoteSchemaDocumentProvider() {}
virtual const SchemaDocumentType* GetRemoteDocument(const Ch* uri, SizeType length) = 0;
+ virtual const SchemaDocumentType* GetRemoteDocument(const GenericUri<ValueType, AllocatorType> uri, Specification& spec) {
+ // Default implementation just calls through for compatibility
+ // Following line suppresses unused parameter warning
+ (void)spec;
+ // printf("GetRemoteDocument: %d %d\n", spec.draft, spec.oapi);
+ return GetRemoteDocument(uri.GetBaseString(), uri.GetBaseStringLength());
+ }
};
///////////////////////////////////////////////////////////////////////////////
@@ -1582,7 +1822,9 @@ public:
typedef typename EncodingType::Ch Ch;
typedef internal::Schema<GenericSchemaDocument> SchemaType;
typedef GenericPointer<ValueType, Allocator> PointerType;
- typedef GenericValue<EncodingType, Allocator> URIType;
+ typedef GenericValue<EncodingType, AllocatorType> GValue;
+ typedef GenericUri<ValueType, Allocator> UriType;
+ typedef GenericStringRef<Ch> StringRefType;
friend class internal::Schema<GenericSchemaDocument>;
template <typename, typename, typename>
friend class GenericSchemaValidator;
@@ -1596,46 +1838,53 @@ public:
\param uriLength Length of \c name, in code points.
\param remoteProvider An optional remote schema document provider for resolving remote reference. Can be null.
\param allocator An optional allocator instance for allocating memory. Can be null.
+ \param pointer An optional JSON pointer to the start of the schema document
+ \param spec Optional schema draft or OpenAPI version. Used if no specification in document. Defaults to draft-04.
*/
explicit GenericSchemaDocument(const ValueType& document, const Ch* uri = 0, SizeType uriLength = 0,
- IRemoteSchemaDocumentProviderType* remoteProvider = 0, Allocator* allocator = 0) :
+ IRemoteSchemaDocumentProviderType* remoteProvider = 0, Allocator* allocator = 0,
+ const PointerType& pointer = PointerType(), // PR #1393
+ const Specification& spec = Specification(kDraft04)) :
remoteProvider_(remoteProvider),
allocator_(allocator),
ownAllocator_(),
root_(),
typeless_(),
schemaMap_(allocator, kInitialSchemaMapSize),
- schemaRef_(allocator, kInitialSchemaRefSize)
+ schemaRef_(allocator, kInitialSchemaRefSize),
+ spec_(spec),
+ error_(kObjectType),
+ currentError_()
{
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaDocument::GenericSchemaDocument");
if (!allocator_)
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
Ch noUri[1] = {0};
uri_.SetString(uri ? uri : noUri, uriLength, *allocator_);
+ docId_ = UriType(uri_, allocator_);
typeless_ = static_cast<SchemaType*>(allocator_->Malloc(sizeof(SchemaType)));
- new (typeless_) SchemaType(this, PointerType(), ValueType(kObjectType).Move(), ValueType(kObjectType).Move(), allocator_);
+ new (typeless_) SchemaType(this, PointerType(), ValueType(kObjectType).Move(), ValueType(kObjectType).Move(), allocator_, docId_);
- // Generate root schema, it will call CreateSchema() to create sub-schemas,
- // And call AddRefSchema() if there are $ref.
- CreateSchemaRecursive(&root_, PointerType(), document, document);
+ // Establish the schema draft or open api version.
+ // We only ever look for '$schema' or 'swagger' or 'openapi' at the root of the document.
+ SetSchemaSpecification(document);
- // Resolve $ref
- while (!schemaRef_.Empty()) {
- SchemaRefEntry* refEntry = schemaRef_.template Pop<SchemaRefEntry>(1);
- if (const SchemaType* s = GetSchema(refEntry->target)) {
- if (refEntry->schema)
- *refEntry->schema = s;
-
- // Create entry in map if not exist
- if (!GetSchema(refEntry->source)) {
- new (schemaMap_.template Push<SchemaEntry>()) SchemaEntry(refEntry->source, const_cast<SchemaType*>(s), false, allocator_);
- }
- }
- else if (refEntry->schema)
- *refEntry->schema = typeless_;
-
- refEntry->~SchemaRefEntry();
+ // Generate root schema, it will call CreateSchema() to create sub-schemas,
+ // And call HandleRefSchema() if there are $ref.
+ // PR #1393 use input pointer if supplied
+ root_ = typeless_;
+ if (pointer.GetTokenCount() == 0) {
+ CreateSchemaRecursive(&root_, pointer, document, document, docId_);
+ }
+ else if (const ValueType* v = pointer.Get(document)) {
+ CreateSchema(&root_, pointer, *v, document, docId_);
+ }
+ else {
+ GenericStringBuffer<EncodingType> sb;
+ pointer.StringifyUriFragment(sb);
+ SchemaErrorValue(kSchemaErrorStartUnknown, PointerType(), sb.GetString(), static_cast<SizeType>(sb.GetSize() / sizeof(Ch)));
}
RAPIDJSON_ASSERT(root_ != 0);
@@ -1653,7 +1902,11 @@ public:
typeless_(rhs.typeless_),
schemaMap_(std::move(rhs.schemaMap_)),
schemaRef_(std::move(rhs.schemaRef_)),
- uri_(std::move(rhs.uri_))
+ uri_(std::move(rhs.uri_)),
+ docId_(std::move(rhs.docId_)),
+ spec_(rhs.spec_),
+ error_(std::move(rhs.error_)),
+ currentError_(std::move(rhs.currentError_))
{
rhs.remoteProvider_ = 0;
rhs.allocator_ = 0;
@@ -1672,26 +1925,87 @@ public:
Allocator::Free(typeless_);
}
+ // these may contain some allocator data so clear before deleting ownAllocator_
+ uri_.SetNull();
+ error_.SetNull();
+ currentError_.SetNull();
+
RAPIDJSON_DELETE(ownAllocator_);
}
- const URIType& GetURI() const { return uri_; }
+ const GValue& GetURI() const { return uri_; }
+
+ const Specification& GetSpecification() const { return spec_; }
+ bool IsSupportedSpecification() const { return spec_.IsSupported(); }
+
+ //! Static method to get the specification of any schema document
+ // Returns kDraftNone if document is silent
+ static const Specification GetSpecification(const ValueType& document) {
+ SchemaDraft draft = GetSchemaDraft(document);
+ if (draft != kDraftNone)
+ return Specification(draft);
+ else {
+ OpenApiVersion oapi = GetOpenApiVersion(document);
+ if (oapi != kVersionNone)
+ return Specification(oapi);
+ }
+ return Specification(kDraftNone);
+ }
//! Get the root schema.
const SchemaType& GetRoot() const { return *root_; }
-private:
+ //! Gets the error object.
+ GValue& GetError() { return error_; }
+ const GValue& GetError() const { return error_; }
+
+ static const StringRefType& GetSchemaErrorKeyword(SchemaErrorCode schemaErrorCode) {
+ switch (schemaErrorCode) {
+ case kSchemaErrorStartUnknown: return GetStartUnknownString();
+ case kSchemaErrorRefPlainName: return GetRefPlainNameString();
+ case kSchemaErrorRefInvalid: return GetRefInvalidString();
+ case kSchemaErrorRefPointerInvalid: return GetRefPointerInvalidString();
+ case kSchemaErrorRefUnknown: return GetRefUnknownString();
+ case kSchemaErrorRefCyclical: return GetRefCyclicalString();
+ case kSchemaErrorRefNoRemoteProvider: return GetRefNoRemoteProviderString();
+ case kSchemaErrorRefNoRemoteSchema: return GetRefNoRemoteSchemaString();
+ case kSchemaErrorRegexInvalid: return GetRegexInvalidString();
+ case kSchemaErrorSpecUnknown: return GetSpecUnknownString();
+ case kSchemaErrorSpecUnsupported: return GetSpecUnsupportedString();
+ case kSchemaErrorSpecIllegal: return GetSpecIllegalString();
+ case kSchemaErrorReadOnlyAndWriteOnly: return GetReadOnlyAndWriteOnlyString();
+ default: return GetNullString();
+ }
+ }
+
+ //! Default error method
+ void SchemaError(const SchemaErrorCode code, const PointerType& location) {
+ currentError_ = GValue(kObjectType);
+ AddCurrentError(code, location);
+ }
+
+ //! Method for error with single string value insert
+ void SchemaErrorValue(const SchemaErrorCode code, const PointerType& location, const Ch* value, SizeType length) {
+ currentError_ = GValue(kObjectType);
+ currentError_.AddMember(GetValueString(), GValue(value, length, *allocator_).Move(), *allocator_);
+ AddCurrentError(code, location);
+ }
+
+ //! Method for error with invalid pointer
+ void SchemaErrorPointer(const SchemaErrorCode code, const PointerType& location, const Ch* value, SizeType length, const PointerType& pointer) {
+ currentError_ = GValue(kObjectType);
+ currentError_.AddMember(GetValueString(), GValue(value, length, *allocator_).Move(), *allocator_);
+ currentError_.AddMember(GetOffsetString(), static_cast<SizeType>(pointer.GetParseErrorOffset() / sizeof(Ch)), *allocator_);
+ AddCurrentError(code, location);
+ }
+
+ private:
//! Prohibit copying
GenericSchemaDocument(const GenericSchemaDocument&);
//! Prohibit assignment
GenericSchemaDocument& operator=(const GenericSchemaDocument&);
- struct SchemaRefEntry {
- SchemaRefEntry(const PointerType& s, const PointerType& t, const SchemaType** outSchema, Allocator *allocator) : source(s, allocator), target(t, allocator), schema(outSchema) {}
- PointerType source;
- PointerType target;
- const SchemaType** schema;
- };
+ typedef const PointerType* SchemaRefPtr; // PR #1393
struct SchemaEntry {
SchemaEntry(const PointerType& p, SchemaType* s, bool o, Allocator* allocator) : pointer(p, allocator), schema(s), owned(o) {}
@@ -1706,79 +2020,361 @@ private:
bool owned;
};
- void CreateSchemaRecursive(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document) {
- if (schema)
- *schema = typeless_;
+ void AddErrorInstanceLocation(GValue& result, const PointerType& location) {
+ GenericStringBuffer<EncodingType> sb;
+ location.StringifyUriFragment(sb);
+ GValue instanceRef(sb.GetString(), static_cast<SizeType>(sb.GetSize() / sizeof(Ch)), *allocator_);
+ result.AddMember(GetInstanceRefString(), instanceRef, *allocator_);
+ }
+ void AddError(GValue& keyword, GValue& error) {
+ typename GValue::MemberIterator member = error_.FindMember(keyword);
+ if (member == error_.MemberEnd())
+ error_.AddMember(keyword, error, *allocator_);
+ else {
+ if (member->value.IsObject()) {
+ GValue errors(kArrayType);
+ errors.PushBack(member->value, *allocator_);
+ member->value = errors;
+ }
+ member->value.PushBack(error, *allocator_);
+ }
+ }
+
+ void AddCurrentError(const SchemaErrorCode code, const PointerType& location) {
+ RAPIDJSON_SCHEMA_PRINT(InvalidKeyword, GetSchemaErrorKeyword(code));
+ currentError_.AddMember(GetErrorCodeString(), code, *allocator_);
+ AddErrorInstanceLocation(currentError_, location);
+ AddError(GValue(GetSchemaErrorKeyword(code)).Move(), currentError_);
+ }
+
+#define RAPIDJSON_STRING_(name, ...) \
+ static const StringRefType& Get##name##String() {\
+ static const Ch s[] = { __VA_ARGS__, '\0' };\
+ static const StringRefType v(s, static_cast<SizeType>(sizeof(s) / sizeof(Ch) - 1)); \
+ return v;\
+ }
+
+ RAPIDJSON_STRING_(InstanceRef, 'i', 'n', 's', 't', 'a', 'n', 'c', 'e', 'R', 'e', 'f')
+ RAPIDJSON_STRING_(ErrorCode, 'e', 'r', 'r', 'o', 'r', 'C', 'o', 'd', 'e')
+ RAPIDJSON_STRING_(Value, 'v', 'a', 'l', 'u', 'e')
+ RAPIDJSON_STRING_(Offset, 'o', 'f', 'f', 's', 'e', 't')
+
+ RAPIDJSON_STRING_(Null, 'n', 'u', 'l', 'l')
+ RAPIDJSON_STRING_(SpecUnknown, 'S', 'p', 'e', 'c', 'U', 'n', 'k', 'n', 'o', 'w', 'n')
+ RAPIDJSON_STRING_(SpecUnsupported, 'S', 'p', 'e', 'c', 'U', 'n', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd')
+ RAPIDJSON_STRING_(SpecIllegal, 'S', 'p', 'e', 'c', 'I', 'l', 'l', 'e', 'g', 'a', 'l')
+ RAPIDJSON_STRING_(StartUnknown, 'S', 't', 'a', 'r', 't', 'U', 'n', 'k', 'n', 'o', 'w', 'n')
+ RAPIDJSON_STRING_(RefPlainName, 'R', 'e', 'f', 'P', 'l', 'a', 'i', 'n', 'N', 'a', 'm', 'e')
+ RAPIDJSON_STRING_(RefInvalid, 'R', 'e', 'f', 'I', 'n', 'v', 'a', 'l', 'i', 'd')
+ RAPIDJSON_STRING_(RefPointerInvalid, 'R', 'e', 'f', 'P', 'o', 'i', 'n', 't', 'e', 'r', 'I', 'n', 'v', 'a', 'l', 'i', 'd')
+ RAPIDJSON_STRING_(RefUnknown, 'R', 'e', 'f', 'U', 'n', 'k', 'n', 'o', 'w', 'n')
+ RAPIDJSON_STRING_(RefCyclical, 'R', 'e', 'f', 'C', 'y', 'c', 'l', 'i', 'c', 'a', 'l')
+ RAPIDJSON_STRING_(RefNoRemoteProvider, 'R', 'e', 'f', 'N', 'o', 'R', 'e', 'm', 'o', 't', 'e', 'P', 'r', 'o', 'v', 'i', 'd', 'e', 'r')
+ RAPIDJSON_STRING_(RefNoRemoteSchema, 'R', 'e', 'f', 'N', 'o', 'R', 'e', 'm', 'o', 't', 'e', 'S', 'c', 'h', 'e', 'm', 'a')
+ RAPIDJSON_STRING_(ReadOnlyAndWriteOnly, 'R', 'e', 'a', 'd', 'O', 'n', 'l', 'y', 'A', 'n', 'd', 'W', 'r', 'i', 't', 'e', 'O', 'n', 'l', 'y')
+ RAPIDJSON_STRING_(RegexInvalid, 'R', 'e', 'g', 'e', 'x', 'I', 'n', 'v', 'a', 'l', 'i', 'd')
+
+#undef RAPIDJSON_STRING_
+
+ // Static method to get schema draft of any schema document
+ static SchemaDraft GetSchemaDraft(const ValueType& document) {
+ static const Ch kDraft03String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '3', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
+ static const Ch kDraft04String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '4', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
+ static const Ch kDraft05String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '5', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
+ static const Ch kDraft06String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '6', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
+ static const Ch kDraft07String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '7', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
+ static const Ch kDraft2019_09String[] = { 'h', 't', 't', 'p', 's', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '/', '2', '0', '1', '9', '-', '0', '9', '/', 's', 'c', 'h', 'e', 'm', 'a', '\0' };
+ static const Ch kDraft2020_12String[] = { 'h', 't', 't', 'p', 's', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '/', '2', '0', '2', '0', '-', '1', '2', '/', 's', 'c', 'h', 'e', 'm', 'a', '\0' };
+
+ if (!document.IsObject()) {
+ return kDraftNone;
+ }
+
+ // Get the schema draft from the $schema keyword at the supplied location
+ typename ValueType::ConstMemberIterator itr = document.FindMember(SchemaType::GetSchemaString());
+ if (itr != document.MemberEnd()) {
+ if (!itr->value.IsString()) return kDraftUnknown;
+ const UriType draftUri(itr->value);
+ // Check base uri for match
+ if (draftUri.Match(UriType(kDraft04String), false)) return kDraft04;
+ if (draftUri.Match(UriType(kDraft05String), false)) return kDraft05;
+ if (draftUri.Match(UriType(kDraft06String), false)) return kDraft06;
+ if (draftUri.Match(UriType(kDraft07String), false)) return kDraft07;
+ if (draftUri.Match(UriType(kDraft03String), false)) return kDraft03;
+ if (draftUri.Match(UriType(kDraft2019_09String), false)) return kDraft2019_09;
+ if (draftUri.Match(UriType(kDraft2020_12String), false)) return kDraft2020_12;
+ return kDraftUnknown;
+ }
+ // $schema not found
+ return kDraftNone;
+ }
+
+
+ // Get open api version of any schema document
+ static OpenApiVersion GetOpenApiVersion(const ValueType& document) {
+ static const Ch kVersion20String[] = { '2', '.', '0', '\0' };
+ static const Ch kVersion30String[] = { '3', '.', '0', '.', '\0' }; // ignore patch level
+ static const Ch kVersion31String[] = { '3', '.', '1', '.', '\0' }; // ignore patch level
+ static SizeType len = internal::StrLen<Ch>(kVersion30String);
+
+ if (!document.IsObject()) {
+ return kVersionNone;
+ }
+
+ // Get the open api version from the swagger / openapi keyword at the supplied location
+ typename ValueType::ConstMemberIterator itr = document.FindMember(SchemaType::GetSwaggerString());
+ if (itr == document.MemberEnd()) itr = document.FindMember(SchemaType::GetOpenApiString());
+ if (itr != document.MemberEnd()) {
+ if (!itr->value.IsString()) return kVersionUnknown;
+ const ValueType kVersion20Value(kVersion20String);
+ if (kVersion20Value == itr->value) return kVersion20; // must match 2.0 exactly
+ const ValueType kVersion30Value(kVersion30String);
+ if (itr->value.GetStringLength() > len && kVersion30Value == ValueType(itr->value.GetString(), len)) return kVersion30; // must match 3.0.x
+ const ValueType kVersion31Value(kVersion31String);
+ if (itr->value.GetStringLength() > len && kVersion31Value == ValueType(itr->value.GetString(), len)) return kVersion31; // must match 3.1.x
+ return kVersionUnknown;
+ }
+ // swagger or openapi not found
+ return kVersionNone;
+ }
+
+ // Get the draft of the schema or the open api version (which implies the draft).
+ // Report an error if schema draft or open api version not supported or not recognized, or both in document, and carry on.
+ void SetSchemaSpecification(const ValueType& document) {
+ // Look for '$schema', 'swagger' or 'openapi' keyword at document root
+ SchemaDraft docDraft = GetSchemaDraft(document);
+ OpenApiVersion docOapi = GetOpenApiVersion(document);
+ // Error if both in document
+ if (docDraft != kDraftNone && docOapi != kVersionNone)
+ SchemaError(kSchemaErrorSpecIllegal, PointerType());
+ // Use document draft or open api version if present or use spec from constructor
+ if (docDraft != kDraftNone)
+ spec_ = Specification(docDraft);
+ else if (docOapi != kVersionNone)
+ spec_ = Specification(docOapi);
+ // Error if draft or version unknown
+ if (spec_.draft == kDraftUnknown || spec_.oapi == kVersionUnknown)
+ SchemaError(kSchemaErrorSpecUnknown, PointerType());
+ else if (!spec_.IsSupported())
+ SchemaError(kSchemaErrorSpecUnsupported, PointerType());
+ }
+
+ // Changed by PR #1393
+ void CreateSchemaRecursive(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document, const UriType& id) {
if (v.GetType() == kObjectType) {
- const SchemaType* s = GetSchema(pointer);
- if (!s)
- CreateSchema(schema, pointer, v, document);
+ UriType newid = UriType(CreateSchema(schema, pointer, v, document, id), allocator_);
for (typename ValueType::ConstMemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr)
- CreateSchemaRecursive(0, pointer.Append(itr->name, allocator_), itr->value, document);
+ CreateSchemaRecursive(0, pointer.Append(itr->name, allocator_), itr->value, document, newid);
}
else if (v.GetType() == kArrayType)
for (SizeType i = 0; i < v.Size(); i++)
- CreateSchemaRecursive(0, pointer.Append(i, allocator_), v[i], document);
+ CreateSchemaRecursive(0, pointer.Append(i, allocator_), v[i], document, id);
}
- void CreateSchema(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document) {
+ // Changed by PR #1393
+ const UriType& CreateSchema(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document, const UriType& id) {
RAPIDJSON_ASSERT(pointer.IsValid());
+ GenericStringBuffer<EncodingType> sb;
+ pointer.StringifyUriFragment(sb);
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaDocument::CreateSchema", sb.GetString(), id.GetString());
if (v.IsObject()) {
- if (!HandleRefSchema(pointer, schema, v, document)) {
- SchemaType* s = new (allocator_->Malloc(sizeof(SchemaType))) SchemaType(this, pointer, v, document, allocator_);
- new (schemaMap_.template Push<SchemaEntry>()) SchemaEntry(pointer, s, true, allocator_);
+ if (const SchemaType* sc = GetSchema(pointer)) {
+ if (schema)
+ *schema = sc;
+ AddSchemaRefs(const_cast<SchemaType*>(sc));
+ }
+ else if (!HandleRefSchema(pointer, schema, v, document, id)) {
+ // The new schema constructor adds itself and its $ref(s) to schemaMap_
+ SchemaType* s = new (allocator_->Malloc(sizeof(SchemaType))) SchemaType(this, pointer, v, document, allocator_, id);
if (schema)
*schema = s;
+ return s->GetId();
}
}
+ else {
+ if (schema)
+ *schema = typeless_;
+ AddSchemaRefs(typeless_);
+ }
+ return id;
}
- bool HandleRefSchema(const PointerType& source, const SchemaType** schema, const ValueType& v, const ValueType& document) {
- static const Ch kRefString[] = { '$', 'r', 'e', 'f', '\0' };
- static const ValueType kRefValue(kRefString, 4);
-
- typename ValueType::ConstMemberIterator itr = v.FindMember(kRefValue);
+ // Changed by PR #1393
+ // TODO should this return a UriType& ?
+ bool HandleRefSchema(const PointerType& source, const SchemaType** schema, const ValueType& v, const ValueType& document, const UriType& id) {
+ typename ValueType::ConstMemberIterator itr = v.FindMember(SchemaType::GetRefString());
if (itr == v.MemberEnd())
return false;
+ GenericStringBuffer<EncodingType> sb;
+ source.StringifyUriFragment(sb);
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaDocument::HandleRefSchema", sb.GetString(), id.GetString());
+ // Resolve the source pointer to the $ref'ed schema (finally)
+ new (schemaRef_.template Push<SchemaRefPtr>()) SchemaRefPtr(&source);
+
if (itr->value.IsString()) {
SizeType len = itr->value.GetStringLength();
- if (len > 0) {
- const Ch* s = itr->value.GetString();
- SizeType i = 0;
- while (i < len && s[i] != '#') // Find the first #
- i++;
-
- if (i > 0) { // Remote reference, resolve immediately
- if (remoteProvider_) {
- if (const GenericSchemaDocument* remoteDocument = remoteProvider_->GetRemoteDocument(s, i)) {
- PointerType pointer(&s[i], len - i, allocator_);
- if (pointer.IsValid()) {
- if (const SchemaType* sc = remoteDocument->GetSchema(pointer)) {
- if (schema)
- *schema = sc;
- new (schemaMap_.template Push<SchemaEntry>()) SchemaEntry(source, const_cast<SchemaType*>(sc), false, allocator_);
+ if (len == 0)
+ SchemaError(kSchemaErrorRefInvalid, source);
+ else {
+ // First resolve $ref against the in-scope id
+ UriType scopeId = UriType(id, allocator_);
+ UriType ref = UriType(itr->value, allocator_).Resolve(scopeId, allocator_);
+ RAPIDJSON_SCHEMA_PRINT(SchemaIds, id.GetString(), itr->value.GetString(), ref.GetString());
+ // See if the resolved $ref minus the fragment matches a resolved id in this document
+ // Search from the root. Returns the subschema in the document and its absolute JSON pointer.
+ PointerType basePointer = PointerType();
+ const ValueType *base = FindId(document, ref, basePointer, docId_, false);
+ if (!base) {
+ // Remote reference - call the remote document provider
+ if (!remoteProvider_)
+ SchemaError(kSchemaErrorRefNoRemoteProvider, source);
+ else {
+ if (const GenericSchemaDocument* remoteDocument = remoteProvider_->GetRemoteDocument(ref, spec_)) {
+ const Ch* s = ref.GetFragString();
+ len = ref.GetFragStringLength();
+ if (len <= 1 || s[1] == '/') {
+ // JSON pointer fragment, absolute in the remote schema
+ const PointerType pointer(s, len, allocator_);
+ if (!pointer.IsValid())
+ SchemaErrorPointer(kSchemaErrorRefPointerInvalid, source, s, len, pointer);
+ else {
+ // Get the subschema
+ if (const SchemaType *sc = remoteDocument->GetSchema(pointer)) {
+ if (schema)
+ *schema = sc;
+ AddSchemaRefs(const_cast<SchemaType *>(sc));
+ return true;
+ } else
+ SchemaErrorValue(kSchemaErrorRefUnknown, source, ref.GetString(), ref.GetStringLength());
+ }
+ } else
+ // Plain name fragment, not allowed in remote schema
+ SchemaErrorValue(kSchemaErrorRefPlainName, source, s, len);
+ } else
+ SchemaErrorValue(kSchemaErrorRefNoRemoteSchema, source, ref.GetString(), ref.GetStringLength());
+ }
+ }
+ else { // Local reference
+ const Ch* s = ref.GetFragString();
+ len = ref.GetFragStringLength();
+ if (len <= 1 || s[1] == '/') {
+ // JSON pointer fragment, relative to the resolved URI
+ const PointerType relPointer(s, len, allocator_);
+ if (!relPointer.IsValid())
+ SchemaErrorPointer(kSchemaErrorRefPointerInvalid, source, s, len, relPointer);
+ else {
+ // Get the subschema
+ if (const ValueType *pv = relPointer.Get(*base)) {
+ // Now get the absolute JSON pointer by adding relative to base
+ PointerType pointer(basePointer, allocator_);
+ for (SizeType i = 0; i < relPointer.GetTokenCount(); i++)
+ pointer = pointer.Append(relPointer.GetTokens()[i], allocator_);
+ if (IsCyclicRef(pointer))
+ SchemaErrorValue(kSchemaErrorRefCyclical, source, ref.GetString(), ref.GetStringLength());
+ else {
+ // Call CreateSchema recursively, but first compute the in-scope id for the $ref target as we have jumped there
+ // TODO: cache pointer <-> id mapping
+ size_t unresolvedTokenIndex;
+ scopeId = pointer.GetUri(document, docId_, &unresolvedTokenIndex, allocator_);
+ CreateSchema(schema, pointer, *pv, document, scopeId);
return true;
}
- }
+ } else
+ SchemaErrorValue(kSchemaErrorRefUnknown, source, ref.GetString(), ref.GetStringLength());
}
+ } else {
+ // Plain name fragment, relative to the resolved URI
+ // Not supported in open api 2.0 and 3.0
+ PointerType pointer(allocator_);
+ if (spec_.oapi == kVersion20 || spec_.oapi == kVersion30)
+ SchemaErrorValue(kSchemaErrorRefPlainName, source, s, len);
+ // See if the fragment matches an id in this document.
+ // Search from the base we just established. Returns the subschema in the document and its absolute JSON pointer.
+ else if (const ValueType *pv = FindId(*base, ref, pointer, UriType(ref.GetBaseString(), ref.GetBaseStringLength(), allocator_), true, basePointer)) {
+ if (IsCyclicRef(pointer))
+ SchemaErrorValue(kSchemaErrorRefCyclical, source, ref.GetString(), ref.GetStringLength());
+ else {
+ // Call CreateSchema recursively, but first compute the in-scope id for the $ref target as we have jumped there
+ // TODO: cache pointer <-> id mapping
+ size_t unresolvedTokenIndex;
+ scopeId = pointer.GetUri(document, docId_, &unresolvedTokenIndex, allocator_);
+ CreateSchema(schema, pointer, *pv, document, scopeId);
+ return true;
+ }
+ } else
+ SchemaErrorValue(kSchemaErrorRefUnknown, source, ref.GetString(), ref.GetStringLength());
}
}
- else if (s[i] == '#') { // Local reference, defer resolution
- PointerType pointer(&s[i], len - i, allocator_);
- if (pointer.IsValid()) {
- if (const ValueType* nv = pointer.Get(document))
- if (HandleRefSchema(source, schema, *nv, document))
- return true;
+ }
+ }
- new (schemaRef_.template Push<SchemaRefEntry>()) SchemaRefEntry(source, pointer, schema, allocator_);
- return true;
- }
+ // Invalid/Unknown $ref
+ if (schema)
+ *schema = typeless_;
+ AddSchemaRefs(typeless_);
+ return true;
+ }
+
+ //! Find the first subschema with a resolved 'id' that matches the specified URI.
+ // If full specified use all URI else ignore fragment.
+ // If found, return a pointer to the subschema and its JSON pointer.
+ // TODO cache pointer <-> id mapping
+ ValueType* FindId(const ValueType& doc, const UriType& finduri, PointerType& resptr, const UriType& baseuri, bool full, const PointerType& here = PointerType()) const {
+ SizeType i = 0;
+ ValueType* resval = 0;
+ UriType tempuri = UriType(finduri, allocator_);
+ UriType localuri = UriType(baseuri, allocator_);
+ if (doc.GetType() == kObjectType) {
+ // Establish the base URI of this object
+ typename ValueType::ConstMemberIterator m = doc.FindMember(SchemaType::GetIdString());
+ if (m != doc.MemberEnd() && m->value.GetType() == kStringType) {
+ localuri = UriType(m->value, allocator_).Resolve(baseuri, allocator_);
+ }
+ // See if it matches
+ if (localuri.Match(finduri, full)) {
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaDocument::FindId (match)", full ? localuri.GetString() : localuri.GetBaseString());
+ resval = const_cast<ValueType *>(&doc);
+ resptr = here;
+ return resval;
+ }
+ // No match, continue looking
+ for (m = doc.MemberBegin(); m != doc.MemberEnd(); ++m) {
+ if (m->value.GetType() == kObjectType || m->value.GetType() == kArrayType) {
+ resval = FindId(m->value, finduri, resptr, localuri, full, here.Append(m->name.GetString(), m->name.GetStringLength(), allocator_));
+ }
+ if (resval) break;
+ }
+ } else if (doc.GetType() == kArrayType) {
+ // Continue looking
+ for (typename ValueType::ConstValueIterator v = doc.Begin(); v != doc.End(); ++v) {
+ if (v->GetType() == kObjectType || v->GetType() == kArrayType) {
+ resval = FindId(*v, finduri, resptr, localuri, full, here.Append(i, allocator_));
}
+ if (resval) break;
+ i++;
}
}
+ return resval;
+ }
+
+ // Added by PR #1393
+ void AddSchemaRefs(SchemaType* schema) {
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaDocument::AddSchemaRefs");
+ while (!schemaRef_.Empty()) {
+ SchemaRefPtr *ref = schemaRef_.template Pop<SchemaRefPtr>(1);
+ SchemaEntry *entry = schemaMap_.template Push<SchemaEntry>();
+ new (entry) SchemaEntry(**ref, schema, false, allocator_);
+ }
+ }
+
+ // Added by PR #1393
+ bool IsCyclicRef(const PointerType& pointer) const {
+ for (const SchemaRefPtr* ref = schemaRef_.template Bottom<SchemaRefPtr>(); ref != schemaRef_.template End<SchemaRefPtr>(); ++ref)
+ if (pointer == **ref)
+ return true;
return false;
}
@@ -1807,8 +2403,12 @@ private:
const SchemaType* root_; //!< Root schema.
SchemaType* typeless_;
internal::Stack<Allocator> schemaMap_; // Stores created Pointer -> Schemas
- internal::Stack<Allocator> schemaRef_; // Stores Pointer from $ref and schema which holds the $ref
- URIType uri_;
+ internal::Stack<Allocator> schemaRef_; // Stores Pointer(s) from $ref(s) until resolved
+ GValue uri_; // Schema document URI
+ UriType docId_;
+ Specification spec_;
+ GValue error_;
+ GValue currentError_;
};
//! GenericSchemaDocument using Value type.
@@ -1872,11 +2472,10 @@ public:
currentError_(),
missingDependents_(),
valid_(true),
- flags_(kValidateDefaultFlags)
-#if RAPIDJSON_SCHEMA_VERBOSE
- , depth_(0)
-#endif
+ flags_(kValidateDefaultFlags),
+ depth_(0)
{
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::GenericSchemaValidator");
}
//! Constructor with output handler.
@@ -1904,11 +2503,10 @@ public:
currentError_(),
missingDependents_(),
valid_(true),
- flags_(kValidateDefaultFlags)
-#if RAPIDJSON_SCHEMA_VERBOSE
- , depth_(0)
-#endif
+ flags_(kValidateDefaultFlags),
+ depth_(0)
{
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::GenericSchemaValidator (output handler)");
}
//! Destructor.
@@ -1941,13 +2539,12 @@ public:
return flags_;
}
- //! Checks whether the current state is valid.
- // Implementation of ISchemaValidator
virtual bool IsValid() const {
if (!valid_) return false;
if (GetContinueOnErrors() && !error_.ObjectEmpty()) return false;
return true;
}
+ //! End of Implementation of ISchemaValidator
//! Gets the error object.
ValueType& GetError() { return error_; }
@@ -1963,7 +2560,7 @@ public:
// If reporting all errors, the stack will be empty, so return "errors".
const Ch* GetInvalidSchemaKeyword() const {
if (!schemaStack_.Empty()) return CurrentContext().invalidKeyword;
- if (GetContinueOnErrors() && !error_.ObjectEmpty()) return (const Ch*)GetErrorsString();
+ if (GetContinueOnErrors() && !error_.ObjectEmpty()) return static_cast<const Ch*>(GetErrorsString());
return 0;
}
@@ -2155,13 +2752,29 @@ public:
void NoneOf(ISchemaValidator** subvalidators, SizeType count) {
AddErrorArray(kValidateErrorAnyOf, subvalidators, count);
}
- void NotOneOf(ISchemaValidator** subvalidators, SizeType count, bool matched = false) {
- AddErrorArray(matched ? kValidateErrorOneOfMatch : kValidateErrorOneOf, subvalidators, count);
+ void NotOneOf(ISchemaValidator** subvalidators, SizeType count) {
+ AddErrorArray(kValidateErrorOneOf, subvalidators, count);
+ }
+ void MultipleOneOf(SizeType index1, SizeType index2) {
+ ValueType matches(kArrayType);
+ matches.PushBack(index1, GetStateAllocator());
+ matches.PushBack(index2, GetStateAllocator());
+ currentError_.SetObject();
+ currentError_.AddMember(GetMatchesString(), matches, GetStateAllocator());
+ AddCurrentError(kValidateErrorOneOfMatch);
}
void Disallowed() {
currentError_.SetObject();
AddCurrentError(kValidateErrorNot);
}
+ void DisallowedWhenWriting() {
+ currentError_.SetObject();
+ AddCurrentError(kValidateErrorReadOnly);
+ }
+ void DisallowedWhenReading() {
+ currentError_.SetObject();
+ AddCurrentError(kValidateErrorWriteOnly);
+ }
#define RAPIDJSON_STRING_(name, ...) \
static const StringRefType& Get##name##String() {\
@@ -2180,25 +2793,18 @@ public:
RAPIDJSON_STRING_(ErrorCode, 'e', 'r', 'r', 'o', 'r', 'C', 'o', 'd', 'e')
RAPIDJSON_STRING_(ErrorMessage, 'e', 'r', 'r', 'o', 'r', 'M', 'e', 's', 's', 'a', 'g', 'e')
RAPIDJSON_STRING_(Duplicates, 'd', 'u', 'p', 'l', 'i', 'c', 'a', 't', 'e', 's')
+ RAPIDJSON_STRING_(Matches, 'm', 'a', 't', 'c', 'h', 'e', 's')
#undef RAPIDJSON_STRING_
-#if RAPIDJSON_SCHEMA_VERBOSE
-#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_() \
-RAPIDJSON_MULTILINEMACRO_BEGIN\
- *documentStack_.template Push<Ch>() = '\0';\
- documentStack_.template Pop<Ch>(1);\
- internal::PrintInvalidDocument(documentStack_.template Bottom<Ch>());\
-RAPIDJSON_MULTILINEMACRO_END
-#else
-#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_()
-#endif
-
#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_(method, arg1)\
if (!valid_) return false; \
if ((!BeginValue() && !GetContinueOnErrors()) || (!CurrentSchema().method arg1 && !GetContinueOnErrors())) {\
- RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_();\
- return valid_ = false;\
+ *documentStack_.template Push<Ch>() = '\0';\
+ documentStack_.template Pop<Ch>(1);\
+ RAPIDJSON_SCHEMA_PRINT(InvalidDocument, documentStack_.template Bottom<Ch>());\
+ valid_ = false;\
+ return valid_;\
}
#define RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(method, arg2)\
@@ -2235,52 +2841,68 @@ RAPIDJSON_MULTILINEMACRO_END
{ RAPIDJSON_SCHEMA_HANDLE_VALUE_(String, (CurrentContext(), str, length, copy), (str, length, copy)); }
bool StartObject() {
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::StartObject");
RAPIDJSON_SCHEMA_HANDLE_BEGIN_(StartObject, (CurrentContext()));
RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(StartObject, ());
- return valid_ = !outputHandler_ || outputHandler_->StartObject();
+ valid_ = !outputHandler_ || outputHandler_->StartObject();
+ return valid_;
}
bool Key(const Ch* str, SizeType len, bool copy) {
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::Key", str);
if (!valid_) return false;
AppendToken(str, len);
- if (!CurrentSchema().Key(CurrentContext(), str, len, copy) && !GetContinueOnErrors()) return valid_ = false;
+ if (!CurrentSchema().Key(CurrentContext(), str, len, copy) && !GetContinueOnErrors()) {
+ valid_ = false;
+ return valid_;
+ }
RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(Key, (str, len, copy));
- return valid_ = !outputHandler_ || outputHandler_->Key(str, len, copy);
+ valid_ = !outputHandler_ || outputHandler_->Key(str, len, copy);
+ return valid_;
}
bool EndObject(SizeType memberCount) {
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::EndObject");
if (!valid_) return false;
RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(EndObject, (memberCount));
- if (!CurrentSchema().EndObject(CurrentContext(), memberCount) && !GetContinueOnErrors()) return valid_ = false;
+ if (!CurrentSchema().EndObject(CurrentContext(), memberCount) && !GetContinueOnErrors()) {
+ valid_ = false;
+ return valid_;
+ }
RAPIDJSON_SCHEMA_HANDLE_END_(EndObject, (memberCount));
}
bool StartArray() {
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::StartArray");
RAPIDJSON_SCHEMA_HANDLE_BEGIN_(StartArray, (CurrentContext()));
RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(StartArray, ());
- return valid_ = !outputHandler_ || outputHandler_->StartArray();
+ valid_ = !outputHandler_ || outputHandler_->StartArray();
+ return valid_;
}
bool EndArray(SizeType elementCount) {
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::EndArray");
if (!valid_) return false;
RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(EndArray, (elementCount));
- if (!CurrentSchema().EndArray(CurrentContext(), elementCount) && !GetContinueOnErrors()) return valid_ = false;
+ if (!CurrentSchema().EndArray(CurrentContext(), elementCount) && !GetContinueOnErrors()) {
+ valid_ = false;
+ return valid_;
+ }
RAPIDJSON_SCHEMA_HANDLE_END_(EndArray, (elementCount));
}
-#undef RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_
#undef RAPIDJSON_SCHEMA_HANDLE_BEGIN_
#undef RAPIDJSON_SCHEMA_HANDLE_PARALLEL_
#undef RAPIDJSON_SCHEMA_HANDLE_VALUE_
// Implementation of ISchemaStateFactory<SchemaType>
virtual ISchemaValidator* CreateSchemaValidator(const SchemaType& root, const bool inheritContinueOnErrors) {
+ *documentStack_.template Push<Ch>() = '\0';
+ documentStack_.template Pop<Ch>(1);
ISchemaValidator* sv = new (GetStateAllocator().Malloc(sizeof(GenericSchemaValidator))) GenericSchemaValidator(*schemaDocument_, root, documentStack_.template Bottom<char>(), documentStack_.GetSize(),
-#if RAPIDJSON_SCHEMA_VERBOSE
depth_ + 1,
-#endif
&GetStateAllocator());
- sv->SetValidateFlags(inheritContinueOnErrors ? GetValidateFlags() : GetValidateFlags() & ~(unsigned)kValidateContinueOnErrorFlag);
+ sv->SetValidateFlags(inheritContinueOnErrors ? GetValidateFlags() : GetValidateFlags() & ~static_cast<unsigned>(kValidateContinueOnErrorFlag));
return sv;
}
@@ -2311,6 +2933,7 @@ RAPIDJSON_MULTILINEMACRO_END
virtual void FreeState(void* p) {
StateAllocator::Free(p);
}
+ // End of implementation of ISchemaStateFactory<SchemaType>
private:
typedef typename SchemaType::Context Context;
@@ -2321,9 +2944,7 @@ private:
const SchemaDocumentType& schemaDocument,
const SchemaType& root,
const char* basePath, size_t basePathSize,
-#if RAPIDJSON_SCHEMA_VERBOSE
unsigned depth,
-#endif
StateAllocator* allocator = 0,
size_t schemaStackCapacity = kDefaultSchemaStackCapacity,
size_t documentStackCapacity = kDefaultDocumentStackCapacity)
@@ -2339,11 +2960,10 @@ private:
currentError_(),
missingDependents_(),
valid_(true),
- flags_(kValidateDefaultFlags)
-#if RAPIDJSON_SCHEMA_VERBOSE
- , depth_(depth)
-#endif
+ flags_(kValidateDefaultFlags),
+ depth_(depth)
{
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::GenericSchemaValidator (internal)", basePath && basePathSize ? basePath : "");
if (basePath && basePathSize)
memcpy(documentStack_.template Push<char>(basePathSize), basePath, basePathSize);
}
@@ -2359,6 +2979,7 @@ private:
}
bool BeginValue() {
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::BeginValue");
if (schemaStack_.Empty())
PushSchema(root_);
else {
@@ -2380,6 +3001,7 @@ private:
ISchemaValidator**& va = CurrentContext().patternPropertiesValidators;
SizeType& validatorCount = CurrentContext().patternPropertiesValidatorCount;
va = static_cast<ISchemaValidator**>(MallocState(sizeof(ISchemaValidator*) * count));
+ std::memset(va, 0, sizeof(ISchemaValidator*) * count);
for (SizeType i = 0; i < count; i++)
va[validatorCount++] = CreateSchemaValidator(*sa[i], true); // Inherit continueOnError
}
@@ -2390,17 +3012,15 @@ private:
}
bool EndValue() {
+ RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::EndValue");
if (!CurrentSchema().EndValue(CurrentContext()) && !GetContinueOnErrors())
return false;
-#if RAPIDJSON_SCHEMA_VERBOSE
GenericStringBuffer<EncodingType> sb;
- schemaDocument_->GetPointer(&CurrentSchema()).Stringify(sb);
-
+ schemaDocument_->GetPointer(&CurrentSchema()).StringifyUriFragment(sb);
*documentStack_.template Push<Ch>() = '\0';
documentStack_.template Pop<Ch>(1);
- internal::PrintValidatorPointers(depth_, sb.GetString(), documentStack_.template Bottom<Ch>());
-#endif
+ RAPIDJSON_SCHEMA_PRINT(ValidatorPointers, sb.GetString(), documentStack_.template Bottom<Ch>(), depth_);
void* hasher = CurrentContext().hasher;
uint64_t h = hasher && CurrentContext().arrayUniqueness ? static_cast<HasherType*>(hasher)->GetHashCode() : 0;
@@ -2451,7 +3071,7 @@ private:
}
}
- RAPIDJSON_FORCEINLINE void PushSchema(const SchemaType& schema) { new (schemaStack_.template Push<Context>()) Context(*this, *this, &schema); }
+ RAPIDJSON_FORCEINLINE void PushSchema(const SchemaType& schema) { new (schemaStack_.template Push<Context>()) Context(*this, *this, &schema, flags_); }
RAPIDJSON_FORCEINLINE void PopSchema() {
Context* c = schemaStack_.template Pop<Context>(1);
@@ -2553,9 +3173,7 @@ private:
ValueType missingDependents_;
bool valid_;
unsigned flags_;
-#if RAPIDJSON_SCHEMA_VERBOSE
unsigned depth_;
-#endif
};
typedef GenericSchemaValidator<SchemaDocument> SchemaValidator;
diff --git a/contrib/rapidjson/include/rapidjson/uri.h b/contrib/rapidjson/include/rapidjson/uri.h
new file mode 100644
index 000000000..f93e508a4
--- /dev/null
+++ b/contrib/rapidjson/include/rapidjson/uri.h
@@ -0,0 +1,481 @@
+// Tencent is pleased to support the open source community by making RapidJSON available.
+//
+// (C) Copyright IBM Corporation 2021
+//
+// Licensed under the MIT License (the "License"); you may not use this file except
+// in compliance with the License. You may obtain a copy of the License at
+//
+// http://opensource.org/licenses/MIT
+//
+// Unless required by applicable law or agreed to in writing, software distributed
+// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+// CONDITIONS OF ANY KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations under the License.
+
+#ifndef RAPIDJSON_URI_H_
+#define RAPIDJSON_URI_H_
+
+#include "internal/strfunc.h"
+
+#if defined(__clang__)
+RAPIDJSON_DIAG_PUSH
+RAPIDJSON_DIAG_OFF(c++98-compat)
+#elif defined(_MSC_VER)
+RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
+#endif
+
+RAPIDJSON_NAMESPACE_BEGIN
+
+///////////////////////////////////////////////////////////////////////////////
+// GenericUri
+
+template <typename ValueType, typename Allocator=CrtAllocator>
+class GenericUri {
+public:
+ typedef typename ValueType::Ch Ch;
+#if RAPIDJSON_HAS_STDSTRING
+ typedef std::basic_string<Ch> String;
+#endif
+
+ //! Constructors
+ GenericUri(Allocator* allocator = 0) : uri_(), base_(), scheme_(), auth_(), path_(), query_(), frag_(), allocator_(allocator), ownAllocator_() {
+ }
+
+ GenericUri(const Ch* uri, SizeType len, Allocator* allocator = 0) : uri_(), base_(), scheme_(), auth_(), path_(), query_(), frag_(), allocator_(allocator), ownAllocator_() {
+ Parse(uri, len);
+ }
+
+ GenericUri(const Ch* uri, Allocator* allocator = 0) : uri_(), base_(), scheme_(), auth_(), path_(), query_(), frag_(), allocator_(allocator), ownAllocator_() {
+ Parse(uri, internal::StrLen<Ch>(uri));
+ }
+
+ // Use with specializations of GenericValue
+ template<typename T> GenericUri(const T& uri, Allocator* allocator = 0) : uri_(), base_(), scheme_(), auth_(), path_(), query_(), frag_(), allocator_(allocator), ownAllocator_() {
+ const Ch* u = uri.template Get<const Ch*>(); // TypeHelper from document.h
+ Parse(u, internal::StrLen<Ch>(u));
+ }
+
+#if RAPIDJSON_HAS_STDSTRING
+ GenericUri(const String& uri, Allocator* allocator = 0) : uri_(), base_(), scheme_(), auth_(), path_(), query_(), frag_(), allocator_(allocator), ownAllocator_() {
+ Parse(uri.c_str(), internal::StrLen<Ch>(uri.c_str()));
+ }
+#endif
+
+ //! Copy constructor
+ GenericUri(const GenericUri& rhs) : uri_(), base_(), scheme_(), auth_(), path_(), query_(), frag_(), allocator_(), ownAllocator_() {
+ *this = rhs;
+ }
+
+ //! Copy constructor
+ GenericUri(const GenericUri& rhs, Allocator* allocator) : uri_(), base_(), scheme_(), auth_(), path_(), query_(), frag_(), allocator_(allocator), ownAllocator_() {
+ *this = rhs;
+ }
+
+ //! Destructor.
+ ~GenericUri() {
+ Free();
+ RAPIDJSON_DELETE(ownAllocator_);
+ }
+
+ //! Assignment operator
+ GenericUri& operator=(const GenericUri& rhs) {
+ if (this != &rhs) {
+ // Do not delete ownAllocator
+ Free();
+ Allocate(rhs.GetStringLength());
+ auth_ = CopyPart(scheme_, rhs.scheme_, rhs.GetSchemeStringLength());
+ path_ = CopyPart(auth_, rhs.auth_, rhs.GetAuthStringLength());
+ query_ = CopyPart(path_, rhs.path_, rhs.GetPathStringLength());
+ frag_ = CopyPart(query_, rhs.query_, rhs.GetQueryStringLength());
+ base_ = CopyPart(frag_, rhs.frag_, rhs.GetFragStringLength());
+ uri_ = CopyPart(base_, rhs.base_, rhs.GetBaseStringLength());
+ CopyPart(uri_, rhs.uri_, rhs.GetStringLength());
+ }
+ return *this;
+ }
+
+ //! Getters
+ // Use with specializations of GenericValue
+ template<typename T> void Get(T& uri, Allocator& allocator) {
+ uri.template Set<const Ch*>(this->GetString(), allocator); // TypeHelper from document.h
+ }
+
+ const Ch* GetString() const { return uri_; }
+ SizeType GetStringLength() const { return uri_ == 0 ? 0 : internal::StrLen<Ch>(uri_); }
+ const Ch* GetBaseString() const { return base_; }
+ SizeType GetBaseStringLength() const { return base_ == 0 ? 0 : internal::StrLen<Ch>(base_); }
+ const Ch* GetSchemeString() const { return scheme_; }
+ SizeType GetSchemeStringLength() const { return scheme_ == 0 ? 0 : internal::StrLen<Ch>(scheme_); }
+ const Ch* GetAuthString() const { return auth_; }
+ SizeType GetAuthStringLength() const { return auth_ == 0 ? 0 : internal::StrLen<Ch>(auth_); }
+ const Ch* GetPathString() const { return path_; }
+ SizeType GetPathStringLength() const { return path_ == 0 ? 0 : internal::StrLen<Ch>(path_); }
+ const Ch* GetQueryString() const { return query_; }
+ SizeType GetQueryStringLength() const { return query_ == 0 ? 0 : internal::StrLen<Ch>(query_); }
+ const Ch* GetFragString() const { return frag_; }
+ SizeType GetFragStringLength() const { return frag_ == 0 ? 0 : internal::StrLen<Ch>(frag_); }
+
+#if RAPIDJSON_HAS_STDSTRING
+ static String Get(const GenericUri& uri) { return String(uri.GetString(), uri.GetStringLength()); }
+ static String GetBase(const GenericUri& uri) { return String(uri.GetBaseString(), uri.GetBaseStringLength()); }
+ static String GetScheme(const GenericUri& uri) { return String(uri.GetSchemeString(), uri.GetSchemeStringLength()); }
+ static String GetAuth(const GenericUri& uri) { return String(uri.GetAuthString(), uri.GetAuthStringLength()); }
+ static String GetPath(const GenericUri& uri) { return String(uri.GetPathString(), uri.GetPathStringLength()); }
+ static String GetQuery(const GenericUri& uri) { return String(uri.GetQueryString(), uri.GetQueryStringLength()); }
+ static String GetFrag(const GenericUri& uri) { return String(uri.GetFragString(), uri.GetFragStringLength()); }
+#endif
+
+ //! Equality operators
+ bool operator==(const GenericUri& rhs) const {
+ return Match(rhs, true);
+ }
+
+ bool operator!=(const GenericUri& rhs) const {
+ return !Match(rhs, true);
+ }
+
+ bool Match(const GenericUri& uri, bool full = true) const {
+ Ch* s1;
+ Ch* s2;
+ if (full) {
+ s1 = uri_;
+ s2 = uri.uri_;
+ } else {
+ s1 = base_;
+ s2 = uri.base_;
+ }
+ if (s1 == s2) return true;
+ if (s1 == 0 || s2 == 0) return false;
+ return internal::StrCmp<Ch>(s1, s2) == 0;
+ }
+
+ //! Resolve this URI against another (base) URI in accordance with URI resolution rules.
+ // See https://tools.ietf.org/html/rfc3986
+ // Use for resolving an id or $ref with an in-scope id.
+ // Returns a new GenericUri for the resolved URI.
+ GenericUri Resolve(const GenericUri& baseuri, Allocator* allocator = 0) {
+ GenericUri resuri;
+ resuri.allocator_ = allocator;
+ // Ensure enough space for combining paths
+ resuri.Allocate(GetStringLength() + baseuri.GetStringLength() + 1); // + 1 for joining slash
+
+ if (!(GetSchemeStringLength() == 0)) {
+ // Use all of this URI
+ resuri.auth_ = CopyPart(resuri.scheme_, scheme_, GetSchemeStringLength());
+ resuri.path_ = CopyPart(resuri.auth_, auth_, GetAuthStringLength());
+ resuri.query_ = CopyPart(resuri.path_, path_, GetPathStringLength());
+ resuri.frag_ = CopyPart(resuri.query_, query_, GetQueryStringLength());
+ resuri.RemoveDotSegments();
+ } else {
+ // Use the base scheme
+ resuri.auth_ = CopyPart(resuri.scheme_, baseuri.scheme_, baseuri.GetSchemeStringLength());
+ if (!(GetAuthStringLength() == 0)) {
+ // Use this auth, path, query
+ resuri.path_ = CopyPart(resuri.auth_, auth_, GetAuthStringLength());
+ resuri.query_ = CopyPart(resuri.path_, path_, GetPathStringLength());
+ resuri.frag_ = CopyPart(resuri.query_, query_, GetQueryStringLength());
+ resuri.RemoveDotSegments();
+ } else {
+ // Use the base auth
+ resuri.path_ = CopyPart(resuri.auth_, baseuri.auth_, baseuri.GetAuthStringLength());
+ if (GetPathStringLength() == 0) {
+ // Use the base path
+ resuri.query_ = CopyPart(resuri.path_, baseuri.path_, baseuri.GetPathStringLength());
+ if (GetQueryStringLength() == 0) {
+ // Use the base query
+ resuri.frag_ = CopyPart(resuri.query_, baseuri.query_, baseuri.GetQueryStringLength());
+ } else {
+ // Use this query
+ resuri.frag_ = CopyPart(resuri.query_, query_, GetQueryStringLength());
+ }
+ } else {
+ if (path_[0] == '/') {
+ // Absolute path - use all of this path
+ resuri.query_ = CopyPart(resuri.path_, path_, GetPathStringLength());
+ resuri.RemoveDotSegments();
+ } else {
+ // Relative path - append this path to base path after base path's last slash
+ size_t pos = 0;
+ if (!(baseuri.GetAuthStringLength() == 0) && baseuri.GetPathStringLength() == 0) {
+ resuri.path_[pos] = '/';
+ pos++;
+ }
+ size_t lastslashpos = baseuri.GetPathStringLength();
+ while (lastslashpos > 0) {
+ if (baseuri.path_[lastslashpos - 1] == '/') break;
+ lastslashpos--;
+ }
+ std::memcpy(&resuri.path_[pos], baseuri.path_, lastslashpos * sizeof(Ch));
+ pos += lastslashpos;
+ resuri.query_ = CopyPart(&resuri.path_[pos], path_, GetPathStringLength());
+ resuri.RemoveDotSegments();
+ }
+ // Use this query
+ resuri.frag_ = CopyPart(resuri.query_, query_, GetQueryStringLength());
+ }
+ }
+ }
+ // Always use this frag
+ resuri.base_ = CopyPart(resuri.frag_, frag_, GetFragStringLength());
+
+ // Re-constitute base_ and uri_
+ resuri.SetBase();
+ resuri.uri_ = resuri.base_ + resuri.GetBaseStringLength() + 1;
+ resuri.SetUri();
+ return resuri;
+ }
+
+ //! Get the allocator of this GenericUri.
+ Allocator& GetAllocator() { return *allocator_; }
+
+private:
+ // Allocate memory for a URI
+ // Returns total amount allocated
+ std::size_t Allocate(std::size_t len) {
+ // Create own allocator if user did not supply.
+ if (!allocator_)
+ ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
+
+ // Allocate one block containing each part of the URI (5) plus base plus full URI, all null terminated.
+ // Order: scheme, auth, path, query, frag, base, uri
+ // Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
+ size_t total = (3 * len + 7) * sizeof(Ch);
+ scheme_ = static_cast<Ch*>(allocator_->Malloc(total));
+ *scheme_ = '\0';
+ auth_ = scheme_;
+ auth_++;
+ *auth_ = '\0';
+ path_ = auth_;
+ path_++;
+ *path_ = '\0';
+ query_ = path_;
+ query_++;
+ *query_ = '\0';
+ frag_ = query_;
+ frag_++;
+ *frag_ = '\0';
+ base_ = frag_;
+ base_++;
+ *base_ = '\0';
+ uri_ = base_;
+ uri_++;
+ *uri_ = '\0';
+ return total;
+ }
+
+ // Free memory for a URI
+ void Free() {
+ if (scheme_) {
+ Allocator::Free(scheme_);
+ scheme_ = 0;
+ }
+ }
+
+ // Parse a URI into constituent scheme, authority, path, query, & fragment parts
+ // Supports URIs that match regex ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? as per
+ // https://tools.ietf.org/html/rfc3986
+ void Parse(const Ch* uri, std::size_t len) {
+ std::size_t start = 0, pos1 = 0, pos2 = 0;
+ Allocate(len);
+
+ // Look for scheme ([^:/?#]+):)?
+ if (start < len) {
+ while (pos1 < len) {
+ if (uri[pos1] == ':') break;
+ pos1++;
+ }
+ if (pos1 != len) {
+ while (pos2 < len) {
+ if (uri[pos2] == '/') break;
+ if (uri[pos2] == '?') break;
+ if (uri[pos2] == '#') break;
+ pos2++;
+ }
+ if (pos1 < pos2) {
+ pos1++;
+ std::memcpy(scheme_, &uri[start], pos1 * sizeof(Ch));
+ scheme_[pos1] = '\0';
+ start = pos1;
+ }
+ }
+ }
+ // Look for auth (//([^/?#]*))?
+ // Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
+ auth_ = scheme_ + GetSchemeStringLength();
+ auth_++;
+ *auth_ = '\0';
+ if (start < len - 1 && uri[start] == '/' && uri[start + 1] == '/') {
+ pos2 = start + 2;
+ while (pos2 < len) {
+ if (uri[pos2] == '/') break;
+ if (uri[pos2] == '?') break;
+ if (uri[pos2] == '#') break;
+ pos2++;
+ }
+ std::memcpy(auth_, &uri[start], (pos2 - start) * sizeof(Ch));
+ auth_[pos2 - start] = '\0';
+ start = pos2;
+ }
+ // Look for path ([^?#]*)
+ // Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
+ path_ = auth_ + GetAuthStringLength();
+ path_++;
+ *path_ = '\0';
+ if (start < len) {
+ pos2 = start;
+ while (pos2 < len) {
+ if (uri[pos2] == '?') break;
+ if (uri[pos2] == '#') break;
+ pos2++;
+ }
+ if (start != pos2) {
+ std::memcpy(path_, &uri[start], (pos2 - start) * sizeof(Ch));
+ path_[pos2 - start] = '\0';
+ if (path_[0] == '/')
+ RemoveDotSegments(); // absolute path - normalize
+ start = pos2;
+ }
+ }
+ // Look for query (\?([^#]*))?
+ // Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
+ query_ = path_ + GetPathStringLength();
+ query_++;
+ *query_ = '\0';
+ if (start < len && uri[start] == '?') {
+ pos2 = start + 1;
+ while (pos2 < len) {
+ if (uri[pos2] == '#') break;
+ pos2++;
+ }
+ if (start != pos2) {
+ std::memcpy(query_, &uri[start], (pos2 - start) * sizeof(Ch));
+ query_[pos2 - start] = '\0';
+ start = pos2;
+ }
+ }
+ // Look for fragment (#(.*))?
+ // Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
+ frag_ = query_ + GetQueryStringLength();
+ frag_++;
+ *frag_ = '\0';
+ if (start < len && uri[start] == '#') {
+ std::memcpy(frag_, &uri[start], (len - start) * sizeof(Ch));
+ frag_[len - start] = '\0';
+ }
+
+ // Re-constitute base_ and uri_
+ base_ = frag_ + GetFragStringLength() + 1;
+ SetBase();
+ uri_ = base_ + GetBaseStringLength() + 1;
+ SetUri();
+ }
+
+ // Reconstitute base
+ void SetBase() {
+ Ch* next = base_;
+ std::memcpy(next, scheme_, GetSchemeStringLength() * sizeof(Ch));
+ next+= GetSchemeStringLength();
+ std::memcpy(next, auth_, GetAuthStringLength() * sizeof(Ch));
+ next+= GetAuthStringLength();
+ std::memcpy(next, path_, GetPathStringLength() * sizeof(Ch));
+ next+= GetPathStringLength();
+ std::memcpy(next, query_, GetQueryStringLength() * sizeof(Ch));
+ next+= GetQueryStringLength();
+ *next = '\0';
+ }
+
+ // Reconstitute uri
+ void SetUri() {
+ Ch* next = uri_;
+ std::memcpy(next, base_, GetBaseStringLength() * sizeof(Ch));
+ next+= GetBaseStringLength();
+ std::memcpy(next, frag_, GetFragStringLength() * sizeof(Ch));
+ next+= GetFragStringLength();
+ *next = '\0';
+ }
+
+ // Copy a part from one GenericUri to another
+ // Return the pointer to the next part to be copied to
+ Ch* CopyPart(Ch* to, Ch* from, std::size_t len) {
+ RAPIDJSON_ASSERT(to != 0);
+ RAPIDJSON_ASSERT(from != 0);
+ std::memcpy(to, from, len * sizeof(Ch));
+ to[len] = '\0';
+ Ch* next = to + len + 1;
+ return next;
+ }
+
+ // Remove . and .. segments from the path_ member.
+ // https://tools.ietf.org/html/rfc3986
+ // This is done in place as we are only removing segments.
+ void RemoveDotSegments() {
+ std::size_t pathlen = GetPathStringLength();
+ std::size_t pathpos = 0; // Position in path_
+ std::size_t newpos = 0; // Position in new path_
+
+ // Loop through each segment in original path_
+ while (pathpos < pathlen) {
+ // Get next segment, bounded by '/' or end
+ size_t slashpos = 0;
+ while ((pathpos + slashpos) < pathlen) {
+ if (path_[pathpos + slashpos] == '/') break;
+ slashpos++;
+ }
+ // Check for .. and . segments
+ if (slashpos == 2 && path_[pathpos] == '.' && path_[pathpos + 1] == '.') {
+ // Backup a .. segment in the new path_
+ // We expect to find a previously added slash at the end or nothing
+ RAPIDJSON_ASSERT(newpos == 0 || path_[newpos - 1] == '/');
+ size_t lastslashpos = newpos;
+ // Make sure we don't go beyond the start segment
+ if (lastslashpos > 1) {
+ // Find the next to last slash and back up to it
+ lastslashpos--;
+ while (lastslashpos > 0) {
+ if (path_[lastslashpos - 1] == '/') break;
+ lastslashpos--;
+ }
+ // Set the new path_ position
+ newpos = lastslashpos;
+ }
+ } else if (slashpos == 1 && path_[pathpos] == '.') {
+ // Discard . segment, leaves new path_ unchanged
+ } else {
+ // Move any other kind of segment to the new path_
+ RAPIDJSON_ASSERT(newpos <= pathpos);
+ std::memmove(&path_[newpos], &path_[pathpos], slashpos * sizeof(Ch));
+ newpos += slashpos;
+ // Add slash if not at end
+ if ((pathpos + slashpos) < pathlen) {
+ path_[newpos] = '/';
+ newpos++;
+ }
+ }
+ // Move to next segment
+ pathpos += slashpos + 1;
+ }
+ path_[newpos] = '\0';
+ }
+
+ Ch* uri_; // Everything
+ Ch* base_; // Everything except fragment
+ Ch* scheme_; // Includes the :
+ Ch* auth_; // Includes the //
+ Ch* path_; // Absolute if starts with /
+ Ch* query_; // Includes the ?
+ Ch* frag_; // Includes the #
+
+ Allocator* allocator_; //!< The current allocator. It is either user-supplied or equal to ownAllocator_.
+ Allocator* ownAllocator_; //!< Allocator owned by this Uri.
+};
+
+//! GenericUri for Value (UTF-8, default allocator).
+typedef GenericUri<Value> Uri;
+
+RAPIDJSON_NAMESPACE_END
+
+#if defined(__clang__)
+RAPIDJSON_DIAG_POP
+#endif
+
+#endif // RAPIDJSON_URI_H_
diff --git a/contrib/rapidjson/include/rapidjson/writer.h b/contrib/rapidjson/include/rapidjson/writer.h
index 8b389219a..632e02ce7 100644
--- a/contrib/rapidjson/include/rapidjson/writer.h
+++ b/contrib/rapidjson/include/rapidjson/writer.h
@@ -67,6 +67,7 @@ enum WriteFlag {
kWriteNoFlags = 0, //!< No flags are set.
kWriteValidateEncodingFlag = 1, //!< Validate encoding of JSON strings.
kWriteNanAndInfFlag = 2, //!< Allow writing of Infinity, -Infinity and NaN.
+ kWriteNanAndInfNullFlag = 4, //!< Allow writing of Infinity, -Infinity and NaN as null.
kWriteDefaultFlags = RAPIDJSON_WRITE_DEFAULT_FLAGS //!< Default write flags. Can be customized by defining RAPIDJSON_WRITE_DEFAULT_FLAGS
};
@@ -348,8 +349,13 @@ protected:
bool WriteDouble(double d) {
if (internal::Double(d).IsNanOrInf()) {
- if (!(writeFlags & kWriteNanAndInfFlag))
+ if (!(writeFlags & kWriteNanAndInfFlag) && !(writeFlags & kWriteNanAndInfNullFlag))
return false;
+ if (writeFlags & kWriteNanAndInfNullFlag) {
+ PutReserve(*os_, 4);
+ PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'u'); PutUnsafe(*os_, 'l'); PutUnsafe(*os_, 'l');
+ return true;
+ }
if (internal::Double(d).IsNan()) {
PutReserve(*os_, 3);
PutUnsafe(*os_, 'N'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'N');
@@ -548,6 +554,11 @@ inline bool Writer<StringBuffer>::WriteDouble(double d) {
// Note: This code path can only be reached if (RAPIDJSON_WRITE_DEFAULT_FLAGS & kWriteNanAndInfFlag).
if (!(kWriteDefaultFlags & kWriteNanAndInfFlag))
return false;
+ if (kWriteDefaultFlags & kWriteNanAndInfNullFlag) {
+ PutReserve(*os_, 4);
+ PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'u'); PutUnsafe(*os_, 'l'); PutUnsafe(*os_, 'l');
+ return true;
+ }
if (internal::Double(d).IsNan()) {
PutReserve(*os_, 3);
PutUnsafe(*os_, 'N'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'N');
diff --git a/contrib/rapidjson/readme.md b/contrib/rapidjson/readme.md
index b833a98e8..ac683b051 100644
--- a/contrib/rapidjson/readme.md
+++ b/contrib/rapidjson/readme.md
@@ -6,7 +6,7 @@
Tencent is pleased to support the open source community by making RapidJSON available.
-Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
+Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
* [RapidJSON GitHub](https://github.com/Tencent/rapidjson/)
* RapidJSON Documentation
@@ -43,7 +43,7 @@ RapidJSON is a JSON parser and generator for C++. It was inspired by [RapidXml](
More features can be read [here](doc/features.md).
-JSON(JavaScript Object Notation) is a light-weight data exchange format. RapidJSON should be in fully compliance with RFC7159/ECMA-404, with optional support of relaxed syntax. More information about JSON can be obtained at
+JSON(JavaScript Object Notation) is a light-weight data exchange format. RapidJSON should be in full compliance with RFC7159/ECMA-404, with optional support of relaxed syntax. More information about JSON can be obtained at
* [Introducing JSON](http://json.org/)
* [RFC7159: The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc7159)
* [Standard ECMA-404: The JSON Data Interchange Format](https://www.ecma-international.org/publications/standards/Ecma-404.htm)
@@ -72,6 +72,9 @@ Users can build and run the unit tests on their platform/compiler.
RapidJSON is a header-only C++ library. Just copy the `include/rapidjson` folder to system or project's include path.
+Alternatively, if you are using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager you can download and install rapidjson with CMake integration in a single command:
+* vcpkg install rapidjson
+
RapidJSON uses following software as its dependencies:
* [CMake](https://cmake.org/) as a general build tool
* (optional) [Doxygen](http://www.doxygen.org) to build documentation
@@ -158,3 +161,50 @@ More [examples](https://github.com/Tencent/rapidjson/tree/master/example) are av
* [parsebyparts](https://github.com/Tencent/rapidjson/blob/master/example/parsebyparts/parsebyparts.cpp): Implements an `AsyncDocumentParser` which can parse JSON in parts, using C++11 thread.
* [filterkey](https://github.com/Tencent/rapidjson/blob/master/example/filterkey/filterkey.cpp): A command line tool to remove all values with user-specified key.
* [filterkeydom](https://github.com/Tencent/rapidjson/blob/master/example/filterkeydom/filterkeydom.cpp): Same tool as above, but it demonstrates how to use a generator to populate a `Document`.
+
+## Contributing
+
+RapidJSON welcomes contributions. When contributing, please follow the code below.
+
+### Issues
+
+Feel free to submit issues and enhancement requests.
+
+Please help us by providing **minimal reproducible examples**, because source code is easier to let other people understand what happens.
+For crash problems on certain platforms, please bring stack dump content with the detail of the OS, compiler, etc.
+
+Please try breakpoint debugging first, tell us what you found, see if we can start exploring based on more information been prepared.
+
+### Workflow
+
+In general, we follow the "fork-and-pull" Git workflow.
+
+ 1. **Fork** the repo on GitHub
+ 2. **Clone** the project to your own machine
+ 3. **Checkout** a new branch on your fork, start developing on the branch
+ 4. **Test** the change before commit, Make sure the changes pass all the tests, including `unittest` and `preftest`, please add test case for each new feature or bug-fix if needed.
+ 5. **Commit** changes to your own branch
+ 6. **Push** your work back up to your fork
+ 7. Submit a **Pull request** so that we can review your changes
+
+NOTE: Be sure to merge the latest from "upstream" before making a pull request!
+
+### Copyright and Licensing
+
+You can copy and paste the license summary from below.
+
+```
+Tencent is pleased to support the open source community by making RapidJSON available.
+
+Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
+
+Licensed under the MIT License (the "License"); you may not use this file except
+in compliance with the License. You may obtain a copy of the License at
+
+http://opensource.org/licenses/MIT
+
+Unless required by applicable law or agreed to in writing, software distributed
+under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied. See the License for the
+specific language governing permissions and limitations under the License.
+```
diff --git a/contrib/unzip/ioapi.h b/contrib/unzip/ioapi.h
index f54089639..ec2f2ac2d 100644
--- a/contrib/unzip/ioapi.h
+++ b/contrib/unzip/ioapi.h
@@ -50,7 +50,7 @@
#define ftello64 ftell
#define fseeko64 fseek
#else
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__VXWORKS__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(__VXWORKS__)
#define fopen64 fopen
#define ftello64 ftello
#define fseeko64 fseeko
diff --git a/doc/Fileformats.md b/doc/Fileformats.md
index 118d798f2..5e7983812 100644
--- a/doc/Fileformats.md
+++ b/doc/Fileformats.md
@@ -12,7 +12,6 @@ __Importers__:
- ASE
- ASK
- B3D
-- [BLEND](https://en.wikipedia.org/wiki/.blend_(file_format))
- [BVH](https://en.wikipedia.org/wiki/Biovision_Hierarchy)
- CSM
- COB
@@ -66,6 +65,9 @@ __Importers__:
- XGL
- ZGL
+Note: support for [BLEND](https://en.wikipedia.org/wiki/.blend_(file_format)) is deprecated.
+It is too time-consuming to maintain an undocumented format which contains so much more than we need.
+
Additionally, some formats are supported by dependency on non-free code or external SDKs (not built by default):
- [C4D](https://en.wikipedia.org/wiki/Cinema_4D) (https://github.com/assimp/assimp/wiki/Cinema4D-&-Melange) IMporting geometry + node hierarchy are currently supported
diff --git a/doc/dox.h b/doc/dox.h
index 1d5f59aa4..2fb127a2b 100644
--- a/doc/dox.h
+++ b/doc/dox.h
@@ -1545,7 +1545,7 @@ Don't trust the input data! Check all offsets!
Mixed stuff for internal use by loaders, mostly documented (most of them are already included by <i>AssimpPCH.h</i>):
<ul>
<li><b>ByteSwapper</b> (<i>ByteSwapper.h</i>) - manual byte swapping stuff for binary loaders.</li>
-<li><b>StreamReader</b> (<i>StreamReader.h</i>) - safe, endianess-correct, binary reading.</li>
+<li><b>StreamReader</b> (<i>StreamReader.h</i>) - safe, endianness-correct, binary reading.</li>
<li><b>IrrXML</b> (<i>irrXMLWrapper.h</i>) - for XML-parsing (SAX.</li>
<li><b>CommentRemover</b> (<i>RemoveComments.h</i>) - remove single-line and multi-line comments from a text file.</li>
<li>fast_atof, strtoul10, strtoul16, SkipSpaceAndLineEnd, SkipToNextToken .. large family of low-level
diff --git a/fuzz/assimp_fuzzer.cc b/fuzz/assimp_fuzzer.cc
index e347f59cb..8178674e8 100644
--- a/fuzz/assimp_fuzzer.cc
+++ b/fuzz/assimp_fuzzer.cc
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/Base64.hpp b/include/assimp/Base64.hpp
index 10288713c..6a3551307 100644
--- a/include/assimp/Base64.hpp
+++ b/include/assimp/Base64.hpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/BaseImporter.h b/include/assimp/BaseImporter.h
index d0b173171..447784e75 100644
--- a/include/assimp/BaseImporter.h
+++ b/include/assimp/BaseImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -63,6 +63,7 @@ struct aiImporterDesc;
namespace Assimp {
+// Forward declarations
class Importer;
class IOSystem;
class BaseProcess;
@@ -73,6 +74,9 @@ class IOStream;
#define AI_MAKE_MAGIC(string) ((uint32_t)((string[0] << 24) + \
(string[1] << 16) + (string[2] << 8) + string[3]))
+using UByteBuffer = std::vector<uint8_t>;
+using ByteBuffer = std::vector<int8_t>;
+
// ---------------------------------------------------------------------------
/** FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface
* for all importer worker classes.
@@ -91,7 +95,7 @@ public:
BaseImporter() AI_NO_EXCEPT;
/** Destructor, private as well */
- virtual ~BaseImporter();
+ virtual ~BaseImporter() = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
diff --git a/include/assimp/Bitmap.h b/include/assimp/Bitmap.h
index 2678b5f64..5145a6cd5 100644
--- a/include/assimp/Bitmap.h
+++ b/include/assimp/Bitmap.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/BlobIOSystem.h b/include/assimp/BlobIOSystem.h
index 7e8d46a53..eb23f9e92 100644
--- a/include/assimp/BlobIOSystem.h
+++ b/include/assimp/BlobIOSystem.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/ByteSwapper.h b/include/assimp/ByteSwapper.h
index 488f7a51d..73c115b8a 100644
--- a/include/assimp/ByteSwapper.h
+++ b/include/assimp/ByteSwapper.h
@@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -66,10 +65,10 @@ namespace Assimp {
* and vice versa. Direct use of this class is DEPRECATED. Use #StreamReader instead. */
// --------------------------------------------------------------------------------------
class ByteSwap {
- ByteSwap() AI_NO_EXCEPT {}
+ ByteSwap() AI_NO_EXCEPT = default;
+ ~ByteSwap() = default;
public:
-
// ----------------------------------------------------------------------
/** Swap two bytes of data
* @param[inout] _szOut A void* to save the reintcasts for the caller. */
@@ -89,8 +88,7 @@ public:
// ----------------------------------------------------------------------
/** Swap four bytes of data
* @param[inout] _szOut A void* to save the reintcasts for the caller. */
- static inline void Swap4(void* _szOut)
- {
+ static inline void Swap4(void* _szOut) {
ai_assert(_szOut);
#if _MSC_VER >= 1400
@@ -263,7 +261,7 @@ struct ByteSwapper<T,false> {
};
// --------------------------------------------------------------------------------------------
-template <bool SwapEndianess, typename T, bool RuntimeSwitch>
+template <bool SwapEndianness, typename T, bool RuntimeSwitch>
struct Getter {
void operator() (T* inout, bool le) {
#ifdef AI_BUILD_BIG_ENDIAN
@@ -278,12 +276,12 @@ struct Getter {
}
};
-template <bool SwapEndianess, typename T>
-struct Getter<SwapEndianess,T,false> {
+template <bool SwapEndianness, typename T>
+struct Getter<SwapEndianness,T,false> {
void operator() (T* inout, bool /*le*/) {
// static branch
- ByteSwapper<T,(SwapEndianess && sizeof(T)>1)> () (inout);
+ ByteSwapper<T,(SwapEndianness && sizeof(T)>1)> () (inout);
}
};
} // end Intern
diff --git a/include/assimp/ColladaMetaData.h b/include/assimp/ColladaMetaData.h
index 52eb3c508..9973d16a5 100644
--- a/include/assimp/ColladaMetaData.h
+++ b/include/assimp/ColladaMetaData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/CreateAnimMesh.h b/include/assimp/CreateAnimMesh.h
index e5211f504..6e14ac747 100644
--- a/include/assimp/CreateAnimMesh.h
+++ b/include/assimp/CreateAnimMesh.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/DefaultIOStream.h b/include/assimp/DefaultIOStream.h
index 67cba3c5c..c39d9a8e1 100644
--- a/include/assimp/DefaultIOStream.h
+++ b/include/assimp/DefaultIOStream.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/DefaultIOSystem.h b/include/assimp/DefaultIOSystem.h
index 8545e75cf..0aeef9eb8 100644
--- a/include/assimp/DefaultIOSystem.h
+++ b/include/assimp/DefaultIOSystem.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/DefaultLogger.hpp b/include/assimp/DefaultLogger.hpp
index 723097ff2..b43eebb70 100644
--- a/include/assimp/DefaultLogger.hpp
+++ b/include/assimp/DefaultLogger.hpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/Exceptional.h b/include/assimp/Exceptional.h
index ec3d38c5a..b4b51863f 100644
--- a/include/assimp/Exceptional.h
+++ b/include/assimp/Exceptional.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp
index 09a459442..bdec20b97 100644
--- a/include/assimp/Exporter.hpp
+++ b/include/assimp/Exporter.hpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/GenericProperty.h b/include/assimp/GenericProperty.h
index 073d53312..a35ebf23d 100644
--- a/include/assimp/GenericProperty.h
+++ b/include/assimp/GenericProperty.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/GltfMaterial.h b/include/assimp/GltfMaterial.h
index 86ca8897c..5e63b9132 100644
--- a/include/assimp/GltfMaterial.h
+++ b/include/assimp/GltfMaterial.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/Hash.h b/include/assimp/Hash.h
index cf889362c..9dec87408 100644
--- a/include/assimp/Hash.h
+++ b/include/assimp/Hash.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/IOStream.hpp b/include/assimp/IOStream.hpp
index 12beb0dbb..1866a3d72 100644
--- a/include/assimp/IOStream.hpp
+++ b/include/assimp/IOStream.hpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -73,14 +73,14 @@ class ASSIMP_API IOStream
{
protected:
/** Constructor protected, use IOSystem::Open() to create an instance. */
- IOStream() AI_NO_EXCEPT;
+ IOStream() AI_NO_EXCEPT = default;
public:
// -------------------------------------------------------------------
/** @brief Destructor. Deleting the object closes the underlying file,
* alternatively you may use IOSystem::Close() to release the file.
*/
- virtual ~IOStream();
+ virtual ~IOStream() = default;
// -------------------------------------------------------------------
/** @brief Read from the file
@@ -126,15 +126,6 @@ public:
virtual void Flush() = 0;
}; //! class IOStream
-// ----------------------------------------------------------------------------------
-AI_FORCE_INLINE
-IOStream::IOStream() AI_NO_EXCEPT = default;
-
-// ----------------------------------------------------------------------------------
-AI_FORCE_INLINE
-IOStream::~IOStream() = default;
-// ----------------------------------------------------------------------------------
-
} //!namespace Assimp
#endif //!!AI_IOSTREAM_H_INC
diff --git a/include/assimp/IOStreamBuffer.h b/include/assimp/IOStreamBuffer.h
index fae480e71..5a6924a09 100644
--- a/include/assimp/IOStreamBuffer.h
+++ b/include/assimp/IOStreamBuffer.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -66,7 +66,7 @@ public:
IOStreamBuffer(size_t cache = 4096 * 4096);
/// @brief The class destructor.
- ~IOStreamBuffer();
+ ~IOStreamBuffer() = default;
/// @brief Will open the cached access for a given stream.
/// @param stream The stream to cache.
@@ -141,9 +141,6 @@ AI_FORCE_INLINE IOStreamBuffer<T>::IOStreamBuffer(size_t cache) :
}
template <class T>
-AI_FORCE_INLINE IOStreamBuffer<T>::~IOStreamBuffer() = default;
-
-template <class T>
AI_FORCE_INLINE bool IOStreamBuffer<T>::open(IOStream *stream) {
// file still opened!
if (nullptr != m_stream) {
@@ -287,7 +284,7 @@ static AI_FORCE_INLINE bool isEndOfCache(size_t pos, size_t cacheSize) {
template <class T>
AI_FORCE_INLINE bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
buffer.resize(m_cacheSize);
- if (isEndOfCache(m_cachePos, m_cacheSize) || 0 == m_filePos) {
+ if (m_cachePos >= m_cacheSize || 0 == m_filePos) {
if (!readNextBlock()) {
return false;
}
diff --git a/include/assimp/IOSystem.hpp b/include/assimp/IOSystem.hpp
index 30f48b81c..b345151d5 100644
--- a/include/assimp/IOSystem.hpp
+++ b/include/assimp/IOSystem.hpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -97,7 +97,7 @@ public:
* Create an instance of your derived class and assign it to an
* #Assimp::Importer instance by calling Importer::SetIOHandler().
*/
- IOSystem() AI_NO_EXCEPT;
+ IOSystem() AI_NO_EXCEPT = default;
// -------------------------------------------------------------------
/** @brief Virtual destructor.
@@ -105,7 +105,7 @@ public:
* It is safe to be called from within DLL Assimp, we're constructed
* on Assimp's heap.
*/
- virtual ~IOSystem();
+ virtual ~IOSystem() = default;
// -------------------------------------------------------------------
/** @brief For backward compatibility
@@ -237,12 +237,6 @@ private:
};
// ----------------------------------------------------------------------------
-AI_FORCE_INLINE IOSystem::IOSystem() AI_NO_EXCEPT = default;
-
-// ----------------------------------------------------------------------------
-AI_FORCE_INLINE IOSystem::~IOSystem() = default;
-
-// ----------------------------------------------------------------------------
// For compatibility, the interface of some functions taking a std::string was
// changed to const char* to avoid crashes between binary incompatible STL
// versions. This code her is inlined, so it shouldn't cause any problems.
diff --git a/include/assimp/Importer.hpp b/include/assimp/Importer.hpp
index 418643f1f..a3a0d9eae 100644
--- a/include/assimp/Importer.hpp
+++ b/include/assimp/Importer.hpp
@@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/LineSplitter.h b/include/assimp/LineSplitter.h
index 379821f03..635349dc0 100644
--- a/include/assimp/LineSplitter.h
+++ b/include/assimp/LineSplitter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -86,7 +86,7 @@ public:
*/
LineSplitter(StreamReaderLE& stream, bool skip_empty_lines = true, bool trim = true);
- ~LineSplitter();
+ ~LineSplitter() = default;
// -----------------------------------------
/** pseudo-iterator increment */
@@ -110,6 +110,8 @@ public:
std::string operator* () const;
+ const char *getEnd() const;
+
// -----------------------------------------
/** boolean context */
operator bool() const;
@@ -139,23 +141,25 @@ public:
private:
line_idx mIdx;
std::string mCur;
+ const char *mEnd;
StreamReaderLE& mStream;
bool mSwallow, mSkip_empty_lines, mTrim;
};
AI_FORCE_INLINE LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_empty_lines, bool trim ) :
mIdx(0),
+ mCur(),
+ mEnd(nullptr),
mStream(stream),
mSwallow(),
mSkip_empty_lines(skip_empty_lines),
mTrim(trim) {
mCur.reserve(1024);
+ mEnd = mCur.c_str() + 1024;
operator++();
mIdx = 0;
}
-AI_FORCE_INLINE LineSplitter::~LineSplitter() = default;
-
AI_FORCE_INLINE LineSplitter& LineSplitter::operator++() {
if (mSwallow) {
mSwallow = false;
@@ -203,14 +207,14 @@ AI_FORCE_INLINE LineSplitter &LineSplitter::operator++(int) {
AI_FORCE_INLINE const char *LineSplitter::operator[] (size_t idx) const {
const char* s = operator->()->c_str();
- SkipSpaces(&s);
+ SkipSpaces(&s, mEnd);
for (size_t i = 0; i < idx; ++i) {
for (; !IsSpace(*s); ++s) {
if (IsLineEnd(*s)) {
throw std::range_error("Token index out of range, EOL reached");
}
}
- SkipSpaces(&s);
+ SkipSpaces(&s, mEnd);
}
return s;
}
@@ -219,7 +223,7 @@ template <size_t N>
AI_FORCE_INLINE void LineSplitter::get_tokens(const char* (&tokens)[N]) const {
const char* s = operator->()->c_str();
- SkipSpaces(&s);
+ SkipSpaces(&s, mEnd);
for (size_t i = 0; i < N; ++i) {
if (IsLineEnd(*s)) {
throw std::range_error("Token count out of range, EOL reached");
@@ -227,7 +231,7 @@ AI_FORCE_INLINE void LineSplitter::get_tokens(const char* (&tokens)[N]) const {
tokens[i] = s;
for (; *s && !IsSpace(*s); ++s);
- SkipSpaces(&s);
+ SkipSpaces(&s, mEnd);
}
}
@@ -239,6 +243,10 @@ AI_FORCE_INLINE std::string LineSplitter::operator* () const {
return mCur;
}
+AI_FORCE_INLINE const char* LineSplitter::getEnd() const {
+ return mEnd;
+}
+
AI_FORCE_INLINE LineSplitter::operator bool() const {
return mStream.GetRemainingSize() > 0;
}
diff --git a/include/assimp/LogAux.h b/include/assimp/LogAux.h
index a8cb8f24c..20a7564b8 100644
--- a/include/assimp/LogAux.h
+++ b/include/assimp/LogAux.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/LogStream.hpp b/include/assimp/LogStream.hpp
index 3b17b200a..2d9f1d350 100644
--- a/include/assimp/LogStream.hpp
+++ b/include/assimp/LogStream.hpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/Logger.hpp b/include/assimp/Logger.hpp
index e8df64dd8..0051153e2 100644
--- a/include/assimp/Logger.hpp
+++ b/include/assimp/Logger.hpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/MathFunctions.h b/include/assimp/MathFunctions.h
index f2a7ccdf6..eaa8b4ac4 100644
--- a/include/assimp/MathFunctions.h
+++ b/include/assimp/MathFunctions.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/MemoryIOWrapper.h b/include/assimp/MemoryIOWrapper.h
index 4023f7529..ef06af273 100644
--- a/include/assimp/MemoryIOWrapper.h
+++ b/include/assimp/MemoryIOWrapper.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/NullLogger.hpp b/include/assimp/NullLogger.hpp
index 1b594ea28..552bcf66a 100644
--- a/include/assimp/NullLogger.hpp
+++ b/include/assimp/NullLogger.hpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/ObjMaterial.h b/include/assimp/ObjMaterial.h
index 9c511916a..21087ebcb 100644
--- a/include/assimp/ObjMaterial.h
+++ b/include/assimp/ObjMaterial.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/ParsingUtils.h b/include/assimp/ParsingUtils.h
index b08f23227..e0ee2d77c 100644
--- a/include/assimp/ParsingUtils.h
+++ b/include/assimp/ParsingUtils.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -70,7 +70,6 @@ namespace Assimp {
static const unsigned int BufferSize = 4096;
-
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE bool IsUpper(char_t in) {
@@ -103,8 +102,8 @@ AI_FORCE_INLINE bool IsSpaceOrNewLine(char_t in) {
// ---------------------------------------------------------------------------------
template <class char_t>
-AI_FORCE_INLINE bool SkipSpaces(const char_t *in, const char_t **out) {
- while (*in == (char_t)' ' || *in == (char_t)'\t') {
+AI_FORCE_INLINE bool SkipSpaces(const char_t *in, const char_t **out, const char_t *end) {
+ while ((*in == (char_t)' ' || *in == (char_t)'\t') && in != end) {
++in;
}
*out = in;
@@ -113,19 +112,19 @@ AI_FORCE_INLINE bool SkipSpaces(const char_t *in, const char_t **out) {
// ---------------------------------------------------------------------------------
template <class char_t>
-AI_FORCE_INLINE bool SkipSpaces(const char_t **inout) {
- return SkipSpaces<char_t>(*inout, inout);
+AI_FORCE_INLINE bool SkipSpaces(const char_t **inout, const char_t *end) {
+ return SkipSpaces<char_t>(*inout, inout, end);
}
// ---------------------------------------------------------------------------------
template <class char_t>
-AI_FORCE_INLINE bool SkipLine(const char_t *in, const char_t **out) {
- while (*in != (char_t)'\r' && *in != (char_t)'\n' && *in != (char_t)'\0') {
+AI_FORCE_INLINE bool SkipLine(const char_t *in, const char_t **out, const char_t *end) {
+ while ((*in != (char_t)'\r' && *in != (char_t)'\n' && *in != (char_t)'\0') && in != end) {
++in;
}
// files are opened in binary mode. Ergo there are both NL and CR
- while (*in == (char_t)'\r' || *in == (char_t)'\n') {
+ while ((*in == (char_t)'\r' || *in == (char_t)'\n') && in != end) {
++in;
}
*out = in;
@@ -134,14 +133,14 @@ AI_FORCE_INLINE bool SkipLine(const char_t *in, const char_t **out) {
// ---------------------------------------------------------------------------------
template <class char_t>
-AI_FORCE_INLINE bool SkipLine(const char_t **inout) {
- return SkipLine<char_t>(*inout, inout);
+AI_FORCE_INLINE bool SkipLine(const char_t **inout, const char_t *end) {
+ return SkipLine<char_t>(*inout, inout, end);
}
// ---------------------------------------------------------------------------------
template <class char_t>
-AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t *in, const char_t **out) {
- while (*in == (char_t)' ' || *in == (char_t)'\t' || *in == (char_t)'\r' || *in == (char_t)'\n') {
+AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t *in, const char_t **out, const char_t *end) {
+ while ((*in == (char_t)' ' || *in == (char_t)'\t' || *in == (char_t)'\r' || *in == (char_t)'\n') && in != end) {
++in;
}
*out = in;
@@ -150,8 +149,8 @@ AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t *in, const char_t **out)
// ---------------------------------------------------------------------------------
template <class char_t>
-AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t **inout) {
- return SkipSpacesAndLineEnd<char_t>(*inout, inout);
+AI_FORCE_INLINE bool SkipSpacesAndLineEnd(const char_t **inout, const char_t *end) {
+ return SkipSpacesAndLineEnd<char_t>(*inout, inout, end);
}
// ---------------------------------------------------------------------------------
@@ -211,16 +210,16 @@ AI_FORCE_INLINE bool TokenMatchI(const char *&in, const char *token, unsigned in
}
// ---------------------------------------------------------------------------------
-AI_FORCE_INLINE void SkipToken(const char *&in) {
- SkipSpaces(&in);
+AI_FORCE_INLINE void SkipToken(const char *&in, const char *end) {
+ SkipSpaces(&in, end);
while (!IsSpaceOrNewLine(*in)) {
++in;
}
}
// ---------------------------------------------------------------------------------
-AI_FORCE_INLINE std::string GetNextToken(const char *&in) {
- SkipSpacesAndLineEnd(&in);
+AI_FORCE_INLINE std::string GetNextToken(const char *&in, const char *end) {
+ SkipSpacesAndLineEnd(&in, end);
const char *cur = in;
while (!IsSpaceOrNewLine(*in)) {
++in;
diff --git a/include/assimp/Profiler.h b/include/assimp/Profiler.h
index 3b9263b40..ff4f590c3 100644
--- a/include/assimp/Profiler.h
+++ b/include/assimp/Profiler.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/ProgressHandler.hpp b/include/assimp/ProgressHandler.hpp
index 93d881659..2a1ab309c 100644
--- a/include/assimp/ProgressHandler.hpp
+++ b/include/assimp/ProgressHandler.hpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/RemoveComments.h b/include/assimp/RemoveComments.h
index c2defff63..a7a9a2381 100644
--- a/include/assimp/RemoveComments.h
+++ b/include/assimp/RemoveComments.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/SGSpatialSort.h b/include/assimp/SGSpatialSort.h
index 96feefabb..13a214d44 100644
--- a/include/assimp/SGSpatialSort.h
+++ b/include/assimp/SGSpatialSort.h
@@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -63,10 +62,8 @@ namespace Assimp {
* implementation to handle all details of its file format correctly.
*/
// ----------------------------------------------------------------------------------
-class ASSIMP_API SGSpatialSort
-{
+class ASSIMP_API SGSpatialSort {
public:
-
SGSpatialSort();
// -------------------------------------------------------------------
@@ -90,7 +87,7 @@ public:
void Prepare();
/** Destructor */
- ~SGSpatialSort();
+ ~SGSpatialSort() = default;
// -------------------------------------------------------------------
/** Returns an iterator for all positions close to the given position.
diff --git a/include/assimp/SceneCombiner.h b/include/assimp/SceneCombiner.h
index d6096900c..790a18c2d 100644
--- a/include/assimp/SceneCombiner.h
+++ b/include/assimp/SceneCombiner.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/SkeletonMeshBuilder.h b/include/assimp/SkeletonMeshBuilder.h
index 2929aaa61..620748632 100644
--- a/include/assimp/SkeletonMeshBuilder.h
+++ b/include/assimp/SkeletonMeshBuilder.h
@@ -4,7 +4,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/SmallVector.h b/include/assimp/SmallVector.h
index 60ad26411..8e8e2db5f 100644
--- a/include/assimp/SmallVector.h
+++ b/include/assimp/SmallVector.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/SmoothingGroups.h b/include/assimp/SmoothingGroups.h
index 4625a2916..e77a8b2d9 100644
--- a/include/assimp/SmoothingGroups.h
+++ b/include/assimp/SmoothingGroups.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/SmoothingGroups.inl b/include/assimp/SmoothingGroups.inl
index d5fff5bf7..6de5ee997 100644
--- a/include/assimp/SmoothingGroups.inl
+++ b/include/assimp/SmoothingGroups.inl
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/SpatialSort.h b/include/assimp/SpatialSort.h
index cd055450e..e527b15a2 100644
--- a/include/assimp/SpatialSort.h
+++ b/include/assimp/SpatialSort.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/StandardShapes.h b/include/assimp/StandardShapes.h
index 77880cf9e..aad2ce395 100644
--- a/include/assimp/StandardShapes.h
+++ b/include/assimp/StandardShapes.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/StreamReader.h b/include/assimp/StreamReader.h
index 44b24a33b..cc74bd652 100644
--- a/include/assimp/StreamReader.h
+++ b/include/assimp/StreamReader.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -68,7 +68,7 @@ namespace Assimp {
*
* XXX switch from unsigned int for size types to size_t? or ptrdiff_t?*/
// --------------------------------------------------------------------------------------------
-template <bool SwapEndianess = false, bool RuntimeSwitch = false>
+template <bool SwapEndianness = false, bool RuntimeSwitch = false>
class StreamReader {
public:
using diff = size_t;
@@ -84,7 +84,7 @@ public:
* reads from the current position to the end of the stream.
* @param le If @c RuntimeSwitch is true: specifies whether the
* stream is in little endian byte order. Otherwise the
- * endianness information is contained in the @c SwapEndianess
+ * endianness information is contained in the @c SwapEndianness
* template parameter and this parameter is meaningless. */
StreamReader(std::shared_ptr<IOStream> stream, bool le = false) :
mStream(stream),
@@ -291,7 +291,7 @@ public:
T f;
::memcpy(&f, mCurrent, sizeof(T));
- Intern::Getter<SwapEndianess, T, RuntimeSwitch>()(&f, mLe);
+ Intern::Getter<SwapEndianness, T, RuntimeSwitch>()(&f, mLe);
mCurrent += sizeof(T);
return f;
diff --git a/include/assimp/StreamWriter.h b/include/assimp/StreamWriter.h
index 50e28447c..32da6911b 100644
--- a/include/assimp/StreamWriter.h
+++ b/include/assimp/StreamWriter.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -65,7 +65,7 @@ namespace Assimp {
* stream is to be determined at runtime.
*/
// --------------------------------------------------------------------------------------------
-template <bool SwapEndianess = false, bool RuntimeSwitch = false>
+template <bool SwapEndianness = false, bool RuntimeSwitch = false>
class StreamWriter {
enum {
INITIAL_CAPACITY = 1024
@@ -82,7 +82,7 @@ public:
continues at the current position of the stream cursor.
* @param le If @c RuntimeSwitch is true: specifies whether the
* stream is in little endian byte order. Otherwise the
- * endianness information is defined by the @c SwapEndianess
+ * endianness information is defined by the @c SwapEndianness
* template parameter and this parameter is meaningless. */
StreamWriter(std::shared_ptr<IOStream> stream, bool le = false)
: stream(stream)
@@ -260,7 +260,7 @@ public:
/** Generic write method. ByteSwap::Swap(T*) *must* be defined */
template <typename T>
void Put(T f) {
- Intern :: Getter<SwapEndianess,T,RuntimeSwitch>() (&f, le);
+ Intern :: Getter<SwapEndianness,T,RuntimeSwitch>() (&f, le);
if (cursor + sizeof(T) >= buffer.size()) {
buffer.resize(cursor + sizeof(T));
diff --git a/include/assimp/StringComparison.h b/include/assimp/StringComparison.h
index 0518d426d..283d8ba6b 100644
--- a/include/assimp/StringComparison.h
+++ b/include/assimp/StringComparison.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/StringUtils.h b/include/assimp/StringUtils.h
index cd8726785..0af923902 100644
--- a/include/assimp/StringUtils.h
+++ b/include/assimp/StringUtils.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/Subdivision.h b/include/assimp/Subdivision.h
index 114120368..75f44cbb5 100644
--- a/include/assimp/Subdivision.h
+++ b/include/assimp/Subdivision.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/TinyFormatter.h b/include/assimp/TinyFormatter.h
index df2a32eca..387fc86b6 100644
--- a/include/assimp/TinyFormatter.h
+++ b/include/assimp/TinyFormatter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/Vertex.h b/include/assimp/Vertex.h
index 3fc974504..62a531ce2 100644
--- a/include/assimp/Vertex.h
+++ b/include/assimp/Vertex.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/XMLTools.h b/include/assimp/XMLTools.h
index b2766f19b..fa27af134 100644
--- a/include/assimp/XMLTools.h
+++ b/include/assimp/XMLTools.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/XmlParser.h b/include/assimp/XmlParser.h
index 4ab42ba2a..4c19098a4 100644
--- a/include/assimp/XmlParser.h
+++ b/include/assimp/XmlParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/ZipArchiveIOSystem.h b/include/assimp/ZipArchiveIOSystem.h
index 9f3a4783b..8145e98f8 100644
--- a/include/assimp/ZipArchiveIOSystem.h
+++ b/include/assimp/ZipArchiveIOSystem.h
@@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -55,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp>
+#include <zlib.h>
namespace Assimp {
diff --git a/include/assimp/aabb.h b/include/assimp/aabb.h
index b38aa1697..bd78e67a6 100644
--- a/include/assimp/aabb.h
+++ b/include/assimp/aabb.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -59,18 +59,12 @@ struct aiAABB {
#ifdef __cplusplus
/// @brief The default class constructor.
- aiAABB() :
- mMin(), mMax() {
- // empty
- }
+ aiAABB() = default;
/// @brief The class constructor with the minimum and maximum.
/// @param min The minimum dimension.
/// @param max The maximum dimension.
- aiAABB(const aiVector3D &min, const aiVector3D &max) :
- mMin(min), mMax(max) {
- // empty
- }
+ aiAABB(const aiVector3D &min, const aiVector3D &max) : mMin(min), mMax(max) {}
/// @brief The class destructor.
~aiAABB() = default;
diff --git a/include/assimp/ai_assert.h b/include/assimp/ai_assert.h
index e49a482dd..e4d43f31c 100644
--- a/include/assimp/ai_assert.h
+++ b/include/assimp/ai_assert.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/anim.h b/include/assimp/anim.h
index 49f0d5014..4e29fa0c0 100644
--- a/include/assimp/anim.h
+++ b/include/assimp/anim.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -90,6 +90,7 @@ struct aiVectorKey {
bool operator==(const aiVectorKey &rhs) const {
return rhs.mValue == this->mValue;
}
+
bool operator!=(const aiVectorKey &rhs) const {
return rhs.mValue != this->mValue;
}
diff --git a/include/assimp/camera.h b/include/assimp/camera.h
index 09255fa05..b8ea59927 100644
--- a/include/assimp/camera.h
+++ b/include/assimp/camera.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/cexport.h b/include/assimp/cexport.h
index a45ece39b..175fe5ea4 100644
--- a/include/assimp/cexport.h
+++ b/include/assimp/cexport.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/cfileio.h b/include/assimp/cfileio.h
index fc1b95ad1..bd971957c 100644
--- a/include/assimp/cfileio.h
+++ b/include/assimp/cfileio.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/cimport.h b/include/assimp/cimport.h
index 935ed18bd..b0b4e038a 100644
--- a/include/assimp/cimport.h
+++ b/include/assimp/cimport.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/color4.h b/include/assimp/color4.h
index e1e354939..cdd61e451 100644
--- a/include/assimp/color4.h
+++ b/include/assimp/color4.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/color4.inl b/include/assimp/color4.inl
index aed3de6f1..7fd067758 100644
--- a/include/assimp/color4.inl
+++ b/include/assimp/color4.inl
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/commonMetaData.h b/include/assimp/commonMetaData.h
index ccded585b..53d2f37aa 100644
--- a/include/assimp/commonMetaData.h
+++ b/include/assimp/commonMetaData.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/config.h.in b/include/assimp/config.h.in
index 97551e602..897eecb19 100644
--- a/include/assimp/config.h.in
+++ b/include/assimp/config.h.in
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -226,6 +226,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"PP_PTV_ROOT_TRANSFORMATION"
// ---------------------------------------------------------------------------
+/** @brief Set epsilon to check the identity of the matrix 4x4.
+ *
+ * This is used by aiMatrix4x4t<TReal>::IsIdentity(const TReal epsilon).
+ * @note The default value is 10e-3f for backward compatibility of legacy code.
+ * Property type: Float.
+ */
+#define AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON \
+ "CHECK_IDENTITY_MATRIX_EPSILON"
+
+// default value for AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON
+#if (!defined AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT)
+# define AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT 10e-3f
+#endif
+
+// ---------------------------------------------------------------------------
/** @brief Configures the #aiProcess_FindDegenerates step to
* remove degenerated primitives from the import - immediately.
*
@@ -1085,6 +1100,29 @@ enum aiComponent
*/
#define AI_CONFIG_USE_GLTF_PBR_SPECULAR_GLOSSINESS "USE_GLTF_PBR_SPECULAR_GLOSSINESS"
+/** @brief Specifies whether to apply a limit on the number of four bones per vertex in skinning
+ *
+ * When this flag is not defined, all bone weights and indices are limited to a
+ * maximum of four bones for each vertex (attributes JOINT_0 and WEIGHT_0 only).
+ * By enabling this flag, the number of bones per vertex is unlimited.
+ * In both cases, indices and bone weights are sorted by weight in descending order.
+ * In the case of the limit of up to four bones, a maximum of the four largest values are exported.
+ * Weights are not normalized.
+ * Property type: Bool. Default value: false.
+ */
+#define AI_CONFIG_EXPORT_GLTF_UNLIMITED_SKINNING_BONES_PER_VERTEX \
+ "USE_UNLIMITED_BONES_PER VERTEX"
+
+/** @brief Specifies whether to write the value referenced to opacity in TransparencyFactor of each material.
+ *
+ * When this flag is not defined, the TransparencyFactor value of each meterial is 1.0.
+ * By enabling this flag, the value is 1.0 - opacity;
+
+ * Property type: Bool. Default value: false.
+ */
+#define AI_CONFIG_EXPORT_FBX_TRANSPARENCY_FACTOR_REFER_TO_OPACITY \
+ "EXPORT_FBX_TRANSPARENCY_FACTOR_REFER_TO_OPACITY"
+
/**
* @brief Specifies the blob name, assimp uses for exporting.
*
diff --git a/include/assimp/defs.h b/include/assimp/defs.h
index e1aaafd44..6a971928d 100644
--- a/include/assimp/defs.h
+++ b/include/assimp/defs.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/importerdesc.h b/include/assimp/importerdesc.h
index d08bd1781..e26751049 100644
--- a/include/assimp/importerdesc.h
+++ b/include/assimp/importerdesc.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/light.h b/include/assimp/light.h
index 3331997a9..3233cec70 100644
--- a/include/assimp/light.h
+++ b/include/assimp/light.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/material.h b/include/assimp/material.h
index 80551e53d..30db265e8 100644
--- a/include/assimp/material.h
+++ b/include/assimp/material.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/material.inl b/include/assimp/material.inl
index b7222f9c7..fdf837db4 100644
--- a/include/assimp/material.inl
+++ b/include/assimp/material.inl
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/matrix3x3.h b/include/assimp/matrix3x3.h
index 74382e263..a49394ea4 100644
--- a/include/assimp/matrix3x3.h
+++ b/include/assimp/matrix3x3.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/matrix3x3.inl b/include/assimp/matrix3x3.inl
index 99d9197e3..c41a5a076 100644
--- a/include/assimp/matrix3x3.inl
+++ b/include/assimp/matrix3x3.inl
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/matrix4x4.h b/include/assimp/matrix4x4.h
index 67e0e356e..861a7acef 100644
--- a/include/assimp/matrix4x4.h
+++ b/include/assimp/matrix4x4.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/vector3.h>
#include <assimp/defs.h>
+#include <assimp/config.h>
#ifdef __cplusplus
@@ -136,9 +137,13 @@ public:
// -------------------------------------------------------------------
/** @brief Returns true of the matrix is the identity matrix.
+ * @param epsilon Value of epsilon. Default value is 10e-3 for backward
+ * compatibility with legacy code.
+ * @return Returns true of the matrix is the identity matrix.
* The check is performed against a not so small epsilon.
*/
- inline bool IsIdentity() const;
+ inline bool IsIdentity(const TReal
+ epsilon = AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT) const;
// -------------------------------------------------------------------
/** @brief Decompose a trafo matrix into its original components
diff --git a/include/assimp/matrix4x4.inl b/include/assimp/matrix4x4.inl
index 54d176d18..56f7296e5 100644
--- a/include/assimp/matrix4x4.inl
+++ b/include/assimp/matrix4x4.inl
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -242,7 +242,7 @@ aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::Inverse() {
const TReal det = Determinant();
if(det == static_cast<TReal>(0.0))
{
- // Matrix not invertible. Setting all elements to nan is not really
+ // Matrix is not invertible. Setting all elements to nan is not really
// correct in a mathematical sense but it is easy to debug for the
// programmer.
const TReal nan = std::numeric_limits<TReal>::quiet_NaN();
@@ -545,10 +545,7 @@ aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::FromEulerAnglesXYZ(TReal x, TReal y, T
// ----------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE
-bool aiMatrix4x4t<TReal>::IsIdentity() const {
- // Use a small epsilon to solve floating-point inaccuracies
- const static TReal epsilon = 10e-3f;
-
+bool aiMatrix4x4t<TReal>::IsIdentity(const TReal epsilon) const {
return (a2 <= epsilon && a2 >= -epsilon &&
a3 <= epsilon && a3 >= -epsilon &&
a4 <= epsilon && a4 >= -epsilon &&
@@ -657,7 +654,7 @@ aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::Scaling( const aiVector3t<TReal>& v, a
/** A function for creating a rotation matrix that rotates a vector called
* "from" into another vector called "to".
* Input : from[3], to[3] which both must be *normalized* non-zero vectors
- * Output: mtx[3][3] -- a 3x3 matrix in colum-major form
+ * Output: mtx[3][3] -- a 3x3 matrix in column-major form
* Authors: Tomas Möller, John Hughes
* "Efficiently Building a Matrix to Rotate One Vector to Another"
* Journal of Graphics Tools, 4(4):1-4, 1999
diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h
index 3ef94e606..ed9a8faf9 100644
--- a/include/assimp/mesh.h
+++ b/include/assimp/mesh.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -59,6 +59,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/types.h>
#ifdef __cplusplus
+#include <unordered_set>
+
extern "C" {
#endif
@@ -872,11 +874,15 @@ struct aiMesh {
// DO NOT REMOVE THIS ADDITIONAL CHECK
if (mNumBones && mBones) {
+ std::unordered_set<const aiBone *> bones;
for (unsigned int a = 0; a < mNumBones; a++) {
if (mBones[a]) {
- delete mBones[a];
+ bones.insert(mBones[a]);
}
}
+ for (const aiBone *bone: bones) {
+ delete bone;
+ }
delete[] mBones;
}
diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h
index c766d0ae2..8d387ca00 100644
--- a/include/assimp/metadata.h
+++ b/include/assimp/metadata.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/pbrmaterial.h b/include/assimp/pbrmaterial.h
index 3bdf151a3..172d2b8cb 100644
--- a/include/assimp/pbrmaterial.h
+++ b/include/assimp/pbrmaterial.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/postprocess.h b/include/assimp/postprocess.h
index a905a8be0..962d500f8 100644
--- a/include/assimp/postprocess.h
+++ b/include/assimp/postprocess.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/qnan.h b/include/assimp/qnan.h
index c64cabaad..2c071320f 100644
--- a/include/assimp/qnan.h
+++ b/include/assimp/qnan.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/include/assimp/quaternion.h b/include/assimp/quaternion.h
index 7ab3ad6f8..457c650aa 100644
--- a/include/assimp/quaternion.h
+++ b/include/assimp/quaternion.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -45,14 +45,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_QUATERNION_H_INC
#define AI_QUATERNION_H_INC
+#include <assimp/defs.h>
+
#ifdef __cplusplus
#ifdef __GNUC__
# pragma GCC system_header
#endif
-#include <assimp/defs.h>
-
// Forward declarations
template <typename TReal> class aiVector3t;
template <typename TReal> class aiMatrix3x3t;
diff --git a/include/assimp/quaternion.inl b/include/assimp/quaternion.inl
index 2cb24653c..d3e391331 100644
--- a/include/assimp/quaternion.inl
+++ b/include/assimp/quaternion.inl
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/include/assimp/scene.h b/include/assimp/scene.h
index 1b830a5b0..86ab9bf60 100644
--- a/include/assimp/scene.h
+++ b/include/assimp/scene.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/texture.h b/include/assimp/texture.h
index 576fa7711..53837fc86 100644
--- a/include/assimp/texture.h
+++ b/include/assimp/texture.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/types.h b/include/assimp/types.h
index 42aa0f9eb..ea72dd996 100644
--- a/include/assimp/types.h
+++ b/include/assimp/types.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -523,6 +523,23 @@ struct aiMemoryInfo {
unsigned int total;
}; // !struct aiMemoryInfo
+/**
+ * @brief Type to store a in-memory data buffer.
+ */
+struct aiBuffer {
+ const char *data; ///< Begin poiner
+ const char *end; ///< End pointer
+
+#ifdef __cplusplus
+ /// @brief The class constructor.
+ aiBuffer() :
+ data(nullptr), end(nullptr) {}
+
+ /// @brief The class destructor.
+ ~aiBuffer() = default;
+#endif //! __cplusplus
+};
+
#ifdef __cplusplus
}
#endif //! __cplusplus
diff --git a/include/assimp/vector2.h b/include/assimp/vector2.h
index f06e9441d..a8bfddba2 100644
--- a/include/assimp/vector2.h
+++ b/include/assimp/vector2.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/vector2.inl b/include/assimp/vector2.inl
index 245eb3190..a5592ea31 100644
--- a/include/assimp/vector2.inl
+++ b/include/assimp/vector2.inl
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/include/assimp/vector3.h b/include/assimp/vector3.h
index 5d0962b6a..c09fe9b08 100644
--- a/include/assimp/vector3.h
+++ b/include/assimp/vector3.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -151,6 +151,8 @@ public:
typedef aiVector3t<ai_real> aiVector3D;
+typedef aiVector3t<float> aiVector3f;
+typedef aiVector3t<double> aiVector3d;
#else
diff --git a/include/assimp/vector3.inl b/include/assimp/vector3.inl
index 28ca2be07..c42e4cf32 100644
--- a/include/assimp/vector3.inl
+++ b/include/assimp/vector3.inl
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/include/assimp/version.h b/include/assimp/version.h
index 812be551c..f7bcf5bbf 100644
--- a/include/assimp/version.h
+++ b/include/assimp/version.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/packaging/windows-mkzip/bin_readme.txt b/packaging/windows-mkzip/bin_readme.txt
deleted file mode 100644
index f4402d6bf..000000000
--- a/packaging/windows-mkzip/bin_readme.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-
-------------------------------------------------------------------------------------
-Open Asset Import Library (Assimp) Tools/Binaries for Windows
-Release Notes
-------------------------------------------------------------------------------------
-
-
-Known Bugs & Limitations
-========================
-
-Viewer
-
-- For files more than one embedded texture, only the first is loaded.
-- Normals appear flipped from time to time when either of the normals-related menu items was hit.
-- Alpha-sorting is implemented, but still causes artifacts when models are moved quickly.
-- Several important texture file formats (such as GIF) are not supported.
-- HUD is blurred on the right side. ATI/AMD hardware only.
-
-Troubleshooting
-===============
-
-1. Missing d3dx9_42.dll?
-Install the latest DirectX runtime or grab the file from somewhere (that's evil but mostly fine).
-
-2. Application configuration not correct / missing msv*** DLLs?
-(Re)install Microsoft Visual C++ 2005 SP1 Redistributable (x86 or x64, depending on your system)
-
-3. Crashes immediately
-You CPU lacks SSE2 support. Build Assimp from scratch to suit your CPU, sorry.
diff --git a/packaging/windows-mkzip/mkfinal.bat b/packaging/windows-mkzip/mkfinal.bat
deleted file mode 100644
index b626514c0..000000000
--- a/packaging/windows-mkzip/mkfinal.bat
+++ /dev/null
@@ -1,169 +0,0 @@
-
-rem -----------------------------------------------------
-rem Batch file to build zipped redist packages
-rem Two different packages are built:
-rem
-rem assimp--<revision>-bin.zip
-rem Binaries for x86 and x64
-rem Command line reference
-rem
-rem assimp--<revision>-sdk.zip
-rem Binaries for x86 and x64, Debug & Release
-rem Libs for DLL build, x86 & 64, Debug & Release
-rem Full SVN checkout exluding mkutil & port
-rem
-rem
-rem PREREQUISITES:
-rem -7za.exe (7zip standalone)
-rem Download from http://www.7-zip.org/download.html
-rem
-rem -svnversion.exe (Subversion revision getter)
-rem Download any command line SVN package
-rem
-rem -doxygen.exe (Doxygen client)
-rem Download from www.doxygen.com
-rem
-rem -svn client
-rem
-rem NOTES:
-rem ./bin must not have any local modifications
-rem
-rem -----------------------------------------------------
-
-@echo off
-color 4e
-cls
-
-rem -----------------------------------------------------
-rem Setup file revision for build
-rem -----------------------------------------------------
-call mkrev.bat
-
-rem -----------------------------------------------------
-rem Build output file names
-rem -----------------------------------------------------
-
-cd ..\..\bin
-svnversion > tmpfile.txt
-SET /p REVISIONBASE= < tmpfile.txt
-DEL /q tmpfile.txt
-cd ..\packaging\windows-mkzip
-
-SET VERSIONBASE=2.0.%REVISIONBASE%
-
-SET OUT_SDK=assimp--%VERSIONBASE%-sdk
-SET OUT_BIN=assimp--%VERSIONBASE%-bin
-
-SET BINCFG_x86=release-dll_win32
-SET BINCFG_x64=release-dll_x64
-
-SET BINCFG_x86_DEBUG=debug-dll_win32
-SET BINCFG_x64_DEBUG=debug-dll_x64
-
-rem -----------------------------------------------------
-rem Delete previous output directories
-rem -----------------------------------------------------
-RD /S /q final\
-
-rem -----------------------------------------------------
-rem Create output directories
-rem -----------------------------------------------------
-
-mkdir final\%OUT_BIN%\x86
-mkdir final\%OUT_BIN%\x64
-
-rem -----------------------------------------------------
-rem Copy all executables to 'final-bin'
-rem -----------------------------------------------------
-
-copy /Y ..\..\bin\assimpview_%BINCFG_x86%\assimp_view.exe "final\%OUT_BIN%\x86\assimp_view.exe"
-copy /Y ..\..\bin\assimpview_%BINCFG_x64%\assimp_view.exe "final\%OUT_BIN%\x64\assimp_view.exe"
-
-copy /Y ..\..\bin\assimpcmd_%BINCFG_x86%\assimp.exe "final\%OUT_BIN%\x86\assimp.exe"
-copy /Y ..\..\bin\assimpcmd_%BINCFG_x64%\assimp.exe "final\%OUT_BIN%\x64\assimp.exe"
-
-copy /Y ..\..\bin\assimp_%BINCFG_x86%\Assimp32.dll "final\%OUT_BIN%\x86\Assimp32.dll"
-copy /Y ..\..\bin\assimp_%BINCFG_x64%\Assimp64.dll "final\%OUT_BIN%\x64\Assimp64.dll"
-
-copy ..\..\LICENSE final\%OUT_BIN%\LICENSE
-copy ..\..\CREDITS final\%OUT_BIN%\CREDITS
-copy bin_readme.txt final\%OUT_BIN%\README
-copy bin_readme.txt final\%OUT_BIN%\README
-
-copy ..\..\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm final\%OUT_BIN%\CommandLine.chm
-
-rem -----------------------------------------------------
-rem Do a clean export of the repository and build SDK
-rem
-rem We take the current revision and remove some stuff
-rem that is nto yet ready to be published.
-rem -----------------------------------------------------
-
-svn export .\..\..\ .\final\%OUT_SDK%
-
-mkdir final\%OUT_SDK%\doc\assimp_html
-mkdir final\%OUT_SDK%\doc\assimpcmd_html
-copy .\..\..\doc\AssimpDoc_Html\* final\%OUT_SDK%\doc\assimp_html
-copy .\..\..\doc\AssimpCmdDoc_Html\* final\%OUT_SDK%\doc\assimpcmd_html
-del final\%OUT_SDK%\doc\assimpcmd_html\AssimpCmdDoc.chm
-del final\%OUT_SDK%\doc\assimp_html\AssimpDoc.chm
-
-rem Copy doc to a suitable place
-move final\%OUT_SDK%\doc\AssimpDoc_Html\AssimpDoc.chm final\%OUT_SDK%\Documentation.chm
-move final\%OUT_SDK%\doc\AssimpCmdDoc_Html\AssimpCmdDoc.chm final\%OUT_SDK%\CommandLine.chm
-
-rem Cleanup ./doc folder
-del /q final\%OUT_SDK%\doc\Preamble.txt
-RD /s /q final\%OUT_SDK%\doc\AssimpDoc_Html
-RD /s /q final\%OUT_SDK%\doc\AssimpCmdDoc_Html
-
-rem Insert 'dummy' files into empty folders
-echo. > final\%OUT_SDK%\lib\dummy
-echo. > final\%OUT_SDK%\obj\dummy
-
-
-RD /s /q final\%OUT_SDK%\port\swig
-
-rem Also, repackaging is not a must-have feature
-RD /s /q final\%OUT_SDK%\packaging
-
-rem Copy prebuilt libs
-mkdir "final\%OUT_SDK%\lib\assimp_%BINCFG_x86%"
-mkdir "final\%OUT_SDK%\lib\assimp_%BINCFG_x64%"
-mkdir "final\%OUT_SDK%\lib\assimp_%BINCFG_x86_DEBUG%"
-mkdir "final\%OUT_SDK%\lib\assimp_%BINCFG_x64_DEBUG%"
-
-copy /Y ..\..\lib\assimp_%BINCFG_x86%\assimp.lib "final\%OUT_SDK%\lib\assimp_%BINCFG_x86%"
-copy /Y ..\..\lib\assimp_%BINCFG_x64%\assimp.lib "final\%OUT_SDK%\lib\assimp_%BINCFG_x64%\"
-copy /Y ..\..\lib\assimp_%BINCFG_x86_DEBUG%\assimp.lib "final\%OUT_SDK%\lib\assimp_%BINCFG_x86_DEBUG%\"
-copy /Y ..\..\lib\assimp_%BINCFG_x64_DEBUG%\assimp.lib "final\%OUT_SDK%\lib\assimp_%BINCFG_x64_DEBUG%\"
-
-rem Copy prebuilt DLLs
-mkdir "final\%OUT_SDK%\bin\assimp_%BINCFG_x86%"
-mkdir "final\%OUT_SDK%\bin\assimp_%BINCFG_x64%"
-mkdir "final\%OUT_SDK%\bin\assimp_%BINCFG_x86_DEBUG%"
-mkdir "final\%OUT_SDK%\bin\assimp_%BINCFG_x64_DEBUG%"
-
-
-copy /Y ..\..\bin\assimp_%BINCFG_x86%\Assimp32.dll "final\%OUT_SDK%\bin\assimp_%BINCFG_x86%\"
-copy /Y ..\..\bin\assimp_%BINCFG_x64%\Assimp64.dll "final\%OUT_SDK%\bin\assimp_%BINCFG_x64%\"
-copy /Y ..\..\bin\assimp_%BINCFG_x86_DEBUG%\Assimp32d.dll "final\%OUT_SDK%\bin\assimp_%BINCFG_x86_DEBUG%\"
-copy /Y ..\..\bin\assimp_%BINCFG_x64_DEBUG%\Assimp64d.dll "final\%OUT_SDK%\bin\assimp_%BINCFG_x64_DEBUG%\"
-
-
-rem -----------------------------------------------------
-rem Make final-bin.zip and final-sdk.zip
-rem -----------------------------------------------------
-
-IF NOT EXIST 7za.exe (
- cls
- echo You need to have 7zip standalone installed to
- echo build ZIP archives. Download: http://www.7-zip.org/download.html
- pause
-) else (
-7za.exe a -tzip "final\%OUT_BIN%.zip" ".\final\%OUT_BIN%"
-7za.exe a -tzip "final\%OUT_SDK%.zip" ".\final\%OUT_SDK%"
-)
-
-rem OK. We should have the release packages now.
-
diff --git a/packaging/windows-mkzip/mkrev.bat b/packaging/windows-mkzip/mkrev.bat
deleted file mode 100644
index 9d8eec120..000000000
--- a/packaging/windows-mkzip/mkrev.bat
+++ /dev/null
@@ -1,27 +0,0 @@
-@echo off
-
-rem -----------------------------------------------------
-rem Tiny batch script to build the input file revision.h
-rem revision.h contains the revision number of the wc.
-rem It is included by assimp.rc.
-rem -----------------------------------------------------
-
-rem This is not very elegant, but it works.
-rem ./bin shouldn't have any local modifications
-
-svnversion > tmpfile.txt
-set /p addtext= < tmpfile.txt
-del /q tmpfile.txt
-
-echo #define SVNRevision > tmpfile.txt
-
-if exist ..\..\revision.h del /q ..\..\revision.h
-for /f "delims=" %%l in (tmpfile.txt) Do (
- for /f "delims=M:" %%r in ("%addtext%") Do (
- echo %%l %%r >> ..\..\revision.h
- )
-)
-del /q tmpfile.txt
-
-
-
diff --git a/port/PyAssimp/LICENSE b/port/PyAssimp/LICENSE
new file mode 100644
index 000000000..91cf88d72
--- /dev/null
+++ b/port/PyAssimp/LICENSE
@@ -0,0 +1,17 @@
+ISC License
+
+Copyright 2024, pyassimp contributors
+
+Permission to use, copy, modify, and/or distribute this software
+for any purpose with or without fee is hereby granted, provided
+that the above copyright notice and this permission notice appear
+in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
+OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
diff --git a/port/PyAssimp/pyassimp/helper.py b/port/PyAssimp/pyassimp/helper.py
index 7c14f6097..0ae7cbdff 100644
--- a/port/PyAssimp/pyassimp/helper.py
+++ b/port/PyAssimp/pyassimp/helper.py
@@ -5,13 +5,17 @@ Some fancy helper functions.
"""
import os
+import platform
import ctypes
import operator
-from distutils.sysconfig import get_python_lib
import re
import sys
+have_distutils = sys.version_info[0] < 3 and sys.version_info[1] < 12
+if have_distutils:
+ from distutils.sysconfig import get_python_lib
+
try: import numpy
except ImportError: numpy = None
@@ -32,10 +36,14 @@ if os.name=='posix':
if 'LD_LIBRARY_PATH' in os.environ:
additional_dirs.extend([item for item in os.environ['LD_LIBRARY_PATH'].split(':') if item])
+
+ if platform.system() == 'Darwin':
+ if 'DYLD_LIBRARY_PATH' in os.environ:
+ additional_dirs.extend([item for item in os.environ['DYLD_LIBRARY_PATH'].split(':') if item])
# check if running from anaconda.
anaconda_keywords = ("conda", "continuum")
- if any(k in sys.version.lower() for k in anaconda_keywords):
+ if have_distutils and any(k in sys.version.lower() for k in anaconda_keywords):
cur_path = get_python_lib()
pattern = re.compile('.*\/lib\/')
conda_lib = pattern.match(cur_path).group()
diff --git a/samples/SimpleTexturedDirectx11/CMakeLists.txt b/samples/SimpleTexturedDirectx11/CMakeLists.txt
index de83734ba..f64923179 100644
--- a/samples/SimpleTexturedDirectx11/CMakeLists.txt
+++ b/samples/SimpleTexturedDirectx11/CMakeLists.txt
@@ -19,6 +19,7 @@ INCLUDE_DIRECTORIES(
${Assimp_SOURCE_DIR}/include
${Assimp_SOURCE_DIR}/code
${SAMPLES_SHARED_CODE_DIR}
+ ${Assimp_SOURCE_DIR}/contrib/utf8cpp/source
)
LINK_DIRECTORIES(
diff --git a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp
index 4da5820a1..ec031a594 100644
--- a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp
+++ b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp
@@ -23,6 +23,7 @@
#include <dxgi1_2.h>
#include <DirectXMath.h>
#include <d3dcompiler.h>
+#include <utf8.h>
#include "ModelLoader.h"
#include "SafeRelease.hpp"
diff --git a/samples/SimpleTexturedOpenGL/CMakeLists.txt b/samples/SimpleTexturedOpenGL/CMakeLists.txt
index 70837e87c..a10a15101 100644
--- a/samples/SimpleTexturedOpenGL/CMakeLists.txt
+++ b/samples/SimpleTexturedOpenGL/CMakeLists.txt
@@ -21,6 +21,7 @@ INCLUDE_DIRECTORIES(
${OPENGL_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
${SAMPLES_SHARED_CODE_DIR}
+ ${Assimp_SOURCE_DIR}/contrib/utf8cpp/source
)
LINK_DIRECTORIES(
diff --git a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp
index 7d730a630..f6d3097fe 100644
--- a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp
+++ b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glu.h>
+#include <utf8.h>
#ifdef _MSC_VER
#pragma warning(disable: 4100) // Disable warning 'unreferenced formal parameter'
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index afe487411..a59cafbbc 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,6 +1,6 @@
# Open Asset Import Library (assimp)
# ----------------------------------------------------------------------
-# Copyright (c) 2006-2022, assimp team
+# Copyright (c) 2006-2024, assimp team
#
# All rights reserved.
#
@@ -165,6 +165,7 @@ SET( IMPORTERS
unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp
unit/ImportExport/RAW/utRAWImportExport.cpp
unit/ImportExport/Terragen/utTerragenImportExport.cpp
+ unit/ImportExport/Pbrt/utPbrtImportExport.cpp
)
SET( MATERIAL
diff --git a/test/models/AC/SphereWithLight.acc b/test/models/AC/SphereWithLight.acc
new file mode 100644
index 000000000..42096672a
--- /dev/null
+++ b/test/models/AC/SphereWithLight.acc
@@ -0,0 +1,535 @@
+AC3Db
+MATERIAL "ac3dmat1" rgb 1.00 1.00 1.00 amb 0.20 0.20 0.20 emis 0.00 0.00 0.00 spec 0.20 0.20 0.20 shi 128 trans 0
+OBJECT world
+kids 2
+OBJECT light
+name "light"
+loc 0.000424567 -0.0127304 0
+kids 0
+OBJECT poly
+name "sphere"
+texture "earthSpherical.jpg" base
+texture empty_texture_no_mapping tiled
+texture empty_texture_no_mapping skids
+texture empty_texture_no_mapping shad
+numvert 167
+-0.051576 -0.062833 0.063067 0.224114 -0.961969 0.156168
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.049587 -0.062833 0.055841 0.270337 -0.962554 0.020215
+-0.057009 -0.062833 0.068357 0.117917 -0.961035 0.250013
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.064432 -0.062833 0.070294 -0.019618 -0.960685 0.276946
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.071854 -0.062833 0.068357 -0.151973 -0.961267 0.229935
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.077288 -0.062833 0.063067 -0.243865 -0.962202 0.121235
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.079277 -0.062833 0.055841 -0.270337 -0.962554 -0.020215
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.077288 -0.062833 0.048614 -0.224114 -0.961969 -0.156168
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.071854 -0.062833 0.043324 -0.117917 -0.961035 -0.250013
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.064432 -0.062833 0.041388 0.019618 -0.960685 -0.276946
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.057009 -0.062833 0.043324 0.151973 -0.961267 -0.229935
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.049587 0.042114 0.055841 0.270334 0.962554 -0.020215
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.051576 0.042114 0.063067 0.243863 0.962202 0.121233
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.057009 0.042114 0.068357 0.151972 0.961268 0.229933
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.064432 0.042114 0.070294 0.019618 0.960686 0.276944
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.071854 0.042114 0.068357 -0.117915 0.961036 0.250011
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.077288 0.042114 0.063067 -0.224112 0.961970 0.156167
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.079277 0.042114 0.055841 -0.270334 0.962554 0.020215
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.077288 0.042114 0.048614 -0.243863 0.962202 -0.121233
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.071854 0.042114 0.043324 -0.151972 0.961268 -0.229933
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.064432 0.042114 0.041388 -0.019618 0.960686 -0.276944
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.057009 0.042114 0.043324 0.117916 0.961036 -0.250011
+-0.035753 -0.057406 0.055841 0.479979 -0.877222 0.010123
+-0.049587 -0.062833 0.055841 0.270337 -0.962554 0.020215
+-0.051576 -0.062833 0.048614 0.243865 -0.962202 -0.121234
+-0.039596 -0.057406 0.041881 0.420061 -0.875943 -0.237219
+-0.023874 -0.048773 0.055841 0.687850 -0.725803 0.008451
+-0.029308 -0.048773 0.036098 0.598218 -0.723534 -0.344433
+-0.014759 -0.037522 0.055841 0.853991 -0.520251 0.006112
+-0.021414 -0.037522 0.031661 0.739473 -0.517639 -0.430382
+-0.009029 -0.024420 0.055841 0.962274 -0.272063 0.003217
+-0.016452 -0.024420 0.028872 0.830450 -0.270187 -0.487187
+-0.007075 -0.010360 0.055841 1.000000 -0.000000 0.000000
+-0.014759 -0.010360 0.027920 0.860926 0.000265 -0.508731
+-0.009029 0.003701 0.055841 0.962274 0.272063 -0.003217
+-0.016452 0.003701 0.028872 0.827147 0.270625 -0.492534
+-0.014759 0.016803 0.055841 0.853991 0.520251 -0.006112
+-0.021414 0.016803 0.031661 0.733264 0.517855 -0.440625
+-0.023874 0.028054 0.055841 0.687850 0.725803 -0.008451
+-0.029308 0.028054 0.036098 0.589753 0.723523 -0.358756
+-0.035753 0.036687 0.055841 0.479979 0.877222 -0.010123
+-0.039596 0.036687 0.041881 0.410061 0.875812 -0.254565
+-0.049587 0.042114 0.055841 0.270334 0.962554 -0.020215
+-0.051576 0.042114 0.048614 0.224112 0.961970 -0.156167
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+-0.039596 -0.057406 0.069801 0.410061 -0.875812 0.254565
+-0.035753 -0.057406 0.055841 0.479979 -0.877222 0.010123
+-0.050092 -0.057406 0.080021 0.230454 -0.873143 0.429549
+-0.064432 -0.057406 0.083761 -0.009683 -0.871880 0.489625
+-0.078771 -0.057406 0.080021 -0.247407 -0.873270 0.419748
+-0.089268 -0.057406 0.069801 -0.420061 -0.875942 0.237220
+-0.093110 -0.057406 0.055841 -0.479980 -0.877221 -0.010124
+-0.089268 -0.057406 0.041881 -0.410062 -0.875812 -0.254565
+-0.078771 -0.057406 0.031661 -0.230453 -0.873143 -0.429549
+-0.064432 -0.057406 0.027920 0.009684 -0.871880 -0.489625
+-0.050092 -0.057406 0.031661 0.247407 -0.873271 -0.419748
+-0.029308 -0.048773 0.075583 0.589753 -0.723523 0.358757
+-0.023874 -0.048773 0.055841 0.687850 -0.725803 0.008451
+-0.044153 -0.048773 0.090036 0.333957 -0.719029 0.609483
+-0.064432 -0.048773 0.095326 -0.007940 -0.716811 0.697222
+-0.084710 -0.048773 0.090036 -0.348006 -0.719035 0.601564
+-0.099555 -0.048773 0.075583 -0.598218 -0.723534 0.344434
+-0.104989 -0.048773 0.055841 -0.687850 -0.725804 -0.008451
+-0.099555 -0.048773 0.036098 -0.589753 -0.723523 -0.358757
+-0.084710 -0.048773 0.021645 -0.333958 -0.719029 -0.609483
+-0.064432 -0.048773 0.016355 0.007940 -0.716811 -0.697222
+-0.044153 -0.048773 0.021645 0.348006 -0.719035 -0.601565
+-0.021414 -0.037522 0.080021 0.733263 -0.517855 0.440625
+-0.014759 -0.037522 0.055841 0.853991 -0.520251 0.006112
+-0.039596 -0.037522 0.097721 0.416448 -0.512938 0.750643
+-0.064432 -0.037522 0.104200 -0.005639 -0.510417 0.859908
+-0.089268 -0.037522 0.097721 -0.426533 -0.512723 0.745107
+-0.107449 -0.037522 0.080021 -0.739473 -0.517640 0.430382
+-0.114104 -0.037522 0.055841 -0.853991 -0.520252 -0.006112
+-0.107449 -0.037522 0.031661 -0.733262 -0.517857 -0.440626
+-0.089268 -0.037522 0.013960 -0.416448 -0.512938 -0.750643
+-0.064432 -0.037522 0.007481 0.005639 -0.510417 -0.859908
+-0.039595 -0.037522 0.013960 0.426534 -0.512723 -0.745107
+-0.016452 -0.024420 0.082810 0.827147 -0.270625 0.492534
+-0.009029 -0.024420 0.055841 0.962274 -0.272063 0.003217
+-0.036730 -0.024420 0.102553 0.470709 -0.267377 0.840799
+-0.064432 -0.024420 0.109779 -0.002929 -0.265584 0.964083
+-0.092133 -0.024420 0.102553 -0.475987 -0.266955 0.837957
+-0.112412 -0.024420 0.082810 -0.830450 -0.270188 0.487187
+-0.119834 -0.024420 0.055841 -0.962274 -0.272062 -0.003217
+-0.112412 -0.024420 0.028872 -0.827148 -0.270623 -0.492534
+-0.092133 -0.024420 0.009129 -0.470709 -0.267377 -0.840799
+-0.064432 -0.024420 0.001903 0.002929 -0.265584 -0.964083
+-0.036730 -0.024420 0.009129 0.475987 -0.266954 -0.837957
+-0.014759 -0.010360 0.083761 0.860926 -0.000266 0.508731
+-0.007075 -0.010360 0.055841 1.000000 -0.000000 0.000000
+-0.035753 -0.010360 0.104200 0.491288 -0.000257 0.870997
+-0.064432 -0.010360 0.111682 0.000000 -0.000000 1.000000
+-0.093110 -0.010360 0.104200 -0.491288 0.000257 0.870997
+-0.114104 -0.010360 0.083761 -0.860926 0.000265 0.508731
+-0.121788 -0.010360 0.055841 -1.000000 -0.000001 -0.000001
+-0.114104 -0.010360 0.027920 -0.860925 -0.000266 -0.508731
+-0.093110 -0.010360 0.007481 -0.491288 -0.000256 -0.870997
+-0.064432 -0.010360 0.000000 0.000000 -0.000000 -1.000000
+-0.035753 -0.010360 0.007481 0.491288 0.000257 -0.870997
+-0.016452 0.003701 0.082810 0.830450 0.270188 0.487187
+-0.009029 0.003701 0.055841 0.962274 0.272063 -0.003217
+-0.036730 0.003701 0.102553 0.475987 0.266955 0.837957
+-0.064432 0.003701 0.109779 0.002929 0.265584 0.964083
+-0.092133 0.003701 0.102553 -0.470709 0.267377 0.840799
+-0.112412 0.003701 0.082810 -0.827147 0.270625 0.492534
+-0.119834 0.003701 0.055841 -0.962274 0.272063 0.003217
+-0.112412 0.003701 0.028872 -0.830450 0.270186 -0.487188
+-0.092133 0.003701 0.009129 -0.475987 0.266954 -0.837957
+-0.064432 0.003701 0.001903 -0.002929 0.265583 -0.964083
+-0.036730 0.003701 0.009129 0.470710 0.267376 -0.840799
+-0.021414 0.016803 0.080021 0.739473 0.517639 0.430383
+-0.014759 0.016803 0.055841 0.853991 0.520251 -0.006112
+-0.039596 0.016803 0.097721 0.426533 0.512723 0.745107
+-0.064432 0.016803 0.104200 0.005639 0.510417 0.859908
+-0.089268 0.016803 0.097721 -0.416448 0.512938 0.750643
+-0.107449 0.016803 0.080021 -0.733262 0.517857 0.440626
+-0.114104 0.016803 0.055841 -0.853991 0.520252 0.006112
+-0.107449 0.016803 0.031661 -0.739473 0.517640 -0.430382
+-0.089268 0.016803 0.013960 -0.426533 0.512723 -0.745107
+-0.064432 0.016803 0.007481 -0.005640 0.510418 -0.859908
+-0.039595 0.016803 0.013960 0.416449 0.512938 -0.750643
+-0.029308 0.028054 0.075583 0.598218 0.723534 0.344433
+-0.023874 0.028054 0.055841 0.687850 0.725803 -0.008451
+-0.044153 0.028054 0.090036 0.348006 0.719035 0.601565
+-0.064432 0.028054 0.095326 0.007940 0.716811 0.697222
+-0.084710 0.028054 0.090036 -0.333958 0.719029 0.609483
+-0.099555 0.028054 0.075583 -0.589753 0.723523 0.358757
+-0.104989 0.028054 0.055841 -0.687850 0.725804 0.008451
+-0.099555 0.028054 0.036098 -0.598218 0.723534 -0.344434
+-0.084710 0.028054 0.021645 -0.348006 0.719035 -0.601564
+-0.064432 0.028054 0.016355 -0.007940 0.716811 -0.697222
+-0.044153 0.028054 0.021645 0.333956 0.719030 -0.609483
+-0.039596 0.036687 0.069801 0.420061 0.875943 0.237219
+-0.035753 0.036687 0.055841 0.479979 0.877222 -0.010123
+-0.050092 0.036687 0.080021 0.247407 0.873271 0.419748
+-0.064432 0.036687 0.083761 0.009684 0.871880 0.489625
+-0.078771 0.036687 0.080021 -0.230453 0.873143 0.429549
+-0.089268 0.036687 0.069801 -0.410062 0.875812 0.254565
+-0.093110 0.036687 0.055841 -0.479980 0.877221 0.010124
+-0.089268 0.036687 0.041881 -0.420061 0.875942 -0.237220
+-0.078771 0.036687 0.031661 -0.247407 0.873270 -0.419748
+-0.064432 0.036687 0.027920 -0.009683 0.871880 -0.489625
+-0.050092 0.036687 0.031661 0.230454 0.873143 -0.429549
+-0.064432 0.043965 0.055841 0.000000 1.000000 -0.000000
+-0.064432 -0.064684 0.055841 0.000000 -1.000000 -0.000000
+numsurf 13
+SURF 0x14
+mat 0
+refs 25
+166 0.12500 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+19 0.16667 0.08333 0.20078 0.00100 0.27261 -0.65958 0.06470 0.11207
+44 0.08333 0.08333 0.22774 0.00100 0.24337 -0.66338 0.11207 0.06470
+45 0.08333 0.16667 0.25662 0.00100 0.24258 -0.70570 0.21651 0.12500
+42 -0.00000 0.16667 0.29617 0.00100 0.18165 -0.65455 0.25000 0.00000
+45 0.08333 0.16667 0.25662 0.00100 0.24258 -0.70570 0.21651 0.12500
+46 -0.00000 0.25000 0.34675 0.00100 0.14154 -0.62617 0.35355 0.00000
+47 0.08333 0.25000 0.28254 0.00100 0.23215 -0.72379 0.30619 0.17678
+48 -0.00000 0.33333 0.39286 0.00100 0.09463 -0.54477 0.43301 0.00000
+49 0.08333 0.33333 0.30010 0.00100 0.20445 -0.70053 0.37500 0.21651
+50 -0.00000 0.41667 0.42672 0.00100 0.04684 -0.39635 0.48296 0.00000
+51 0.08333 0.41667 0.30053 0.00100 0.14994 -0.59217 0.41826 0.24148
+52 -0.00000 0.50000 0.43819 0.27990 0.01216 -0.18101 0.50000 0.00000
+53 0.08333 0.50000 0.27797 0.11146 0.07998 -0.31169 0.43301 0.25000
+54 -0.00000 0.58333 0.42036 0.71453 0.00746 0.06528 0.48296 0.00000
+55 0.08333 0.58333 0.25398 0.77247 0.06825 0.11068 0.41826 0.24148
+56 -0.00000 0.66667 0.37732 0.99900 0.03584 0.27934 0.43301 0.00000
+57 0.08333 0.66667 0.24356 0.99900 0.12085 0.40243 0.37500 0.21651
+58 -0.00000 0.75000 0.32156 0.99900 0.08264 0.41936 0.35355 0.00000
+59 0.08333 0.75000 0.23016 0.99900 0.16764 0.51660 0.30619 0.17678
+60 -0.00000 0.83333 0.26409 0.99900 0.13155 0.48413 0.25000 0.00000
+61 0.08333 0.83333 0.21022 0.99900 0.19350 0.53698 0.21651 0.12500
+62 -0.00000 0.91667 0.21082 0.99900 0.17434 0.49121 0.12941 0.00000
+63 0.08333 0.91667 0.18721 0.99900 0.20517 0.51082 0.11207 0.06470
+64 0.04167 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 4
+42 -0.00000 0.16667 0.29617 0.00100 0.18165 -0.65455 0.25000 0.00000
+43 -0.00000 0.08333 0.24596 0.00100 0.21392 -0.64381 0.12941 0.00000
+44 0.08333 0.08333 0.22774 0.00100 0.24337 -0.66338 0.11207 0.06470
+65 0.04167 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+41 0.16667 0.91667 0.15686 0.99900 0.23923 0.50697 0.06470 0.11207
+165 0.12500 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+41 0.16667 0.91667 0.15686 0.99900 0.23923 0.50697 0.06470 0.11207
+63 0.08333 0.91667 0.18721 0.99900 0.20517 0.51082 0.11207 0.06470
+164 0.16667 0.83333 0.14064 0.99900 0.27287 0.52638 0.12500 0.21651
+61 0.08333 0.83333 0.21022 0.99900 0.19350 0.53698 0.21651 0.12500
+153 0.16667 0.75000 0.11005 0.99900 0.30883 0.49554 0.17678 0.30619
+59 0.08333 0.75000 0.23016 0.99900 0.16764 0.51660 0.30619 0.17678
+142 0.16667 0.66667 0.06221 0.99900 0.34565 0.37156 0.21651 0.37500
+57 0.08333 0.66667 0.24356 0.99900 0.12085 0.40243 0.37500 0.21651
+131 0.16667 0.58333 0.01707 0.75383 0.37997 0.09731 0.24148 0.41826
+55 0.08333 0.58333 0.25398 0.77247 0.06825 0.11068 0.41826 0.24148
+120 0.16667 0.50000 0.02917 0.16155 0.40148 -0.27285 0.25000 0.43301
+53 0.08333 0.50000 0.27797 0.11146 0.07998 -0.31169 0.43301 0.25000
+109 0.16667 0.41667 0.09227 0.00100 0.39866 -0.54216 0.24148 0.41826
+51 0.08333 0.41667 0.30053 0.00100 0.14994 -0.59217 0.41826 0.24148
+98 0.16667 0.33333 0.14840 0.00100 0.37604 -0.66637 0.21651 0.37500
+49 0.08333 0.33333 0.30010 0.00100 0.20445 -0.70053 0.37500 0.21651
+87 0.16667 0.25000 0.18125 0.00100 0.34374 -0.70421 0.17678 0.30619
+47 0.08333 0.25000 0.28254 0.00100 0.23215 -0.72379 0.30619 0.17678
+76 0.16667 0.16667 0.19643 0.00100 0.30813 -0.69579 0.12500 0.21651
+45 0.08333 0.16667 0.25662 0.00100 0.24258 -0.70570 0.21651 0.12500
+76 0.16667 0.16667 0.19643 0.00100 0.30813 -0.69579 0.12500 0.21651
+19 0.16667 0.08333 0.20078 0.00100 0.27261 -0.65958 0.06470 0.11207
+17 0.25000 0.08333 0.17478 0.00100 0.29109 -0.63431 0.00000 0.12941
+20 0.20833 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+39 0.25000 0.91667 0.13138 0.99900 0.26321 0.48188 0.00000 0.12941
+40 0.20833 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+39 0.25000 0.91667 0.13138 0.99900 0.26321 0.48188 0.00000 0.12941
+41 0.16667 0.91667 0.15686 0.99900 0.23923 0.50697 0.06470 0.11207
+163 0.25000 0.83333 0.09337 0.99900 0.32380 0.46306 0.00000 0.25000
+164 0.16667 0.83333 0.14064 0.99900 0.27287 0.52638 0.12500 0.21651
+152 0.25000 0.75000 0.05350 0.99900 0.38666 0.38881 0.00000 0.35355
+153 0.16667 0.75000 0.11005 0.99900 0.30883 0.49554 0.17678 0.30619
+141 0.25000 0.66667 0.01921 0.99900 0.44417 0.25077 0.00000 0.43301
+142 0.16667 0.66667 0.06221 0.99900 0.34565 0.37156 0.21651 0.37500
+130 0.25000 0.58333 0.00104 0.70147 0.48527 0.05732 0.00000 0.48296
+131 0.16667 0.58333 0.01707 0.75383 0.37997 0.09731 0.24148 0.41826
+119 0.25000 0.50000 0.00634 0.30861 0.50000 -0.15875 0.00000 0.50000
+120 0.16667 0.50000 0.02917 0.16155 0.40148 -0.27285 0.25000 0.43301
+108 0.25000 0.41667 0.03263 0.00100 0.48620 -0.35427 0.00000 0.48296
+109 0.16667 0.41667 0.09227 0.00100 0.39866 -0.54216 0.24148 0.41826
+97 0.25000 0.33333 0.07009 0.00100 0.45008 -0.50072 0.00000 0.43301
+98 0.16667 0.33333 0.14840 0.00100 0.37604 -0.66637 0.21651 0.37500
+86 0.25000 0.25000 0.10926 0.00100 0.40081 -0.59156 0.00000 0.35355
+87 0.16667 0.25000 0.18125 0.00100 0.34374 -0.70421 0.17678 0.30619
+75 0.25000 0.16667 0.14481 0.00100 0.34608 -0.63293 0.00000 0.25000
+76 0.16667 0.16667 0.19643 0.00100 0.30813 -0.69579 0.12500 0.21651
+75 0.25000 0.16667 0.14481 0.00100 0.34608 -0.63293 0.00000 0.25000
+17 0.25000 0.08333 0.17478 0.00100 0.29109 -0.63431 0.00000 0.12941
+15 0.33333 0.08333 0.15726 0.00100 0.29335 -0.59942 -0.06470 0.11207
+18 0.29167 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+37 0.33333 0.91667 0.11731 0.99900 0.26926 0.44859 -0.06470 0.11207
+38 0.29167 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+37 0.33333 0.91667 0.11731 0.99900 0.26926 0.44859 -0.06470 0.11207
+39 0.25000 0.91667 0.13138 0.99900 0.26321 0.48188 0.00000 0.12941
+162 0.33333 0.83333 0.07414 0.99900 0.32883 0.39669 -0.12500 0.21651
+163 0.25000 0.83333 0.09337 0.99900 0.32380 0.46306 0.00000 0.25000
+151 0.33333 0.75000 0.03873 0.99900 0.38213 0.30552 -0.17678 0.30619
+152 0.25000 0.75000 0.05350 0.99900 0.38666 0.38881 0.00000 0.35355
+140 0.33333 0.66667 0.01433 0.96962 0.42405 0.18283 -0.21651 0.37500
+141 0.25000 0.66667 0.01921 0.99900 0.44417 0.25077 0.00000 0.43301
+129 0.33333 0.58333 0.00283 0.67965 0.45074 0.03994 -0.24148 0.41826
+130 0.25000 0.58333 0.00104 0.70147 0.48527 0.05732 0.00000 0.48296
+118 0.33333 0.50000 0.00464 0.37108 0.46020 -0.11023 -0.25000 0.43301
+119 0.25000 0.50000 0.00634 0.30861 0.50000 -0.15875 0.00000 0.50000
+107 0.33333 0.41667 0.01889 0.06946 0.45233 -0.25504 -0.24148 0.41826
+108 0.25000 0.41667 0.03263 0.00100 0.48620 -0.35427 0.00000 0.48296
+96 0.33333 0.33333 0.04378 0.00100 0.42865 -0.38353 -0.21651 0.37500
+97 0.25000 0.33333 0.07009 0.00100 0.45008 -0.50072 0.00000 0.43301
+85 0.33333 0.25000 0.07694 0.00100 0.39190 -0.48717 -0.17678 0.30619
+86 0.25000 0.25000 0.10926 0.00100 0.40081 -0.59156 0.00000 0.35355
+74 0.33333 0.16667 0.11569 0.00100 0.34553 -0.56015 -0.12500 0.21651
+75 0.25000 0.16667 0.14481 0.00100 0.34608 -0.63293 0.00000 0.25000
+74 0.33333 0.16667 0.11569 0.00100 0.34553 -0.56015 -0.12500 0.21651
+15 0.33333 0.08333 0.15726 0.00100 0.29335 -0.59942 -0.06470 0.11207
+13 0.41667 0.08333 0.15134 0.00100 0.28069 -0.56690 -0.11207 0.06470
+16 0.37500 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+35 0.41667 0.91667 0.11568 0.99900 0.25826 0.41884 -0.11207 0.06470
+36 0.37500 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+35 0.41667 0.91667 0.11568 0.99900 0.25826 0.41884 -0.11207 0.06470
+37 0.33333 0.91667 0.11731 0.99900 0.26926 0.44859 -0.06470 0.11207
+161 0.41667 0.83333 0.07575 0.99900 0.30096 0.34871 -0.21651 0.12500
+162 0.33333 0.83333 0.07414 0.99900 0.32883 0.39669 -0.12500 0.21651
+150 0.41667 0.75000 0.04562 0.99900 0.33524 0.25608 -0.30619 0.17678
+151 0.33333 0.75000 0.03873 0.99900 0.38213 0.30552 -0.17678 0.30619
+139 0.41667 0.66667 0.02569 0.92724 0.36024 0.14834 -0.37500 0.21651
+140 0.33333 0.66667 0.01433 0.96962 0.42405 0.18283 -0.21651 0.37500
+128 0.41667 0.58333 0.01596 0.67063 0.37568 0.03187 -0.41826 0.24148
+129 0.33333 0.58333 0.00283 0.67965 0.45074 0.03994 -0.24148 0.41826
+117 0.41667 0.50000 0.01621 0.39994 0.38162 -0.08785 -0.43301 0.25000
+118 0.33333 0.50000 0.00464 0.37108 0.46020 -0.11023 -0.25000 0.43301
+106 0.41667 0.41667 0.02609 0.13144 0.37828 -0.20590 -0.41826 0.24148
+107 0.33333 0.41667 0.01889 0.06946 0.45233 -0.25504 -0.24148 0.41826
+95 0.41667 0.33333 0.04522 0.00100 0.36600 -0.31762 -0.37500 0.21651
+96 0.33333 0.33333 0.04378 0.00100 0.42865 -0.38353 -0.21651 0.37500
+84 0.41667 0.25000 0.07305 0.00100 0.34519 -0.41833 -0.30619 0.17678
+85 0.33333 0.25000 0.07694 0.00100 0.39190 -0.48717 -0.17678 0.30619
+73 0.41667 0.16667 0.10881 0.00100 0.31647 -0.50313 -0.21651 0.12500
+74 0.33333 0.16667 0.11569 0.00100 0.34553 -0.56015 -0.12500 0.21651
+73 0.41667 0.16667 0.10881 0.00100 0.31647 -0.50313 -0.21651 0.12500
+13 0.41667 0.08333 0.15134 0.00100 0.28069 -0.56690 -0.11207 0.06470
+11 0.50000 0.08333 0.15695 0.00100 0.25836 -0.54379 -0.12941 0.00000
+14 0.45833 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+33 0.50000 0.91667 0.12506 0.99900 0.23590 0.39836 -0.12941 0.00000
+34 0.45833 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+33 0.50000 0.91667 0.12506 0.99900 0.23590 0.39836 -0.12941 0.00000
+35 0.41667 0.91667 0.11568 0.99900 0.25826 0.41884 -0.11207 0.06470
+160 0.50000 0.83333 0.09377 0.99900 0.25637 0.32013 -0.25000 0.00000
+161 0.41667 0.83333 0.07575 0.99900 0.30096 0.34871 -0.21651 0.12500
+149 0.50000 0.75000 0.07035 0.99900 0.27148 0.22961 -0.35355 0.00000
+150 0.41667 0.75000 0.04562 0.99900 0.33524 0.25608 -0.30619 0.17678
+138 0.50000 0.66667 0.05477 0.90616 0.28211 0.13113 -0.43301 0.00000
+139 0.41667 0.66667 0.02569 0.92724 0.36024 0.14834 -0.37500 0.21651
+127 0.50000 0.58333 0.04697 0.66642 0.28889 0.02798 -0.48296 0.00000
+128 0.41667 0.58333 0.01596 0.67063 0.37568 0.03187 -0.41826 0.24148
+116 0.50000 0.50000 0.04685 0.41393 0.29223 -0.07709 -0.50000 0.00000
+117 0.41667 0.50000 0.01621 0.39994 0.38162 -0.08785 -0.43301 0.25000
+105 0.50000 0.41667 0.05433 0.16212 0.29232 -0.18164 -0.48296 0.00000
+106 0.41667 0.41667 0.02609 0.13144 0.37828 -0.20590 -0.41826 0.24148
+94 0.50000 0.33333 0.06929 0.00100 0.28922 -0.28327 -0.43301 0.00000
+95 0.41667 0.33333 0.04522 0.00100 0.36600 -0.31762 -0.37500 0.21651
+83 0.50000 0.25000 0.09157 0.00100 0.28277 -0.37947 -0.35355 0.00000
+84 0.41667 0.25000 0.07305 0.00100 0.34519 -0.41833 -0.30619 0.17678
+72 0.50000 0.16667 0.12093 0.00100 0.27266 -0.46743 -0.25000 0.00000
+73 0.41667 0.16667 0.10881 0.00100 0.31647 -0.50313 -0.21651 0.12500
+72 0.50000 0.16667 0.12093 0.00100 0.27266 -0.46743 -0.25000 0.00000
+11 0.50000 0.08333 0.15695 0.00100 0.25836 -0.54379 -0.12941 0.00000
+9 0.58333 0.08333 0.17221 0.00100 0.23253 -0.53297 -0.11207 -0.06470
+12 0.54167 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+31 0.58333 0.91667 0.14311 0.99900 0.20878 0.38894 -0.11207 -0.06470
+32 0.54167 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+31 0.58333 0.91667 0.14311 0.99900 0.20878 0.38894 -0.11207 -0.06470
+33 0.50000 0.91667 0.12506 0.99900 0.23590 0.39836 -0.12941 0.00000
+159 0.58333 0.83333 0.12527 0.99900 0.20699 0.30801 -0.21651 -0.12500
+160 0.50000 0.83333 0.09377 0.99900 0.25637 0.32013 -0.25000 0.00000
+148 0.58333 0.75000 0.11143 0.99900 0.20500 0.21899 -0.30619 -0.17678
+149 0.50000 0.75000 0.07035 0.99900 0.27148 0.22961 -0.35355 0.00000
+137 0.58333 0.66667 0.10210 0.89651 0.20368 0.12444 -0.37500 -0.21651
+138 0.50000 0.66667 0.05477 0.90616 0.28211 0.13113 -0.43301 0.00000
+126 0.58333 0.58333 0.09758 0.66389 0.20355 0.02650 -0.41826 -0.24148
+127 0.50000 0.58333 0.04697 0.66642 0.28889 0.02798 -0.48296 0.00000
+115 0.58333 0.50000 0.09802 0.41933 0.20491 -0.07299 -0.43301 -0.25000
+116 0.50000 0.50000 0.04685 0.41393 0.29223 -0.07709 -0.50000 0.00000
+104 0.58333 0.41667 0.10346 0.17498 0.20788 -0.17229 -0.41826 -0.24148
+105 0.50000 0.41667 0.05433 0.16212 0.29232 -0.18164 -0.48296 0.00000
+93 0.58333 0.33333 0.11385 0.00100 0.21242 -0.26969 -0.37500 -0.21651
+94 0.50000 0.33333 0.06929 0.00100 0.28922 -0.28327 -0.43301 0.00000
+82 0.58333 0.25000 0.12901 0.00100 0.21834 -0.36350 -0.30619 -0.17678
+83 0.50000 0.25000 0.09157 0.00100 0.28277 -0.37947 -0.35355 0.00000
+71 0.58333 0.16667 0.14863 0.00100 0.22526 -0.45191 -0.21651 -0.12500
+72 0.50000 0.16667 0.12093 0.00100 0.27266 -0.46743 -0.25000 0.00000
+71 0.58333 0.16667 0.14863 0.00100 0.22526 -0.45191 -0.21651 -0.12500
+9 0.58333 0.08333 0.17221 0.00100 0.23253 -0.53297 -0.11207 -0.06470
+7 0.66667 0.08333 0.19399 0.00100 0.20888 -0.53519 -0.06470 -0.11207
+10 0.62500 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+29 0.66667 0.91667 0.16656 0.99900 0.18279 0.39086 -0.06470 -0.11207
+30 0.62500 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+29 0.66667 0.91667 0.16656 0.99900 0.18279 0.39086 -0.06470 -0.11207
+31 0.58333 0.91667 0.14311 0.99900 0.20878 0.38894 -0.11207 -0.06470
+158 0.66667 0.83333 0.16659 0.99900 0.16130 0.31057 -0.12500 -0.21651
+159 0.58333 0.83333 0.12527 0.99900 0.20699 0.30801 -0.21651 -0.12500
+147 0.66667 0.75000 0.16588 0.99900 0.14487 0.22131 -0.17678 -0.30619
+148 0.58333 0.75000 0.11143 0.99900 0.20500 0.21899 -0.30619 -0.17678
+136 0.66667 0.66667 0.16546 0.89633 0.13378 0.12594 -0.21651 -0.37500
+137 0.58333 0.66667 0.10210 0.89651 0.20368 0.12444 -0.37500 -0.21651
+125 0.66667 0.58333 0.16597 0.66293 0.12819 0.02683 -0.24148 -0.41826
+126 0.58333 0.58333 0.09758 0.66389 0.20355 0.02650 -0.41826 -0.24148
+114 0.66667 0.50000 0.16776 0.41811 0.12818 -0.07393 -0.25000 -0.43301
+115 0.58333 0.50000 0.09802 0.41933 0.20491 -0.07299 -0.43301 -0.25000
+103 0.66667 0.41667 0.17097 0.17362 0.13376 -0.17442 -0.24148 -0.41826
+104 0.58333 0.41667 0.10346 0.17498 0.20788 -0.17229 -0.41826 -0.24148
+92 0.66667 0.33333 0.17556 0.00100 0.14484 -0.27274 -0.21651 -0.37500
+93 0.58333 0.33333 0.11385 0.00100 0.21242 -0.26969 -0.37500 -0.21651
+81 0.66667 0.25000 0.18129 0.00100 0.16125 -0.36700 -0.17678 -0.30619
+82 0.58333 0.25000 0.12901 0.00100 0.21834 -0.36350 -0.30619 -0.17678
+70 0.66667 0.16667 0.18769 0.00100 0.18273 -0.45521 -0.12500 -0.21651
+71 0.58333 0.16667 0.14863 0.00100 0.22526 -0.45191 -0.21651 -0.12500
+70 0.66667 0.16667 0.18769 0.00100 0.18273 -0.45521 -0.12500 -0.21651
+7 0.66667 0.08333 0.19399 0.00100 0.20888 -0.53519 -0.06470 -0.11207
+5 0.75000 0.08333 0.21789 0.00100 0.19222 -0.55023 0.00000 -0.12941
+8 0.70833 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+27 0.75000 0.91667 0.19095 0.99900 0.16283 0.40401 0.00000 -0.12941
+28 0.70833 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+27 0.75000 0.91667 0.19095 0.99900 0.16283 0.40401 0.00000 -0.12941
+29 0.66667 0.91667 0.16656 0.99900 0.18279 0.39086 -0.06470 -0.11207
+157 0.75000 0.83333 0.21201 0.99900 0.12561 0.32796 0.00000 -0.25000
+158 0.66667 0.83333 0.16659 0.99900 0.16130 0.31057 -0.12500 -0.21651
+146 0.75000 0.75000 0.22797 0.99900 0.09754 0.23688 0.00000 -0.35355
+147 0.66667 0.75000 0.16588 0.99900 0.14487 0.22131 -0.17678 -0.30619
+135 0.75000 0.66667 0.23948 0.90806 0.07868 0.13588 0.00000 -0.43301
+136 0.66667 0.66667 0.16546 0.89633 0.13378 0.12594 -0.21651 -0.37500
+124 0.75000 0.58333 0.24702 0.66503 0.06897 0.02906 0.00000 -0.48296
+125 0.66667 0.58333 0.16597 0.66293 0.12819 0.02683 -0.24148 -0.41826
+113 0.75000 0.50000 0.25094 0.41006 0.06830 -0.08009 0.00000 -0.50000
+114 0.66667 0.50000 0.16776 0.41811 0.12818 -0.07393 -0.25000 -0.43301
+102 0.75000 0.41667 0.25144 0.15617 0.07651 -0.18841 0.00000 -0.48296
+103 0.66667 0.41667 0.17097 0.17362 0.13376 -0.17442 -0.24148 -0.41826
+91 0.75000 0.33333 0.24857 0.00100 0.09338 -0.29285 0.00000 -0.43301
+92 0.66667 0.33333 0.17556 0.00100 0.14484 -0.27274 -0.21651 -0.37500
+80 0.75000 0.25000 0.24221 0.00100 0.11860 -0.39028 0.00000 -0.35355
+81 0.66667 0.25000 0.18129 0.00100 0.16125 -0.36700 -0.17678 -0.30619
+69 0.75000 0.16667 0.23212 0.00100 0.15175 -0.47734 0.00000 -0.25000
+70 0.66667 0.16667 0.18769 0.00100 0.18273 -0.45521 -0.12500 -0.21651
+69 0.75000 0.16667 0.23212 0.00100 0.15175 -0.47734 0.00000 -0.25000
+5 0.75000 0.08333 0.21789 0.00100 0.19222 -0.55023 0.00000 -0.12941
+3 0.83333 0.08333 0.23838 0.00100 0.18630 -0.57670 0.06470 -0.11207
+6 0.79167 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+25 0.83333 0.91667 0.21053 0.99900 0.15290 0.42768 0.06470 -0.11207
+26 0.79167 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+25 0.83333 0.91667 0.21053 0.99900 0.15290 0.42768 0.06470 -0.11207
+27 0.75000 0.91667 0.19095 0.99900 0.16283 0.40401 0.00000 -0.12941
+156 0.83333 0.83333 0.25271 0.99900 0.10497 0.36222 0.12500 -0.21651
+157 0.75000 0.83333 0.21201 0.99900 0.12561 0.32796 0.00000 -0.25000
+145 0.83333 0.75000 0.28799 0.99900 0.06767 0.26941 0.17678 -0.30619
+146 0.75000 0.75000 0.22797 0.99900 0.09754 0.23688 0.00000 -0.35355
+134 0.83333 0.66667 0.31457 0.93678 0.04237 0.15738 0.21651 -0.37500
+135 0.75000 0.66667 0.23948 0.90806 0.07868 0.13588 0.00000 -0.43301
+123 0.83333 0.58333 0.33150 0.67193 0.02955 0.03395 0.24148 -0.41826
+124 0.75000 0.58333 0.24702 0.66503 0.06897 0.02906 0.00000 -0.48296
+112 0.83333 0.50000 0.33844 0.39249 0.02914 -0.09363 0.25000 -0.43301
+113 0.75000 0.50000 0.25094 0.41006 0.06830 -0.08009 0.00000 -0.50000
+101 0.83333 0.41667 0.33549 0.11627 0.04068 -0.21875 0.24148 -0.41826
+102 0.75000 0.41667 0.25144 0.15617 0.07651 -0.18841 0.00000 -0.48296
+90 0.83333 0.33333 0.32310 0.00100 0.06342 -0.33527 0.21651 -0.37500
+91 0.75000 0.33333 0.24857 0.00100 0.09338 -0.29285 0.00000 -0.43301
+79 0.83333 0.25000 0.30202 0.00100 0.09629 -0.43738 0.17678 -0.30619
+80 0.75000 0.25000 0.24221 0.00100 0.11860 -0.39028 0.00000 -0.35355
+68 0.83333 0.16667 0.27332 0.00100 0.13788 -0.51956 0.12500 -0.21651
+69 0.75000 0.16667 0.23212 0.00100 0.15175 -0.47734 0.00000 -0.25000
+68 0.83333 0.16667 0.27332 0.00100 0.13788 -0.51956 0.12500 -0.21651
+3 0.83333 0.08333 0.23838 0.00100 0.18630 -0.57670 0.06470 -0.11207
+0 0.91667 0.08333 0.24936 0.00100 0.19351 -0.61071 0.11207 -0.06470
+4 0.87500 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 26
+23 0.91667 0.91667 0.21882 0.99900 0.15617 0.45920 0.11207 -0.06470
+24 0.87500 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+23 0.91667 0.91667 0.21882 0.99900 0.15617 0.45920 0.11207 -0.06470
+25 0.83333 0.91667 0.21053 0.99900 0.15290 0.42768 0.06470 -0.11207
+154 0.91667 0.83333 0.27563 0.99900 0.10447 0.41577 0.21651 -0.12500
+156 0.83333 0.83333 0.25271 0.99900 0.10497 0.36222 0.12500 -0.21651
+143 0.91667 0.75000 0.32918 0.99900 0.05945 0.32703 0.30619 -0.17678
+145 0.83333 0.75000 0.28799 0.99900 0.06767 0.26941 0.17678 -0.30619
+132 0.91667 0.66667 0.37332 0.99232 0.02664 0.19879 0.37500 -0.21651
+134 0.83333 0.66667 0.31457 0.93678 0.04237 0.15738 0.21651 -0.37500
+121 0.91667 0.58333 0.40266 0.68601 0.01006 0.04379 0.41826 -0.24148
+123 0.83333 0.58333 0.33150 0.67193 0.02955 0.03395 0.24148 -0.41826
+110 0.91667 0.50000 0.41387 0.35730 0.01120 -0.12091 0.43301 -0.25000
+112 0.83333 0.50000 0.33844 0.39249 0.02914 -0.09363 0.25000 -0.43301
+99 0.91667 0.41667 0.40641 0.03864 0.02889 -0.27785 0.41826 -0.24148
+101 0.83333 0.41667 0.33549 0.11627 0.04068 -0.21875 0.24148 -0.41826
+88 0.91667 0.33333 0.38226 0.00100 0.06003 -0.41261 0.37500 -0.21651
+90 0.83333 0.33333 0.32310 0.00100 0.06342 -0.33527 0.21651 -0.37500
+77 0.91667 0.25000 0.34511 0.00100 0.10054 -0.51553 0.30619 -0.17678
+79 0.83333 0.25000 0.30202 0.00100 0.09629 -0.43738 0.17678 -0.30619
+66 0.91667 0.16667 0.29935 0.00100 0.14628 -0.58181 0.21651 -0.12500
+68 0.83333 0.16667 0.27332 0.00100 0.13788 -0.51956 0.12500 -0.21651
+66 0.91667 0.16667 0.29935 0.00100 0.14628 -0.58181 0.21651 -0.12500
+0 0.91667 0.08333 0.24936 0.00100 0.19351 -0.61071 0.11207 -0.06470
+2 1.00000 0.08333 0.24596 0.00100 0.21392 -0.64381 0.12941 0.00000
+1 0.95833 0.00000 0.19898 0.00100 0.23912 -0.60440 0.00000 0.00000
+SURF 0x14
+mat 0
+refs 23
+66 0.91667 0.16667 0.29935 0.00100 0.14628 -0.58181 0.21651 -0.12500
+2 1.00000 0.08333 0.24596 0.00100 0.21392 -0.64381 0.12941 0.00000
+66 0.91667 0.16667 0.29935 0.00100 0.14628 -0.58181 0.21651 -0.12500
+67 1.00000 0.16667 0.29617 0.00100 0.18165 -0.65455 0.25000 0.00000
+77 0.91667 0.25000 0.34511 0.00100 0.10054 -0.51553 0.30619 -0.17678
+78 1.00000 0.25000 0.34675 0.00100 0.14154 -0.62617 0.35355 0.00000
+88 0.91667 0.33333 0.38226 0.00100 0.06003 -0.41261 0.37500 -0.21651
+89 1.00000 0.33333 0.39286 0.00100 0.09463 -0.54477 0.43301 0.00000
+99 0.91667 0.41667 0.40641 0.03864 0.02889 -0.27785 0.41826 -0.24148
+100 1.00000 0.41667 0.42672 0.00100 0.04684 -0.39635 0.48296 0.00000
+110 0.91667 0.50000 0.41387 0.35730 0.01120 -0.12091 0.43301 -0.25000
+111 1.00000 0.50000 0.43819 0.27990 0.01216 -0.18101 0.50000 0.00000
+121 0.91667 0.58333 0.40266 0.68601 0.01006 0.04379 0.41826 -0.24148
+122 1.00000 0.58333 0.42036 0.71453 0.00746 0.06528 0.48296 0.00000
+132 0.91667 0.66667 0.37332 0.99232 0.02664 0.19879 0.37500 -0.21651
+133 1.00000 0.66667 0.37732 0.99900 0.03584 0.27934 0.43301 0.00000
+143 0.91667 0.75000 0.32918 0.99900 0.05945 0.32703 0.30619 -0.17678
+144 1.00000 0.75000 0.32156 0.99900 0.08264 0.41936 0.35355 0.00000
+154 0.91667 0.83333 0.27563 0.99900 0.10447 0.41577 0.21651 -0.12500
+155 1.00000 0.83333 0.26409 0.99900 0.13155 0.48413 0.25000 0.00000
+23 0.91667 0.91667 0.21882 0.99900 0.15617 0.45920 0.11207 -0.06470
+21 1.00000 0.91667 0.21082 0.99900 0.17434 0.49121 0.12941 0.00000
+22 0.95833 1.00000 0.16417 0.99900 0.20895 0.45830 0.00000 0.00000
+kids 0
diff --git a/test/models/IRR/EpisodeII_TheDwarfesStrikeBack.irr b/test/models/IRR/EpisodeII_TheDwarfesStrikeBack.irr
index a317ac61e..761ea0ad4 100644
--- a/test/models/IRR/EpisodeII_TheDwarfesStrikeBack.irr
+++ b/test/models/IRR/EpisodeII_TheDwarfesStrikeBack.irr
@@ -32,7 +32,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="textures/editor_defaults/default_texture.png" />
+ <texture name="Texture1" value="assets/default_texture.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -89,7 +89,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="skybox/default_skybox2.jpg" />
+ <texture name="Texture1" value="assets/skybox/default_skybox2.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -128,7 +128,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="skybox/default_skybox1.jpg" />
+ <texture name="Texture1" value="assets/skybox/default_skybox1.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -167,7 +167,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="skybox/default_skybox0.jpg" />
+ <texture name="Texture1" value="assets/skybox/default_skybox0.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -206,7 +206,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="skybox/default_skybox3.jpg" />
+ <texture name="Texture1" value="assets/skybox/default_skybox3.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -245,7 +245,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="skybox/default_skyboxup.jpg" />
+ <texture name="Texture1" value="assets/skybox/default_skyboxup.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -284,7 +284,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="skybox/default_skyboxdn.jpg" />
+ <texture name="Texture1" value="assets/skybox/default_skyboxdn.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -329,7 +329,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="Looping" value="true" />
<bool name="ReadOnlyMaterials" value="false" />
<float name="FramesPerSecond" value="0.250000" />
@@ -345,7 +345,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -384,7 +384,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -468,7 +468,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="Looping" value="true" />
<bool name="ReadOnlyMaterials" value="false" />
<float name="FramesPerSecond" value="0.250000" />
@@ -484,7 +484,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -523,7 +523,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -620,7 +620,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="textures/editor_defaults/default_texture.png" />
+ <texture name="Texture1" value="assets/default_texture.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -678,7 +678,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="textures/editor_defaults/default_texture.png" />
+ <texture name="Texture1" value="assets/default_texture.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -723,7 +723,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="Looping" value="true" />
<bool name="ReadOnlyMaterials" value="false" />
<float name="FramesPerSecond" value="0.250000" />
@@ -739,7 +739,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -778,7 +778,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -875,7 +875,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="textures/editor_defaults/default_texture.png" />
+ <texture name="Texture1" value="assets/default_texture.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -920,7 +920,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="Looping" value="true" />
<bool name="ReadOnlyMaterials" value="false" />
<float name="FramesPerSecond" value="0.250000" />
@@ -936,7 +936,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -975,7 +975,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/EpisodeII_TheDwarfesStrikeBack_UTF16LE.irr b/test/models/IRR/EpisodeII_TheDwarfesStrikeBack_UTF16LE.irr
index 9321cf93f..d109c67cc 100644
--- a/test/models/IRR/EpisodeII_TheDwarfesStrikeBack_UTF16LE.irr
+++ b/test/models/IRR/EpisodeII_TheDwarfesStrikeBack_UTF16LE.irr
Binary files differ
diff --git a/test/models/IRR/EpisodeI_ANewDwarf.irr b/test/models/IRR/EpisodeI_ANewDwarf.irr
index 65f65ad4b..c84073553 100644
--- a/test/models/IRR/EpisodeI_ANewDwarf.irr
+++ b/test/models/IRR/EpisodeI_ANewDwarf.irr
@@ -33,8 +33,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="brownground_1-1.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/brownground_1-1.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -72,8 +72,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="crackedground_1-6.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/crackedground_1-6.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -117,7 +117,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -131,7 +131,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -170,7 +170,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -254,7 +254,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -268,7 +268,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -307,7 +307,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -391,7 +391,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -405,7 +405,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -444,7 +444,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -528,7 +528,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -542,7 +542,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -581,7 +581,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -665,7 +665,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -679,7 +679,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -718,7 +718,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/EpisodeI_ANewDwarf_UTF16LE.irr b/test/models/IRR/EpisodeI_ANewDwarf_UTF16LE.irr
index 5e5a68f2d..551a5ac9a 100644
--- a/test/models/IRR/EpisodeI_ANewDwarf_UTF16LE.irr
+++ b/test/models/IRR/EpisodeI_ANewDwarf_UTF16LE.irr
Binary files differ
diff --git a/test/models/IRR/animMesh.irr b/test/models/IRR/animMesh.irr
index 0e246bacf..5cd109d77 100644
--- a/test/models/IRR/animMesh.irr
+++ b/test/models/IRR/animMesh.irr
@@ -19,7 +19,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="Looping" value="true" />
<bool name="ReadOnlyMaterials" value="false" />
<float name="FramesPerSecond" value="0.025000" />
@@ -35,7 +35,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -73,7 +73,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/animMesh_UTF16LE.irr b/test/models/IRR/animMesh_UTF16LE.irr
index c041565ea..70f6374fa 100644
--- a/test/models/IRR/animMesh_UTF16LE.irr
+++ b/test/models/IRR/animMesh_UTF16LE.irr
Binary files differ
diff --git a/test/models/IRR/1.png b/test/models/IRR/assets/1.png
index e7200658b..e7200658b 100644
--- a/test/models/IRR/1.png
+++ b/test/models/IRR/assets/1.png
Binary files differ
diff --git a/test/models/IRR/SpiderTex.jpg b/test/models/IRR/assets/SpiderTex.jpg
index 397e68434..397e68434 100644
--- a/test/models/IRR/SpiderTex.jpg
+++ b/test/models/IRR/assets/SpiderTex.jpg
Binary files differ
diff --git a/test/models/IRR/UVTransformTestImg.png b/test/models/IRR/assets/UVTransformTestImg.png
index b8f6f54f1..b8f6f54f1 100644
--- a/test/models/IRR/UVTransformTestImg.png
+++ b/test/models/IRR/assets/UVTransformTestImg.png
Binary files differ
diff --git a/test/models/IRR/axe.jpg b/test/models/IRR/assets/axe.jpg
index ba14ae0ea..ba14ae0ea 100644
--- a/test/models/IRR/axe.jpg
+++ b/test/models/IRR/assets/axe.jpg
Binary files differ
diff --git a/test/models/IRR/brownground_1-1.jpg b/test/models/IRR/assets/brownground_1-1.jpg
index fda7d45c6..fda7d45c6 100644
--- a/test/models/IRR/brownground_1-1.jpg
+++ b/test/models/IRR/assets/brownground_1-1.jpg
Binary files differ
diff --git a/test/models/IRR/crackedground_1-6.jpg b/test/models/IRR/assets/crackedground_1-6.jpg
index 48da577fd..48da577fd 100644
--- a/test/models/IRR/crackedground_1-6.jpg
+++ b/test/models/IRR/assets/crackedground_1-6.jpg
Binary files differ
diff --git a/test/models/IRR/assets/default.png b/test/models/IRR/assets/default.png
new file mode 100644
index 000000000..fe9926e41
--- /dev/null
+++ b/test/models/IRR/assets/default.png
Binary files differ
diff --git a/test/models/IRR/assets/default_texture.png b/test/models/IRR/assets/default_texture.png
new file mode 100644
index 000000000..a1ad5979b
--- /dev/null
+++ b/test/models/IRR/assets/default_texture.png
Binary files differ
diff --git a/test/models/IRR/drkwood2.jpg b/test/models/IRR/assets/drkwood2.jpg
index 7ca470306..7ca470306 100644
--- a/test/models/IRR/drkwood2.jpg
+++ b/test/models/IRR/assets/drkwood2.jpg
Binary files differ
diff --git a/test/models/IRR/dwarf.jpg b/test/models/IRR/assets/dwarf.jpg
index 9c07e0038..9c07e0038 100644
--- a/test/models/IRR/dwarf.jpg
+++ b/test/models/IRR/assets/dwarf.jpg
Binary files differ
diff --git a/test/models/IRR/dwarf.x b/test/models/IRR/assets/dwarf.x
index 0fb7be0d2..0fb7be0d2 100644
--- a/test/models/IRR/dwarf.x
+++ b/test/models/IRR/assets/dwarf.x
diff --git a/test/models/IRR/earthSpherical.jpg b/test/models/IRR/assets/earthSpherical.jpg
index 3419e8071..3419e8071 100644
--- a/test/models/IRR/earthSpherical.jpg
+++ b/test/models/IRR/assets/earthSpherical.jpg
Binary files differ
diff --git a/test/models/IRR/engineflare1.jpg b/test/models/IRR/assets/engineflare1.jpg
index 072619113..072619113 100644
--- a/test/models/IRR/engineflare1.jpg
+++ b/test/models/IRR/assets/engineflare1.jpg
Binary files differ
diff --git a/test/models/IRR/assets/skybox/credits.txt b/test/models/IRR/assets/skybox/credits.txt
new file mode 100644
index 000000000..b2b601392
--- /dev/null
+++ b/test/models/IRR/assets/skybox/credits.txt
@@ -0,0 +1,11 @@
+This skybox is basing on a skydome texture from
+
+http://mikepan.homeip.net/earth
+
+Downloaded November 22th, 08
+Distribution note:
+"These royalty-free skydome textures work best when applied to a sphere or hemisphere"
+
+
+
+Thanks for your great work!
diff --git a/test/models/IRR/assets/skybox/default_skybox0.jpg b/test/models/IRR/assets/skybox/default_skybox0.jpg
new file mode 100644
index 000000000..0fe4d0890
--- /dev/null
+++ b/test/models/IRR/assets/skybox/default_skybox0.jpg
Binary files differ
diff --git a/test/models/IRR/assets/skybox/default_skybox1.jpg b/test/models/IRR/assets/skybox/default_skybox1.jpg
new file mode 100644
index 000000000..c4c286bff
--- /dev/null
+++ b/test/models/IRR/assets/skybox/default_skybox1.jpg
Binary files differ
diff --git a/test/models/IRR/assets/skybox/default_skybox2.jpg b/test/models/IRR/assets/skybox/default_skybox2.jpg
new file mode 100644
index 000000000..935f72579
--- /dev/null
+++ b/test/models/IRR/assets/skybox/default_skybox2.jpg
Binary files differ
diff --git a/test/models/IRR/assets/skybox/default_skybox3.jpg b/test/models/IRR/assets/skybox/default_skybox3.jpg
new file mode 100644
index 000000000..e8107ff99
--- /dev/null
+++ b/test/models/IRR/assets/skybox/default_skybox3.jpg
Binary files differ
diff --git a/test/models/IRR/assets/skybox/default_skyboxdn.jpg b/test/models/IRR/assets/skybox/default_skyboxdn.jpg
new file mode 100644
index 000000000..af66a6176
--- /dev/null
+++ b/test/models/IRR/assets/skybox/default_skyboxdn.jpg
Binary files differ
diff --git a/test/models/IRR/assets/skybox/default_skyboxup.jpg b/test/models/IRR/assets/skybox/default_skyboxup.jpg
new file mode 100644
index 000000000..7959709fa
--- /dev/null
+++ b/test/models/IRR/assets/skybox/default_skyboxup.jpg
Binary files differ
diff --git a/test/models/IRR/spider.mtl b/test/models/IRR/assets/spider.mtl
index d225a7c62..d225a7c62 100644
--- a/test/models/IRR/spider.mtl
+++ b/test/models/IRR/assets/spider.mtl
diff --git a/test/models/IRR/wal67ar_small.jpg b/test/models/IRR/assets/wal67ar_small.jpg
index b07716bc0..b07716bc0 100644
--- a/test/models/IRR/wal67ar_small.jpg
+++ b/test/models/IRR/assets/wal67ar_small.jpg
Binary files differ
diff --git a/test/models/IRR/wal69ar_small.jpg b/test/models/IRR/assets/wal69ar_small.jpg
index b4723f9e3..b4723f9e3 100644
--- a/test/models/IRR/wal69ar_small.jpg
+++ b/test/models/IRR/assets/wal69ar_small.jpg
Binary files differ
diff --git a/test/models/IRR/box.irr b/test/models/IRR/box.irr
index 8a094ded6..2af68ab44 100644
--- a/test/models/IRR/box.irr
+++ b/test/models/IRR/box.irr
@@ -32,7 +32,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="default.png" />
+ <texture name="Texture1" value="assets/default.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/box_UTF16LE.irr b/test/models/IRR/box_UTF16LE.irr
index efc165d93..655517195 100644
--- a/test/models/IRR/box_UTF16LE.irr
+++ b/test/models/IRR/box_UTF16LE.irr
Binary files differ
diff --git a/test/models/IRR/cellar.irrmesh b/test/models/IRR/cellar.irrmesh
index 0278c9239..ee787463a 100644
--- a/test/models/IRR/cellar.irrmesh
+++ b/test/models/IRR/cellar.irrmesh
@@ -13,8 +13,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="brownground_1-1.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/brownground_1-1.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -870,8 +870,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="crackedground_1-6.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/crackedground_1-6.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
diff --git a/test/models/IRR/dawfInCellar_ChildOfCellar.irr b/test/models/IRR/dawfInCellar_ChildOfCellar.irr
index b9fa20c6a..0b57fc158 100644
--- a/test/models/IRR/dawfInCellar_ChildOfCellar.irr
+++ b/test/models/IRR/dawfInCellar_ChildOfCellar.irr
@@ -33,8 +33,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="brownground_1-1.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/brownground_1-1.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -71,8 +71,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="crackedground_1-6.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/crackedground_1-6.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -113,7 +113,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -127,7 +127,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -165,7 +165,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/dawfInCellar_ChildOfCellar_UTF16LE.irr b/test/models/IRR/dawfInCellar_ChildOfCellar_UTF16LE.irr
index aba42e94d..cd7ba9752 100644
--- a/test/models/IRR/dawfInCellar_ChildOfCellar_UTF16LE.irr
+++ b/test/models/IRR/dawfInCellar_ChildOfCellar_UTF16LE.irr
Binary files differ
diff --git a/test/models/IRR/dawfInCellar_SameHierarchy.irr b/test/models/IRR/dawfInCellar_SameHierarchy.irr
index 424b42df8..5f6d01fe5 100644
--- a/test/models/IRR/dawfInCellar_SameHierarchy.irr
+++ b/test/models/IRR/dawfInCellar_SameHierarchy.irr
@@ -33,8 +33,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="brownground_1-1.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/brownground_1-1.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -71,8 +71,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="crackedground_1-6.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/crackedground_1-6.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -115,7 +115,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -129,7 +129,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -167,7 +167,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/dawfInCellar_SameHierarchy_UTF16LE.irr b/test/models/IRR/dawfInCellar_SameHierarchy_UTF16LE.irr
index a4e7cc951..5cc3dda87 100644
--- a/test/models/IRR/dawfInCellar_SameHierarchy_UTF16LE.irr
+++ b/test/models/IRR/dawfInCellar_SameHierarchy_UTF16LE.irr
Binary files differ
diff --git a/test/models/IRR/instancing.irr b/test/models/IRR/instancing.irr
index ba0e710da..18b86f6e7 100644
--- a/test/models/IRR/instancing.irr
+++ b/test/models/IRR/instancing.irr
@@ -33,7 +33,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -71,7 +71,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -153,7 +153,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -167,7 +167,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -205,7 +205,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -287,7 +287,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -301,7 +301,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -339,7 +339,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -421,7 +421,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -435,7 +435,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -473,7 +473,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -555,7 +555,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -569,7 +569,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -607,7 +607,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -689,7 +689,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="ReadOnlyMaterials" value="false" />
</attributes>
@@ -703,7 +703,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -741,7 +741,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/scenegraphAnim.irr b/test/models/IRR/scenegraphAnim.irr
index 2300ea18f..dedc1c2cf 100644
--- a/test/models/IRR/scenegraphAnim.irr
+++ b/test/models/IRR/scenegraphAnim.irr
@@ -126,7 +126,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="UVTransformTestImg.png" />
+ <texture name="Texture1" value="assets/UVTransformTestImg.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -197,7 +197,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="Looping" value="true" />
<bool name="ReadOnlyMaterials" value="false" />
<float name="FramesPerSecond" value="0.025000" />
@@ -213,7 +213,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -251,7 +251,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -347,8 +347,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="brownground_1-1.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/brownground_1-1.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -385,8 +385,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="crackedground_1-6.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/crackedground_1-6.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -442,7 +442,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="UVTransformTestImg.png" />
+ <texture name="Texture1" value="assets/UVTransformTestImg.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -512,7 +512,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="UVTransformTestImg.png" />
+ <texture name="Texture1" value="assets/UVTransformTestImg.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/scenegraphAnimMod.irr b/test/models/IRR/scenegraphAnimMod.irr
index 21408b245..9f82efcb0 100644
--- a/test/models/IRR/scenegraphAnimMod.irr
+++ b/test/models/IRR/scenegraphAnimMod.irr
@@ -126,7 +126,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="UVTransformTestImg.png" />
+ <texture name="Texture1" value="assets/UVTransformTestImg.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -197,7 +197,7 @@
<enum name="AutomaticCulling" value="box" />
<int name="DebugDataVisible" value="0" />
<bool name="IsDebugObject" value="false" />
- <string name="Mesh" value="dwarf.x" />
+ <string name="Mesh" value="assets/dwarf.x" />
<bool name="Looping" value="true" />
<bool name="ReadOnlyMaterials" value="false" />
<float name="FramesPerSecond" value="0.025000" />
@@ -213,7 +213,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="axe.jpg" />
+ <texture name="Texture1" value="assets/axe.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -251,7 +251,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="dwarf.jpg" />
+ <texture name="Texture1" value="assets/dwarf.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -347,8 +347,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="brownground_1-1.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/brownground_1-1.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -385,8 +385,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="crackedground_1-6.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/crackedground_1-6.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -442,7 +442,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="UVTransformTestImg.png" />
+ <texture name="Texture1" value="assets/UVTransformTestImg.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -512,7 +512,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="UVTransformTestImg.png" />
+ <texture name="Texture1" value="assets/UVTransformTestImg.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/scenegraphAnimMod_UTF16LE.irr b/test/models/IRR/scenegraphAnimMod_UTF16LE.irr
index 7384ae29a..a8cab1a12 100644
--- a/test/models/IRR/scenegraphAnimMod_UTF16LE.irr
+++ b/test/models/IRR/scenegraphAnimMod_UTF16LE.irr
Binary files differ
diff --git a/test/models/IRR/scenegraphAnim_UTF16LE.irr b/test/models/IRR/scenegraphAnim_UTF16LE.irr
index f6794351f..4b6a2a6f7 100644
--- a/test/models/IRR/scenegraphAnim_UTF16LE.irr
+++ b/test/models/IRR/scenegraphAnim_UTF16LE.irr
Binary files differ
diff --git a/test/models/IRR/sphere.irr b/test/models/IRR/sphere.irr
index 1e548fee5..1b1896e2a 100644
--- a/test/models/IRR/sphere.irr
+++ b/test/models/IRR/sphere.irr
@@ -34,7 +34,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="earthSpherical.jpg" />
+ <texture name="Texture1" value="assets/earthSpherical.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRR/sphere_UTF16LE.irr b/test/models/IRR/sphere_UTF16LE.irr
index d0f99a018..7974a4c70 100644
--- a/test/models/IRR/sphere_UTF16LE.irr
+++ b/test/models/IRR/sphere_UTF16LE.irr
Binary files differ
diff --git a/test/models/IRRMesh/1.png b/test/models/IRRMesh/assets/1.png
index e7200658b..e7200658b 100644
--- a/test/models/IRRMesh/1.png
+++ b/test/models/IRRMesh/assets/1.png
Binary files differ
diff --git a/test/models/IRRMesh/SpiderTex.jpg b/test/models/IRRMesh/assets/SpiderTex.jpg
index 397e68434..397e68434 100644
--- a/test/models/IRRMesh/SpiderTex.jpg
+++ b/test/models/IRRMesh/assets/SpiderTex.jpg
Binary files differ
diff --git a/test/models/IRRMesh/assets/UVTransformTestImg.png b/test/models/IRRMesh/assets/UVTransformTestImg.png
new file mode 100644
index 000000000..b8f6f54f1
--- /dev/null
+++ b/test/models/IRRMesh/assets/UVTransformTestImg.png
Binary files differ
diff --git a/test/models/IRRMesh/assets/UVTransform_OffsetUV0.5-mirrorUV.png b/test/models/IRRMesh/assets/UVTransform_OffsetUV0.5-mirrorUV.png
new file mode 100644
index 000000000..447d30c32
--- /dev/null
+++ b/test/models/IRRMesh/assets/UVTransform_OffsetUV0.5-mirrorUV.png
Binary files differ
diff --git a/test/models/IRRMesh/assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72.png b/test/models/IRRMesh/assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72.png
new file mode 100644
index 000000000..4645a5668
--- /dev/null
+++ b/test/models/IRRMesh/assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72.png
Binary files differ
diff --git a/test/models/IRRMesh/assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.png b/test/models/IRRMesh/assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.png
new file mode 100644
index 000000000..9fdc6daab
--- /dev/null
+++ b/test/models/IRRMesh/assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.png
Binary files differ
diff --git a/test/models/IRRMesh/assets/UVTransform_ScaleUV2x_Rotate45.png b/test/models/IRRMesh/assets/UVTransform_ScaleUV2x_Rotate45.png
new file mode 100644
index 000000000..ac15908c3
--- /dev/null
+++ b/test/models/IRRMesh/assets/UVTransform_ScaleUV2x_Rotate45.png
Binary files differ
diff --git a/test/models/IRRMesh/brownground_1-1.jpg b/test/models/IRRMesh/assets/brownground_1-1.jpg
index fda7d45c6..fda7d45c6 100644
--- a/test/models/IRRMesh/brownground_1-1.jpg
+++ b/test/models/IRRMesh/assets/brownground_1-1.jpg
Binary files differ
diff --git a/test/models/IRRMesh/crackedground_1-6.jpg b/test/models/IRRMesh/assets/crackedground_1-6.jpg
index 48da577fd..48da577fd 100644
--- a/test/models/IRRMesh/crackedground_1-6.jpg
+++ b/test/models/IRRMesh/assets/crackedground_1-6.jpg
Binary files differ
diff --git a/test/models/IRRMesh/drkwood2.jpg b/test/models/IRRMesh/assets/drkwood2.jpg
index 7ca470306..7ca470306 100644
--- a/test/models/IRRMesh/drkwood2.jpg
+++ b/test/models/IRRMesh/assets/drkwood2.jpg
Binary files differ
diff --git a/test/models/IRRMesh/engineflare1.jpg b/test/models/IRRMesh/assets/engineflare1.jpg
index 072619113..072619113 100644
--- a/test/models/IRRMesh/engineflare1.jpg
+++ b/test/models/IRRMesh/assets/engineflare1.jpg
Binary files differ
diff --git a/test/models/IRRMesh/wal67ar_small.jpg b/test/models/IRRMesh/assets/wal67ar_small.jpg
index b07716bc0..b07716bc0 100644
--- a/test/models/IRRMesh/wal67ar_small.jpg
+++ b/test/models/IRRMesh/assets/wal67ar_small.jpg
Binary files differ
diff --git a/test/models/IRRMesh/wal69ar_small.jpg b/test/models/IRRMesh/assets/wal69ar_small.jpg
index b4723f9e3..b4723f9e3 100644
--- a/test/models/IRRMesh/wal69ar_small.jpg
+++ b/test/models/IRRMesh/assets/wal69ar_small.jpg
Binary files differ
diff --git a/test/models/IRRMesh/cellar.irrmesh b/test/models/IRRMesh/cellar.irrmesh
index 0278c9239..ee787463a 100644
--- a/test/models/IRRMesh/cellar.irrmesh
+++ b/test/models/IRRMesh/cellar.irrmesh
@@ -13,8 +13,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="brownground_1-1.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/brownground_1-1.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
@@ -870,8 +870,8 @@
<float name="Shininess" value="0.750000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="crackedground_1-6.jpg" />
- <texture name="Texture2" value="1.png" />
+ <texture name="Texture1" value="assets/crackedground_1-6.jpg" />
+ <texture name="Texture2" value="assets/1.png" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
<bool name="Wireframe" value="false" />
diff --git a/test/models/IRRMesh/cellar_UTF16LE.irrmesh b/test/models/IRRMesh/cellar_UTF16LE.irrmesh
index d8d3a661b..38ef1847c 100644
--- a/test/models/IRRMesh/cellar_UTF16LE.irrmesh
+++ b/test/models/IRRMesh/cellar_UTF16LE.irrmesh
Binary files differ
diff --git a/test/models/IRRMesh/spider.irrmesh b/test/models/IRRMesh/spider.irrmesh
index e446a9ec2..e94901156 100644
--- a/test/models/IRRMesh/spider.irrmesh
+++ b/test/models/IRRMesh/spider.irrmesh
@@ -13,7 +13,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="wal67ar_small.jpg" />
+ <texture name="Texture1" value="assets/wal67ar_small.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -354,7 +354,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="SpiderTex.jpg" />
+ <texture name="Texture1" value="assets/SpiderTex.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -485,7 +485,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="drkwood2.jpg" />
+ <texture name="Texture1" value="assets/drkwood2.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -1609,7 +1609,7 @@
<float name="Shininess" value="0.000000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="engineflare1.jpg" />
+ <texture name="Texture1" value="assets/engineflare1.jpg" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRRMesh/spider_UTF16LE.irrmesh b/test/models/IRRMesh/spider_UTF16LE.irrmesh
index 25fda7c27..4a3509d5b 100644
--- a/test/models/IRRMesh/spider_UTF16LE.irrmesh
+++ b/test/models/IRRMesh/spider_UTF16LE.irrmesh
Binary files differ
diff --git a/test/models/IRRMesh/testFormatDetection.xml b/test/models/IRRMesh/testFormatDetection.xml
index 0986eaf61..fd2e34f65 100644
--- a/test/models/IRRMesh/testFormatDetection.xml
+++ b/test/models/IRRMesh/testFormatDetection.xml
@@ -13,7 +13,7 @@
<float name="Shininess" value="0.100000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="" />
+ <texture name="Texture1" value="assets/UVTransformTestImg.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -96,7 +96,7 @@
<float name="Shininess" value="0.100000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="" />
+ <texture name="Texture1" value="assets/UVTransform_OffsetUV0.5-mirrorUV.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -179,7 +179,7 @@
<float name="Shininess" value="0.100000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="" />
+ <texture name="Texture1" value="assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -262,7 +262,7 @@
<float name="Shininess" value="0.100000" />
<float name="Param1" value="0.000000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="" />
+ <texture name="Texture1" value="assets/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
@@ -345,7 +345,7 @@
<float name="Shininess" value="0.100000" />
<float name="Param1" value="0.170000" />
<float name="Param2" value="0.000000" />
- <texture name="Texture1" value="" />
+ <texture name="Texture1" value="assets/UVTransform_ScaleUV2x_Rotate45.png" />
<texture name="Texture2" value="" />
<texture name="Texture3" value="" />
<texture name="Texture4" value="" />
diff --git a/test/models/IRRMesh/testFormatDetection_UTF16LE.xml b/test/models/IRRMesh/testFormatDetection_UTF16LE.xml
index aa73560d4..64891be9f 100644
--- a/test/models/IRRMesh/testFormatDetection_UTF16LE.xml
+++ b/test/models/IRRMesh/testFormatDetection_UTF16LE.xml
Binary files differ
diff --git a/test/models/X3D/IndexedLineSet.x3d b/test/models/X3D/IndexedLineSet.x3d
new file mode 100644
index 000000000..ed865ebb7
--- /dev/null
+++ b/test/models/X3D/IndexedLineSet.x3d
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
+<X3D profile='Interchange' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
+ <head>
+ </head>
+ <Scene>
+ <WorldInfo title='vertices.x3d'/>
+ <NavigationInfo type='"EXAMINE" "WALK" "FLY" "ANY"'/>
+ <Viewpoint description='vertices' position='0 0 10'/>
+ <Shape>
+ <Appearance>
+ <Material emissiveColor='1 0 0'/>
+ </Appearance>
+ <IndexedLineSet coordIndex='0 1 2 3 0 -1'>
+ <Coordinate point='1 0 0 1 1 0 0 1 0 0 0 0'/>
+ </IndexedLineSet>
+ </Shape>
+ </Scene>
+</X3D>
diff --git a/test/models/glTF2/simple_skin/quad_skin.glb b/test/models/glTF2/simple_skin/quad_skin.glb
new file mode 100644
index 000000000..407cebc76
--- /dev/null
+++ b/test/models/glTF2/simple_skin/quad_skin.glb
Binary files differ
diff --git a/test/models/invalid/box_nested_animation_4286.dae b/test/models/invalid/box_nested_animation_4286.dae
new file mode 100644
index 000000000..2def61d20
--- /dev/null
+++ b/test/models/invalid/box_nested_animation_4286.dae
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="utf-8"?>
+<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <asset>
+ <contributor>
+ <author>Blender User</author>
+ <authoring_tool>Blender 2.80.40 commit date:2019-01-07, commit time:23:37, hash:91a155833e59</authoring_tool>
+ </contributor>
+ <created>2019-01-08T17:44:11</created>
+ <modified>2019-01-08T17:44:11</modified>
+ <unit name="meter" meter="1"/>
+ <up_axis>Z_UP</up_axis>
+ </asset>
+ <library_effects>
+ <effect id="Material-effect">
+ <profile_COMMON>
+ <technique sid="common">
+ <lambert>
+ <diffuse>
+ <color sid="diffuse">0.8 0.8 0.8 1</color>
+ </diffuse>
+ <specular>
+ <color sid="specular">0 0.5 0 1</color>
+ </specular>
+ </lambert>
+ </technique>
+ </profile_COMMON>
+ </effect>
+ </library_effects>
+ <library_images/>
+ <library_materials>
+ <material id="Material-material" name="Material">
+ <instance_effect url="#Material-effect"/>
+ </material>
+ </library_materials>
+ <library_geometries>
+ <geometry id="Cube-mesh" name="Cube">
+ <mesh>
+ <source id="Cube-mesh-positions">
+ <float_array id="Cube-mesh-positions-array" count="3">1 1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1</float_array>
+ <technique_common>
+ <accessor source="#Cube-mesh-positions-array" count="8" stride="3">
+ <param name="X" type="float"/>
+ <param name="Y" type="float"/>
+ <param name="Z" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <source id="Cube-mesh-normals">
+ <float_array id="Cube-mesh-normals-array" count="18">0 0 1 0 -1 0 -1 0 0 0 0 -1 1 0 0 0 1 0</float_array>
+ <technique_common>
+ <accessor source="#Cube-mesh-normals-array" count="6" stride="3">
+ <param name="X" type="float"/>
+ <param name="Y" type="float"/>
+ <param name="Z" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <source id="Cube-mesh-map-0">
+ <float_array id="Cube-mesh-map-0-array" count="72">0.625 0 0.375 0.25 0.375 0 0.625 0.25 0.375 0.5 0.375 0.25 0.625 0.5 0.375 0.75 0.375 0.5 0.625 0.75 0.375 1 0.375 0.75 0.375 0.5 0.125 0.75 0.125 0.5 0.875 0.5 0.625 0.75 0.625 0.5 0.625 0 0.625 0.25 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1 0.375 1 0.375 0.5 0.375 0.75 0.125 0.75 0.875 0.5 0.875 0.75 0.625 0.75</float_array>
+ <technique_common>
+ <accessor source="#Cube-mesh-map-0-array" count="36" stride="2">
+ <param name="S" type="float"/>
+ <param name="T" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <vertices id="Cube-mesh-vertices">
+ <input semantic="POSITION" source="#Cube-mesh-positions"/>
+ </vertices>
+ <polylist material="Material-material" count="12">
+ <input semantic="VERTEX" source="#Cube-mesh-vertices" offset="0"/>
+ <input semantic="NORMAL" source="#Cube-mesh-normals" offset="1"/>
+ <input semantic="TEXCOORD" source="#Cube-mesh-map-0" offset="2" set="1"/>
+ <vcount>3 3 3 3 3 3 3 3 3 3 3 3 </vcount>
+ <p>4 0 0 2 0 1 0 0 2 2 1 3 7 1 4 3 1 5 6 2 6 5 2 7 7 2 8 1 3 9 7 3 10 5 3 11 0 4 12 3 4 13 1 4 14 4 5 15 1 5 16 5 5 17 4 0 18 6 0 19 2 0 20 2 1 21 6 1 22 7 1 23 6 2 24 4 2 25 5 2 26 1 3 27 3 3 28 7 3 29 0 4 30 2 4 31 3 4 32 4 5 33 0 5 34 1 5 35</p>
+ </polylist>
+ </mesh>
+ </geometry>
+ </library_geometries>
+ <library_controllers>
+ <controller id="Armature_Cube-skin" name="Armature">
+ <skin source="#Cube-mesh">
+ <bind_shape_matrix>1 0 0 -1 0 1 0 1 0 0 1 1 0 0 0 1</bind_shape_matrix>
+ <source id="Armature_Cube-skin-joints">
+ <Name_array id="Armature_Cube-skin-joints-array" count="1">Bone</Name_array>
+ <technique_common>
+ <accessor source="#Armature_Cube-skin-joints-array" count="1" stride="1">
+ <param name="JOINT" type="name"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <source id="Armature_Cube-skin-bind_poses">
+ <float_array id="Armature_Cube-skin-bind_poses-array" count="16">0.7886752 0.2113248 0.5773504 -0.5773504 -0.5773503 0.5773503 0.5773503 1.154701 -0.2113249 -0.7886752 0.5773503 -0.5773502 0 0 0 1</float_array>
+ <technique_common>
+ <accessor source="#Armature_Cube-skin-bind_poses-array" count="1" stride="16">
+ <param name="TRANSFORM" type="float4x4"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <source id="Armature_Cube-skin-weights">
+ <float_array id="Armature_Cube-skin-weights-array" count="8">1 1 1 1 1 1 1 1</float_array>
+ <technique_common>
+ <accessor source="#Armature_Cube-skin-weights-array" count="8" stride="1">
+ <param name="WEIGHT" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <joints>
+ <input semantic="JOINT" source="#Armature_Cube-skin-joints"/>
+ <input semantic="INV_BIND_MATRIX" source="#Armature_Cube-skin-bind_poses"/>
+ </joints>
+ <vertex_weights count="8">
+ <input semantic="JOINT" source="#Armature_Cube-skin-joints" offset="0"/>
+ <input semantic="WEIGHT" source="#Armature_Cube-skin-weights" offset="1"/>
+ <vcount>1 1 1 1 1 1 1 1 </vcount>
+ <v>0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7</v>
+ </vertex_weights>
+ </skin>
+ </controller>
+ </library_controllers>
+ <library_animations>
+ <animation id="action_container-Armature" name="Armature">
+ <animation id="Armature_ArmatureAction_transform" name="Armature">
+ <source id="Armature_ArmatureAction_transform-input">
+ <float_array id="Armature_ArmatureAction_transform-input-array" count="40">0.04166662 0.08333331 0.125 0.1666666 0.2083333 0.25 0.2916666 0.3333333 0.375 0.4166666 0.4583333 0.5 0.5416667 0.5833333 0.625 0.6666667 0.7083333 0.75 0.7916667 0.8333333 0.875 0.9166667 0.9583333 1 1.041667 1.083333 1.125 1.166667 1.208333 1.25 1.291667 1.333333 1.375 1.416667 1.458333 1.5 1.541667 1.583333 1.625 1.666667</float_array>
+ <technique_common>
+ <accessor source="#Armature_ArmatureAction_transform-input-array" count="40" stride="1">
+ <param name="TIME" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <source id="Armature_ArmatureAction_transform-output">
+ <float_array id="Armature_ArmatureAction_transform-output-array" count="640">1 0 0 1 0 1 0 -1 0 0 1 0 0 0 0 1 0.9999878 3.10816e-5 0.004935208 1 0 0.9999802 -0.006297799 -1 -0.004935306 0.006297722 0.999968 0 0 0 0 1 0.999819 4.61727e-4 0.01901668 1 0 0.9997054 -0.02427293 -1 -0.01902229 0.02426853 0.9995245 0 0 0 0 1 0.9991519 0.002163141 0.04111904 1 0 0.9986191 -0.05253414 -1 -0.04117589 0.05248959 0.9977722 0 0 0 0 1 0.9975264 0.006301912 0.07000974 1 0 0.9959731 -0.08965231 -1 -0.0702928 0.08943056 0.9935095 0 0 0 0 1 0.9944467 0.01411698 0.1042901 1 0 0.9909625 -0.1341392 -1 -0.1052413 0.1333943 0.9854594 0 0 0 0 1 0.9894527 0.02671701 0.1423712 1 0 0.9828442 -0.184438 -1 -0.1448563 0.1824927 0.9724778 0 0 0 0 1 0.9821799 0.04490547 0.1825 1 0 0.9710366 -0.2389307 -1 -0.1879434 0.234673 0.9537326 0 0 0 0 1 0.9724072 0.06904543 0.2228386 1 0 0.9551992 -0.2959637 -1 -0.2332902 0.2877972 0.9288425 0 0 0 0 1 0.9600915 0.09897761 0.261587 1 0 0.9352878 -0.3538882 -1 -0.2796861 0.339765 0.8979618 0 0 0 0 1 0.9453882 0.1340003 0.2971281 1 0 0.9115852 -0.4111113 -1 -0.3259466 0.3886598 0.8618018 0 0 0 0 1 0.9286572 0.1729132 0.328172 1 0 0.8847058 -0.4661497 -1 -0.3709391 0.4328933 0.8215885 0 0 0 0 1 0.9104556 0.2141147 0.3538722 1 0 0.8555763 -0.5176768 -1 -0.4136069 0.4713217 0.7789642 0 0 0 0 1 0.8915175 0.2557371 0.3738919 1 0 0.8253933 -0.5645581 -1 -0.4529863 0.5033134 0.7358525 0 0 0 0 1 0.8727233 0.2957927 0.388408 1 0 0.7955672 -0.6058654 -1 -0.4882152 0.5287529 0.6943099 0 0 0 0 1 0.8550603 0.332307 0.3980502 1 0 0.7676533 -0.6408653 -1 -0.5185286 0.5479785 0.6563899 0 0 0 0 1 0.8395769 0.3634188 0.4037789 1 0 0.7432778 -0.6689829 -1 -0.5432408 0.5616626 0.6240388 0 0 0 0 1 0.8273312 0.3874339 0.4067161 1 0 0.7240622 -0.6897347 -1 -0.5617144 0.5706391 0.5990393 0 0 0 0 1 0.8193359 0.4028329 0.4079393 1 0 0.7115462 -0.7026393 -1 -0.5733138 0.5756976 0.5829953 0 0 0 0 1 0.8164964 0.4082482 0.4082486 1 7.75722e-8 0.707107 -0.7071065 -1 -0.5773504 0.57735 0.5773503 0 0 0 0 1 0.8190646 0.4033515 0.4079717 1 7.78161e-8 0.7111219 -0.7030687 -1 -0.5737014 0.5758587 0.5824547 0 0 0 0 1 0.8263245 0.3893851 0.4068995 1 7.85059e-8 0.7224849 -0.6913868 -1 -0.5631944 0.5713098 0.5970069 0 0 0 0 1 0.8375081 0.3675125 0.4043696 1 7.95684e-8 0.7400277 -0.6725764 -1 -0.5464249 0.5632883 0.6197791 0 0 0 0 1 0.8517552 0.3390183 0.3994742 1 8.0922e-8 0.7624427 -0.6470557 -1 -0.5239399 0.5511332 0.6494145 0 0 0 0 1 0.8681612 0.3053284 0.3912425 1 8.24806e-8 0.7883466 -0.6152314 -1 -0.4962822 0.5341201 0.6844119 0 0 0 0 1 0.8858209 0.2680094 0.3788038 1 8.41584e-8 0.8163394 -0.5775725 -1 -0.4640273 0.5116258 0.7231305 0 0 0 0 1 0.9038687 0.2287352 0.3615268 1 8.58731e-8 0.8450637 -0.5346656 -1 -0.42781 0.4832675 0.7638266 0 0 0 0 1 0.9215156 0.1892192 0.339124 1 8.75496e-8 0.8732626 -0.4872499 -1 -0.3883413 0.4490085 0.8047251 0 0 0 0 1 0.9380813 0.1511175 0.3117163 1 8.91235e-8 0.899834 -0.4362323 -1 -0.3464153 0.4092214 0.8441175 0 0 0 0 1 0.9530206 0.1159168 0.2798482 1 9.05428e-8 0.9238796 -0.3826832 -1 -0.3029055 0.3647051 0.8804763 0 0 0 0 1 0.965943 0.08482374 0.2444564 1 9.17705e-8 0.9447417 -0.3278156 -1 -0.2587547 0.3166512 0.9125667 0 0 0 0 1 0.9766233 0.05867312 0.2067956 1 9.27852e-8 0.9620277 -0.2729518 -1 -0.2149581 0.2665711 0.9395387 0 0 0 0 1 0.9850019 0.03787052 0.1683363 1 9.35812e-8 0.975616 -0.2194843 -1 -0.1725436 0.2161924 0.9609836 0 0 0 0 1 0.991176 0.02237916 0.1306496 1 9.41678e-8 0.9856446 -0.1688333 -1 -0.1325524 0.1673435 0.9769473 0 0 0 0 1 0.9953793 0.01175384 0.09529842 1 9.45671e-8 0.9924796 -0.1224106 -1 -0.09602053 0.121845 0.9878936 0 0 0 0 1 0.997952 0.005218936 0.06375288 1 9.48115e-8 0.996666 -0.08159051 -1 -0.06396614 0.08142342 0.9946249 0 0 0 0 1 0.9993011 0.001782816 0.03733916 1 9.49397e-8 0.998862 -0.04769476 -1 -0.0373817 0.04766143 0.9981638 0 0 0 0 1 0.9998515 3.78837e-4 0.01722835 1 9.4992e-8 0.9997582 -0.02198936 -1 -0.01723252 0.0219861 0.9996098 0 0 0 0 1 0.99999 2.53135e-5 0.004462156 1 9.50052e-8 0.9999838 -0.00569412 -1 -0.004462227 0.005694063 0.9999738 0 0 0 0 1 1 0 0 2 0 1 0 -1 0 0 1 0 0 0 0 1</float_array>
+ <technique_common>
+ <accessor source="#Armature_ArmatureAction_transform-output-array" count="40" stride="16">
+ <param name="TRANSFORM" type="float4x4"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <source id="Armature_ArmatureAction_transform-interpolation">
+ <Name_array id="Armature_ArmatureAction_transform-interpolation-array" count="40">LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR LINEAR</Name_array>
+ <technique_common>
+ <accessor source="#Armature_ArmatureAction_transform-interpolation-array" count="40" stride="1">
+ <param name="INTERPOLATION" type="name"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <sampler id="Armature_ArmatureAction_transform-sampler">
+ <input semantic="INPUT" source="#Armature_ArmatureAction_transform-input"/>
+ <input semantic="OUTPUT" source="#Armature_ArmatureAction_transform-output"/>
+ <input semantic="INTERPOLATION" source="#Armature_ArmatureAction_transform-interpolation"/>
+ </sampler>
+ <channel source="#Armature_ArmatureAction_transform-sampler" target="Armature_Bone/transform"/>
+ </animation>
+ </animation>
+ </library_animations>
+ <library_visual_scenes>
+ <visual_scene id="Scene" name="Scene">
+ <node id="Armature" name="Armature" type="NODE">
+ <matrix sid="transform">1 0 0 1 0 1 0 -1 0 0 1 0 0 0 0 1</matrix>
+ <node id="Armature_Bone" name="Bone" sid="Bone" type="JOINT">
+ <matrix sid="transform">0.7886751 -0.5773503 -0.211325 0 0.2113248 0.5773503 -0.7886751 0 0.5773503 0.5773503 0.5773502 0 0 0 0 1</matrix>
+ <extra>
+ <technique profile="blender">
+ <layer sid="layer" type="string">0</layer>
+ <roll sid="roll" type="float">-0.5235989</roll>
+ <tip_x sid="tip_x" type="float">-2</tip_x>
+ <tip_y sid="tip_y" type="float">2</tip_y>
+ <tip_z sid="tip_z" type="float">2</tip_z>
+ </technique>
+ </extra>
+ </node>
+ <node id="Cube" name="Cube" type="NODE">
+ <translate sid="location">0 0 0</translate>
+ <rotate sid="rotationZ">0 0 1 0</rotate>
+ <rotate sid="rotationY">0 1 0 0</rotate>
+ <rotate sid="rotationX">1 0 0 0</rotate>
+ <scale sid="scale">1 1 1</scale>
+ <instance_controller url="#Armature_Cube-skin">
+ <skeleton>#Armature_Bone</skeleton>
+ <bind_material>
+ <technique_common>
+ <instance_material symbol="Material-material" target="#Material-material">
+ <bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
+ </instance_material>
+ </technique_common>
+ </bind_material>
+ </instance_controller>
+ </node>
+ </node>
+ </visual_scene>
+ </library_visual_scenes>
+ <scene>
+ <instance_visual_scene url="#Scene"/>
+ </scene>
+</COLLADA>
diff --git a/test/models/invalid/crash-30d6d0f7c529b3b66b4131700b7a4580cd7082df.ply b/test/models/invalid/crash-30d6d0f7c529b3b66b4131700b7a4580cd7082df.ply
new file mode 100644
index 000000000..948f5bcf9
--- /dev/null
+++ b/test/models/invalid/crash-30d6d0f7c529b3b66b4131700b7a4580cd7082df.ply
Binary files differ
diff --git a/test/models/invalid/readme.txt b/test/models/invalid/readme.txt
index 6ad8b4380..ad144ca36 100644
--- a/test/models/invalid/readme.txt
+++ b/test/models/invalid/readme.txt
@@ -18,6 +18,9 @@ crash.
FILES
*********************************************************
+box_nested_animation_4286.dae - This was reported as GH#4286.
+ The "count" parameter in "Cube-mesh-positions-array" is too small.
+
OutOfMemory.off - the number of faces is invalid. There won't be
enough memory so std::vector::reserve() will most likely fail.
The exception should be caught in Importer.cpp.
diff --git a/test/unit/AbstractImportExportBase.cpp b/test/unit/AbstractImportExportBase.cpp
index 077a4d1f2..80e53500d 100644
--- a/test/unit/AbstractImportExportBase.cpp
+++ b/test/unit/AbstractImportExportBase.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/AssimpAPITest.cpp b/test/unit/AssimpAPITest.cpp
index b8739b039..effe940b1 100644
--- a/test/unit/AssimpAPITest.cpp
+++ b/test/unit/AssimpAPITest.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/AssimpAPITest_aiMatrix3x3.cpp b/test/unit/AssimpAPITest_aiMatrix3x3.cpp
index 90976ba6e..7b4532dce 100644
--- a/test/unit/AssimpAPITest_aiMatrix3x3.cpp
+++ b/test/unit/AssimpAPITest_aiMatrix3x3.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/AssimpAPITest_aiMatrix4x4.cpp b/test/unit/AssimpAPITest_aiMatrix4x4.cpp
index 9372bd9c4..2f17ea2ad 100644
--- a/test/unit/AssimpAPITest_aiMatrix4x4.cpp
+++ b/test/unit/AssimpAPITest_aiMatrix4x4.cpp
@@ -3,9 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
-
-
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -47,7 +45,7 @@ using namespace Assimp;
class AssimpAPITest_aiMatrix4x4 : public AssimpMathTest {
protected:
- virtual void SetUp() {
+ void SetUp() override {
result_c = result_cpp = aiMatrix4x4();
}
@@ -64,6 +62,11 @@ protected:
aiMatrix4x4 result_c, result_cpp;
};
+TEST_F(AssimpAPITest_aiMatrix4x4, isIdendityTest) {
+ aiMatrix4x4 m = aiMatrix4x4(1.001f, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
+ EXPECT_TRUE(m.IsIdentity(1e-3f));
+}
+
TEST_F(AssimpAPITest_aiMatrix4x4, aiIdentityMatrix4Test) {
// Force a non-identity matrix.
result_c = aiMatrix4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
diff --git a/test/unit/AssimpAPITest_aiQuaternion.cpp b/test/unit/AssimpAPITest_aiQuaternion.cpp
index 68daeefec..fe28bc9d0 100644
--- a/test/unit/AssimpAPITest_aiQuaternion.cpp
+++ b/test/unit/AssimpAPITest_aiQuaternion.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/AssimpAPITest_aiVector2D.cpp b/test/unit/AssimpAPITest_aiVector2D.cpp
index 44bb34aec..8831016cd 100644
--- a/test/unit/AssimpAPITest_aiVector2D.cpp
+++ b/test/unit/AssimpAPITest_aiVector2D.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/AssimpAPITest_aiVector3D.cpp b/test/unit/AssimpAPITest_aiVector3D.cpp
index c7521163d..67ad11bb6 100644
--- a/test/unit/AssimpAPITest_aiVector3D.cpp
+++ b/test/unit/AssimpAPITest_aiVector3D.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/Common/uiScene.cpp b/test/unit/Common/uiScene.cpp
index 509bf71b1..5002b5dd8 100644
--- a/test/unit/Common/uiScene.cpp
+++ b/test/unit/Common/uiScene.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/Common/utAssertHandler.cpp b/test/unit/Common/utAssertHandler.cpp
index 039ba8345..53bf5c929 100644
--- a/test/unit/Common/utAssertHandler.cpp
+++ b/test/unit/Common/utAssertHandler.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/Common/utBase64.cpp b/test/unit/Common/utBase64.cpp
index ec927b980..910a908cb 100644
--- a/test/unit/Common/utBase64.cpp
+++ b/test/unit/Common/utBase64.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/Common/utBaseProcess.cpp b/test/unit/Common/utBaseProcess.cpp
index 359042315..f70dae07b 100644
--- a/test/unit/Common/utBaseProcess.cpp
+++ b/test/unit/Common/utBaseProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/Common/utHash.cpp b/test/unit/Common/utHash.cpp
index 97e2d91c1..912aca11d 100644
--- a/test/unit/Common/utHash.cpp
+++ b/test/unit/Common/utHash.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/Common/utLineSplitter.cpp b/test/unit/Common/utLineSplitter.cpp
index 0a97f72d9..f62a00c74 100644
--- a/test/unit/Common/utLineSplitter.cpp
+++ b/test/unit/Common/utLineSplitter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/Common/utMaybe.cpp b/test/unit/Common/utMaybe.cpp
index 9de300290..c66b8f603 100644
--- a/test/unit/Common/utMaybe.cpp
+++ b/test/unit/Common/utMaybe.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/Common/utMesh.cpp b/test/unit/Common/utMesh.cpp
index 77a711394..7baaa92a0 100644
--- a/test/unit/Common/utMesh.cpp
+++ b/test/unit/Common/utMesh.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/Common/utSpatialSort.cpp b/test/unit/Common/utSpatialSort.cpp
index 6b05ac65e..a75daebce 100644
--- a/test/unit/Common/utSpatialSort.cpp
+++ b/test/unit/Common/utSpatialSort.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/Common/utStandardShapes.cpp b/test/unit/Common/utStandardShapes.cpp
index d7e6d21d7..e1843d6c5 100644
--- a/test/unit/Common/utStandardShapes.cpp
+++ b/test/unit/Common/utStandardShapes.cpp
@@ -1,7 +1,7 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
diff --git a/test/unit/Common/utXmlParser.cpp b/test/unit/Common/utXmlParser.cpp
index 2db78e30d..b566aa381 100644
--- a/test/unit/Common/utXmlParser.cpp
+++ b/test/unit/Common/utXmlParser.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/Geometry/utGeometryUtils.cpp b/test/unit/Geometry/utGeometryUtils.cpp
index 2e764860d..345946132 100644
--- a/test/unit/Geometry/utGeometryUtils.cpp
+++ b/test/unit/Geometry/utGeometryUtils.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/MDL/MDLHL1TestFiles.h b/test/unit/ImportExport/MDL/MDLHL1TestFiles.h
index 3c0630f63..0fff3411e 100644
--- a/test/unit/ImportExport/MDL/MDLHL1TestFiles.h
+++ b/test/unit/ImportExport/MDL/MDLHL1TestFiles.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp b/test/unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp
index d50c2b35a..f6e03cb09 100644
--- a/test/unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp
+++ b/test/unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp b/test/unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp
index f733893ca..d0345e3e4 100644
--- a/test/unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp
+++ b/test/unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp b/test/unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp
index 49ae8a16c..1029a6138 100644
--- a/test/unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp
+++ b/test/unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/Pbrt/utPbrtImportExport.cpp b/test/unit/ImportExport/Pbrt/utPbrtImportExport.cpp
new file mode 100644
index 000000000..c7807205a
--- /dev/null
+++ b/test/unit/ImportExport/Pbrt/utPbrtImportExport.cpp
@@ -0,0 +1,70 @@
+/*
+---------------------------------------------------------------------------
+Open Asset Import Library (assimp)
+---------------------------------------------------------------------------
+
+Copyright (c) 2006-2020, assimp team
+
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the following
+conditions are met:
+
+* Redistributions of source code must retain the above
+copyright notice, this list of conditions and the
+following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the
+following disclaimer in the documentation and/or other
+materials provided with the distribution.
+
+* Neither the name of the assimp team, nor the names of its
+contributors may be used to endorse or promote products
+derived from this software without specific prior
+written permission of the assimp team.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+---------------------------------------------------------------------------
+*/
+#include "AbstractImportExportBase.h"
+#include "UnitTestPCH.h"
+#include <assimp/postprocess.h>
+#include <assimp/scene.h>
+#include <assimp/Importer.hpp>
+#include <assimp/Exporter.hpp>
+
+using namespace Assimp;
+
+class utPbrtImportExport : public AbstractImportExportBase {
+public:
+#ifndef ASSIMP_BUILD_NO_EXPORT
+ bool exporterTest() override {
+ Assimp::Importer importer;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
+ EXPECT_NE(scene, nullptr );
+
+ ::Assimp::Exporter exporter;
+ return AI_SUCCESS == exporter.Export(scene, "pbrt", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.pbrt");
+ }
+#endif
+};
+
+#ifndef ASSIMP_BUILD_NO_EXPORT
+
+TEST_F(utPbrtImportExport, exportTest_Success) {
+ EXPECT_TRUE(exporterTest());
+}
+
+#endif // ASSIMP_BUILD_NO_EXPORT
diff --git a/test/unit/ImportExport/RAW/utRAWImportExport.cpp b/test/unit/ImportExport/RAW/utRAWImportExport.cpp
index bdd7f8533..9981ed2f7 100644
--- a/test/unit/ImportExport/RAW/utRAWImportExport.cpp
+++ b/test/unit/ImportExport/RAW/utRAWImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/Terragen/utTerragenImportExport.cpp b/test/unit/ImportExport/Terragen/utTerragenImportExport.cpp
index 8ec20e0c0..1ddde44a6 100644
--- a/test/unit/ImportExport/Terragen/utTerragenImportExport.cpp
+++ b/test/unit/ImportExport/Terragen/utTerragenImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utAssjsonImportExport.cpp b/test/unit/ImportExport/utAssjsonImportExport.cpp
index 3470874b5..c32b0f160 100644
--- a/test/unit/ImportExport/utAssjsonImportExport.cpp
+++ b/test/unit/ImportExport/utAssjsonImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utCOBImportExport.cpp b/test/unit/ImportExport/utCOBImportExport.cpp
index 187f16ede..705cda38d 100644
--- a/test/unit/ImportExport/utCOBImportExport.cpp
+++ b/test/unit/ImportExport/utCOBImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utExporter.cpp b/test/unit/ImportExport/utExporter.cpp
index 096a5c49d..d94f179ed 100644
--- a/test/unit/ImportExport/utExporter.cpp
+++ b/test/unit/ImportExport/utExporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utMD2Importer.cpp b/test/unit/ImportExport/utMD2Importer.cpp
index 0fcf76bfc..975b8f641 100644
--- a/test/unit/ImportExport/utMD2Importer.cpp
+++ b/test/unit/ImportExport/utMD2Importer.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utMD5Importer.cpp b/test/unit/ImportExport/utMD5Importer.cpp
index 082121937..6fe558565 100644
--- a/test/unit/ImportExport/utMD5Importer.cpp
+++ b/test/unit/ImportExport/utMD5Importer.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utMDLImporter.cpp b/test/unit/ImportExport/utMDLImporter.cpp
index c8960601d..43cdf9a1d 100644
--- a/test/unit/ImportExport/utMDLImporter.cpp
+++ b/test/unit/ImportExport/utMDLImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utNFFImportExport.cpp b/test/unit/ImportExport/utNFFImportExport.cpp
index 621324a85..b989578f5 100644
--- a/test/unit/ImportExport/utNFFImportExport.cpp
+++ b/test/unit/ImportExport/utNFFImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utOFFImportExport.cpp b/test/unit/ImportExport/utOFFImportExport.cpp
index 78ae4acc4..abd1fe154 100644
--- a/test/unit/ImportExport/utOFFImportExport.cpp
+++ b/test/unit/ImportExport/utOFFImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utOgreImportExport.cpp b/test/unit/ImportExport/utOgreImportExport.cpp
index 7312d6b58..d3234c036 100644
--- a/test/unit/ImportExport/utOgreImportExport.cpp
+++ b/test/unit/ImportExport/utOgreImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utQ3BSPFileImportExport.cpp b/test/unit/ImportExport/utQ3BSPFileImportExport.cpp
index f5694d2ee..d8738eff7 100644
--- a/test/unit/ImportExport/utQ3BSPFileImportExport.cpp
+++ b/test/unit/ImportExport/utQ3BSPFileImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ImportExport/utXGLImportExport.cpp b/test/unit/ImportExport/utXGLImportExport.cpp
index 8199806cc..080290e1d 100644
--- a/test/unit/ImportExport/utXGLImportExport.cpp
+++ b/test/unit/ImportExport/utXGLImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/MathTest.cpp b/test/unit/MathTest.cpp
index 86a5d7e0f..6069df22e 100644
--- a/test/unit/MathTest.cpp
+++ b/test/unit/MathTest.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/MathTest.h b/test/unit/MathTest.h
index 08411e82f..a09024370 100644
--- a/test/unit/MathTest.h
+++ b/test/unit/MathTest.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/RandomNumberGeneration.h b/test/unit/RandomNumberGeneration.h
index 95ba5b43b..0383332e4 100644
--- a/test/unit/RandomNumberGeneration.h
+++ b/test/unit/RandomNumberGeneration.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/SceneDiffer.cpp b/test/unit/SceneDiffer.cpp
index a7132496a..6cbc33dde 100644
--- a/test/unit/SceneDiffer.cpp
+++ b/test/unit/SceneDiffer.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/SceneDiffer.h b/test/unit/SceneDiffer.h
index 2ac429b76..06065bd5f 100644
--- a/test/unit/SceneDiffer.h
+++ b/test/unit/SceneDiffer.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/TestIOSystem.h b/test/unit/TestIOSystem.h
index fe2455e52..8791f9b92 100644
--- a/test/unit/TestIOSystem.h
+++ b/test/unit/TestIOSystem.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/TestModelFactory.h b/test/unit/TestModelFactory.h
index c938af0fd..2ddf37e3e 100644
--- a/test/unit/TestModelFactory.h
+++ b/test/unit/TestModelFactory.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/UTLogStream.h b/test/unit/UTLogStream.h
index 6e5d75762..d35de8bdc 100644
--- a/test/unit/UTLogStream.h
+++ b/test/unit/UTLogStream.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/UnitTestFileGenerator.h b/test/unit/UnitTestFileGenerator.h
index 2166c6939..93007bad9 100644
--- a/test/unit/UnitTestFileGenerator.h
+++ b/test/unit/UnitTestFileGenerator.h
@@ -44,9 +44,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdlib>
#include <gtest/gtest.h>
+#if defined(_MSC_VER) || defined(__MINGW64__) || defined(__MINGW32__)
+#define TMP_PATH "./"
+#elif defined(__GNUC__) || defined(__clang__)
+#define TMP_PATH "/tmp/"
+#endif
+
#if defined(_MSC_VER)
#include <io.h>
-#define TMP_PATH "./"
inline FILE* MakeTmpFile(char* tmplate)
{
auto pathtemplate = _mktemp(tmplate);
@@ -60,7 +65,6 @@ inline FILE* MakeTmpFile(char* tmplate)
return fs;
}
#elif defined(__GNUC__) || defined(__clang__)
-#define TMP_PATH "/tmp/"
inline FILE* MakeTmpFile(char* tmplate)
{
auto fd = mkstemp(tmplate);
diff --git a/test/unit/ut3DImportExport.cpp b/test/unit/ut3DImportExport.cpp
index 32b77ddf8..4cd538c46 100644
--- a/test/unit/ut3DImportExport.cpp
+++ b/test/unit/ut3DImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/ut3DSImportExport.cpp b/test/unit/ut3DSImportExport.cpp
index 7279227fc..a2da3607c 100644
--- a/test/unit/ut3DSImportExport.cpp
+++ b/test/unit/ut3DSImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utACImportExport.cpp b/test/unit/utACImportExport.cpp
index c844603cf..4fdb68651 100644
--- a/test/unit/utACImportExport.cpp
+++ b/test/unit/utACImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -99,6 +99,12 @@ TEST(utACImportExport, importSphereWithLight) {
ASSERT_NE(nullptr, scene);
}
+TEST(utACImportExport, importSphereWithLightACC) {
+ Assimp::Importer importer;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight.acc", aiProcess_ValidateDataStructure);
+ ASSERT_NE(nullptr, scene);
+}
+
TEST(utACImportExport, importSphereWithLightUTF16) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight_UTF16LE.ac", aiProcess_ValidateDataStructure);
diff --git a/test/unit/utAMFImportExport.cpp b/test/unit/utAMFImportExport.cpp
index 7319320cf..996614572 100644
--- a/test/unit/utAMFImportExport.cpp
+++ b/test/unit/utAMFImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utASEImportExport.cpp b/test/unit/utASEImportExport.cpp
index af05a2fe5..e2d1bfa59 100644
--- a/test/unit/utASEImportExport.cpp
+++ b/test/unit/utASEImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utAnim.cpp b/test/unit/utAnim.cpp
index 956810d74..613f7f03b 100644
--- a/test/unit/utAnim.cpp
+++ b/test/unit/utAnim.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utArmaturePopulate.cpp b/test/unit/utArmaturePopulate.cpp
index 0acea7b50..9f4545c6a 100644
--- a/test/unit/utArmaturePopulate.cpp
+++ b/test/unit/utArmaturePopulate.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utAssbinImportExport.cpp b/test/unit/utAssbinImportExport.cpp
index 437a0a5fe..5eb2f56bd 100644
--- a/test/unit/utAssbinImportExport.cpp
+++ b/test/unit/utAssbinImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utB3DImportExport.cpp b/test/unit/utB3DImportExport.cpp
index 9672aa01b..76017f66c 100644
--- a/test/unit/utB3DImportExport.cpp
+++ b/test/unit/utB3DImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utBVHImportExport.cpp b/test/unit/utBVHImportExport.cpp
index 5a0ff1e10..94636c7bf 100644
--- a/test/unit/utBVHImportExport.cpp
+++ b/test/unit/utBVHImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utBatchLoader.cpp b/test/unit/utBatchLoader.cpp
index df6aa7995..be1ac30ad 100644
--- a/test/unit/utBatchLoader.cpp
+++ b/test/unit/utBatchLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utBlendImportAreaLight.cpp b/test/unit/utBlendImportAreaLight.cpp
index 4a16e662c..cc6e1e1a0 100644
--- a/test/unit/utBlendImportAreaLight.cpp
+++ b/test/unit/utBlendImportAreaLight.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -48,6 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class BlendImportAreaLight : public ::testing::Test {
public:
+ BlendImportAreaLight() :
+ im(nullptr) {}
+ ~BlendImportAreaLight() override = default;
void SetUp() override {
im = new Assimp::Importer();
}
diff --git a/test/unit/utBlendImportMaterials.cpp b/test/unit/utBlendImportMaterials.cpp
index 11499cc18..416fb3236 100644
--- a/test/unit/utBlendImportMaterials.cpp
+++ b/test/unit/utBlendImportMaterials.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utBlenderImportExport.cpp b/test/unit/utBlenderImportExport.cpp
index c220b7daa..0eda7b661 100644
--- a/test/unit/utBlenderImportExport.cpp
+++ b/test/unit/utBlenderImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utBlenderIntermediate.cpp b/test/unit/utBlenderIntermediate.cpp
index c2cc51e8d..b76c48b44 100644
--- a/test/unit/utBlenderIntermediate.cpp
+++ b/test/unit/utBlenderIntermediate.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utBlenderWork.cpp b/test/unit/utBlenderWork.cpp
index b20720521..2ba6329ca 100644
--- a/test/unit/utBlenderWork.cpp
+++ b/test/unit/utBlenderWork.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -48,11 +48,14 @@ using namespace ::Assimp;
class BlenderWorkTest : public ::testing::Test {
public:
- virtual void SetUp() {
+ BlenderWorkTest() : im(nullptr) {}
+ ~BlenderWorkTest() override = default;
+
+ void SetUp() override {
im = new Assimp::Importer();
}
- virtual void TearDown() {
+ void TearDown() override {
delete im;
}
diff --git a/test/unit/utCSMImportExport.cpp b/test/unit/utCSMImportExport.cpp
index 13bfd52bc..8ef14e282 100644
--- a/test/unit/utCSMImportExport.cpp
+++ b/test/unit/utCSMImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utColladaExport.cpp b/test/unit/utColladaExport.cpp
index 0df9312f2..e0a62b338 100644
--- a/test/unit/utColladaExport.cpp
+++ b/test/unit/utColladaExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utColladaImportExport.cpp b/test/unit/utColladaImportExport.cpp
index e2842732e..4e92c6930 100644
--- a/test/unit/utColladaImportExport.cpp
+++ b/test/unit/utColladaImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -357,6 +357,14 @@ TEST_F(utColladaImportExport, exporterUniqueIdsTest) {
ImportAsNames(outFileNamed, scene);
}
+// This file is invalid, we just want to ensure that the importer is not crashing
+// This was reported as GH#4286. The "count" parameter in "Cube-mesh-positions-array" is too small.
+TEST_F(utColladaImportExport, parseInvalid4286) {
+ Assimp::Importer importer;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/invalid/box_nested_animation_4286.dae", 0);
+ EXPECT_EQ(nullptr, scene);
+}
+
#endif
class utColladaZaeImportExport : public AbstractImportExportBase {
diff --git a/test/unit/utD3MFImportExport.cpp b/test/unit/utD3MFImportExport.cpp
index ed290e876..f25b2dcf7 100644
--- a/test/unit/utD3MFImportExport.cpp
+++ b/test/unit/utD3MFImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utDXFImporterExporter.cpp b/test/unit/utDXFImporterExporter.cpp
index 53c5328e4..ee0c57db6 100644
--- a/test/unit/utDXFImporterExporter.cpp
+++ b/test/unit/utDXFImporterExporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utDefaultIOStream.cpp b/test/unit/utDefaultIOStream.cpp
index 803c6f6f6..2a2d7a894 100644
--- a/test/unit/utDefaultIOStream.cpp
+++ b/test/unit/utDefaultIOStream.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utExport.cpp b/test/unit/utExport.cpp
index cb7826bfc..ebb664fa4 100644
--- a/test/unit/utExport.cpp
+++ b/test/unit/utExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utFBXImporterExporter.cpp b/test/unit/utFBXImporterExporter.cpp
index 9fa293aaf..5cc40d216 100644
--- a/test/unit/utFBXImporterExporter.cpp
+++ b/test/unit/utFBXImporterExporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utFastAtof.cpp b/test/unit/utFastAtof.cpp
index cc25482d2..50c26ca03 100644
--- a/test/unit/utFastAtof.cpp
+++ b/test/unit/utFastAtof.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utFindDegenerates.cpp b/test/unit/utFindDegenerates.cpp
index 5eadc032c..04f554716 100644
--- a/test/unit/utFindDegenerates.cpp
+++ b/test/unit/utFindDegenerates.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utFindInvalidData.cpp b/test/unit/utFindInvalidData.cpp
index b995b951b..ab845b35e 100644
--- a/test/unit/utFindInvalidData.cpp
+++ b/test/unit/utFindInvalidData.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utFixInfacingNormals.cpp b/test/unit/utFixInfacingNormals.cpp
index 8f75dd2f0..54fef7b59 100644
--- a/test/unit/utFixInfacingNormals.cpp
+++ b/test/unit/utFixInfacingNormals.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utGenBoundingBoxesProcess.cpp b/test/unit/utGenBoundingBoxesProcess.cpp
index c512e7f80..18b15c31e 100644
--- a/test/unit/utGenBoundingBoxesProcess.cpp
+++ b/test/unit/utGenBoundingBoxesProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utGenNormals.cpp b/test/unit/utGenNormals.cpp
index 92d477dbf..4a1db0216 100644
--- a/test/unit/utGenNormals.cpp
+++ b/test/unit/utGenNormals.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utHMPImportExport.cpp b/test/unit/utHMPImportExport.cpp
index 83e7ba09d..8171bb26a 100644
--- a/test/unit/utHMPImportExport.cpp
+++ b/test/unit/utHMPImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utIFCImportExport.cpp b/test/unit/utIFCImportExport.cpp
index 49c7446c7..06009be2b 100644
--- a/test/unit/utIFCImportExport.cpp
+++ b/test/unit/utIFCImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utIOStreamBuffer.cpp b/test/unit/utIOStreamBuffer.cpp
index 7565014c1..381716040 100644
--- a/test/unit/utIOStreamBuffer.cpp
+++ b/test/unit/utIOStreamBuffer.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utIOSystem.cpp b/test/unit/utIOSystem.cpp
index d69e645fe..5bc9996b0 100644
--- a/test/unit/utIOSystem.cpp
+++ b/test/unit/utIOSystem.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utImporter.cpp b/test/unit/utImporter.cpp
index 5ecc45e34..2470283c0 100644
--- a/test/unit/utImporter.cpp
+++ b/test/unit/utImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utImproveCacheLocality.cpp b/test/unit/utImproveCacheLocality.cpp
index 0e97eb0c7..269721eda 100644
--- a/test/unit/utImproveCacheLocality.cpp
+++ b/test/unit/utImproveCacheLocality.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utIssues.cpp b/test/unit/utIssues.cpp
index 546c36ad0..4a3fa1585 100644
--- a/test/unit/utIssues.cpp
+++ b/test/unit/utIssues.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utJoinVertices.cpp b/test/unit/utJoinVertices.cpp
index b0700900c..9dbe87536 100644
--- a/test/unit/utJoinVertices.cpp
+++ b/test/unit/utJoinVertices.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utLWOImportExport.cpp b/test/unit/utLWOImportExport.cpp
index 2ab1c4722..78572a7db 100644
--- a/test/unit/utLWOImportExport.cpp
+++ b/test/unit/utLWOImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utLWSImportExport.cpp b/test/unit/utLWSImportExport.cpp
index 730911ec2..3f9c62361 100644
--- a/test/unit/utLWSImportExport.cpp
+++ b/test/unit/utLWSImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utLimitBoneWeights.cpp b/test/unit/utLimitBoneWeights.cpp
index bf3ea93f5..5a543aa2b 100644
--- a/test/unit/utLimitBoneWeights.cpp
+++ b/test/unit/utLimitBoneWeights.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utMDCImportExport.cpp b/test/unit/utMDCImportExport.cpp
index 29b9ed56c..d5b8dee0b 100644
--- a/test/unit/utMDCImportExport.cpp
+++ b/test/unit/utMDCImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utMaterialSystem.cpp b/test/unit/utMaterialSystem.cpp
index a84ae8333..8b1691b3f 100644
--- a/test/unit/utMaterialSystem.cpp
+++ b/test/unit/utMaterialSystem.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utMatrix3x3.cpp b/test/unit/utMatrix3x3.cpp
index ae722a811..54bbece7d 100644
--- a/test/unit/utMatrix3x3.cpp
+++ b/test/unit/utMatrix3x3.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utMatrix4x4.cpp b/test/unit/utMatrix4x4.cpp
index 795971afc..510900e82 100644
--- a/test/unit/utMatrix4x4.cpp
+++ b/test/unit/utMatrix4x4.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -90,3 +90,17 @@ TEST_F(utMatrix4x4, indexOperatorTest) {
ai_real *a15 = a12 + 3;
EXPECT_FLOAT_EQ(1.0, *a15);
}
+
+TEST_F(utMatrix4x4, identityMatrixTest) {
+ aiMatrix4x4 m1 = aiMatrix4x4(1.f,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0, 1);
+ EXPECT_TRUE(m1.IsIdentity());
+ aiMatrix4x4 m2 = aiMatrix4x4(1.02f,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0, 1);
+ EXPECT_FALSE(m2.IsIdentity());
+ aiMatrix4x4 m3 = aiMatrix4x4(1.009f,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0, 1);
+ EXPECT_TRUE(m3.IsIdentity());
+
+ EXPECT_TRUE(m1.IsIdentity(1e-3f));
+ EXPECT_FALSE(m2.IsIdentity(1e-3f));
+ EXPECT_TRUE(m2.IsIdentity(1e-1f));
+ EXPECT_FALSE(m3.IsIdentity(1e-3f));
+}
diff --git a/test/unit/utMetadata.cpp b/test/unit/utMetadata.cpp
index 676404c3c..e7cd239aa 100644
--- a/test/unit/utMetadata.cpp
+++ b/test/unit/utMetadata.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utObjImportExport.cpp b/test/unit/utObjImportExport.cpp
index ce778a950..8e9b4e633 100644
--- a/test/unit/utObjImportExport.cpp
+++ b/test/unit/utObjImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utObjTools.cpp b/test/unit/utObjTools.cpp
index f2e5304ad..f1437ff32 100644
--- a/test/unit/utObjTools.cpp
+++ b/test/unit/utObjTools.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utOpenGEXImportExport.cpp b/test/unit/utOpenGEXImportExport.cpp
index ed22a6fb7..51da9e237 100644
--- a/test/unit/utOpenGEXImportExport.cpp
+++ b/test/unit/utOpenGEXImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utPLYImportExport.cpp b/test/unit/utPLYImportExport.cpp
index 1f733c0e7..e748a40cf 100644
--- a/test/unit/utPLYImportExport.cpp
+++ b/test/unit/utPLYImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -196,3 +196,10 @@ TEST_F(utPLYImportExport, parseErrorTest) {
const aiScene *scene = importer.ReadFileFromMemory(test_file, strlen(test_file), 0);
EXPECT_NE(nullptr, scene);
}
+
+// This file is invalid, we just want to ensure that the importer is not crashing
+TEST_F(utPLYImportExport, parseInvalid) {
+ Assimp::Importer importer;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/invalid/crash-30d6d0f7c529b3b66b4131700b7a4580cd7082df.ply", 0);
+ EXPECT_EQ(nullptr, scene);
+}
diff --git a/test/unit/utPMXImporter.cpp b/test/unit/utPMXImporter.cpp
index 167fb234a..a5aba923b 100644
--- a/test/unit/utPMXImporter.cpp
+++ b/test/unit/utPMXImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utPretransformVertices.cpp b/test/unit/utPretransformVertices.cpp
index b3ae818bc..9652ec611 100644
--- a/test/unit/utPretransformVertices.cpp
+++ b/test/unit/utPretransformVertices.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utProfiler.cpp b/test/unit/utProfiler.cpp
index 6738d568e..a9a54a934 100644
--- a/test/unit/utProfiler.cpp
+++ b/test/unit/utProfiler.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utQ3DImportExport.cpp b/test/unit/utQ3DImportExport.cpp
index e5396a680..4fb71bb69 100644
--- a/test/unit/utQ3DImportExport.cpp
+++ b/test/unit/utQ3DImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utRemoveComments.cpp b/test/unit/utRemoveComments.cpp
index 44fb56ef8..f101b7d9e 100644
--- a/test/unit/utRemoveComments.cpp
+++ b/test/unit/utRemoveComments.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utRemoveComponent.cpp b/test/unit/utRemoveComponent.cpp
index dd9e4f9cb..5fbfe612c 100644
--- a/test/unit/utRemoveComponent.cpp
+++ b/test/unit/utRemoveComponent.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utRemoveRedundantMaterials.cpp b/test/unit/utRemoveRedundantMaterials.cpp
index 99b91aa5f..5c9983859 100644
--- a/test/unit/utRemoveRedundantMaterials.cpp
+++ b/test/unit/utRemoveRedundantMaterials.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utRemoveVCProcess.cpp b/test/unit/utRemoveVCProcess.cpp
index b555b0c86..fdb4049b9 100644
--- a/test/unit/utRemoveVCProcess.cpp
+++ b/test/unit/utRemoveVCProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utSIBImporter.cpp b/test/unit/utSIBImporter.cpp
index b36e0883f..e2deb85c2 100644
--- a/test/unit/utSIBImporter.cpp
+++ b/test/unit/utSIBImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utSMDImportExport.cpp b/test/unit/utSMDImportExport.cpp
index 08683d554..6e2bc08e7 100644
--- a/test/unit/utSMDImportExport.cpp
+++ b/test/unit/utSMDImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utSTLImportExport.cpp b/test/unit/utSTLImportExport.cpp
index 4bf374a1b..7e2c29168 100644
--- a/test/unit/utSTLImportExport.cpp
+++ b/test/unit/utSTLImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utScaleProcess.cpp b/test/unit/utScaleProcess.cpp
index baa13ab52..5772d4883 100644
--- a/test/unit/utScaleProcess.cpp
+++ b/test/unit/utScaleProcess.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utSceneCombiner.cpp b/test/unit/utSceneCombiner.cpp
index d837e4dce..055b54f5b 100644
--- a/test/unit/utSceneCombiner.cpp
+++ b/test/unit/utSceneCombiner.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utScenePreprocessor.cpp b/test/unit/utScenePreprocessor.cpp
index 45d8a36ee..5e3dd95ce 100644
--- a/test/unit/utScenePreprocessor.cpp
+++ b/test/unit/utScenePreprocessor.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utSharedPPData.cpp b/test/unit/utSharedPPData.cpp
index 16ee9c75f..f70d352ff 100644
--- a/test/unit/utSharedPPData.cpp
+++ b/test/unit/utSharedPPData.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utSimd.cpp b/test/unit/utSimd.cpp
index 720d657b6..3f073b475 100644
--- a/test/unit/utSimd.cpp
+++ b/test/unit/utSimd.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utSortByPType.cpp b/test/unit/utSortByPType.cpp
index 5fd360fcc..ff8b717ef 100644
--- a/test/unit/utSortByPType.cpp
+++ b/test/unit/utSortByPType.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utSplitLargeMeshes.cpp b/test/unit/utSplitLargeMeshes.cpp
index 160831baa..b8bab7193 100644
--- a/test/unit/utSplitLargeMeshes.cpp
+++ b/test/unit/utSplitLargeMeshes.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utStringUtils.cpp b/test/unit/utStringUtils.cpp
index 9c5ab31f5..7cb11797d 100644
--- a/test/unit/utStringUtils.cpp
+++ b/test/unit/utStringUtils.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utTargetAnimation.cpp b/test/unit/utTargetAnimation.cpp
index 9cbb45309..2711e895c 100644
--- a/test/unit/utTargetAnimation.cpp
+++ b/test/unit/utTargetAnimation.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utTextureTransform.cpp b/test/unit/utTextureTransform.cpp
index 9cbb45309..2711e895c 100644
--- a/test/unit/utTextureTransform.cpp
+++ b/test/unit/utTextureTransform.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utTriangulate.cpp b/test/unit/utTriangulate.cpp
index f51daea63..2df0ce6cd 100644
--- a/test/unit/utTriangulate.cpp
+++ b/test/unit/utTriangulate.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utTypes.cpp b/test/unit/utTypes.cpp
index 33d2b4f76..45a4b5517 100644
--- a/test/unit/utTypes.cpp
+++ b/test/unit/utTypes.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/test/unit/utVector3.cpp b/test/unit/utVector3.cpp
index 2602c287c..f13521894 100644
--- a/test/unit/utVector3.cpp
+++ b/test/unit/utVector3.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utVersion.cpp b/test/unit/utVersion.cpp
index e4378e9f6..838d2dd7f 100644
--- a/test/unit/utVersion.cpp
+++ b/test/unit/utVersion.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -48,18 +48,18 @@ TEST_F( utVersion, aiGetLegalStringTest ) {
EXPECT_NE( lv, nullptr );
std::string text( lv );
- size_t pos = text.find(std::string("2023"));
+ size_t pos = text.find(std::string("2024"));
EXPECT_NE(pos, std::string::npos);
}
-TEST_F( utVersion, aiGetVersionMinorTest ) {
- EXPECT_EQ(aiGetVersionMinor(), 3U);
-}
-
TEST_F( utVersion, aiGetVersionMajorTest ) {
EXPECT_EQ( aiGetVersionMajor(), 5U );
}
+TEST_F( utVersion, aiGetVersionMinorTest ) {
+ EXPECT_EQ(aiGetVersionMinor(), 4U);
+}
+
TEST_F( utVersion, aiGetVersionPatchTest ) {
EXPECT_EQ(aiGetVersionPatch(), 0U );
}
diff --git a/test/unit/utVertexTriangleAdjacency.cpp b/test/unit/utVertexTriangleAdjacency.cpp
index 8c8d9db04..f5ad492ef 100644
--- a/test/unit/utVertexTriangleAdjacency.cpp
+++ b/test/unit/utVertexTriangleAdjacency.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utX3DImportExport.cpp b/test/unit/utX3DImportExport.cpp
index f2df81ac2..b0b6802b9 100644
--- a/test/unit/utX3DImportExport.cpp
+++ b/test/unit/utX3DImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
+#include <assimp/scene.h>
using namespace Assimp;
@@ -59,3 +60,16 @@ public:
TEST_F(utX3DImportExport, importX3DFromFileTest) {
EXPECT_TRUE(importerTest());
}
+
+TEST_F(utX3DImportExport, importX3DIndexedLineSet) {
+ Assimp::Importer importer;
+ const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X3D/IndexedLineSet.x3d", aiProcess_ValidateDataStructure);
+ ASSERT_NE(nullptr, scene);
+ ASSERT_EQ(scene->mNumMeshes, 1u);
+ ASSERT_EQ(scene->mMeshes[0]->mNumFaces, 4u);
+ ASSERT_EQ(scene->mMeshes[0]->mPrimitiveTypes, aiPrimitiveType_LINE);
+ ASSERT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
+ for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; i++) {
+ ASSERT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2u);
+ }
+}
diff --git a/test/unit/utXImporterExporter.cpp b/test/unit/utXImporterExporter.cpp
index 4d247cc6f..807e3ca83 100644
--- a/test/unit/utXImporterExporter.cpp
+++ b/test/unit/utXImporterExporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp
index ba1c859ad..c29d17d33 100644
--- a/test/unit/utglTF2ImportExport.cpp
+++ b/test/unit/utglTF2ImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/commonMetaData.h>
#include <assimp/postprocess.h>
+#include <assimp/config.h>
#include <assimp/scene.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
@@ -504,6 +505,143 @@ TEST_F(utglTF2ImportExport, bug_import_simple_skin) {
EXPECT_NE(nullptr, scene);
}
+bool checkSkinnedScene(const aiScene *scene){
+ float eps = 0.001f;
+ bool result = true;
+ EXPECT_EQ(scene->mNumMeshes, 1u);
+ EXPECT_EQ(scene->mMeshes[0]->mNumBones, 10u);
+ EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[0].x - -1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[0].y - -1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[0].z - 0), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[1].x - 1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[1].y - -1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[1].z - 0), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[2].x - 1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[2].y - 1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[2].z - 0), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[3].x - -1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[3].y - 1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[3].z - 0), eps);
+
+ unsigned int numWeights[] = {4u, 4u, 4u, 4u, 2u , 1u, 1u, 2u, 1u, 1u};
+ float weights[10][4] = {{0.207f, 0.291f, 0.057f, 0.303f},
+ {0.113f, 0.243f, 0.499f, 0.251f},
+ {0.005f, 0.010f, 0.041f, 0.093f},
+ {0.090f, 0.234f, 0.404f, 0.243f},
+ {0.090f, 0.222f, 0.000f, 0.000f},
+ {0.216f, 0.000f, 0.000f, 0.000f},
+ {0.058f, 0.000f, 0.000f, 0.000f},
+ {0.086f, 0.000f, 0.000f, 0.111f},
+ {0.088f, 0.000f, 0.000f, 0.000f},
+ {0.049f, 0.000f, 0.000f, 0.000f}};
+ for (size_t boneIndex = 0; boneIndex < 10u; ++boneIndex) {
+ EXPECT_EQ(scene->mMeshes[0]->mBones[boneIndex]->mNumWeights, numWeights[boneIndex]);
+ std::map<unsigned int, float> map;
+ for (size_t jointIndex = 0; jointIndex < scene->mMeshes[0]->mBones[boneIndex]->mNumWeights; ++jointIndex){
+ auto key = scene->mMeshes[0]->mBones[boneIndex]->mWeights[jointIndex].mVertexId;
+ auto weight = scene->mMeshes[0]->mBones[boneIndex]->mWeights[jointIndex].mWeight;
+ map[key] = weight;
+ }
+
+ for (unsigned int jointIndex = 0; jointIndex < scene->mMeshes[0]->mBones[boneIndex]->mNumWeights; ++jointIndex) {
+ auto weight = map[jointIndex];
+ EXPECT_LT(abs(ai_real(weight) - ai_real(weights[boneIndex][jointIndex])), 0.002);
+ }
+ }
+
+ return result;
+}
+
+void checkSkinnedSceneLimited(const aiScene *scene){
+ float eps = 0.001f;
+ EXPECT_EQ(scene->mNumMeshes, 1u);
+ EXPECT_EQ(scene->mMeshes[0]->mNumBones, 10u);
+ EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[0].x - -1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[0].y - -1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[0].z - 0), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[1].x - 1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[1].y - -1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[1].z - 0), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[2].x - 1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[2].y - 1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[2].z - 0), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[3].x - -1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[3].y - 1), eps);
+ EXPECT_LT(abs(scene->mMeshes[0]->mVertices[3].z - 0), eps);
+
+ unsigned int numWeights[] = {4u, 4u, 1u, 4u, 1u , 1u, 1u, 1u, 1u, 1u};
+ float weights[10][4] = {{0.207f, 0.291f, 0.057f, 0.303f},
+ {0.113f, 0.243f, 0.499f, 0.251f},
+ {0.000f, 0.000f, 0.041f, 0.000f},
+ {0.090f, 0.234f, 0.404f, 0.243f},
+ {0.000f, 0.222f, 0.000f, 0.000f},
+ {0.216f, 0.000f, 0.000f, 0.000f},
+ {0.000f, 0.000f, 0.000f, 0.000f},
+ {0.000f, 0.000f, 0.000f, 0.111f},
+ {0.000f, 0.000f, 0.000f, 0.000f},
+ {0.000f, 0.000f, 0.000f, 0.000f}};
+ for (unsigned int boneIndex = 0; boneIndex < 10u; ++boneIndex) {
+ EXPECT_EQ(scene->mMeshes[0]->mBones[boneIndex]->mNumWeights, numWeights[boneIndex]);
+ std::map<unsigned int, float> map;
+ for (unsigned int jointIndex = 0; jointIndex < scene->mMeshes[0]->mBones[boneIndex]->mNumWeights; ++jointIndex){
+ auto key = scene->mMeshes[0]->mBones[boneIndex]->mWeights[jointIndex].mVertexId;
+ auto weight = scene->mMeshes[0]->mBones[boneIndex]->mWeights[jointIndex].mWeight;
+ map[key] = weight;
+ }
+ for (unsigned int jointIndex = 0; jointIndex < scene->mMeshes[0]->mBones[boneIndex]->mNumWeights; ++jointIndex) {
+ auto weight = map[jointIndex];
+ EXPECT_LT(std::abs(ai_real(weight) - ai_real(weights[boneIndex][jointIndex])), 0.002);
+ }
+ }
+}
+
+TEST_F(utglTF2ImportExport, bug_import_simple_skin2) {
+ Assimp::Importer importer;
+ Assimp::Exporter exporter;
+ const aiScene *scene = importer.ReadFile(
+ ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/quad_skin.glb",
+ aiProcess_ValidateDataStructure);
+ checkSkinnedScene(scene);
+
+ ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2",
+ ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/quad_four_out.glb"));
+ ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "gltf2",
+ ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/quad_four_out.gltf"));
+
+ // enable more than four bones per vertex
+ Assimp::ExportProperties properties = Assimp::ExportProperties();
+ properties.SetPropertyBool(
+ AI_CONFIG_EXPORT_GLTF_UNLIMITED_SKINNING_BONES_PER_VERTEX, true);
+ ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "glb2",
+ ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/quad_all_out.glb", 0u, &properties));
+ ASSERT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "gltf2",
+ ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/quad_all_out.gltf", 0u, &properties));
+
+ // check skinning data of both exported files for limited number bones per vertex
+ const aiScene *limitedSceneImported = importer.ReadFile(
+ ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/quad_four_out.gltf",
+ aiProcess_ValidateDataStructure);
+ checkSkinnedSceneLimited(limitedSceneImported);
+ limitedSceneImported = importer.ReadFile(
+ ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/quad_four_out.glb",
+ aiProcess_ValidateDataStructure);
+ checkSkinnedSceneLimited(limitedSceneImported);
+
+ // check skinning data of both exported files for unlimited number bones per vertex
+ const aiScene *sceneImported = importer.ReadFile(
+ ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/quad_all_out.gltf",
+ aiProcess_ValidateDataStructure);
+ checkSkinnedScene(sceneImported);
+ sceneImported = importer.ReadFile(
+ ASSIMP_TEST_MODELS_DIR "/glTF2/simple_skin/quad_all_out.glb",
+ aiProcess_ValidateDataStructure);
+ checkSkinnedScene(sceneImported);
+
+
+}
+
TEST_F(utglTF2ImportExport, import_cameras) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/cameras/Cameras.gltf",
@@ -850,3 +988,27 @@ TEST_F(utglTF2ImportExport, noSchemaFound) {
EXPECT_NE(scene, nullptr);
EXPECT_STREQ(importer.GetErrorString(), "");
}
+
+// ------------------------------------------------------------------------------------------------
+TEST_F(utglTF2ImportExport, testSetIdentityMatrixEpsilon) {
+// Assimp::Exporter exporter;
+ Assimp::ExportProperties properties = Assimp::ExportProperties();
+ EXPECT_EQ(AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT,
+ properties.GetPropertyFloat("CHECK_IDENTITY_MATRIX_EPSILON",
+ AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT));
+ aiMatrix4x4 m;
+ m = aiMatrix4x4(1.02f, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
+ EXPECT_FALSE(m.IsIdentity());
+ m = aiMatrix4x4(1.001f, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
+ EXPECT_TRUE(m.IsIdentity());
+
+ bool b = properties.SetPropertyFloat("CHECK_IDENTITY_MATRIX_EPSILON", 0.0001f);
+ EXPECT_TRUE(!b);
+ ai_real epsilon = properties.GetPropertyFloat("CHECK_IDENTITY_MATRIX_EPSILON", 0.01f);
+ EXPECT_EQ(0.0001f, epsilon);
+ m = aiMatrix4x4(1.0002f, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
+ EXPECT_FALSE(m.IsIdentity(epsilon));
+ m = aiMatrix4x4(1.00009f, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
+ EXPECT_TRUE(m.IsIdentity(epsilon));
+}
+
diff --git a/test/unit/utglTFImportExport.cpp b/test/unit/utglTFImportExport.cpp
index cb20c1519..9d1cebc54 100644
--- a/test/unit/utglTFImportExport.cpp
+++ b/test/unit/utglTFImportExport.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_cmd/CMakeLists.txt b/tools/assimp_cmd/CMakeLists.txt
index 5b80ee77b..2f4486723 100644
--- a/tools/assimp_cmd/CMakeLists.txt
+++ b/tools/assimp_cmd/CMakeLists.txt
@@ -1,7 +1,7 @@
# Open Asset Import Library (assimp)
# ----------------------------------------------------------------------
#
-# Copyright (c) 2006-2022, assimp team
+# Copyright (c) 2006-2024, assimp team
# All rights reserved.
#
# Redistribution and use of this software in source and binary forms,
diff --git a/tools/assimp_cmd/CompareDump.cpp b/tools/assimp_cmd/CompareDump.cpp
index 3cf22bb28..5ea162cae 100644
--- a/tools/assimp_cmd/CompareDump.cpp
+++ b/tools/assimp_cmd/CompareDump.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/tools/assimp_cmd/Export.cpp b/tools/assimp_cmd/Export.cpp
index b78db157b..2961bad2c 100644
--- a/tools/assimp_cmd/Export.cpp
+++ b/tools/assimp_cmd/Export.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_cmd/ImageExtractor.cpp b/tools/assimp_cmd/ImageExtractor.cpp
index 49edf9790..6469db42b 100644
--- a/tools/assimp_cmd/ImageExtractor.cpp
+++ b/tools/assimp_cmd/ImageExtractor.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_cmd/Info.cpp b/tools/assimp_cmd/Info.cpp
index d67974269..18cf1a1c1 100644
--- a/tools/assimp_cmd/Info.cpp
+++ b/tools/assimp_cmd/Info.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp
index 06c44f029..aa7a137de 100644
--- a/tools/assimp_cmd/Main.cpp
+++ b/tools/assimp_cmd/Main.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_cmd/Main.h b/tools/assimp_cmd/Main.h
index a95bc96f6..a3329dd0b 100644
--- a/tools/assimp_cmd/Main.h
+++ b/tools/assimp_cmd/Main.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_cmd/WriteDump.cpp b/tools/assimp_cmd/WriteDump.cpp
index 4ada408fd..d922d7947 100644
--- a/tools/assimp_cmd/WriteDump.cpp
+++ b/tools/assimp_cmd/WriteDump.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/AnimEvaluator.cpp b/tools/assimp_view/AnimEvaluator.cpp
index 4f8d1bda8..206afb284 100644
--- a/tools/assimp_view/AnimEvaluator.cpp
+++ b/tools/assimp_view/AnimEvaluator.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/AnimEvaluator.h b/tools/assimp_view/AnimEvaluator.h
index aa44ab211..854b232dd 100644
--- a/tools/assimp_view/AnimEvaluator.h
+++ b/tools/assimp_view/AnimEvaluator.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/AssetHelper.h b/tools/assimp_view/AssetHelper.h
index 8661d875f..16648f9c7 100644
--- a/tools/assimp_view/AssetHelper.h
+++ b/tools/assimp_view/AssetHelper.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/Background.cpp b/tools/assimp_view/Background.cpp
index e49630204..6943115df 100644
--- a/tools/assimp_view/Background.cpp
+++ b/tools/assimp_view/Background.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt
index a5a9eed35..e8c354fc8 100644
--- a/tools/assimp_view/CMakeLists.txt
+++ b/tools/assimp_view/CMakeLists.txt
@@ -1,7 +1,7 @@
# Open Asset Import Library (assimp)
# ----------------------------------------------------------------------
#
-# Copyright (c) 2006-2022, assimp team
+# Copyright (c) 2006-2024, assimp team
# All rights reserved.
diff --git a/tools/assimp_view/Display.cpp b/tools/assimp_view/Display.cpp
index 95ed41615..5020d65ca 100644
--- a/tools/assimp_view/Display.cpp
+++ b/tools/assimp_view/Display.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -518,20 +518,19 @@ int CDisplay::AddTextureToDisplayList(unsigned int iType,
return 1;
}
//-------------------------------------------------------------------------------
-int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
- unsigned int iIndex)
-{
+int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot, unsigned int iIndex) {
ai_assert(nullptr != hRoot);
aiMaterial* pcMat = g_pcAsset->pcScene->mMaterials[iIndex];
+ if (g_pcAsset->pcScene->mNumMeshes == 0) {
+ return -1;
+ }
// find the first mesh using this material index
unsigned int iMesh = 0;
- for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
- {
- if (iIndex == g_pcAsset->pcScene->mMeshes[i]->mMaterialIndex)
- {
+ for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i) {
+ if (iIndex == g_pcAsset->pcScene->mMeshes[i]->mMaterialIndex) {
iMesh = i;
break;
}
@@ -540,12 +539,9 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
// use the name of the material, if possible
char chTemp[512];
aiString szOut;
- if (AI_SUCCESS != aiGetMaterialString(pcMat,AI_MATKEY_NAME,&szOut))
- {
+ if (AI_SUCCESS != aiGetMaterialString(pcMat,AI_MATKEY_NAME,&szOut)) {
ai_snprintf(chTemp,512,"Material %i",iIndex+1);
- }
- else
- {
+ } else {
ai_snprintf(chTemp,512,"%s (%i)",szOut.data,iIndex+1);
}
TVITEMEXW tvi;
@@ -577,17 +573,15 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
aiTextureOp eOp;
aiString szPath;
bool bNoOpacity = true;
- for (unsigned int i = 0; i <= AI_TEXTURE_TYPE_MAX;++i)
- {
+ for (unsigned int i = 0; i <= AI_TEXTURE_TYPE_MAX;++i) {
unsigned int iNum = 0;
- while (true)
- {
- if (AI_SUCCESS != aiGetMaterialTexture(pcMat,(aiTextureType)i,iNum,
- &szPath,nullptr, &iUV,&fBlend,&eOp))
- {
+ while (true) {
+ if (AI_SUCCESS != aiGetMaterialTexture(pcMat,(aiTextureType)i,iNum, &szPath,nullptr, &iUV,&fBlend,&eOp)) {
break;
}
- if (aiTextureType_OPACITY == i)bNoOpacity = false;
+ if (aiTextureType_OPACITY == i) {
+ bNoOpacity = false;
+ }
AddTextureToDisplayList(i,iNum,&szPath,hTexture,iUV,fBlend,eOp,iMesh);
++iNum;
}
@@ -595,8 +589,7 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
AssetHelper::MeshHelper* pcMesh = g_pcAsset->apcMeshes[iMesh];
- if (pcMesh->piDiffuseTexture && pcMesh->piDiffuseTexture == pcMesh->piOpacityTexture && bNoOpacity)
- {
+ if (pcMesh->piDiffuseTexture && pcMesh->piDiffuseTexture == pcMesh->piOpacityTexture && bNoOpacity) {
// check whether the diffuse texture is not a default texture
// {9785DA94-1D96-426b-B3CB-BADC36347F5E}
@@ -606,9 +599,7 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
uint32_t iData = 0;
DWORD dwSize = 4;
- if(FAILED( pcMesh->piDiffuseTexture->GetPrivateData(guidPrivateData,&iData,&dwSize) ||
- 0xffffffff == iData))
- {
+ if(FAILED( pcMesh->piDiffuseTexture->GetPrivateData(guidPrivateData,&iData,&dwSize) || 0xffffffff == iData)) {
// seems the diffuse texture contains alpha, therefore it has been
// added to the opacity channel, too. Add a special value ...
AddTextureToDisplayList(aiTextureType_OPACITY | 0x40000000,
@@ -625,33 +616,26 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
this->AddMaterial(info);
return 1;
}
+
//-------------------------------------------------------------------------------
// Expand all elements in the tree-view
-int CDisplay::ExpandTree()
-{
+int CDisplay::ExpandTree() {
// expand all materials
- for (std::vector< MaterialInfo >::iterator
- i = m_asMaterials.begin();
- i != m_asMaterials.end();++i)
- {
+ for (std::vector< MaterialInfo >::iterator i = m_asMaterials.begin(); i != m_asMaterials.end();++i) {
TreeView_Expand(GetDlgItem(g_hDlg,IDC_TREE1),(*i).hTreeItem,TVE_EXPAND);
}
// expand all nodes
- for (std::vector< NodeInfo >::iterator
- i = m_asNodes.begin();
- i != m_asNodes.end();++i)
- {
+ for (std::vector< NodeInfo >::iterator i = m_asNodes.begin(); i != m_asNodes.end();++i) {
TreeView_Expand(GetDlgItem(g_hDlg,IDC_TREE1),(*i).hTreeItem,TVE_EXPAND);
}
TreeView_Expand(GetDlgItem(g_hDlg,IDC_TREE1),m_hRoot,TVE_EXPAND);
return 1;
}
+
//-------------------------------------------------------------------------------
// Get image list for tree view
-int CDisplay::LoadImageList(void)
-{
- if (!m_hImageList)
- {
+int CDisplay::LoadImageList() {
+ if (!m_hImageList) {
// First, create the image list we will need.
// FIX: Need RGB888 color space to display all colors correctly
HIMAGELIST hIml = ImageList_Create( 16,16,ILC_COLOR24, 5, 0 );
@@ -682,12 +666,13 @@ int CDisplay::LoadImageList(void)
m_hImageList = hIml;
}
+
return 1;
}
+
//-------------------------------------------------------------------------------
// Fill tree view
-int CDisplay::FillDisplayList(void)
-{
+int CDisplay::FillDisplayList(void) {
LoadImageList();
// Initialize the tree view window.
@@ -713,11 +698,11 @@ int CDisplay::FillDisplayList(void)
(LPARAM)(LPTVINSERTSTRUCT)&sNew);
// add each loaded material to the tree
- for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMaterials;++i)
+ for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMaterials; ++i)
AddMaterialToDisplayList(m_hRoot,i);
// add each mesh to the tree
- for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
+ for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i)
AddMeshToDisplayList(i,m_hRoot);
// now add all loaded nodes recursively
@@ -729,8 +714,10 @@ int CDisplay::FillDisplayList(void)
// everything reacts a little bit slowly if D3D is rendering,
// so give GDI a small hint to leave the couch and work ;-)
UpdateWindow(g_hDlg);
+
return 1;
}
+
//-------------------------------------------------------------------------------
// Main render loop
int CDisplay::OnRender()
diff --git a/tools/assimp_view/HelpDialog.cpp b/tools/assimp_view/HelpDialog.cpp
index fde4e1caf..700619a6c 100644
--- a/tools/assimp_view/HelpDialog.cpp
+++ b/tools/assimp_view/HelpDialog.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/Input.cpp b/tools/assimp_view/Input.cpp
index b8572d792..f9bda0451 100644
--- a/tools/assimp_view/Input.cpp
+++ b/tools/assimp_view/Input.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/LogDisplay.cpp b/tools/assimp_view/LogDisplay.cpp
index 1bd650c08..41777856f 100644
--- a/tools/assimp_view/LogDisplay.cpp
+++ b/tools/assimp_view/LogDisplay.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/LogWindow.cpp b/tools/assimp_view/LogWindow.cpp
index 8e80bf564..24a359f19 100644
--- a/tools/assimp_view/LogWindow.cpp
+++ b/tools/assimp_view/LogWindow.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/Material.cpp b/tools/assimp_view/Material.cpp
index c28231332..2337f13fa 100644
--- a/tools/assimp_view/Material.cpp
+++ b/tools/assimp_view/Material.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/MaterialManager.h b/tools/assimp_view/MaterialManager.h
index b708fb337..577f81a6b 100644
--- a/tools/assimp_view/MaterialManager.h
+++ b/tools/assimp_view/MaterialManager.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/MeshRenderer.cpp b/tools/assimp_view/MeshRenderer.cpp
index 655e99d0b..710ce1cce 100644
--- a/tools/assimp_view/MeshRenderer.cpp
+++ b/tools/assimp_view/MeshRenderer.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/MessageProc.cpp b/tools/assimp_view/MessageProc.cpp
index aea65a8d5..5acdafb68 100644
--- a/tools/assimp_view/MessageProc.cpp
+++ b/tools/assimp_view/MessageProc.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/Normals.cpp b/tools/assimp_view/Normals.cpp
index b76408939..32c5a486a 100644
--- a/tools/assimp_view/Normals.cpp
+++ b/tools/assimp_view/Normals.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/SceneAnimator.cpp b/tools/assimp_view/SceneAnimator.cpp
index c8b20229e..f24f2018f 100644
--- a/tools/assimp_view/SceneAnimator.cpp
+++ b/tools/assimp_view/SceneAnimator.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/SceneAnimator.h b/tools/assimp_view/SceneAnimator.h
index 454357f30..444f71014 100644
--- a/tools/assimp_view/SceneAnimator.h
+++ b/tools/assimp_view/SceneAnimator.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/Shaders.cpp b/tools/assimp_view/Shaders.cpp
index 9fd05ca8d..10e89e696 100644
--- a/tools/assimp_view/Shaders.cpp
+++ b/tools/assimp_view/Shaders.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp
index e00c6e39d..c2c8bfd4a 100644
--- a/tools/assimp_view/assimp_view.cpp
+++ b/tools/assimp_view/assimp_view.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -291,7 +291,7 @@ int LoadAsset() {
//-------------------------------------------------------------------------------
// Delete the loaded asset
-// The function does nothing is no asset is loaded
+// The function does nothing if no asset is loaded
//-------------------------------------------------------------------------------
int DeleteAsset(void) {
if (!g_pcAsset) {
diff --git a/tools/assimp_view/assimp_view.h b/tools/assimp_view/assimp_view.h
index e67cc9fd0..f5c08559d 100644
--- a/tools/assimp_view/assimp_view.h
+++ b/tools/assimp_view/assimp_view.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/tools/make/build_env_win32.bat b/tools/make/build_env_win32.bat
deleted file mode 100644
index 4b8b4674b..000000000
--- a/tools/make/build_env_win32.bat
+++ /dev/null
@@ -1,57 +0,0 @@
-@echo off
-set "initialdir=%cd%"
-goto:main
-
-:exitsucc
-cd /d "%initialdir%"
-set initialdir=
-
-set MSBUILD_15="C:\Program Files (x86)\Microsoft Visual Studio\2018\Professional\MSBuild\15.0\Bin\msbuild.exe"
-set MSBUILD_14="C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe"
-
-if not "%VS150%"=="" set MSBUILD_15="%VS150%\MSBuild\15.0\Bin\msbuild.exe"
-
-if /i %VS_VERSION%==2017 (
- set MS_BUILD_EXE=%MSBUILD_15%
- set PLATFORM_VER=v141
-) else (
- set MS_BUILD_EXE=%MSBUILD_14%
- set PLATFORM_VER=v140
-)
-
-set MSBUILD=%MS_BUILD_EXE%
-
-exit /b 0
-
-:main
-if not defined PLATFORM set "PLATFORM=x64"
-
-::my work here is done?
-
-set PATH_VSWHERE=C:\Program Files (x86)\Microsoft Visual Studio\Installer\
-REM set PATH_STUDIO="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\"
-
-for /f "usebackq tokens=*" %%i in (`"%PATH_VSWHERE%vswhere" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
- set InstallDir=%%i
-)
-
-IF EXIST "%InstallDir%\VC\Auxiliary\Build\vcvarsall.bat" set VS150=%InstallDir%\
-
-set "CMAKE_GENERATOR=Visual Studio 15 2017 Win64"
-if not "%VS150%"=="" call "%VS150%\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM% && echo found VS 2o17 && set PLATFORM_VER=v141 && set VS_VERSION=2017 && goto:exitsucc
-
-set "CMAKE_GENERATOR=Visual Studio 14 2015 Win64"
-if defined VS140COMNTOOLS call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o15 && set PLATFORM_VER=v140 && set VS_VERSION=2015 && goto:exitsucc
-
-if defined VS130COMNTOOLS echo call ghostbusters... found lost VS version
-
-set "CMAKE_GENERATOR=Visual Studio 12 2013 Win64"
-if defined VS120COMNTOOLS call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o13 && set PLATFORM_VER=v120 && set VS_VERSION=2013 && goto:exitsucc
-
-set "CMAKE_GENERATOR=Visual Studio 11 2012 Win64"
-if defined VS110COMNTOOLS call "%VS110COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o12 && set PLATFORM_VER=v110 && set VS_VERSION=2012 && goto:exitsucc
-
-set "CMAKE_GENERATOR=Visual Studio 10 2010 Win64"
-if defined VS100COMNTOOLS call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" %PLATFORM% && echo found VS 2o1o && set PLATFORM_VER=v100 && set VS_VERSION=2010 && goto:exitsucc
-
-goto:exitsucc \ No newline at end of file
diff --git a/tools/make/make_all_win32_x64.bat b/tools/make/make_all_win32_x64.bat
deleted file mode 100644
index 4a1e663e6..000000000
--- a/tools/make/make_all_win32_x64.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-rem @echo off
-setlocal
-call build_env_win32.bat
-
-set BUILD_CONFIG=release
-set PLATFORM_CONFIG=x64
-set MAX_CPU_CONFIG=4
-
-set CONFIG_PARAMETER=/p:Configuration="%BUILD_CONFIG%"
-set PLATFORM_PARAMETER=/p:Platform="%PLATFORM_CONFIG%"
-set CPU_PARAMETER=/maxcpucount:%MAX_CPU_CONFIG%
-set PLATFORM_TOOLSET=/p:PlatformToolset=%PLATFORM_VER%
-
-pushd ..\..\
-cmake CMakeLists.txt -G "Visual Studio 15 2017 Win64"
-%MSBUILD% assimp.sln %CONFIG_PARAMETER% %PLATFORM_PARAMETER% %CPU_PARAMETER% %PLATFORM_TOOLSET%
-popd
-endlocal