mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
177 lines
7.7 KiB
C#
177 lines
7.7 KiB
C#
// <auto-generated/>
|
|
// Generated by Brutal.Jolt.Generate; do not edit by hand.
|
|
#nullable enable
|
|
|
|
using System.Runtime.CompilerServices;
|
|
using Brutal.Interop;
|
|
using Brutal.Numerics;
|
|
|
|
namespace Brutal.JoltApi
|
|
{
|
|
/// <summary>
|
|
/// <para>
|
|
/// Base class interface for locking a body. Usually you will use BodyLockRead / BodyLockWrite /
|
|
/// BodyLockMultiRead / BodyLockMultiWrite instead.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Body/BodyLockInterface.h#L16">Jolt/Physics/Body/BodyLockInterface.h:16</see>
|
|
/// <br/>
|
|
/// <c>class BodyLockInterface : public NonCopyable</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[InteropHandle]
|
|
public readonly partial struct BodyLockInterface
|
|
{
|
|
/// <summary>
|
|
/// <para>
|
|
/// Convert body ID to body
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Physics/Body/BodyLockInterface.h#L50">Jolt/Physics/Body/BodyLockInterface.h:50</see>
|
|
/// <br/>
|
|
/// <c>inline Body * TryGetBody(const BodyID &inBodyID) const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The returned handle is borrowed from its owner; don't Dispose it.
|
|
/// </para>
|
|
/// </remarks>
|
|
public Body TryGetBody(uint bodyID) => Jolt.PInvoke.BodyLockInterface_TryGetBody(this, bodyID);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Reads the world transform of every body in bodyIDs into transforms, taking the body locks once for the
|
|
/// whole set rather than once per body - what a render loop reading back many bodies wants. An ID that no
|
|
/// longer names a body (removed, or a stale sequence number) reads back as the identity, the same as
|
|
/// BodyInterface does. Only as many elements as there are IDs are written.
|
|
/// </para>
|
|
/// </summary>
|
|
public unsafe void GetWorldTransforms(ReadOnlySpan<uint> bodyIDs, Span<float4x4> transforms)
|
|
{
|
|
fixed (float4x4* transforms_fixed = transforms)
|
|
fixed (uint* bodyIDs_fixed = bodyIDs)
|
|
{
|
|
if (transforms.Length < bodyIDs.Length)
|
|
throw new ArgumentException(
|
|
"transforms must hold at least one element per body ID.",
|
|
nameof(transforms)
|
|
);
|
|
Jolt.PInvoke.BodyLockInterface_GetWorldTransforms(
|
|
this,
|
|
bodyIDs_fixed,
|
|
(nuint)bodyIDs.Length,
|
|
transforms_fixed,
|
|
(nuint)transforms.Length
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Reads the position and rotation of every body in bodyIDs into positions and rotations, taking the body
|
|
/// locks once for the whole set rather than once per body. An ID that no longer names a body (removed, or a
|
|
/// stale sequence number) reads back as the origin and the identity rotation, the same as BodyInterface
|
|
/// does. Only as many elements as there are IDs are written.
|
|
/// </para>
|
|
/// </summary>
|
|
public unsafe void GetPositionsAndRotations(
|
|
ReadOnlySpan<uint> bodyIDs,
|
|
Span<float3> positions,
|
|
Span<floatQuat> rotations
|
|
)
|
|
{
|
|
fixed (floatQuat* rotations_fixed = rotations)
|
|
fixed (float3* positions_fixed = positions)
|
|
fixed (uint* bodyIDs_fixed = bodyIDs)
|
|
{
|
|
if (positions.Length < bodyIDs.Length)
|
|
throw new ArgumentException(
|
|
"positions must hold at least one element per body ID.",
|
|
nameof(positions)
|
|
);
|
|
if (rotations.Length < bodyIDs.Length)
|
|
throw new ArgumentException(
|
|
"rotations must hold at least one element per body ID.",
|
|
nameof(rotations)
|
|
);
|
|
Jolt.PInvoke.BodyLockInterface_GetPositionsAndRotations(
|
|
this,
|
|
bodyIDs_fixed,
|
|
(nuint)bodyIDs.Length,
|
|
positions_fixed,
|
|
(nuint)positions.Length,
|
|
rotations_fixed,
|
|
(nuint)rotations.Length
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Reads the linear and angular velocity of every body in bodyIDs, taking the body locks once for the whole
|
|
/// set rather than once per body. A static body reads as zero, as it does one at a time. An ID that no
|
|
/// longer names a body (removed, or a stale sequence number) reads back as zero, the same as BodyInterface
|
|
/// does. Only as many elements as there are IDs are written.
|
|
/// </para>
|
|
/// </summary>
|
|
public unsafe void GetLinearAndAngularVelocities(
|
|
ReadOnlySpan<uint> bodyIDs,
|
|
Span<float3> linearVelocities,
|
|
Span<float3> angularVelocities
|
|
)
|
|
{
|
|
fixed (float3* angularVelocities_fixed = angularVelocities)
|
|
fixed (float3* linearVelocities_fixed = linearVelocities)
|
|
fixed (uint* bodyIDs_fixed = bodyIDs)
|
|
{
|
|
if (linearVelocities.Length < bodyIDs.Length)
|
|
throw new ArgumentException(
|
|
"linearVelocities must hold at least one element per body ID.",
|
|
nameof(linearVelocities)
|
|
);
|
|
if (angularVelocities.Length < bodyIDs.Length)
|
|
throw new ArgumentException(
|
|
"angularVelocities must hold at least one element per body ID.",
|
|
nameof(angularVelocities)
|
|
);
|
|
Jolt.PInvoke.BodyLockInterface_GetLinearAndAngularVelocities(
|
|
this,
|
|
bodyIDs_fixed,
|
|
(nuint)bodyIDs.Length,
|
|
linearVelocities_fixed,
|
|
(nuint)linearVelocities.Length,
|
|
angularVelocities_fixed,
|
|
(nuint)angularVelocities.Length
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Reads the position, rotation, velocities, user data and activation of every body in bodyIDs into states,
|
|
/// taking the body locks once for the whole set - one pass where syncing a snapshot would otherwise take a
|
|
/// pose read, a velocity read and a per-body activation query. An ID that no longer names a body reads as
|
|
/// the origin at rest with BodyStateFlags.Valid clear. Only as many elements as there are IDs are written.
|
|
/// </para>
|
|
/// </summary>
|
|
public unsafe void GetBodyStates(ReadOnlySpan<uint> bodyIDs, Span<BodyState> states)
|
|
{
|
|
fixed (BodyState* states_fixed = states)
|
|
fixed (uint* bodyIDs_fixed = bodyIDs)
|
|
{
|
|
if (states.Length < bodyIDs.Length)
|
|
throw new ArgumentException("states must hold at least one element per body ID.", nameof(states));
|
|
Jolt.PInvoke.BodyLockInterface_GetBodyStates(
|
|
this,
|
|
bodyIDs_fixed,
|
|
(nuint)bodyIDs.Length,
|
|
states_fixed,
|
|
(nuint)states.Length
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|