Comments (3)
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.
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.
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)
- No vcpkg port available.
- UnitVec isn't generalized to N dimensions
- Testbed Test subclasses all in header files
- "vector<bool> subscript out of range" in WorldImpl HOT 5
- PlayRho and LiquidFun
- CMake: export of targets not used at all in config file HOT 2
- Fix code scanning alert - Returning stack-allocated memory HOT 1
- Some unit test failures on Apple M2 Silicon
- UnderlyingValue deprecated warnings in release 1.1.0 Testbed build
- Release 1.1.0 Testbed warns about using OpenGL functions on macOS deprecated since 10.14
- Warnings on building Testbed from uses of *sprintf
- benchmark submodule not based on v1.7.1 or newer
- AppVeyor doesn't run for release-1.1.1 branch HOT 1
- Get*JointConf functions incorrectly marked noexcept
- Checked class template support for non-throwing for known valid values HOT 1
- Performance regression introduced or former bug fixed? HOT 1
- Use custom container allocators in WorldImpl HOT 3
- Move WorldImpl under detail namespace HOT 1
- Move Island under detail namespace HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playrho.