-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
Reflect and register Collider
type
#404
Comments
Collider
type
This currently requires some changes on bevy_reflect side as |
it looks like the linked PR has been merged, is the door opened now to impl |
Semi-relevant issue: dimforge/rapier#467 |
The HEAD revision of It's a similar idea to component mirror, but baked into the save pipeline: app.register_type::<SerializedCollider>()
.add_systems(
PreUpdate,
(
save_default()
.map_component(serialize_collider)
.into_file("example.ron"),
load_from_file_with_mapper(
"example.ron",
SceneMapper::default().map(deserialize_collider),
),
),
) Where #[derive(Component, Reflect)]
#[reflect(Component)]
enum SerializedCollider {
Ball(f32),
// ...
}
fn serialize_collider(collider: &Collider) -> SerializedCollider {
if let Some(ball) = collider.as_ball() {
SerializedCollider::Ball(ball.radius())
} else {
todo!()
}
}
fn deserialize_collider(serialized: &SerializedCollider) -> Collider {
match serialized {
SerializedCollider::Ball(radius) => Collider::ball(*radius),
_ => todo!(),
}
} I'm curious to know if:
|
Hi, I'm blocked because the
Collider
type is not registered to the app, and cannot be manually registered because it lacks the required traits implementations. I guess it is related to this TODO:bevy_rapier/src/geometry/collider.rs
Line 61 in af5ac6e
I suppose this is not the only type that requires reflection. Is there any work in progress to add those? If not I may write a PR.
The text was updated successfully, but these errors were encountered: