Skip to content

Conversation

@avezey-ci
Copy link

Summary

  • Added a bounded, staggered collision lookahead for strafing aircraft: only every 8 frames per unit and with a tight radius (80–160 elmos scaled by turn radius/speed). Still gated by collide, so we keep light anticipatory avoidance without the previous mass quad-field scans. (rts/Sim/MoveTypes/StrafeAirMoveType.cpp)
  • Let AAirMoveType::CheckForCollision accept a radius so callers can choose cheaper probes without affecting hover aircraft defaults. (rts/Sim/MoveTypes/AAirMoveType.{h,cpp})
  • Rationale: preserves a minimal lookahead (better than removing it) while avoiding the unbounded O(n²) load when large fighter groups receive move/attack orders.

Testing

  • ✅ docker-build-v2/build.sh linux -DBUILD_spring-headless=OFF -DBUILD_spring-dedicated=OFF (ghcr.io/beyond-all-reason/recoil-build-amd64-linux:latest) — build succeeds; only compiler warnings.

@avezey-ci
Copy link
Author

avezey-ci commented Dec 15, 2025

Context and rationale: - Large fighter blobs issuing mass move/attack orders were causing O(n^2)-like spikes from CStrafeAirMoveType repeatedly calling AAirMoveType::CheckForCollision with a 200 elmo radius every 4 frames per unit. The results were discarded (�voidCollision was always false), so the heavy quad-field scans provided no steering benefit while hammering perf.

What changed: - CheckForCollision now accepts an optional radius, enabling callers to choose a tighter, cheaper probe without touching other air move types. - StrafeAir lookahead is now bounded and staggered: only every 8 frames per unit, and radius clamped to 80–160 elmos scaled by turn radius/speed, still gated by collide. This preserves a minimal anticipatory check (better than removing it) while avoiding the prior unbounded work in big swarms.

Why this is preferable to removing the scan entirely:- Keeps gentle preemptive avoidance for fast movers (fewer rubber-band corrections) but caps both frequency and search radius so it scales in large groups.

Testing:- Docker build: docker-build-v2/build.sh linux -DBUILD_spring-headless=OFF -DBUILD_spring-dedicated=OFF (ghcr.io/beyond-all-reason/recoil-build-amd64-linux:latest) passed; only compiler warnings.

@sprunk
Copy link
Collaborator

sprunk commented Dec 16, 2025

Throttle strafing air lookahead

it's already "throttled", all this actually does is tweak numerical values

The results were discarded (avoidCollision was always false), so the heavy quad-field scans provided no steering benefit while hammering perf

this is still the case with this PR, but also you mention fighter screens in the context/rationale which tend to have collide=false so don't even run a scan in the first place.

only every 8 frames per unit and with a tight radius (80–160 elmos scaled by turn radius/speed)

reducing values is going to make collision avoidance worse

moveType->turnRadius * std::max(speedNorm, 0.5f)

where is this formula from?

avoiding the unbounded O(n²) load

all you did was tweak numerical constants. it's still O(n²)

Testing
build succeeds; only compiler warnings.

there better be perf measurements if we're going to make behaviour worse, and manual testing for whether the new values introduce bad edge cases in existing games.

@avezey-ci
Copy link
Author

The original tweak was a constant‑factor perf guard: strafers were still calling CheckForCollision every 4 frames with a 200 radius even though avoidCollision was off, so the scan results were thrown away. I tightened radius and frequency to cut that wasted work without touching other air move types or deleting the hook, in case we ever re-enable avoidance. After your point that the scans remained unused and still O(n²), I’ve now removed the strafing lookahead calls entirely. Behavior is unchanged (avoidance still off), and we stop paying for unused quad scans. If we decide to revive avoidance later, we’ll reintroduce it with measured perf/behavior data.

I am working on changes with actual perf results and will add those next.

@sprunk
Copy link
Collaborator

sprunk commented Dec 16, 2025

After your point that the scans remained unused and still O(n²), I’ve now removed the strafing lookahead calls entirely.

i didn't say it remains unused, i said it remains O(n²). i don't know if it's completely unused but your OP claims it does something after all, in which case removal is incorrect. either way it would be best to fix collisions, since any game interested in saving perf can turn them off anyway.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants