Search Unity

  1. Curious about what's going to be in 2021.1? Have a look at the 2021.1 beta blog post.
    Dismiss Notice
  2. The Burst compiler has its own forum section now.
    Dismiss Notice

Some newbie questions on ECS

Discussion in 'Data Oriented Technology Stack' started by TMPxyz, Jul 10, 2019.

  1. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    765
    Hi, I'm trying to use ECS to boost performance on computational intensive algorithm, and here I've some newbie questions:

    Assume I've a big map with a lot of cities which are randomly connected with roads ( a big graph ).
    So each city is an entity, each road is an entity too.

    Code (CSharp):
    1. struct CpCity : IComponentData
    2. {
    3.      float population;
    4. }
    5.  
    6. struct CpRoad : IComponentData
    7. {
    8.      Entity cityA, cityB;
    9.      float cost;
    10. }
    11.  
    12. void ChangeCost(Entity cityA, Entity cityB, float newCost) { ... }
    13.  
    Now I need to write the method to modify the cost of road given two cities.
    Assume there'll be 100+ calls of the method per frame, and there are around 100K roads in total. Is it true that the only way is to use a NativeHashMap< Entity_City_Pair, Entity_Road > in a ComponentSystem?
     
unityunity