beyond-all-reason / beyond-all-reason/RecoilEngine
Optimization request for Sim::Unit::UpdateWeaponVectors
- Dominant language
- C++
- Stars
- 683
- Forks
- 293
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 40
Description
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();
```
2. Add two checks to `void CUnit::UpdateWeaponVectors()`
`script->HaveAnimations()`
And another check that checking if unit changed own position.
Contributor guide
Research direction
Start at CUnit::UpdateWeaponVectors() and the activeUnits call site shown in the issue. Trace how weapon vectors are updated for units outside combat, then verify that the requested for_mt_chunk usage and both checks cover the intended idle cases; done means the update avoids unnecessary CPU work without breaking active-unit behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100