Code Monkey home page Code Monkey logo

Comments (3)

louis-langholtz avatar louis-langholtz commented on May 24, 2024

Hi LoneBoco. Thank you for raising the issue. I agree with what you’re saying. I’d started work on this a while back actually. I haven’t had the time however to finish reorganizing things though.

from playrho.

louis-langholtz avatar louis-langholtz commented on May 24, 2024

I just realized that I may have partly overlooked what you wrote in terms of my previous response.

Using a Body with a World

As far as I can tell, there is no way to acquire a non-const Body

Any of the following should work to acquire a non-const Body:

#include <PlayRho/PlayRho.hpp>

int main()
{
    static auto bodyWithStaticStorageDuration = playrho::d2::Body{};
    auto bodyWithAutomaticStorageDuration = playrho::d2::Body{};
    auto* bodyWithDynamicStorageDuration = new playrho::d2::Body{};
}

Do none of these work for you?

Is the confusion with relating a Body instance with a World instance? Things are different in this regard from Box2D as PlayRho is more value semantic oriented. This was also something that did seem like an issue to me in the pre-2.0 code interfaces which I've changed in the current master branch code.

For example...

In the release-1.1 branch code, a World instance takes a BodyConf to create a body while it takes a Body to override the current state of a created body. I.e. there's these two functions which are asymmetric in this regard:

  • BodyID World::CreateBody(const BodyConf& def = GetDefaultBodyConf());.
  • void World::SetBody(BodyID id, const Body& value).

In the master branch code however this has been changed to the following:

  • BodyID World::CreateBody(const Body& body);
  • void SetBody(BodyID id, const Body& value);

Note that there's also the following functions available to convert between a Body and a BodyConf:

Body::Body(const BodyConf& bd = GetDefaultBodyConf());
BodyConf GetBodyConf(const Body& body);

Unusable Functions

I would expect to not become trapped by finding functions that are unusable.

That's what I had read and was thinking about till now and I agree with you on this. The problem also comes up when creating or using the project as a dynamic library. And there's a tension in this regard against unit testing the code. I don't want users concerning themselves with implementation functions for example but I do want that code tested directly. I have it in mind and have made some starts at dealing with that.

from playrho.

louis-langholtz avatar louis-langholtz commented on May 24, 2024

Added a new project of Reduce Namespace Pollution to address the concerns I share with this issue. Closing this particular issue in deference to this new project.

from playrho.

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.