Skip to content

Instantly share code, notes, and snippets.

@amcgregor
Last active July 28, 2020 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amcgregor/647094c4faf40d8c3b8ba30485dcf9ae to your computer and use it in GitHub Desktop.
Save amcgregor/647094c4faf40d8c3b8ba30485dcf9ae to your computer and use it in GitHub Desktop.

Performance Bottlenecks

I've played a lot of Rimworld, for a long time (since early alphas), and certain specific things have remained as a noticeable, impactful burden on the game engine.

Roof Bit Map Updates

From the chunk of Base-64 encoded data in the save file, and the absolutely atrocious performance, I'm guessing the overhead roof tile state is stored in a packed C structure. Access of indexed tiles within this packed structure is expensive, and updating it even more so. The game begins to noticeably take large fractions of a full second per tile update, and when you've got an army of pawns working away, it stutters and stops and rushes forwards, and seemingly stops again, before going, for quite some time. It's dramatic, and roof construction/deconstruction is the single largest in-game performance impactor I encounter, by frequency.

See the video at the end.

Roof Strain Calculations

A subset of this is the calculation of which roof tiles are in danger of collapse. This does not seem to be pre-calculated, but calculated on each roof tile update. By gum, this has a negative impact, and through optimizations, leads to curious possibilities, such as infinite spans supported by one anchor point:

If you're crafty, you can construct large halls of overhead doom to crush your enemies with, activated by eliminating a single wall or ceiling tile from the safety of the inside of your base, but this absolutely has no basis in physics, and the six-tile-from-support restriction is implemented… clearly incorrectly. Not quite in the spirit of what it's actually trying to represent.

Explosion Effect Calculations

It's absolutely beautiful to watch a very large explosion flow like liquid through openings and around corners. But damn, it can chug if there are pawns with many limbs and organs in the path of destruction. Damage is applied and calculated against everything. What gets shredded? What's outright destroyed or blown off? What's burnt? Burning is the worst, see the next section. This makes each pawn have a supra-linear impact on the overall calculation. Watching a Antigrain warhead trap detonate in a carefully crafted killbox is a joy…

Lingering Effect Caclulations

The lingering wounds as a result of any explosion, but especially explosions as they generate so many, result in catastrophic slow-down in the aftermath.

Video Demonstration

https://vimeo.com/gothalice/rimworld-112654-mac-performance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment