beyond-all-reason / beyond-all-reason/RecoilEngine

Optimization request for Sim::Unit::UpdateWeaponVectors

Open
#1,408 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.