Method Draw<T>
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
Draw<T>(ref T, in DebugDrawOptions)
Emits the world's debug geometry to a drawer.
public void Draw<T>(ref T drawer, in DebugDrawOptions options) where T : struct, IDebugDrawerParameters
drawerT-
The drawer, passed by reference. Anything it accumulates during the call is visible on return.
optionsDebugDrawOptions-
What to draw. Everything is off by default.
Type Parameters
T-
The drawer. Constrained to a value type so that the calls stay devirtualised and nothing is boxed; put whatever state the renderer needs inside it, references included.
Examples
var drawer = new WireframeDrawer(renderer);
world.Draw(ref drawer, DebugDrawOptions.Default with
{
DrawJoints = true,
DrawContacts = true,
});
Remarks
Synchronous: every callback runs before this returns, on the calling thread. The drawer must not touch this world while it runs, for the same reason nothing may touch a world mid-step.
A frame allocates nothing on the managed heap, provided the drawer does not allocate itself.
Shapes are the one thing this does not draw. Box3D does not emit shape geometry as primitives: it asks the application to build a drawable once, through a callback on the world definition, hands back the opaque handle it returned, and expects the renderer to draw that handle at a transform. Those callbacks are set when the world is created and are not yet surfaced by this layer, so Box3D.DebugDrawOptions.DrawShapes currently produces nothing. Everything else — joints, contacts, normals, forces, bounding boxes, centres of mass, islands — is emitted in full.
Exceptions
- ObjectDisposedException
-
The world has been disposed.