Skip to content

[Feature] Add physics backend plugin interface - #15

Closed
miogds wants to merge 1 commit into
developfrom
feature/physics_backend_interface
Closed

[Feature] Add physics backend plugin interface#15
miogds wants to merge 1 commit into
developfrom
feature/physics_backend_interface

Conversation

@miogds

@miogds miogds commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

PR A of the physics plugin readiness plan (upstream discussion #1116): the plugin-facing seam for optional physics backends. Nothing invokes the new API yet, so runtime behavior is unchanged by construction.

  • Sources/UntoldEngine/Physics/PhysicsBackend.swiftPhysicsBackend protocol with the threading contract (step/drain on the frame thread, backends buffer worker-thread events internally) and batch-only transform transfer, plus all value types: PhysicsCapabilities, PhysicsMotionType, PhysicsColliderShape, PhysicsWorldConfiguration (gravity default (0, -9.8, 0), collision layer matrix, m/kg/s units), body/collider descriptors, write/read transform batches, contact/trigger/activation events, PhysicsEventSink, ray query types. Default no-op implementations so minimal backends only implement what they support.
  • Sources/UntoldEngine/Physics/PhysicsBackendRegistry.swiftPhysicsBackendPlugin + manifest + validator following the render-extension plugin conventions (namespaced IDs, exact API-version match, backend ID inside plugin namespace); single-slot registry with install/replace/reject semantics, uninstall, failure introspection, and a lockForRuntime() seam for engine creation (wired in PR B).
  • ColliderComponent and RigidBodyComponent in Components.swift, with cleanup handlers in RegistrationSystem.swift (handler ID physicsBody).
  • 15 unit tests covering validation rejections, install/replace/uninstall, second-backend conflict, runtime lock, and inert default implementations.

Follow-ups per the plan: PR B (default backend wrap + PhysicsCoordinator + runFrame seam), PR C (event sink + USC OnCollision wiring), PR D (raycast facade).

Test plan

  • swift test --filter PhysicsBackendRegistryTests — 15/15 pass
  • ComponentRegistryTest (enforces cleanup handlers for every component in Components.swift) and ECSTests pass
  • Engine builds with zero new warnings; no existing file touched beyond the two additive edits

Plugin-facing seam for optional physics backends (PR A of the physics
plugin readiness plan): PhysicsBackend protocol with value types and
threading/batch-transfer contracts, single-slot PhysicsBackendRegistry
with validation and runtime lock, ColliderComponent and
RigidBodyComponent with cleanup handlers. Nothing invokes the new API
yet, so runtime behavior is unchanged.
@miogds

miogds commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Superseded by upstream untoldengine#1123 (merged as 260b23f with the review-revised layout), which is now in this fork's develop via the upstream sync.

@miogds miogds closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant