Search Unity

Putting linked archetypes closer together

Discussion in 'Entity Component System' started by dCalle, May 24, 2020.

  1. dCalle

    dCalle

    Joined:
    Dec 16, 2013
    Posts:
    55
    Hey, I'm using two Components that work in tandem with each other (ShieldTile and Shieldable) but sit on different Entities.

    Most of the Time, I'm just trying to fetch the Shieldable Data via GetComponent while being in a ShieldTile.ForEach. So my question is, is that alright? is there a better way to do it, or would it, indeed, be nice if we could position those Entities (or their Chunks) in an A-B-A-B order, because fetching that Data would be faster?
     
    Last edited: May 24, 2020
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,270
    I don't know enough about your problem to make a suggestion for optimal data layout. But what exactly would you expect the A-B-A-B data structure to look like?
     
    dCalle likes this.
  3. dCalle

    dCalle

    Joined:
    Dec 16, 2013
    Posts:
    55
    I wouldn't know^^ But I thought since data layout might at least be placed 2 dimensional a column is populated with Entities A and its linked Entities are placed at the next column
     
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,270
    Memory is one-dimensional.
    A chunk is composed of an array of entities, and an array of each component in the archetype, plus metadata, shared component indices, and chunk components.