Commit graph Crafter.Asset/lib
Author SHA1 Message Date
c04b7a331a
feat(glb): a loader for binary glTF, and images decoded from memory
- Crafter.Asset:GLB. GlbAsset::Load reads a .glb from a file or a buffer:
  - nodes, with their parents;
  - every mesh's primitives: positions, normals, UV0, tangents (computed
    when absent), joints, weights (normalized), u32 indices;
  - skins with their inverse-bind matrices;
  - materials: PBR, emissive strength, transmission, ior, alpha mode;
  - images decoded to RGBA8, and samplers;
  - cameras and KHR_lights_punctual lights;
  - the raw JSON, and the extras of the scene, nodes, materials and lights.
  nlohmann/json 3.12.0 is vendored in lib/; only the implementation sees it.
- A broken file comes back as an error rather than a crash:
  - bad magic, truncation, a sparse accessor;
  - a chunk, view or accessor past its bounds, checked so that nothing
    wraps round, with 32-bit size_t too;
  - a stride outside 4..252, or one its elements overlap in;
  - a reference to something that doesn't exist, or children that form a
    cycle (found stepping through each node once, however deep);
  - a path that isn't a file;
  - an image larger than a texture's 65535 a side.
- TextureAsset::LoadPNGFromMemory decodes an image already in memory.
  LoadPNG refuses images over 65535 a side instead of truncating their size
  (in its float path, past the end of the pixels).
- Tests: GLB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 19:46:43 +02:00
Crafter Build CI
021ced683d fix vendored libdeflate _rotr* macros colliding with mingw stdlib.h
compiler_gcc.h defined _rotl/_rotr/_rotl64/_rotr64 as macros before
mingw's <stdlib.h> got a chance to declare them as functions. Any
translation unit that did `#include "lib_common.h"` (which transitively
pulls in compiler_gcc.h) and later included <stdlib.h> — utils.c does
exactly this — would have the mingw function declarations textually
substituted by the macros, producing a syntax error.

Force <stdlib.h> in from compiler_gcc.h on mingw so the function
declarations are parsed before the macro names get shadowed. The
later #include in utils.c becomes a no-op via the header guard, and
call sites still resolve to the macros below (so the generated code
is unchanged on every other compiler/target).

This unblocks the Crafter.Build CI's x86_64-w64-mingw32 cross-compile,
which has been failing for a while when building Crafter.Asset →
gdeflate → libdeflate as a dep.
2026-05-27 02:23:53 +00:00
765cf33069 wasm 2026-05-18 22:31:28 +02:00
30a283c1b3 asset compression 2026-05-11 18:37:30 +02:00
057e7b94d7 rewrite 2026-02-19 03:00:13 +01:00