Closed
Labels
Description
Right now the world container iterates all of its children, then performs a rectangle overlap check to determine whether its in the viewport (thus determining if it should be updated) We can optimize this selection logic by collecting a list of entities potentially within the viewport using the QuadTree. Thereby allowing the container to iterate only a subset of its children (especially on large maps).
Second, the alwaysUpdate children might have to be placed in a separate child-list that is always iterated and updated. This is pretty similar to #191, actually. Which will be a matter of managing child placement within different lists.
Activity
[-]Optimize me.Contianer.update with QuadTree[/-][+]Optimize me.Container.update with QuadTree[/+]obiot commentedon Oct 9, 2014
did we actually properly tested several level of containers with the quadtree ? (i'm wondering how is this working, as so far, 99% of the stuff I saw were not using containers)
parasyte commentedon Feb 7, 2015
Nested Containers now work with QuadTree thanks to @agmcleod in #634
agmcleod commentedon Jun 8, 2015
After learning a bit on quad trees in that issue, going to try and take a crack at this :)
6 remaining items
parasyte commentedon Aug 12, 2015
Translation happens during draw. But yeah, it's kind of the same problems there; we want to iterate only the list of visible items.
agmcleod commentedon Oct 25, 2015
Hmm, i think the other problem is, what if someone uses the container's update, expecting it to work? It's an object you're adding to the scene, therefore it should update. I feel like it would just be unexpected behaviour.
agmcleod commentedon Oct 28, 2015
So i'm starting to back track on getting a list of stuff in the viewport, and updating those. In order to get that list, we will iterate through the children anyways. Why not do that in the update to begin with, and check each one
if (QuadTree.has(rect))invoke the object's update.obiot commentedon Mar 17, 2016
I've been thinking about this one again, especially since we exactly do that for pointer detection, and also since containers are now added into the quadtree.
However, my only worry is on objects with the
alwaysUpdateflag on, as if not in (or overlaping) the container rect, the quadtree most likely won't include them in the list.parasyte commentedon Mar 18, 2016
Good old
alwaysUpdate! What a nightmare. Maybe it's time to start thinking about #396 in the context of updates. I can see a case wherealwaysUpdateobjects get put into their own array for iteration, and everything else uses quadTree. (Work in #396 will be responsible for queueing these special-case objects.)Now to prevent double-updates...