GithubHelp home page GithubHelp logo

Comments (5)

jagoly avatar jagoly commented on September 26, 2024

Actually, I just noticed that RigidBody actually already does this, I misread the documentation. Sorry! However, it certainly does still apply to Collision / Dynamics World, Bodies and Joints, perhaps being more important as it would help with consistency.

from reactphysics3d.

DanielChappuis avatar DanielChappuis commented on September 26, 2024

Yes, you are right. A body or a joint cannot outlive the World in which they have been added. However, they life can be shorter. A user should be able to call the destroyBody() or destroyJoint() methods if he wants to remove a body or a joint from the world before the end of the application for instance (for optimization because the object is not visible anymore, etc). Therefore, we need to keep those two methods to manually remove a body or a joint from the world.

I agree with you, the world destructor should be smarter. I propose to change the CollisionWorld and DynamicsWorld destructors so that they call the destroyBody() or destroyJoint() methods on every bodies or joints that have not been removed from the World yet.

It means that the user will still be able to manually remove a body (or joint) but if he doesn't, the World destructor will remove it automatically at the end.

from reactphysics3d.

jagoly avatar jagoly commented on September 26, 2024

Yes, that is exactly what I meant. Of course we still need to keep the destroy methods, for that reason. Splendid! :)

from reactphysics3d.

DanielChappuis avatar DanielChappuis commented on September 26, 2024

OK perfect. I will take care of this for the next release. Thanks a lot for reporting this.

from reactphysics3d.

DanielChappuis avatar DanielChappuis commented on September 26, 2024

I have implemented this in the commit 345afc1 in the develop branch.

This will be available in the next release of the library.

from reactphysics3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.