-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix PR Bevy 0.9 Update #38
Conversation
- renamed and split `register_rollback_type` in `register_rollback_component` and `register_rollback_resource` - cleaned up examples - split register_component and register_resource - up dependency to bevy 0.9.1 to use `resources.iter()`
thank you for working on this! The two-player example seems to work, but the spectator example crashes immediately.
leads to:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got to admit I don't understand all of the reflect stuff. But most of this PR looks sensible to me (though I wrote parts of it myself :P)
Added mostly nitpick comments.
As I understand it what were previously part of the GGRS reflect_resource
module is now implemented within Bevy itself. I guess that means we should also delete the reflect_resource module?
You mentioned you didn't do much checking... One thing you could do, is check if the frame count resource in the p2p example works as expected?
EDIT: Also, thanks for picking this up! :)
SessionType::SyncTestSession | ||
} | ||
} | ||
// TODO: more specific name to avoid conflicts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should probably think about what to name this... It's public API that will be used, and Inputs
quite easily conflicts with something else... and is very similar to Bevy's Input
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I agree, but at t he same time it's namespaced so it's not a very big issue. What do you think of SessionInputs
OR SessionFrameInput
? Also this could use some type documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's easy enough to fix... More thinking about it being easy to read.
We have prefixed GGRSError
, GGRSConfig
. And some have P2P
as prefix (P2PSession
).
GGRSInputs
P2PInputs
PlayerInputs
(matchesPlayerHandle
which is used to index this resource)SessionInputs
Just spitballing. Don't really have a strong opinion. I'm also ok with Inputs
. What do you think @gschup ?
definitely agree it could use some documentation!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
properly naming the Inputs is tough, but I think we should definitely not name it Inputs
. I like PlayerInputs
quite a bit. I would shy away from naming it GGRSInputs
as this struct does not come from the GGRS crate itself.
@@ -55,7 +54,7 @@ impl Rollback { | |||
|
|||
/// Provides unique ids for your Rollback components. | |||
/// When you add the GGRS Plugin, this should be available as a resource. | |||
#[derive(Default)] | |||
#[derive(Resource, Default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(Resource, Default)] | |
#[derive(Resource, Default)] | |
#[reflect(Resource)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this accomplish ? wouldn't Resource already have some reflect capabilities ? or is it to enable bevy_egui reflection ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. maybe it's not needed? I think I maybe just made a brainfart and thought you added derive(Reflect)
.
I guess the real answer is to just check what works :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, sorry about the noise. We could perhaps add reflect in another PR. It might be useful for debugging.
} | ||
} | ||
// TODO: more specific name to avoid conflicts? | ||
#[derive(Resource, Deref, DerefMut)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(Resource, Deref, DerefMut)] | |
#[derive(Resource, Deref, DerefMut)] | |
#[reflect(Resource)] |
Co-authored-by: Johan Klokkhammer Helsing <johanhelsing@gmail.com>
@@ -32,7 +32,7 @@ impl Config for GGRSConfig { | |||
} | |||
|
|||
#[repr(C)] | |||
#[derive(Copy, Clone, PartialEq, Pod, Zeroable)] | |||
#[derive(Copy, Clone, PartialEq, Eq, Pod, Zeroable)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eq
was not really necessary but it pleases clippy :)
// in order to allow a GGRS `SyncTestSession` to construct a checksum for a world snapshot | ||
#[derive(Default, Reflect, Hash, Component)] | ||
// You can also register resources. | ||
#[derive(Resource, Default, Reflect, Hash)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if reflect/hash is still needed, I didn't check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of this is still kind of shallow, but register_rollback_resource
seems to need Reflect because it's needed for TypeRegistration::insert
...
Or more specifically TypeRegistration::insert
needs the TypeData
trait to be implemented, which is automatically implemented by deriving Reflect
.
I think #[derive(Hash)]
and #[reflect(Hash)
is not needed. At least the examples, including synctest, run fine without them. Perhaps @gschup would like to confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deriving and reflecting hash is useful here. It is definitely optional, but encouraged to give SyncTest an actual meaning beyond "checking if this still runs".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could be more specific about it in the comment... Something like "By deriving Hash
and adding reflect(Hash)
the resource can automatically be checked for desyncs during a SyncTestSession
"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is definitely a lot to be improved regarding documentation (see e.g. #35). It might probably even be better to that outside of this PR, in a big documentation commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested resource rollback by adding some logging to the synctest session example's FrameCount
. Everything works as expected :D
Also ported my tutorial to this branch, and it works fine (though that doesn't really need resource rollback): https://github.com/johanhelsing/extreme_bevy/tree/bevy-0.9-wip
Feels like this is really close now, just some minor nits and some docs for the new resources would be nice. Great work @Vrixyz !
// in order to allow a GGRS `SyncTestSession` to construct a checksum for a world snapshot | ||
#[derive(Default, Reflect, Hash, Component)] | ||
// You can also register resources. | ||
#[derive(Resource, Default, Reflect, Hash)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of this is still kind of shallow, but register_rollback_resource
seems to need Reflect because it's needed for TypeRegistration::insert
...
Or more specifically TypeRegistration::insert
needs the TypeData
trait to be implemented, which is automatically implemented by deriving Reflect
.
I think #[derive(Hash)]
and #[reflect(Hash)
is not needed. At least the examples, including synctest, run fine without them. Perhaps @gschup would like to confirm?
@@ -55,7 +54,7 @@ impl Rollback { | |||
|
|||
/// Provides unique ids for your Rollback components. | |||
/// When you add the GGRS Plugin, this should be available as a resource. | |||
#[derive(Default)] | |||
#[derive(Resource, Default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, sorry about the noise. We could perhaps add reflect in another PR. It might be useful for debugging.
SessionType::SyncTestSession | ||
} | ||
} | ||
// TODO: more specific name to avoid conflicts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's easy enough to fix... More thinking about it being easy to read.
We have prefixed GGRSError
, GGRSConfig
. And some have P2P
as prefix (P2PSession
).
GGRSInputs
P2PInputs
PlayerInputs
(matchesPlayerHandle
which is used to index this resource)SessionInputs
Just spitballing. Don't really have a strong opinion. I'm also ok with Inputs
. What do you think @gschup ?
definitely agree it could use some documentation!
Co-authored-by: Johan Klokkhammer Helsing <johanhelsing@gmail.com>
Co-authored-by: Johan Klokkhammer Helsing <johanhelsing@gmail.com>
Co-authored-by: Johan Klokkhammer Helsing <johanhelsing@gmail.com>
I don't think we are missing much here. I think it would be nice to rename |
My attempt to help with #36.
What I added with commit 63dc9af:
cargo test passing with bevy 0.9.1
register_rollback_type
inregister_rollback_component
andregister_rollback_resource
resources.iter()
refect_resource
modWhat I tested