Skip to content

Fix keyboard camera and minimap timing, sprite colour and scale, trail wrap, and drag-over-UI in the renderer - #101

Merged
vhata merged 10 commits into
mainfrom
review/render-input-and-sprite-fixes
Nov 9, 2026
Merged

vhata merged 10 commits into
mainfrom
review/render-input-and-sprite-fixes

Conversation

@vhata

@vhata vhata commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Why

The 2026-10-09 full review found six renderer bugs, batched as the
review backlog entry render-input-and-sprite-fixes. Each one makes the
world view misreport what the sim is doing, or react to input it should
ignore.

  • render-input-on-virtual-time: camera_control_system and
    update_minimap read the default Time, which in Update is
    Time<Virtual>. sim_speed_system pauses and rescales that clock.
    So while paused, WASD, the arrows and E/Q/-/= did nothing, and the
    minimap (viewport box, selection marker, mode switches) froze. At
    16x, keyboard pan ran 16 times faster. Pausing to look around is one
    of the main ways to watch the sim, and that was exactly when the
    keyboard camera stopped working.
  • sprite-colour-frozen-at-spawn-species: a simple-LOD sprite's colour
    came from the organism's species when the sprite was built and never
    changed after that. Founders spawn in species 0 before the first
    classification pass, so every founder kept species 0's colour, and
    an organism moved to another species kept its old one. This lasted
    until the next LOD switch rebuilt the sprites, so at a steady zoom a
    new species was invisible on screen until its children appeared.
  • trail-draws-across-torus-wrap: the selected organism's trail was a
    single line strip. When the organism wrapped across a world edge, the
    strip drew a line across the whole map.
  • minimap-row-underflow-at-world-edge: the minimap's normal and range
    modes computed a dot's row as size - 1 - (y / world_h * size) as usize. That underflows when y == world_h, which rem_euclid can
    produce for a tiny negative input. A debug build panics there. A
    release build wraps the value and the bounds check throws the dot
    away.
  • simple-lod-spawn-scale-overwritten: a new simple-LOD sprite spawned
    at body_size * 1.5 for plants or * 2.0 for everything else. On
    the next frame the per-frame update replaced that with
    organism_sprite_scale, which includes the energy factor. So the
    plant multiplier did nothing, and every new sprite changed size after
    one frame. Detailed sprites had the same one-frame jump, because
    their spawn scale left out energy and flash.
  • drag-pan-ignores-pointer-over-ui: scroll zoom and click-select
    already stand down while the pointer is over egui, but mouse-drag
    panning did not. A right-, middle- or Shift+left-drag that started
    on the side panel or the minimap panned the world underneath it.

What changed

  • The keyboard pan and zoom in camera_control_system, and the repaint
    timer in update_minimap, now read Time<Real>. They run at the
    same on-screen rate whether the sim is paused or at any speed.
    Time<Real> has no maximum delta, unlike the sim's Time<Virtual>
    (capped at 100 ms by the sim plugin), so the camera's step is capped
    at CAMERA_MAX_DT_SECS (0.1 s), the same figure.
    Without the cap, a slow frame with a pan or zoom key held would jump
    the camera or snap the zoom to its clamp. Mouse drag and scroll never
    used a delta, so they are unchanged.
  • The simple-LOD colour formula is now a separate function,
    simple_sprite_color. A new PostUpdate system,
    recolour_sprites_on_species_change, runs after
    sync_organism_transforms. For every simple-LOD sprite with
    Changed<SpeciesId>, it rewrites the sprite's material colour. The
    species classifier writes every organism's id on each pass, even when
    the id stays the same (the TODO species-id-rewritten-every-pass
    tracks that), so the system compares colours first and only calls
    get_mut (which re-uploads the material) when the colour actually
    changed. Detailed-LOD parts are coloured by segment type,
    not species, so they are left alone.
  • draw_trails_system splits the trail into runs with trail_runs. A
    run ends wherever two consecutive samples are more than half the
    world apart on either axis. Each run with at least two points is
    drawn as its own line strip.
  • minimap_px computes a minimap pixel with signed arithmetic, the way
    the selection-marker code already did. minimap_dot returns that
    pixel as image indices, or None if it falls outside the image. The
    normal-mode dots, range-mode grey dots, range-mode highlight and
    selection marker all go through these two functions.
  • current_sprite_scale computes organism_sprite_scale with the
    energy factor and flash pulse applied. The spawn and the per-frame
    update now both use it, so a sprite keeps its size from its first
    frame. The plant-only 1.5 spawn multiplier is gone. It only ever
    lasted one frame, so the steady-state sizes on screen are unchanged.
    To provide those inputs at spawn, the without-sprite query now also
    reads Energy, BodySize and ActionFlash. The with-sprite update
    query already required all three.
  • CameraDragState now holds a DragPhase (Idle, Panning,
    Ignored). next_drag_phase settles each drag on the frame its
    button goes down: if the pointer is over the UI then, the drag is
    ignored until release. A drag that starts on the world keeps panning
    when the pointer crosses onto a panel. A drag that starts on a panel
    stays ignored when the pointer moves onto the world. The cursor
    position is now tracked in every phase, and the first pan delta is
    measured from the last cursor sample before the press frame. Before,
    the drag skipped its first cursor sample. last_pos is an Option,
    so the first cursor event ever seen cannot produce a jump from the
    origin.
  • Docs: the "Virtual time pause" entry in docs/DECISIONS.md now notes
    that the keyboard camera and the minimap repaint read Time<Real>.
    The pan/zoom/drag line in docs/FEATURES.md now says keyboard pan
    and zoom work while paused, and that a drag starting over the side
    panel or minimap is ignored.
  • The render-input-and-sprite-fixes entry is removed from
    review/BACKLOG.md. No other entry's Related: line named it. The
    related lod-switch-skips-childless-sprites TODO is out of scope and
    untouched.

Markers

Type: fix
Resolves review backlog: render-input-and-sprite-fixes
Resolves review finding: render-input-on-virtual-time
Resolves review finding: sprite-colour-frozen-at-spawn-species
Resolves review finding: trail-draws-across-torus-wrap
Resolves review finding: minimap-row-underflow-at-world-edge
Resolves review finding: simple-lod-spawn-scale-overwritten
Resolves review finding: drag-pan-ignores-pointer-over-ui

Validation

All scenarios use cargo run --release -- --seed 42, which opens a
window, and start at the default zoom (1.0, the simple LOD).

  1. Keyboard camera and minimap while paused
    (render-input-on-virtual-time). Press Space to pause. Hold D, then
    the arrow keys, then Q and E. Before the fix nothing moved while
    paused; now the camera pans and zooms. While still paused, pan with
    WASD and watch the minimap in the top-left. Before, its yellow
    viewport box stayed where it was when you paused; now it follows
    the camera within half a second. Press M while paused: the minimap
    should switch to the heatmap within half a second (before, it stayed
    on the old mode until you unpaused). Then unpause, press ] four
    times to reach 16x and hold D. The pan speed should match 1x;
    before, it was 16 times faster.
  2. Founder colours split into species
    (sprite-colour-frozen-at-spawn-species). Do not zoom. For the
    first few seconds every consumer founder is drawn in shades of one
    hue, species 0's colour shifted towards red by claw power and
    towards green by photosynthesis. After the first classification
    pass, at 5 s of sim time, consumers should split into several
    distinct species hues without any zooming. Before the fix, they kept
    the founder hue until you zoomed in past the LOD threshold and back
    out. Plants stay yellow-green either way.
  3. Trail at the world edge (trail-draws-across-torus-wrap).
    Click near the edge of the minimap to jump to a world edge. Click an
    active (outlined) organism moving towards the edge and press T. When
    it crosses the edge, the old trail drew a straight line across the
    whole map to the far side. Now the trail breaks at the seam: a short
    piece stays at the edge it left, and a new piece starts on the
    opposite side.
  4. Minimap rows at the top edge
    (minimap-row-underflow-at-world-edge). The trigger is an organism
    at exactly the world's top edge, which is too rare to stage by hand,
    so check it by inspection. Run
    grep -n "size - 1 -" crates/clauvolution_render/src/lib.rs. The
    only hits should be the two terrain loops' size - 1 - py, which
    are safe because py < size. Every minimap dot and marker goes
    through minimap_px or minimap_dot, and
    cargo test -p clauvolution_render minimap_dot covers the edge
    itself. As a regression check in the GUI, the minimap's dots should
    still sit where the organisms are in Normal mode. Press M twice for
    Range mode with an organism selected: its species should still be
    highlighted in the right places, and the selection crosshair should
    still sit on the selected organism.
  5. Newborn sprite size (simple-lod-spawn-scale-overwritten). The
    old bug lasted a single frame, so it is hard to see by eye. Watch
    newborns at the default zoom: a new sprite should appear at its
    final size, without a one-frame pop. The steady-state sizes of
    plants and consumers should look the same as before the fix, since
    the formula the per-frame update applies has not changed. The test
    new_sprites_keep_their_spawn_scale (run it with
    cargo test -p clauvolution_render new_sprites) checks that the
    frame-one and frame-two scales match at both LODs for plants and
    consumers.
  6. Drag that starts over the UI
    (drag-pan-ignores-pointer-over-ui). Press the right mouse button
    over the side panel and drag onto the world. Before the fix, the
    world panned. Now nothing moves until you release, and pressing
    again over the world pans as usual. Do the same starting on the
    minimap image: no pan. Then start a right-drag on the world and drag
    across onto the side panel. It should keep panning, since the drag
    started over the world.

Automated: bash scripts/check.sh passes (queues, links, fmt, clippy,
all workspace tests), cargo test -p clauvolution_render passes, and
cargo run --release -q -- --headless 300 --seed 42 runs clean. The
headless run does not exercise render code; it only guards the build.

New unit tests in clauvolution_render cover each fix. Each was
mutation-checked by putting the old code back and confirming the test
fails:

  • keyboard_pan_and_zoom_run_on_real_time_while_paused and
    minimap_repaints_on_real_time_while_paused fail with Res<Time>.
  • a_slow_frame_moves_the_keyboard_camera_at_most_one_capped_step
    fails with the delta cap removed.
  • simple_sprite_recolours_when_its_species_changes fails with the
    recolour loop emptied.
  • trail_breaks_where_it_wraps_on_either_axis fails with no split, and
    also with an x-only split.
  • minimap_dot_maps_corners_and_drops_the_far_edges panics with
    "attempt to subtract with overflow" under the old usize arithmetic.
  • new_sprites_keep_their_spawn_scale fails with the old spawn scale,
    for simple and detailed LODs, plant and consumer.
  • drag_phase_is_decided_when_the_button_goes_down and
    drag_started_over_the_ui_does_not_pan fail with the UI gate
    removed.

vhata added a commit that referenced this pull request Nov 9, 2026
Five ideas from the #101, #103 and probe-script work that the October 24
review did not ledger: the predation attacker-order bias (which
docs/DECISIONS.md already cites), old age never firing, SpeciesId
rewritten every classification pass, the stale Killed doc comment and
the audit summary crash on a missing CSV. Also records extra-tick
evidence on headless-save-ticks-past-summary.
@vhata
vhata force-pushed the review/render-input-and-sprite-fixes branch from b2a106b to 1ff72d5 Compare November 9, 2026 01:52
@vhata

vhata commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Review

Independent review by a separate Claude Opus 5.5 reviewer agent at
e17fb8d (originally 462c581): approve with nits.

Verified:

  • System registration and ordering:
    recolour_sprites_on_species_change runs in the PostUpdate chain
    after sync_organism_transforms.
  • Simple-LOD materials are per sprite, not shared, so recolouring one
    sprite cannot affect another.
  • The trail split uses the sim's wrap dimensions
    (SimConfig::world_width and world_height).
  • All minimap dot and marker sites go through the new helpers.
  • The claim that the plant 1.5 multiplier only lasted one frame holds.
  • The drag phases have no stuck states.
  • The added per-frame cost is negligible.
  • Five reviewer mutations were caught by the tests.
  • scripts/check.sh and check-pr-markers pass.

Findings: 3.

  1. Time<Real> has no maximum delta, so a slow frame with a pan or
    zoom key held could jump the camera or snap the zoom. Fixed in
    48f06c9 (originally b2a106b) with CAMERA_MAX_DT_SECS (0.1 s) and
    a mutation-checked test.
  2. The colour validation scenario overstated the founders as one
    colour; claw power and photosynthesis shift it, so it is shades of
    one hue. Fixed in the PR body.
  3. The drag description said the first pan delta was measured from
    where the pointer was when the button went down; it is from the
    last cursor sample before the press frame. Fixed in the PR body.

The same reviewer re-checked the fixes at 48f06c9 (originally
b2a106b): removing the cap fails the new slow-frame test, reverting to
the virtual clock still fails the paused-camera test, and
cargo test -p clauvolution_render passes. Approved.

Not checked: on-screen appearance, since no GUI was opened. Plugin
registration was verified by reading the code, not by a test.

Rebase onto origin/main 2a2dafb (from base 716d16a): the nine commits
carry over with identical code changes (git range-diff shows every
code commit unchanged; only the backlog-removal and docs commits differ,
in surrounding context). Old to new SHAs: 6aab1cb 10705aa, 20007ae
7659bf0, 75b2e26 343e2c2, e95e990 ce4116c, 78464b5 9795c22, 3adf6da
0401f48, fe4197c 5f97811, 462c581 e17fb8d, b2a106b 48f06c9. After the
rebase, scripts/check.sh passes, cargo test -p clauvolution_render
passes 27 tests, and four mutations still fail the tests: removing the
camera delta cap, dropping the drag-start UI gate, an x-only trail
split, and Res<Time> in camera_control_system. The rebased branch
has not had a fresh independent review.

Post-rebase review

Independent review by a separate Claude Opus 5.5 reviewer agent at
48f06c9 (rebased onto origin/main 2a2dafb, after #102 to #108):
approve with nits; fixes confirmed at 1b6f854, approve.

Verified: crate code is byte-identical to the pre-rebase head; with
#103, Killed victims are despawned before classification, so neither
recolour nor sprite sync sees a corpse; with #104, all three spawn
paths insert Energy, BodySize and ActionFlash; with #102,
UiInputState.pointer_over_ui is still set in PreUpdate and read by the
drag gate in PostUpdate; recolour excludes the shared outline
material; four new mutations (minimap bound, cursor tracking only
while panning, recolour guard inverted, detailed flag forced at spawn)
each fail the intended test; all six GUI scenarios match the current
key bindings; cargo test -p clauvolution_render (27), scripts/check.sh
and check-pr-markers --strict pass.

Findings: 2.

  1. The CAMERA_MAX_DT_SECS comment and the description cited
    Time's default 250 ms cap; the sim plugin sets 100 ms.
    Fixed in 1b6f854.
  2. The drag comment still described the first pan delta as measured
    from the button-down position. Fixed in 1b6f854.

Not checked by the reviewer: on-screen behaviour (no GUI opened).

GUI validation (coordinator, release build at 1ff72d5's code)

A scripted tour (--seed 42, 4x, screenshots at 20 s and 23 s of sim
time) shows consumer sprites in several species hues after the first
classification passes, rather than one founder colour, and the
minimap drawing the viewport rectangle at close zoom.

Not yet checked by hand: pausing and panning with WASD, minimap
tracking while paused, the trail seam and drag over the UI. These need
real key and mouse input, which this session could not send (the
terminal has no Accessibility permission). The backlog entry's
acceptance gate ("pause, then WASD still pans and the minimap still
tracks") is outstanding until someone runs it.

Unrelated, found on the way: a tour's exit action leaves the app
running on main as well; filed as TODO script-exit-leaves-app-running.

@vhata vhata added docket Made under the Docket workflow type:fix Docket change type: fix queue:review Docket: claims or resolves review backlog work area:render Docket queue area [RENDER] priority:p2 Docket queue priority P2 labels Nov 9, 2026
@vhata
vhata force-pushed the review/render-input-and-sprite-fixes branch from 1ff72d5 to cc601e3 Compare November 9, 2026 02:02
@vhata
vhata merged commit 681860e into main Nov 9, 2026
3 checks passed
@vhata
vhata deleted the review/render-input-and-sprite-fixes branch November 9, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:render Docket queue area [RENDER] docket Made under the Docket workflow priority:p2 Docket queue priority P2 queue:review Docket: claims or resolves review backlog work type:fix Docket change type: fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant