Skip to content

armgit / forma

Public Imported from GitHub
0

A 1.2 MB pure-Rust rewrite of headless Blender built for AI agents — 3D B-rep modeling engine, CLI, and MCP server

6.1 KB
Raw Blame

[!NOTE] Archived engineering snapshot (initial v0.1 architecture study). Binary sizes, memory figures, and architecture details reflect the initial pre-build Blender audit. For current v0.4.5 architecture and specs, see docs/explanation/architecture.md and README.md.

Phase 1.1 — Blender 5.3.0 Architecture Audit & Build-vs-Slice Decision Record

1. Raw Measurements on Installed Blender 5.3.0 (macOS arm64)

Target inspected: /Applications/Blender.app/Contents/MacOS/Blender (Blender 5.3.0, release hash 02f0899d78e3, CMake Release build).

1.1 Binary & Dependency Footprint

Artifact Measured Size Notes
/Applications/Blender.app 953 MB Full bundle
Contents/MacOS/Blender 200 MB Monolithic executable linking 48+ frameworks/dylibs
Contents/Resources/5.3 388 MB Scripts, bundled Python, datafiles, add-ons
Contents/Resources/lib 359 MB Shared libraries

Non-modeling libraries dynamically linked into Blender even under --background --factory-startup (verified via otool -L):

  • Rendering / Shading / Denoising / USD: libopenvdb.dylib (63 MB), libOpenImageDenoise_core.dylib (45 MB), libOpenImageIO.dylib (16 MB), libembree4.dylib (14 MB), libusd_ms.dylib, libOpenColorIO.dylib (6.6 MB), libMaterialX*.dylib (~6 MB), liboslexec/liboslcomp
  • GUI / Audio / Video / XR / Tracking: AppKit, Cocoa, Carbon, Metal, OpenGL, AudioUnit, CoreAudio, OpenAL, VideoToolbox, libSDL3.dylib (2.6 MB), libopenxr_loader.dylib, libceres.dylib (8.3 MB), libopentimelineio.dylib, libJolt.dylib (2.6 MB)

1.2 Latency & Memory Benchmarks (5 runs, --background --factory-startup)

Workload Median Wall Time Min / Max Peak RSS
Cold start (pass) 672.6 ms 664.0 / 1522.3 ms 223 MB
5× bpy.ops boolean + bevel + .glb export 947.5 ms 891.0 / 987.9 ms —
Pure in-process bmesh (3× subdivide + bevel → 3,434 V / 3,432 F) 4.14 ms (inner) 692.5 ms total —

Inner breakdown of the 5× bpy.ops boolean + bevel + .glb pipeline:

  • OPS_BOOL_MS: 167.92 ms (context switching, modifier stack, depsgraph flushes, object unlinking)
  • BEVEL_MS: 5.14 ms
  • GLB_MS: 66.66 ms (Python glTF exporter serialization)
  • Total inner time: 239.71 ms vs. 672.6 ms cold startup overhead.

1.3 Boolean Solver Robustness & Speed Benchmark (Blender 5.3.0)

Workload A: 5× cylindrical difference holes through a 2×2×2 cube. Workload B: Coplanar union of two 2×2×2 cubes offset by x = 1.0 (exact expected volume = 12.0).

Solver 5× Diff Time Result Topology Coplanar Union Vol (exp. 12.0) Coplanar Non-Manifold Edges
FLOAT 14.46 ms 186 V / 96 F 8.0000 (BROKEN) 22 (CORRUPT)
EXACT 141.35 ms 186 V / 96 F 12.0000 0
MANIFOLD 16.82 ms 186 V / 96 F 12.0000 0

Key finding: Standard floating-point booleans silently corrupt coplanar geometry (22 non-manifold edges, 33% volume error) without raising an exception—a lethal silent failure mode for autonomous LLM agents. Manifold-guaranteed booleans run 8.4× faster than exact arithmetic while preserving 100% manifoldness and exact volume.


2. Source Dependency Boundary Audit (bmesh, geometry, modifiers)

In Blender's source tree:

  • source/blender/bmesh/ (bf_bmesh) depends directly on bf_blenlib (BLI_mempool, math, containers) and bf_dna (makesdna structs for Mesh, CustomData).
  • source/blender/geometry/ and source/blender/modifiers/ sit above bf_bmesh and bf_blenkernel (BKE), pulling in depsgraph, makesrna, ID datablocks, Main scene databases, and scene/object context evaluation.
  • Even compiling Blender with WITH_HEADLESS=ON and WITH_PYTHON_MODULE=ON:
    1. Still embeds blenkernel, depsgraph, makesdna/makesrna, and the CPython runtime (>150 MB artifact, hundreds of ms startup).
    2. Preserves Blender's mouse-and-viewport mental model: modal OBJECT/EDIT state, implicit active object/selection, ephemeral integer element indices (face[42] invalidates on topology change), no persistent topological naming/lineage, no O(1) copy-on-write transactional branching, and no compact LLM-oriented spatial/topological feedback channel.

3. Architecture Decision: Clean-Room Rust Modeling Kernel (forma)

Decision: Build a clean-room, zero-GUI Rust modeling kernel (forma) rather than slicing Blender's CMake tree, while keeping stock Blender 5.3.0 as our external baseline and downstream round-trip verification oracle.

Quantitative rationale:

  1. Footprint & latency: Single native binary (~3–5 MB vs. 953 MB), <5 ms cold start (vs. 673 ms), <15 MB RSS (vs. 223 MB), native binary .glb/.obj/.stl writer in <1 ms (vs. 67 ms Python glTF export).
  2. Agent-native data model from day 1:
    • Explicit Half-Edge / Polyhedral B-Rep with persistent topological lineage & semantic tags (solving the Topological Naming Problem for LLM edits).
    • Predicate/semantic selectors (top, bottom, normal(+z), dihedral > 45, created_by(op), tag(...)) — zero reliance on brittle integer indices.
    • Guaranteed-manifold CSG/boolean engine (BSP/exact-plane/manifold-preserving solid booleans + watertight verification) + Catmull-Clark subdivision + bevel / inset / extrude / loop-cut / revolve / loft / sweep / mirror / array / shell / offset.
    • Immutable / Copy-on-Write transactional snapshots & rollback (checkpoint, rollback, branch) with automatic post-op topological invariant checks (2-manifoldness, Euler-Poincaré formula, outward winding, zero degenerate/NaN faces, volume, bounding box).
    • Bidirectional compact observation channel (~100–200 tokens): Every op returns structured geometric/topological deltas, named part bounds, and invariant alerts.
  3. Zero lock-in & Blender interoperability: Exports spec-compliant .glb, .obj, .stl, and a .blend converter script verified warning-free against /Applications/Blender.app/Contents/MacOS/Blender --background.