Skip to content

feat: Add VehicleComponent with serialization, scripting, and runtime…#387

Merged
drsnuggles8 merged 3 commits into
masterfrom
feature/physics-vehicle-constraint
Jun 25, 2026
Merged

feat: Add VehicleComponent with serialization, scripting, and runtime…#387
drsnuggles8 merged 3 commits into
masterfrom
feature/physics-vehicle-constraint

Conversation

@drsnuggles8

Copy link
Copy Markdown
Owner

… support

  • Implemented VehicleComponent with properties for vehicle dynamics including half track width, axle offsets, wheel dimensions, suspension parameters, and driver inputs.
  • Added serialization support for VehicleComponent to ensure proper saving and loading of component state.
  • Integrated VehicleComponent into the Lua and C# scripting systems, allowing for manipulation of vehicle properties from scripts.
  • Created tests to validate the functionality of VehicleComponent, including physics interactions, suspension behavior, and save-game round-trip integrity.
  • Updated Scene class to handle vehicle addition and removal during runtime, ensuring proper management of vehicle constraints in the physics engine.

… support

- Implemented VehicleComponent with properties for vehicle dynamics including half track width, axle offsets, wheel dimensions, suspension parameters, and driver inputs.
- Added serialization support for VehicleComponent to ensure proper saving and loading of component state.
- Integrated VehicleComponent into the Lua and C# scripting systems, allowing for manipulation of vehicle properties from scripts.
- Created tests to validate the functionality of VehicleComponent, including physics interactions, suspension behavior, and save-game round-trip integrity.
- Updated Scene class to handle vehicle addition and removal during runtime, ensuring proper management of vehicle constraints in the physics engine.
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@drsnuggles8, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 24 minutes and 28 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: acb12297-3b22-4308-9b87-3fede411ca72

📥 Commits

Reviewing files that changed from the base of the PR and between 952d23e and 29ca083.

⛔ Files ignored due to path filters (3)
  • OloEngine/src/OloEngine/Scene/Generated/AllComponents.Generated.inl is excluded by !**/generated/**
  • OloEngine/src/OloEngine/Scripting/C#/Generated/ScriptGlueBindings.inl is excluded by !**/generated/**
  • OloEngine/src/OloEngine/Scripting/C#/Generated/ScriptGlueRegistrations.inl is excluded by !**/generated/**
📒 Files selected for processing (13)
  • OloEngine-ScriptCore/src/OloEngine/InternalCalls.Generated.cs
  • OloEngine-ScriptCore/src/OloEngine/Scene/Components.Generated.cs
  • OloEngine/src/OloEngine/Physics3D/JoltScene.cpp
  • OloEngine/src/OloEngine/Physics3D/JoltScene.h
  • OloEngine/src/OloEngine/SaveGame/SaveGameComponentSerializer.cpp
  • OloEngine/src/OloEngine/SaveGame/SaveGameComponentSerializer.h
  • OloEngine/src/OloEngine/SaveGame/SaveGameSerializer.cpp
  • OloEngine/src/OloEngine/Scene/Components.h
  • OloEngine/src/OloEngine/Scene/Scene.cpp
  • OloEngine/src/OloEngine/Scene/SceneSerializer.cpp
  • OloEngine/src/OloEngine/Scripting/Lua/LuaScriptGlue.cpp
  • OloEngine/tests/CMakeLists.txt
  • OloEngine/tests/Functional/AnimationPhysics/VehicleTest.cpp

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

drsnuggles8 and others added 2 commits June 25, 2026 10:25
Resolve the AllComponents tuple conflict in Scene/Components.h: master moved
the hand-maintained AllComponents ComponentGroup<...> list into OloHeaderTool
codegen (#include Scene/Generated/AllComponents.Generated.inl). Took master's
generated-include side and dropped the hand-written list; VehicleComponent is a
struct *Component definition, so GenerateBindings now registers it in the
regenerated tuple automatically (verified by ComponentTupleCoverage).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Self-review of the VehicleComponent PR surfaced reachable use-after-free /
assert paths in the vehicle runtime lifecycle. A VehicleConstraint is a live
Jolt step listener that dereferences its chassis body every tick, so it must be
torn down before that body is freed.

- Scene::DestroyEntity now destroys the vehicle (vehicle-before-body) before
  registry.destroy(); entt's registry.destroy does NOT fire OnComponentRemoved,
  so the constraint would otherwise outlive its freed chassis body.
- Scene::OnComponentRemoved<Rigidbody3DComponent> destroys the vehicle before
  destroying the chassis body it drives.
- JoltScene::UpdateVehicleControllers uses the non-asserting TryGetEntityWithUUID
  instead of GetEntityByUUID, so a transient m_Vehicles/entity desync degrades to
  a clean skip instead of an assert/UB on the physics tick.
- JoltScene::CreateVehicle: allow an authored SuspensionMinLength of 0 (the
  contract and serializers permit 0 <= min; SanitizeVehiclePositive wrongly
  rewrote 0 to the default), and fall steer-angle back to 0 (steering disabled)
  on a non-finite value, matching the documented intent.

Adds two regression tests: DestroyingVehicleEntityReleasesTheConstraint and
RemovingChassisRigidbodyReleasesTheVehicle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@drsnuggles8

Copy link
Copy Markdown
Owner Author

🤖 Self-review (finish-pr) @ 29ca083d2803449539069609bae1eb1cbc50569c

Reviewed the PR diff against master at high effort (8 finder angles + verification), after merging origin/master in to resolve the Components.h AllComponents conflict (master's #386 moved that tuple into OloHeaderTool codegen — took the generated-include side; VehicleComponent is auto-registered, verified by ComponentTupleCoverage).

Findings: 5 fixed + 2 regression tests (commit 29ca083d). The review surfaced a reachable use-after-free class in the vehicle runtime lifecycle — a VehicleConstraint is a live Jolt step listener that dereferences its chassis body every tick, so it must be torn down before that body is freed.

  • Fixed: Scene::DestroyEntity now destroys the vehicle before registry.destroy() (entt doesn't fire OnComponentRemoved there) — was a UAF/assert when destroying a car at runtime.
  • Fixed: OnComponentRemoved<Rigidbody3DComponent> destroys the vehicle before the chassis body it drives.
  • Fixed: UpdateVehicleControllers uses non-asserting TryGetEntityWithUUID instead of the asserting GetEntityByUUID, so a transient m_Vehicles/entity desync skips cleanly instead of crashing the tick.
  • Fixed: CreateVehicle preserves an authored SuspensionMinLength == 0 (serializers/Jolt allow 0 <= min; SanitizeVehiclePositive had rewritten 0 to the default).
  • Fixed: CreateVehicle steer-angle falls back to 0 (steering disabled) on a non-finite value, matching the documented intent.
  • Tests: added DestroyingVehicleEntityReleasesTheConstraint + RemovingChassisRigidbodyReleasesTheVehicle (both UAF without the fixes).

Dismissed (4) — all faithfully mirror the existing PhysicsJoint3DComponent pattern, so out of scope for this PR: per-site duplicated sanitization tables; Scene.cpp re-looping vs JoltScene::CreateVehicles() (joints do the same); m_RuntimeVehicleToken mirroring m_Vehicles membership; per-step UUID hashing in UpdateVehicleControllers.

Verification: full suite 3485 passed / 4 skipped (expected) / 0 failed; all component cross-binding coverage guards pass; VehicleTest (7 cases incl. the 2 new) green. Runtime-only change (no visual surface) — behavior verified through the Functional tests' real Scene::OnUpdateRuntime + Jolt.

@drsnuggles8 drsnuggles8 added the self-reviewed finish-pr self-review done label Jun 25, 2026
@drsnuggles8 drsnuggles8 merged commit 0f95ec8 into master Jun 25, 2026
4 of 5 checks passed
@drsnuggles8 drsnuggles8 deleted the feature/physics-vehicle-constraint branch June 25, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

self-reviewed finish-pr self-review done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant