silver icon indicating copy to clipboard operation
silver copied to clipboard

"ECS-style" Nodes

Open remexre opened this issue 2 years ago • 2 comments

Putting this here as a note -- this is an experiment I wanna try after the deadline.

Instead of storing an array of attributes per-node, we could assign each node an int ID (unique per TopNode, "densely assigned") and give it a pointer to the TopNode, then store a HashMap<AttributeId, Object[]> on the TopNode, where the indices in the arrays are the node IDs.

This feels like it oughta be a quick enough change to try out in a week or so.

remexre avatar Jul 03 '23 23:07 remexre

What does "ECS-style" mean?

Is the goal of this to reduce memory usage? Or performance?

krame505 avatar Jul 03 '23 23:07 krame505

Performance; improved cache locality, mainly.

ECS is a style of OO some games / game engines do as a library, where objects are just int(-sized struct)s (Entities), you store arrays (or some other sparser data structure) of their fields (Components), and you perform computations over them as "for every entity with non-null values for components A, B, and C," which are easy to parallelize and have nice cache usage (Systems).

remexre avatar Jul 03 '23 23:07 remexre