luvcraft/light-tests.lisp
A world whose absent +Y boundary is open sky, with all-air chunks.
Lateral terrain is generatable but not resident, so the result is honest but provisional.
Stone roof cells admit no sky; the open shaft carries a full beam to the floor, and lateral spread attenuates one level per step.
Sixteen Manhattan steps out, the level is exhausted.
Between the two emitters each cell keeps the brighter contribution.
Emission does not perturb the sky field.
A full stone shell one step out along +X.
Roof the upper chunk's top layer, world y = 31, with one shaft.
The beam crosses the seam at world y = 15/16 undiminished.
Lateral falloff below the seam still measures from the shaft.
Roof the +X chunk completely; its light must arrive sideways from the open chunk across the seam.
Light publication does not impersonate an authored edit.
A second solve over unchanged content publishes nothing.
A content edit then changes the field and only the light revision and changed light boundaries advance.
The incremental relighter is judged against the reference solver: after its queues settle, every resident cell must be bit-identical to a from-scratch solve of the same world.
Give the comparison vertical and lateral crossings, occlusion, two competing emitters, and a direct sky shaft in one small world.
Three chunks with vertical and lateral seams, occlusion, a shaft, emitters.
The program states its law; the realization retains the checked expressions, the emitted forms, and the compiled functions.
The transfer law is checked in the bound field's own quantity: sky
light stays sky light, and attenuation steps enter through an explicit
as-field-quantity boundary rather than by coincidence of encoding.
The emitted scalar loop contains no arithmetic dispatch: the law was inlined as ordinary CL operators over declared lanes.
Open sky is a virtual source at full brightness related inward through the program's own transfer law: straight down pays only opacity, a lateral boundary pays one step more, and a fully opaque cell admits nothing. The realization exposes this as its RELATE entry.
A second, dimmer relation into the same site is not an improvement.
A warmed drain over pre-grown frontier storage allocates only at chunk crossings, where the window resolves a coordinate key (#L84JCX), never per site or per relation. The proof world exposes about 68,000 relations and 4,000 crossings; one cons per relation would exceed a megabyte.
Warm CLOS accessor caches outside the measured extent.
The former dynamic TYPEP specifier allocated three conses per push.
Arrival through the hook lights the fresh chunk incrementally.
Roofing one cell darkens its column; removing it restores the beam.
An emitter appears and disappears.
A settled state publishes nothing further.
The request owns its dense input. A later edit invalidates publication without changing what the producer is currently solving.
Initial residency is a global concern. Settle it before modeling the ordinary player edit path in an already visible world.
Random terrain, then interleaved edit bursts and reconciles.
A departure relights the retained neighbors; a re-arrival with fresh edits converges again.
The compiled removal and addition programs must reproduce the reference field across the same edit bursts, departure, and re-arrival. #K3WRD3
Roofing a lit column: the sky removal clears exactly the beam beneath the roof (its dependents), hands the beam's lit lateral neighbours to the addition frontier as survivors, and the addition program relights the column from them to the reference field.
The edited cell plus the fifteen cells of beam beneath it.
Streaming can replace a chunk at the same key before the next lighting reconcile. The departure still has to run, or retained neighbors keep light propagated from the old incarnation.
A solid floor with a glowing block resting on it, under open sky.
Floor tops under open sky read full skylight; the glow block's own faces carry its surface emission, and its blocklight reaches the floor around it.
Five exposed faces of the resting glow block, six vertices each.
The immutable snapshot meshes bit-identically to the owner side.
A world with no source keeps every boundary :UNKNOWN, so nothing is lit and the result says so instead of inventing daylight.
(window x y z)Resolve world site X,Y,Z through WINDOW. Return (VALUES MATERIALIZATION OFFSET AVAILABILITY). AVAILABILITY is :AVAILABLE or :UNAVAILABLE; field and subsystem policy must interpret that fact rather than making the spatial protocol call absence air, solid, zero, or open sky. Implementations keep their existing…
(&rest chunk-keys)(&key (id (gensym "BLOCK-WORLD-"))
(chunk-width 16)
(chunk-height 16)
(chunk-depth 16)
(cell-extent 1d0)
source)Logical disjunction of tests and raw truth values.
(world x y z)(world x y z)(world x y z)(world x y z)(world)Solve and publish voxel light from scratch for WORLD's resident chunks. Returns the chunks whose published light changed. The selected production solver must have an explicit SOLVE-LIGHT-REGION-USING method.
Test whether two compatible scalars are equal.
Logical conjunction of tests and raw truth values.
(world x y z)Return one site as BLOCK and :RESIDENT, or NIL and :ABSENT. This sparse world-coordinate accessor constructs coordinate descriptors and a chunk lookup key. It is appropriate for inspectors, ray hits, collision probes, and sparse interaction. Algorithms over many cells should select a chunk/domain once and use…
Addition over compatible quantities.
(world x y z)(field direction)(region &key (scheduling :level))(world &key immutable-p)Capture every resident chunk of WORLD for a from-scratch relight. With IMMUTABLE-P, copy content indices and capture absent-boundary semantics; the returned region may then be solved without reading the live world.
(world)(entry)One top-level defining form of a source file.
(name)Return the live frontier program definition named by NAME.
One live semantic account of frontier-shaped materialization work. #X7Q90E The definition names the dynamic family, physical frontier layout, and neighborhood at an aggregate boundary, and states its local law: field roles, realization constants, relation predicates, and the arithmetic TRANSFER, ADMISSION, and…
(world &key (candidate :compiled))Compare the test-only legacy oracle with production CANDIDATE over WORLD. Equivalent captures are solved without publication. The result reports exact per-chunk array equality, work and runtime observations, and the candidate's retained frontier executions. Unsupported candidate names signal through the production…
Test whether one compatible scalar is at least another.
Multiplication and scalar scaling.
(field-name)(realization)Assert that a raw or foreign value is measured in a program field's quantity.
Logical negation of one test or raw truth value.
(&rest operands)(&rest operands)(realization &key (initial-capacity 256))(realization input frontier)(x y z)(realization window frontier execution materialization offset direction
&rest arguments)Expose one relation into MATERIALIZATION/OFFSET from a virtual source. ARGUMENTS supply the program's constants and, keyed by role name, the source field values the transfer reads; DIRECTION is the relation's direction as seen from that source. The target is tested, committed, and admitted by the same law as an…
(domain x y z)(realization region frontier execution &key key entry)((observation) &body body)Measure time, allocation, GC time, and collections while executing BODY. OBSERVATION is reset in place and BODY's values are preserved. SBCL's byte and GC clocks are process-wide; in a multithreaded image this deliberately attributes concurrent runtime activity during the observed extent too.
(realization window frontier execution &rest arguments)Run the compiled program until FRONTIER is empty; return EXECUTION. ARGUMENTS are the program's constants as keywords. A program whose family hands sites to a companion frontier, such as invalidation's surviving sources, takes that frontier as the first argument before the keywords.
Test whether one compatible scalar is greater than another.
Test whether one compatible scalar is less than another.
The voxel-light program selected for production solves. Only :COMPILED is implemented by the runtime. The legacy implementation is loaded explicitly by the LUVCRAFT/LIGHT-REFERENCE system as a differential test oracle; unsupported names signal through the closed EQL dispatch. #X7Q90E #PJY6E1 #K3WRD3
(world)Subscribe a fresh lighting state to WORLD's content and residency hooks. Chunks already resident at attachment are treated as arrivals, so the first reconcile lights a caller-built world without a separate protocol.
(world)(solver region &key &allow-other-keys)Solve captured REGION with the explicitly implemented voxel-light SOLVER. There is deliberately no default method: unsupported solver names signal instead of silently selecting another implementation.
(solver state region)Settle STATE's dirty cells, departures, and arrivals over candidate REGION with the explicitly implemented incremental relighter named by SOLVER. There is deliberately no default method: unsupported names signal rather than falling back to a different algorithm. #K3WRD3
(&key maximum-priority priority-meaning (initial-capacity 256))(frontier materialization offset priority)(frontier)(&key label)((trace) &body body)(trace)(state)Settle STATE's queues over a candidate and publish once. Returns the chunks whose published light changed. Work runs on the calling owner thread; the counters record its actual cost so any move to captured producer batches is justified by measurement rather than guesswork.
(request)Compute REQUEST on the production worker and return a transferable value.
(session request value)Validate and accept one worker product on the render/GPU owning thread. This is the owner-side mirror of PERFORM-PRODUCTION-REQUEST: each request class carries its own publication rule, so a new kind of asynchronous product plugs in with one method on each generic rather than an edit to the drain loop. A stale…
(state)Reconcile cell edits incrementally or schedule a residency-wide relight. Authored edits normally touch one settled cell and are much cheaper to reconcile against the published field than to solve every resident chunk from scratch. Chunk arrivals and departures still use a coalesced immutable worker request, keeping…
The non-negative remainder of integer division.
Raise a dimensionless value to a dimensionless power.
(chunk)(world x y z)(field-name)(state region)Settle STATE's dirty cells, departures, and arrivals over candidate REGION with the compiled removal and addition programs. Return the executions and the total visits. #K3WRD3
(region)(block world x y z)(mesher world chunk)The maximum of compatible quantities.
(world chunk dependency-stamp)Copy CHUNK and its one-cell halo into immutable worker-owned columns. Every resident chunk's indices are already offsets under WORLD's vocabulary, so the halo is gathered by plain slab copies from the up to 27 neighbours, with no per-cell decomposition, translation, or block object lookup. The vocabulary's members…
(world chunk)Describe exactly which resident data CHUNK's exposed mesh observes. Content and light are named as separate revision domains: relighting must invalidate a mesh without impersonating an authored edit, and the stamp preserves which domain made a product stale.
(mesher snapshot)(&key (chunk-radius 4)
(chunk-width 16)
(chunk-height 16)
(chunk-depth 16)
(seed 121))(x y z)(domain local)(&key (scheduling :lifo) field-definition)Make the reference solver's packed LIFO or level-scheduled worklist. This machinery belongs to the test-only voxel-light oracle. Both modes retain ENTRY plus dense OFFSET and LEVEL lanes, never a cons or coordinate object per item. #QS1ERH #LDP5UR
(worklist entry offset level)(region field-reader queue skylight-p)(domain)(domain old-levels new-levels direction)Intent: expose the shared aggregate operation already visible in the live world, resolved meshing neighborhood, immutable halo snapshot, and light-region atlas. Give those four concrete representations a small protocol for locating a world site or resolving a domain crossing, while keeping availability distinct from…
Intent: state removal and incremental reconsideration in the same compiled vocabulary after the monotone kernel establishes its source and lowering boundary. Evidence: #ZEENY3. voxel-light-removal is an :invalidation program whose compiled drain reads like unlight-light-region but is emitted from the family and the…
The reference relight is exercised on small hand-built worlds whose correct fields can be reasoned out cell by cell: open columns, roofs and shafts, emitters and their falloff, and both vertical and lateral chunk seams.