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

serde Serialize and Deserialise on shape types #10626

Closed
ActuallyHappening opened this issue Nov 18, 2023 · 6 comments
Closed

serde Serialize and Deserialise on shape types #10626

ActuallyHappening opened this issue Nov 18, 2023 · 6 comments
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@ActuallyHappening
Copy link
Contributor

What problem does this solve or what need does it fill?

I am wanting ot efficiently sync data between server and client. Since Mesh is not (and should not) implement serialise, I am using a custom enum. I wanted this enum to have variants like Prism(shape::Box) but I found out shape::Box doesn't implement serialise and deserialise.

What solution would you like?

#[cfg_attr("serialize-serde", derive(Serialize, Deserialize)] on all of the shapes

What alternative(s) have you considered?

Currently I can manually store the underlying types

Additional context

Thanks so much for bevy! Its awesome to have fun with :)

@ActuallyHappening ActuallyHappening added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Nov 18, 2023
@Kanabenki Kanabenki added D-Trivial Nice and easy! A great choice to get started with Bevy A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Nov 18, 2023
@Kanabenki
Copy link
Contributor

That could also be done for the shapes types recently added in bevy_math.

@ActuallyHappening
Copy link
Contributor Author

That could also be done for the shapes types recently added in bevy_math.

Bevy-math looks cool but I've never heard of it until now, is it supposed to replace bevy::prelude::shape in a future release? (I've only briefly looked myself, doesn't parry support these basic shapes?) it would be cool to have more expressive shapes in the future

@Jondolf
Copy link
Contributor

Jondolf commented Nov 20, 2023

is it supposed to replace bevy::prelude::shape in a future release?

For the most part, yes. The high-level goal is to have a nice set of primitive shapes that are reusable and interoperable across Bevy's own crates and 3rd party plugins, so they could be used for mesh creation, rendering shapes via gizmos, collider shapes, raycasting, bounding volumes, some rendering things, and so on. This is unlike the existing shapes in bevy_render that are specific to meshes (e.g. IcoSphere and UVSphere with subdivision counts instead of a simple Sphere with a radius).

doesn't parry support these basic shapes?

Yes, but we don't want to depend on Parry and bring Nalgebra to the dependency tree. We also might need to have more control over the shape representations so that they are as efficient and general-purpose as possible while being ergonomic to use.

And yes, implementing Serialize/Deserialize for the primitive shapes could be useful :)

@rlidwka
Copy link
Contributor

rlidwka commented Nov 20, 2023

Since Mesh is not (and should not) implement serialise, I am using a custom enum.

Why shouldn't it implement serialize?

@ActuallyHappening
Copy link
Contributor Author

Since Mesh is not (and should not) implement serialise, I am using a custom enum.

Why shouldn't it implement serialize?

I guess it's entirely possible, I just looked at it and saw it was complicated with only private fields. Maybe upholding invariants? It would be great, actually, if Mesh would be serializable.

@BD103
Copy link
Member

BD103 commented Jul 18, 2024

At this point, all of the primitives within bevy_math now implement Serialize and Deserialize behind a feature flag. (And the old shapes have been removed.) Marking as closed :)

@BD103 BD103 closed this as completed Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

No branches or pull requests

5 participants