Re:Data-oriented design or why you might shoot yourself in t...
by ajuc on Monday June 28, 2021 @10:25AM
(#27662396)
There are tradeofs between regular arrays, sparse arrays and hash maps in ECS - it's very similar in concept to storage hints in relational databases, and similarly to relational databases you can add indexes if needed.
Re:Data-oriented design or why you might shoot yourself in t...
by professoretc on Monday June 28, 2021 @12:04PM
(#27663639)
> They iterate over one hash map in a linear way which is fast, but then they do a bunch of slow lookups like GP is saying.
Usually all but the most simple "systems" will need to access more than one component, which means you have a choice between a) store component data in regular arrays (and potentially waste huge amounts of space if relatively few entities have those components) or b) store component data in some kind of hash table (and then you use cache locality for all but the "primary" component of a system).
In those situations, GP's suggestions are wise.
If you can iterate over arrays in parallel like you say, that's also a good approach.