Code Monkey home page Code Monkey logo

Comments (6)

louis-langholtz avatar louis-langholtz commented on June 27, 2024

Out of curiosity, what flavor of interface for this info would you prefer:

  1. IsDestroyed(const World&, EntityID).
  2. entity.IsDestroyed().
  3. std::optional<Entity> GetEntity(const World&, EntityID).

from playrho.

opera-aberglund avatar opera-aberglund commented on June 27, 2024

Out of curiosity, what flavor of interface for this info would you prefer:

  1. IsDestroyed(const World&, EntityID)
  2. entity.IsDestroyed()
  3. std::optional GetEntity(const World&, EntityID)

I would prefer 1 I think because it matches the signature of the Destroy function.

from playrho.

louis-langholtz avatar louis-langholtz commented on June 27, 2024

I would prefer 1 I think because it matches the signature of the Destroy function.

Interesting to me that option 3 didn't get mentioned. Interesting in terms of discussion, because while I'm a fan of C++ vocabulary types like std::optional, I'm also concerned about minimizing memory usage.

Specifically, making the underlying storage arrays that the implementing world uses be arrays of std::optional<T> instead of arrays of T seems more likely to be suboptimal bit-density wise than another possibility I'm thinking of.

In this case, PlayRho types like Body and Contact already provide boolean properties stored directly in bits packed optimally. That leads most naturally for me to options 1 and 2.

The more abstracted PlayRho types Shape and Joint don't seem to have as optimal, or, at least, not such a straight forward path for providing an is-destroyed piece of info. Perhaps the most straight forward to me is using their has_value member function for this. That way, supporting types (like DiskShapeConf for example), don't have to all change their interfaces to support this.

So I think that's what I'll do then, and why. I.e. provide interface 1 (and 2) for the PlayRho Body, Contact, Joint, Shape types. Assuming of course that this works out; I'm concerned I may yet encounter wrinkles with this design.

Relatedly from my thinking, and see issue #547, I'm continuing to consider removing all of the World based functions GetBodies(const World&), GetContacts(const World&), GetJoints(const World&) (and their implementation based counterparts).

from playrho.

louis-langholtz avatar louis-langholtz commented on June 27, 2024

The following is available now in current master branch:

  • IsDestroyed(const Body&).
  • IsDestroyed(const Contact&).
  • IsDestroyed(const Shape&).
  • IsDestroyed(const Joint&).
  • IsDestroyed(const World&, BodyID id).
  • IsDestroyed(const World&, ContactID id).

Relatedly, manifolds would use the info for contact.

I still have to add the following however - I'd forgotten these but meant to add these as well:

  • IsDestroyed(const World&, JointID id).
  • IsDestroyed(const World&, ShapeID id).

from playrho.

opera-aberglund avatar opera-aberglund commented on June 27, 2024

The following is available now in current master branch:

Funny thing I just realised I don't need them anymore since I just use the MakeTouchingMap function now to filter the contacts. I think it's good to have them anyway!

from playrho.

louis-langholtz avatar louis-langholtz commented on June 27, 2024

This is complete now with PR #566.

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.