Boundaries Config
Optional static boundaries around the dev.zinchenko.physicsbox.layout.PhysicsBox container.
When enabled, the engine creates four static “walls” (left / top / right / bottom) that surround the container. These walls prevent dynamic bodies from leaving the visible area and allow you to tune how objects bounce and slide when they hit the edges.
Coordinate space and sizing
The container uses Compose coordinates: X to the right, Y down.
Boundary geometry is generated from the current container size (in px) as observed by
PhysicsBoxLayout.thicknessPx defines the wall thickness in pixels. A thicker wall reduces the chance that fast bodies “tunnel” through edges (though true CCD depends on body settings like
isBullet).
Contact behavior
restitution controls how “bouncy” the container edges are:
0.0→ no bounce (perfectly inelastic)1.0→ highly elastic bounce Values above1.0are allowed by the underlying physics engines in many cases, but can inject energy and destabilize simulation; keep it in[0..1]for typical UI use.friction controls sliding against the walls:
0.0→ no friction (objects slide freely)higher values → stronger resistance to sliding
Lifecycle
Walls are (re)generated whenever the container size changes.
Disabling boundaries removes the walls from the physics world.
Recommended starting values
restitution = 0.2fandfriction = 0.3fgive a subtle bounce with controlled sliding.thicknessPx = 32f..96fis usually enough for UI scenes depending on element sizes and speeds.