Package-level declarations

Types

Link copied to clipboard
@Immutable
data class BoundariesConfig(val enabled: Boolean = true, val restitution: Float = 0.2f, val friction: Float = 0.3f, val thicknessPx: Float = 64.0f)

Optional static boundaries around the dev.zinchenko.physicsbox.layout.PhysicsBox container.

Link copied to clipboard
@Immutable
data class PhysicsBodySnapshot(val key: Any, val transformPx: PhysicsTransform, val isAwake: Boolean, val linearVelocityPxPerSecond: PhysicsVector2)

Immutable body state exported as part of PhysicsWorldSnapshot.

Link copied to clipboard
@Immutable
data class PhysicsBoxConfig(val boundaries: BoundariesConfig = BoundariesConfig(), val worldScale: PxPerMeter = PhysicsDefaults.WorldScale, val step: StepConfig = StepConfig())

Global configuration for a dev.zinchenko.physicsbox.layout.PhysicsBox world.

Link copied to clipboard
@Stable
class PhysicsBoxState

Mutable controller for a physics world hosted by dev.zinchenko.physicsbox.layout.PhysicsBox.

Link copied to clipboard
sealed interface PhysicsCommand

Commands produced by UI/layout code and consumed by the runtime physics backend.

Link copied to clipboard
@Immutable
data class PhysicsDebugConfig(val enabled: Boolean = false, val drawBodies: Boolean = false, val drawBounds: Boolean = false, val drawContacts: Boolean = false)
Link copied to clipboard

Shared default values used by API contracts.

Link copied to clipboard
@Immutable
data class PhysicsVector2(val x: Float, val y: Float)

Small immutable 2D vector used by PhysicsBox API.

Link copied to clipboard
@Immutable
data class PhysicsWorldSnapshot(val isPaused: Boolean, val gravity: PhysicsVector2, val stepConfig: StepConfig, val solverIterations: SolverIterations, val bodies: List<PhysicsBodySnapshot> = emptyList(), val bodiesByKey: Map<Any, PhysicsBodySnapshot> = bodies.associateBy { it.key }, val stepIndex: Long = 0)

Immutable world snapshot used for UI/runtime synchronization.

Link copied to clipboard
@Immutable
data class PxPerMeter(val value: Float = 100.0f)

Pixels-per-meter ratio used to map UI coordinates (px) to physics coordinates (m).

Link copied to clipboard
@Immutable
data class SolverIterations(val velocity: Int = 8, val position: Int = 3)

Solver iteration counts used by the physics backend.

Link copied to clipboard
@Immutable
data class StepConfig(val hz: Float = 60.0f, val velocityIterations: Int = 8, val positionIterations: Int = 3, val maxSubSteps: Int = 3, val maxDeltaSeconds: Float = 1f / 15f)

Fixed-step simulation settings for the PhysicsBox world.

Functions

Link copied to clipboard
@Composable
fun rememberPhysicsBoxState(initialIsPaused: Boolean = false, initialGravity: PhysicsVector2 = PhysicsDefaults.Gravity, initialStepConfig: StepConfig = StepConfig()): PhysicsBoxState

Remembers a PhysicsBoxState instance for controlling world-level behavior.

Link copied to clipboard

Creates a unit-conversion helper bound to PhysicsBoxConfig.worldScale.