Compare commits

..

24 Commits

Author SHA1 Message Date
Kim Kulling
557caa8569 Fix warnings from sonarcube. 2026-01-13 00:07:15 +01:00
tyler92
1ce99b9cf7 MD5: Fix uninitialized pointer dereference for file with invalid vertex index (#6439)
A segmentation fault occurred while parsing an MD5 file that contains an invalid vertex index.
The issue was caused by mScene->mMaterials not being kept in sync with mScene->mNumMaterials.
As a result, the aiScene destructor could call delete on uninitialized pointers. This patch
ensures that mScene->mNumMaterials always matches the actual contents of the mScene->mMaterials
array. That way, if an exception is thrown during file import, delete is only called for
properly allocated aiMaterial objects.
2026-01-12 15:08:31 +01:00
LP
522c703bb9 fuzz: Fix memory leak in ForceFormat helper (#6435)
The ForceFormat function unregisters importers from the Importer
but doesn't delete them, causing memory leaks detected by ASan
during OSS-Fuzz check_build.

When UnregisterLoader is called, the importer is removed from the
internal list but the memory is not freed. Since the Importer
originally allocated these objects and we're removing them from
its management, we must delete them explicitly.

Also include BaseImporter.h to ensure complete type information
is available for proper deletion.

This fixes OSS-Fuzz check_build failures for all format-specific
fuzzers (obj, gltf, glb, fbx, collada, stl).
2026-01-09 11:02:21 +01:00
peng
17318b02cf MDC: Fix heap OOB read by validating vertex buffer boundaries (#6168) (#6438)
- Add explicit boundary checks for pcVerts and pcCVerts arrays in MDCImporter.
- Prevents heap out-of-bounds reads with malformed or truncated files.
- Fixes CVE-2025-5166.

Signed-off-by: mapengyuan <mapengyuan@xfusion.com>
2026-01-09 08:59:22 +01:00
peng
ac8eac60a5 MDL: Fix synctype validation in MDLImporter to prevent OOB (#6437)
* MDL: Validate synctype > 0 in MDL 3/4/5 loader to prevent OOB access (#6170)

Signed-off-by: mapengyuan <mapengyuan@xfusion.com>
Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2026-01-07 10:50:12 +01:00
Kim Kulling
c234aa28c6 Add CHANGES.md file (#6436) 2026-01-03 22:32:33 +01:00
LP
ae6f477604 Fuzzing: Add OSS-Fuzz integration and multiple format-specific fuzzers (#6429)
* fuzz: Add OSS-Fuzz integration and multiple format-specific fuzzers

* fuzz: Add GLB fuzzer and fix null pointer issue

- Add null check for mFileExtensions in ForceFormat() to prevent
  undefined behavior when the field is null
- Fix misleading comment in gltf fuzzer (only covers text format)
- Add separate GLB fuzzer for binary glTF format coverage
- Update OSS-Fuzz build script to include GLB fuzzer with corpus

* Add copyright and licensing information

Added licensing information and copyright notice to fuzzer_common.h

---------

Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2025-12-23 19:31:27 +01:00
hankarun
0fb7c4a439 Feature: Add EXT_texture_webp extension to glb importer (#6431)
* Add EXT_texture_webp extension texture read for glb file format.
2025-12-22 12:44:18 +01:00
ljgdsq
8c0ab23470 Fix UTF-8 flag check in CMakeLists.txt (#6432) 2025-12-21 18:19:10 +01:00
Kim Kulling
f4980c455c Test against possible nullptr dereferencing (#6430)
Co-authored-by: Kim Kulling <kim.kulling@draeger.com>
2025-12-18 11:26:13 +01:00
dependabot[bot]
c58496185d Bump actions/cache from 4 to 5 (#6425)
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2025-12-16 12:56:08 +01:00
dependabot[bot]
a438bbb271 Bump actions/upload-artifact from 5 to 6 (#6426)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2025-12-16 11:43:03 +01:00
dependabot[bot]
0373bbede8 Bump actions/download-artifact from 6 to 7 (#6427)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-16 11:22:14 +01:00
Kim Kulling
c0b8cfaf41 Add closing brace to CMakePresets.json (#6424)
* Add closing braces to CMakePresets.json
2025-12-14 10:38:31 +01:00
Kim Kulling
5245511f1d Add new CMake preset for static build with double precision (#6414)
- Add static build preset
- Add build all preset
2025-12-13 09:58:49 +01:00
Matt Penny
e3b13a48a9 Fix incorrect FBX connection order (#6421)
PR #6120 fixed a macro which previously prevented std::unordered_multimap
from being used during FBX import when compiled with GCC.

This caused FBX::Element properties to be stored in arbitrary order,
but the order of connections ("C" properties) in FBX files matters.
The main issue I saw was incorrect materials.

This changes the type of FBX::ElementMap to always use std::multimap
(i.e., ordered). This was the behavior for years under GCC while the
broken macro was in use. Unordered containers are still used elsewhere
in the FBX importer to benefit from their performance.

Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
2025-12-11 21:42:45 +01:00
Kim Kulling
9481ce8db9 Delete tools/coverity/assimp_modeling.cpp (#6422) 2025-12-10 16:38:09 +01:00
Kim Kulling
3761ee65c2 Update project details in Doxyfile (#6420) 2025-12-10 08:52:46 +01:00
Kim Kulling
75386282c1 Delete cmake-modules/FindDevIL.cmake (#6418) 2025-12-10 00:03:00 +01:00
Kim Kulling
c087c20e8b Update stb_image.h to version 2.30 (#6419) 2025-12-09 23:52:34 +01:00
Kim Kulling
7d1fa60aa3 Implement overflow check in Q3DLoader (#6417)
* Implement overflow check in Q3DLoader
2025-12-09 23:28:44 +01:00
Kim Kulling
6ef6d84a7e Revert buggy PR (#6415)
Co-authored-by: Kim Kulling <kim.kulling@draeger.com>
2025-12-09 20:57:36 +01:00
Paul Zander
4d197881ff Only build collada test when importer/exporter is build (#6411)
See-also: https://bugs.gentoo.org/962559

Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
2025-12-05 19:57:44 +01:00
Kim Kulling
10cd8982b0 Update copyright year in materialgen.py (#6410)
* Update copyright year in materialgen.py

* Update copyright year in structsgen.py
2025-12-04 14:24:42 +01:00
35 changed files with 4861 additions and 1011 deletions

View File

@@ -65,7 +65,7 @@ jobs:
- name: Cache DX SDK
id: dxcache
if: contains(matrix.name, 'windows')
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: '${{ github.workspace }}/DX_SDK'
key: ${{ runner.os }}-DX_SDK
@@ -109,7 +109,7 @@ jobs:
run: cd build/bin && ./unit ${{ steps.hunter_extra_test_args.outputs.args }}
shell: bash
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v6
if: matrix.name == 'windows-msvc'
with:
name: 'assimp-bins-${{ matrix.name }}'
@@ -141,7 +141,7 @@ jobs:
prerelease: true
- run: |
echo '${{steps.create-release.outputs.upload_url}}' > release_upload_url.txt
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v6
with:
name: create-release
path: release_upload_url.txt
@@ -188,7 +188,7 @@ jobs:
- id: upload-url
run: |
echo "url=$(cat create-release/release_upload_url.txt)" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v6
- uses: actions/download-artifact@v7
with:
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}'
- uses: actions/upload-release-asset@v1

View File

@@ -19,7 +19,7 @@ jobs:
dry-run: false
language: c++
- name: Upload Crash
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v6
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts

607
CHANGES
View File

@@ -1,607 +0,0 @@
----------------------------------------------------------------------
CHANGELOG
----------------------------------------------------------------------
4.1.0 (2017-12):
- FEATURES:
- Export 3MF ( experimental )
- Import / Export glTF 2
- Introduce new zib-lib to eb able to export zip-archives
- FIXES/HOUSEKEEPING:
- Added missing include to stdlib.h and remove load library call
- Fix install for builds with MSVC compiler and NMake.
- Update list of supported file formats.
- Add TriLib to the official list of supported ports.
- Re-enabling PACK_STRUCT for MDL files.
- Use std.::unique_ptr
- Update D3MFExporter.h
- Update MD3Loader.cpp, using index
- Fix all warnings on MSVC14
- Copy assimp dll to unit folder on windows
- Update jvm port supported formats
- Add support for building Mac OS X Framework bundles
- Check for nullptr dereferencing before copying scene data
- Update ValidateDataStructure.h, typo
- Enable data structure validation in cases where it doesn't cause failures
- Remove some dead assignments
- fast_atof: Silence some uninitialized variable warnings
- Check for area test if the face is a triangle.
- Set mNumUVComponents to 0 when deleting texture coordinate sets
- Only scale the root node because this will rescale all children nodes as well.
- Issue 1514: Fix frame pointer arithmetic
- Prevent failing stringstream to crash the export process
- powf -> pow
- add Defines.h to include folder for install.
- Android:
- Fix android build
- Fix assimp for cross compile for android
- Use define for D_FILE_OFFSET_BITS only for not-android systems.
- FBX:
- Fix handling with embedded textures
- FBX 7500 Binary reading
- Remove dead assignment
- Fix export of deleted meshes; Add LazyDict::Remove method
- Log an error instead of letting the fbx-importer crash. ( issue 213 )
- Replace bad pointer casting with memcpy
- Remove useless const qualifier from return value
- Add explicit instantiation of log_prefix so other FBX source files can see it
- add missing inversion of postrotation matrix for fbx.
- FIReader: Silence uninitialized variable warning
- Update version check in FBX reader to check for version >= 7500
- Use actual min/max of anim keys when start/stop time is missing
- GLTF1:
- Fix output of glTF 1 version string
- Fix delete / delete[] mismatch in glTFAsset
- Dont ignore rgba(1,1,1,1) color properties
- glTF2 primitives fixes
- Dont ignore rgba(1,1,1,1) color properties
- Fix delete / delete[] mismatch in glTFAsset
- Remove KHR_binary_glTF code
- glTF nodes can only hold one mesh. this simply assigns to and checks a Nodes Mesh
- version in glb header is stored as uint32_t
- GLTF2:
- node name conflict fix
- Fix transform matrices multiplication order
- Preserve node names when importing
- Add support for tangents in import
- Fix typo on gltf2 camera parameters
- Moved byteStride from accessor to bufferView
- Implemented reading binary glTF2 (glb) files
- Fix signed/unsigned warning
- Add postprocess step for scaling
- Fix shininess to roughness conversion
- Prefer “BLEND” over “MASK” as an alphaMode default
- Approximate specularity / glossiness in metallicRoughness materials
- Diffuse color and diffuse texture import and export improvements
- Addressed some mismatched news/deletes caused by the new glTF2 sources.
- Fix delete / delete[] mismatches in glTF2 importer
- use correct name of exporter to gltf2
- Fix possible infinite loop when exporting to gltf2
- Fix glTF2::Asset::FindUniqueID() when the input string is >= 256 chars
- Fix glTF2 alphaMode storage and reading
- Fix glTF 2.0 multi-primitive support
- Load gltf .bin files from correct directory
- Add support for importing both glTF and glTF2 files
- ampler improvements; Add new LazyDict method
- Changes to GLTF2 materials
- Remove Light, Technique references
- Start removing materials common, and adding pbrSpecularGlossiness
- Use !ObjectEmpty() vs. MemberCount() > 0
- Working read, import, export, and write of gltf2 (pbr) material
- Check in gltf2 models to test directory
- Remove un-needed test models
- Start managing and importing gltf2 pbr materials
- Update glTF2 Asset to use indexes
- Duplicate gltfImporter as gltf2Importer; Include glTF2 importer in CMake List
- glTF2: Fix animation export
- use opacity for diffuse alpha + alphaMode
- STL:
- Restore import of multi mesh binary STLs
- Blender:
- Silence warning about uninitialized member
- MDLImporter:
- Don't take address of packed struct member
- assimp_cmd:
- Fix strict-aliasing warnings
- Open3DGC:
- Fix strict-aliasing warnings
- Add assertions to silence static analyzer warnings
- Remove redundant const qualifiers from return types
- Fix some uninitialized variable warnings
- Remove OPEN3DGC and compression references
- unzip:
- Remove dead assignment
- Bail on bad compression method
- Fix possibly uninitialized variables
- clipper:
- Add assertion to silence a static analyzer warning
- OpenDDLExport:
- Reduce scope of a variable
- Remove dead variable
- Remove dead assignment
- Fix another potential memory leak
- X3DImporter:
- Add assertions to silence static analyzer warnings
- Add missing unittest
- Workaround for buggy Android NDK (issue #1361)
- TerragenLoader:
- Remove unused variable
- SIBImporter:
- Add assertions to silence static analyzer warnings
- IFC:
- Remove dead code
- Add explicit instantiation of log_prefix so IFCMaterial.cpp can see it
- PLY:
- Remove dead assignment and reduce scope of a variable
- fix vertex attribute lookup.
- OpenGEX:
- Add assertion to silence a static analyzer warning
- Fix for TextureFile with number in file name
- Return early when element is TextureFile
- NFF:
- Add assertions to silence static analyzer warnings
- Split up some complicated assignments
- Raw: Fix misleading indentation warning
- Reduce scope of a variable
- LWO
- Reduce scope of a variable
- IRRLoader:
- Fix confusing boolean casting
- AssbinExporter:
- Add assertion to silence a static analyzer warning
- ASE:
- Add assertion to silence a static analyzer warning
- AMFImporter:
- Add assertion to silence a static analyzer warning
- Add a block
- OptimizeGraph:
- Fix possible null pointer dereference
- RemoveRedundantMaterials:
- Add assertion to silence a static analyzer warning
- ImproveCacheLocality:
- Add assertion to silence a static analyzer warning
- RemoveRedundantMaterials:
- Set pointer to nullptr after deleting it
- Travis:
- Disable unit tests in scan-build config
- Move slower builds earlier to improve parallelization
- Add static analysis to build
- Remove unused branch rule for travis.
- Add Clang UBSan build configuration
- Treat warnings as errors, without typos this time
- Unittests:
- Add VS-based source groups for the unittests.
- Collada:
- export <library_animations> tag
- Update ColladaExporter.cpp
- Silence uninitialized variable warning
- Add support for line strip primitives
- Obj Wavefront:
- check in exporting against out-of-bounds-access .
- Issue 1351: use correct name for obj-meshname export for groups.
- fix mem-lead: face will be not released in case of an error.
- Anatoscope obj exporter nomtl
- Raise exception when obj file contains invalid face indices
- Added alternative displacement texture token in OBJ MTL material.
- Obj: rename attribute from exporter.
- Fix OBJ discarding all material names if the material library is missing
- Step:
- use correct lookup for utf32
- MD2:
- Fix MD2 frames containing garbage
- STL
- add missing const.
- Fix memory-alignment bug.
- Fix issue 104: deal with more solids in one STL file.
- CMake
- Fix issue 213: use correct include folder for assimp
- Doxygen
- Fix issue 1513: put irrXML onto exclucde list for doxygen run
- PyAssimp:
- Search for libassimp.so in LD_LIBRARY_PATH if available.
- Fix operator precedence issue in header check
- Split setup.py into multiple lines
- Detect if Anaconda and fixed 3d_viewer for Python 3
- created a python3 version of the 3dviewer and fixed the / = float in py3
- Blender:
- Fix invalid access to mesh array when the array is empty.
- Fix short overflow.
- Silence warning about inline function which is declared but not defined
- JAssimp
- Changed license header for IHMC contributions from Apache 2.0 to BSD
- Add Node metadata to the Jassmip Java API
- Added supported for custom IO Systems in Java. Implemented ClassLoader IO System
- Added a link to pure jvm assimp port
- Clang sanitizer:
- Undefined Behavior sanitizer
- Fixed a divide by zero error in IFCBoolean that was latent, but nevertheless a bug
- B3DImporter:
- Replace bad pointer casting with memcpy
- AppVeyor:
- Cleanup and Addition of VS 2017 and running Tests
- Fixed File Size reported as 0 in tests that use temporary files
- x86 isn't a valid VS platform. Win32 it is, then.
- Replaced the worker image name, which doesn't work as generator name, with a manually created generator name.
- Cleaned up appveyor setup, added VS 2017 to the build matrix and attempted to add running of tests.
- Treat warnings as errors on Appveyor
- Disable warning 4351 on MSVC 2013
- OpenGEXImporter:
- Copy materials to scene
- Store RefInfo in unique_ptr so they get automatically cleaned up
- Fix IOStream leak
- Store ChildInfo in unique_ptr so they get automatically cleaned up
- improve logging to be able to detect error-prone situations.
- AMFImporter:
- Fix memory leak
- UnrealLoader:
- Fix IOStream leak
- Upgrade RapidJSON to get rid of a clang warning
- zlib:
- Update zlib contribution
- Removed unnecessary files from zlib contribution
- Replaced unsigned long for the crc table to z_crc_t, to match what is returned by get-crc_table
- MakeVerboseFormat:
- Fix delete / delete[] mismatches in MakeVerboseFormat
- MaterialSystem:
- Fix out-of-bounds read in MaterialSystem unit test
- SIB:
- Added support for SIB models from Silo 2.5
- AssbinExporter:
- Fix strict aliasing violation
- Add Write specialization for aiColor3D
- DefaultLogger:
- Whitespace cleanup to fix GCC misleading indentation warning
- MDP:
- Fix encoding issues.
- PreTransformVertices:
- fix name lost in mesh and nodes when load with flag
- C4D:
- Fixes for C4D importer
- Unzip:
- Latest greatest.
4.0.1 (2017-07-28)
- FIXES/HOUSEKEEPING:
- fix version test.
- Not compiling when using ASSIMP_DOUBLE_PRECISION
- Added support for python3
- Check if cmake is installed with brew
- Low performance in OptimizeMeshesProcess::ProcessNode with huge numbers of meshes
- Elapsed seconds not shown correctly
- StreamReader: fix out-of-range exception
- PPdPmdParser: fix compilation for clang
4.0.0 (2017-07-18)
FEATURES:
- Double precision support provided ( available via cmake option )
- QT-Widget based assimp-viewer ( works for windows, linux, osx )
- Open3DGC codec supported by glFT-importer
- glTF: Read and write transparency values
- Add Triangulate post-processing step to glTF exporters
- Update rapidjson to v1.0.2
- Added method to append new metadata to structure
- Unittests: intoduce a prototype model differ
- X3D support
- AMF support
- Lugdunum3D support
- Obj-Importer: obj-homogeneous_coords support
- Obj-Importer: new streaming handling
- Added support for 64 bit version header introduced in FbxSdk2016
- Travis: enable coverall support.
- PyAssimp: New version of the pyASSIMP 3D viewer, with much improved 3D controls
- Morph animation support for collada
- Added support for parameters Ni and Tf in OBJ/MTL file format
- aiScene: add method to add children
- Added new option to IFC importer to control tessellation angle + removed unused IFC option
- aiMetaData: introduce aiMetaData::Dealloc
- Samples: add a DX11 example
- travis ci: test on OXS ( XCode 6.3 ) as well
- travis ci: enable sudo support.
- openddlparser: integrate release v0.4.0
- aiMetaData: Added support for metadata in assbin format
FIXES/HOUSEKEEPING:
- Introduce usage of #pragma statement
- Put cmake-scripts into their own folder
- Fix install pathes ( issue 938 )
- Fix object_compare in blender importer( issue 946 )
- Fix OSX compilation error
- Fix unzip path when no other version was found ( issue 967 )
- Set _FILE_OFFSET_BITS=64 for 32-bit linux ( issue 975 )
- Fix constructor for radjson on OSX
- Use Assimp namespace to fix build for big-endian architectures
- Add -fPIC to C Flags for 64bit linux Shared Object builds
- MDLLoader: fix resource leak.
- MakeVerboseFormat: fix invalid delete statement
- IFC: fix possible use after free access bug
- ComputeUVMappingprocess: add missing initialization for scalar value
- Fix invalid release of mat + mesh
- IrrImporter: Fix release functions
- Split mesh before exporting gltf ( issue 995 )
- 3MFImporter: add source group for visual studio
- IFC: Switch generated file to 2 files to fix issue related to <mingw4.9 ( Thanks Qt! )
- ObjImporter: fix test for vertices import
- export scene combiner ( issues177 )
- FBX: make lookup test less strict ( issues 994 )
- OpenGEX-Importer: add import of vertex colors ( issue 954 )
- fix bug when exporting mRotationKeys data
- fix mingw build (mingw supports stat64 nowadays)
- cfileio: fix leaks by not closing files in the destructor
- Fix OBJ parser mtllib statement parsing bug.
- Q3BSP-Importer: remove dead code
- Fix BlenderDNA for clang cross compiler.
- ScenePreprocessor: fix invalid index counter.
- Fix compiler warnings ( issue 957 )
- Fix obj .mtl file loading
- Fixed a compile error on MSVC14 x64 caused by the /bigobj flag failing to be set for the 1 and 2-suffixed versions introduced in commit 0a25b076b8968b7ea2aa96d7d1b4381be2d72ce6
- Fixed build warnings on MSVC14 x64
- Remove scaling of specular exponent in OBJFileImporter.cpp
- use ai_assert instead of assert ( issue 1076 )
- Added a preprocessor definition for MSVC to silence safety warnings regarding C library functions. This addresses all warnings for MSVC x86 and x64 when building zlib, tools and viewer as a static lib
- fix parsing of texture name ( issue 899 )
- add warning when detecting invalid mat definition ( issue 1111 )
- copy aiTexture type declaration instead of using decltype for declaration to fix iOS build( issue 1101 )
- FBX: Add additional material properties
- FBX: Correct camera position and clip planes
- FBX: Add correct light locations and falloff values
- fix typo ( issue 1141 )
- Fix collada export. Don't duplicate TEXCOORD/NORMALS/COLORS in <vertices> and <polylist> ( issue 1084 )
- OBJParser: set material index when changing current material
- OBJ: check for null mesh before updating material index
- add vertex color export support ( issue 809 )
- Fix memory leak in Collada importer ( issue 1169 )
- add stp to the list of supported extensions for step-files ( issue 1183 )
- fix clang build ( Issue-1169 )
- fix for FreeBSD
- Import FindPkgMacros to main CMake Configuration
- Extended support for tessellation parameter to more IFC shapes
- defensice handling of utf-8 decode issues ( issue 1211 )
- Fixed compiler error on clang 4.0 running on OSX
- use test extension for exported test files ( issue 1228 )
- Set UVW index material properties for OBJ files
- Fixed no member named 'atop' in global namespace issue for Android NDK compilation
- Apply mechanism to decide use for IrrXML external or internal
- Fix static init ordering bug in OpenGEX importer
- GLTF exporter: ensure animation accessors have same count
- GLTF exporter: convert animation time from ticks to seconds
- Add support for reading texture coordinates from PLY meshes with properties named 'texture_u' and 'texture_v'
- Added TokensForSearch in BlenderLoader to allow CanRead return true for in-memory files.
- fix wrong delete ( issue 1266 )
- OpenGEX: fix invalid handling with color4 token ( issue 1262 )
- LWOLoader: fix link in loader description
- Fix error when custom CMAKE_C_FLAGS is specified
- Fast-atof: log overflow errors
- Obj-Importer: do not break when detecting an overflow ( issue 1244 )
- Obj-Importer: fix parsing of multible line data definitions
- Fixed bug where IFC models with multiple IFCSite only loaded 1 site instead of the complete model
- PLYImporter: - optimize memory and speed on ply importer / change parser to use a file stream - manage texture path in ply
import - manage texture coords on faces in ply import - correction on point cloud faces generation
- Utf8: integrate new lib ( issue 1158 )
- fixed CMAKE_MODULE_PATH overwriting previous values
- OpenGEX: Fixed bug in material color processing ( issue 1271 )
- SceneCombiner: move header for scenecombiner to public folder.
- GLTF exporter: ensure buffer view byte offsets are correctly aligned
- X3D importer: Added EXPORT and IMPORT to the list of ignored XML tags
- X3D Exporter: fixed missing attributes
- X3D importer: Fixed import of normals for the single index / normal per vertex case
- X3D importer: Fixed handling of inlined files
- X3D importer: fixed whitespace handling (issue 1202)
- X3D importer: Fixed iterator on MSVC 2015
- X3D importer: Fixed problems with auto, override and regex on older compilers
- X3D importer: Fixed missing header file
- X3D importer: Fixed path handling
- X3D importer: Implemented support for binary X3D files
- fix build without 3DS ( issue 1319 )
- pyassimp: Fixed indices for IndexedTriangleFanSet, IndexedTriangleSet and IndexedTriangleStripSet
- Fixes parameters to pyassimp.load
- Obj-Importe: Fixed texture bug due simultaneously using 'usemtl' and 'usemap' attributes
- check if all exporters are disabled ( issue 1320 )
- Remove std functions deprecated by C++11.
- X-Importer: make it deal with lines
- use correct path for compilers ( issue 1335 )
- Collada: add workaround to deal with polygon with holes
- update python readme
- Use unique node names when loading Collada files
- Fixed many FBX bugs
API COMPATIBILITY:
- Changed ABI-compatibility to v3.3.1, please rebuild your precompiled libraries ( see issue 1182 )
- VS2010 outdated
3.3.1 (2016-07-08)
FIXES/HOUSEKEEPING:
- Setup of default precision for 17 exporters
- Fix xcode project files
- Fix BlenderTesselator: offsetof operator
- Invalid version in cmake file
- Update pstdint.h to latest greatest
3.3.0 (2016-07-05)
FEATURES:
- C++11 support enabled
- New regression-test-UI
- Experimental glTF-importer support
- OpenGEX: add support for cameras and lights
- C4D: update to latest Melange-SDK
- Add a gitter channel
- Coverity check enabled
- Switch to <...> include brackets for public headers
- Enable export by pyAssimp
- CI: check windows build
- Add functionality to perform a singlepost-processing step
- many more, just check the history
FIXES/HOUSEKEEPING:
- Fix of many resource leaks in unittests and main lib
- Fix iOS-buildfor X64
- Choosing zlib manually for cmake
- many more, just check the history
3.2.1 (2016-010-10)
FEATURES:
- Updated glTF exporter to meet 1.0 specification.
FIXES/HOUSEKEEPING:
- Fixed glTF Validator errors for exported glTF format.
ISSUES:
- Hard coded sampler setting for
- magFilter
- minFilter
- void* in ExportData for accessor max and min.
3.2.0 (2015-11-03)
FEATURES:
- OpenDDL-Parser is part of contrib-source.
- Experimental OpenGEX-support
- CI-check for linux and windows
- Coverity check added
- New regression testsuite.
FIXES/HOUSEKEEPING:
- Hundreds of bugfixes in all parts of the library
- Unified line endings
API COMPATIBILITY:
- Removed precompiled header to increase build speed for linux
3.1.1 (2014-06-15)
FEATURES:
- Support for FBX 2013 and newer, binary and ASCII (this is partly
work from Google Summer of Code 2012)
- Support for OGRE binary mesh and skeleton format
- Updated BLEND support for newer Blender versions
- Support for arbitrary meta data, used to hold FBX and DAE metadata
- OBJ Export now produces smaller files
- Meshes can now have names, this is supported by the major importers
- Improved IFC geometry generation
- M3 support has been removed
FIXES/HOUSEKEEPING:
- Hundreds of bugfixes in all parts of the library
- CMake is now the primary build system
API COMPATIBILITY:
- 3.1.1 is not binary compatible to 3.0 due to aiNode::mMetaData
and aiMesh::mName
- Export interface has been cleaned up and unified
- Other than that no relevant changes
3.0 (2012-07-07)
FEATURES:
- new export interface similar to the import API.
- Supported export formats: Collada, OBJ, PLY and STL
- added new import formats: XGL/ZGL, M3 (experimental)
- new postprocessing steps: Debone
- vastly improved IFC (Industry Foundation Classes) support
- introduced API to query importer meta information (such as supported
format versions, full name, maintainer info).
- reworked Ogre XML import
- C-API now supports per-import properties
FIXES/HOUSEKEEPING:
- hundreds of bugfixes in all parts of the library
- unified naming and cleanup of public headers
- improved CMake build system
- templatized math library
- reduce dependency on boost.thread, only remaining spot
is synchronization for the C logging API
API COMPATIBILITY:
- renamed headers, export interface, C API properties and meta data
prevent compatibility with code written for 2.0, but in
most cases these can be easily resolved
- Note: 3.0 is not binary compatible with 2.0
2.0 (2010-11-21)
FEATURES:
- Add support for static Blender (*.blend) scenes
- Add support for Q3BSP scenes
- Add a windows-based OpenGL sample featuring texturing & basic materials
- Add an experimental progress feedback interface.
- Vastly improved performance (up to 500%, depending on mesh size and
spatial structure) in some expensive postprocessing steps
- AssimpView now uses a reworked layout which leaves more space
to the scene hierarchy window
- Add C# bindings ('Assimp.NET')
- Keep BSD-licensed and otherwise free test files in separate
folders (./test/models and ./test/models-nonbsd).
FIXES:
- Many Collada bugfixes, improve fault tolerance
- Fix possible crashes in the Obj loader
- Improve the Ogre XML loader
- OpenGL-sample now works with MinGW
- Fix Importer::FindLoader failing on uppercase file extensions
- Fix flawed path handling when locating external files
- Limit the maximum number of vertices, faces, face indices and
weights that Assimp is able to handle. This is to avoid
crashes due to overflowing counters.
- Updated XCode project files
- Further CMAKE build improvements
API CHANGES:
- Add data structures for vertex-based animations (These are not
currently used, however ...)
- Some Assimp::Importer methods are const now.
1.1 (2010-04-17)
This is the list of relevant changes from the 1.0 (r412) release to 1.1 (r700).
FEATURES:
- Vastly improved Collada support
- Add MS3D (Milkshape 3D) support
- Add support for Ogre XML static meshes
- Add experimental COB (TrueSpace) support
- Automatic test suite to quickly locate regressions
- D bindings (`dAssimp`)
- Python 2.n bindings (`PyAssimp`)
- Add basic support for Unicode input files (utf8, utf16 and utf32)
- Add further utilities to the `assimp` tool (xml/binary dumps, quick file stats)
- Switch to a CMAKE-based build system including an install target for unix'es
- Automatic evaluation of subdivision surfaces for some formats.
- Add `Importer::ReadFileFromMemory` and the corresponding C-API `aiReadFileFromMemory`
- Expose further math utilities via the C-API (i.e. `aiMultiplyMatrix4`)
- Move noboost files away from the public include directory
- Many, many bugfixes and improvements in existing loaders and postprocessing steps
- Documentation improved and clarified in many places.
- Add a sample on using Assimp in conjunction with OpenGL
- Distribution/packaging: comfortable SDK installer for Windows
- Distribution/packaging: improved release packages for other architectures
CRITICAL FIXES:
- Resolve problems with clashing heap managers, STL ABIs and runtime libraries (win32)
- Fix automatic detection of file type if no file extension is given
- Improved exception safety and robustness, prevent leaking of exceptions through the C interface
- Fix possible heap corruption due to material properties pulled in incorrectly
- Avoid leaking in certain error scenarios
- Fix 64 bit compatibility problems in some loaders (i.e. MDL)
BREAKING API CHANGES:
- None -
MINOR API BEHAVIOUR CHANGES:
- Change quaternion orientation to suit to the more common convention (-w).
- aiString is utf8 now. Not yet consistent, however.

3961
CHANGES.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -362,7 +362,7 @@ ELSEIF(MSVC)
elseif((GENERATOR_IS_MULTI_CONFIG) OR (CMAKE_BUILD_TYPE MATCHES Release))
message("-- MSVC PDB generation disabled. Release binary will not be debuggable.")
endif()
if(NOT /utf-8 IN_LIST CMAKE_CXX_FLAGS)
if(NOT CMAKE_CXX_FLAGS MATCHES "/utf-8")
# Source code is encoded in UTF-8
ADD_COMPILE_OPTIONS(/source-charset:utf-8)
endif()

View File

@@ -14,6 +14,16 @@
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF"
}
},
{
"name": "assimp_static",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SHARED_LIBS": "OFF",
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF",
"ASSIMP_DOUBLE_PRECISION": "ON"
}
},
{
"name": "assimp_double_precision",
"binaryDir": "${sourceDir}",
@@ -29,6 +39,15 @@
"cacheVariables": {
"ASSIMP_BUILD_ASSIMP_TOOLS": "ON"
}
},
{
"name": "assimp_all",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"ASSIMP_BUILD_ASSIMP_TOOLS": "ON",
"ASSIMP_BUILD_SAMPLES": "ON",
"ASSIMP_BUILD_DOCS": "ON"
}
}
]
}

View File

@@ -1,72 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindDevIL
# ---------
#
#
#
# This module locates the developer's image library.
# http://openil.sourceforge.net/
#
# This module sets:
#
# ::
#
# IL_LIBRARIES - the name of the IL library. These include the full path to
# the core DevIL library. This one has to be linked into the
# application.
# ILU_LIBRARIES - the name of the ILU library. Again, the full path. This
# library is for filters and effects, not actual loading. It
# doesn't have to be linked if the functionality it provides
# is not used.
# ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the
# library interfaces with OpenGL. It is not strictly needed
# in applications.
# IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files.
# IL_FOUND - this is set to TRUE if all the above variables were set.
# This will be set to false if ILU or ILUT are not found,
# even if they are not needed. In most systems, if one
# library is found all the others are as well. That's the
# way the DevIL developers release it.
# TODO: Add version support.
# Tested under Linux and Windows (MSVC)
#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
include(FindPackageHandleStandardArgs)
find_path(IL_INCLUDE_DIR il.h
PATH_SUFFIXES include IL
DOC "The path to the directory that contains il.h"
)
#message("IL_INCLUDE_DIR is ${IL_INCLUDE_DIR}")
find_library(IL_LIBRARIES
NAMES IL DEVIL
PATH_SUFFIXES lib64 lib lib32
DOC "The file that corresponds to the base il library."
)
#message("IL_LIBRARIES is ${IL_LIBRARIES}")
find_library(ILUT_LIBRARIES
NAMES ILUT
PATH_SUFFIXES lib64 lib lib32
DOC "The file that corresponds to the il (system?) utility library."
)
#message("ILUT_LIBRARIES is ${ILUT_LIBRARIES}")
find_library(ILU_LIBRARIES
NAMES ILU
PATH_SUFFIXES lib64 lib lib32
DOC "The file that corresponds to the il utility library."
)
#message("ILU_LIBRARIES is ${ILU_LIBRARIES}")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IL DEFAULT_MSG
IL_LIBRARIES IL_INCLUDE_DIR)

View File

@@ -76,14 +76,14 @@ class ChunkWriter {
public:
ChunkWriter(StreamWriterLE &writer, uint16_t chunk_type) :
mWriter(writer) {
mChunkStartPos = writer.GetCurrentPos();
mWriter(writer),
mChunkStartPos(writer.GetCurrentPos()) {
writer.PutU2(chunk_type);
writer.PutU4((uint32_t)CHUNK_SIZE_NOT_SET);
writer.PutU4(static_cast<uint32_t>(CHUNK_SIZE_NOT_SET));
}
~ChunkWriter() {
std::size_t head_pos = mWriter.GetCurrentPos();
const std::size_t head_pos = mWriter.GetCurrentPos();
ai_assert(head_pos > mChunkStartPos);
const std::size_t chunk_size = head_pos - mChunkStartPos;
@@ -95,7 +95,7 @@ public:
private:
StreamWriterLE &mWriter;
std::size_t mChunkStartPos;
std::size_t mChunkStartPos{0};
};
// Return an unique name for a given |mesh| attached to |node| that

View File

@@ -64,7 +64,7 @@ class Parser;
class Element;
using ScopeList = std::vector<Scope*>;
using ElementMap = std::fbx_unordered_multimap< std::string, Element*>;
using ElementMap = std::multimap< std::string, Element*>;
using ElementCollection = std::pair<ElementMap::const_iterator,ElementMap::const_iterator>;
#define new_Scope new (allocator.Allocate(sizeof(Scope))) Scope

View File

@@ -361,19 +361,19 @@ void MD5Importer::LoadMD5MeshFile() {
#else
// FIX: MD5 files exported from Blender can have empty meshes
unsigned int numMaterials = 0;
for (std::vector<MD5::MeshDesc>::const_iterator it = meshParser.mMeshes.begin(), end = meshParser.mMeshes.end(); it != end; ++it) {
if (!(*it).mFaces.empty() && !(*it).mVertices.empty()) {
++mScene->mNumMaterials;
++numMaterials;
}
}
// generate all meshes
mScene->mNumMeshes = mScene->mNumMaterials;
mScene->mMeshes = new aiMesh *[mScene->mNumMeshes];
mScene->mMaterials = new aiMaterial *[mScene->mNumMeshes];
mScene->mMeshes = new aiMesh *[numMaterials];
mScene->mMaterials = new aiMaterial *[numMaterials];
// storage for node mesh indices
pcNode->mNumMeshes = mScene->mNumMeshes;
pcNode->mNumMeshes = numMaterials;
pcNode->mMeshes = new unsigned int[pcNode->mNumMeshes];
for (unsigned int m = 0; m < pcNode->mNumMeshes; ++m) {
pcNode->mMeshes[m] = m;
@@ -386,7 +386,10 @@ void MD5Importer::LoadMD5MeshFile() {
continue;
}
aiMesh *mesh = mScene->mMeshes[n] = new aiMesh();
aiMesh* mesh = new aiMesh();
mScene->mMeshes[n] = mesh;
++mScene->mNumMeshes;
mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
// generate unique vertices in our internal verbose format
@@ -508,6 +511,7 @@ void MD5Importer::LoadMD5MeshFile() {
// generate a material for the mesh
aiMaterial *mat = new aiMaterial();
mScene->mMaterials[n] = mat;
++mScene->mNumMaterials;
// insert the typical doom3 textures:
// nnn_local.tga - normal map

View File

@@ -324,6 +324,15 @@ void MDCImporter::InternReadFile(
#endif
// boundary check for pcVerts
auto surfStart = reinterpret_cast<const uint8_t*>(pcSurface);
const uint8_t* surfEnd = surfStart + pcSurface->ulOffsetEnd;
auto vertBufStart = reinterpret_cast<const uint8_t*>(pcVerts);
const size_t needVertBytes = sizeof(MDC::BaseVertex) * pcSurface->ulNumVertices;
if (vertBufStart < surfStart || vertBufStart + needVertBytes > surfEnd) {
throw DeadlyImportError("MDCImporter: pcVerts points outside of surface block.");
}
const MDC::CompressedVertex *pcCVerts = nullptr;
int16_t *mdcCompVert = nullptr;
@@ -335,6 +344,12 @@ void MDCImporter::InternReadFile(
pcCVerts = (const MDC::CompressedVertex *)((int8_t *)pcSurface +
pcSurface->ulOffsetCompVerts) +
*mdcCompVert * pcSurface->ulNumVertices;
auto cvertBufStart = reinterpret_cast<const uint8_t*>(pcCVerts);
const size_t needCompVertBytes = sizeof(MDC::CompressedVertex) * pcSurface->ulNumVertices;
if (cvertBufStart < surfStart || cvertBufStart > surfEnd ||
needCompVertBytes > static_cast<size_t>(surfEnd - cvertBufStart)) {
throw DeadlyImportError("MDCImporter: pcCVerts points outside of surface block.");
}
} else
mdcCompVert = nullptr;
}

View File

@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2025, assimp team
Copyright (c) 2006-2026, assimp team
All rights reserved.
@@ -602,6 +602,9 @@ void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1() {
// Read a MDL 3,4,5 file
void MDLImporter::InternReadFile_3DGS_MDL345() {
ai_assert(nullptr != pScene);
if (pScene == nullptr) {
throw DeadlyImportError("INvalid scene pointer detected.");
}
// the header of MDL 3/4/5 is nearly identical to the original Quake1 header
BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header *)this->mBuffer;
@@ -610,6 +613,10 @@ void MDLImporter::InternReadFile_3DGS_MDL345() {
#endif
ValidateHeader_Quake1(pcHeader);
if (pcHeader->synctype < 0) {
throw DeadlyImportError("Invalid synctype value in MDL header; possible corrupt file.");
}
// current cursor position in the file
const unsigned char *szCurrent = (const unsigned char *)(pcHeader + 1);
const unsigned char *szEnd = mBuffer + iFileSize;
@@ -619,8 +626,7 @@ void MDLImporter::InternReadFile_3DGS_MDL345() {
if (szCurrent + sizeof(uint32_t) > szEnd) {
throw DeadlyImportError("Texture data past end of file.");
}
BE_NCONST MDL::Skin *pcSkin;
pcSkin = (BE_NCONST MDL::Skin *)szCurrent;
BE_NCONST MDL::Skin *pcSkin = (BE_NCONST MDL::Skin *)szCurrent;
AI_SWAP4(pcSkin->group);
// create one output image
unsigned int iSkip = i ? UINT_MAX : 0;
@@ -1838,6 +1844,10 @@ void MDLImporter::GenerateOutputMeshes_3DGS_MDL7(
const unsigned int iNumOutBones = pcHeader->bones_num;
for (std::vector<aiMaterial *>::size_type i = 0; i < shared.pcMats.size(); ++i) {
if (splitGroupData.aiSplit == nullptr) {
continue;
}
if (!splitGroupData.aiSplit[i]->empty()) {
// allocate the output mesh

View File

@@ -379,7 +379,12 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
light->mColorSpecular = light->mColorDiffuse;
// We don't need the rest, but we need to know where this chunk ends.
unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4());
const auto t1 = stream.GetI4();
const auto t2 = stream.GetI4();
if (t1 < 0 || t2 < 0) {
throw DeadlyImportError("Quick3D: Overflow detected.");
}
const unsigned int temp = static_cast<unsigned int>(t1*t2);
// skip the background file name
while (stream.GetI1())

View File

@@ -77,7 +77,6 @@ static constexpr aiImporterDesc desc = {
};
namespace Assimp {
using namespace std;
// Constructor to be privately used by Importer
USDImporter::USDImporter() :

View File

@@ -53,9 +53,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "USDLoaderImplTinyusdz.h"
namespace Assimp {
class USDImporter : public BaseImporter {
/// @brief USD Importer class
class USDImporter final : public BaseImporter {
public:
/// @brief Constructor
USDImporter();
/// @brief Destructor
~USDImporter() override = default;
/// \brief Returns whether the class can handle the format of the given file.

View File

@@ -44,32 +44,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ASSIMP_BUILD_NO_USD_IMPORTER
#include "USDLoaderImplTinyusdz.h"
#include "USDLoaderImplTinyusdzHelper.h"
#include "USDLoaderUtil.h"
#include "USDPreprocessor.h"
#include "io-util.hh" // namespace tinyusdz::io
#include "tydra/scene-access.hh"
#include "tydra/shader-network.hh"
#include <memory>
#include <sstream>
// internal headers
#include <assimp/ai_assert.h>
#include <assimp/anim.h>
#include "assimp/MemoryIOWrapper.h"
#include <assimp/CreateAnimMesh.h>
#include <assimp/DefaultIOSystem.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/fast_atof.h>
#include <assimp/Importer.hpp>
#include <assimp/importerdesc.h>
#include <assimp/IOStreamBuffer.h>
#include <assimp/IOSystem.hpp>
#include "assimp/MemoryIOWrapper.h"
#include <assimp/StringUtils.h>
#include <assimp/StreamReader.h>
#include <assimp/metadata.h>
#include <assimp/StringUtils.h>
#include <assimp/ai_assert.h>
#include <assimp/anim.h>
#include <assimp/fast_atof.h>
#include <assimp/importerdesc.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp>
#include <assimp/Importer.hpp>
#include "io-util.hh" // namespace tinyusdz::io
#include "tydra/scene-access.hh"
#include "tydra/shader-network.hh"
#include "USDLoaderImplTinyusdzHelper.h"
#include "USDLoaderImplTinyusdz.h"
#include "USDLoaderUtil.h"
#include "USDPreprocessor.h"
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
@@ -78,17 +79,18 @@ namespace {
}
namespace Assimp {
using namespace std;
void USDImporterImplTinyusdz::InternReadFile(
const std::string &pFile,
aiScene *pScene,
IOSystem *pIOHandler) {
using Assimp::tinyUsdzMat4ToAiMat4;
using Assimp::tinyusdzNodeTypeFor;
using tinyusdz::tydra::NodeType;
using namespace tinyusdz::tydra;
void USDImporterImplTinyusdz::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
// Grab filename for logging purposes
size_t pos = pFile.find_last_of('/');
string basePath = pFile.substr(0, pos);
string nameWExt = pFile.substr(pos + 1);
stringstream ss;
std::string basePath = pFile.substr(0, pos);
std::string nameWExt = pFile.substr(pos + 1);
std::stringstream ss;
ss.str("");
ss << "InternReadFile(): model" << nameWExt;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -161,9 +163,10 @@ void USDImporterImplTinyusdz::InternReadFile(
TINYUSDZLOGE(TAG, "%s", ss.str().c_str());
return;
}
tinyusdz::tydra::RenderScene render_scene;
tinyusdz::tydra::RenderSceneConverter converter;
tinyusdz::tydra::RenderSceneConverterEnv env(stage);
RenderScene render_scene;
RenderSceneConverter converter;
RenderSceneConverterEnv env(stage);
std::string usd_basedir = tinyusdz::io::GetBaseDir(pFile);
env.set_search_paths({ usd_basedir }); // {} needed to convert to vector of char
@@ -220,16 +223,12 @@ void USDImporterImplTinyusdz::InternReadFile(
textures(render_scene, pScene, nameWExt);
textureImages(render_scene, pScene, nameWExt);
buffers(render_scene, pScene, nameWExt);
std::map<size_t, tinyusdz::tydra::Node> meshNodes;
setupNodes(render_scene, pScene, stage, meshNodes, nameWExt);
pScene->mRootNode = nodesRecursive(nullptr, render_scene.nodes[0], render_scene.skeletons);
setupBlendShapes(render_scene, pScene, nameWExt);
}
void USDImporterImplTinyusdz::animations(
const tinyusdz::tydra::RenderScene& render_scene,
aiScene* pScene) {
void USDImporterImplTinyusdz::animations(const tinyusdz::tydra::RenderScene &render_scene, aiScene *pScene) {
if (render_scene.animations.empty()) {
return;
}
@@ -269,7 +268,7 @@ void USDImporterImplTinyusdz::animations(
for (const auto &[channelType, animChannel] : animationChannelMap) {
switch (channelType) {
case tinyusdz::tydra::AnimationChannel::ChannelType::Rotation:
case AnimationChannel::ChannelType::Rotation:
if (animChannel.rotations.static_value.has_value()) {
rotationKeys.emplace_back(0, tinyUsdzQuatToAiQuat(animChannel.rotations.static_value.value()));
}
@@ -281,7 +280,7 @@ void USDImporterImplTinyusdz::animations(
rotationKeys.emplace_back(rotationAnimSampler.t, tinyUsdzQuatToAiQuat(rotationAnimSampler.value));
}
break;
case tinyusdz::tydra::AnimationChannel::ChannelType::Scale:
case AnimationChannel::ChannelType::Scale:
if (animChannel.scales.static_value.has_value()) {
scalingKeys.emplace_back(0, tinyUsdzScaleOrPosToAssimp(animChannel.scales.static_value.value()));
}
@@ -292,7 +291,7 @@ void USDImporterImplTinyusdz::animations(
scalingKeys.emplace_back(scaleAnimSampler.t, tinyUsdzScaleOrPosToAssimp(scaleAnimSampler.value));
}
break;
case tinyusdz::tydra::AnimationChannel::ChannelType::Transform:
case AnimationChannel::ChannelType::Transform:
if (animChannel.transforms.static_value.has_value()) {
aiVector3D position;
aiVector3D scale;
@@ -318,7 +317,7 @@ void USDImporterImplTinyusdz::animations(
rotationKeys.emplace_back(transformAnimSampler.t, rotation);
}
break;
case tinyusdz::tydra::AnimationChannel::ChannelType::Translation:
case AnimationChannel::ChannelType::Translation:
if (animChannel.translations.static_value.has_value()) {
positionKeys.emplace_back(0, tinyUsdzScaleOrPosToAssimp(animChannel.translations.static_value.value()));
}
@@ -356,7 +355,7 @@ void USDImporterImplTinyusdz::meshes(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const std::string &nameWExt) {
stringstream ss;
std::stringstream ss;
pScene->mNumMeshes = static_cast<unsigned int>(render_scene.meshes.size());
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes]();
ss.str("");
@@ -368,10 +367,7 @@ void USDImporterImplTinyusdz::meshes(
pScene->mMeshes[meshIdx] = new aiMesh();
pScene->mMeshes[meshIdx]->mName.Set(render_scene.meshes[meshIdx].prim_name);
ss.str("");
ss << " mesh[" << meshIdx << "]: " <<
render_scene.meshes[meshIdx].joint_and_weights.jointIndices.size() << " jointIndices, " <<
render_scene.meshes[meshIdx].joint_and_weights.jointWeights.size() << " jointWeights, elementSize: " <<
render_scene.meshes[meshIdx].joint_and_weights.elementSize;
ss << " mesh[" << meshIdx << "]: " << render_scene.meshes[meshIdx].joint_and_weights.jointIndices.size() << " jointIndices, " << render_scene.meshes[meshIdx].joint_and_weights.jointWeights.size() << " jointWeights, elementSize: " << render_scene.meshes[meshIdx].joint_and_weights.elementSize;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
ss.str("");
ss << " skel_id: " << render_scene.meshes[meshIdx].skel_id;
@@ -390,12 +386,8 @@ void USDImporterImplTinyusdz::meshes(
}
}
void USDImporterImplTinyusdz::verticesForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
void USDImporterImplTinyusdz::verticesForMesh(const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene, size_t meshIdx, const std::string &) {
const auto numVertices = static_cast<unsigned int>(render_scene.meshes[meshIdx].points.size());
pScene->mMeshes[meshIdx]->mNumVertices = numVertices;
pScene->mMeshes[meshIdx]->mVertices = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
@@ -454,7 +446,7 @@ void USDImporterImplTinyusdz::verticesForMesh(
std::swap_ranges(aiBonesVertexWeights[boneIndex].begin(), aiBonesVertexWeights[boneIndex].end(), pScene->mMeshes[meshIdx]->mBones[boneIndex]->mWeights);
}
} // Skinned mesh end
} // Skinned mesh end
for (size_t j = 0; j < pScene->mMeshes[meshIdx]->mNumVertices; ++j) {
pScene->mMeshes[meshIdx]->mVertices[j].x = render_scene.meshes[meshIdx].points[j][0];
@@ -463,12 +455,8 @@ void USDImporterImplTinyusdz::verticesForMesh(
}
}
void USDImporterImplTinyusdz::facesForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
void USDImporterImplTinyusdz::facesForMesh(const RenderScene &render_scene, aiScene *pScene,
size_t meshIdx, const std::string &) {
pScene->mMeshes[meshIdx]->mNumFaces = static_cast<unsigned int>(render_scene.meshes[meshIdx].faceVertexCounts().size());
pScene->mMeshes[meshIdx]->mFaces = new aiFace[pScene->mMeshes[meshIdx]->mNumFaces]();
size_t faceVertIdxOffset = 0;
@@ -483,12 +471,8 @@ void USDImporterImplTinyusdz::facesForMesh(
}
}
void USDImporterImplTinyusdz::normalsForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
void USDImporterImplTinyusdz::normalsForMesh(const RenderScene &render_scene, aiScene *pScene,
size_t meshIdx, const std::string &) {
pScene->mMeshes[meshIdx]->mNormals = new aiVector3D[pScene->mMeshes[meshIdx]->mNumVertices];
const float *floatPtr = reinterpret_cast<const float *>(render_scene.meshes[meshIdx].normals.get_data().data());
for (size_t vertIdx = 0, fpj = 0; vertIdx < pScene->mMeshes[meshIdx]->mNumVertices; ++vertIdx, fpj += 3) {
@@ -498,20 +482,16 @@ void USDImporterImplTinyusdz::normalsForMesh(
}
}
void USDImporterImplTinyusdz::materialsForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(render_scene); UNUSED(pScene); UNUSED(meshIdx); UNUSED(nameWExt);
void USDImporterImplTinyusdz::materialsForMesh(const RenderScene&, aiScene*,
size_t, const std::string&) {
// todo
}
void USDImporterImplTinyusdz::uvsForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
const std::string&) {
const size_t uvSlotsCount = render_scene.meshes[meshIdx].texcoords.size();
if (uvSlotsCount < 1) {
return;
@@ -539,10 +519,8 @@ static aiColor3D *ownedColorPtrFor(const std::array<float, 3> &color) {
return colorPtr;
}
static std::string nameForTextureWithId(
const tinyusdz::tydra::RenderScene &render_scene,
const int targetId) {
stringstream ss;
static std::string nameForTextureWithId(const RenderScene &render_scene, const int targetId) {
std::stringstream ss;
std::string texName;
for (const auto &image : render_scene.images) {
if (image.buffer_id == targetId) {
@@ -560,16 +538,15 @@ static std::string nameForTextureWithId(
}
static void assignTexture(
const tinyusdz::tydra::RenderScene &render_scene,
const tinyusdz::tydra::RenderMaterial &material,
const RenderScene &render_scene,
const RenderMaterial &,
aiMaterial *mat,
const int textureId,
const int aiTextureType) {
UNUSED(material);
std::string name = nameForTextureWithId(render_scene, textureId);
aiString *texName = new aiString();
texName->Set(name);
stringstream ss;
std::stringstream ss;
ss.str("");
ss << "assignTexture(): name: " << name;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -581,9 +558,8 @@ void USDImporterImplTinyusdz::materials(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const std::string &nameWExt) {
const size_t numMaterials{render_scene.materials.size()};
(void) numMaterials; // Ignore unused variable when -Werror enabled
stringstream ss;
const size_t numMaterials{ render_scene.materials.size() };
std::stringstream ss;
ss.str("");
ss << "materials(): model" << nameWExt << ", numMaterials: " << numMaterials;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -591,6 +567,7 @@ void USDImporterImplTinyusdz::materials(
if (render_scene.materials.empty()) {
return;
}
pScene->mMaterials = new aiMaterial *[render_scene.materials.size()];
for (const auto &material : render_scene.materials) {
ss.str("");
@@ -673,22 +650,18 @@ void USDImporterImplTinyusdz::materials(
void USDImporterImplTinyusdz::textures(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
aiScene*,
const std::string &nameWExt) {
UNUSED(pScene);
const size_t numTextures{render_scene.textures.size()};
UNUSED(numTextures); // Ignore unused variable when -Werror enabled
stringstream ss;
const size_t numTextures{ render_scene.textures.size() };
std::stringstream ss;
ss.str("");
ss << "textures(): model" << nameWExt << ", numTextures: " << numTextures;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
size_t i{0};
UNUSED(i);
size_t i{ 0 };
for (const auto &texture : render_scene.textures) {
UNUSED(texture);
ss.str("");
ss << " texture[" << i << "]: id: " << texture.texture_image_id << ", disp name: |" << texture.display_name << "|, varname_uv: " <<
texture.varname_uv << ", prim_name: |" << texture.prim_name << "|, abs_path: |" << texture.abs_path << "|";
ss << " texture[" << i << "]: id: " << texture.texture_image_id << ", disp name: |" << texture.display_name << "|, varname_uv: " << texture.varname_uv << ", prim_name: |" << texture.prim_name << "|, abs_path: |" << texture.abs_path << "|";
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
++i;
}
@@ -702,15 +675,12 @@ void USDImporterImplTinyusdz::textures(
* @param nameWExt filename w/ext (use to extract file type hint)
* @return aiTexture ptr
*/
static aiTexture *ownedEmbeddedTextureFor(
const tinyusdz::tydra::RenderScene &render_scene,
const tinyusdz::tydra::TextureImage &image,
const std::string &nameWExt) {
UNUSED(nameWExt);
stringstream ss;
static aiTexture *ownedEmbeddedTextureFor(const RenderScene &render_scene, const TextureImage &image,
const std::string&) {
std::stringstream ss;
aiTexture *tex = new aiTexture();
size_t pos = image.asset_identifier.find_last_of('/');
string embTexName{image.asset_identifier.substr(pos + 1)};
std::string embTexName{ image.asset_identifier.substr(pos + 1) };
tex->mFilename.Set(image.asset_identifier.c_str());
tex->mHeight = image.height;
@@ -718,20 +688,20 @@ static aiTexture *ownedEmbeddedTextureFor(
if (tex->mHeight == 0) {
pos = embTexName.find_last_of('.');
strncpy(tex->achFormatHint, embTexName.substr(pos + 1).c_str(), 3);
const size_t imageBytesCount{render_scene.buffers[image.buffer_id].data.size()};
tex->pcData = (aiTexel *) new char[imageBytesCount];
const size_t imageBytesCount{ render_scene.buffers[image.buffer_id].data.size() };
tex->pcData = (aiTexel *)new char[imageBytesCount];
memcpy(tex->pcData, &render_scene.buffers[image.buffer_id].data[0], imageBytesCount);
} else {
string formatHint{"rgba8888"};
std::string formatHint{ "rgba8888" };
strncpy(tex->achFormatHint, formatHint.c_str(), 8);
const size_t imageTexelsCount{tex->mWidth * tex->mHeight};
tex->pcData = (aiTexel *) new char[imageTexelsCount * image.channels];
const size_t imageTexelsCount{ tex->mWidth * tex->mHeight };
tex->pcData = (aiTexel *)new char[imageTexelsCount * image.channels];
const float *floatPtr = reinterpret_cast<const float *>(&render_scene.buffers[image.buffer_id].data[0]);
ss.str("");
ss << "ownedEmbeddedTextureFor(): manual fill...";
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
for (size_t i = 0, fpi = 0; i < imageTexelsCount; ++i, fpi += 4) {
tex->pcData[i].b = static_cast<uint8_t>(floatPtr[fpi] * 255);
tex->pcData[i].b = static_cast<uint8_t>(floatPtr[fpi] * 255);
tex->pcData[i].g = static_cast<uint8_t>(floatPtr[fpi + 1] * 255);
tex->pcData[i].r = static_cast<uint8_t>(floatPtr[fpi + 2] * 255);
tex->pcData[i].a = static_cast<uint8_t>(floatPtr[fpi + 3] * 255);
@@ -743,13 +713,9 @@ static aiTexture *ownedEmbeddedTextureFor(
return tex;
}
void USDImporterImplTinyusdz::textureImages(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const std::string &nameWExt) {
stringstream ss;
const size_t numTextureImages{render_scene.images.size()};
UNUSED(numTextureImages); // Ignore unused variable when -Werror enabled
void USDImporterImplTinyusdz::textureImages(const RenderScene &render_scene, aiScene *pScene, const std::string &nameWExt) {
std::stringstream ss;
const size_t numTextureImages{ render_scene.images.size() };
ss.str("");
ss << "textureImages(): model" << nameWExt << ", numTextureImages: " << numTextureImages;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -757,13 +723,15 @@ void USDImporterImplTinyusdz::textureImages(
pScene->mNumTextures = 0;
for (const auto &image : render_scene.images) {
ss.str("");
ss << " image[" << pScene->mNumTextures << "]: |" << image.asset_identifier << "| w: " << image.width << ", h: " << image.height <<
", channels: " << image.channels << ", miplevel: " << image.miplevel << ", buffer id: " << image.buffer_id << "\n" <<
" buffers.size(): " << render_scene.buffers.size() << ", data empty? " << render_scene.buffers[image.buffer_id].data.empty();
ss << " image[" << pScene->mNumTextures << "]: |" << image.asset_identifier << "| w: "
<< image.width << ", h: " << image.height << ", channels: " << image.channels << ", miplevel: "
<< image.miplevel << ", buffer id: " << image.buffer_id << "\n"
<< " buffers.size(): " << render_scene.buffers.size() << ", data empty? "
<< render_scene.buffers[image.buffer_id].data.empty();
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
if (image.buffer_id > -1 &&
image.buffer_id < static_cast<long int>(render_scene.buffers.size()) &&
!render_scene.buffers[image.buffer_id].data.empty()) {
image.buffer_id < static_cast<long int>(render_scene.buffers.size()) &&
!render_scene.buffers[image.buffer_id].data.empty()) {
aiTexture *tex = ownedEmbeddedTextureFor(
render_scene,
image,
@@ -775,8 +743,8 @@ void USDImporterImplTinyusdz::textureImages(
pScene->mTextures = new aiTexture *[render_scene.images.size()];
}
ss.str("");
ss << " pScene->mTextures[" << pScene->mNumTextures << "] name: |" << tex->mFilename.C_Str() <<
"|, w: " << tex->mWidth << ", h: " << tex->mHeight << ", hint: " << tex->achFormatHint;
ss << " pScene->mTextures[" << pScene->mNumTextures << "] name: |" << tex->mFilename.C_Str()
<< "|, w: " << tex->mWidth << ", h: " << tex->mHeight << ", hint: " << tex->achFormatHint;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
pScene->mTextures[pScene->mNumTextures++] = tex;
}
@@ -784,12 +752,9 @@ void USDImporterImplTinyusdz::textureImages(
}
void USDImporterImplTinyusdz::buffers(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const std::string &nameWExt) {
const size_t numBuffers{render_scene.buffers.size()};
UNUSED(pScene); UNUSED(numBuffers); // Ignore unused variable when -Werror enabled
stringstream ss;
const RenderScene &render_scene, aiScene*, const std::string &nameWExt) {
const size_t numBuffers{ render_scene.buffers.size() };
std::stringstream ss;
ss.str("");
ss << "buffers(): model" << nameWExt << ", numBuffers: " << numBuffers;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
@@ -802,53 +767,9 @@ void USDImporterImplTinyusdz::buffers(
}
}
void USDImporterImplTinyusdz::setupNodes(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const tinyusdz::Stage &usdStage,
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
const std::string &nameWExt) {
stringstream ss;
pScene->mRootNode = nodes(render_scene, usdStage, meshNodes, nameWExt);
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
pScene->mRootNode->mMeshes = new unsigned int[pScene->mRootNode->mNumMeshes];
ss.str("");
ss << "setupNodes(): pScene->mNumMeshes: " << pScene->mNumMeshes;
if (pScene->mRootNode != nullptr) {
ss << ", mRootNode->mNumMeshes: " << pScene->mRootNode->mNumMeshes;
}
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
for (unsigned int meshIdx = 0; meshIdx < pScene->mNumMeshes; meshIdx++) {
pScene->mRootNode->mMeshes[meshIdx] = meshIdx;
}
}
aiNode *USDImporterImplTinyusdz::nodes(
const tinyusdz::tydra::RenderScene &render_scene,
const tinyusdz::Stage &usdStage,
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
const std::string &nameWExt) {
const size_t numNodes{render_scene.nodes.size()};
(void) numNodes; // Ignore unused variable when -Werror enabled
stringstream ss;
ss.str("");
ss << "nodes(): model" << nameWExt << ", numNodes: " << numNodes;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
return nodesRecursive(nullptr, usdStage.root_prims()[0], render_scene.nodes[0], meshNodes);
}
using Assimp::tinyusdzNodeTypeFor;
using Assimp::tinyUsdzMat4ToAiMat4;
using tinyusdz::tydra::NodeType;
aiNode *USDImporterImplTinyusdz::nodesRecursive(
aiNode *pNodeParent,
const tinyusdz::Prim& prim,
const tinyusdz::tydra::Node &node,
const std::vector<tinyusdz::tydra::SkelHierarchy> &skeletons) {
stringstream ss;
aiNode *USDImporterImplTinyusdz::nodesRecursive(aiNode *pNodeParent, const tinyusdz::tydra::Node &node,
const std::vector<SkelHierarchy> &skeletons) {
std::stringstream ss;
aiNode *cNode = new aiNode();
cNode->mParent = pNodeParent;
cNode->mName.Set(node.prim_name);
@@ -861,9 +782,9 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(
}
ss.str("");
ss << "nodesRecursive(): node " << cNode->mName.C_Str() <<
" type: |" << tinyusdzNodeTypeFor(node.nodeType) <<
"|, disp " << node.display_name << ", abs " << node.abs_path;
ss << "nodesRecursive(): node " << cNode->mName.C_Str() << " type: |"
<< tinyusdzNodeTypeFor(node.nodeType)
<< "|, disp " << node.display_name << ", abs " << node.abs_path;
if (cNode->mParent != nullptr) {
ss << " (parent " << cNode->mParent->mName.C_Str() << ")";
}
@@ -887,22 +808,6 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(
}
}
// Composition: references
if (prim.metas().references.has_value())
{
const tinyusdz::ListEditQual referenceQual = prim.metas().references->first;
const std::vector<tinyusdz::Reference> references = prim.metas().references->second;
for (const auto &reference : references)
{
cNode->mMetaData = aiMetadata::Alloc(1);
cNode->mMetaData->Add("ref", aiString(reference.asset_path.GetAssetPath()));
}
}
size_t i{0};
for (const auto &childNode: node.children) {
cNode->mChildren[i] = nodesRecursive(cNode, prim.children()[i], childNode, meshNodes);
cNode->mNumChildren = numChildren;
// Done. No more children.
@@ -920,15 +825,15 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(
if (skelNode != nullptr) {
// Convert USD skeleton into an Assimp node and make it the last child
cNode->mChildren[cNode->mNumChildren-1] = skeletonNodesRecursive(cNode, *skelNode);
cNode->mChildren[cNode->mNumChildren - 1] = skeletonNodesRecursive(cNode, *skelNode);
}
return cNode;
}
aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
aiNode* pNodeParent,
const tinyusdz::tydra::SkelNode& joint) {
aiNode *pNodeParent,
const SkelNode &joint) {
auto *cNode = new aiNode(joint.joint_path);
cNode->mParent = pNodeParent;
cNode->mNumMeshes = 0; // not a mesh node
@@ -943,7 +848,7 @@ aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
cNode->mChildren = new aiNode *[cNode->mNumChildren];
for (unsigned i = 0; i < cNode->mNumChildren; ++i) {
const tinyusdz::tydra::SkelNode &childJoint = joint.children[i];
const SkelNode &childJoint = joint.children[i];
cNode->mChildren[i] = skeletonNodesRecursive(cNode, childJoint);
}
@@ -952,7 +857,7 @@ aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
void USDImporterImplTinyusdz::sanityCheckNodesRecursive(
aiNode *cNode) {
stringstream ss;
std::stringstream ss;
ss.str("");
ss << "sanityCheckNodesRecursive(): node " << cNode->mName.C_Str();
if (cNode->mParent != nullptr) {
@@ -965,16 +870,14 @@ void USDImporterImplTinyusdz::sanityCheckNodesRecursive(
}
}
void USDImporterImplTinyusdz::setupBlendShapes(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
void USDImporterImplTinyusdz::setupBlendShapes(const RenderScene &render_scene, aiScene *pScene,
const std::string &nameWExt) {
stringstream ss;
std::stringstream ss;
ss.str("");
ss << "setupBlendShapes(): iterating over " << pScene->mNumMeshes << " meshes for model" << nameWExt;
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
for (size_t meshIdx = 0; meshIdx < pScene->mNumMeshes; meshIdx++) {
blendShapesForMesh(render_scene, pScene, meshIdx, nameWExt);
blendShapesForMesh(render_scene, pScene, meshIdx, nameWExt);
}
}
@@ -982,10 +885,9 @@ void USDImporterImplTinyusdz::blendShapesForMesh(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
size_t meshIdx,
const std::string &nameWExt) {
UNUSED(nameWExt);
stringstream ss;
const unsigned int numBlendShapeTargets{static_cast<unsigned int>(render_scene.meshes[meshIdx].targets.size())};
const std::string &) {
std::stringstream ss;
const unsigned int numBlendShapeTargets{ static_cast<unsigned int>(render_scene.meshes[meshIdx].targets.size()) };
UNUSED(numBlendShapeTargets); // Ignore unused variable when -Werror enabled
ss.str("");
ss << " blendShapesForMesh(): mesh[" << meshIdx << "], numBlendShapeTargets: " << numBlendShapeTargets;
@@ -995,15 +897,13 @@ void USDImporterImplTinyusdz::blendShapesForMesh(
pScene->mMeshes[meshIdx]->mAnimMeshes = new aiAnimMesh *[pScene->mMeshes[meshIdx]->mNumAnimMeshes];
}
auto mapIter = render_scene.meshes[meshIdx].targets.begin();
size_t animMeshIdx{0};
size_t animMeshIdx{ 0 };
for (; mapIter != render_scene.meshes[meshIdx].targets.end(); ++mapIter) {
const std::string name{mapIter->first};
const tinyusdz::tydra::ShapeTarget shapeTarget{mapIter->second};
const std::string name{ mapIter->first };
const tinyusdz::tydra::ShapeTarget shapeTarget{ mapIter->second };
pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx] = aiCreateAnimMesh(pScene->mMeshes[meshIdx]);
ss.str("");
ss << " mAnimMeshes[" << animMeshIdx << "]: mNumVertices: " << pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mNumVertices <<
", target: " << shapeTarget.pointIndices.size() << " pointIndices, " << shapeTarget.pointOffsets.size() <<
" pointOffsets, " << shapeTarget.normalOffsets.size() << " normalOffsets";
ss << " mAnimMeshes[" << animMeshIdx << "]: mNumVertices: " << pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mNumVertices << ", target: " << shapeTarget.pointIndices.size() << " pointIndices, " << shapeTarget.pointOffsets.size() << " pointOffsets, " << shapeTarget.normalOffsets.size() << " normalOffsets";
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
for (size_t iVert = 0; iVert < shapeTarget.pointOffsets.size(); ++iVert) {
pScene->mMeshes[meshIdx]->mAnimMeshes[animMeshIdx]->mVertices[shapeTarget.pointIndices[iVert]] +=
@@ -1014,12 +914,7 @@ void USDImporterImplTinyusdz::blendShapesForMesh(
tinyUsdzScaleOrPosToAssimp(shapeTarget.normalOffsets[iVert]);
}
ss.str("");
ss << " target[" << animMeshIdx << "]: name: " << name << ", prim_name: " <<
shapeTarget.prim_name << ", abs_path: " << shapeTarget.abs_path <<
", display_name: " << shapeTarget.display_name << ", " << shapeTarget.pointIndices.size() <<
" pointIndices, " << shapeTarget.pointOffsets.size() << " pointOffsets, " <<
shapeTarget.normalOffsets.size() << " normalOffsets, " << shapeTarget.inbetweens.size() <<
" inbetweens";
ss << " target[" << animMeshIdx << "]: name: " << name << ", prim_name: " << shapeTarget.prim_name << ", abs_path: " << shapeTarget.abs_path << ", display_name: " << shapeTarget.display_name << ", " << shapeTarget.pointIndices.size() << " pointIndices, " << shapeTarget.pointOffsets.size() << " pointOffsets, " << shapeTarget.normalOffsets.size() << " normalOffsets, " << shapeTarget.inbetweens.size() << " inbetweens";
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
++animMeshIdx;
}

View File

@@ -43,21 +43,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Declaration of the USD importer class.
*/
#pragma once
#ifndef AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
#define AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED
#include "tinyusdz.hh"
#include "tydra/render-data.hh"
#include <assimp/BaseImporter.h>
#include <assimp/scene.h>
#include <assimp/types.h>
#include <vector>
#include <cstdint>
#include "tinyusdz.hh"
#include "tydra/render-data.hh"
#include <vector>
namespace Assimp {
/**
* @brief USD Importer implementation using tinyusdz.
*/
class USDImporterImplTinyusdz {
public:
/// @brief The class constructor.
USDImporterImplTinyusdz() = default;
/// @brief The class destructor.
~USDImporterImplTinyusdz() = default;
void InternReadFile(
@@ -124,23 +132,8 @@ public:
aiScene *pScene,
const std::string &nameWExt);
void setupNodes(
const tinyusdz::tydra::RenderScene &render_scene,
aiScene *pScene,
const tinyusdz::Stage &usdStage,
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
const std::string &nameWExt
);
aiNode *nodes(
const tinyusdz::tydra::RenderScene &render_scene,
const tinyusdz::Stage &usdStage,
std::map<size_t, tinyusdz::tydra::Node> &meshNodes,
const std::string &nameWExt);
aiNode *nodesRecursive(
aiNode *pNodeParent,
const tinyusdz::Prim &prim,
const tinyusdz::tydra::Node &node,
const std::vector<tinyusdz::tydra::SkelHierarchy> &skeletons);
@@ -162,5 +155,7 @@ public:
size_t meshIdx,
const std::string &nameWExt);
};
} // namespace Assimp
#endif // AI_USDLOADER_IMPL_TINYUSDZ_H_INCLUDED

View File

@@ -364,11 +364,8 @@ struct CustomExtension {
}
CustomExtension() = default;
~CustomExtension() = default;
CustomExtension(const CustomExtension &other) = default;
CustomExtension& operator=(const CustomExtension&) = default;
};
@@ -423,7 +420,6 @@ public:
Type_text
};
/// \struct SEncodedRegion
/// Descriptor of encoded region in "bufferView".
struct SEncodedRegion {
const size_t Offset; ///< Offset from begin of "bufferView" to encoded region, in bytes.
@@ -432,7 +428,6 @@ public:
const size_t DecodedData_Length; ///< Size of decoded region, in bytes.
const std::string ID; ///< ID of the region.
/// \fn SEncodedRegion(const size_t pOffset, const size_t pEncodedData_Length, uint8_t* pDecodedData, const size_t pDecodedData_Length, const std::string pID)
/// Constructor.
/// \param [in] pOffset - offset from begin of "bufferView" to encoded region, in bytes.
/// \param [in] pEncodedData_Length - size of encoded region, in bytes.
@@ -446,7 +441,6 @@ public:
DecodedData_Length(pDecodedData_Length),
ID(pID) {}
/// \fn ~SEncodedRegion()
/// Destructor.
~SEncodedRegion() { delete[] DecodedData; }
};
@@ -460,7 +454,6 @@ public:
Type type;
/// \var EncodedRegion_Current
/// Pointer to currently active encoded region.
/// Why not decoding all regions at once and not to set one buffer with decoded data?
/// Yes, why not? Even "accessor" point to decoded data. I mean that fields "byteOffset", "byteStride" and "count" has values which describes decoded
@@ -500,7 +493,6 @@ public:
bool LoadFromStream(IOStream &stream, size_t length = 0, size_t baseOffset = 0);
/// \fn void EncodedRegion_Mark(const size_t pOffset, const size_t pEncodedData_Length, uint8_t* pDecodedData, const size_t pDecodedData_Length, const std::string& pID)
/// Mark region of "bufferView" as encoded. When data is request from such region then "bufferView" use decoded data.
/// \param [in] pOffset - offset from begin of "bufferView" to encoded region, in bytes.
/// \param [in] pEncodedData_Length - size of encoded region, in bytes.
@@ -509,12 +501,10 @@ public:
/// \param [in] pID - ID of the region.
void EncodedRegion_Mark(const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string &pID);
/// \fn void EncodedRegion_SetCurrent(const std::string& pID)
/// Select current encoded region by ID. \sa EncodedRegion_Current.
/// \param [in] pID - ID of the region.
void EncodedRegion_SetCurrent(const std::string &pID);
/// \fn bool ReplaceData(const size_t pBufferData_Offset, const size_t pBufferData_Count, const uint8_t* pReplace_Data, const size_t pReplace_Count)
/// Replace part of buffer data. Pay attention that function work with original array of data (\ref mData) not with encoded regions.
/// \param [in] pBufferData_Offset - index of first element in buffer from which new data will be placed.
/// \param [in] pBufferData_Count - count of bytes in buffer which will be replaced.
@@ -1002,27 +992,24 @@ struct Texture : public Object {
struct Animation : public Object {
struct Sampler {
Sampler() :
interpolation(Interpolation_LINEAR) {}
Sampler() = default;
Ref<Accessor> input; //!< Accessor reference to the buffer storing the key-frame times.
Ref<Accessor> output; //!< Accessor reference to the buffer storing the key-frame values.
Interpolation interpolation; //!< Type of interpolation algorithm to use between key-frames.
Interpolation interpolation{Interpolation_LINEAR}; //!< Type of interpolation algorithm to use between key-frames.
};
struct Target {
Target() :
path(AnimationPath_TRANSLATION) {}
Target() = default;
Ref<Node> node; //!< The node to animate.
AnimationPath path; //!< The property of the node to animate.
AnimationPath path{AnimationPath_TRANSLATION}; //!< The property of the node to animate.
};
struct Channel {
Channel() :
sampler(-1) {}
Channel() = default;
int sampler; //!< The sampler index containing the animation data.
int sampler{-1}; //!< The sampler index containing the animation data.
Target target; //!< The node and property to animate.
};
@@ -1135,50 +1122,34 @@ class Asset {
public:
//! Keeps info about the enabled extensions
struct Extensions {
bool KHR_materials_pbrSpecularGlossiness;
bool KHR_materials_specular;
bool KHR_materials_unlit;
bool KHR_lights_punctual;
bool KHR_texture_transform;
bool KHR_materials_sheen;
bool KHR_materials_clearcoat;
bool KHR_materials_transmission;
bool KHR_materials_volume;
bool KHR_materials_ior;
bool KHR_materials_emissive_strength;
bool KHR_materials_anisotropy;
bool KHR_draco_mesh_compression;
bool FB_ngon_encoding;
bool KHR_texture_basisu;
bool KHR_materials_pbrSpecularGlossiness{false};
bool KHR_materials_specular{false};
bool KHR_materials_unlit{false};
bool KHR_lights_punctual{false};
bool KHR_texture_transform{false};
bool KHR_materials_sheen{false};
bool KHR_materials_clearcoat{false};
bool KHR_materials_transmission{false};
bool KHR_materials_volume{false};
bool KHR_materials_ior{false};
bool KHR_materials_emissive_strength{false};
bool KHR_materials_anisotropy{false};
bool KHR_draco_mesh_compression{false};
bool FB_ngon_encoding{false};
bool KHR_texture_basisu{false};
bool EXT_texture_webp{false};
Extensions() :
KHR_materials_pbrSpecularGlossiness(false),
KHR_materials_specular(false),
KHR_materials_unlit(false),
KHR_lights_punctual(false),
KHR_texture_transform(false),
KHR_materials_sheen(false),
KHR_materials_clearcoat(false),
KHR_materials_transmission(false),
KHR_materials_volume(false),
KHR_materials_ior(false),
KHR_materials_emissive_strength(false),
KHR_materials_anisotropy(false),
KHR_draco_mesh_compression(false),
FB_ngon_encoding(false),
KHR_texture_basisu(false) {
// empty
}
Extensions() = default;
~Extensions() = default;
} extensionsUsed;
//! Keeps info about the required extensions
struct RequiredExtensions {
bool KHR_draco_mesh_compression;
bool KHR_texture_basisu;
bool KHR_draco_mesh_compression{false};
bool KHR_texture_basisu{false};
bool EXT_texture_webp{false};
RequiredExtensions() : KHR_draco_mesh_compression(false), KHR_texture_basisu(false) {
// empty
}
RequiredExtensions() = default;
} extensionsRequired;
AssetMetadata asset;

View File

@@ -1217,6 +1217,13 @@ inline void Texture::Read(Value &obj, Asset &r) {
if (r.extensionsUsed.KHR_texture_basisu) {
if (Value *curBasisU = FindObject(*extensions, "KHR_texture_basisu")) {
if (Value *sourceVal = FindUInt(*curBasisU, "source")) {
source = r.images.Retrieve(sourceVal->GetUint());
}
}
} else if(r.extensionsUsed.EXT_texture_webp) {
if (Value *curBasisU = FindObject(*extensions, "EXT_texture_webp")) {
if (Value *sourceVal = FindUInt(*curBasisU, "source")) {
source = r.images.Retrieve(sourceVal->GetUint());
}
@@ -2149,6 +2156,7 @@ inline void Asset::ReadExtensionsRequired(Document &doc) {
CHECK_REQUIRED_EXT(KHR_draco_mesh_compression);
CHECK_REQUIRED_EXT(KHR_texture_basisu);
CHECK_REQUIRED_EXT(EXT_texture_webp);
#undef CHECK_REQUIRED_EXT
}
@@ -2179,6 +2187,7 @@ inline void Asset::ReadExtensionsUsed(Document &doc) {
CHECK_EXT(KHR_materials_anisotropy);
CHECK_EXT(KHR_draco_mesh_compression);
CHECK_EXT(KHR_texture_basisu);
CHECK_EXT(EXT_texture_webp);
#undef CHECK_EXT
}

View File

@@ -1663,7 +1663,7 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
ext = "kx2";
} else if (strcmp(ext, "basis") == 0) { // basisu
ext = "bu";
}
} // webp requires no transformation
size_t len = strlen(ext);
if (len > 3) len = 3;

View File

@@ -1,4 +1,4 @@
/* stb_image - v2.29 - public domain image loader - http://nothings.org/stb
/* stb_image - v2.30 - public domain image loader - http://nothings.org/stb
no warranty implied; use at your own risk
Do this:
@@ -48,6 +48,7 @@ LICENSE
RECENT REVISION HISTORY:
2.30 (2024-05-31) avoid erroneous gcc warning
2.29 (2023-05-xx) optimizations
2.28 (2023-01-29) many error fixes, security errors, just tons of stuff
2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
@@ -5159,9 +5160,11 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
// non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
if (z->depth == 16) {
for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
for (k = 0; k < s->img_n && k < 3; ++k) // extra loop test to suppress false GCC warning
tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
} else {
for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
for (k = 0; k < s->img_n && k < 3; ++k)
tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
}
}
break;

View File

@@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "My Project"
PROJECT_NAME = "The Open Asset Importer Lib"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER =
PROJECT_NUMBER = "6.0.2"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
PROJECT_BRIEF =
PROJECT_BRIEF = The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one unified and clean data structure.
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
@@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.
OUTPUT_DIRECTORY =
OUTPUT_DIRECTORY = out
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and

View File

@@ -47,6 +47,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
// Limit input size to 1MB to prevent OOMs and timeouts
if (dataSize > 1024 * 1024) {
return 0;
}
#ifdef _DEBUG
aiLogStream stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT, nullptr);
aiAttachLogStream(&stream);

40
fuzz/assimp_fuzzer.dict Normal file
View File

@@ -0,0 +1,40 @@
# OBJ
"v "
"vn "
"vt "
"f "
"mtllib "
"usemtl "
# GLTF (JSON)
"asset"
"scene"
"scenes"
"nodes"
"meshes"
"accessors"
"bufferViews"
"buffers"
# PLY
"ply"
"format"
"element"
"property"
"vertex"
"face"
# STL
"solid"
"facet"
"normal"
"outer loop"
"vertex"
"endloop"
"endfacet"
"endsolid"
# Collada (XML)
"COLLADA"
"library_geometries"
"library_visual_scenes"

View File

@@ -0,0 +1,63 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2025, 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 "fuzzer_common.h"
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
using namespace Assimp;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
if (dataSize > 1024 * 1024) {
return 0;
}
Importer importer;
// Force Collada format (dae)
if (!AssimpFuzz::ForceFormat(importer, "dae")) {
return 0;
}
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "dae");
return 0;
}

View File

@@ -1,13 +1,15 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
----------------------------------------------------------------------
---------------------------------------------------------------------------
Copyright (c) 2006-2025, assimp team
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:
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
@@ -34,7 +36,28 @@ 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 "fuzzer_common.h"
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
using namespace Assimp;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
if (dataSize > 1024 * 1024) {
return 0;
}
Importer importer;
// Force FBX format
if (!AssimpFuzz::ForceFormat(importer, "fbx")) {
return 0;
}
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "fbx");
return 0;
}

63
fuzz/assimp_fuzzer_glb.cc Normal file
View File

@@ -0,0 +1,63 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2025, 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 "fuzzer_common.h"
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
using namespace Assimp;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
if (dataSize > 1024 * 1024) {
return 0;
}
Importer importer;
// Force GLB binary format only (see assimp_fuzzer_gltf.cc for text glTF)
if (!AssimpFuzz::ForceFormat(importer, "glb")) {
return 0;
}
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "glb");
return 0;
}

View File

@@ -0,0 +1,63 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2025, 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 "fuzzer_common.h"
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
using namespace Assimp;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
if (dataSize > 1024 * 1024) {
return 0;
}
Importer importer;
// Force glTF text format only (see assimp_fuzzer_glb.cc for binary GLB)
if (!AssimpFuzz::ForceFormat(importer, "gltf")) {
return 0;
}
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "gltf");
return 0;
}

65
fuzz/assimp_fuzzer_obj.cc Normal file
View File

@@ -0,0 +1,65 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2025, 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 "fuzzer_common.h"
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
using namespace Assimp;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
// Limit input size to 1MB
if (dataSize > 1024 * 1024) {
return 0;
}
Importer importer;
// Force OBJ format
if (!AssimpFuzz::ForceFormat(importer, "obj")) {
return 0;
}
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
// We pass "obj" hint as well, though only OBJ loader is registered now.
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "obj");
return 0;
}

63
fuzz/assimp_fuzzer_stl.cc Normal file
View File

@@ -0,0 +1,63 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2025, 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 "fuzzer_common.h"
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
using namespace Assimp;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
if (dataSize > 1024 * 1024) {
return 0;
}
Importer importer;
// Force STL format
if (!AssimpFuzz::ForceFormat(importer, "stl")) {
return 0;
}
unsigned int flags = aiProcessPreset_TargetRealtime_Quality | aiProcess_ValidateDataStructure;
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize, flags, "stl");
return 0;
}

107
fuzz/fuzzer_common.h Normal file
View File

@@ -0,0 +1,107 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2025, 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.
---------------------------------------------------------------------------
*/
#pragma once
#include <assimp/Importer.hpp>
#include <assimp/BaseImporter.h>
#include <assimp/importerdesc.h>
#include <cstring>
#include <vector>
namespace AssimpFuzz {
// Unregisters all loaders except the ones matching the given extension.
// Returns true if at least one loader was kept.
inline bool ForceFormat(Assimp::Importer& importer, const char* targetExtension) {
size_t count = importer.GetImporterCount();
std::vector<Assimp::BaseImporter*> toRemove;
bool found = false;
for (size_t i = 0; i < count; ++i) {
const aiImporterDesc* desc = importer.GetImporterInfo(i);
Assimp::BaseImporter* imp = importer.GetImporter(i);
if (!desc || !imp) continue;
// Check if the importer supports the target extension
// mFileExtensions is a space-separated list (e.g., "obj mod")
// We wrap target in spaces or check bounds to be precise,
// but for fuzzing, a simple strstr is usually sufficient
// if the target string is unique enough (e.g. "gltf", "obj").
// A more robust check:
bool isTarget = false;
const char* extList = desc->mFileExtensions;
if (!extList) {
toRemove.push_back(imp);
continue;
}
const size_t targetLen = strlen(targetExtension);
const char* p = extList;
while ((p = strstr(p, targetExtension)) != nullptr) {
// Check boundaries
const char prev = (p == extList) ? ' ' : *(p - 1);
const char next = *(p + targetLen);
if (prev == ' ' && (next == ' ' || next == '\0')) {
isTarget = true;
break;
}
p++;
}
if (isTarget) {
found = true;
} else {
toRemove.push_back(imp);
}
}
for (auto* imp : toRemove) {
importer.UnregisterLoader(imp);
delete imp; // Free the unregistered importer to prevent memory leaks
}
return found;
}
}

22
fuzz/ossfuzz/Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#
################################################################################
FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update && apt-get install -y make autoconf automake libtool ninja-build cmake zip
RUN git clone --depth 1 https://github.com/assimp/assimp.git assimp
WORKDIR assimp
COPY build.sh $SRC/

100
fuzz/ossfuzz/build.sh Executable file
View File

@@ -0,0 +1,100 @@
#!/bin/bash -eu
# Build directory
mkdir -p build
cd build
# Configure
cmake .. \
-G Ninja \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DASSIMP_BUILD_ZLIB=ON \
-DASSIMP_BUILD_TESTS=OFF \
-DASSIMP_BUILD_ASSIMP_TOOLS=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=ON \
-DASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=ON
# Build the library
ninja
# Helper function to build fuzzers
build_fuzzer() {
local fuzzer_name=$1
local source_file=$2
echo "Building $fuzzer_name..."
$CXX $CXXFLAGS -I../include -I../build/include -c "$source_file" -o "${fuzzer_name}.o"
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE "${fuzzer_name}.o" -o "$OUT/${fuzzer_name}" \
./lib/libassimp.a \
./contrib/zlib/libzlibstatic.a \
-lpthread -ldl
}
# 1. Generic Fuzzer
build_fuzzer "assimp_fuzzer" "../fuzz/assimp_fuzzer.cc"
# Corpus for generic fuzzer (all models)
(cd ../test/models && zip -q -r $OUT/assimp_fuzzer_seed_corpus.zip .)
# Dictionary
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer.dict || true
# 2. OBJ Fuzzer
build_fuzzer "assimp_fuzzer_obj" "../fuzz/assimp_fuzzer_obj.cc"
if [ -d "../test/models/OBJ" ]; then
(cd ../test/models/OBJ && zip -q -r $OUT/assimp_fuzzer_obj_seed_corpus.zip .)
fi
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_obj.dict || true
# 3. GLTF Fuzzer (text format only, glTF and glTF2 versions)
build_fuzzer "assimp_fuzzer_gltf" "../fuzz/assimp_fuzzer_gltf.cc"
mkdir -p gltf_corpus
[ -d "../test/models/glTF" ] && cp -r ../test/models/glTF/* gltf_corpus/
[ -d "../test/models/glTF2" ] && cp -r ../test/models/glTF2/* gltf_corpus/
if [ -d "gltf_corpus" ] && [ "$(ls -A gltf_corpus)" ]; then
(cd gltf_corpus && zip -q -r $OUT/assimp_fuzzer_gltf_seed_corpus.zip .)
fi
rm -rf gltf_corpus
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_gltf.dict || true
# 4. GLB Fuzzer (binary glTF format)
build_fuzzer "assimp_fuzzer_glb" "../fuzz/assimp_fuzzer_glb.cc"
mkdir -p glb_corpus
# GLB files can be found in glTF and glTF2 directories
[ -d "../test/models/glTF" ] && find ../test/models/glTF -name "*.glb" -exec cp {} glb_corpus/ \; 2>/dev/null || true
[ -d "../test/models/glTF2" ] && find ../test/models/glTF2 -name "*.glb" -exec cp {} glb_corpus/ \; 2>/dev/null || true
if [ -d "glb_corpus" ] && [ "$(ls -A glb_corpus)" ]; then
(cd glb_corpus && zip -q -r $OUT/assimp_fuzzer_glb_seed_corpus.zip .)
fi
rm -rf glb_corpus
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_glb.dict || true
# 5. FBX Fuzzer
build_fuzzer "assimp_fuzzer_fbx" "../fuzz/assimp_fuzzer_fbx.cc"
if [ -d "../test/models/FBX" ]; then
(cd ../test/models/FBX && zip -q -r $OUT/assimp_fuzzer_fbx_seed_corpus.zip .)
fi
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_fbx.dict || true
# 6. Collada Fuzzer
build_fuzzer "assimp_fuzzer_collada" "../fuzz/assimp_fuzzer_collada.cc"
if [ -d "../test/models/Collada" ]; then
(cd ../test/models/Collada && zip -q -r $OUT/assimp_fuzzer_collada_seed_corpus.zip .)
fi
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_collada.dict || true
# 7. STL Fuzzer
build_fuzzer "assimp_fuzzer_stl" "../fuzz/assimp_fuzzer_stl.cc"
if [ -d "../test/models/STL" ]; then
(cd ../test/models/STL && zip -q -r $OUT/assimp_fuzzer_stl_seed_corpus.zip .)
fi
cp ../fuzz/assimp_fuzzer.dict $OUT/assimp_fuzzer_stl.dict || true

14
fuzz/ossfuzz/project.yaml Normal file
View File

@@ -0,0 +1,14 @@
homepage: "https://github.com/assimp/assimp"
main_repo: "https://github.com/assimp/assimp"
language: c++
primary_contact: "kim.kulling@assimp.org"
auto_ccs:
- "kim.kulling@googlemail.com"
sanitizers:
- address
- undefined
- memory
fuzzing_engines:
- libfuzzer
- afl
- honggfuzz

View File

@@ -147,8 +147,6 @@ SET( IMPORTERS
unit/utBlendImportMaterials.cpp
unit/utBlenderWork.cpp
unit/utBVHImportExport.cpp
unit/utColladaExport.cpp
unit/utColladaImportExport.cpp
unit/utCSMImportExport.cpp
unit/utB3DImportExport.cpp
#unit/utM3DImportExport.cpp
@@ -180,6 +178,18 @@ if(ASSIMP_BUILD_USD_IMPORTER)
)
endif()
if(ASSIMP_BUILD_COLLADA_EXPORTER)
list( APPEND IMPORTERS
unit/utColladaExport.cpp
)
endif()
if(ASSIMP_BUILD_COLLADA_IMPORTER)
list( APPEND IMPORTERS
unit/utColladaImportExport.cpp
)
endif()
SET( MATERIAL
unit/utMaterialSystem.cpp
)