// // 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 character object. This object usually represents the player. Contrary to the Character class it /// doesn't use a rigid body but moves doing collision checks only (hence the name virtual). The advantage of /// this is that you can determine when the character moves in the frame (usually this has to happen at a very /// particular point in the frame) but the downside is that other objects don't see this virtual character. To /// make a CharacterVirtual visible to the simulation, you can optionally create an inner rigid body through /// CharacterVirtualSettings::mInnerBodyShape. A CharacterVirtual is not tracked by the PhysicsSystem so you /// need to update it yourself. This also means that a call to PhysicsSystem::SaveState will not save its state, /// you need to call CharacterVirtual::SaveState yourself. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:268 ///
/// class CharacterVirtual : public CharacterBase ///
///
[InteropHandle] public readonly partial struct CharacterVirtual : IDisposable { /// /// /// Settings struct with settings for ExtendedUpdate /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:429 ///
/// struct ExtendedUpdateSettings ///
///
[StructLayout(LayoutKind.Explicit, Size = 64)] public partial struct ExtendedUpdateSettings { /// /// /// See StickToFloor inStepDown parameter. Can be zero to turn off. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:431 ///
/// Vec3 mStickToFloorStepDown { 0, -0.5f, 0 } ///
///
[FieldOffset(0)] public float3 StickToFloorStepDown; /// /// /// See WalkStairs inStepUp parameter. Can be zero to turn off. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:432 ///
/// Vec3 mWalkStairsStepUp { 0, 0.4f, 0 } ///
///
[FieldOffset(16)] public float3 WalkStairsStepUp; /// /// /// See WalkStairs inStepForward parameter. Note that the parameter only indicates a magnitude, /// direction is taken from current velocity. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:433 ///
/// float mWalkStairsMinStepForward { 0.02f } ///
///
[FieldOffset(32)] public float WalkStairsMinStepForward; /// /// /// See WalkStairs inStepForwardTest parameter. Note that the parameter only indicates a magnitude, /// direction is taken from current velocity. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:434 ///
/// float mWalkStairsStepForwardTest { 0.15f } ///
///
[FieldOffset(36)] public float WalkStairsStepForwardTest; /// /// /// Cos(angle) where angle is the maximum angle between the ground normal in the horizontal plane and /// the character forward vector where we're willing to adjust the step forward test towards the contact /// normal. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:435 ///
/// float mWalkStairsCosAngleForwardContact { Cos(DegreesToRadians(75.0f)) } ///
///
[FieldOffset(40)] public float WalkStairsCosAngleForwardContact; /// /// /// See WalkStairs inStepDownExtra /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:436 ///
/// Vec3 mWalkStairsStepDownExtra { Vec3::sZero() } ///
///
[FieldOffset(48)] public float3 WalkStairsStepDownExtra; } /// /// /// A constraint that limits the movement of the character /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:556 ///
/// struct Constraint ///
///
[StructLayout(LayoutKind.Explicit, Size = 64)] public partial struct Constraint { /// /// /// Contact that this constraint was generated from /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:558 ///
/// CharacterContact * mContact ///
///
[FieldOffset(0)] public Ptr Contact; /// /// /// Calculated time of impact (can be negative if penetrating) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:559 ///
/// float mTOI ///
///
[FieldOffset(8)] public float TOI; /// /// /// Velocity of the contact projected on the contact normal (negative if separating) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:560 ///
/// float mProjectedVelocity ///
///
[FieldOffset(12)] public float ProjectedVelocity; /// /// /// Velocity of the contact (can contain a corrective velocity to resolve penetration) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:561 ///
/// Vec3 mLinearVelocity ///
///
[FieldOffset(16)] public float3 LinearVelocity; /// /// /// Plane around the origin that describes how far we can displace (from the origin) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:562 ///
/// Plane mPlane ///
///
[FieldOffset(32)] public Plane Plane; /// /// /// If this constraint belongs to a steep slope /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:563 ///
/// bool mIsSteepSlope = false ///
///
[FieldOffset(48)] public Brutal.Bool8 IsSteepSlope; } /// /// /// View from a contact listener perspective on which contacts have been added/removed /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:736 ///
/// struct ListenerContactValue ///
///
[StructLayout(LayoutKind.Explicit, Size = 8)] public partial struct ListenerContactValue { /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:741 ///
/// CharacterContactSettings mSettings ///
///
[FieldOffset(0)] public CharacterContactSettings Settings; /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:742 ///
/// int mCount = 0 ///
///
[FieldOffset(4)] public int Count; } /// /// /// Constructor /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:279 ///
/// CharacterVirtual(const CharacterVirtualSettings *inSettings, RVec3Arg inPosition, QuatArg inRotation, uint64 inUserData, PhysicsSystem *inSystem) ///
///
/// /// /// Constructor /// @param inSettings The settings for the character /// @param inPosition Initial position for the character /// @param inRotation Initial rotation for the character (usually only around the up-axis) /// @param inUserData Application specific value /// @param inSystem Physics system that this character will be added to /// /// public static CharacterVirtual Create( CharacterVirtualSettings settings, float3 position, floatQuat rotation, ulong userData, PhysicsSystem system ) => Jolt.PInvoke.CharacterVirtual_Create(settings, position, rotation, userData, system); /// /// /// Constructor without user data /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:282 ///
/// CharacterVirtual(const CharacterVirtualSettings *inSettings, RVec3Arg inPosition, QuatArg inRotation, PhysicsSystem *inSystem) ///
///
public static CharacterVirtual Create( CharacterVirtualSettings settings, float3 position, floatQuat rotation, PhysicsSystem system ) => Jolt.PInvoke.CharacterVirtual_Create_2(settings, position, rotation, system); /// /// /// The ID of this character /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:288 ///
/// inline const CharacterID & GetID() const ///
///
public uint GetID() => Jolt.PInvoke.CharacterVirtual_GetID(this); /// /// /// Set the contact listener /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:291 ///
/// void SetListener(CharacterContactListener *inListener) ///
///
public void SetListener(CharacterContactListener listener) => Jolt.PInvoke.CharacterVirtual_SetListener(this, listener); /// /// /// Get the current contact listener /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:294 ///
/// CharacterContactListener * GetListener() const ///
///
/// /// /// The returned handle is borrowed from its owner; don't Dispose it. /// /// public CharacterContactListener GetListener() => Jolt.PInvoke.CharacterVirtual_GetListener(this); /// /// /// Set the character vs character collision interface /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:297 ///
/// void SetCharacterVsCharacterCollision(CharacterVsCharacterCollision *inCharacterVsCharacterCollision) ///
///
public void SetCharacterVsCharacterCollision(CharacterVsCharacterCollision characterVsCharacterCollision) => Jolt.PInvoke.CharacterVirtual_SetCharacterVsCharacterCollision(this, characterVsCharacterCollision); /// /// /// Get the linear velocity of the character (m / s) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:300 ///
/// Vec3 GetLinearVelocity() const ///
///
public float3 GetLinearVelocity() => Jolt.PInvoke.CharacterVirtual_GetLinearVelocity(this); /// /// /// Set the linear velocity of the character (m / s) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:303 ///
/// void SetLinearVelocity(Vec3Arg inLinearVelocity) ///
///
public void SetLinearVelocity(float3 linearVelocity) => Jolt.PInvoke.CharacterVirtual_SetLinearVelocity(this, linearVelocity); /// /// /// Get the position of the character /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:306 ///
/// RVec3 GetPosition() const ///
///
public float3 GetPosition() => Jolt.PInvoke.CharacterVirtual_GetPosition(this); /// /// /// Set the position of the character /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:309 ///
/// void SetPosition(RVec3Arg inPosition) ///
///
public void SetPosition(float3 position) => Jolt.PInvoke.CharacterVirtual_SetPosition(this, position); /// /// /// Get the rotation of the character /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:312 ///
/// Quat GetRotation() const ///
///
public floatQuat GetRotation() => Jolt.PInvoke.CharacterVirtual_GetRotation(this); /// /// /// Set the rotation of the character /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:315 ///
/// void SetRotation(QuatArg inRotation) ///
///
public void SetRotation(floatQuat rotation) => Jolt.PInvoke.CharacterVirtual_SetRotation(this, rotation); /// /// /// Get the center of mass position of the shape /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:318 ///
/// inline RVec3 GetCenterOfMassPosition() const ///
///
public float3 GetCenterOfMassPosition() => Jolt.PInvoke.CharacterVirtual_GetCenterOfMassPosition(this); /// /// /// Calculate the world transform of the character /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:321 ///
/// RMat44 GetWorldTransform() const ///
///
public float4x4 GetWorldTransform() => Jolt.PInvoke.CharacterVirtual_GetWorldTransform(this); /// /// /// Calculates the transform for this character's center of mass /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:324 ///
/// RMat44 GetCenterOfMassTransform() const ///
///
public float4x4 GetCenterOfMassTransform() => Jolt.PInvoke.CharacterVirtual_GetCenterOfMassTransform(this); /// /// /// Character mass (kg) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:327 ///
/// float GetMass() const ///
///
public float GetMass() => Jolt.PInvoke.CharacterVirtual_GetMass(this); /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:328 ///
/// void SetMass(float inMass) ///
///
public void SetMass(float mass) => Jolt.PInvoke.CharacterVirtual_SetMass(this, mass); /// /// /// Maximum force with which the character can push other bodies (N) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:331 ///
/// float GetMaxStrength() const ///
///
public float GetMaxStrength() => Jolt.PInvoke.CharacterVirtual_GetMaxStrength(this); /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:332 ///
/// void SetMaxStrength(float inMaxStrength) ///
///
public void SetMaxStrength(float maxStrength) => Jolt.PInvoke.CharacterVirtual_SetMaxStrength(this, maxStrength); /// /// /// This value governs how fast a penetration will be resolved, 0 = nothing is resolved, 1 = everything in /// one update /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:335 ///
/// float GetPenetrationRecoverySpeed() const ///
///
public float GetPenetrationRecoverySpeed() => Jolt.PInvoke.CharacterVirtual_GetPenetrationRecoverySpeed(this); /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:336 ///
/// void SetPenetrationRecoverySpeed(float inSpeed) ///
///
public void SetPenetrationRecoverySpeed(float speed) => Jolt.PInvoke.CharacterVirtual_SetPenetrationRecoverySpeed(this, speed); /// /// /// Set to indicate that extra effort should be made to try to remove ghost contacts (collisions with /// internal edges of a mesh). This is more expensive but makes bodies move smoother over a mesh with convex /// edges. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:339 ///
/// bool GetEnhancedInternalEdgeRemoval() const ///
///
public bool GetEnhancedInternalEdgeRemoval() => Jolt.PInvoke.CharacterVirtual_GetEnhancedInternalEdgeRemoval(this); /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:340 ///
/// void SetEnhancedInternalEdgeRemoval(bool inApply) ///
///
public void SetEnhancedInternalEdgeRemoval(bool apply) => Jolt.PInvoke.CharacterVirtual_SetEnhancedInternalEdgeRemoval(this, apply); /// /// /// Character padding /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:343 ///
/// float GetCharacterPadding() const ///
///
public float GetCharacterPadding() => Jolt.PInvoke.CharacterVirtual_GetCharacterPadding(this); /// /// /// Max num hits to collect in order to avoid excess of contact points collection /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:346 ///
/// uint GetMaxNumHits() const ///
///
public uint GetMaxNumHits() => Jolt.PInvoke.CharacterVirtual_GetMaxNumHits(this); /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:347 ///
/// void SetMaxNumHits(uint inMaxHits) ///
///
public void SetMaxNumHits(uint maxHits) => Jolt.PInvoke.CharacterVirtual_SetMaxNumHits(this, maxHits); /// /// /// Cos(angle) where angle is the maximum angle between two hits contact normals that are allowed to be /// merged during hit reduction. Default is around 2.5 degrees. Set to -1 to turn off. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:350 ///
/// float GetHitReductionCosMaxAngle() const ///
///
public float GetHitReductionCosMaxAngle() => Jolt.PInvoke.CharacterVirtual_GetHitReductionCosMaxAngle(this); /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:351 ///
/// void SetHitReductionCosMaxAngle(float inCosMaxAngle) ///
///
public void SetHitReductionCosMaxAngle(float cosMaxAngle) => Jolt.PInvoke.CharacterVirtual_SetHitReductionCosMaxAngle(this, cosMaxAngle); /// /// /// Returns if we exceeded the maximum number of hits during the last collision check and had to discard /// hits based on distance. This can be used to find areas that have too complex geometry for the character /// to navigate properly. To solve you can either increase the max number of hits or simplify the geometry. /// Note that the character simulation will try to do its best to select the most relevant contacts to avoid /// the character from getting stuck. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:357 ///
/// bool GetMaxHitsExceeded() const ///
///
public bool GetMaxHitsExceeded() => Jolt.PInvoke.CharacterVirtual_GetMaxHitsExceeded(this); /// /// /// An extra offset applied to the shape in local space. This allows applying an extra offset to the shape /// in local space. Note that setting it on the fly can cause the shape to teleport into collision. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:360 ///
/// Vec3 GetShapeOffset() const ///
///
public float3 GetShapeOffset() => Jolt.PInvoke.CharacterVirtual_GetShapeOffset(this); /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:361 ///
/// void SetShapeOffset(Vec3Arg inShapeOffset) ///
///
public void SetShapeOffset(float3 shapeOffset) => Jolt.PInvoke.CharacterVirtual_SetShapeOffset(this, shapeOffset); /// /// /// Access to the user data, can be used for anything by the application /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:364 ///
/// uint64 GetUserData() const ///
///
public ulong GetUserData() => Jolt.PInvoke.CharacterVirtual_GetUserData(this); /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:365 ///
/// void SetUserData(uint64 inUserData) ///
///
public void SetUserData(ulong userData) => Jolt.PInvoke.CharacterVirtual_SetUserData(this, userData); /// /// /// Optional inner rigid body that proxies the character in the world. Can be used to update body /// properties. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:368 ///
/// BodyID GetInnerBodyID() const ///
///
public uint GetInnerBodyID() => Jolt.PInvoke.CharacterVirtual_GetInnerBodyID(this); /// /// /// This function can be called prior to calling Update() to convert a desired velocity into a velocity that /// won't make the character move further onto steep slopes. This velocity can then be set on the character /// using SetLinearVelocity() /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:374 ///
/// Vec3 CancelVelocityTowardsSteepSlopes(Vec3Arg inDesiredVelocity) const ///
///
/// /// /// This function can be called prior to calling Update() to convert a desired velocity into a velocity that won't make the character move further onto steep slopes. /// This velocity can then be set on the character using SetLinearVelocity() /// @param inDesiredVelocity Velocity to clamp against steep walls /// @return A new velocity vector that won't make the character move up steep slopes /// /// public float3 CancelVelocityTowardsSteepSlopes(float3 desiredVelocity) => Jolt.PInvoke.CharacterVirtual_CancelVelocityTowardsSteepSlopes(this, desiredVelocity); /// /// /// This function is internally called by Update, WalkStairs, StickToFloor and ExtendedUpdate and is /// responsible for tracking if contacts are added, persisted or removed. If you want to do multiple /// operations on a character (e.g. first Update then WalkStairs), you can surround the code with a /// StartTrackingContactChanges and FinishTrackingContactChanges pair to only receive a single callback per /// contact on the CharacterContactListener. If you don't do this then you could for example receive a /// contact added callback during the Update and a contact persisted callback during WalkStairs. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:380 ///
/// void StartTrackingContactChanges() ///
///
public void StartTrackingContactChanges() => Jolt.PInvoke.CharacterVirtual_StartTrackingContactChanges(this); /// /// /// This call triggers contact removal callbacks and is used in conjunction with /// StartTrackingContactChanges. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:383 ///
/// void FinishTrackingContactChanges() ///
///
public void FinishTrackingContactChanges() => Jolt.PInvoke.CharacterVirtual_FinishTrackingContactChanges(this); /// /// /// This is the main update function. It moves the character according to its current velocity (the /// character is similar to a kinematic body in the sense that you set the velocity and the character will /// follow unless collision is blocking the way). Note it's your own responsibility to apply gravity to the /// character velocity! Different surface materials (like ice) can be emulated by getting the ground /// material and adjusting the velocity and/or the max slope angle accordingly every frame. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:395 ///
/// void Update(float inDeltaTime, Vec3Arg inGravity, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator) ///
///
/// /// /// This is the main update function. It moves the character according to its current velocity (the character is similar to a kinematic body in the sense /// that you set the velocity and the character will follow unless collision is blocking the way). Note it's your own responsibility to apply gravity to the character velocity! /// Different surface materials (like ice) can be emulated by getting the ground material and adjusting the velocity and/or the max slope angle accordingly every frame. /// @param inDeltaTime Time step to simulate. /// @param inGravity Gravity vector (m/s^2). This gravity vector is only used when the character is standing on top of another object to apply downward force. /// @param inBroadPhaseLayerFilter Filter that is used to check if the character collides with something in the broadphase. /// @param inObjectLayerFilter Filter that is used to check if a character collides with a layer. /// @param inBodyFilter Filter that is used to check if a character collides with a body. /// @param inShapeFilter Filter that is used to check if a character collides with a subshape. /// @param inAllocator An allocator for temporary allocations. All memory will be freed by the time this function returns. /// /// /// Pass default for broadPhaseLayerFilter to filter nothing out. /// /// /// Pass default for objectLayerFilter to filter nothing out. /// /// /// Pass default for bodyFilter to filter nothing out. /// /// /// Pass default for shapeFilter to filter nothing out. /// /// public void Update( float deltaTime, float3 gravity, BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator ) => Jolt.PInvoke.CharacterVirtual_Update( this, deltaTime, gravity, broadPhaseLayerFilter, objectLayerFilter, bodyFilter, shapeFilter, allocator ); /// /// /// This function will return true if the character has moved into a slope that is too steep (e.g. a /// vertical wall). You would call WalkStairs to attempt to step up stairs. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:400 ///
/// bool CanWalkStairs(Vec3Arg inLinearVelocity) const ///
///
/// /// /// This function will return true if the character has moved into a slope that is too steep (e.g. a vertical wall). /// You would call WalkStairs to attempt to step up stairs. /// @param inLinearVelocity The linear velocity that the player desired. This is used to determine if we're pushing into a step. /// /// public bool CanWalkStairs(float3 linearVelocity) => Jolt.PInvoke.CharacterVirtual_CanWalkStairs(this, linearVelocity); /// /// /// When stair walking is needed, you can call the WalkStairs function to cast up, forward and down again to /// try to find a valid position /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:414 ///
/// bool WalkStairs(float inDeltaTime, Vec3Arg inStepUp, Vec3Arg inStepForward, Vec3Arg inStepForwardTest, Vec3Arg inStepDownExtra, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator) ///
///
/// /// /// When stair walking is needed, you can call the WalkStairs function to cast up, forward and down again to try to find a valid position /// @param inDeltaTime Time step to simulate. /// @param inStepUp The direction and distance to step up (this corresponds to the max step height) /// @param inStepForward The direction and distance to step forward after the step up /// @param inStepForwardTest When running at a high frequency, inStepForward can be very small and it's likely that you hit the side of the stairs on the way down. This could produce a normal that violates the max slope angle. If this happens, we test again using this distance from the up position to see if we find a valid slope. /// @param inStepDownExtra An additional translation that is added when stepping down at the end. Allows you to step further down than up. Set to zero if you don't want this. Should be in the opposite direction of up. /// @param inBroadPhaseLayerFilter Filter that is used to check if the character collides with something in the broadphase. /// @param inObjectLayerFilter Filter that is used to check if a character collides with a layer. /// @param inBodyFilter Filter that is used to check if a character collides with a body. /// @param inShapeFilter Filter that is used to check if a character collides with a subshape. /// @param inAllocator An allocator for temporary allocations. All memory will be freed by the time this function returns. /// @return true if the stair walk was successful /// /// /// Pass default for broadPhaseLayerFilter to filter nothing out. /// /// /// Pass default for objectLayerFilter to filter nothing out. /// /// /// Pass default for bodyFilter to filter nothing out. /// /// /// Pass default for shapeFilter to filter nothing out. /// /// public bool WalkStairs( float deltaTime, float3 stepUp, float3 stepForward, float3 stepForwardTest, float3 stepDownExtra, BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator ) => Jolt.PInvoke.CharacterVirtual_WalkStairs( this, deltaTime, stepUp, stepForward, stepForwardTest, stepDownExtra, broadPhaseLayerFilter, objectLayerFilter, bodyFilter, shapeFilter, allocator ); /// /// /// This function can be used to artificially keep the character to the floor. Normally when a character is /// on a small step and starts moving horizontally, the character will lose contact with the floor because /// the initial vertical velocity is zero while the horizontal velocity is quite high. To prevent the /// character from losing contact with the floor, we do an additional collision check downwards and if we /// find the floor within a certain distance, we project the character onto the floor. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:426 ///
/// bool StickToFloor(Vec3Arg inStepDown, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator) ///
///
/// /// /// This function can be used to artificially keep the character to the floor. Normally when a character is on a small step and starts moving horizontally, the character will /// lose contact with the floor because the initial vertical velocity is zero while the horizontal velocity is quite high. To prevent the character from losing contact with the floor, /// we do an additional collision check downwards and if we find the floor within a certain distance, we project the character onto the floor. /// @param inStepDown Max amount to project the character downwards (if no floor is found within this distance, the function will return false) /// @param inBroadPhaseLayerFilter Filter that is used to check if the character collides with something in the broadphase. /// @param inObjectLayerFilter Filter that is used to check if a character collides with a layer. /// @param inBodyFilter Filter that is used to check if a character collides with a body. /// @param inShapeFilter Filter that is used to check if a character collides with a subshape. /// @param inAllocator An allocator for temporary allocations. All memory will be freed by the time this function returns. /// @return True if the character was successfully projected onto the floor. /// /// /// Pass default for broadPhaseLayerFilter to filter nothing out. /// /// /// Pass default for objectLayerFilter to filter nothing out. /// /// /// Pass default for bodyFilter to filter nothing out. /// /// /// Pass default for shapeFilter to filter nothing out. /// /// public bool StickToFloor( float3 stepDown, BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator ) => Jolt.PInvoke.CharacterVirtual_StickToFloor( this, stepDown, broadPhaseLayerFilter, objectLayerFilter, bodyFilter, shapeFilter, allocator ); /// /// /// This function combines Update, StickToFloor and WalkStairs. This function serves as an example of how /// these functions could be combined. Before calling, call SetLinearVelocity to update the /// horizontal/vertical speed of the character, typically this is: - When on OnGround and not moving away /// from ground: velocity = GetGroundVelocity() + horizontal speed as input by player + optional vertical /// jump velocity + delta time * gravity - Else: velocity = current vertical velocity + horizontal speed as /// input by player + delta time * gravity /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:451 ///
/// void ExtendedUpdate(float inDeltaTime, Vec3Arg inGravity, const ExtendedUpdateSettings &inSettings, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator) ///
///
/// /// /// This function combines Update, StickToFloor and WalkStairs. This function serves as an example of how these functions could be combined. /// Before calling, call SetLinearVelocity to update the horizontal/vertical speed of the character, typically this is: /// - When on OnGround and not moving away from ground: velocity = GetGroundVelocity() + horizontal speed as input by player + optional vertical jump velocity + delta time * gravity /// - Else: velocity = current vertical velocity + horizontal speed as input by player + delta time * gravity /// @param inDeltaTime Time step to simulate. /// @param inGravity Gravity vector (m/s^2). This gravity vector is only used when the character is standing on top of another object to apply downward force. /// @param inSettings A structure containing settings for the algorithm. /// @param inBroadPhaseLayerFilter Filter that is used to check if the character collides with something in the broadphase. /// @param inObjectLayerFilter Filter that is used to check if a character collides with a layer. /// @param inBodyFilter Filter that is used to check if a character collides with a body. /// @param inShapeFilter Filter that is used to check if a character collides with a subshape. /// @param inAllocator An allocator for temporary allocations. All memory will be freed by the time this function returns. /// /// /// Pass default for broadPhaseLayerFilter to filter nothing out. /// /// /// Pass default for objectLayerFilter to filter nothing out. /// /// /// Pass default for bodyFilter to filter nothing out. /// /// /// Pass default for shapeFilter to filter nothing out. /// /// public void ExtendedUpdate( float deltaTime, float3 gravity, in CharacterVirtual.ExtendedUpdateSettings settings, BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator ) => Jolt.PInvoke.CharacterVirtual_ExtendedUpdate( this, deltaTime, gravity, in settings, broadPhaseLayerFilter, objectLayerFilter, bodyFilter, shapeFilter, allocator ); /// /// /// This function can be used after a character has teleported to determine the new contacts with the world. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:454 ///
/// void RefreshContacts(const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator) ///
///
/// /// /// Pass default for broadPhaseLayerFilter to filter nothing out. /// /// /// Pass default for objectLayerFilter to filter nothing out. /// /// /// Pass default for bodyFilter to filter nothing out. /// /// /// Pass default for shapeFilter to filter nothing out. /// /// public void RefreshContacts( BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator ) => Jolt.PInvoke.CharacterVirtual_RefreshContacts( this, broadPhaseLayerFilter, objectLayerFilter, bodyFilter, shapeFilter, allocator ); /// /// /// Use the ground body ID to get an updated estimate of the ground velocity. This function can be used if /// the ground body has moved / changed velocity and you want a new estimate of the ground velocity. It will /// not perform collision detection, so is less accurate than RefreshContacts but a lot faster. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:458 ///
/// void UpdateGroundVelocity() ///
///
public void UpdateGroundVelocity() => Jolt.PInvoke.CharacterVirtual_UpdateGroundVelocity(this); /// /// /// Switch the shape of the character (e.g. for stance). /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:469 ///
/// bool SetShape(const Shape *inShape, float inMaxPenetrationDepth, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter, TempAllocator &inAllocator) ///
///
/// /// /// Switch the shape of the character (e.g. for stance). /// @param inShape The shape to switch to. /// @param inMaxPenetrationDepth When inMaxPenetrationDepth is not FLT_MAX, it checks if the new shape collides before switching shape. This is the max penetration we're willing to accept after the switch. /// @param inBroadPhaseLayerFilter Filter that is used to check if the character collides with something in the broadphase. /// @param inObjectLayerFilter Filter that is used to check if a character collides with a layer. /// @param inBodyFilter Filter that is used to check if a character collides with a body. /// @param inShapeFilter Filter that is used to check if a character collides with a subshape. /// @param inAllocator An allocator for temporary allocations. All memory will be freed by the time this function returns. /// @return Returns true if the switch succeeded. /// /// /// Pass default for broadPhaseLayerFilter to filter nothing out. /// /// /// Pass default for objectLayerFilter to filter nothing out. /// /// /// Pass default for bodyFilter to filter nothing out. /// /// /// Pass default for shapeFilter to filter nothing out. /// /// public bool SetShape( Shape shape, float maxPenetrationDepth, BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter, TempAllocator allocator ) => Jolt.PInvoke.CharacterVirtual_SetShape( this, shape, maxPenetrationDepth, broadPhaseLayerFilter, objectLayerFilter, bodyFilter, shapeFilter, allocator ); /// /// /// Updates the shape of the inner rigid body. Should be called after a successful call to SetShape. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:472 ///
/// void SetInnerBodyShape(const Shape *inShape) ///
///
public void SetInnerBodyShape(Shape shape) => Jolt.PInvoke.CharacterVirtual_SetInnerBodyShape(this, shape); /// /// /// Get the transformed shape that represents the volume of the character, can be used for collision checks. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:475 ///
/// TransformedShape GetTransformedShape() const ///
///
/// /// /// The returned handle is an owned copy; Dispose it when you're done with it. /// /// public TransformedShape GetTransformedShape() => Jolt.PInvoke.CharacterVirtual_GetTransformedShape(this); /// /// /// Get all contacts for the character at a particular location. When colliding with another character /// virtual, this pointer will be provided through CollideShapeCollector::SetUserContext before adding a /// hit. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:490 ///
/// void CheckCollision(RVec3Arg inPosition, QuatArg inRotation, Vec3Arg inMovementDirection, float inMaxSeparationDistance, const Shape *inShape, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const ///
///
/// /// /// @brief Get all contacts for the character at a particular location. /// When colliding with another character virtual, this pointer will be provided through CollideShapeCollector::SetUserContext before adding a hit. /// @param inPosition Position to test, note that this position will be corrected for the character padding. /// @param inRotation Rotation at which to test the shape. /// @param inMovementDirection A hint in which direction the character is moving, will be used to calculate a proper normal. /// @param inMaxSeparationDistance How much distance around the character you want to report contacts in (can be 0 to match the character exactly). /// @param inShape Shape to test collision with. /// @param inBaseOffset All hit results will be returned relative to this offset, can be zero to get results in world position, but when you're testing far from the origin you get better precision by picking a position that's closer e.g. GetPosition() since floats are most accurate near the origin /// @param ioCollector Collision collector that receives the collision results. /// @param inBroadPhaseLayerFilter Filter that is used to check if the character collides with something in the broadphase. /// @param inObjectLayerFilter Filter that is used to check if a character collides with a layer. /// @param inBodyFilter Filter that is used to check if a character collides with a body. /// @param inShapeFilter Filter that is used to check if a character collides with a subshape. /// /// /// Collects every hit into checkcollisionresults, which you allocate and size. Returns how many were /// written; totalHits is how many the query found, so a larger span is needed when it exceeds the span's /// length. /// /// /// Pass default for broadPhaseLayerFilter to filter nothing out. /// /// /// Pass default for objectLayerFilter to filter nothing out. /// /// /// Pass default for bodyFilter to filter nothing out. /// /// /// Pass default for shapeFilter to filter nothing out. /// /// public unsafe uint CheckCollision( float3 position, floatQuat rotation, float3 movementDirection, float maxSeparationDistance, Shape shape, float3 baseOffset, Span results, out uint totalHits, BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter ) { fixed (CollideShapeResult* results_fixed = results) { totalHits = Jolt.PInvoke.CharacterVirtual_CheckCollision( this, position, rotation, movementDirection, maxSeparationDistance, shape, baseOffset, results_fixed, (uint)results.Length, broadPhaseLayerFilter, objectLayerFilter, bodyFilter, shapeFilter ); return totalHits < (uint)results.Length ? totalHits : (uint)results.Length; } } /// /// /// Get all contacts for the character at a particular location. When colliding with another character /// virtual, this pointer will be provided through CollideShapeCollector::SetUserContext before adding a /// hit. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:490 ///
/// void CheckCollision(RVec3Arg inPosition, QuatArg inRotation, Vec3Arg inMovementDirection, float inMaxSeparationDistance, const Shape *inShape, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const ///
///
/// /// /// @brief Get all contacts for the character at a particular location. /// When colliding with another character virtual, this pointer will be provided through CollideShapeCollector::SetUserContext before adding a hit. /// @param inPosition Position to test, note that this position will be corrected for the character padding. /// @param inRotation Rotation at which to test the shape. /// @param inMovementDirection A hint in which direction the character is moving, will be used to calculate a proper normal. /// @param inMaxSeparationDistance How much distance around the character you want to report contacts in (can be 0 to match the character exactly). /// @param inShape Shape to test collision with. /// @param inBaseOffset All hit results will be returned relative to this offset, can be zero to get results in world position, but when you're testing far from the origin you get better precision by picking a position that's closer e.g. GetPosition() since floats are most accurate near the origin /// @param ioCollector Collision collector that receives the collision results. /// @param inBroadPhaseLayerFilter Filter that is used to check if the character collides with something in the broadphase. /// @param inObjectLayerFilter Filter that is used to check if a character collides with a layer. /// @param inBodyFilter Filter that is used to check if a character collides with a body. /// @param inShapeFilter Filter that is used to check if a character collides with a subshape. /// /// /// Keeps only the closest (or deepest) hit. Returns false, and writes a native default-constructed result /// (e.g. RayCastResult's fraction is 1 + epsilon), when nothing was hit. /// /// /// Pass default for broadPhaseLayerFilter to filter nothing out. /// /// /// Pass default for objectLayerFilter to filter nothing out. /// /// /// Pass default for bodyFilter to filter nothing out. /// /// /// Pass default for shapeFilter to filter nothing out. /// /// public bool CheckCollisionClosest( float3 position, floatQuat rotation, float3 movementDirection, float maxSeparationDistance, Shape shape, float3 baseOffset, out CollideShapeResult result, BroadPhaseLayerFilter broadPhaseLayerFilter, ObjectLayerFilter objectLayerFilter, BodyFilter bodyFilter, ShapeFilter shapeFilter ) => Jolt.PInvoke.CharacterVirtual_CheckCollisionClosest( this, position, rotation, movementDirection, maxSeparationDistance, shape, baseOffset, out result, broadPhaseLayerFilter, objectLayerFilter, bodyFilter, shapeFilter ) != 0; /// /// /// Get the character settings that can recreate this character /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:493 ///
/// CharacterVirtualSettings GetCharacterVirtualSettings() const ///
///
/// /// /// The returned handle carries its own reference; Dispose it once when you're done. /// /// public CharacterVirtualSettings GetCharacterVirtualSettings() => Jolt.PInvoke.CharacterVirtual_GetCharacterVirtualSettings(this); /// public void SaveState(StateRecorder stream) => ((CharacterBase)this).SaveState(stream); /// public void RestoreState(StateRecorder stream) => ((CharacterBase)this).RestoreState(stream); /// /// /// Access to the internal list of contacts that the character has found. Note that only contacts that have /// their mHadCollision flag set are actual contacts. /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:511 ///
/// const ContactList & GetActiveContacts() 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 GetActiveContacts() { Jolt.PInvoke.CharacterVirtual_GetActiveContacts(this, out var _outResult); return new ReadOnlySpan((void*)_outResult.Data, checked((int)_outResult.Count)); } /// /// /// Check if the character is currently in contact with or has collided with another body in the last /// operation (e.g. Update or WalkStairs) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:514 ///
/// bool HasCollidedWith(const BodyID &inBody) const ///
///
public bool HasCollidedWith(uint body) => Jolt.PInvoke.CharacterVirtual_HasCollidedWith(this, body); /// /// /// Check if the character is currently in contact with or has collided with another character in the last /// time step (e.g. Update or WalkStairs) /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:532 ///
/// bool HasCollidedWith(const CharacterVirtual *inCharacter) const ///
///
public bool HasCollidedWith(CharacterVirtual character) => Jolt.PInvoke.CharacterVirtual_HasCollidedWith_2(this, character); /// /// /// Draw the current state of the constraints for iteration 0 when creating them /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:500 ///
/// static inline bool sDrawConstraints = false ///
///
public static bool GetDrawConstraints() => Jolt.PInvoke.CharacterVirtual_GetDrawConstraints(); /// /// /// Draw the current state of the constraints for iteration 0 when creating them /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:500 ///
/// static inline bool sDrawConstraints = false ///
///
public static void SetDrawConstraints(bool value) => Jolt.PInvoke.CharacterVirtual_SetDrawConstraints(value); /// /// /// Draw the state of the walk stairs algorithm /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:501 ///
/// static inline bool sDrawWalkStairs = false ///
///
public static bool GetDrawWalkStairs() => Jolt.PInvoke.CharacterVirtual_GetDrawWalkStairs(); /// /// /// Draw the state of the walk stairs algorithm /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:501 ///
/// static inline bool sDrawWalkStairs = false ///
///
public static void SetDrawWalkStairs(bool value) => Jolt.PInvoke.CharacterVirtual_SetDrawWalkStairs(value); /// /// /// Draw the state of the stick to floor algorithm /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:502 ///
/// static inline bool sDrawStickToFloor = false ///
///
public static bool GetDrawStickToFloor() => Jolt.PInvoke.CharacterVirtual_GetDrawStickToFloor(); /// /// /// Draw the state of the stick to floor algorithm /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:502 ///
/// static inline bool sDrawStickToFloor = false ///
///
public static void SetDrawStickToFloor(bool value) => Jolt.PInvoke.CharacterVirtual_SetDrawStickToFloor(value); /// /// /// Draw the supporting volume plane /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:503 ///
/// static inline bool sDrawSupportingVolume = false ///
///
public static bool GetDrawSupportingVolume() => Jolt.PInvoke.CharacterVirtual_GetDrawSupportingVolume(); /// /// /// Draw the supporting volume plane /// /// /// C++: /// Jolt/Physics/Character/CharacterVirtual.h:503 ///
/// static inline bool sDrawSupportingVolume = false ///
///
public static void SetDrawSupportingVolume(bool value) => Jolt.PInvoke.CharacterVirtual_SetDrawSupportingVolume(value); public void AddRef() => ((CharacterBase)this).AddRef(); public void Release() => ((CharacterBase)this).Release(); public uint GetRefCount() => ((CharacterBase)this).GetRefCount(); public static implicit operator CharacterBase(CharacterVirtual value) => Unsafe.BitCast(value); public void Dispose() { if (IsNull()) return; Release(); } /// public void SetMaxSlopeAngle(float maxSlopeAngle) => ((CharacterBase)this).SetMaxSlopeAngle(maxSlopeAngle); /// public float GetCosMaxSlopeAngle() => ((CharacterBase)this).GetCosMaxSlopeAngle(); /// public void SetUp(float3 up) => ((CharacterBase)this).SetUp(up); /// public float3 GetUp() => ((CharacterBase)this).GetUp(); /// public Plane GetSupportingVolume() => ((CharacterBase)this).GetSupportingVolume(); /// public void SetSupportingVolume(in Plane plane) => ((CharacterBase)this).SetSupportingVolume(in plane); /// public bool IsSlopeTooSteep(float3 normal) => ((CharacterBase)this).IsSlopeTooSteep(normal); /// public Shape GetShape() => ((CharacterBase)this).GetShape(); /// public CharacterBase.GroundState GetGroundState() => ((CharacterBase)this).GetGroundState(); /// public bool IsSupported() => ((CharacterBase)this).IsSupported(); /// public float3 GetGroundPosition() => ((CharacterBase)this).GetGroundPosition(); /// public float3 GetGroundNormal() => ((CharacterBase)this).GetGroundNormal(); /// public float3 GetGroundVelocity() => ((CharacterBase)this).GetGroundVelocity(); /// public PhysicsMaterial GetGroundMaterial() => ((CharacterBase)this).GetGroundMaterial(); /// public uint GetGroundBodyID() => ((CharacterBase)this).GetGroundBodyID(); /// public uint GetGroundSubShapeID() => ((CharacterBase)this).GetGroundSubShapeID(); /// public ulong GetGroundUserData() => ((CharacterBase)this).GetGroundUserData(); } }