docs/kitbash.md: freezing, what triggers a live collection Boolean, and what freeze buys on KESTREL (cut kit-freeze)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-02 20:48:35 +01:00
commit a69bb89374

View file

@ -1,7 +1,7 @@
# Kitbash parts: machinery from kits
`surfaces/blender/brokkr_kitbash` is a Blender add-on that places parametric machine parts from a **kit**, mates
them **socket** to socket, cuts them with booleans and bakes them, and makes the faceted armor **shell** they sit under. It is the machinery vocabulary of a ship's fixed chassis: the frame, tanks,
them **socket** to socket, cuts them with booleans and freezes them, and makes the faceted armor **shell** they sit under. It is the machinery vocabulary of a ship's fixed chassis: the frame, tanks,
actuators, housings and plumbing an agent assembles offline under a hand-fit armor cage, baked once. It is a host
add-on in Brokkr's sense (`install.md`, "Host add-on actions"), a sibling of `brokkr_mesh_polish` and `brokkr_rig`:
it imports the polish package's operator base, `Refused` and `mesh_object`, and nothing from `brokkr_bridge`.
@ -31,6 +31,8 @@ Who owns what:
and `kit_close_to_socket` properties. Only `close` writes them and only `detach` clears them. A closure places
nothing: whether it holds is derived at each report.
- A boolean belongs to its Boolean modifier on the part that is cut.
- Whether a cut object is live or frozen belongs to its `kit_frozen` property, which holds the live mesh while
the object carries its evaluated one. Only `freeze` sets it, and `thaw`, which deletes it, is its one undo.
## A part, end to end
@ -317,12 +319,56 @@ took 1.89 s through the collection modifier, 12.6 s with a Boolean modifier for
eight cutters joined into one mesh (medians of five interleaved evaluations, Blender 5.3 on Starfire; an earlier
probe with raw cutters read 2.04, 14.7 and 1.94 s). All three give the same faces and volume. The cost is the
target's, hardly the cutters': one cutter on that shell already costs 1.4 s. The target pays it each time it is
evaluated, and Blender evaluates it after every action that changes it or a cutter. `boolean`
evaluated, and Blender evaluates it after every action that changes it or a cutter, and after much that changes
neither ("Freezing", below): `freeze` an object when its cuts are settled. `boolean`
evaluates the target once and reports `evaluated: {faces, volume, nonManifoldEdges}`; `report` never evaluates a
modifier. The cutter is any other mesh object and is not changed: hide it with `setObjectVisibility`. A cutter
with no material leaves the target's material slots as they are; a cutter that has materials brings them, after
the target's own, on the faces it makes.
### Freezing
A live Boolean over a collection is paid for far more often than its target changes. In Blender 5.3 every such
Boolean in the scene is evaluated again, whatever it cuts, after any datablock is removed (an orphan mesh
included), after any object's `hide_viewport` changes, and after any evaluated mesh is copied out
(`new_from_object`). Adding objects, collections or modifiers does not do it. Nearly every action here does one of
the three (`cut_many` hides its target's Booleans to cast, `ribs` makes and removes working objects), so each
finished cut object is paid for again at each later action. Hiding the finished object does not help while its
cutters show, and the hide is itself one more trigger. On a replica of six cut plates (a subdivided, solidified
sphere under one Exact Boolean of four cutters each), each trigger on an unrelated datablock cost 19 to 23 s; with
the plates frozen, 0.004 to 0.014 s (three interleaved repetitions, Blender 5.3 on Starfire).
**`freeze`** takes any mesh object that has modifiers, a kit part, a shell or a plain mesh. Its mesh becomes its
evaluated mesh (named `<object> frozen`), its live mesh is held by an ID-pointer property, `kit_frozen`, so it
survives a purge of orphans, and every modifier stays in the stack with its collections, turned off in viewports
and renders. Nothing is removed: the cutter objects stay, a cutter placed by `cut` keeps its floor socket and what
is attached to it, and `booleans` still lists what cuts the object. The frozen mesh's material slots are the
object's own (an empty one it had included), followed by any a cutter brought; faces a cutter made from an empty
slot of its own take the first slot. A frozen kit part keeps `kit_kit`, `kit_part`, `kit_params` and its
connections: its sockets are still derived from the params, so `attach`, `detach`, `roll`, `aim`, `reach` and
`close` work on it and on what hangs from it. `freeze` reports the part (or `object`), `frozen`, `faces`,
`volume`, `nonManifoldEdges`, `modifiers` and `booleans`.
**`thaw`** puts the live mesh back, deletes `kit_frozen`, turns every modifier on and removes the frozen mesh. It
evaluates nothing itself; Blender evaluates the object once afterwards, and the thawed object evaluates to the
faces and volume it had.
A frozen object's mesh is not its design, so every action that would write its live mesh or its stack refuses it
with "thaw it first": `set_params`, `boolean`, `cut`, `cut_many`, `ribs` from it, a `shell` or `hose` rebuild of
it, and `freeze`. Derive ribs before freezing a cage. `freeze` also refuses an object with no modifiers, one with a
modifier already off in viewports or renders (it names them: `thaw` turns every modifier on, and would not give
that stack back), and one Blender does not evaluate. `thaw` refuses an object that is not frozen, and one whose
held mesh was removed. What nothing detects: a modifier of a frozen object turned on by hand, and a material
assigned to a frozen object, which lands on the frozen mesh and goes at `thaw`. `exportGltf` with `applyModifiers`
exports a frozen object's frozen mesh, since its modifiers are off.
What it buys on an assembly: KESTREL, an experiment mech of 22 cut shells and blocks, evaluated 1035 Booleans
where its cuts need 139 when each finished component was only hidden, and 139 when each was frozen as it was
finished; the whole build took 4.5 times as long hidden as frozen (medians of three interleaved pairs, 3.4 to 5.7
within a pair, Blender 5.3 on Starfire under other load; an earlier series on a quieter machine read 251.7 s
against 51.2 s). In `tests/live/kitbash_assembly.py`, removing an orphan mesh beside three cut tanks costs 1.05 s
with them live and 0.0023 s with them frozen.
## Making a shell
`shell` makes an armor plate the way one is modelled by hand: fit a sparse subdivision cage, crease the edges that
@ -419,7 +465,7 @@ medians of three interleaved calls in the live suite (Blender 5.3 on Starfire).
are twisted, and the Boolean, which cuts quads into triangles, can read the wall as passing through itself and
leave edges with four faces. On the Seraph's cap that began at 0.91 of the thickness at which the first face
folds (0.0301 against 0.033), on the left cap and not on its mirror, the right; on its breast plate at 0.91 as
well (0.032 against 0.035). Read `nonManifoldEdges` after cutting (`boolean`, or a count on the evaluated
well (0.032 against 0.035). Read `nonManifoldEdges` after cutting (`boolean`, `freeze`, or a count on the evaluated
mesh), and keep `thickness` clear of the first folding one with a thinner wall, fewer `levels` or wider facets at
the corner.
@ -493,7 +539,7 @@ attaching a part to a floor) costs an evaluation again while the target is visib
more cutters than fit (about 150 of long names), the rows left off the end are counted in `booleansOmitted`. The
scene keeps every cutter; the target's `Kit` modifier collections list them.
`cut`, `cut_many` and `boolean` evaluate their object, and refuse one Blender does not evaluate in the
`cut`, `cut_many`, `boolean` and `freeze` evaluate their object, and refuse one Blender does not evaluate in the
view layer: an object disabled in viewports that nothing evaluated depends on, or one whose collections no view
layer shows. A disabled object that an evaluated object needs (a parent of one, a cutter of one) is evaluated
all the same, and is cut.
@ -920,8 +966,8 @@ Python loop of BVH queries with three rays a sample, and the 13,824-candidate se
| --- | --- | --- |
| `brokkr_kitbash.describe` | `kit` (default `mechanical`), `part` (default: all) | Parts with their params (type, min, max, default, doc) and sockets in the part frame at default params. Changes nothing. |
| `brokkr_kitbash.place_part` | `kit`, `part`, `object_name`, `params` | A new mesh object at the origin: the part's mesh, a `Kit Bevel` modifier when the part has a bevel, and the three ID properties. Refuses a name an object already has. |
| `brokkr_kitbash.set_params` | `object_name`, `params` | Overlays `params` on the stored ones and rebuilds the mesh in the same datablock: modifiers and material slots stay, and the Bevel width follows. Per-face materials are carried by shape: each shape of the part keeps the material most of its faces had, whatever the new face count. Seats the part and the parts attached to it again; refuses a change that breaks a connection or a closure's mate. Reports the part and `closures`, every closure in the scene as `{part, to, holds}`: its own first, then the broken, then the rest; rows that would not fit a receipt are left off the end and counted in `closuresOmitted`. Each closure in the scene adds a few milliseconds (both its parts are built again to find their sockets). |
| `brokkr_kitbash.report` | `object_name` (default: every kit part) | Each part as the scene has it: kit, part, params, faces, shells, each socket's world frame, `connection` and `closure`. Changes nothing and evaluates no modifier. |
| `brokkr_kitbash.set_params` | `object_name`, `params` | Overlays `params` on the stored ones and rebuilds the mesh in the same datablock: modifiers and material slots stay, and the Bevel width follows. Per-face materials are carried by shape: each shape of the part keeps the material most of its faces had, whatever the new face count. Seats the part and the parts attached to it again; refuses a change that breaks a connection or a closure's mate, and a frozen part. Reports the part and `closures`, every closure in the scene as `{part, to, holds}`: its own first, then the broken, then the rest; rows that would not fit a receipt are left off the end and counted in `closuresOmitted`. Each closure in the scene adds a few milliseconds (both its parts are built again to find their sockets). |
| `brokkr_kitbash.report` | `object_name` (default: every kit part) | Each part as the scene has it: kit, part, params, faces, shells, each socket's world frame, `connection`, `closure` and `frozen`. Changes nothing and evaluates no modifier. |
| `brokkr_kitbash.attach` | `object_name` (the child), `socket`, `parent_name`, `parent_socket`, `roll` (degrees, -360 to 360, default 0) | Seats the child's socket on the parent's and parents it there; the two parts are of one kit or of two whose socket types agree. Reports the child. |
| `brokkr_kitbash.detach` | `object_name` | Clears the part's connection and the closure it states; it stays where it stands. Refuses a part that has neither. |
| `brokkr_kitbash.roll` | `object_name`, `roll` (degrees, -360 to 360) | Turns an attached part to that roll where it hangs. Refuses a part that is not attached. Reports the part and `closures` as `set_params` does. |
@ -931,6 +977,8 @@ Python loop of BVH queries with three rays a sample, and the 13,824-candidate se
| `brokkr_kitbash.boolean` | `object_name` (any mesh), `cutter`, `operation` (`DIFFERENCE`, `UNION` or `INTERSECT`; default `DIFFERENCE`) | Adds the cutter to the collection of the target's one live Exact Boolean for the operation, above the Bevel. Refuses a cutter that is the target, is not a mesh, or already cuts it, and a scaled target. Reports the part (or `object` for a mesh that is not one), `booleans: [{cutter, operation}]` (difference, union, intersect; each in the order added; `booleansOmitted` counts rows a receipt had no room for) and `evaluated`. |
| `brokkr_kitbash.cut` | `object_name` (any mesh), `cutter_name`, `part` (`box`, `cyl`, `slot`, `slab`), `params`, `origin_x/y/z`, `direction_x/y/z`, `up_x/y/z` (default 0, 0, 1), `roll` (degrees, default 0), `axis_x/y/z` (default 0, 0, 0: the surface normal) | Places a `cutters` part where the ray meets the target, parented to it, and adds it to the target's difference Boolean. Refuses a ray that misses or has no direction, a name an object has, an `up` along the cutter's axis, an `axis` into the surface and a scaled target. Reports `object`, the `cutter` with its floor sockets, and `booleans` (with `booleansOmitted`, as `boolean`). |
| `brokkr_kitbash.cut_many` | `object_name` (any mesh), `cuts` (a JSON array of 1 to 64 cutters) | `cut` for several cutters in one action: all placed or none, one evaluation of the target afterwards. Reports `object`, `cutters` (names) and `booleans` (with `booleansOmitted`, as `boolean`). |
| `brokkr_kitbash.freeze` | `object_name` (any mesh with modifiers) | Makes the evaluated mesh the object's mesh, holds the live mesh in `kit_frozen` and turns every modifier off, keeping the stack, its collections and the cutters. Refuses a frozen object, one with no modifiers, one with a modifier already off and one Blender does not evaluate. Reports the part (or `object`), `frozen`, `faces`, `volume`, `nonManifoldEdges`, `modifiers` and `booleans`. |
| `brokkr_kitbash.thaw` | `object_name` | Puts the live mesh back, turns every modifier on and removes the frozen mesh; evaluates nothing. Refuses an object that is not frozen or whose held mesh is gone. Reports `object`, `frozen`, `modifiers` and the live mesh's `faces`. |
| `brokkr_kitbash.ribs` | `object_name` (the cage), `ribs_name`, `planes` (a JSON array of 1 to 64 `{origin, normal}`, up to 16000 characters), `standoff`, `depth`, `thickness`, `step`, `holes`, `posts`, `post_r`, `bridge`, `clearance`, `longerons` (a JSON array of 0 to 16 `{origin, axis, toward}`, up to 8000 characters), `longeron`, `longeron_w`, `longeron_h`, `longeron_t` | Derives ribs, lightening holes, posts and longerons from the cage as it is cut, as one mesh object under it. Refuses before it writes anything, naming the plane or longeron. Reports `object`, `ribs`, `thickness`, `sections: [{plane, chains, pieces, length, open}]`, `posts`, `holes`, `longerons: [{index, stations}]` (trimmed to a receipt, with `longeronsOmitted`), `faces`, `volume` and `nonManifoldEdges`. |
| `brokkr_kitbash.shell` | `object_name`, `sheet` (a JSON object `{rings, closed, mirror, creases, rim, flip}`, up to 32000 characters), `thickness`, `offset`, `levels`, `bevel`, `count_folds` | Makes a faceted, hollow armor shell from a loft of rings with crease runs, or rebuilds a shell's cage in place under its cutters and ribs. Refuses before it writes anything, naming the field and index. Reports `object`, `rebuilt`, `rings`, `points`, `cageFaces`, `creases`, `folded` (with `count_folds`, the number of the evaluated wall's inner faces that fold; else null), `corners`, `subdividedFaces`, `facing`, `thickness`, `offset`, `levels` and `children`. |
| `brokkr_kitbash.hose` | `object_name`, `start`, `end`, `count`, `radius`, `spread`, `clearance`, `bend`, `step`, `sag`, `clamps` (a JSON array of up to 8 `{socket}`), `joint` (empty, or a JSON object `{socket, standoff, range}`) | Routes a bundle of hoses between two sockets around every other mesh, over clamps and through a pin's axis across its roll range; on a hose's name, rebuilds it in place. Reports `length`, `lengthChange`, `clearance`, `radii`, `sag`, `voxels`, `seed`, `rolls`, `worstRoll`, `faces`, `nonManifoldEdges`. |
@ -967,6 +1015,7 @@ assembly by its root: an attached part is placed by its connection.
{"action": "createObject", "objectType": "MESH", "name": "Cutter", "location": [0.3, 0.6, 0], "size": 0.2},
{"action": "brokkr_kitbash.boolean", "object_name": "Tank", "cutter": "Cutter"},
{"action": "setObjectVisibility", "targetObjectName": "Cutter", "visible": false},
{"action": "brokkr_kitbash.freeze", "object_name": "Tank"},
{"action": "brokkr_kitbash.report", "object_name": "Nozzle"},
{"action": "exportGltf", "filepath": "engine.glb", "selection": ["Tank", "Tee", "Nozzle"]}
]}
@ -1057,6 +1106,6 @@ frame `cut` gives a cutter. `MateTests` covers the mate arithmetic and what may
`PoseTests` the closed-form rolls. The operators are exercised in a real Blender by
`tests/live/kitbash.py` (placing and re-parameterising, and the frame kit: its nine parts placed, the truss
re-parameterised, a beam seated on a bracket), `tests/live/kitbash_assembly.py` (attach, detach,
`set_params` on assemblies, a braced leg closed by `close` and boolean), `tests/live/kitbash_shell.py`
`set_params` on assemblies, a braced leg closed by `close`, boolean, and freeze and thaw with what a frozen part costs), `tests/live/kitbash_shell.py`
(`cut` and `cut_many` on a cage that is not a kit part, a part on a cutter's floor, the three Boolean modifiers, an object in no
collection) and `tests/live/kitbash_pose.py` (roll, aim and reach).