Skip to main content

roxlap_core/
lib.rs

1//! roxlap engine core.
2//!
3//! A Rust voxel engine. The CPU renderer is a clean-room per-pixel
4//! 3D-DDA over an 8³ brickmap ([`dda`] + [`dda_sprite`]); it reads the
5//! voxlap-compatible `.vxl` / KV6 / KFA formats from `roxlap-formats`
6//! but the rendering algorithm is not voxlap-derived. See
7//! `docs/porting/PORTING-RUST.md` in the repository for the project
8//! history.
9//!
10//! # World handedness and the horizontal mirror
11//!
12//! roxlap's world is **z-down**: `x` = east, `y` = north, `z` points
13//! *down* into the map. Physically the triple (east, north, up) is
14//! left-handed, so a faithfully-projected view is **horizontally
15//! mirrored** relative to a real camera at the same heading — the
16//! viewer's geometric *right* lands on screen-*left*. This is Voxlap's
17//! native convention; it is baked into the projection, the frustum
18//! cull, the scan loops, and every bit-exact oracle golden, and is
19//! reproduced deliberately. It is **not** a bug.
20//!
21//! The camera basis the engine actually renders with is
22//! right-handed in the `(right, down, forward)` sense
23//! (`right × down = +forward`). Build it with
24//! [`Camera::from_yaw_pitch`], [`Camera::orbit`], or
25//! [`Camera::look_at`] — never by rotating [`Camera::default`], whose
26//! placeholder basis is left-handed and will make the sprite cull
27//! reject every sprite.
28//!
29//! ## I want an un-mirrored world
30//!
31//! Do **not** "fix" the mirror by negating `right` in the basis. That
32//! flips the chirality to `right × down = -forward`; the world still
33//! renders, but the sprite frustum cull then rejects every sprite
34//! (and you diverge from the oracle goldens). The mirror is in the
35//! projection, not the basis.
36//!
37//! Handle it on the **consumer side** instead — pick one and stay
38//! consistent:
39//!
40//! - mirror a single world axis in your scene → world mapping (e.g.
41//!   negate world-x when you place content), or
42//! - negate your yaw input so headings sweep the opposite way.
43//!
44//! Either re-establishes the chirality your project expects without
45//! touching the engine. (A true engine-side de-mirror would mean
46//! negating screen-x in *both* the grid raycaster and the sprite
47//! rasteriser while preserving the cull's normal winding — a large,
48//! golden-breaking change that diverges from Voxlap, and is out of
49//! scope here.)
50
51mod camera;
52pub mod camera_math;
53pub mod dda;
54pub mod dda_sprite;
55mod engine;
56pub(crate) mod fixed;
57pub mod grid_view;
58pub mod kfa_draw;
59pub mod opticast;
60pub mod raster_target;
61pub mod ray_aabb;
62pub mod sky;
63pub mod world_lighting;
64pub mod world_query;
65
66pub use camera::Camera;
67pub use dda::CompositeOccluder;
68pub use dda::{
69    effective_mip, pixel_ray, render_dda, render_dda_parallel, render_sky_fill, BrickCache,
70    CpuLights, CpuPointLight, DdaEnv, PixelSink, RasterSink, WorldOccluder, WorldShadowCtx,
71};
72pub use dda_sprite::{
73    draw_sprite_dda, draw_sprite_dda_shaded, draw_sprite_dense, draw_sprite_dense_shaded,
74    ClipFlipbook, SpriteDense, SpriteOccluder, SpriteShade,
75};
76pub use engine::{Engine, LightSrc, DEFAULT_KV6COL};
77pub use grid_view::{ChunkGrid, GridView};
78pub use opticast::OpticastSettings;
79pub use world_lighting::{
80    apply_lighting_with_cache, update_lighting, update_lighting_chunk, AoParams, EstNormCache,
81    ESTNORMRAD,
82};