ProwlEngine / Prowl

An Open Source C# 3D Game Engine under MIT license, inspired by Unity and featuring a complete editor and built on Silk.NET
MIT License
328 stars 27 forks source link

[Engine] Reduce the overhead of GameObjects #89

Closed michaelsakharov closed 8 months ago

michaelsakharov commented 8 months ago

Right now a GameObject is pretty slow. Every time it moves/updates it regenerates and caches ALL its settings, and there are a lot, This results in

  1. Transform manipulations are expensive since they trigger a full GameObject.Recalculate() Which does a ton of heavy math work
  2. Heavy on memory since all variables exist in memory and theres like 120+ bytes for 1 gameobject JUST for its transform data, That is a big overhead for something so vital to the engine

First, I would like to separate the Transform component and make it optional on game objects. This is already huge since almost 100% of a game object's overhead is the Transform, without it, it's just Tags, Layers, Hideflag, and name. Second, I want to switch things like 'Forward' out to be properties calculated on the spot, the end user can cache them for the frame if it's a performance bottleneck, This makes game objects super lightweight.

michaelsakharov commented 8 months ago

This is mostly solved now by making Transforms Optional. I have also reduced the overhead of Transforms quite a bit, it could be optimized further but its pretty good for now, if it becomes an issue in the future we can come back to this.

PaperPrototype commented 8 months ago

Yay