Skip to content

fix: elevation smoothing artifacts for small bboxes and search double fire - #789

Merged
louis-e merged 3 commits into
mainfrom
fix/elevation-smoothing-and-search-debounce
Mar 24, 2026
Merged

louis-e merged 3 commits into
mainfrom
fix/elevation-smoothing-and-search-debounce

Conversation

@louis-e

@louis-e louis-e commented Mar 15, 2026

Copy link
Copy Markdown
Owner
  • Compute output_sigma as max(sigma_from_grid, sigma_terrain) using a single Gaussian blur pass, preventing Voronoi block cliff edges and SRTM surface artifacts for small bounding boxes (~100-200m). Large-area behaviour is unchanged (sigma_from_grid dominates above ~7.5 km crossover). min/max and output heights derive from the same blur field, eliminating any possibility of range-decoupling division-by-zero.

  • Fix search.js double-fire: button/Enter handlers now call clearTimeout() before performSearch(), and in-flight Ajax requests are aborted before issuing a new one via activeRequest.abort().

…-fire

- Compute output_sigma as max(sigma_from_grid, sigma_terrain) using a single
  Gaussian blur pass, preventing Voronoi block cliff edges and SRTM surface
  artifacts for small bounding boxes (~100-200m). Large-area behaviour is
  unchanged (sigma_from_grid dominates above ~7.5 km crossover).
  min/max and output heights derive from the same blur field, eliminating
  any possibility of range-decoupling division-by-zero.

- Fix search.js double-fire: button/Enter handlers now call clearTimeout()
  before performSearch(), and in-flight Ajax requests are aborted before
  issuing a new one via activeRequest.abort().
Copilot AI review requested due to automatic review settings March 15, 2026 00:01
@github-actions

Copy link
Copy Markdown

⏱️ Benchmark run finished in 0m 27s
🧠 Peak memory usage: 1111 MB

📈 Compared against baseline: 30s
🧮 Delta: -3s
🔢 Commit: f2c9823

🟢 Generation time is unchanged.

📅 Last benchmark: 2026-03-15 00:04:38 UTC

You can retrigger the benchmark by commenting retrigger-benchmark.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets two user-facing issues: terrain generation artifacts for very small bounding boxes, and duplicate/double-fired city searches in the GUI.

Changes:

  • Adjust elevation blur selection to use a single blur pass with output_sigma = max(sigma_from_grid, sigma_terrain) and compute min/max from the same blurred field.
  • Add GUI search debouncing fixes by clearing pending timeouts on click/Enter and aborting in-flight Ajax requests before issuing a new one.
  • Add tests around the new sigma selection behavior and expected crossover.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/gui/js/search.js Adds timeout clearing and in-flight request aborting to reduce duplicate/stale searches.
src/elevation_data.rs Updates blur sigma selection logic and min/max derivation; adds tests for sigma behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/gui/js/search.js Outdated
Comment thread src/gui/js/search.js Outdated
Comment thread src/elevation_data.rs Outdated
Comment thread src/elevation_data.rs
Comment thread src/elevation_data.rs
search.js:
- Capture jqXHR in local var and guard callbacks against stale responses
  (older request's callback no longer clears newer activeRequest)
- Use jQuery textStatus parameter instead of xhr.statusText for abort detection

elevation_data.rs:
- Remove .max(1.0) clamp on native_resolution; guard sigma_terrain with
  .max(1e-6) instead, so scale < 1.0 no longer over-blurs
- Add sentinel validation after min/max reduction: fall back to flat terrain
  if no finite samples exist (all-NaN grid from failed tile downloads)
- Strengthen test_output_sigma_same_field_invariant to run actual blur on
  synthetic grid and verify every cell lies within derived [min, max]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses two user-facing issues: terrain elevation smoothing artifacts on small bounding boxes during world generation, and duplicate/stale city search requests in the GUI.

Changes:

  • Adjust elevation smoothing by selecting output_sigma = max(sigma_from_grid, sigma_terrain) and deriving min/max from the same blurred field to avoid small-area artifacts.
  • Prevent overlapping/stale city search responses by aborting in-flight Ajax requests and clearing pending debounce timeouts before triggering a new search.
  • Add unit tests around sigma selection/crossover and a “single blur field” invariant.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/gui/js/search.js Adds request tracking/abort logic to reduce duplicate search behavior and prevent stale responses from overwriting newer ones.
src/elevation_data.rs Revises Gaussian blur sigma selection for small bboxes and adds tests to guard against regressions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/elevation_data.rs Outdated
Comment thread src/elevation_data.rs
Comment thread src/elevation_data.rs
Comment thread src/gui/js/search.js
- Rename native_resolution to blocks_per_tile_pixel (unit was blocks, not metres)
- Clamp output_sigma to grid_size/2: beyond that the kernel exceeds the grid
  and extra sigma only wastes computation with no visual effect
- Abort in-flight Ajax request in hideResults() so stale responses don't
  re-display results when the user clears the search input

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@louis-e
louis-e merged commit 1a0f1f7 into main Mar 24, 2026
6 checks passed
@louis-e
louis-e deleted the fix/elevation-smoothing-and-search-debounce branch March 26, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants