-
-
Notifications
You must be signed in to change notification settings - Fork 139
[WIP] Add component-level dirty/changed flags #291
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
base: master
Are you sure you want to change the base?
Conversation
@genaray I'd like to hear your opinion on the implementation, to know if I'm going in the right direction. |
@JoNax97 |
I considered making the change tracker a component, but in order to avoid unexpected structural changes, the user would need to opt-in to the feature at entity creation time. What's your view on that? Additionally, it would make it less performant to check for changed components in queries. The current approach wil allow for skipping whole chunks with a single boolean check |
True, I assume this is the best way of doing it so far. I guess we could merge it then, tests are missing tho :) |
…et for each component in a chunk
The pipeline fails for some reason, not sure why atm . |
…s implementation to row-first (bitset per entity) to allow checking against bitmasks per entity.
…pping non-dirty elements
Updated the PR with most of the support for filtering non-changed entities in queries. For simple cases where we need to iterate over the entity or a single component only, a new enumerator encapsulates all the changed logic while keeping the same performance as before. For more complex cases, a single iterator can't return multiple values in a performant way. I will address those by injecting the new logic directly in the loops. Some methods (like query-based add, set, remove) will not support change filtering, so I've added an assertion to reject such queries. This is to avoid confusion, as otherwise the query will affect more entities than expected. I also added a bunch of new tests, with different combinations of filters. I still have some work to do but the core it's already in place. I'd appreciate any feedback you have |
Looks good so far! :) I really appreciate your work! |
Adds the ability to mark entities as changed on a per-component basis. This can be done manually by calling
entity.MarkChanged<MyComponentType>()
or (coming soon) automatically when a query potentially modifies it.It works by storing a BitSet for each entity inside each chunk.
It's behind a compile-time flag and even when enabled, it should have minimal cpu and memory overhead when unused.
Remaining work: