Skip to content

Optimization: collision layer with a single body #587

Closed

Description

@parasyte

Each shape in the collision layer gets its own entity and body. This can get fairly heavy with enough shapes on the map. Optimize by squashing all shapes in the collision layer into a single entity/body.

Activity

  1. added this to the milestone on Oct 14, 2014
  2. obiot commented on Oct 15, 2014

    @obiot
    Member

    as I was saying on gitter, as a simple improvements, what about skipping objects with the WORLD_SHAPE type from the container update/draw loop ?

  3. parasyte commented on Oct 15, 2014

    @parasyte
    CollaboratorAuthor

    It's required for me.debug.renderHitBox actually.

  4. modified the milestones: , 2.1.0 on Oct 26, 2014
  5. obiot commented on Oct 30, 2014

    @obiot
    Member

    i was thinking about this, and I'm wondering if it's actually a good idea.

    Considering that the quadtree is a rectangle based algorithm, and therefore relies on shapes bounding box, this could generate collision check with the (one) collision shape at every movement, as if the collision layer is complex there is chance that the bounding box would then take the whole level.

    keeping the current implementation for sure create more shapes, but allow for less collision check per frame ? and I suppose that ultimately the trade off is for the end user to optimize the number of collision shapes he is creating.

    (last but not least, with entities objects not being currently pooled by default, none of these collision shapes are being reused from one level to the other, which keeps the GC busy when changing level)

  6. parasyte commented on Oct 30, 2014

    @parasyte
    CollaboratorAuthor

    Suppose shapes are added to QuadTree instead of entities. This was how I originally envisioned the QuadTree would be used.

    The entity bounds can still be used to lookup candidate collision pairs within the QuadTree. But what you'll get back is individual shapes, instead of an entity who references a body who references all of its shapes.

  7. modified the milestones: , 2.1.0 on Feb 7, 2015
  8. modified the milestones: 3.0.0, on Jul 9, 2015
  9. modified the milestones: 3.0.0, on Jul 26, 2015
  10. 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

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions