Repository navigation
Describe serde wire formats in BRP schema - #26337
jbuehler23 wants to merge 2 commits into
Conversation
6cef932 to
0df16ce
Compare
0df16ce to
8d90e07
Compare
8d90e07 to
a868100
Compare
| } | ||
| } | ||
|
|
||
| const COMPONENTS: [&str; 4] = ["x", "y", "z", "w"]; |
There was a problem hiding this comment.
This feels super janky to me. Why do we have / want special-cased logic for glam inside of bevy_remote, rather than deriving this from reflection data or something? This feels contrary to both the point of this PR and like it ignores the annotation work done earlier.
alice-i-cecile
left a comment
There was a problem hiding this comment.
Very skeptical of impl_brp_json_schemas. Embedding this sort of random list into bevy_remote is 100% going to bite us. We need to find a better architecture to solve this problem.
|
Yeah, fair. The list is there because Catch is |
Objective
Part of #23013. Follow-up to #26308.
Types that register
ReflectSerializeare sent over BRP in their own serde format, butregistry.schemastill describes their reflected fields.Vec3is described as{x, y, z}and sent as[x, y, z],Nameas a newtype and sent as a string, and so on, so tools building values from the schema get them wrong.Solution
BrpJsonSchematrait and#[reflect(BrpJsonSchema)]type data, so a type can declare the JSON schema of its serialized formDuration,Entity,Name, theNonZerointegers,Uuid,AssetPathand a few string-like types; glam array items are titled (x,y,x_axis.y, ...)reflectSchemafieldrawJson: trueinstead of a guessed shapeSchemaRegistrykeeps reading the reflected structure, soVec3still hasx,yandzfields, andTypeSchema::wiregives the wire schemaStructured types with derived serde, like
Transform, are unchanged since their serialized form already matches their fields.Testing
Each built-in is checked against a real serialized value, and glam item titles are checked against the reflected fields. Other tests cover a user-declared schema,
rawJson, and the index.AI disclosure
The implementation and tests were written with the help of AI, and I reviewed the changes before using any of the proposed code.