onephysicsDocs
onephysics docs
Everything about OnePhysics: getting started, the three tiers, events, queries and layers, rollback and lockstep, determinism, units and limits, soft bodies, and coming from Unity. OnePhysics is a preview: 0.4.0-preview.1.
Start
Getting startedInstall the OnePhysics preview for .NET 10, drop a ball on the ground, walk a character, cast a ray, and take a snapshot and a world hash, with the same world state, bit for bit, on every platform.OverviewDeterministic 2D rigid-body physics for .NET, written from first principles: the same world state, bit for bit, on every platform, CPU, vector width and thread count. Package RecursiveAI.OnePhysics, built on onemath for its deterministic math.InstallThe package id is RecursiveAI.OnePhysics. Its only dependency is RecursiveAI.OneMath (the deterministic vectors and functions the API is written in: Vector2F, Vector2D, Vector3F, Vector3D), which NuGet restores for you.Quick startThe namespaces you import: RecursiveAI.OneMath for the vector types, RecursiveAI.OnePhysics for what both dimensions share (BodyType, EventKind, EventMask, exceptions, raw handles), and RecursiveAI.OnePhysics.Physics2D (or Physics3D) for the world, Body, Shape, Joint…The three tiersEach tier is built on the one below, so you can start at the top and drop down for one object without rewriting the rest.
Building a world
EventsA step produces events: contacts beginning and ending, sensor overlaps, sleeping and waking, joint breaks. They are collected during the step and delivered after it, in a fixed order that does not depend on threads or platform. You can consume them two ways.Queries and layersEvery shape has a layer, 0 to 31 (ShapeDef.Layer; body.Layer reads the first shape's layer and sets all of them, as Unity's per-object layer does). The world has a 32 x 32 matrix saying which layers collide; by default all do.Units and sizesThe full list of conventions, including handles and joint names, is in names and conventions.Input limitsInputs outside these limits are refused with a typed error that names the value and the limit; nothing is changed when an operation refuses.Names and conventionsOne place for the choices a host has to know. The two worlds (PhysicsWorld2D, PhysicsWorld3D) share every name here; only the math types differ.
Rollback and determinism
Rollback and lockstepA rollback host runs the same fixed-dt simulation on every peer, keeps a ring of recent snapshots, and when a late input arrives restores an old frame and resimulates. The world is built for it: snapshots are byte-exact, restores are atomic, and a world hash per step lets…DeterminismThe repository's hash-matrix tool steps its scenes and compares the per-step world hash across x64 and arm64, scalar and every vector width, one thread and all cores, JIT and NativeAOT, and WebAssembly. ../spec/hash-matrix.md describes it and ../spec/architecture.md defines…
Reference
Guide mapTask-oriented pages with examples that are compiled and run by the test suite. For the exact members, read the XML documentation in your editor. The normative, bit-level descriptions for ports live in ../spec.ChangelogWhat changed for hosts in each preview, newest first. "Moved results" lists the changes that alter a world's state after the same inputs (and so its snapshot bytes and world hashes).