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

Memoize Y-offset for pawn rendering #3523

Merged
merged 1 commit into from
Nov 4, 2024
Merged

Conversation

mszabo-wikia
Copy link
Contributor

Changes

Matrix4x4.rotation and Quaternion.eulerAngles are, somewhat confusingly, not fields but relatively costly property accessors. When rendering many pawns, repeated calls to them can have a measurable impact, so store the result in a local variable and reuse it.

Reasoning

This cuts the overhead of our pawn rendering patch by half. Impact on the overall game performance would depend on how many pawns are being rendered in the viewport, but when profiling a 10k point tribal raid, it went from ~2.22% to ~1.23%.

Testing

  • Compiles without warnings
  • Game runs without errors
  • Playtested a colony -- compared the rendering of a 10k point tribal raid.

Matrix4x4.rotation and Quaternion.eulerAngles are, somewhat confusingly,
not fields but relatively costly property accessors. When rendering many
pawns, repeated calls to them can have a measurable impact, so store the
result in a local variable and reuse it.
@mszabo-wikia mszabo-wikia requested review from a team as code owners October 30, 2024 21:41
@mszabo-wikia
Copy link
Contributor Author

Test save:
pawn.rws.zip

Copy link

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-11602103254.zip

@github-actions github-actions bot added the Download in Comments This PR has a zipfile download available. label Oct 30, 2024
Copy link
Contributor

@N7Huntsman N7Huntsman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Dub's PA with a 10k (non-hostile) tribal raid milling on the map, I'm seeing an improvement on Pawn Renderer of about ~0.1 ms.

@N7Huntsman N7Huntsman merged commit 08bcf98 into Development Nov 4, 2024
3 checks passed
@N7Huntsman N7Huntsman deleted the minor-render-opt branch November 4, 2024 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Download in Comments This PR has a zipfile download available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants