Skip to main content

Crate crcbl_core

Crate crcbl_core 

Source
Expand description

Core primitives shared by every Crucible crate.

Nothing here depends on a backend, a window, or a renderer — this is the vocabulary layer that the rest of the engine is written in:

  • handle — Handle, a typed generational id, and Pool, the slot arena that issues and invalidates them.
  • world — WorldPos, the sector-tiled absolute position that every simulated thing in the engine uses. Plain Vec3 is only ever camera-relative render space; see WorldPos::relative_to.
  • alloc — FrameArena, a fixed-capacity bump allocator for per-frame transient data.
  • time — FrameClock, the fixed-timestep server tick accumulator plus variable render delta, TickId, and EventTime, the stated-epoch timestamp every input event carries.
  • input — the names for keys, buttons and axes (KeyCode, Keysym, PointerButton, Modifiers). Vocabulary only: the event enum lives in crcbl-shell, which is the only crate that produces one.
  • log — stderr logging behind the log facade, filtered by CRCBL_LOG, with the console’s log ring in log::console and the log command that sets the filter while the engine runs.
  • player — PlayerId, who a player is across sessions: drawn once by a client, presented in every hello, and self-asserted — see the module docs for how little an open server can trust it.
  • rand — deterministic values from an index, for simulations that replay. Deliberately not a generator; see the module docs for why every sample independently arrived at the same shape.
  • schedule — FixedRateSchedule, per-agent sampling at a fixed rate and a staggered phase, reporting each sample at its exact time inside the tick. Sample times come from an integer index, never an accumulated sum; see the module docs.
  • srgb — the sRGB transfer function, decode to linear light and encode back, for colour authored in sRGB.
  • stats — percentile_of and MIN_PERCENTILE_SAMPLES, the nearest-rank arithmetic the debug panel’s budget row and crcbl bench both report through. No mean, on purpose; see the module docs.
  • trace — Span and counter, the CPU half of the profiler: scoped spans with static names, nesting freely and carrying the thread they ran on, plus named u64 counters. Compiled into every build and gated at runtime; see the module docs for what that costs.
  • trig — sin, cos, atan and atan2 in f64, built from operations IEEE-754 pins down so a simulation that calls them reaches the same bits on every target. No platform libm; see the module docs.
  • hash — FNV-1a (fnv1a_32, fnv1a_64 and the Fnv1a64 hasher), for ids and digests that must be the same on every target and run.
  • surface — SurfaceTarget, the native window handles the shell produces and a HAL backend consumes. It lives here, and not in either of those crates, because neither may depend on the other; see the module docs for the dependency argument.

Re-exports§

pub use alloc::FrameArena;
pub use handle::Handle;
pub use handle::Pool;
pub use input::KeyCode;
pub use player::PlayerId;
pub use surface::SurfaceTarget;
pub use time::EventTime;
pub use time::FrameClock;
pub use time::TickId;
pub use world::SECTOR_SIZE;
pub use world::WorldPos;

Modules§

alloc
Frame-scoped bump allocation.
bounds
Lane-wise min/max that a NaN cannot corrupt.
handle
Typed handles and the slot pool that issues them.
hash
FNV-1a: a hash whose output is the same on every target, toolchain and run.
input
Input vocabulary: the names every layer of the engine uses for keys, buttons, axes and the devices they came from.
log
The engine’s logging: five macros, a filter, and the sink they write to.
logarithm
ln(1 + x) in f64, computed without calling the platform’s logarithm.
player
PlayerId: who a player is, across sessions, on the servers they join.
rand
Deterministic values from an index, for simulations that have to replay.
schedule
Fixed-rate sampling at exact sub-tick times, staggered per agent.
srgb
The sRGB transfer function, in both directions, on one channel in 0..=1.
stats
Nearest-rank percentiles, and the sample count below which one is a lie.
surface
SurfaceTarget — the one sanctioned platform leak in the engine.
time
The frame clock: a fixed-timestep accumulator for the server tick plus the variable render delta.
trace
CPU spans and counters: where a frame’s time went, and on which thread.
trig
Sine, cosine and the arc tangent in f64, computed without calling the platform’s.
world
Sector-tiled world positions.

Macros§

debug
Logs at Level::Debug: detail for someone reading this subsystem.
error
Logs at Level::Error: something the run could not do.
info
Logs at Level::Info: what the run is doing, at the default level.
log_at
Logs at an explicit Level, taking format! arguments.
trace
Logs at Level::Trace: every step, for when nothing else has worked.
warn
Logs at Level::Warn: something that will surprise someone later.

Functions§

console_table
Everything this crate exposes to the debug console.