-
Notifications
You must be signed in to change notification settings - Fork 29
Add/Remove entities from systems when when its component bitmask changes #16
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
Add/Remove entities from systems when when its component bitmask changes #16
Conversation
For some reason the Otherwise I have no qualms with your PR, it's a simple solution to the problem. It's possible that some optimizations can be made using some bitset magic. I will give it some thought, but I think this is a great place to start. |
When I have a moment I will try the mingw32/mingw64 tests in MSYS2. |
Just some findings so far: Still not entirely sure why but, figured it was interesting and might help with troubleshooting. |
I tried to replicate the problem in MSYS2 without success. I'll try a few more things tomorrow. The fact that this is happening is very peculiar since the ECS tests for the other platforms run successfully, and all of the other MinGW tests run successfully across all platforms. If it comes down to it, I'll create a new project and do some brute force debugging. |
One thing to consider, it could be a problem with the tests. |
As a sanity check, I'll try running main with no changes tonight, and then the tests without my new test changes. |
Valgrind reveals this:
|
Just looking from my phone, but, that's likely my doing. I assumed ecs_sparse_set_remove was safe to call even if the id didn't exist in the sparse set. From a cursory look, my guess is we probably need to add a bounds check on the sparse set to make sure id is less than capacity. |
I think something very subtle is going on. |
Actually, perhaps I'm wrong. Maybe there is a need to do a bounds check in |
No worries. I added the bounds check and it seems to have completed successfully in my fork. (Still using windows-latest for good measure, not windows-2025) Thanks for running valgrind; I didn't even think of it. |
I was able to do a bit of optimization. Naturally, the changes to |
5ebc695
to
1f2fa81
Compare
1f2fa81
to
feec54f
Compare
I think everything is about ready to go. I would, however, appreciate any comments you have regarding the optimization. It is designed to make the common case fast (i.e. no exclusions). If you agree with the change, I'll merge the PR right away. |
Looks great! All of the negative logic was hurting my brain, but, I think it makes sense. ie. When removing a component, we only need to add an entity to a system if that system could have been excluding the component we just removed. We might get an optimization for the exclude-case by doing something similar: maybe a bitset test on the exclude bits for the component we just removed/added? I'd need to benchmark. |
It might be helpful to think of the |
Figured I'd open this in case its helpful. I shamelessly stole the tests from #11. Feel free to close if you had something else in mind, or if there's something that's better for performance.