Skip to content
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

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

Open
kungfooman opened this issue Oct 1, 2024 · 0 comments
Open

Comments

@kungfooman
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant