Skip to content

feat!: rewrite in Rust with exact algorithms and a GPU-rendered UI - #1

Merged
shanto462 merged 4 commits into
mainfrom
rust-port
Oct 6, 2026
Merged

shanto462 merged 4 commits into
mainfrom
rust-port

Conversation

@shanto462

Copy link
Copy Markdown
Owner

Summary

Replaces the C# WPF app with a Rust workspace that runs on Windows and macOS (and Linux).

  • visibility-core (library, Rust 1.88+): exact event-driven visibility polygons, exact frustum culling, and exact occlusion culling from the same sweep. Obstacles live in one flat vertex array with a CSR uniform grid.
  • visibility-app (desktop app, Rust 1.95+): egui + wgpu. Obstacles are uploaded to the GPU once, so 100,000 obstacles pan and zoom smoothly. Light and dark themes, live timings, rays, keyboard shortcuts, and a command line with a --screenshot mode.
  • Repository setup: CI (fmt, clippy pedantic, tests on Linux/macOS/Windows, per-crate MSRV, docs, cargo-deny, coverage, one CI result gate), CodeQL, OpenSSF Scorecard, dependency review, Dependabot, a release workflow (Windows/macOS/Linux archives, SHA-256 sums, build provenance), and community files.

Fixed problems of the old version: fixed-ray shadow casting that cut corners, missed thin obstacles and had a data race; frustum culling that missed arc-only crossings; and occlusion culling that only tested corners.

Type of change

  • New feature
  • Performance improvement
  • Bug fix
  • Documentation
  • CI, build, or dependencies

How I tested it

  • cargo test --workspace --locked: 34 tests, including brute-force comparisons of the visible outline on random and heavily overlapping scenes, a frustum sandwich test, and regression tests for the old bugs. Mutation checks confirm the tests fail when key steps are removed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings (pedantic), cargo fmt --check, cargo doc with -D warnings, cargo deny check.
  • MSRV: visibility-core built and tested on Rust 1.88.
  • cargo check for x86_64-pc-windows-msvc and x86_64-unknown-linux-gnu from macOS. Windows and Linux run for real in this PR's CI.
  • Ran the app on macOS (Apple M4 Pro): all modes, themes, and 100,000 to 200,000 obstacles. Dry-ran the macOS release packaging (bundle, plist, ad-hoc signature).

Benchmark (cargo run --release -p visibility-core --example bench, one core): 23 µs for a 360° visibility query and 1.2 µs for frustum culling in the default scene.

Checklist

  • The PR title follows Conventional Commits.
  • cargo fmt --all --check passes.
  • cargo clippy --workspace --all-targets --locked -- -D warnings passes.
  • cargo test --workspace --locked passes.
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --locked passes.
  • I added or updated tests for the change.
  • I updated CHANGELOG.md.

…dered UI

Replace the C# WPF app with a Rust workspace:

- visibility-core: exact event-driven visibility polygons (full circle or
  view cone), exact view-cone culling, and occlusion culling from the same
  sweep. Obstacles live in one flat vertex array with a CSR uniform grid.
- visibility-app: egui/wgpu desktop viewer for Windows and macOS. Obstacles
  are uploaded to the GPU once; panning and zooming only update a uniform.

Correctness tests compare the outline against brute-force ray casting on
random and heavily overlapping scenes, and cover the cases fixed-ray
sampling gets wrong (thin obstacles, arc-only crossings, walls seen between
posts).
- Library keeps Rust 1.88; the app needs 1.95 for egui 0.36.
- Doctested library examples in the crate docs.
- Benchmark warms up with a full pass for stable numbers.
- Readable 'Inside an obstacle' label and plain-text key hints.
- macOS app icon (icns) for release bundles.
…etup

- README for the Rust version: gallery, benchmarks, install, controls,
  command line, how it works, library usage, and upgrade notes.
- CI: rustfmt, clippy, tests on Linux/macOS/Windows, MSRV per crate,
  docs, cargo-deny, coverage, and one 'CI result' gate check.
- Release: Windows, macOS (.app) and Linux archives with SHA-256 sums
  and build provenance attestations.
- CodeQL, OpenSSF Scorecard, dependency review, Dependabot, CODEOWNERS,
  issue and PR templates, SECURITY, CONTRIBUTING, CODE_OF_CONDUCT,
  CHANGELOG.
- scripts/readme-images.sh rebuilds the README images.
- Remove the old C# screenshots.
Library:
- Keep obstacle ids equal to the input order; degenerate polygons never block.
- Treat a viewer standing exactly on an obstacle edge or corner as blocked.
- Check every corner when several lie on one ray from the viewer.
- Clamp zero, negative and NaN arc tolerances.
- Reuse a thread-local visited set instead of allocating one per query.
- Remove unused grid helpers; document Scene::cast_ray as a public
  line-of-sight query. The library now forbids unsafe code itself.

App:
- 'Keep density' (on by default): the world grows with the obstacle count,
  so 200,000 obstacles get a 40,000 x 40,000 world instead of piling up.
- Fade obstacle outlines when zoomed far out so colors stay visible.
- Windows release builds attach to the parent console, so --help,
  --version and errors are visible.
- Screenshot mode gives up after 60 s if the window never renders.
- Status bar shows 'UI x ms' instead of a misleading 'ms/frame'.
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@shanto462
shanto462 merged commit 4db8ddf into main Oct 6, 2026
24 checks passed
@shanto462
shanto462 deleted the rust-port branch October 6, 2026 21:19
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