beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
199 stars 98 forks source link

Moving units performance bottleneck (MoveType) #231

Closed 6AKU66 closed 2 years ago

6AKU66 commented 2 years ago

https://cdn.discordapp.com/attachments/724924957074915358/944384114449080330/screen00472.jpg (around 1000 moving fleas at same time).

A lot of units moving at same time drive sim down. Ticket made by request Tarnished Knight.

marcushutchings commented 2 years ago

b42e780028885010e354117e8f6610e20deda261 involves additional multi-threading.

marcushutchings commented 2 years ago

The biggest performance hitting area of code for group movement now is with collision detection and resolution. This cannot be multi-threaded because each and every collision triggers a Lua Event where the game code can handle the collision and then pass true back to tell the engine that the collision has been handled and that the engine doens't need to do anything more with that particular collision.

marcushutchings commented 2 years ago

I'll investigate using crowd control, not just collision avoidance, to try and space out the units and better avoid collisions in the first place (obviously some units will want to collide, so we'll still support that.)

marcushutchings commented 2 years ago

After a chat with Ivand and Sprung. We may be able to multi-thread collision. The events involved look like they can be deferred. The return values from UnitUnitCollision and UnitFeatureCollision events look like they can be deprecated.

marcushutchings commented 2 years ago

The process of preparing collisions for multi-threading will give us the opportunity to hopefully resolve https://github.com/beyond-all-reason/spring/issues/15