Drawing max range rings based on map elevation - #11
Conversation
|
I'm going to hold this one for now. The implementation is interesting, but the projectile model here is based on the older vacuum-fit approximation. The private ballistic research has moved significantly beyond that model, and automatic terrain ballistic behaviour is deliberately still disabled until the current held-out gameplay validation is complete I don't want to introduce a public feature based on a model that we already know is superseded, even if it is only being used for the range-ring delta The idea is good though, and I'd definitely like to revisit it once the validated ballistic model is ready |
|
I did end up doing some ballistics tests last night in the test range and it seems pretty confident about our range and time of flight estimates now with a newer model, dunno if you plan on doing more research on this but otherwise I can see about refactoring those changes into this PR aswell |
The max range ring currently assumes flat ground. Shooting downhill reaches further than the circle shows, uphill less. This solves the ring against a baked heightfield instead.
What is in here
scripts/lib/ballistics.mjs+scripts/fit-ballistics.mjs: a vacuum trajectory model fitted from the shipped firing tables, giving max range as a function of height difference.data/ballistics/projectile-model.json: the fitted model.scripts/lib/heightfield.mjs+scripts/build-heightfield.mjs: bakes a coarse height grid per map.data/terrain/{bakurani,ozeti}/heightfield.{bin,json}: 370 KB total.scripts/lib/terrain-source.mjs: shared reader for the raw terrain chunks.js/map/heightfield.js: runtime loader and sampling.js/map/range-ring.js: the solve and the drawing.Both generators reproduce the committed artifacts byte-identically (except a
generatedAttimestamp) from data already tracked here.Rendering change
This is the one part that modifies existing code.
draw()injs/map/renderer.jshad the max-range circle inline under/* Layer 5: artillery range. */. That block is replaced with a call todrawMaxRangeRing(a, rangePx, v.scale);a,rangePxandv.scalewere already computed on the line above.The ring is drawn as two outlines: the flat-ground range, and the extra reach where the terrain gives it. When there is no heightfield, no fitted model, or the map is unsupported,
drawMaxRangeRingdraws exactly the circle it draws today, with the same canvas calls.The min range circle is untouched and stays inline. It is deliberately not height-corrected.
Safety property
With the heightfield forced flat, every bearing returns the declared max range to within 9e-5 m, so the terrain solve cannot quietly shrink the ring relative to what the tables say.
Review notes
loadProjectileModel()andPROJECTILE_MODELare exported fromrange-ring.jsand load ininit().test:scriptsentry. The project has no test setup today, so that commit is last and separable.With the contour lines from #10 on to show its on a elevated spot: