perf(ui): Atlas deep rungs draw one gridunit per 2x2 px block
DISPLAY_RATIO_DEEP 1.0 -> 2.0, so a viewport-fit request at District/ Quarter/Block/Chunk asks for ~4x fewer gridunits (1920x1080: ~2.07M cells -> ~518K) and the server-side derive cost falls with it. Texel- exactness is preserved — the ratio stays a whole number of screen px per gridunit, so every source texel still lands on whole pixels; only the block size changes. Non-integer ratios are not an option here: they reintroduce exactly the sub-pixel blur D-255's texel-exactness exists to prevent. Judged live by Jeroen against the 1x1 build (pair session): the deep rungs read as crisp larger pixels rather than blur, and the speedup is substantial. Looks were the gate. Both transport tests that pinned the old literal now assert the RELATIONSHIP instead — deep rungs share the constant, viewport-fit divides by it — plus a new guard that the ratio stays whole, so the value remains tunable without editing tests that are not about it. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -76,9 +76,21 @@ func test_spacing_for_rung_matches_d243_metre_values() -> void:
|
||||
# =============================================================================
|
||||
|
||||
|
||||
func test_display_ratio_deep_rungs_are_one_to_one() -> void:
|
||||
## The four deep rungs share ONE display ratio, whatever its current value —
|
||||
## asserting the relationship rather than the literal, so tuning
|
||||
## DISPLAY_RATIO_DEEP (pair session 2026-07-26: 1.0 -> 2.0, the cost/looks
|
||||
## experiment) doesn't require editing a test that isn't about the number.
|
||||
## The value itself is a presentation tunable (D-255(a)); what must hold is
|
||||
## that the deep rungs agree with each other and stay a texel-exact integer.
|
||||
func test_display_ratio_deep_rungs_all_share_the_deep_ratio() -> void:
|
||||
var deep: float = StepCanvasTransport.DISPLAY_RATIO_DEEP
|
||||
for rung in ["District", "Quarter", "Block", "Chunk"]:
|
||||
assert_float(StepCanvasTransport.display_ratio_for_rung(rung)).is_equal_approx(1.0, 0.001)
|
||||
assert_float(StepCanvasTransport.display_ratio_for_rung(rung)).is_equal_approx(deep, 0.001)
|
||||
assert_float(deep).override_failure_message(
|
||||
"the deep display ratio must be a whole number of screen px per gridunit —"
|
||||
+ " a fractional ratio reintroduces the sub-pixel blur D-255 texel-exactness prevents"
|
||||
).is_equal_approx(floorf(deep), 0.0001)
|
||||
assert_float(deep).is_greater(0.0)
|
||||
|
||||
|
||||
func test_display_ratio_shallow_rungs_use_the_five_x_five_fallback() -> void:
|
||||
@@ -98,10 +110,16 @@ func test_is_orbital_rung_true_only_for_global_and_region() -> void:
|
||||
# =============================================================================
|
||||
|
||||
|
||||
func test_viewport_fit_extent_at_deep_ratio_matches_viewport_pixels() -> void:
|
||||
# 1x1 ratio -> extent in gridunits == viewport px, 1:1.
|
||||
var extent: Vector2i = StepCanvasTransport.viewport_fit_extent(Vector2(800.0, 600.0), "Chunk")
|
||||
assert_that(extent).is_equal(Vector2i(800, 600))
|
||||
## A deep-rung request asks for viewport_px / DISPLAY_RATIO_DEEP gridunits —
|
||||
## derived from the constant, not the literal, so the ratio stays tunable
|
||||
## (see the deep-ratio test above). This IS the cost lever: doubling the
|
||||
## ratio quarters the requested cell count.
|
||||
func test_viewport_fit_extent_at_deep_ratio_divides_by_the_deep_ratio() -> void:
|
||||
var deep: float = StepCanvasTransport.DISPLAY_RATIO_DEEP
|
||||
var viewport := Vector2(800.0, 600.0)
|
||||
var extent: Vector2i = StepCanvasTransport.viewport_fit_extent(viewport, "Chunk")
|
||||
var expected := Vector2i(int(ceil(viewport.x / deep)), int(ceil(viewport.y / deep)))
|
||||
assert_that(extent).is_equal(expected)
|
||||
|
||||
|
||||
func test_viewport_fit_extent_at_shallow_ratio_divides_by_the_display_ratio() -> void:
|
||||
|
||||
Reference in New Issue
Block a user