Inserter performance

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

BlackMoon
Inserter
Inserter
Posts: 42
Joined: Wed Aug 06, 2014 7:15 am
Contact:

Inserter performance

Post by BlackMoon »

Hi. I have read that inserters do a lot of trig calculations to figure out how to move, even while off screen.

I propose a optimization.

Instead of doing all the trig/calculations to move the inserter head each frame, you can simple calculate distance from source to target, or difference in inserter 'length' to target and rotation and turn it into a time the inserter should take to move between those points.

Once you have the time, you can slave the animation to the timer, meaning that any offscreen inserter now only has to do 'Timer -= TimeSinceLastFrame * Energy; if (timer < 0)...'
instead of all that trig/calculations to figure out how exactly to move the head. It could be made even faster if energy was factored into the timer when the inserter started but per-frame energy based speed shouldn't be much overhead.

Onscreen, you would calculate what phase the inserter should be in based on the timer and interpolate its length/rotation between its start/stop points of that phase (0 to 10% pickup, 10 to 50% dropoff, 50% to 100% return to start)


Advantages are the majority of inserters in a large factory will be offscreen and much faster to calculate
Downside is the time it takes an inserter to insert into a moving train might not be exactly the same as it is now since it won't take the movement into account.

it would still be the same time across MP and the same regardless if an inserter is onscreen or not.
Post Reply

Return to “Ideas and Suggestions”