Skip to content

Linking legion entities with rapier2d colliders. #297

Description

@pollmaecher

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions