Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch PROJECTILE to use PagedEntityContainer<PROJECTILE> as backing storage #3675

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

ManManson
Copy link
Member

@ManManson ManManson commented Mar 7, 2024

The game still uses psProjectileList to maintain stable and predictable order of iteration for projectiles, but the individual PROJECTILE instances are allocated from the global PagedEntityContainer<PROJECTILE> instance.

Optimize proj_UpdateAll() by removing additional checks inside the tight loop, which enumerates all projectiles currently in play, thus considerably speeding up this frequent and expensive operation.

Brief summary for the performance impact of this PR: on my machine this PR yields ~5-10 FPS improvement in stress-test conditions (e.g. horde of units with Seraph weapons, simultaneously firing lots of projectiles in one direction).

Signed-off-by: Pavel Solodovnikov [email protected]

Better to avoid self-destructing methods that do
`delete this` or similar.

Signed-off-by: Pavel Solodovnikov <[email protected]>
@ManManson ManManson requested review from KJeff01 and past-due March 7, 2024 13:11
@ManManson ManManson added this to the 4.5.0-beta1 milestone Mar 7, 2024
The method translates the address of the argument
to container's page index for the corresponding
element.

Add a couple of asserts in `erase()`

Signed-off-by: Pavel Solodovnikov <[email protected]>
@ManManson ManManson force-pushed the projectile_refactor_v2 branch from dbc938d to fb9bc37 Compare March 7, 2024 15:37
src/projectile.h Outdated Show resolved Hide resolved
@ManManson ManManson force-pushed the projectile_refactor_v2 branch from fb9bc37 to 0e9b459 Compare March 11, 2024 13:38
…ing storage

The game still uses `psProjectileList` to maintain stable and
predictable order of iteration for projectiles, but the
individual `PROJECTILE` instances are allocated from the
global `PagedEntityContainer<PROJECTILE>` instance.

Optimize `proj_UpdateAll()` by removing additional
checks inside the tight loop, which enumerates all
projectiles currently in play, thus considerably
speeding up this frequent and expensive operation.

Signed-off-by: Pavel Solodovnikov <[email protected]>
@ManManson ManManson force-pushed the projectile_refactor_v2 branch from 0e9b459 to 7dc704c Compare March 11, 2024 13:40
@past-due past-due merged commit 232da04 into Warzone2100:master Mar 13, 2024
38 checks passed
@ManManson ManManson deleted the projectile_refactor_v2 branch March 16, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants