Skip to content

fix(world): size world backgrounds from the camera's extent, not viewport * 5 - #199

Merged
LeadcodeDev merged 1 commit into
mainfrom
fix/world-halo-extent
Aug 12, 2026
Merged

fix(world): size world backgrounds from the camera's extent, not viewport * 5#199
LeadcodeDev merged 1 commit into
mainfrom
fix/world-halo-extent

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

Closes #189.

What

The same halo config behaved differently in a slide view and a world view: a radius: 0.55 that reads as a half-screen glow became a >5000px wash flooding every frame.

crates/rustmotion/src/engine/render/background.rs:68:

let world_w = width * 5.0;
let world_h = height * 5.0;

while HaloZone documents its fields as fractions of width/height.

Two problems in one line:

  • The unit changed with the view type, silently, for the same field.
  • 5.0 was unrelated to the world's actual extent, which is determined by the scenes' world-position values. A world spanning two viewports got the same canvas as one spanning ten — so calibrating a halo was trial and error with no rule to reason from.

How

WorldTimeline::world_extent(vw, vh) returns the union of one viewport-sized rect per camera waypoint — exactly the span the camera ever shows — as (x, y, width, height). The origin travels with it, so negative world-positions are inside the world rather than off its edge, which the old 0..w*5 framing could not express.

draw_world_bg_with_parallax takes that extent instead of computing its own, and HaloZone's doc comments name the surface for both view types.

Visual change

Any world-view halo calibrated against the old 5x canvas now covers a different share of the frame — proportionally larger for a world smaller than five screens, which is most of them. Checked against the 3-beat world view in the showcase scenario: the halos went from near-invisible points to a proportionate ambient glow, text still legible, register unchanged. Slide views are untouched.

Tests

Four on world_extent, no rendering needed:

  • spans the waypoints plus one viewport
  • a single-waypoint world is one screen — where viewport * 5.0 claimed five, and divided every radius by five with it
  • negative waypoints move the origin rather than being measured from zero
  • no waypoints falls back to the viewport

cargo test --workspace green, cargo fmt --check and cargo clippy --all-targets -- -D warnings clean.

…port * 5

A halo config behaved differently in a slide view and a world view: the same
radius: 0.55 that reads as a half-screen glow became a wash flooding every
frame. HaloZone documents its fields as fractions of width/height; in a world
view they were fractions of a hardcoded 5x viewport.

Two problems in one line. The unit changed silently with the view type, and
5.0 was unrelated to the world's actual extent — a world spanning two
viewports got the same canvas as one spanning ten, so calibrating a halo was
trial and error with no rule to reason from.

WorldTimeline::world_extent derives the surface from the camera's own
waypoints: the union of one viewport-sized rect per waypoint, which is exactly
the span the camera ever shows. The origin travels with it, so negative
world-positions are inside the world rather than off its edge.

HaloZone's doc comments now name the surface for both view types.

Visual change: any world-view halo calibrated against the old 5x canvas covers
a different share of the frame now — proportionally larger for a world smaller
than five screens, which is most of them.
@LeadcodeDev LeadcodeDev self-assigned this Aug 12, 2026
@LeadcodeDev LeadcodeDev added the bug Something isn't working label Aug 12, 2026
@LeadcodeDev
LeadcodeDev merged commit 2e99161 into main Aug 12, 2026
3 checks passed
@LeadcodeDev
LeadcodeDev deleted the fix/world-halo-extent branch August 12, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

halo zones are fractions of a hardcoded 5x world in world views, contradicting their doc

1 participant