diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index f82d7c3..b507720 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -450,8 +450,10 @@ and about 0.002 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 -are facets' borders, give it a wall, then cut into it. The cage is a **loft**: rings of points with equal counts, -quads between neighbouring rings. The description is a JSON object, `sheet`: +are facets' borders, give it a wall, then cut into it. The description is a JSON object, `sheet`, in one of two +forms, both compiled by `core.sheet` into the same cage: a **loft** (`rings`), below, or a **free cage** (`verts` +and `faces`, [A free cage](#a-free-cage)). A sheet states exactly one of `rings` and `verts`. The loft is rings of +points with equal counts, quads between neighbouring rings: | key | default | what it says | | --- | --- | --- | @@ -550,14 +552,85 @@ the corner. Refused, each before anything is written and naming the field and index: a missing or unknown key; a non-finite number; fewer than 2 or more than 64 rings or points; rings of unequal counts; a quad under 1e-8 m2 (a collapsed corner); a mirrored ring that does not start on x = 0 or has a point behind it; `mirror` with `closed`; a run out -of range or with `from` not under `to`; a weight outside 0 to 1; more than 262144 subdivided faces (cage quads -times 4 to the `levels`). +of range or with `from` not under `to`; a weight outside 0 to 1; more than 262144 subdivided faces (a quad gives +4 to the `levels`, a triangle three quarters of that). On the pauldron (25 cage quads, 1600 subdivided faces, 3360 with the wall), `shell` took 3.5 ms a call with Blender's own update after it, and one whole evaluation of the Subdivision and Solidify 1.7 ms. With six cutters (four panel lines, two insets) and ribs under it, a rebuild took 0.92 s, which is its one Boolean evaluation. Medians of 3, interleaved, Blender 5.3 on Starfire (`tests/live/kitbash_faceted.py`, `costs`). +### A free cage + +A loft is a grid: every vertex off its boundary has four edges, so it cannot state a triangle, a pole, or a crease +that ends inside the surface. A hull modelled by hand uses all three. The bar is the fewest cage vertices that +hold the form, with creases doing the work: a dense cage that only looks smooth after subdivision is the failure. +The free form states the cage directly: + +| key | default | what it says | +| --- | --- | --- | +| `verts` | required | 4 to 256 `[x, y, z]` in the shell's own frame | +| `faces` | required | each 3 or 4 vertex indices, counter-clockwise seen from outside | +| `creases` | `[]` | `[a, b, w]`: the edge between vertices a and b, weight 0 to 1 | +| `corners` | `[]` | `[vertex, w]`: a vertex held as a corner | +| `poles` | `[]` | the vertices of irregular valence, by index: a gate, below | +| `mirror` | `false` | the cage is authored on one side of x = 0 and reflected | +| `rim` | `1` | the weight of every boundary edge no crease names | +| `flip` | `false` | reverse every face | + +```json +{"verts": [[0, 0, 0.5], [1, 0, 0], [0, 1, 0], [-1, 0, 0], [0, -1, 0], [1, 0, -1], [0, 1, -1]], + "faces": [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1], [2, 1, 5, 6]], + "creases": [[0, 1, 1.0], [0, 3, 1.0]], "poles": [1, 2], "rim": 0} +``` + +**Mirror.** Every vertex stands on one side of x = 0 (either side, all the same). One within 0.005 m of the +plane is on the seam: it is snapped to x = 0 and shared by both halves. The others are reflected (the k-th of +them is vertex `len(verts) + k`), each face gets a reversed twin, and creases, corners and poles land on both +halves. A vertex 0.006 m off the plane is not on the seam: the cage is open there. A face lying on the plane, +and an edge on the plane that two authored faces share (a fin), are refused. + +**The pole gate.** A vertex's valence is the number of cage edges at it, on the cage as built (after the +mirror). A pole is a vertex whose valence is not 4 off the boundary, or not 2 or 3 on it. `poles` must list +exactly the poles the faces make. An undeclared pole and a declared vertex that is none are both refused, naming +the vertex and its valence. The list changes nothing in the mesh: it is there so that no pole is an accident, +since a pole is where a subdivision surface pinches or flattens. Put one where a crease runs through it or a +triangle stands beside it, and where the form turns anyway. + +**Triangles.** A triangle subdivides to three quads, so after one level the surface is all quads, and the wall, +`cut`, `ribs` and `count_folds` take it as any shell. Use one where a crease run ends: the two cage edges +either side of the crease close onto a point instead of carrying a loop across the rest of the form. Faces of +five or more sides are refused. + +**Budget.** Two cages modelled by hand are the measure. A whole ship hull, 1 m long: 46 control vertices (29 +authored under a mirror), 25 faces a side of which 6 are triangles, 9 creased edges a side, every one at weight +1, six poles, each on a crease or beside a triangle. A petal: 10 vertices, 4 quads and 6 triangles, 5 creased +ridges at weight 1, an uncreased outline. In both the creases are full weight and stand only where the form +truly breaks (turns of 40 to 170 degrees); the longest straight silhouette edges are single cage edges; the cage's +vertices stand outside the form, as subdivision shrinks toward the inside. An armour plate should cost about what +the petal does. Add a vertex only where the limit surface cannot otherwise reach the form, and say why. + +**Refused**, before anything is written and naming the field and index: fewer than 4 or more than 256 vertices; +a vertex in no face; a face of other than 3 or 4 indices, with a repeated or out-of-range index, with another +face's vertices, or under 1e-8 m2; an edge in three faces; two faces crossing an edge the same way (wound +against each other); a crease on no cage edge; two weights for one edge or point; a mirrored cage with vertices +on both sides; the pole gate. `closed` and the loft's crease runs belong to the loft and are refused here, as +`poles`, `corners` and `verts` are on a loft. + +**The report** carries, for both forms, `cageVerts`, `cageFaces`, `triangles`, `creases`, `corners`, `poles` +(`{"3": 2, "5": 1}`: valence to how many vertices, on the cage as built) and `closed` (no boundary edge); +`rings` and `points` are null on a free cage. + +**What it gives up.** A free cage is authored by index, by hand or by an agent: nothing derives it from a +silhouette, and a wrong index is caught only where it breaks a rule above, not where it merely makes a worse form. +There are no pentagons. A loft remains the shorter description of anything that is a grid. + +**Reading and scoring a cage.** `tools/cage_export.py` writes an object of a `.blend` copy as a free cage document +(seam snapped, creases from `crease_edge`, poles computed); it writes only that document and never saves the +`.blend`. `tools/cage_score.py` builds two documents through `shell` and reports, raw and with no pass bar, each +one's counts, the distance between their level-3 limit surfaces (median, 95th centile and worst, as a share of +the reference's largest extent), silhouette overlap from +x, +y and +z, and how far apart their creased curves run. + ## Cutting a shell An armor plate is not a kit part: it is any mesh, usually one made by `shell`. `cut` cuts it, or a