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

Use custom handle type to joints rather than unique_ptr #3

Open
sansumbrella opened this issue Oct 24, 2014 · 1 comment
Open

Use custom handle type to joints rather than unique_ptr #3

sansumbrella opened this issue Oct 24, 2014 · 1 comment

Comments

@sansumbrella
Copy link
Owner

The underlying joint has ambiguous ownership. If either of the b2Bodies it connects are destroyed, the joint will be destroyed by Box2d. This leads to double-deletion if either body is destroyed before the unique_ptr returned by our wrapper.

So we need a handle that can remove the joint, but will (hopefully) not delete it if the joint has already been destroyed. Maybe it keeps both bodies alive by containing a shared_ptr to those involved in the joint as well as the non-owning raw pointer to the joint.

@sansumbrella
Copy link
Owner Author

Handle should implement joint destruction listener. Don't scope the lifetime of the joint to the basic handle. Instead, have an optional scoped version that destroys the joint.

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

1 participant