beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
190 stars 97 forks source link

Optimization request for Sim::Unit::UpdateWeaponVectors #1408

Open 6AKU66 opened 4 months ago

6AKU66 commented 4 months ago

Right now UpdateWeaponVectors consume measurable amount of CPU when units are not in fight, here what can be done:

  1. Use for_mt_chunk in void CUnit::UpdateWeaponVectors(). Sometimes like this.
for_mt_chunk(0, activeUnits.size(), [&](const int idx) {
auto unit = activeUnits[idx];
unit->UpdateWeaponVectors();
  1. Add two checks to void CUnit::UpdateWeaponVectors()

script->HaveAnimations() And another check that checking if unit changed own position.