luft/luft.lisp
Domains and sites.
Chunks.
Boundary conditions.
Chains.
Stars.
Face topology.
Manifold-sheet mesh.
Tests.
--------------------------------------------------------------------------- Packed sites and domains
A site packs, from the least significant bit up: the extent mask (3), the polarity sign (1), Z (8), the within-chunk X and Y (6 each), and the Morton-interleaved chunk coordinates (12+12). Numeric order is therefore chunk-major with hierarchical (Morton) chunk locality, then column-major within a chunk: every (x, y) column's Z run is contiguous, and every power-of-two block of chunks is a contiguous range of any sorted vector.
Coordinates do not wrap. A domain is a box; probing beyond it is an
explicit outside-domain condition with boundary restarts, so the policy
for what lies past an edge belongs to the caller (a chunk store, a whole
world, a test harness), never to the coordinate arithmetic.
Spread a 12-bit chunk coordinate onto the even bit positions.
Compact the even bit positions back into a 12-bit chunk coordinate.
Make a boxed domain with power-of-two X and Y cell extents.
The domain's cell count along X; anchors range over [0, limit].
The Morton-interleaved chunk coordinates of site.
site with its chunk bits cleared: a valid site of the chunk-local box.
Pack a canonical site inside domain's box. No coordinate wraps: anchors
range over [0, limit] per horizontal axis, and a site extending along an
axis cannot begin on that axis's far boundary.
Site anchor (~D ~D ~D) with extent ~3,'0B lies outside the ~ ~Dx~D-cell domain.
Return the coface whose signed low boundary is site, or NIL at the box.
Return the coface whose signed high boundary is site, or NIL below Z.
--------------------------------------------------------------------------- Normalized immutable chains
UB60 site values live in an unboxed UB64 machine-word array on SBCL.
Return a fresh copy; the chain's stored normalized vector stays immutable.
Linear merge of two normalized chains, including run cancellation.
Return the normalized boundary of an ordinary solid three-chain.
A cell probe left its box. The signaling probe offers the boundary restarts TREAT-AS-AIR, TREAT-AS-SOLID, and USE-VALUE, so the caller's handler decides what lies past the edge: a world treats it as air, a chunk store answers from the neighboring chunk or defers, a test refuses.
Signal outside-domain for one probe, offering the boundary restarts.
A probe crossed into a chunk that is not resident in the probing field. The signaling probe offers USE-CHUNK (supply the chunk's chain), plus the TREAT-AS-AIR and TREAT-AS-SOLID boundary restarts for the whole chunk, so a streaming store answers with data, defers, or fills with a constant.
Treat positive cubic-site occurrences in chain as Boolean occupancy.
Cells above and below the Z range are air; probes beyond the horizontal
box signal outside-domain with the boundary restarts.
--------------------------------------------------------------------------- Chunk vocabulary
A chunk is the aligned 64x64-cell full-height column block named by the Morton-interleaved chunk coordinates in a site's top bits. Because those bits are the most significant, a normalized chain is chunk-contiguous: each chunk, and each power-of-two block of chunks, is one contiguous run.
The chunk key of the cell column at world coordinates X, Y.
Call function with each (chunk-key chunk-chain) run of chain in order.
--------------------------------------------------------------------------- Occupancy stars and strict-minority moment classification
Central occupancy convention: cells outside Z=0..254 are air; probes
beyond the horizontal box signal outside-domain with boundary restarts.
occupancy must return a stable NIL, T, 0, or 1 for each in-domain cell.
Pack site's complete incident-cell star.
Absent axes are enumerated in X,Y,Z order. Zero means the cell one unit below the site on that axis (direction -1); one means the cell anchored at the site (direction +1).
--------------------------------------------------------------------------- Canonical face-local topology
Return the canonical positive edge geometry at face's local edge.
Return the canonical positive vertex at local corner (U word first).
direction is +/-1 relative to the oriented normal.
Orient a face from solid to air; return NIL when it is not exposed.
A cell probe left its box. The signaling probe offers the boundary restarts TREAT-AS-AIR, TREAT-AS-SOLID, and USE-VALUE, so the caller's handler decides what lies past the edge: a world treats it as air, a chunk store answers from the neighboring chunk or defers, a test refuses.
(&key (code t))(x y z)Addition over compatible quantities.
(value)(value)(chunk-x chunk-y)(&key (horizontal-bits 6)
(x-bits horizontal-bits)
(y-bits horizontal-bits))(a b)Logical conjunction of tests and raw truth values.
Test whether two compatible scalars are equal.
(domain)(domain)(axis)(index)(axis)(&rest axes)(site)(site)(site)(site)(site)(site)(site)(site)(site)(site)(site)Extract the unsigned bit field (BYTE SIZE POSITION) of one unsigned scalar.
Multiplication and scalar scaling.
(site)Logical negation of one test or raw truth value.
(site polarity)(domain thing)Test whether one compatible scalar is at most another.
Subtraction or unary negation.
(domain x y z &optional (extent +vertex-extent+) (polarity 1))Pack a canonical site inside DOMAIN's box. No coordinate wraps: anchors range over [0, limit] per horizontal axis, and a site extending along an axis cannot begin on that axis's far boundary.
(domain site)(site axis)(site)(domain site extent)(domain site axis delta)Logical disjunction of tests and raw truth values.
Test whether one compatible scalar is greater than another.
(domain site axis)(domain site axis)(site axis present-p)(extent axis side)(site axis side)(domain site axis)(domain site axis)(function domain site)(domain site axis)(domain site axis)(chain)(domain)(chain)(chain)(chain)(a b)Test whether one compatible scalar is less than another.
(domain &key (initial-capacity 0))(builder site)(builder chain)(domain sites)The componentwise absolute value of a raw value.
(builder)(sites start)(source start end destination write)(a b)(sites geometry)(chain site)(chain site)(function chain)(a b)(chain)(solid-chain)(domain x y z)A probe crossed into a chunk that is not resident in the probing field. The signaling probe offers USE-CHUNK (supply the chunk's chain), plus the TREAT-AS-AIR and TREAT-AS-SOLID boundary restarts for the whole chunk, so a streaming store answers with data, defers, or fills with a constant.
(key)(key)(chain x y z)Treat positive cubic-site occurrences in CHAIN as Boolean occupancy. Cells above and below the Z range are air; probes beyond the horizontal box signal OUTSIDE-DOMAIN with the boundary restarts.
Test whether one compatible scalar is at least another.
(x y)(key)(key)(function chain)(arguments)(value)(domain occupancy x y z)Central occupancy convention: cells outside Z=0..254 are air; probes beyond the horizontal box signal OUTSIDE-DOMAIN with boundary restarts. OCCUPANCY must return a stable NIL, T, 0, or 1 for each in-domain cell.
(domain site occupancy)Pack SITE's complete incident-cell star. Absent axes are enumerated in X,Y,Z order. Zero means the cell one unit below the site on that axis (direction -1); one means the cell anchored at the site (direction +1).
Sample a two-dimensional texture through a sampler at a UV coordinate.
(domain face)(face)(axis-number amount)(domain source dx dy dz extent)(domain face edge)(domain face corner)(domain face occupancy direction)(domain geometric-face occupancy)
luft-- canonical cubical topologyPacked sites own topology and normalized vectors own chains. Surface realization lives in MESH.LISP; mutable occupancy and renderer backends remain outside this package.