A from-scratch C11 reimplementation of tinyobjloader: secure, portable,
freestanding-capable, dependency-free, fast, and robust. Not header-only
(tiny_obj_c.c + tiny_obj_c.h, plus a separate tobj_tess tessellation library).
Highlights:
- Dual precision: float (_f) and double (_d) families coexist in one build,
generated from a single template via token-pasting.
- Freestanding / no-dependency: the core links zero libc symbols (verified with
nm under -ffreestanding -DTOBJ_NO_LIBC). Injectable allocator, bundled
ASCII->float parser, no math.h in the core or default tessellator.
- Robust tessellation (tobj_tess): Newell projection with bbox fallback,
magnitude-scaled epsilons, convex fan fast path, and a force-clip backstop
that always emits n-2 triangles and never crashes/loops on degenerate,
concave, collinear, coincident, non-planar, or self-intersecting input.
- Primitives: faces (triangulated), lines, points, and free-form patches
(cstype/curv/curv2/surf/vp/parm/trim/hole/end) parsed and retained losslessly.
- Full material support: Phong + PBR + 13 texture channels with options,
unknown-parameter map, map_Kd-without-Kd default, standalone .mtl API,
material resolver callback, and a streaming callback API.
- Optional perf behind macros (scalar/single-threaded default): multithreaded
two-pass parse (byte-identical to single-threaded), SIMD newline scan
(AVX2/SSE2/NEON), mmap + file I/O, arena allocator, fast float.
- Security: bounds-checked indices, overflow-safe sizing, configurable caps.
Validation (all under ASan + UBSan): 84-file corpus loads with 0 failures;
acutest drivers tester_c (12) and tess_tester (15) pass; freestanding driver
runs with a custom allocator; MT output is byte-identical to single-threaded;
libFuzzer runs find no crashes/leaks. CMake and tests/Makefile integration with
a fuzzer entry point.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
A from-scratch pure C11 reimplementation of tinyobjloader: secure, portable, freestanding-capable, dependency-free, fast, and robust. Not header-only — tiny_obj_c.c + tiny_obj_c.h, plus a separate reusable tessellation library tobj_tess.{c,h}. Carries the C++ feature set over to C11 and adds line/point/free-form-patch primitives.
Highlights
Validation (all under ASan + UBSan)
Build / test
Added options in CMakeLists.txt: TINYOBJLOADER_BUILD_C_LIBRARY (ON), TINYOBJLOADER_C_ENABLE_FILE_IO/MMAP/SIMD/MULTITHREADING, TINYOBJLOADER_C_BUILD_TESTS, plus a fuzz_tobj_c target under LIB_FUZZING_ENGINE.
Known limitation
In the multithreaded path, curv2→vp index resolution can differ from single-threaded only when vp lines have inconsistent component counts (a pathological free-form case); it does not affect the corpus or normal use. A reserved tobj_mathops hook is currently unused (the default tessellator needs no sqrt).
🤖 Generated with Claude Code