How is a shared component hash computed?

am I right to say that two instances of the same shared component with the same value should generate the same hash?

can then assume that
_entityManager.AddSharedComponentData(uecsEntity, new UecsResourceGroup(resourceStruct.resourceID));

would put the entity in the same archetype if the value of resourceID is the same?

(edit: it seems that it created N chunks with 1 entity only each instead :frowning: )
(edit 2: it does seem it’s hashing the content though)

also would you be so kind to explain to me what these numbers mean?

4393321--399451--upload_2019-4-4_17-37-54.png

1 Like

It means you have one chunk that has 1320 chunks with one entity in each
Basically, the vertical axis shows the number of chunks and the horizontal axis number of entities in a chunk.
Here is a detailed explenation:

https://www.youtube.com/watch?v=0y05nw5zET0

1 Like

It’s a hash of the struct I believe, same way as how C# can differentiate two different struct’s content.

As for your second question ( somebody correct me if I’m wrong ):
4393573--399463--upload_2019-4-4_19-8-35.png

A quick tldr explanation is: The further your bar goes to the right and up, the better.

As for detailed explanation:
Top right number 16 ( marked in yellow ): total amount of chunks used ( I got around 5,000 entities in this one )
Vertical axis : Amount of chunks ( You can see max on that vertical axis is 12, and we have 4 other 1-sized bars, all together makes 16 )
Horizontal axis / Chunk utilization: How much entities make use of that chunk space. You can see small bars in the middle in my scenario, that’s because I have a simple int sharedcomponentdata I use for filtering my entities and those ones don’t have that many entities inside, thus they only use 1 chunk but they employ the chunk space quite efficiently.

4393573--399463--upload_2019-4-4_19-8-35.png

1 Like

thank you, that means I was right, I don’t understand then why it’s creating N chunks when I create N entities with the same shared component values.

Entities with ISharedComponentData that have the same value will be grouped together in the same chunks. The important thing to understand about this is that when entities have more than one SharedComponentData, the requirement is now two-fold - they must match both SharedComponentData in order to be placed in the same chunks.

If you are seeing 1320 chunks with 1 entity, then either the values of resourceID are different or there is another SharedComponentData on the entity which is different causing the error.

If you’re interested in how they are being hashed, check out the GetHashCode function in FastEquality.cs (in the Entities package).

thanks, I have seen the code, that’s why I can’t figure out why they are split in different chunks. It’s true, there are multiple shared components, but these are just two

4393744--399499--upload_2019-4-4_19-7-26.png

Mine, which currently can have just two values (UecsResourceGroup)
the RenderMesh, which can have two values as well (they map UecsResourceGroup)

I don’t think any other component is a SharedMesh, however this is how I set a shared component:

_entityManager.AddSharedComponentData(uecsEntity, new UecsResourceGroup(resourceStruct.resourceID));

meaning that I do a new everytime, although it’s a struct and with the same values (can be either 0 or 1 atm)

at the same time I do the setfilter like this

_group.SetFilter(new UecsResourceGroup(resourceStructResourceId));

the Setfilter works fine.

Note that I use _entityManager.Instantiate(originalEntity) to create each new entity. originalEntity can be only two values

@AriaBonczek what do you think about this?

No joy? Do you need more info to investigate my problem or I misunderstood something?

It’s difficult to tell what the problem could be without a repro project. If you’re comfortable uploading one, I can take a quick look!

OK I will at some point

1 Like