Terrain LOD refactor: edge stitching, hybrid mesh LOD, performance fixes#87
Open
brendancol wants to merge 4 commits intomasterfrom
Open
Terrain LOD refactor: edge stitching, hybrid mesh LOD, performance fixes#87brendancol wants to merge 4 commits intomasterfrom
brendancol wants to merge 4 commits intomasterfrom
Conversation
Major enhancements to the terrain LOD system: - Replace tile skirts with boundary vertex stitching (_stitch_tile_boundary) that interpolates Z from coarser neighbor's pyramid data, eliminating T-junction cracks without extra geometry - Hybrid LOD for placed geometry: chunk manager applies simplify_mesh() during merge based on chunk LOD level (LOD 0=full, LOD 3=10% triangles) - Extract update() into focused helper phases (A-E) reducing main method from 324 to ~194 lines - Fix critical NameError: add missing cache_key in _rebuild_vertical_exaggeration - Add build retry budget (max 3 attempts) with logging for failed tile builds - Rate-limit I/O prefetches (max 8/tick) to prevent thread pool flooding - Early frustum culling before LOD/roughness computation (~40-60% fewer evaluations for tiles behind camera) - Single-pass future harvesting in _collect_completed_builds - Pyramid cache eviction for levels above max_lod - In-place simplify cache eviction (del loop vs dict rebuild) - O(1) stale tile eviction via set lookup - Simplified Z re-snapping: final_z = stored_z * ve - GPU re-snap threshold bumped from 1K to 10K verts - Float32 precision for compute_tile_roughness bilinear interpolation - Remove dead _add_tile_skirt function and references - Add get_metrics() structured API for programmatic LOD monitoring - Rename _has_pending to _has_in_flight_work for clarity - 114 tests (up from ~30), including edge stitching Z-value verification, hysteresis dead zone coverage, retry budget, and mesh simplification
Use the already-computed numpy array (base_np) instead of copying the raw raster data, which may be a dask array that doesn't support boolean mask assignment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_stitch_tile_boundary(), eliminating T-junction cracks without extra geometry._needs_stitch()fast-check avoids vertex copies when no neighbor differs._MeshChunkManagerappliessimplify_mesh()during merge based on chunk LOD level (LOD 0 = full detail, LOD 1 = 50%, LOD 2 = 25%, LOD 3+ = 10%). Lazy cached in_simplify_cache, evicted when chunks leave visible set. Curves excluded._rebuild_vertical_exaggeration()was missingcache_keydefinition — causedNameErrorcrash on VE change (Shift+Home/End) with non-LOD terrain.final_z = stored_z * ve), GPU threshold bumped 1K→10K, in-place cache eviction, pyramid level eviction abovemax_lod, float32 roughness computation.get_metrics()structured API,_has_in_flight_workrename for clarity._add_tile_skirtfunction, extractedupdate()into focused helper phases (A-E), updated docstrings and mesh.py references.Test plan
pytest rtxpy/tests/test_lod.py— 114 tests pass