Comments (3)
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.
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.
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)
- How to query a entity by a component value, not component type? HOT 1
- Is there any way to add multiple tracking options to component except #[track(All)]? HOT 4
- Workload scheduling re-evaluation
- How to get+modify a component on one entity? HOT 5
- How to make certain systems always run first? HOT 8
- Help me some lifetime issue.. HOT 3
- Can I run some systems in parallel if UniqueViewMut is thread-safe? HOT 2
- Create a way to easily derive the Label trait HOT 1
- AtomicU64 is not available on 32-bit platforms HOT 6
- Component iteration without modification tracking HOT 2
- Tracking compiles but panics on run HOT 6
- Potential memory leak HOT 2
- Cannot create Unique component with non-sync wgpu properties in WASM demo HOT 4
- Can I get all of the components of the entity? HOT 2
- Better error message for boxed traits in components HOT 1
- Tracking flag error HOT 1
- How to use generic ViewMut with_id? HOT 1
- Potentially useful pattern for working with complex state machines with shipyard ECS HOT 1
- How does the current field in ViewMut struct change? What's the flow?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shipyard.