CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.08k stars 4.1k forks source link

Better cache vehicle mass center #66172

Closed SurFlurer closed 1 year ago

SurFlurer commented 1 year ago

Is your feature request related to a problem? Please describe.

map::vehmove() has to call vehicle::calc_mass_center() multiple times in a turn. This results in around 20% of total overhead for driving large deathmobiles. It seems that the code already handles some cache of the mass center. However, it is clearly not particularly good at reducing overhead.

image

image

Solution you would like.

Have a better cache of the mass center. This change can hopefully save 75% of this function's overhead per turn.

Maybe we should add a set of different functions to "cheaply" handle mass changes caused by fuel drain?

Describe alternatives you have considered.

No response

Additional context

This is somewhat meaningful to finish this to smooth the transition towards the removal of charge from solid comestibles.

SurFlurer commented 1 year ago

Now what's left to do is to add a fast way to recalc mass center for every-turn consumption of fuel.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.