j135 draw-only geometry overlay (TR_GEO_DEBUG) + global debug-draw switch (TR_DEBUG_DRAW)

This commit is contained in:
2026-09-26 14:29:46 +02:00
parent 3903ec71b4
commit fd34e4ae4a
4 changed files with 438 additions and 7 deletions
+30 -7
View File
@@ -44,6 +44,7 @@ import targeting/enemy_tracker
import targeting/target_selector
import env_report
import vbullet_draw
import geo_overlay
const botJsonPath = currentSourcePath().parentDir / "ModularBot.json"
const DebugVBullets = false
@@ -176,6 +177,19 @@ let VBulletDebugOn = vBulletDebugEnabled()
let VBulletDebugMax = vBulletDebugMaxBullets()
let VBulletDebugGun = resolveGunFilter(getEnv(VBulletDebugGunEnv, ""), GunNames)
## ── global debug-draw switch (TR_DEBUG_DRAW, default ON) ───────────────────
## When 0/false/no/off, every mover is built with `debugGraphics = false` and
## the virtual-bullet overlay is skipped, so nothing but the (independent,
## default-off) TR_GEO_DEBUG geometry overlay is left on screen. When on, every
## per-element knob behaves exactly as before.
let DebugDrawOn = debugDrawEnabled()
## ── geometry overlay (TR_GEO_DEBUG, default OFF) ───────────────────────────
## Draw-only visual aid (see `geo_overlay.nim`): the two bots as the endpoints
## of a circle diameter, each heading line, and each line's intersection points
## with the circle. No decision, movement or gun change.
let GeoDebugOn = geoDebugEnabled()
const
CLR_GUN = "\e[33m" # yellow
CLR_MOVE = "\e[36m" # cyan
@@ -1357,7 +1371,7 @@ method run*(bot: ModularBot) =
of BitBrainId: bot.bitbrain.onResult(fe)
else: discard
if fe.hit: inc bot.virtualHits else: inc bot.virtualMiss
if VBulletDebugOn:
if DebugDrawOn and VBulletDebugOn:
resolvedMarks.add VbResolved(
gunId: gunId, aimX: fe.prediction.x, aimY: fe.prediction.y,
actualX: fe.actualX, actualY: fe.actualY, hit: fe.hit)
@@ -1440,12 +1454,19 @@ method run*(bot: ModularBot) =
setGunTurnRate(normDelta)
# Virtual-bullet overlay (default off). Drawn AFTER selection so the
# default "selected gun only" filter uses this tick's choice.
if VBulletDebugOn:
# Virtual-bullet overlay (default off; suppressed by TR_DEBUG_DRAW=0).
# Drawn AFTER selection so the default "selected gun only" filter uses
# this tick's choice.
if DebugDrawOn and VBulletDebugOn:
discard drawVirtualBullets(bot.tracker, resolvedMarks, selectedGun,
VBulletDebugGun, VBulletDebugMax, GunNames)
# Geometry overlay (TR_GEO_DEBUG, default off). Independent of
# TR_DEBUG_DRAW: this is the one thing left when debug drawing is off.
if GeoDebugOn:
discard drawGeoOverlay(ws.selfX, ws.selfY, ws.selfHeading,
ws.enemyX, ws.enemyY, ws.enemyHeading)
# Emit exactly one config line per tick, at the END of the tick, so the gun
# field reflects the selection made above rather than the previous tick's.
if bot.cfgDirty:
@@ -1490,9 +1511,9 @@ when isMainModule:
bitbrain: initBitBrainGun(),
radar: RadarLockModule(),
meleeRadar: initAdaptiveMeleeRadar(),
mover: TFILModule(debugGraphics: true),
ringMover: TFILRingModule(debugGraphics: true),
strafeMover: StrafeModule(debugGraphics: true),
mover: TFILModule(debugGraphics: DebugDrawOn),
ringMover: TFILRingModule(debugGraphics: DebugDrawOn),
strafeMover: StrafeModule(debugGraphics: DebugDrawOn),
surfMover: initWaveSurfer(),
learnedMover: initLearnedSurfer(),
rammer: initRammer(),
@@ -1512,6 +1533,8 @@ when isMainModule:
vBulletDebugGun: getEnv(VBulletDebugGunEnv, ""),
vBulletDebugMax: VBulletDebugMax,
recordWorldState: RecordWorldState,
geoDebug: GeoDebugOn,
debugDraw: DebugDrawOn,
radarForceSpin: RadarForceSpin,
radarScanLog: RadarScanLog,
radarScanLogPath: RadarScanLogPath,