PerthThe worklog
An open-world game, built in the open
Credits & data

Worklog › Code

Measured

Collision is baked for each cell and attached in microseconds

Collision for a cell is one Box3D compound, baked offline. At run time it is loaded from bytes and checked on a worker thread, then attached on the physics thread as one body in one step.

1,000 instances3,00010,000
Compound: children, size126, 102 KiB376, 296 KiB1,251, 976 KiB
Check on a worker3 µs5 to 7 µs32 to 41 µs
Attach, mean / longest2 to 3 µs / 26 µs3 to 5 µs / 27 µs5 to 6 µs / 25 µs
Detach, mean / longest1 µs / 6 µs1 to 2 µs / 6 µs2 µs / 11 µs

Attaching does not grow with what is in the cell. In the test, 200 balls were dropped on each cell while cells came and went; none went through the ground. In the largest cell two rolled off the edge in ten seconds, which the test now tells apart from falling through.

One caution about our own numbers: the physics step timings taken alongside were measured in an order that makes them unreliable, so they are not quoted here. The attach and detach times are direct.

On disk, a baked Box3D triangle costs 43 bytes and a box about 108. That turned out to matter more than expected: see the measured cell of suburb.

Never tried under a car. The test cells are 128 ground triangles and boxes; a cell of real triangle meshes is larger and was not attached in this test.