Skip to content

World is not cleared properly on demo restarts leading to super lag #210

@kungfooman

Description

@kungfooman

image

You don't clean the world properly, that's why you collect subsystems and entries in the collision matrix etc.

However, you can easily add a method in World:

    clear() {
        const {bodies, constraints, solver, collisionMatrix, subsystems} = this;
        // Remove current bodies
        while (bodies.length) {
            this.removeBody(bodies.pop());
        }
        // Remove all constraints
        while (constraints.length) {
            this.removeConstraint(constraints[0]);
        }
        solver.removeAllEquations();
        collisionMatrix.matrix.length = 0;
        subsystems.length = 0;
    }

If this project weren't dead and written in JavaScript, I would have made a PR, but I just want to inform others about this leaky code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions