branchrust_reboot/main/autoturret_optimcancel
37 Commits over 30 Days - 0.05cph!
Bugfix: NRE during initialization of turrets without RCEyes set
Tests: spawned sentry.scientist.static(no RCEyes) and autoturret_deployed(with) - no NREs and still can control and shoot from autoturret_deployed
Bugfix: unbork shooting from RC turrets
- Recalculate where RC eyes are on the server
Tests: remoted into a turret and shot in different directions - saw hits where expected
Update: Rewrite how we rotate turrets on server
- Where possible, yaw and pitch rotations are merged, saving us on math (0.32ms)
- Other cases are calculated separately (0.51ms, still faster than original 1.32ms)
Updating of separate bones was fast but wrong in my last commit. This version corrects it while also being faster than pre-borked-optim.
Tests: On Craggy, spawned sentry.scientist.static and autoturret_deployed, made them rotate to different directions - they were able to track and shoot me.
Update: AutoTurretTests.MeasureServerTick now checks merged and separate yaw-pitch bones
Since separated bone transformations take more math, need to profile how big of an impact it'll be.
Tests: ran the test
Bugfix: NPCAutoTurret now shoots when it's facing the target
Caused by not implementing the same optimization as AutoTurret (while NPCAutoTurret depends on it).
Tests: spawned `sentry.scientist.static` on craggy and became hostile to it - was shot within the whole 360 arc
Update: AutoTurret.ProcessInterferenceQueue - remove last float time calc
Think all server-side logic has been ammended
Tests: builds in editor C+S
Update: AutoTurret.nextAmmoCheckTime -> double
Tests: builds in editor C+S
Update: AutoTurret.nextForcedAimTime -> double
Tests: builds in editor C+S
Update: AutoTurret.nextShotTime -> double
Tests: editor builds C+S
Update: AutoTurret.nextIdleAimTime -> double
Tests: editor builds C+S
Clean: delete AutoTurret.lastShotTime
Was never set, and the code that depended on it had to do extra calcs, only to discard results.
Tests: editor builds C+S
Update: AutoTurret.nextVisCheck -> double
Tests: editor builds C+S
Update: AutoTurret.lastDamageEventTime -> double
Tests: editor builds C+S
Update: AutoTurret.lastTargetSeenTime -> double
Tests: editor builds C+S
Update: AutoTurret.lastScanTime -> double
Tests: builds in editor C+S
Update: make turret scan const a servervar
- called `sentry.scantimer`, default to 1s
Tests: standing in front, sneak damage, flying from far, depower-power turret - it finds a target & shoots
Merge: from main
Tests: none, no conflicts
Bugfix: AutoTurret no longer misses players moving it's it's FOV
- Done by running scans every second when not tracking any targets
Tests: walked into turret's FOV from behind. checked turret still shoots when powered up with non-auth player in front.
Bugfix: powering up auto-turret now runs a search
- Simplify and clean authDirty-related code
One of previous bugfixes mucked this up by allowing authDirty to desync. There's still a case that's possible, so one more fix needed.
Tests: powered up the turret by standing in front of it - it started shooting correctly
Bugfix: prevent turret snapping to a hostile outside of the default firing arc when powering up
Tests: while hostile, depowered turret, got behind it and powered it up - it didn't snap on me until I shot it again
Bugfix: reset turret's cached visibility when unsetting the target
This could cause the turret to think it doesn't have a target, yet has a visible target(unpowering the turret would cause this, for example). It prevents damage reaction.
Tests: while the turret was aiming at me, disabled io power cheat. re-enabled - now responds to shots. Spotted another bug though
Bugfix: turret will respond to sneak attacks
- takes 3 seconds to drop aggro that forces aiming
Spotted another bug - target and targetVisible can desync
Tests: spawned a turret, snuck behind, powered up, shot at it - it rotated
Optim: avoid requiring position from a transform in AutoTurret.ServerTick
Minor change, but should be helpful either way
Tests: none, trivial change
Merge: from main
Tests: editor builds
Clean: remove unused Transform param on AutoTurret.FireAttachedGun
Tests: editor builds
Bugfix: AutoTurret now shoots in all directions
Tests: gun turret with deauth
Clean: simplify code
Tests: gun turret being deauthed
Bugfix: AutoTurret now correctly detects player in front of it
Still need to fix shooting code.
Tests: gun turret on craggy being deauthed
Update: AutoTurret - rewrite rotations via matrices instead of TRS
- Delete all TRS related stuff (turns out you can't do non-uniform scaling with it :/)
- Incorporate transform hierarchy up to gun_yaw
This should be slower, but different PC - will re-bench once home
Tests: spaend a turret and caused it to rotate different ways
Optim: AutoTurret - virtualize part of transform hierarchy on server
- Breaks dependent logic - will update next
This saves 75% of time in synth test of updating aiming of 1k turrets (1.29ms -> 0.32ms)
Tests: perf test + debug rendering
Tests: PerfTest for AutoTurret.UpdateAiming
Hacking AutoTurret's code, it suggest we can shrink this by 85%
Tests: ran the perf test