Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewInitPhysicsSystem ¶
func NewInitPhysicsSystem(rt *internal.Runtime) func(*InitPhysicsSystemState)
NewInitPhysicsSystem returns the Init-hook system bound to rt. The system creates the singleton entity (if absent), then builds the Box2D world and bodies from ECS.
func NewPhysicsPipelineSystem ¶
func NewPhysicsPipelineSystem(rt *internal.Runtime) func(*PhysicsPipelineSystemState)
NewPhysicsPipelineSystem returns the full physics pipeline as one atomic unit, bound to rt. The plugin registers it on cardinal.PreUpdate so simulation and writeback finish before cardinal.Update game logic in the same tick, while contact/trigger system events remain visible until the tick ends.
Phases:
- Reconcile: sync ECS -> Box2D (create/update/destroy bodies from component changes)
- Step: advance physics simulation, buffer contact/trigger events
- Writeback: sync Box2D -> ECS (write post-step positions/velocities back to components)
Types ¶
type InitPhysicsSystemState ¶
type InitPhysicsSystemState struct {
cardinal.BaseSystemState
Bodies cardinal.Contains[physicsBodyRow]
Singleton physicsSingletonSearch
}
InitPhysicsSystemState runs once at world init: FullRebuildFromECS from current ECS entities.
type PhysicsPipelineSystemState ¶
type PhysicsPipelineSystemState struct {
cardinal.BaseSystemState
Bodies cardinal.Contains[physicsBodyRow]
Singleton physicsSingletonSearch
ContactBegin cardinal.WithSystemEventEmitter[physicevent.ContactBeginEvent]
ContactEnd cardinal.WithSystemEventEmitter[physicevent.ContactEndEvent]
TriggerBegin cardinal.WithSystemEventEmitter[physicevent.TriggerBeginEvent]
TriggerEnd cardinal.WithSystemEventEmitter[physicevent.TriggerEndEvent]
}
PhysicsPipelineSystemState runs the full physics pipeline atomically: reconcile -> step -> writeback. Combining all three phases into a single system guarantees the scheduler cannot interleave game code between them.