Crate ferravex

Source
Expand description

Ferravex: original, modular Rust engine systems using only project crates and std.

§Make a game

From a Ferravex checkout, three commands give you a playable 2D starter (add --template 3d for 3D) that depends only on this crate:

python3 -B scripts/ferravex.py new moon-garden
cd ../moon-garden
cargo run

Its rules live in src/game.rs and run on fixed ticks; drawing in src/lib.rs and src/hud.rs only reads them. The same project builds for the browser with python3 scripts/build-web.py --serve.

§Learn the facade

Start with prelude for session timing, math, cameras and input. Rendering functions stay under render so their origin remains clear. The full engine modules remain available for more specialized systems.

§Find an API

The prelude adds only common starting points; qualified paths retain the original types and errors without facade wrappers:

The facade’s optional content feature forwards runtime authoring support to the engine. The default facade already exposes renderer-independent authoring APIs; enabling content is not needed for the example below.

use ferravex::prelude::*;

let config = SessionConfig::try_new(60.0, 8, true)?;
let mut session = GameSession::from_config(config);
let mut position = Vec2::ZERO;
let mut previous = position;
let velocity = vec2(120.0, 0.0);
let frame = session.advance(1.5 / 60.0);
for _ in 0..frame.steps {
    previous = position;
    position += velocity * frame.dt;
}
// Presentation interpolates snapshots without changing simulation state.
let visible_position = previous.lerp(position, frame.alpha);
assert!((visible_position.x - 1.0).abs() < 0.0001);

For drawing, render::shapes provides anti-aliased rounded shapes and glows, render::ui::kit provides modern panels, buttons and key prompts, and render::post adds opt-in bloom and grading such as PostFx::subtle().

Run the facade-only example’s deterministic scenario without a display: cargo run -p ferravex --example quickstart --offline --locked -j 2 -- --headless. Omit -- --headless for an interactive native window. It demonstrates pause, restart and paused single-stepping using the existing render::game! entry point. Compile its Wasm entry point with cargo build -p ferravex --example quickstart --target wasm32-unknown-unknown --offline --locked -j 2. Compilation alone does not exercise a browser host or graphics device.

Re-exports§

pub use ferravex_core as core;

Modules§

ai
Shared AI plus authoritative current-pose rigid-world occlusion.
animation
First-party playback, skeletal/sprite clips, state graphs and retained GPU skinning.
app
Host-driven startup, fixed update, presentation and shutdown hooks. A renderer-independent, host-driven application lifecycle.
assets
Deterministic cooked bundles with bounded parsing and transactional hot reload. The original RLE codec is intended for flat-color assets, not general-purpose compression. Each bundle permits 4096 paths (240 bytes each) and 64 MiB of decoded payload. Retained Arc readers keep old generations alive; the limit is per bundle, not global. Checksums detect corruption and provide no authentication or encryption. Checked lookups normalize authoring paths; legacy operations and the wire format continue to require canonical paths. Checked live updates validate before publication. Bundle::manifest exposes sorted, borrowed metadata for tooling without encoding a bundle or copying its payloads.
audio
Shared first-party audio core; platform output lives in ferravex-render.
bitset
See bitset for the system contract and examples. Dense dirty/visibility masks with checked indices and ascending iteration.
camera
Shared follow, orbit, chase and first-person presentation rigs. Shared presentation rigs and a current-pose rigid-physics obstruction adapter.
commands
See commands for the system contract and examples. Deferred host/world mutations at an explicit synchronization boundary.
diagnostics
See diagnostics for the system contract and examples. Bounded local engine diagnostics with severity filtering and consecutive dedup. Codes are 1..=64 bytes, messages <=1024 bytes; no transport or logging backend. Capacity counts records. Repeated equal records retain first/last host tick.
dynamics
Original, dependency-free 2D/3D translational rigid-body physics.
ecs
Original, dependency-free entity/component storage for small Ferravex games.
ecs_commands
Bounded deferred ECS authoring, with buffer-local, epoch-local spawn tokens.
effects
Original bounded simulation and shared low-poly GPU effect rendering.
events
See events for the system contract and examples. Bounded FIFO engine events. Capacity counts events, not their owned payload bytes. Overflow is explicit; retained events preserve send order. EventQueue::try_send_batch admits a whole batch only when every event fits, preserving queued events and the caller’s batch on capacity rejection.
frame_events
See frame_events for the system contract and examples. Explicit event visibility boundaries for ordered engine systems. Sends enter a pending buffer; advance publishes it and expires the previous frame. Each buffer holds at most capacity events (total retained count <= 2*capacity).
graphics
First-party CPU graphics: reusable mesh storage, visibility and low-poly rasterization.
input
Shared first-party actions, contexts and binding configuration.
interpolation
Two-sample presentation history with explicit holds and discontinuities. Two retained simulation values and caller-selected presentation interpolation.
math
Original, dependency-free scalar game mathematics.
net
Bounded, versioned network protocol shared by native and browser game clients.
physics
Original rigid-body simulation for the recovered Ferravex games.
play
Original, dependency-free gameplay systems shared by small Ferravex games. Renderer-independent systems; cameras share the first-party scalar math crate.
pool
See pool for the system contract and examples. Bounded reusable object slots with generation-checked handles.
prelude
A deliberately small set of common engine entry points.
profile
Bounded telemetry. Register counters once; recording does not allocate. Summary construction clones a bounded name; ids belong to their originating profiler.
random
See random for the system contract and examples. Reproducible SplitMix64 streams for engine variation, never cryptography. Forks depend on the original seed and stream ID, independent of parent draws.
render
Original immediate/retained renderer and platform ABI. Game code, input, geometry and scheduling live in Rust; hosts only bind OS events and GPU submission.
replay
resources
See resources for the system contract and examples. Typed singleton engine resources without string keys or unsafe downcasts. At most 256 distinct types. Values are host-owned and may have arbitrary size. This single-threaded store does not impose Send/Sync on resources.
scheduler
See scheduler for the system contract and examples. Bounded tick deadlines with deterministic FIFO ties and explicit work limits. IDs belong to their scheduler; tick values are monotonic absolute host ticks.
session
Shared lifecycle and fixed-timestep coordination for local games. Shared start, pause, retry and fixed-timestep timing for local game sessions.
shuffle
See shuffle for the system contract and examples. Reproducible shuffled index cycles for nonrepeating engine variants.
smoothing
See smoothing for the system contract and examples. Frame-independent scalar and angular presentation smoothing.
snapshots
See snapshots for the system contract and examples. Bounded monotonic tick snapshots. Hosts own state and interpolation semantics. Failed inserts preserve history; rolling eviction removes only the oldest state.
spatial
See spatial for the system contract and examples. Bounded point buckets for engine interest, selection and proximity queries. IDs are host-owned u64 values. Queries visit at most 4096 cells; an oversized query returns an error instead of partial results. This is not a physics broadphase. Use SpatialGrid::query_into to reuse caller storage and report omitted matches. SpatialGrid::query_radius_into and SpatialGrid::query_nearest_into return stored positions ranked by squared distance, then ID, without allocating.
state
See state for the system contract and examples. Deferred lifecycle transitions (loading, running, paused, etc.) with an explicit allow-list. Hosts handle enter/exit work after commit; callbacks only run when explicitly supplied to StateMachine::commit_with or StateMachine::try_commit_with. No state-specific game rules are imposed.
system_order
See system_order for the system contract and examples. Stable topological ordering for sequential engine stages. No systems execute here. Up to 256 named systems. Among systems whose prerequisites are satisfied, the earliest registered system always runs first, including newly ready systems.
systems
Prepared, bounded sequential execution over the existing SystemOrder.
tags
See tags for the system contract and examples. Bounded hierarchical tags for engine content and system filters. Tags are case-sensitive ASCII segments separated by dots. A stored child satisfies its parent query; render.mesh never matches render.meshes.
time
See time for the system contract and examples. Supplied simulation time, pause/scale control, and drift-free duration timers.
weighted
See weighted for the system contract and examples. Checked integer-weight sampling for engine content and procedural variants.
work_budget
See work_budget for the system contract and examples. Deterministic shared work quotas for AI, streaming and incremental rebuilds. Units are host-defined work items, not inferred CPU time. Requests never partially consume unless the caller explicitly uses WorkBudget::grant_up_to.

Structs§

Entity
Opaque slot identity. A despawned entity never becomes valid again in its world. Handles are world-local; two separate worlds may issue the same identity.
FixedClock
Frame-rate independent simulation with bounded catch-up work.
FrameStats
Allocation-free statistics over the most recent N accepted frame times.
FrameStep
A fixed simulation step budget with a fractional render interpolation factor.
GameSession
A local game lifecycle with an owned, deterministic FixedClock.
SessionConfig
Validated, reusable settings for a GameSession.
TickBatch
An allocation-free snapshot of a frame budget and its scheduled tick IDs.
TickContext
Context for one scheduled fixed update, produced by TickBatch::ticks.
World
Sparse typed storage with generational entities and checked component borrows.

Enums§

SessionState
Host lifecycle state, independent of a game’s simulation-specific phases.