Repository navigation
feat(codegen): generate SceneSerializer blocks for trivial components (#380) - #450
Conversation
- Implemented unit tests for LuaScriptComponent, PerceptibleComponent, and NameplateComponent to ensure they survive YAML serialization and deserialization. - Updated ComponentSerializerCoverageTest to include checks for generated serialization and deserialization blocks, ensuring all components are handled correctly. - Introduced a disjointness test to verify that components are serialized by either the hand-written serializer or the generated code, but not both. - Enhanced OloHeaderTool to generate serialization and deserialization blocks for trivial components, ensuring proper handling of all component fields. - Added a set of components to be kept hand-written despite being trivial, to maintain specific serialization logic.
|
Warning Review limit reached
More reviews will be available in 58 minutes and 33 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|




Summary
Extends OloHeaderTool to generate the per-component scene-YAML serialize/deserialize blocks, collapsing the last big unguarded hand-maintained ECS touch-point (
Scene/SceneSerializer.cpp). A component whose field you forgot to hand-serialize used to round-trip through nothing — silent scene-data loss that the old name-onlyComponentSerializerCoverageTestcouldn't catch. Codegen now prevents the miss.Fourth slice of the #380 epic (after AllComponents tuple #386, SaveGame lists #405, OnComponentAdded/Removed #413).
Scope — the safe 13 of 99
The generator drives off a new full data-member scan (
CollectComponentFields), not theOLO_PROPERTYscan — the serializer persists every field, not just script-exposed ones (e.g.DirectionalLightComponentserializes 9 fields but annotates only 3).A component is auto-generated iff every data member is a primitive /
glm::vec*/std::stringand it isn't in the newkComponentsCustomSerializeexclusion set. Anything with a non-trivial field (enum,AssetHandle,Ref<T>,std::vector, nested struct,glm::quat/mat/ivec) is classified non-trivial and skipped automatically — no exclusion entry needed.The 13 migrated components: CharacterController3D, CircleRenderer, DirectionalLight, PointLight, SpotLight, LocalizedText, LuaScript, Nameplate, NetworkInterest, Perceptible, UICheckbox, UIRectTransform, UIToggle.
Each was verified to be a plain round-trip (parsed-field set == hand-written YAML-key set) before migration. That check also correctly rejected
VehicleComponent(a runtime-onlyRuntimeVehicleTokenfield the serializer deliberately omits) andScriptComponent(writes the external C# ScriptField map, not just itsClassNamemember) — both stay hand-written.What changed
tools/OloHeaderTool/main.cpp— field scanner + classifier (SceneSerType), two emitters,kComponentsCustomSerializeexclusion set, and an empty-output guard (refuses to overwrite with 0 components).Scene/Generated/Scene{Serialize,Deserialize}Components.Generated.inl(new, tracked) —#included at the end ofSerializeEntity/DeserializeEntityComponents. Floats validated viaTryReadFiniteF32/ glmDecode; a missing key keeps the constructor default.SceneSerializer.cpp— 26 hand-written blocks removed, 2 includes added.ComponentSerializerCoverageTest.cpp— existence check now spansSceneSerializer.cpp∪ the generated.inl; newNoComponentIsBothHandWrittenAndGenerateddisjointness test fails loudly on a double-emit.ComponentRoundTripTest.cpp— 3 new tests (LuaScript/string, Perceptible/i32, Nameplate/mixed-vec); the other 10 migrated components already had round-trip tests.CLAUDE.md— touch-point + OloHeaderTool docs updated.Contract / safety
Every component is handled by exactly one of the hand-written serializer or the generated
.inl:AddComponent<T>twice on read)A new trivial component is auto-serialized with zero edits; a new complex one fails the coverage test until hand-written.
Testing
Validated locally with the real clang-cl C++23 toolchain:
.inlare clang-format-stable.Deferred (follow-up)
Complex-field serialization (asset handles,
Ref<T>, enums,std::vector, nested structs, setter-onlySceneCamera, and trivial components needing custom range-clamp/Sanitizevalidation) remains hand-written. A follow-up issue will track the rest of #380's SceneSerializer work.🤖 Generated with Claude Code