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

Perform world.refresh() automatically and provide API for efficient mass changes #60

Open
LearnCocos2D opened this Issue Oct 21, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@LearnCocos2D

So right now if you don't call refresh() on the world after creating an entity (or presumably after changing one entiy's active status?) the new entity's components aren't processed by the systems.

Furthermore, if you happen to call refresh() without any new entities or changing their active status, then anax effectively stops processing all (!) entities. Meaning the "activated" entities list is empty. At least that second part should - at a minimum - raise an error.

But generally I don't really see the point in having to manually refresh the world except for mass changes / creation of entities. In that light I would prefer a solution that calls refresh automatically by default, and for bulk changes offer a way to do so.

Also: it took me an hour debugging anax to figure out that the world needs refreshing and that this was causing my component systems not updating. I'm sure there'll be others running into this as well.

A common pattern is to temporarily disable automatic updates of the world, only to refresh the world at the end, for instance:

world->beginMassiveWorldManipulation();
// do a lot of stuff here that would make refresh() overhead for each entity rather expensive
world->endMassiveWorldManipulation();

@LearnCocos2D LearnCocos2D changed the title from Perform world.refresh() automatically to Perform world.refresh() automatically and provide API for efficient mass changes Oct 21, 2015

@miguelmartin75

This comment has been minimized.

Show comment
Hide comment
@miguelmartin75

miguelmartin75 Oct 22, 2015

Owner

This is a good idea. Not sure about that huge name though. However, this may cause more issues with #61, but if I implemented my idea I mentioned, I think it would be fine.

Furthermore, if you happen to call refresh() without any new entities or changing their active status, then anax effectively stops processing all (!) entities

I thought I fixed this bug, but apparently not. Maybe I'm confusing this for another bug.

Owner

miguelmartin75 commented Oct 22, 2015

This is a good idea. Not sure about that huge name though. However, this may cause more issues with #61, but if I implemented my idea I mentioned, I think it would be fine.

Furthermore, if you happen to call refresh() without any new entities or changing their active status, then anax effectively stops processing all (!) entities

I thought I fixed this bug, but apparently not. Maybe I'm confusing this for another bug.

@Shokwav

This comment has been minimized.

Show comment
Hide comment
@Shokwav

Shokwav Jun 7, 2016

Any developments on this issue? I've been using this library extensively and have ran into a situation that would benefit from this sort of change. I can do a pull request for this issue if you like

Shokwav commented Jun 7, 2016

Any developments on this issue? I've been using this library extensively and have ran into a situation that would benefit from this sort of change. I can do a pull request for this issue if you like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment