//
// 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
{
///
///
/// Instance of a skeleton, contains the pose the current skeleton is in
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:17
///
/// class SkeletonPose
///
///
[InteropHandle]
public readonly partial struct SkeletonPose : IDisposable
{
///
///
/// Draw settings
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:64
///
/// struct DrawSettings
///
///
[StructLayout(LayoutKind.Explicit, Size = 3)]
public partial struct DrawSettings
{
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:66
///
/// bool mDrawJoints = true
///
///
[FieldOffset(0)]
public Brutal.Bool8 DrawJoints;
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:67
///
/// bool mDrawJointOrientations = true
///
///
[FieldOffset(1)]
public Brutal.Bool8 DrawJointOrientations;
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:68
///
/// bool mDrawJointNames = false
///
///
[FieldOffset(2)]
public Brutal.Bool8 DrawJointNames;
}
public static SkeletonPose Create() => Jolt.PInvoke.SkeletonPose_Create();
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:28
///
/// void SetSkeleton(const Skeleton *inSkeleton)
///
///
///
///
/// @name Skeleton
/// @{
///
///
public void SetSkeleton(Skeleton skeleton) => Jolt.PInvoke.SkeletonPose_SetSkeleton(this, skeleton);
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:29
///
/// const Skeleton * GetSkeleton() const
///
///
///
///
/// The returned handle carries its own reference; Dispose it once when you're done.
///
///
public Skeleton GetSkeleton() => Jolt.PInvoke.SkeletonPose_GetSkeleton(this);
///
///
/// Extra offset applied to the root (and therefore also to all of its children)
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:33
///
/// void SetRootOffset(RVec3Arg inOffset)
///
///
public void SetRootOffset(float3 offset) => Jolt.PInvoke.SkeletonPose_SetRootOffset(this, offset);
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:34
///
/// RVec3 GetRootOffset() const
///
///
public float3 GetRootOffset() => Jolt.PInvoke.SkeletonPose_GetRootOffset(this);
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:38
///
/// uint GetJointCount() const
///
///
///
///
/// @name Properties of the joints
/// @{
///
///
public uint GetJointCount() => Jolt.PInvoke.SkeletonPose_GetJointCount(this);
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:40
///
/// JointStateVector & GetJoints()
///
///
///
///
/// 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.
///
///
[return: Brutal.Attributes.Fixed]
public unsafe ReadOnlySpan GetJoints()
{
Jolt.PInvoke.SkeletonPose_GetJoints(this, out var _outResult);
return new ReadOnlySpan(
(void*)_outResult.Data,
checked((int)_outResult.Count)
);
}
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:42
///
/// JointState & GetJoint(int inJoint)
///
///
///
///
/// Writes value into the element GetJoint returns, in place. The C++ getter hands out a reference; the C#
/// GetJoint can only return a copy, so this is how an edit reaches the object.
///
///
public void SetJoint(int joint, in SkeletalAnimation.JointState value)
{
Jolt.PInvoke.SkeletonPose_SetJoint(this, joint, in value, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(joint),
joint,
"Expected an index below the number of joints in the pose."
);
}
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:48
///
/// Mat44Vector & GetJointMatrices()
///
///
///
///
/// 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.
///
///
[return: Brutal.Attributes.Fixed]
public unsafe Span GetJointMatrices()
{
Jolt.PInvoke.SkeletonPose_GetJointMatrices(this, out var _outResult);
return new Span((void*)_outResult.Data, checked((int)_outResult.Count));
}
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:49
///
/// const Mat44 & GetJointMatrix(int inJoint) const
///
///
public float4x4 GetJointMatrix(int joint)
{
var _result = Jolt.PInvoke.SkeletonPose_GetJointMatrix(this, joint, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(joint),
joint,
"Expected an index below the number of joint matrices."
);
return _result;
}
///
///
/// Convert the joint states to joint matrices
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:54
///
/// void CalculateJointMatrices()
///
///
public void CalculateJointMatrices() => Jolt.PInvoke.SkeletonPose_CalculateJointMatrices(this);
///
///
/// Convert joint matrices to joint states
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:57
///
/// void CalculateJointStates()
///
///
public void CalculateJointStates() => Jolt.PInvoke.SkeletonPose_CalculateJointStates(this);
///
///
/// Outputs the joint matrices in local space (ensure that outMatrices has GetJointCount() elements, assumes
/// that values in GetJoints() is up to date)
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:60
///
/// void CalculateLocalSpaceJointMatrices(Mat44 *outMatrices) const
///
///
///
///
/// matrices must hold exactly one element per joint in the pose - 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.
///
///
public unsafe void CalculateLocalSpaceJointMatrices(Span matrices)
{
fixed (float4x4* matrices_fixed = matrices)
{
Jolt.PInvoke.SkeletonPose_CalculateLocalSpaceJointMatrices(
this,
matrices_fixed,
(uint)matrices.Length,
out var _bufferCheck
);
if (_bufferCheck == 1)
throw new ArgumentOutOfRangeException(
nameof(matrices),
matrices.Length,
"Expected one element per joint in the pose."
);
}
}
///
///
/// Draw current pose
///
///
/// C++:
/// Jolt/Skeleton/SkeletonPose.h:72
///
/// void Draw(const DrawSettings &inDrawSettings, DebugRenderer *inRenderer, RMat44Arg inOffset = RMat44::sIdentity()) const
///
///
public void Draw(in SkeletonPose.DrawSettings drawSettings, DebugRenderer renderer, in float4x4 offset) =>
Jolt.PInvoke.SkeletonPose_Draw(this, in drawSettings, renderer, in offset);
public void Dispose() => Jolt.PInvoke.SkeletonPose_Destroy(this);
}
}