system

package
v0.16.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitPhysicsSystem

func InitPhysicsSystem(state *InitPhysicsSystemState)

InitPhysicsSystem creates the singleton entity (if absent), then builds the C-side Box2D world and bodies from ECS. Runs on cardinal.Init.

func PhysicsPipelineSystem

func PhysicsPipelineSystem(state *PhysicsPipelineSystemState)

PhysicsPipelineSystem runs the full physics pipeline as one atomic unit. 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:

  1. Reconcile: sync ECS -> C-side Box2D (create/update/destroy bodies from component changes)
  2. Step: advance physics simulation, buffer contact/trigger events
  3. Writeback: sync C-side Box2D -> ECS (write post-step positions/velocities back to components)

func SetRuntimeConfig

func SetRuntimeConfig(c RuntimeConfig)

SetRuntimeConfig stores config for physics systems; call from Plugin.Register only. Zero FixedDT or SubStepCount are replaced with defaults.

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

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.

type RuntimeConfig

type RuntimeConfig struct {
	Gravity      component.Vec2
	FixedDT      float64
	SubStepCount int
}

RuntimeConfig holds gravity and stepping parameters passed to the physics simulation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL