3 ms·
> In fact my example demonstrates ... loop over only what you care about without doing extraneous work, by iterating over a contiguous chunk of exactly what you
by fenomas 8y ago
> In fact my example demonstrates ... loop over only what you care about without doing extraneous work, by iterating over a contiguous chunk of exactly what you need to update.
Your example demonstrated iterating over a filtered list instead of an unfiltered list. The "contiguous chunks of data" benefit of ECS refers to how the underlying data is stored in memory, not to which data you iterate over (and both of those are orthogonal to types/polymorphism).
- reificator 8y agoMy goal here is not to argue, I don't think we disagree on this concept. I should have more carefully considered how my starting words would be interpreted, based on your replies I fear they came off more pointed than I intended in my sleep-addled state. I did not mean to start off by putting you on the defensive. > Your example demonstrated iterating over a filtered list instead of an unfiltered list. The "contiguous chunks of data" benefit of ECS refers to how the underlying data is stored in memory, not to which data you iterate over I apologize if this came across unclearly, but that's why I started with a block of comments explaining my fictional example ECS system. I did specifically call out that I was retrieving the backing array for the positions component, implying that components were flat arrays in a dictionary where the key was the component type. I hope we can agree that an array should be expected to be a contiguous chunk of memory when giving a quick example on the internet. The relevant part of my previous code example: // This can vary greatly based on implementation // I'm going to go with an option that reads easily // This should just give back the list of components, which we'll say is an array. // Lookup time in this fictional system is the cost of a dictionary lookup. var positions = world.getComponents('position'); Perhaps I should have been more clear that I meant looking up a pointer to the positions array would cost a dictionary lookup. > (and both of those are orthogonal to types/polymorphism) I probably should have given an example in a language other than Javascript, since it's not statically typed.