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

Make this example compile and working ! #1

Open
Vrixyz opened this issue Aug 13, 2018 · 3 comments
Open

Make this example compile and working ! #1

Vrixyz opened this issue Aug 13, 2018 · 3 comments

Comments

@Vrixyz
Copy link
Owner

Vrixyz commented Aug 13, 2018

This line causes trouble:

https://github.com/Vrixyz/testbed-callback/blob/master/src/main.rs#L77

I understand why : because physics_world is move here: https://github.com/Vrixyz/testbed-callback/blob/master/src/main.rs#L67.

But I have no idea how to fix it 😞

Thanks for your help!

13/08: Help asked at nphysics forum

@thedodd
Copy link

thedodd commented Aug 13, 2018

Hey, per my comment on Twitter:
I haven’t delved too deep into the code, but a few things come to mind:

  1. Use a reference instead of passing it in by value.
  2. Clone it (as someone else previously mentioned).
  3. Arc it (heap allocation, but that shouldn’t be a big deal).

I’ll dig a bit deeper and comment again if those options are not viable.

@Vrixyz
Copy link
Owner Author

Vrixyz commented Aug 14, 2018

Thanks ! I tried these approaches and didn't succeed (without modifying testbed source code)

My notes on these options, correct me if I'm wrong:

  • reference
    In order to pass it as reference, I would need to modify testbed source code to request nphysics2d::world::World as reference instead of taking ownership to it, correct ? (I'm not sure about this one)

Best option ? If I could pass a reference of nphysics2d::world::World to specs system but pass its ownership to testbed, that would be the best option, but I had no luck trying.

  • clone
    physics_world is rather heavy, but if it happens once, the performance cost is not a concern.
    I want to modify the same instance, I don't believe nphysics2d::world::World is designed to work like that. Again, that would mean modify testbed source code to allow that.

  • Arc
    That means pass Arc to specs::World, and pass Arc to testbed (or more correctly, a reference to an Arc ?). Again, modify testbed source code.
    Because I can't build an Arc that I pass to a specs::System, then pass its contained item to testbed.

Now, specs is permissive about passing an Arc or whatever, so the "constraint" remains only on testbed side, and I might be oblivious of a solution which could dodge the problem.

I'll check the source code of the testbed to see what are my options, the creator of nphysics answered with valuable informations so it might help

@Vrixyz
Copy link
Owner Author

Vrixyz commented Aug 14, 2018

The branch https://github.com/Vrixyz/testbed-callback/compare/1-reference aims to answer option 1.

As Option 1 (without touching nphysics testbed source code) is the best option in my opinion, I'll focus my effort on understanding that.

I'll create MR to discuss each options in details.

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

2 participants