TheSuperHackers / GeneralsGamePatch

Community Patch to fix and improve original Generals Zero Hour 1.04
Other
55 stars 19 forks source link

GLA Toxin Tractor, Toxin Rebel shooting is expensive #654

Open xezon opened 2 years ago

xezon commented 2 years ago

GLA Toxin Tractor projectile stream has 14 segments (MaxSegments = 14). Could potentially be reduced to save performance.

Likely the same issue as

xezon commented 1 year ago

Reducing MaxSegments to 4 looks like this.

shot_20230505_175810_1

ToxinTruckProjectileStream is not cheap. 25 FPS is low this.

Looks ok. Nothing to do here.

shot_20230505_175513_1

shot_20230505_180418_2

xezon commented 1 year ago

Looks like something else is expensive however.

Blob of Quads shooting = 147 FPS

shot_20230505_180747_3

Blob of Tractors shooting = 26 FPS

ToxinTruckProjectileStream is removed.

shot_20230505_180805_4

xezon commented 1 year ago

Also happens with Tox Rebels, using similar kind of weapon.

xezon commented 1 year ago

I suspect the cause of this slowdown is identical to what is slowing #423.

Weapon ToxinTruckGun
  ProjectileObject            = ToxinTruckStreamProjectile
  DelayBetweenShots           = 40
  ...
End

The Toxin Tractor gun, and all other stream guns, spawn a Projectile object every 2 frames, 66 milliseconds. I suspect what makes it so expensive is the overwhelming amount of object spawn and despawn.

I tested this theory by increasing DelayBetweenShots to 120, aka spawn a Projectile object every 4 frames, 133 milliseconds, effectively twice as cheap.

Original, every 2 frames

Performance drops from 370 to 124 FPS

shot_20230623_211022_2

Changed, every 4 frames

Performance drops from 370 to 180 FPS

shot_20230623_211036_3

Conclusion

The theory is proven correct. Reducing the number of spawned objects in the weapon makes it cheaper.