Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ECS-style" Nodes #765

Open
remexre opened this issue Jul 3, 2023 · 2 comments
Open

"ECS-style" Nodes #765

remexre opened this issue Jul 3, 2023 · 2 comments

Comments

@remexre
Copy link
Member

remexre commented Jul 3, 2023

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.

@krame505
Copy link
Member

krame505 commented Jul 3, 2023

What does "ECS-style" mean?

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

@remexre
Copy link
Member Author

remexre commented Jul 3, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants