feat(importer): ufbx FBX importer + meshoptimizer + Bistro pipeline fixes - #668
Merged
Conversation
Add FbxImporter backed by ufbx v0.14.3 — a single-file C library that supports FBX binary and ASCII formats from 2010 to 2023 (versions 6100–7700), 2–5× faster than Assimp on large files. FbxImporter: - ufbx auto-converts to Y-up and meters (target_axes + target_unit_meters) - Per-face vertex deduplication via (pos,nrm,uv) hash map - UV V-channel flipped (FBX convention) - Per-mesh material extraction with PBR color + texture UUIDs - ImportOptions respected: scale, normals mode, mat/tex gating, flip UV - Progress callbacks at 0.2 / 0.5 / 0.8 / 1.0 AssimpImporter::CanImport now returns true only for "obj" — FBX handled by FbxImporter which is registered first in Engine::Initialize. CMakePresets: remove ASSIMP_BUILD_FBX_IMPORTER (no longer needed). Assimp stays for OBJ only. Closes #667
This was referenced Aug 24, 2026
meshoptimizer v0.22:
- 3-pass optimization per submesh (vertex cache, overdraw, vertex fetch)
- Temp buffers use malloc/free — no arena accumulation across submeshes
- Integrated in FbxImporter and GltfImporter
FbxImporter arena — use ZGetScratch/ZReleaseScratch:
- Replace CreateSubArena(440) with ZGetScratch(&Arena) in ImportFile
- Replace CreateSubArena(64) with ZGetScratch(&Arena) in Import
- Arena.Clear() at start of ImportFile guards against previous crash state
- ZReleaseScratch at end restores cursor
ReloadFromDisk mesh deserialization:
- Use s_Instance->Arena instead of 64MB caller scratch — prevents
OOM crash when reloading large .zemesh files on cold start
Memory budgets:
- ImportPipeline: 1 GB → 3.5 GB (ufbx×2=1GB, gltf×2=128MB, assimp×2=256MB)
- AssetManager: 512 MB → 1 GB (mesh deserialization scratch)
- GLOBAL_VTX_CAPACITY: 256 MB → 512 MB (Bistro needs ~272 MB)
- GLOBAL_IDX_CAPACITY: 256 MB → 512 MB
- MAX_DRAW_COMMANDS: 512 → 8192 (Bistro has ~8000+ submeshes)
Verified: Amazon Lumberyard Bistro exterior FBX (8.5M verts, 272 MB)
imports and renders in the editor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full FBX import pipeline with ufbx, mesh optimization, and all fixes needed to render the Amazon Lumberyard Bistro exterior (8.5M vertices, 272 MB).
ufbx v0.14.3 FBX importer (
FbxImporter)target_axes,target_unit_meters)(pos, nrm, uv)hash mapZGetScratch(&Arena)/ZReleaseScratch— correct engine scratch arena patternmeshoptimizer v0.22 (
MeshOptimizer.h)meshopt_optimizeVertexCache,meshopt_optimizeOverdraw,meshopt_optimizeVertexFetchmalloc/free— no arena accumulation across submeshesFbxImporter::ImportFileandGltfImporter::ImportFilePipeline fixes for large scenes
ReloadFromDiskmesh deserialization usess_Instance->Arena(1 GB) instead of 64 MB caller scratch — prevents cold-start OOM crash on 292 MB .zemesh filesArena.Clear()at start ofImportFileguards against dirty state from previous crashed importAssetState::Loadedrecords inReloadFromDiskto prevent duplicate ingestMemory budgets grown
Verified
Amazon Lumberyard Bistro exterior FBX: 8.5M vertices, 272 MB, 8000+ draw commands — imports and renders in the editor.
Closes #667