Skyline Game Engine Store uses cookies to store certain information to make your site visit more enjoyable. By proceeding to use the store, you are agreeing to the use of cookies.

Development Blog - Upgrading the SceneEntity Array and External Scripts

Posted by SolarPortal 23/01/2018 0 Comment(s)

Hey all, This blog update is about the overhaul of the sceneEntity to now using a highly efficient object pool and the upgrade of the external script to the form of an action like the microscript.

Q) What is an object pool?

An Object pool is a manager class for the creation and deletion of another item class(such as our sceneEntity). An effecient object pool will store the already used slots and fill them up before allocating any new slots and increasing object counts. An object pool is the heart of many game engines as you cannot create an object or entity in our case with all the necessary game framework hooks without them and delete them safely and cleanly.

Lets start with the sceneEntity array. Many of you are familiar with the entity count limits on the free version and the commercial version and the annoying limit you will hit that makes the engine back out for no reason apart from no more array space.

For those who don't then below is the count.

  • Free Version : 1000 sceneEntities
  • Commercial Version : 4000 sceneEntities

The reason we couldn't place too many in the scene was because the sceneEntity count at 4000 entities uses up around 200- 250mb of PC memory, so 10000 sceneEntities will use upwards/upto of 1gig of ram. This is not very useful at all so we have invested time in creating our own object pool that creates a very effiecient management of sceneEntities and of course uses far less ram and reusues empty spaces to stop the counter from going as high, so essentially you only pay for what you use.

The problem before was on the engine initialization; all 4000 sceneEntities were filled with default data from the get go which was like having 4000 sceneEntities in the scene whether they were shown / used or not lol. The benefit of this system though meant that is was easy to create entities and very easy deletion as it simply cleared the data out and reset defaults, but no ram would have been cleared.

We have now changed this system to not create any sceneEntities at engine initialization and only create when something is added to the scene or spawned using the new & delete operators in c++. Back when we first implemented our array 5+ years ago, we did not have the same coding experience as we do today and we know many more efficient methods of programming. Anyway, using this system only takes up 0.1mb - 0.5mb of ram at the start compared to the 200mb-250mb of memory. Here comes the other cool fact with this change though, Skyline is capable of using up to 10000000 ( 10 million ) sceneEntities in the scene which i would call unlimited in any scene lol :P This can also be lowered or increased at any point without affecting scenes.

This all leads on to the next factor which is the External Scripts. We have decided to change them from being an entity type to an action to match the microscript which makes it much easier to make changes & additions in code and to also allow expansion to new systems such as c#. The main real reason for the change though is due to deletion of sceneEntities from inside lua scripts which are running from the sceneEntity root, whereas the microscript holds a references version inside the action which is cleaned up efficiently. When deleting the sceneEntity from an external script, it backs out and deletes the parent holding the lua as a pointer and coincidentally has no back access after the command is completed and obviously crashes bad in any function. This is only happening now because sceneEntities are created when required and deleted from memory when not needed anymore or the end user chooses to delete them.

Of course we will be building the upgrader to turn your already added external scripts and convert them to the action still containing the file used and any dynamic property data required. This will seem as nothing has changed to you and you won't require to make any changes to your work at all apart from having to upgrade your presets on drag to the scene or right clicking in the asset manager.

When the job is completed, i shall write a new blog, but i wanted to update you on the changes i am currently making in the development of skyline.

In the next post, i may even release the code in c++ for the object pool we are now using. :)

Leave a Comment