mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
717 lines
36 KiB
C#
717 lines
36 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>
|
|
/// Class that is able to map a low detail (ragdoll) skeleton to a high detail (animation) skeleton and vice
|
|
/// versa
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L13">Jolt/Skeleton/SkeletonMapper.h:13</see>
|
|
/// <br/>
|
|
/// <c>class SkeletonMapper : public RefTarget<SkeletonMapper></c>
|
|
/// </para>
|
|
/// </summary>
|
|
[InteropHandle]
|
|
public readonly partial struct SkeletonMapper : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// <para>
|
|
/// A joint that maps 1-on-1 to a joint in the other skeleton
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L17">Jolt/Skeleton/SkeletonMapper.h:17</see>
|
|
/// <br/>
|
|
/// <c>class Mapping</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Explicit, Size = 144)]
|
|
public partial struct Mapping
|
|
{
|
|
/// <summary>
|
|
/// <para>
|
|
/// Index of joint from skeleton 1
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L27">Jolt/Skeleton/SkeletonMapper.h:27</see>
|
|
/// <br/>
|
|
/// <c>int mJointIdx1</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[FieldOffset(0)]
|
|
public int JointIdx1;
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Corresponding index of joint from skeleton 2
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L28">Jolt/Skeleton/SkeletonMapper.h:28</see>
|
|
/// <br/>
|
|
/// <c>int mJointIdx2</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[FieldOffset(4)]
|
|
public int JointIdx2;
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Transforms this joint from skeleton 1 to 2
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L29">Jolt/Skeleton/SkeletonMapper.h:29</see>
|
|
/// <br/>
|
|
/// <c>Mat44 mJoint1To2</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[FieldOffset(16)]
|
|
public float4x4 Joint1To2;
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Inverse of the transform above
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L30">Jolt/Skeleton/SkeletonMapper.h:30</see>
|
|
/// <br/>
|
|
/// <c>Mat44 mJoint2To1</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[FieldOffset(80)]
|
|
public float4x4 Joint2To1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Joints that could not be mapped from skeleton 1 to 2
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L45">Jolt/Skeleton/SkeletonMapper.h:45</see>
|
|
/// <br/>
|
|
/// <c>class Unmapped</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Explicit, Size = 8)]
|
|
public partial struct Unmapped
|
|
{
|
|
/// <summary>
|
|
/// <para>
|
|
/// Joint index of unmappable joint
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L51">Jolt/Skeleton/SkeletonMapper.h:51</see>
|
|
/// <br/>
|
|
/// <c>int mJointIdx</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[FieldOffset(0)]
|
|
public int JointIdx;
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Parent joint index of unmappable joint
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L52">Jolt/Skeleton/SkeletonMapper.h:52</see>
|
|
/// <br/>
|
|
/// <c>int mParentJointIdx</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[FieldOffset(4)]
|
|
public int ParentJointIdx;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Joints that should have their translation locked (fixed)
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L56">Jolt/Skeleton/SkeletonMapper.h:56</see>
|
|
/// <br/>
|
|
/// <c>class Locked</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[StructLayout(LayoutKind.Explicit, Size = 32)]
|
|
public partial struct Locked
|
|
{
|
|
/// <summary>
|
|
/// <para>
|
|
/// Joint index of joint with locked translation (in skeleton 2)
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L59">Jolt/Skeleton/SkeletonMapper.h:59</see>
|
|
/// <br/>
|
|
/// <c>int mJointIdx</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[FieldOffset(0)]
|
|
public int JointIdx;
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Parent joint index of joint with locked translation (in skeleton 2)
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L60">Jolt/Skeleton/SkeletonMapper.h:60</see>
|
|
/// <br/>
|
|
/// <c>int mParentJointIdx</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[FieldOffset(4)]
|
|
public int ParentJointIdx;
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Translation of neutral pose
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L61">Jolt/Skeleton/SkeletonMapper.h:61</see>
|
|
/// <br/>
|
|
/// <c>Vec3 mTranslation</c>
|
|
/// </para>
|
|
/// </summary>
|
|
[FieldOffset(16)]
|
|
public float3 Translation;
|
|
}
|
|
|
|
public static SkeletonMapper Create() => Jolt.PInvoke.SkeletonMapper_Create();
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Default function that checks if the names of the joints are equal
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L68">Jolt/Skeleton/SkeletonMapper.h:68</see>
|
|
/// <br/>
|
|
/// <c>static bool sDefaultCanMapJoint(const Skeleton *inSkeleton1, int inIndex1, const Skeleton *inSkeleton2, int inIndex2)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public static bool DefaultCanMapJoint(Skeleton skeleton1, int index1, Skeleton skeleton2, int index2) =>
|
|
Jolt.PInvoke.SkeletonMapper_DefaultCanMapJoint(skeleton1, index1, skeleton2, index2);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Initialize the skeleton mapper. Skeleton 1 should be the (low detail) ragdoll skeleton and skeleton 2
|
|
/// the (high detail) animation skeleton. We assume that each joint in skeleton 1 can be mapped to a joint
|
|
/// in skeleton 2 (if not mapping from animation skeleton to ragdoll skeleton will be undefined). Skeleton 2
|
|
/// should have the same hierarchy as skeleton 1 but can contain extra joints between those in skeleton 1
|
|
/// and it can have extra joints at the root and leaves of the skeleton.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L81">Jolt/Skeleton/SkeletonMapper.h:81</see>
|
|
/// <br/>
|
|
/// <c>void Initialize(const Skeleton *inSkeleton1, const Mat44 *inNeutralPose1, const Skeleton *inSkeleton2, const Mat44 *inNeutralPose2, const CanMapJoint &inCanMapJoint = sDefaultCanMapJoint)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// Initialize the skeleton mapper. Skeleton 1 should be the (low detail) ragdoll skeleton and skeleton 2 the (high detail) animation skeleton.
|
|
/// We assume that each joint in skeleton 1 can be mapped to a joint in skeleton 2 (if not mapping from animation skeleton to ragdoll skeleton will be undefined).
|
|
/// Skeleton 2 should have the same hierarchy as skeleton 1 but can contain extra joints between those in skeleton 1 and it can have extra joints at the root and leaves of the skeleton.
|
|
/// @param inSkeleton1 Source skeleton to map from.
|
|
/// @param inNeutralPose1 Neutral pose of the source skeleton (model space)
|
|
/// @param inSkeleton2 Target skeleton to map to.
|
|
/// @param inNeutralPose2 Neutral pose of the target skeleton (model space), inNeutralPose1 and inNeutralPose2 must match as closely as possible, preferably the position of the mappable joints should be identical.
|
|
/// @param inCanMapJoint Function that checks if joints in skeleton 1 and skeleton 2 are equal.
|
|
/// </code>
|
|
/// <para>
|
|
/// neutralPose1 must hold exactly one element per joint in skeleton 1 - the native count is read from the
|
|
/// object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is only used
|
|
/// for the duration of the call. A null skeleton1 throws ArgumentNullException. Throws ArgumentException
|
|
/// for skeleton1: "skeleton1 has a joint whose parent index isn't an earlier joint - parents must come
|
|
/// first, as Jolt requires."
|
|
/// </para>
|
|
/// <para>
|
|
/// neutralPose2 must hold exactly one element per joint in skeleton 2 - the native count is read from the
|
|
/// object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is only used
|
|
/// for the duration of the call. A null skeleton2 throws ArgumentNullException. Throws ArgumentException
|
|
/// for skeleton2: "skeleton2 has a joint whose parent index isn't an earlier joint - parents must come
|
|
/// first, as Jolt requires."
|
|
/// </para>
|
|
/// <para>
|
|
/// canMapJoint: The callback is invoked from native code: it must be a static method marked
|
|
/// [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])], and userData is passed back to it verbatim.
|
|
/// Pass null for Jolt's default (SkeletonMapper::sDefaultCanMapJoint). The callback and userData are used
|
|
/// only for the duration of this call; userData may be freed when it returns.
|
|
/// </para>
|
|
/// </remarks>
|
|
public unsafe void Initialize(
|
|
Skeleton skeleton1,
|
|
ReadOnlySpan<float4x4> neutralPose1,
|
|
Skeleton skeleton2,
|
|
ReadOnlySpan<float4x4> neutralPose2,
|
|
delegate* unmanaged[Cdecl]<Skeleton, int, Skeleton, int, nint, Brutal.Bool8> canMapJoint,
|
|
nint canMapJointUserData
|
|
)
|
|
{
|
|
fixed (float4x4* neutralPose2_fixed = neutralPose2)
|
|
fixed (float4x4* neutralPose1_fixed = neutralPose1)
|
|
{
|
|
Jolt.PInvoke.SkeletonMapper_Initialize(
|
|
this,
|
|
skeleton1,
|
|
neutralPose1_fixed,
|
|
(uint)neutralPose1.Length,
|
|
skeleton2,
|
|
neutralPose2_fixed,
|
|
(uint)neutralPose2.Length,
|
|
canMapJoint,
|
|
canMapJointUserData,
|
|
out var _bufferCheck
|
|
);
|
|
if (_bufferCheck == 1)
|
|
throw new ArgumentNullException(nameof(skeleton1), "The skeleton handle is null.");
|
|
if (_bufferCheck == 2)
|
|
throw new ArgumentException(
|
|
"skeleton1 has a joint whose parent index isn't an earlier joint - parents must come first, as Jolt requires.",
|
|
nameof(skeleton1)
|
|
);
|
|
if (_bufferCheck == 3)
|
|
throw new ArgumentNullException(nameof(skeleton2), "The skeleton handle is null.");
|
|
if (_bufferCheck == 4)
|
|
throw new ArgumentException(
|
|
"skeleton2 has a joint whose parent index isn't an earlier joint - parents must come first, as Jolt requires.",
|
|
nameof(skeleton2)
|
|
);
|
|
if (_bufferCheck == 5)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(neutralPose1),
|
|
neutralPose1.Length,
|
|
"Expected one element per joint in skeleton 1."
|
|
);
|
|
if (_bufferCheck == 6)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(neutralPose2),
|
|
neutralPose2.Length,
|
|
"Expected one element per joint in skeleton 2."
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// This can be called so lock the translation of a specified set of joints in skeleton 2. Because
|
|
/// constraints are never 100% rigid, there's always a little bit of stretch in the ragdoll when the ragdoll
|
|
/// is under stress. Locking the translations of the pose will remove the visual stretch from the ragdoll
|
|
/// but will introduce a difference between the physical simulation and the visual representation.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L90">Jolt/Skeleton/SkeletonMapper.h:90</see>
|
|
/// <br/>
|
|
/// <c>void LockTranslations(const Skeleton *inSkeleton2, const bool *inLockedTranslations, const Mat44 *inNeutralPose2)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// This can be called so lock the translation of a specified set of joints in skeleton 2.
|
|
/// Because constraints are never 100% rigid, there's always a little bit of stretch in the ragdoll when the ragdoll is under stress.
|
|
/// Locking the translations of the pose will remove the visual stretch from the ragdoll but will introduce a difference between the
|
|
/// physical simulation and the visual representation.
|
|
/// @param inSkeleton2 Target skeleton to map to.
|
|
/// @param inLockedTranslations An array of bools the size of inSkeleton2->GetJointCount(), for each joint indicating if the joint is locked.
|
|
/// @param inNeutralPose2 Neutral pose to take reference translations from
|
|
/// </code>
|
|
/// <para>
|
|
/// lockedTranslations must hold exactly one element per joint in skeleton 2 - the native count is read from
|
|
/// the object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is only
|
|
/// used for the duration of the call. A null skeleton2 throws ArgumentNullException. Throws
|
|
/// ArgumentException for skeleton2: "skeleton2 has a joint whose parent index isn't an earlier joint -
|
|
/// parents must come first, as Jolt requires." Throws ArgumentException for lockedTranslations: "A root
|
|
/// joint (one with no parent) can't have its translation locked - it positions the whole skeleton."
|
|
/// </para>
|
|
/// <para>
|
|
/// neutralPose2 must hold exactly one element per joint in skeleton 2 - the native count is read from the
|
|
/// object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is only used
|
|
/// for the duration of the call. A null skeleton2 throws ArgumentNullException.
|
|
/// </para>
|
|
/// </remarks>
|
|
public unsafe void LockTranslations(
|
|
Skeleton skeleton2,
|
|
ReadOnlySpan<bool> lockedTranslations,
|
|
ReadOnlySpan<float4x4> neutralPose2
|
|
)
|
|
{
|
|
fixed (float4x4* neutralPose2_fixed = neutralPose2)
|
|
fixed (bool* lockedTranslations_fixed = lockedTranslations)
|
|
{
|
|
Jolt.PInvoke.SkeletonMapper_LockTranslations(
|
|
this,
|
|
skeleton2,
|
|
lockedTranslations_fixed,
|
|
(uint)lockedTranslations.Length,
|
|
neutralPose2_fixed,
|
|
(uint)neutralPose2.Length,
|
|
out var _bufferCheck
|
|
);
|
|
if (_bufferCheck == 1)
|
|
throw new ArgumentNullException(nameof(skeleton2), "The skeleton handle is null.");
|
|
if (_bufferCheck == 2)
|
|
throw new ArgumentException(
|
|
"skeleton2 has a joint whose parent index isn't an earlier joint - parents must come first, as Jolt requires.",
|
|
nameof(skeleton2)
|
|
);
|
|
if (_bufferCheck == 3)
|
|
throw new ArgumentException(
|
|
"A root joint (one with no parent) can't have its translation locked - it positions the whole skeleton.",
|
|
nameof(lockedTranslations)
|
|
);
|
|
if (_bufferCheck == 4)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(lockedTranslations),
|
|
lockedTranslations.Length,
|
|
"Expected one element per joint in skeleton 2."
|
|
);
|
|
if (_bufferCheck == 5)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(neutralPose2),
|
|
neutralPose2.Length,
|
|
"Expected one element per joint in skeleton 2."
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// After Initialize(), this can be called to lock the translation of all joints in skeleton 2 below the
|
|
/// first mapped joint to those of the neutral pose. Because constraints are never 100% rigid, there's
|
|
/// always a little bit of stretch in the ragdoll when the ragdoll is under stress. Locking the translations
|
|
/// of the pose will remove the visual stretch from the ragdoll but will introduce a difference between the
|
|
/// physical simulation and the visual representation.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L98">Jolt/Skeleton/SkeletonMapper.h:98</see>
|
|
/// <br/>
|
|
/// <c>void LockAllTranslations(const Skeleton *inSkeleton2, const Mat44 *inNeutralPose2)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// After Initialize(), this can be called to lock the translation of all joints in skeleton 2 below the first mapped joint to those of the neutral pose.
|
|
/// Because constraints are never 100% rigid, there's always a little bit of stretch in the ragdoll when the ragdoll is under stress.
|
|
/// Locking the translations of the pose will remove the visual stretch from the ragdoll but will introduce a difference between the
|
|
/// physical simulation and the visual representation.
|
|
/// @param inSkeleton2 Target skeleton to map to.
|
|
/// @param inNeutralPose2 Neutral pose to take reference translations from
|
|
/// </code>
|
|
/// <para>
|
|
/// neutralPose2 must hold exactly one element per joint in skeleton 2 - the native count is read from the
|
|
/// object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is only used
|
|
/// for the duration of the call. A null skeleton2 throws ArgumentNullException. Throws ArgumentException
|
|
/// for skeleton2: "skeleton2 has a joint whose parent index isn't an earlier joint - parents must come
|
|
/// first, as Jolt requires." Throws InvalidOperationException: "The mapper has no mappings. Call Initialize
|
|
/// first." Throws ArgumentException for skeleton2: "skeleton2 is not the skeleton the mapper was
|
|
/// initialised with."
|
|
/// </para>
|
|
/// </remarks>
|
|
public unsafe void LockAllTranslations(Skeleton skeleton2, ReadOnlySpan<float4x4> neutralPose2)
|
|
{
|
|
fixed (float4x4* neutralPose2_fixed = neutralPose2)
|
|
{
|
|
Jolt.PInvoke.SkeletonMapper_LockAllTranslations(
|
|
this,
|
|
skeleton2,
|
|
neutralPose2_fixed,
|
|
(uint)neutralPose2.Length,
|
|
out var _bufferCheck
|
|
);
|
|
if (_bufferCheck == 1)
|
|
throw new ArgumentNullException(nameof(skeleton2), "The skeleton handle is null.");
|
|
if (_bufferCheck == 2)
|
|
throw new ArgumentException(
|
|
"skeleton2 has a joint whose parent index isn't an earlier joint - parents must come first, as Jolt requires.",
|
|
nameof(skeleton2)
|
|
);
|
|
if (_bufferCheck == 3)
|
|
throw new InvalidOperationException("The mapper has no mappings. Call Initialize first.");
|
|
if (_bufferCheck == 4)
|
|
throw new ArgumentException(
|
|
"skeleton2 is not the skeleton the mapper was initialised with.",
|
|
nameof(skeleton2)
|
|
);
|
|
if (_bufferCheck == 5)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(neutralPose2),
|
|
neutralPose2.Length,
|
|
"Expected one element per joint in skeleton 2."
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Map a pose. Joints that were directly mappable will be copied in model space from pose 1 to pose 2. Any
|
|
/// joints that are only present in skeleton 2 will get their model space transform calculated through the
|
|
/// local space transforms of pose 2. Joints that are part of a joint chain between two mapped joints will
|
|
/// be reoriented towards the next joint in skeleton 1. This means that it is possible for unmapped joints
|
|
/// to have some animation, but very extreme animation poses will show artifacts.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L107">Jolt/Skeleton/SkeletonMapper.h:107</see>
|
|
/// <br/>
|
|
/// <c>void Map(const Mat44 *inPose1ModelSpace, const Mat44 *inPose2LocalSpace, Mat44 *outPose2ModelSpace) const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// Map a pose. Joints that were directly mappable will be copied in model space from pose 1 to pose 2. Any joints that are only present in skeleton 2
|
|
/// will get their model space transform calculated through the local space transforms of pose 2. Joints that are part of a joint chain between two
|
|
/// mapped joints will be reoriented towards the next joint in skeleton 1. This means that it is possible for unmapped joints to have some animation,
|
|
/// but very extreme animation poses will show artifacts.
|
|
/// @param inPose1ModelSpace Pose on skeleton 1 in model space
|
|
/// @param inPose2LocalSpace Pose on skeleton 2 in local space (used for the joints that cannot be mapped)
|
|
/// @param outPose2ModelSpace Model space pose on skeleton 2 (the output of the mapping)
|
|
/// </code>
|
|
/// <para>
|
|
/// pose1ModelSpace must hold at least one element per mapped joint of skeleton 1 - the native count is read
|
|
/// from the object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is
|
|
/// only used for the duration of the call. Throws InvalidOperationException: "The mapper holds a negative
|
|
/// joint index. Only an unmapped joint's ParentJointIdx may be -1."
|
|
/// </para>
|
|
/// <para>
|
|
/// pose2LocalSpace must hold at least one element per joint of skeleton 2 - the native count is read from
|
|
/// the object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is only
|
|
/// used for the duration of the call.
|
|
/// </para>
|
|
/// <para>
|
|
/// pose2ModelSpace must hold at least one element per joint of skeleton 2 - the native count is read from
|
|
/// the object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is only
|
|
/// used for the duration of the call.
|
|
/// </para>
|
|
/// </remarks>
|
|
public unsafe void Map(
|
|
ReadOnlySpan<float4x4> pose1ModelSpace,
|
|
ReadOnlySpan<float4x4> pose2LocalSpace,
|
|
Span<float4x4> pose2ModelSpace
|
|
)
|
|
{
|
|
fixed (float4x4* pose2ModelSpace_fixed = pose2ModelSpace)
|
|
fixed (float4x4* pose2LocalSpace_fixed = pose2LocalSpace)
|
|
fixed (float4x4* pose1ModelSpace_fixed = pose1ModelSpace)
|
|
{
|
|
Jolt.PInvoke.SkeletonMapper_Map(
|
|
this,
|
|
pose1ModelSpace_fixed,
|
|
(uint)pose1ModelSpace.Length,
|
|
pose2LocalSpace_fixed,
|
|
(uint)pose2LocalSpace.Length,
|
|
pose2ModelSpace_fixed,
|
|
(uint)pose2ModelSpace.Length,
|
|
out var _bufferCheck
|
|
);
|
|
if (_bufferCheck == 1)
|
|
throw new InvalidOperationException(
|
|
"The mapper holds a negative joint index. Only an unmapped joint's ParentJointIdx may be -1."
|
|
);
|
|
if (_bufferCheck == 2)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(pose1ModelSpace),
|
|
pose1ModelSpace.Length,
|
|
"Expected at least one element per mapped joint of skeleton 1."
|
|
);
|
|
if (_bufferCheck == 3)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(pose2LocalSpace),
|
|
pose2LocalSpace.Length,
|
|
"Expected at least one element per joint of skeleton 2."
|
|
);
|
|
if (_bufferCheck == 4)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(pose2ModelSpace),
|
|
pose2ModelSpace.Length,
|
|
"Expected at least one element per joint of skeleton 2."
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Reverse map a pose, this will only use the mappings and not the chains (it assumes that all joints in
|
|
/// skeleton 1 are mapped)
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L112">Jolt/Skeleton/SkeletonMapper.h:112</see>
|
|
/// <br/>
|
|
/// <c>void MapReverse(const Mat44 *inPose2ModelSpace, Mat44 *outPose1ModelSpace) const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// Reverse map a pose, this will only use the mappings and not the chains (it assumes that all joints in skeleton 1 are mapped)
|
|
/// @param inPose2ModelSpace Model space pose on skeleton 2
|
|
/// @param outPose1ModelSpace When the function returns this will contain the model space pose for skeleton 1
|
|
/// </code>
|
|
/// <para>
|
|
/// pose2ModelSpace must hold at least one element per joint of skeleton 2 - the native count is read from
|
|
/// the object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is only
|
|
/// used for the duration of the call. Throws InvalidOperationException: "The mapper holds a negative joint
|
|
/// index. Only an unmapped joint's ParentJointIdx may be -1."
|
|
/// </para>
|
|
/// <para>
|
|
/// pose1ModelSpace must hold at least one element per mapped joint of skeleton 1 - the native count is read
|
|
/// from the object itself and a span that doesn't match it throws ArgumentOutOfRangeException. The span is
|
|
/// only used for the duration of the call.
|
|
/// </para>
|
|
/// </remarks>
|
|
public unsafe void MapReverse(ReadOnlySpan<float4x4> pose2ModelSpace, Span<float4x4> pose1ModelSpace)
|
|
{
|
|
fixed (float4x4* pose1ModelSpace_fixed = pose1ModelSpace)
|
|
fixed (float4x4* pose2ModelSpace_fixed = pose2ModelSpace)
|
|
{
|
|
Jolt.PInvoke.SkeletonMapper_MapReverse(
|
|
this,
|
|
pose2ModelSpace_fixed,
|
|
(uint)pose2ModelSpace.Length,
|
|
pose1ModelSpace_fixed,
|
|
(uint)pose1ModelSpace.Length,
|
|
out var _bufferCheck
|
|
);
|
|
if (_bufferCheck == 1)
|
|
throw new InvalidOperationException(
|
|
"The mapper holds a negative joint index. Only an unmapped joint's ParentJointIdx may be -1."
|
|
);
|
|
if (_bufferCheck == 2)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(pose2ModelSpace),
|
|
pose2ModelSpace.Length,
|
|
"Expected at least one element per joint of skeleton 2."
|
|
);
|
|
if (_bufferCheck == 3)
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(pose1ModelSpace),
|
|
pose1ModelSpace.Length,
|
|
"Expected at least one element per mapped joint of skeleton 1."
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Search through the directly mapped joints (mMappings) and find inJoint1Idx, returns the corresponding
|
|
/// Joint2Idx or -1 if not found.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L115">Jolt/Skeleton/SkeletonMapper.h:115</see>
|
|
/// <br/>
|
|
/// <c>int GetMappedJointIdx(int inJoint1Idx) const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public int GetMappedJointIdx(int joint1Idx) => Jolt.PInvoke.SkeletonMapper_GetMappedJointIdx(this, joint1Idx);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Search through the locked translations (mLockedTranslations) and find if joint inJoint2Idx is locked.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L118">Jolt/Skeleton/SkeletonMapper.h:118</see>
|
|
/// <br/>
|
|
/// <c>bool IsJointTranslationLocked(int inJoint2Idx) const</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public bool IsJointTranslationLocked(int joint2Idx) =>
|
|
Jolt.PInvoke.SkeletonMapper_IsJointTranslationLocked(this, joint2Idx);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L128">Jolt/Skeleton/SkeletonMapper.h:128</see>
|
|
/// <br/>
|
|
/// <c>MappingVector & GetMappings()</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The span is a view of the container's own storage, not a copy, so it costs nothing to take. It's only
|
|
/// valid until that container is resized or its owner is destroyed.
|
|
/// </para>
|
|
/// </remarks>
|
|
[return: Brutal.Attributes.Fixed]
|
|
public unsafe ReadOnlySpan<SkeletonMapper.Mapping> GetMappings()
|
|
{
|
|
Jolt.PInvoke.SkeletonMapper_GetMappings(this, out var _outResult);
|
|
return new ReadOnlySpan<SkeletonMapper.Mapping>((void*)_outResult.Data, checked((int)_outResult.Count));
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L132">Jolt/Skeleton/SkeletonMapper.h:132</see>
|
|
/// <br/>
|
|
/// <c>UnmappedVector & GetUnmapped()</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The span is a view of the container's own storage, not a copy: edits land in the object that owns it.
|
|
/// It's only valid until that container is resized or its owner is destroyed.
|
|
/// </para>
|
|
/// </remarks>
|
|
[return: Brutal.Attributes.Fixed]
|
|
public unsafe Span<SkeletonMapper.Unmapped> GetUnmapped()
|
|
{
|
|
Jolt.PInvoke.SkeletonMapper_GetUnmapped(this, out var _outResult);
|
|
return new Span<SkeletonMapper.Unmapped>((void*)_outResult.Data, checked((int)_outResult.Count));
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Skeleton/SkeletonMapper.h#L134">Jolt/Skeleton/SkeletonMapper.h:134</see>
|
|
/// <br/>
|
|
/// <c>LockedVector & GetLockedTranslations()</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// The span is a view of the container's own storage, not a copy, so it costs nothing to take. It's only
|
|
/// valid until that container is resized or its owner is destroyed.
|
|
/// </para>
|
|
/// </remarks>
|
|
[return: Brutal.Attributes.Fixed]
|
|
public unsafe ReadOnlySpan<SkeletonMapper.Locked> GetLockedTranslations()
|
|
{
|
|
Jolt.PInvoke.SkeletonMapper_GetLockedTranslations(this, out var _outResult);
|
|
return new ReadOnlySpan<SkeletonMapper.Locked>((void*)_outResult.Data, checked((int)_outResult.Count));
|
|
}
|
|
|
|
public void AddRef() => Jolt.PInvoke.SkeletonMapper_AddRef(this);
|
|
|
|
public void Release() => Jolt.PInvoke.SkeletonMapper_Release(this);
|
|
|
|
public uint GetRefCount() => Jolt.PInvoke.SkeletonMapper_GetRefCount(this);
|
|
|
|
public void Dispose()
|
|
{
|
|
if (IsNull())
|
|
return;
|
|
Release();
|
|
}
|
|
}
|
|
}
|