Search Unity

chunk.DidChange/DidAddOrChange will never work since it use the current global version

Discussion in 'Entity Component System' started by 5argon, Nov 8, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    ChangedFilter set on ComponentGroup works because it uses a last system number, the system number of the previous update run. And so it can detect chunk changes occured from the last system run to the current run since they will now have a version number higher than the current last system number.

    On the other hand with chunk iteration method, the version number to be compared with chunk's version is captured at GetArchetypeChunkComponentType<T> method. But it captures the current global number, not this system's last version number. Then it is not possible for any previously changed chunk to win over this number since the global number had just been increased right before OnUpdate of the system. It will be 100% higher than any changed chunk's version.

    Am I doing something wrong with the chunk iteration? Is calling GetArchetypeChunkComponentType to get the type on every OnUpdate correct? Possibly if this is a bug, this leads to the TransformSystem problem described here https://forum.unity.com/threads/scale-component-not-being-updated.577477/#post-3860479 since chunk's change version was used all over that file.
     
  2. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
    5argon likes this.
  3. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
    Attached the patch I'm currently using.
     

    Attached Files:

  4. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
    0.0.12-preview.20 fixes this for DidAddOrChange by adding a version parameter but DidChange is still broken. TransformSystem no longer has this issue.
     
  5. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Also whats should go in the new parameter is the newly exposed `LastSystemVersion` protected property of a system.