Skip to content

Generate nav ladders from climbable brushes in nav_generate - #2280

Open
sunzenshen wants to merge 31 commits into
NeotokyoRebuild:masterfrom
sunzenshen:laddergen-hardening-1833
Open

sunzenshen wants to merge 31 commits into
NeotokyoRebuild:masterfrom
sunzenshen:laddergen-hardening-1833

Conversation

@sunzenshen

@sunzenshen sunzenshen commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

Builds on #1833 (Rainyan's brush-ladder generation), rebased on master, with fixes on top. A squash
merge should keep Rainyan's credit (Co-authored-by: Rainyan <Rainyan@users.noreply.github.com>).

nav_generate now builds nav ladders for climbable brushes (CONTENTS_LADDER). Master builds none,
so a mesh generated from scratch has no ladders and a mapper places each one by hand. With this
change the generated mesh has a ladder on each climb, linked to the floor and the landing where
the geometry allows it.

The fixes on top of #1833 reject ladders that cannot be climbed, drop the extra ladders on a
brush's narrow end faces, and connect the ladder ends to the right floor and landing areas. The nav
grid is now updated when areas merge, so lookups during generation see the merged areas.

The generated ladders are rougher than hand-edited ones: some climbs with narrow landings, lips or
thin poles still need manual edits.

Toolchain

  • Windows MSVC VS2022
  • Linux GCC Distro Native (Linux Mint 22.3, GCC 13.3.0)

Linked Issues

Rainyan and others added 24 commits March 13, 2026 15:12
Bug from 2a78129 which breaks polyhedron math
Stack array ptr cannot be null
Validate the remaining signed span before linking a brush ladder. Preserve legacy manual and entity ladder creation.

Co-authored-by: Rainyan <Rainyan@users.noreply.github.com>
Keep the descent backlink and clear the behind slot explicitly when generating a brush ladder. A shared landing can also be a valid forward or side result.

Co-authored-by: Rainyan <Rainyan@users.noreply.github.com>
Brush ladders were built after sampling, so the sampler never
continued from their ends and a landing reached only by the climb
got no nav area. 31 of 43 generated climbs with a linked bottom and
no top exit on the ntre_ maps had no area at the landing at all.

Build brush ladders before sampling, as stock Source does with its
ladders, and connect them once areas exist. Skip a ladder-end seed
whose ground is more than a player height below the ladder end, so a
climbable brush over a void does not seed the void's floor.

When connecting a brush ladder, take the floor under the foot as the
bottom area before falling back to the nearest area: for a foot that
hangs above the floor the nearest area can be the top landing, which
then drops every top exit. If no top exit is found, scan again from a
step higher, for a climbable brush that ends below the landing's lip.

From-scratch nav_generate on 21 ntre_ maps against the curated
meshes: climbs linked up and down to the curated areas 100 -> 120 of
157, no top exit 45 -> 27, no climb that matched before lost its
match. Bullet, Transit, Ridgeline and Skyline output is unchanged.
A climbable brush often gets a ladder on its wide face and more on
its narrow end faces. The player hull overhangs an end face narrower
than itself, so a small sideways drift while climbing loses the
surface: on Transit, bots mounted the 19-unit end faces of the
19x34 brush and fell off about 30 units up on every try, while the
34-unit face worked.

After building the ladders of one brush, remove a ladder when a wider
ladder of the same brush faces another way and covers its height.
End faces that reach lower than the wide face's ladder stay.

From-scratch nav_generate on 21 ntre_ maps: linked end-face ladders
106 -> 56 (the rest are Apparatus end faces that bots climb), matched
curated climbs with up/down links unchanged at 120/120, none lost.
Transit, 4 pinned CTG rounds: 33 ascents, all on the 34-unit face,
all reached the top.
CreateLadder's clearance traces start on the ladder's own face. On a
climbable brush that the generation trace mask treats as solid, every
trace starts in solid, so the bottom moves up until it leaves the
brush. The wide face of a climb brush then loses its ladder or keeps a
stub, and only the narrow end faces remain, which bots fall off. Start
the traces just off the face.

The full-height ladders this restores can top out under a prop or
ceiling, where the top-exit scan starts inside solid and finds no
landing. Retry that scan from the ladder top as well as above it.

From-scratch generation of the 21 ntre_ ladder maps: matched climbs
linked both ways 119 -> 130 of 157, none lost; short ladders 23 -> 0.
Merging grows nav areas without re-adding them to the area grid, so
during generation a grid lookup misses the merged-in part of an area.
Brush ladder top scans now look the landing up in the area list
directly. On 21 ntre_ maps this links Sentinel C1/C2 (CTG and JGR)
both ways; no climb that linked before loses its links.

The wider lookup also finds floors past the far side of a climb, and
snapping the ladder top down to such a floor ends the climb under the
brush top (Dawn/Dusk C1, bots fell off 3 of 3). A brush ladder now drops
a forward exit more than a step below its top.
Replace the brush-ladder bool parameter of CreateLadder,
CommandNavBuildLadder and ConnectGeneratedLadder with a
NavLadderSourceType enum, so call sites read as the ladder source
instead of a bare true. Name the bottom-floor reach and the behind-exit
range, and reword two comments that restated history or code.

No behavior change: nav_generate of Transit, Rogue and Sentinel CTG
with this build matches the previous build's output byte for byte.
@sunzenshen
sunzenshen marked this pull request as ready for review November 7, 2026 16:01
@sunzenshen
sunzenshen requested a review from sunmachine November 7, 2026 16:01
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_ladder.h Resolved
Comment thread src/game/server/nav_ladder.h Resolved
Comment thread src/game/server/nav_mesh.h Resolved
Comment thread src/game/server/nav_mesh.h Resolved
Comment thread src/game/server/nav_edit.cpp Resolved
Comment thread src/game/server/nav_edit.cpp Resolved
Valve SDK files keep their original code under #else, so every NEO
change to them sits behind #ifdef NEO.

Move the brush ladder paths of CreateLadder and ConnectGeneratedLadder
into NEO-only helpers: end clearance and span reject, the bottom area
lookup, and the top area search with its retries. The SDK bodies keep
their lines and call a helper at each hook point. Guard the source
parameter, the area lookup option and the ladder source enum, and
restore blank lines the branch had changed outside the guards.

No behavior change: nav_generate of 8 ntre_ ladder maps (Release) gives
byte-identical navs before and after. Rogue varies under load in both
builds; at 2 wide its six runs are identical.
@sunzenshen
sunzenshen force-pushed the laddergen-hardening-1833 branch from 7ce9bf8 to c24fb28 Compare November 10, 2026 05:29
@AdamTadeusz

Copy link
Copy Markdown
Contributor
image

Does the amount of xp a bot has influence its ability to climb a ladder, or what is this trying to say?

@sunzenshen

sunzenshen commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author
image

Does the amount of xp a bot has influence its ability to climb a ladder, or what is this trying to say?

Oh gosh, that's hilarious but also kind of brain dead. What that is actually trying to test is that bots do not get affected by uneven XP steamrolling in terms of XP ranks. So the harness tests both teams with their XP promotion ranks set equally. Only sanity regression tests do a full 7 round match from start to end. However, that doesn't actually apply to this use case so it ends up testing something that has no effect (climbing ladders is not affected by whether the bot can buy an PZ, and no weapons affect movement, let alone ladders).

The difference in stats between the teams is interesting but probably noise. (I've seen similar levels of noise reported before.)

I still think it's a good consistency test since you might as well collect consistent data points in case some XP level bug comes up, but this awkward language slipping into the report I agree is very confusing.

@AdamTadeusz
AdamTadeusz self-requested a review November 11, 2026 16:37
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_generate.cpp Resolved
Comment thread src/game/server/nav_generate.cpp Resolved

@sunmachine sunmachine left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with @AdamTadeusz on his observations; no notes to add here. This one is dead code as far as I can tell.

Comment thread src/game/server/nav_mesh.cpp Resolved
LadderFromPolyhedron has a single exit that returns true, so the
warning branch in BuildBrushLaddersFromBsp never ran. It also read the
polyhedron after Release(). Make the function void and remove the
branch.
Say what the ladder foot is and why the nearest-area lookup can return
the top landing, and which slot Disconnect() clears when the behind
area was also found by a forward or side scan.
Merging grows the surviving area in place, but the grid kept only the
cells of its original extent, so a grid lookup could miss the merged
part for the rest of generation. Add the area to the cells its new
extent covers in FinishMerge and MergeEdit.

With the grid current, brush ladder generation no longer needs its own
lookup over all areas, so remove it. What is left of the top area
helper is the retry scans, so name it for that.
@sunzenshen
sunzenshen force-pushed the laddergen-hardening-1833 branch from c24fb28 to 52138a3 Compare November 13, 2026 02:08
Keep the blank separator lines after #endif instead of before it, with
the non-NEO text unchanged.
Put the separator lines before #ifdef NEO back where the SDK has them
and keep the ones after #endif.
@sunmachine sunmachine added the Mapping Entities, inputs and outputs. Things that are set up in the world editor label Nov 13, 2026
Comment thread src/game/server/nav_generate.cpp Outdated

#ifdef NEO
//--------------------------------------------------------------------------------------------------------------
static const float LadderEndScanStep = 10.0f;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this is a compile-time constant, so constexpr like GenerationStepSize in nav.h. No change needed if you'd rather leave it.

Comment thread src/game/server/nav_mesh.cpp Outdated
Comment on lines +45 to +49
static auto DrawLine(const Vector& from, const Vector& to, float duration = NDEBUG_PERSIST_TILL_NEXT_SERVER,
int r = 255, int g=255, int b=255)
{
return NDebugOverlay::Line(from, to, r, g, b, true, duration);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This DrawLine honors duration, but the macro it replaces ignored it and always passed NDEBUG_PERSIST_TILL_NEXT_SERVER. The existing DrawLine( ..., 3, ... ) calls in this file (the sniper spot drawing and the two near the ladder edit code) now keep their lines up for 3 seconds instead of one frame. Maybe give the new helper its own name and leave the macro for the old call sites?

The brush ladder debug helper honored its duration and shadowed the
SDK macro, which ignores it, so the existing sniper spot and ladder
edit lines stayed up for 3 seconds. Give the helper its own name.
Also make LadderEndScanStep constexpr.
@AdamTadeusz

Copy link
Copy Markdown
Contributor

I noticed all the ladders on apparatus have two ladder nav things after generation, I don't see the same on bullet's ladders so maybe that's a map quirk, maybe @DESTROYGIRL can tell us more?

image

@DESTROYGIRL

Copy link
Copy Markdown
Contributor

maybe @DESTROYGIRL can tell us more?

Not sure, the ladders do have slanted tops, I'd assume it's that looking at the pic. Rogue also has slanted top ladders so you could test on that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Mapping Entities, inputs and outputs. Things that are set up in the world editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants