//
// 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
{
///
///
/// Runtime ragdoll information
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:136
///
/// class Ragdoll : public RefTarget<Ragdoll>, public NonCopyable
///
///
[InteropHandle]
public readonly partial struct Ragdoll : IDisposable
{
///
///
/// Constructor
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:142
///
/// explicit Ragdoll(PhysicsSystem *inSystem)
///
///
public static Ragdoll Create(PhysicsSystem system) => Jolt.PInvoke.Ragdoll_Create(system);
///
///
/// Add bodies and constraints to the system and optionally activate the bodies
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:148
///
/// void AddToPhysicsSystem(EActivation inActivationMode, bool inLockBodies = true)
///
///
public void AddToPhysicsSystem(Activation activationMode, bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_AddToPhysicsSystem(this, activationMode, lockBodies);
///
///
/// Remove bodies and constraints from the system
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:151
///
/// void RemoveFromPhysicsSystem(bool inLockBodies = true)
///
///
public void RemoveFromPhysicsSystem(bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_RemoveFromPhysicsSystem(this, lockBodies);
///
///
/// Wake up all bodies in the ragdoll
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:154
///
/// void Activate(bool inLockBodies = true)
///
///
public void Activate(bool lockBodies = true) => Jolt.PInvoke.Ragdoll_Activate(this, lockBodies);
///
///
/// Check if one or more of the bodies in the ragdoll are active. Note that this involves locking the bodies
/// (if inLockBodies is true) and looping over them. An alternative and possibly faster way could be to
/// install a BodyActivationListener and count the number of active bodies of a ragdoll as they're activated
/// / deactivated (basically check if the body that activates / deactivates is in GetBodyIDs() and increment
/// / decrement a counter).
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:160
///
/// bool IsActive(bool inLockBodies = true) const
///
///
public bool IsActive(bool lockBodies = true) => Jolt.PInvoke.Ragdoll_IsActive(this, lockBodies);
///
///
/// Set the group ID on all bodies in the ragdoll
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:163
///
/// void SetGroupID(CollisionGroup::GroupID inGroupID, bool inLockBodies = true)
///
///
public void SetGroupID(uint groupID, bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_SetGroupID(this, groupID, lockBodies);
///
///
/// Set the ragdoll to a pose (calls BodyInterface::SetPositionAndRotation to instantly move the ragdoll)
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:166
///
/// void SetPose(const SkeletonPose &inPose, bool inLockBodies = true)
///
///
public void SetPose(SkeletonPose pose, bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_SetPose(this, pose, lockBodies);
///
///
/// Lower level version of SetPose that directly takes the world space joint matrices
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:169
///
/// void SetPose(RVec3Arg inRootOffset, const Mat44 *inJointMatrices, bool inLockBodies = true)
///
///
///
///
/// jointMatrices must hold exactly one element per body in the ragdoll - 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 SetPose(float3 rootOffset, ReadOnlySpan jointMatrices, bool lockBodies = true)
{
fixed (float4x4* jointMatrices_fixed = jointMatrices)
{
Jolt.PInvoke.Ragdoll_SetPose_2(
this,
rootOffset,
jointMatrices_fixed,
(uint)jointMatrices.Length,
lockBodies,
out var _bufferCheck
);
if (_bufferCheck == 1)
throw new ArgumentOutOfRangeException(
nameof(jointMatrices),
jointMatrices.Length,
"Expected one element per body in the ragdoll."
);
}
}
///
///
/// Get the ragdoll pose (uses the world transform of the bodies to calculate the pose)
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:172
///
/// void GetPose(SkeletonPose &outPose, bool inLockBodies = true)
///
///
public void GetPose(SkeletonPose pose, bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_GetPose(this, pose, lockBodies);
///
///
/// Lower level version of GetPose that directly returns the world space joint matrices
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:175
///
/// void GetPose(RVec3 &outRootOffset, Mat44 *outJointMatrices, bool inLockBodies = true)
///
///
///
///
/// jointMatrices must hold exactly one element per body in the ragdoll - 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 GetPose(out float3 rootOffset, Span jointMatrices, bool lockBodies = true)
{
fixed (float4x4* jointMatrices_fixed = jointMatrices)
{
Jolt.PInvoke.Ragdoll_GetPose_2(
this,
out rootOffset,
jointMatrices_fixed,
(uint)jointMatrices.Length,
lockBodies,
out var _bufferCheck
);
if (_bufferCheck == 1)
throw new ArgumentOutOfRangeException(
nameof(jointMatrices),
jointMatrices.Length,
"Expected one element per body in the ragdoll."
);
}
}
///
///
/// This function calls ResetWarmStart on all constraints. It can be used after calling SetPose to reset
/// previous frames impulses. See: Constraint::ResetWarmStart.
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:178
///
/// void ResetWarmStart()
///
///
public void ResetWarmStart() => Jolt.PInvoke.Ragdoll_ResetWarmStart(this);
///
///
/// Drive the ragdoll to a specific pose by setting velocities on each of the bodies so that it will reach
/// inPose in inDeltaTime
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:181
///
/// void DriveToPoseUsingKinematics(const SkeletonPose &inPose, float inDeltaTime, bool inLockBodies = true)
///
///
public void DriveToPoseUsingKinematics(SkeletonPose pose, float deltaTime, bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_DriveToPoseUsingKinematics(this, pose, deltaTime, lockBodies);
///
///
/// Lower level version of DriveToPoseUsingKinematics that directly takes the world space joint matrices
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:184
///
/// void DriveToPoseUsingKinematics(RVec3Arg inRootOffset, const Mat44 *inJointMatrices, float inDeltaTime, bool inLockBodies = true)
///
///
///
///
/// jointMatrices must hold exactly one element per body in the ragdoll - 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 DriveToPoseUsingKinematics(
float3 rootOffset,
ReadOnlySpan jointMatrices,
float deltaTime,
bool lockBodies = true
)
{
fixed (float4x4* jointMatrices_fixed = jointMatrices)
{
Jolt.PInvoke.Ragdoll_DriveToPoseUsingKinematics_2(
this,
rootOffset,
jointMatrices_fixed,
(uint)jointMatrices.Length,
deltaTime,
lockBodies,
out var _bufferCheck
);
if (_bufferCheck == 1)
throw new ArgumentOutOfRangeException(
nameof(jointMatrices),
jointMatrices.Length,
"Expected one element per body in the ragdoll."
);
}
}
///
///
/// Drive the ragdoll to a specific pose by activating the motors on each constraint.
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:187
///
/// void DriveToPoseUsingMotors(const SkeletonPose &inPose)
///
///
///
///
/// Throws ArgumentException for pose: "pose must use the ragdoll's own skeleton (SkeletonPose.SetSkeleton
/// with RagdollSettings.GetSkeleton())."
///
///
public void DriveToPoseUsingMotors(SkeletonPose pose)
{
Jolt.PInvoke.Ragdoll_DriveToPoseUsingMotors(this, pose, out var _bufferCheck);
if (_bufferCheck == 1)
throw new ArgumentException(
"pose must use the ragdoll's own skeleton (SkeletonPose.SetSkeleton with RagdollSettings.GetSkeleton()).",
nameof(pose)
);
}
///
///
/// Drive the ragdoll to a specific pose by activating the motors on each constraint. Drives both to target
/// position and velocity.
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:193
///
/// void DriveToPoseUsingMotors(const SkeletonPose &inPrevPose, const SkeletonPose &inPose, float inDeltaTime)
///
///
///
///
/// Drive the ragdoll to a specific pose by activating the motors on each constraint. Drives both to target position and velocity.
/// @param inPrevPose The previous pose of the ragdoll, used to calculate the target velocity for each motor
/// @param inPose The target pose of the ragdoll, used to calculate the target position for each motor
/// @param inDeltaTime The time between inPrevPose and inPose, used to calculate the target velocity for each motor
///
///
/// Throws ArgumentException for pose: "pose must use the ragdoll's own skeleton (SkeletonPose.SetSkeleton
/// with RagdollSettings.GetSkeleton())." Throws ArgumentException for prevPose: "prevPose must use the
/// ragdoll's own skeleton (SkeletonPose.SetSkeleton with RagdollSettings.GetSkeleton())." Throws
/// ArgumentException for deltaTime: "deltaTime must be greater than zero."
///
///
public void DriveToPoseUsingMotors(SkeletonPose prevPose, SkeletonPose pose, float deltaTime)
{
Jolt.PInvoke.Ragdoll_DriveToPoseUsingMotors_2(this, prevPose, pose, deltaTime, out var _bufferCheck);
if (_bufferCheck == 1)
throw new ArgumentException(
"pose must use the ragdoll's own skeleton (SkeletonPose.SetSkeleton with RagdollSettings.GetSkeleton()).",
nameof(pose)
);
if (_bufferCheck == 2)
throw new ArgumentException(
"prevPose must use the ragdoll's own skeleton (SkeletonPose.SetSkeleton with RagdollSettings.GetSkeleton()).",
nameof(prevPose)
);
if (_bufferCheck == 3)
throw new ArgumentException("deltaTime must be greater than zero.", nameof(deltaTime));
}
///
///
/// Control the linear and velocity of all bodies in the ragdoll
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:196
///
/// void SetLinearAndAngularVelocity(Vec3Arg inLinearVelocity, Vec3Arg inAngularVelocity, bool inLockBodies = true)
///
///
public void SetLinearAndAngularVelocity(
float3 linearVelocity,
float3 angularVelocity,
bool lockBodies = true
) => Jolt.PInvoke.Ragdoll_SetLinearAndAngularVelocity(this, linearVelocity, angularVelocity, lockBodies);
///
///
/// Set the world space linear velocity of all bodies in the ragdoll.
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:199
///
/// void SetLinearVelocity(Vec3Arg inLinearVelocity, bool inLockBodies = true)
///
///
public void SetLinearVelocity(float3 linearVelocity, bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_SetLinearVelocity(this, linearVelocity, lockBodies);
///
///
/// Add a world space velocity (in m/s) to all bodies in the ragdoll.
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:202
///
/// void AddLinearVelocity(Vec3Arg inLinearVelocity, bool inLockBodies = true)
///
///
public void AddLinearVelocity(float3 linearVelocity, bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_AddLinearVelocity(this, linearVelocity, lockBodies);
///
///
/// Add impulse to all bodies of the ragdoll (center of mass of each of them)
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:205
///
/// void AddImpulse(Vec3Arg inImpulse, bool inLockBodies = true)
///
///
public void AddImpulse(float3 impulse, bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_AddImpulse(this, impulse, lockBodies);
///
///
/// Get the position and orientation of the root of the ragdoll
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:208
///
/// void GetRootTransform(RVec3 &outPosition, Quat &outRotation, bool inLockBodies = true) const
///
///
public void GetRootTransform(out float3 position, out floatQuat rotation, bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_GetRootTransform(this, out position, out rotation, lockBodies);
///
///
/// Get number of bodies in the ragdoll
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:211
///
/// size_t GetBodyCount() const
///
///
public ElementCount GetBodyCount() => (ElementCount)Jolt.PInvoke.Ragdoll_GetBodyCount(this);
///
///
/// Access a body ID
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:214
///
/// BodyID GetBodyID(int inBodyIndex) const
///
///
public uint GetBodyID(int bodyIndex)
{
var _result = Jolt.PInvoke.Ragdoll_GetBodyID(this, bodyIndex, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(bodyIndex),
bodyIndex,
"Expected an index below the number of bodies."
);
return _result;
}
///
///
/// Access to the array of body IDs
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:217
///
/// const Array<BodyID> & GetBodyIDs() const
///
///
///
///
/// 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 GetBodyIDs()
{
Jolt.PInvoke.Ragdoll_GetBodyIDs(this, out var _outResult);
return new ReadOnlySpan((void*)_outResult.Data, checked((int)_outResult.Count));
}
///
///
/// Get number of constraints in the ragdoll
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:220
///
/// size_t GetConstraintCount() const
///
///
public ElementCount GetConstraintCount() => (ElementCount)Jolt.PInvoke.Ragdoll_GetConstraintCount(this);
///
///
/// Access a constraint by index
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:223
///
/// TwoBodyConstraint * GetConstraint(int inConstraintIndex)
///
///
///
///
/// The returned handle carries its own reference; Dispose it once when you're done.
///
///
public TwoBodyConstraint GetConstraint(int constraintIndex)
{
var _result = Jolt.PInvoke.Ragdoll_GetConstraint(this, constraintIndex, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(constraintIndex),
constraintIndex,
"Expected an index below the number of constraints."
);
return _result;
}
///
///
/// Get world space bounding box for all bodies of the ragdoll
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:229
///
/// AABox GetWorldSpaceBounds(bool inLockBodies = true) const
///
///
public AABox GetWorldSpaceBounds(bool lockBodies = true) =>
Jolt.PInvoke.Ragdoll_GetWorldSpaceBounds(this, lockBodies);
///
///
/// Get the settings object that created this ragdoll
///
///
/// C++:
/// Jolt/Physics/Ragdoll/Ragdoll.h:232
///
/// const RagdollSettings * GetRagdollSettings() const
///
///
///
///
/// The returned handle carries its own reference; Dispose it once when you're done.
///
///
public RagdollSettings GetRagdollSettings() => Jolt.PInvoke.Ragdoll_GetRagdollSettings(this);
public void AddRef() => Jolt.PInvoke.Ragdoll_AddRef(this);
public void Release() => Jolt.PInvoke.Ragdoll_Release(this);
public uint GetRefCount() => Jolt.PInvoke.Ragdoll_GetRefCount(this);
public void Dispose()
{
if (IsNull())
return;
Release();
}
}
}