# physicsObstacles2D

Import from `@pibbl/core/physics/2d`. Call `physicsObstacles2D(world)` during
component evaluation to obtain a stable source accepted by
`useFlowField2D({ ..., obstacles: source })` or
`embers({ ..., physics: { obstacles: source } })`. The world retains the source and
its reusable numerical buffers until disposal. Worlds that never request it
perform no obstacle packing.

`source.read()` returns `{ revision, boxes, ellipses, polygons }` from the last successful physics
commit. The borrowed `Float64Array` uses ten entries per box: center x/y,
half-width/height, rotation in radians, center-of-mass linear velocity x/y,
angular velocity in radians per second, and world center-of-mass x/y.
Coordinates use the physics world's simulation space. The field must use the
same origin and scale.

The obstacle revision changes only when packed geometry or motion changes;
unchanged physics commits retain the revision so a flow field can reuse its grid.
Do not mutate or retain borrowed values across commits; copy them if needed.
The buffer contains copies, never Rapier or another WASM module's memory.
Ellipses (including circles) use the same ten-entry layout with radii instead
of half extents. Each polygon record contains vertex count, linear velocity x/y,
angular velocity, center of mass x/y, then world-space vertex x/y pairs.

Rounded boxes with equal corner radii are exported as an exact union of
central boxes and corner circles. Their immutable local geometry is cached.

Disabled bodies and sensors are excluded. Unsupported solid collider kinds
(such as capsules or rounded boxes with unequal corner radii) produce an explicit error on read. Reading after world disposal throws.

Geometry and motion publish together after physics adoption, so flow advancement
reads the previous committed physics state regardless of registration order.
The flow applies no forces back to the world, and smoke particles need no bodies.

## API details from source

<span id="api-physicsObstacles2D"></span>

A borrowed committed solid batch, structurally compatible with a flow obstacle source.

```ts
physicsObstacles2D: (world: PibblPhysicsWorldHandle2D) => Readonly<{ read(): Readonly<{ revision: number; boxes: Float64Array; ellipses: Float64Array; polygons: Float64Array; }>; }>
```

Related API: [physicsObstacles2D](/reference/functions/physics-obstacles/), [PibblPhysicsWorldHandle2D](/reference/types/physics-2d/#pibblphysicsworldhandle2d).

### Parameters

- **`world`** — World supplying collider geometry. See [PibblPhysicsWorldHandle2D](/reference/types/physics-2d/#pibblphysicsworldhandle2d).

### Returns

An obstacle source whose read method returns the current revision and packed geometry.

### See also

[PibblPhysicsWorldHandle2D](/reference/types/physics-2d/#pibblphysicsworldhandle2d)

[View source — packages/core/src/features/physics/2d.ts:439](/source/packages/core/src/features/physics/2d-ts/#L439)

## Implementation guidance for agents

Read the [Physics and geometry companion](/agents/topics/physics/) for ownership, adaptation, failure modes, and verification. [Agent start](/agents/) provides the version-selection workflow.

## Complete minimal examples

- [World queries](/minimal-examples/physics/runtime-queries/): Query a static collider by ray, moving shape, overlap, point, and bounds. [Plain source](/minimal/physics/runtime-queries.tsx)
## Interactive examples

- [Embers Physics](/examples/embers-physics/) · [Full page](/experience/embers-physics/)
## Documentation version

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.
