Table of Contents

Class NativeInterop

Namespace
Box3D.Interop
Assembly
Box3D.NET.dll

Conversions between the types of Box3D and the raw identifiers of Box3D.Native.

public static class NativeInterop

Inheritance

Inherited Members

Examples

Setting a debug name, which the high-level API does not expose:

using Box3D;
using Box3D.Interop;
using Box3D.Native;

Body body = world.CreateDynamicBody(position);

unsafe
{
    fixed (byte* name = "player\0"u8)
    {
        B3.b3Body_SetName(body.ToNativeId(), name);
    }
}

Going the other way, when a native callback hands back a raw identifier:

b3ShapeId raw = /* from a native query */;
Shape shape = raw.ToShape();

Remarks

These live in their own namespace so that reaching for the C API is a deliberate act. The main surface never mentions a native type, which keeps the two layers independent: Box3D.NET can change how it represents a body without that being a breaking change for anyone who never imported this namespace, and nothing about the C ABI leaks into ordinary application code.

The escape hatch exists because a thin wrapper should never be a ceiling. Box3D exports around 580 functions and the idiomatic surface deliberately does not cover all of them; when you need one that is missing, convert the handle and call it, rather than waiting for this library to catch up.

Nothing here validates anything. Converting a stale or foreign handle produces a value the C API will reject or, worse, silently misuse.

Methods

ToBody(b3BodyId)

Wraps a native body identifier.

ToJoint(b3JointId)

Wraps a native joint identifier.

ToNativeId(PhysicsWorld)

Gets the native identifier of a world.

ToNativeId(Body)

Gets the native identifier of a body.

ToNativeId(Shape)

Gets the native identifier of a shape.

ToNativeId(Joint)

Gets the native identifier of a joint.

ToNativePointer(CompoundGeometry)

Gets the native pointer of a baked compound.

ToShape(b3ShapeId)

Wraps a native shape identifier.