Jump to content

  • Log In with Google      Sign In   
  • Create Account

Statistic algorithms for ECS


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1   Members   

102
Like
0Likes
Like

Posted 08 May 2014 - 12:42 PM

I have not found a good solution for ECS data structure in termes of cache coherency. Maybe it does not exist, so I am looking for some algorithms that reorder antities or components in memory using some data (may be also statistic data obtaind from the the game real time) to achieve contiguas memory traversing when the systems will travers on entities to accomplish their mission.



#2   Members   

2678
Like
1Likes
Like

Posted 08 May 2014 - 01:42 PM

You could use a pool allocator for each type of component in order to guarantee (mostly) contiguous memory for components of the same type.



#3   Moderators   

21413
Like
7Likes
Like

Posted 08 May 2014 - 03:10 PM

*
POPULAR

Keep in mind that an ECS doesn't have to be implemented in terms of each entity object holding" containers of its components. You can use data-oriented architectures to store the component relationships externally from the actual entity/component objects/classes themselves. It's a little trickier to read, but it works pretty well in my experience.


Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

#4   Senior Moderators   

17831
Like
0Likes
Like

Posted 08 May 2014 - 04:32 PM

Adding to what ApochPiQ said, a lot of ECS systems tend to use the "outboard component" model, where each component is pooled separately, and the entity itself is just a semantic tag (usually an integer handle).

 

That's kind of the idea case for cache coherency - you can have a system, for example, that just iterates over a flat array of position data, and calculates world transforms for each one.


Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]


#5   Members   

1459
Like
0Likes
Like

Posted 10 May 2014 - 04:54 PM

What ApochPiQ and swiftcoder said is exactly how I implemented my ECS. I don't have any caching stats I can point to that prove its better doing it that way, but I can say that it was relatively straightforward to implement, and gives you quite a few interesting advantages.

 

The biggest downside is that it becomes a little more difficult to list all components for a single entity, since each component is stored far away from the others. 


Currently working on an open world survival RPG - For info check out my Development blog: ByteWrangler




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.