Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

GetKeyArray but for NativeMultiHashMap?

Discussion in 'Entity Component System and C# Job system' started by Mr-Mechanical, Feb 10, 2019.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    161
    I've noticed NativeHashMap has a GetKeyArray function but NativeMultiHashMap does not. Any thoughts?

    Thanks. Advice is always appreciated.
     
    Tony_Max likes this.
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,059
    I had a look at why this was the case when they first implemented it to see if I could add it myself and I think it's a technical issue. While I didn't spend that long at the problem I couldn't think of an efficient way of implementing it with how the hash maps are designed. They'll probably come up with something at some point though.
     
    Mr-Mechanical likes this.
  3. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    161
    I'm taking a look at IJobNativeMultiHashMapMergedSharedKeyIndices, but it in my use case I'd like to compare each value with every other value in the same key (2 nested loops). Though, I am not sure this is possible with IJobNativeMultiHashMapMergedSharedKeyIndices since you can only visit each value once with ExecuteFirst and ExecuteNext. I'll have to think about this.
     
  4. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    720
    I never really looked into IJobNativeMultiHashMapMergedSharedKeyIndices.

    What exactly does it do?

    I had a similar usecase and just unrolled it via an ijob. I would love to just be able to reinterprete the values per key as native arrays, without any copying
     
    Mr-Mechanical likes this.
  5. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    161
    I like the idea of a special job type that does exactly as you describe. Currently, we only have
    IJobNativeMultiHashMapVisitKeyValue, which access every value but also has to access the same key multiple times to accomplish this.
    Here's a link to IJobNativeMultiHashMapMergedSharedKeyIndices explanation from Mike Acton's GDC. It's a job type that seems to be mostly specialized towards the Boid sample.