#Filtering buffer elements by using hash maps

1 messages · Page 1 of 1 (latest)

muted kayak
#

I have a buffer of elements that can be divided by groups. Some systems needs to operate only on specific type of those element. Is using NativeMultiHashMap inside a separate component would benefit me?

I'm collecting collisions from sides of the character and storing them in buffer. Systems, like grounding needs to operate on bottom part. In my case I believe linear search would not make such performance impact, but I wonder, how to approach making lookup in Unity ECS.

If lookup is not a great option, I believe I can do some tricks. Like collecting collisions in order (0-4 for top, 5-9 for right side,etc.) and then make range based iteration when I need.

Can someone discuss it with me?

analog plaza
#

I have a whole range of collections that override dynamic buffer to work has dictionaries etc

#

Means you don't need to worry about memory management and safety issues of native containers

muted kayak
#

As I can see you using DynamicBuffer<byte> underneath, so that means you hold data in type erased format. I'm just curious, is there any bottlenecks with this?

I was thinking in more of DOD approach, where you have array of contagious data and hashmap with key (enum for example) value (array of indices to contagious data).

analog plaza
#

it just reinterprets to the type you actually use

#

it's as fast as the native versions

#

the downsides are really just, a tiny bit of boilerplate overheead as you have to
remember to call Initialize in the baker baker.AddBuffer<T>(entity).Intialize()
and call AsMap() before you use it buffer.AsMap()
apart from that the only other real drawback is no parallel support

short matrix
#

Also no remapping of Entity fields inside the DynamicHashMap as no type info for unity

devout fog
#

The implementation from Latios Framework can remap entity fields.

analog plaza
#

requires rebuilding after baking but yes