Skip to content

Optimize me.Container.update with QuadTree #581

Closed

Description

@parasyte

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

  1. changed the title [-]Optimize me.Contianer.update with QuadTree[/-] [+]Optimize me.Container.update with QuadTree[/+] on Oct 9, 2014
  2. added this to the milestone on Oct 9, 2014
  3. obiot commented on Oct 9, 2014

    @obiot
    Member

    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)

  4. modified the milestones: , 2.1.0 on Oct 26, 2014
  5. modified the milestones: , 2.1.0 on Feb 7, 2015
  6. parasyte commented on Feb 7, 2015

    @parasyte
    CollaboratorAuthor

    Nested Containers now work with QuadTree thanks to @agmcleod in #634

  7. self-assigned this
    on Jun 8, 2015
  8. agmcleod commented on Jun 8, 2015

    @agmcleod
    Collaborator

    After learning a bit on quad trees in that issue, going to try and take a crack at this :)

  9. modified the milestones: , 3.0.0 on Jul 26, 2015
  10. 6 remaining items

  11. parasyte commented on Aug 12, 2015

    @parasyte
    CollaboratorAuthor

    Translation happens during draw. But yeah, it's kind of the same problems there; we want to iterate only the list of visible items.

  12. agmcleod commented on Oct 25, 2015

    @agmcleod
    Collaborator

    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.

  13. modified the milestones: 3.1.0, 3.0.0 on Oct 27, 2015
  14. agmcleod commented on Oct 28, 2015

    @agmcleod
    Collaborator

    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.

  15. obiot commented on Mar 17, 2016

    @obiot
    Member

    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 alwaysUpdate flag on, as if not in (or overlaping) the container rect, the quadtree most likely won't include them in the list.

  16. parasyte commented on Mar 18, 2016

    @parasyte
    CollaboratorAuthor

    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 where alwaysUpdate objects 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...

  17. modified the milestones: 4.0.0, 3.1.0 on Apr 7, 2016
  18. modified the milestones: 4.1.0, 4.0.0 on Sep 15, 2016
  19. modified the milestones: , 4.1.0 on Jan 18, 2017
  20. locked and limited conversation to collaborators on Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions