GithubHelp home page GithubHelp logo

Comments (3)

leudz avatar leudz commented on June 3, 2024 1

As you noticed indices are not always in increasing order. That's because they are re-used when entities are deleted.
For example your first entity had 2 other entities at that index before.

There are no built-in way to get the order you want.
In theory you could kind-of use the timestamp when they are inserted but since they are added in the same system that wouldn't work.

from shipyard.

leudz avatar leudz commented on June 3, 2024 1

My understanding of ECS is that components should be traversed in index order

For the very simple implementation that's true, probably for bit set also but not for sparse set or archetype based ECS.

In shipyard the iteration is based on the order of components in the data array (and dense, they have the same order) of the storage with the least components.
This order depends on insertion and deletion order. In fact when it comes to single storage iteration the index array is not accessed at all.

Like SeokshinSon, you can also sort the storage to force a specific ordering.

from shipyard.

80ROkWOC4j avatar 80ROkWOC4j commented on June 3, 2024

I'm confused about the answer to your question, so I'll ask just to be sure. My understanding of ECS is that components should be traversed in index order. This seems to be the case based on the implementation of Iterator's next() function. And since Shipyard recycles EntityId by gen bit, the EntityId (gen bit + index) will not always be incremented sequentially, but as long as no Entity deletion occurs, the iterator will increment sequentially, i.e. it will eventually iterate in the order they are in memory (in order of EntityId's index bit)?

from shipyard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.