fix(mapeditor): road grading follows the terrain profile (no floating/dead-ending roads) #266
No reviewers
Labels
No labels
alpha:wave-0
alpha:wave-1
alpha:wave-2
alpha:wave-3
area:assets
area:combat
area:ecology
area:infra
area:render
area:scripting
area:ui
area:world
enhancement
epic
migration
post-alpha
roadmap
tech-debt
type:bug
type:chore
type:design
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
marco/IsoMmo!266
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/road-grading"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Painting a road across hilly terrain in the map editor was producing broken roads: with high Z the road floated over the ground, and on a steep run it would dead-end at a Z the destination terrain never reaches (the grader "cannò il calcolo del dislivello"). Root cause:
RoadGraderdrew a single straight ramp between the two end anchors and ignored the terrain profile in between, so anywhere the ground dipped or the two ends were far apart in Z, the road left the surface.This rewrites
RoadGrader.Gradeto follow the terrain walkably instead of bridging it. It reads the terrain Z under every stroke cell and runs two slope-limited passes over that profile: a forward pass from the start and a backward pass anchored at the end, each clamping every consecutive step to±WorldRules.MaxWalkStepZ. The result hugs the relief — it descends into a walkable dip and climbs back out instead of floating over it — while both ends still sit exactly on the ground and no step ever exceeds the walk cap. Where the terrain is genuinely too steep to climb walkably, it cuts a minimal grade (a cutting) rather than dead-ending; the designer makes the road longer / switchbacks for a big climb.The editor call-site (
EditorGame.GradeRoad) now feeds the per-cell terrain Z (_model.ZAt) into the grader instead of just the two endpoints.Behaviour is pure geometry over the stroke's terrain profile — unit-tested, no engine/rendering involved.
Screenshots / recording
N/A — the visible surface is the map editor (not the game client), and the effect is authored road elevation. The debug-harness drives the game client, not the editor GUI, and reproducing this needs a human painting a road stroke across steep terrain. The behaviour is fully pinned by unit tests over the terrain profile (
RoadGraderTests); the design doc (docs/map-editor.md) describes the new grading.How it was tested
RoadGraderTests(7 cases): flat terrain → flat road; a walkable slope followed exactly; a walkable dip followed down-and-back-up (the anti-float case,[10,5,10]); both ends sit on the terrain; an unwalkable spike ([0,100,0]) cut to a walkable grade with both ends grounded; every consecutive step within the cap for an arbitrary jagged profile; single-cell = the terrain and zero-cells = empty.dotnet test tests/IsoMmo.MapEditor.Core.Tests→ 68/68 green (0 warnings, warnings-as-errors).dotnet csharpier check .→ clean (515 files, full output — no "Was not formatted").python scripts/check-doc-refs.py→ all references resolve.*.dll(Auth/Client/GameServer processes) — pure copy locks (MSB3021/3027), not compile errors; CI builds clean on a fresh machine.Invariants Check
RoadGraderisint[]→int[]over local Z).Worldsim.World.csHARD GATE — N/A —Worlduntouched.ScreenHARD GATE — N/A — editor is not a clientScreen; the grading logic lives inRoadGrader(Core), the call-site inEditorGameonly reads_model.ZAtand delegates.RoadGraderinIsoMmo.MapEditor.Core(no MonoGame), unit-tested;EditorGameholds only the glue._model.ZAt).WorldRules.MaxWalkStepZ(the existing walk-step constant), no new ad-hoc tunable, noIConfigurationread.docs/map-editor.mdroad-grading paragraph updated in this change to describe the terrain-following behaviour.Checklist
just lintpasses (CSharpier clean + affected project builds with zero warnings)just testgreen for the affected project (68/68)RoadGraderTestsrewritten, 7 cases)Superseded by #267. That change takes a different (and correct) approach: roads no longer terraform Z at all — they follow the existing ground, and a new Route (A→B) mode routes a walkable path (A*, switchbacking on steep slopes) using the same
CanStepgate the server enforces. The Z-ramp grader here couldn't stay walkable on a climb steeper than its length. Closing in favour of #267.Pull request closed