BlackPhlox / bevy_dolly

h3r2tic's dolly abstraction layer for the bevy game framework
Apache License 2.0
143 stars 22 forks source link

Derive Reflect for Rig and the drivers, then place them into type registry #34

Open janhohenheim opened 1 year ago

janhohenheim commented 1 year ago

This improves runtime debugging, since reflection is not available for these types right now: image (Screenshot shows bevy_editor_pls)

BlackPhlox commented 1 year ago

Thanks! I totally forgot about that, thanks for reminding me! 👍

BlackPhlox commented 1 month ago

Hi there, I just tried to derive Reflect for the Rig when preparing for the 0.14 crate release. However, I hit the wall of the underlying Box<dyn RigDriverTraits> not easily being able to be reflected, TypePath yes, but not for reflection, maybe there is a way to do manual reflection definition? I'm very much a noob on this topic, so input is appreciated.

janhohenheim commented 1 month ago

Since you are forking dolly anyways, can't you make t he underlying types Reflect?

BlackPhlox commented 1 month ago

That was what I tried. When adding Reflect to RigDriverTraits I hit compiler errors I wasn't sure how to fix.

janhohenheim commented 1 month ago

What happens when you add : Reflect as a trait bound? Or is that what you tried?

BlackPhlox commented 1 month ago

I get:

`Box<(dyn RigDriverTraits + 'static)>` does not have a type path
consider annotating `Box<(dyn RigDriverTraits + 'static)>` with `#[derive(Reflect)]` or `#[derive(TypePath)]`

Impl. TypePath is not enough work for inspection.

I'll create a branch so you can check

BlackPhlox commented 1 month ago

Here you go: https://github.com/BlackPhlox/bevy_dolly/tree/reflect

janhohenheim commented 1 month ago

Hmm. Ping @MrGVSV, maybe you can help? I'm not deep enough into reflection to help much.

MrGVSV commented 1 month ago

What if you tried changing it to Arc<dyn RigDriverTraits>? We don't support reflecting Box yet, but we do make an exception for Arc.

Although, Arc is treated as a "reflect value" meaning that it loses all knowledge about its internal types, including the structure of the underlying dyn RigDriverTraits, so it may not work properly with the inspector.

I don't really know how the inspector works under the hood, but maybe there's a way to register the "actual" type for "reflect value" types like this?