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

Linking legion entities with rapier2d colliders. #297

Open
pollmaecher opened this issue Dec 7, 2022 · 0 comments
Open

Linking legion entities with rapier2d colliders. #297

pollmaecher opened this issue Dec 7, 2022 · 0 comments

Comments

@pollmaecher
Copy link

Hello,

I'm trying to combine legion with rapier2d for physics calculation and 2d . So if I make a query in rapier2d and get a certain rigid body or collider I want to be able to get the legion entity.

For this reason rapier2d provides a u128 userdata linked to each collider, however, the internal legion entity id (NonZeroU64) is private and can therefore not be used.

Would it be possible to provide a way to get the internal entity id and create a new entity using a known id, like:

collider.set_userdata(entity.get_id());
...
let entity = World::get_entity(collider.get_userdata() as NonZeroU64).unwrap();

Or do you even know of a a better solution? The only possible alternative that comes to my mind is building a separate u128 id and mapping it to legions entities. However, this is a lot of boilerplate and effectively managing ids on ids...

Thanks in advance and thanks for this incredible ECS!

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