engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 静态 Public 成员函数 | Public 属性 | Protected 成员函数 | Protected 属性 | 友元 | 所有成员列表
FBodyInstance结构体 参考

Container for a physics representation of an object 更多...

#include <BodyInstance.h>

继承自 FBodyInstanceCore .

Public 成员函数

void AddAngularImpulseInRadians (const FVector &Impulse, bool bVelChange)
 Add a rotational impulse to this body
 
void AddCustomPhysics (FCalculateCustomPhysics &CalculateCustomPhysics)
 Add custom forces and torques on the body. 更多...
 
void AddForce (const FVector &Force, bool bAllowSubstepping=true, bool bAccelChange=false)
 Add a force to this body
 
void AddForceAtPosition (const FVector &Force, const FVector &Position, bool bAllowSubstepping=true, bool bIsLocalForce=false)
 Add a force at a particular position (world space when bIsLocalForce = false, body space otherwise)
 
void AddImpulse (const FVector &Impulse, bool bVelChange)
 Add an impulse to this body
 
void AddImpulseAtPosition (const FVector &Impulse, const FVector &Position)
 Add an impulse to this body and a particular world position
 
void AddRadialForceToBody (const FVector &Origin, float Radius, float Strength, uint8 Falloff, bool bAccelChange=false, bool bAllowSubstepping=true)
 Add a force to this bodyinstance, originating from the supplied world-space location. 更多...
 
void AddRadialImpulseToBody (const FVector &Origin, float Radius, float Strength, uint8 Falloff, bool bVelChange=false)
 Add an impulse to this bodyinstance, radiating out from the specified position. 更多...
 
void AddTorqueInRadians (const FVector &Torque, bool bAllowSubstepping=true, bool bAccelChange=false)
 Add a torque to this body
 
void ApplyDeferredCollisionProfileName ()
 Applies a deferred collision profile
 
void ApplyMaterialToInstanceShapes_AssumesLocked (UPhysicalMaterial *SimplePhysMat, TArray< UPhysicalMaterial * > &ComplexPhysMats, const TArrayView< FPhysicalMaterialMaskParams > &ComplexPhysMatMasks)
 Note: This function is not thread safe. 更多...
 
void ApplyWeldOnChildren ()
 Finds all children that are technically welded to us (for example kinematics are welded but not as far as physx is concerned) and apply the actual physics engine weld on them
 
void BuildBodyFilterData (FBodyCollisionFilterData &OutFilterData, const int32 ShapeIndex=INDEX_NONE) const
 Build the sim and query filter data (for simple and complex shapes) based on the settings of this BodyInstance (and its associated BodySetup)

 
void ClearForces (bool bAllowSubstepping=true)
 Clear accumulated forces on this body
 
void ClearTorques (bool bAllowSubstepping=true)
 Clear accumulated torques on this body
 
void CopyBodyInstancePropertiesFrom (const FBodyInstance *FromInst)
 Utility for copying properties from one BodyInstance to another.
 
void CopyRuntimeBodyInstancePropertiesFrom (const FBodyInstance *FromInst)
 Utility for copying only the runtime instanced properties from one BodyInstance to another.
 
bool DoesUseCollisionProfile () const
 return true if it uses Collision Profile System. 更多...
 
void DrawCOMPosition (class FPrimitiveDrawInterface *PDI, float COMRenderSize, const FColor &COMRenderColor)
 Draws the center of mass as a wire star
 
void ExecuteOnCalculateCustomProjection (FTransform &WorldTM) const
 Executes the OnCalculateCustomProjection delegate if bound.
 
 FBodyInstance ()
 Constructor
 
void FixupData (class UObject *Loader)
 UObject notification by OwningComponent
 
int32 GetAllShapes_AssumesLocked (TArray< FPhysicsShapeHandle > &OutShapes) const
 Utility to get all the shapes from a FBodyInstance NOTE: This function is not thread safe. 更多...
 
FBox GetBodyBounds () const
 Return bounds of physics representation
 
FString GetBodyDebugName () const
 Get the name for this body, for use in debugging
 
FVector GetBodyInertiaTensor () const
 Return the body's inertia tensor. 更多...
 
void GetBodyInstanceResourceSizeEx (FResourceSizeEx &CumulativeResourceSize) const
 Returns memory used by resources allocated for this body instance ( ex. 更多...
 
float GetBodyMass () const
 Returns the body's mass
 
FORCEINLINE ECollisionEnabled::Type GetCollisionEnabled (bool bCheckOwner=true) const
 Get the current type of collision enabled
 
FName GetCollisionProfileName () const
 Returns the collision profile name that will be used.
 
TArray< UPhysicalMaterial * > GetComplexPhysicalMaterials () const
 Get the complex PhysicalMaterials array for this body
 
TArray< UPhysicalMaterial * > GetComplexPhysicalMaterials (TArray< FPhysicalMaterialMaskParams > &OutPhysMaterialMasks) const
 Get the complex PhysicalMaterials and PhysicalMaterialMasks array for this body
 
void GetComplexPhysicalMaterials (TArray< UPhysicalMaterial * > &OutPhysMaterials) const
 Get the complex PhysicalMaterials for this body
 
void GetComplexPhysicalMaterials (TArray< UPhysicalMaterial * > &OutPhysMaterials, TArray< FPhysicalMaterialMaskParams > &OutPhysMaterialMasks) const
 Get the complex PhysicalMaterials and PhysicalMaterialMasks for this body
 
FVector GetCOMPosition () const
 Returns the center of mass of this body (in world space)
 
float GetDistanceToBody (const FVector &Point, FVector &OutPointOnBody) const
 Get the square of the distance to the body surface if available It is only valid if BodyShape is convex If point is inside or shape is not convex, it will return 0.f 更多...
 
FVector GetLockedAxis () const
 [Physx Only]
 
FORCEINLINE FMaskFilter GetMaskFilter () const
 Return the ignore mask filter.
 
float GetMassOverride () const
 Returns the mass override. 更多...
 
FTransform GetMassSpaceLocal () const
 Returns the mass coordinate system to local space transform (position is local center of mass, rotation should be identity)
 
FTransform GetMassSpaceToWorldSpace () const
 Returns the mass coordinate system to world space transform (position is world center of mass, rotation is world inertia orientation)
 
float GetMaxAngularVelocityInRadians () const
 Get the maximum angular velocity of this body
 
FORCEINLINE_DEBUGGABLE ECollisionChannel GetObjectType () const
 Get the movement channel of this body
 
const FBodyInstance * GetOriginalBodyInstance (const FPhysicsShapeHandle &InShape) const
 Returns the original owning body instance. 更多...
 
bool GetOverrideWalkableSlopeOnInstance () const
 Gets bOverrideWalkableSlopeOnInstance
 
FPhysScene * GetPhysicsScene ()
 Get the scene that owns this body.
 
const FTransform & GetRelativeBodyTransform (const FPhysicsShapeHandle &InShape) const
 Returns the relative transform between root body and welded instance owned by the shape.
 
FORCEINLINE_DEBUGGABLE ECollisionResponse GetResponseToChannel (ECollisionChannel Channel) const
 Get the collision response of this body to a particular channel
 
FORCEINLINE_DEBUGGABLE const FCollisionResponseContainer & GetResponseToChannels () const
 Get Collision ResponseToChannels container for this component
 
ECollisionEnabled::Type GetShapeCollisionEnabled (const int32 ShapeIndex) const
 Get the current type of collision enabled for a particular shape
 
const FCollisionResponseContainer & GetShapeResponseToChannels (const int32 ShapeIndex) const
 Get Collision ResponseToChannels container for a specific shape in this component
 
UPhysicalMaterial * GetSimplePhysicalMaterial () const
 Find the correct PhysicalMaterial for simple geometry on this body
 
float GetSleepThresholdMultiplier () const
 Gets the multiplier to the threshold where the body will go to sleep automatically.
 
bool GetSquaredDistanceToBody (const FVector &Point, float &OutDistanceSquared, FVector &OutPointOnBody) const
 Get distance to the body surface if available It is only valid if BodyShape is convex If point is inside distance it will be 0 Returns false if geometry is not supported 更多...
 
FVector GetUnrealWorldAngularVelocityInRadians () const
 Get current angular velocity in world space from physics body.
 
FVector GetUnrealWorldAngularVelocityInRadians_AssumesLocked () const
 Get current angular velocity in world space from physics body.
 
FTransform GetUnrealWorldTransform (bool bWithProjection=true, bool bForceGlobalPose=false) const
 Get current transform in world space from physics body.
 
FTransform GetUnrealWorldTransform_AssumesLocked (bool bWithProjection=true, bool bForceGlobalPose=false) const
 Get current transform in world space from physics body.
 
FVector GetUnrealWorldVelocity () const
 Get current velocity in world space from physics body.
 
FVector GetUnrealWorldVelocity_AssumesLocked () const
 Get current velocity in world space from physics body.
 
FVector GetUnrealWorldVelocityAtPoint (const FVector &Point) const
 Get current velocity of a point on this physics body, in world space. 更多...
 
FVector GetUnrealWorldVelocityAtPoint_AssumesLocked (const FVector &Point) const
 Get current velocity of a point on this physics body, in world space. 更多...
 
const struct FWalkableSlopeOverride & GetWalkableSlopeOverride () const
 Returns the slope override struct for this instance. 更多...
 
void InitBody (UBodySetup *Setup, const FTransform &Transform, UPrimitiveComponent *PrimComp, FPhysScene *InRBScene, const FInitBodySpawnParams &SpawnParams)
 Initialise a single rigid body (this FBodyInstance) for the given body setup 更多...
 
void InitDynamicProperties_AssumesLocked ()
 Initialise dynamic properties for this instance when using physics - this must be done after scene addition. 更多...
 
bool IsDynamic () const
 Returns true if the body is not static
 
bool IsInstanceAwake () const
 Returns whether this body is awake
 
bool IsInstanceSimulatingPhysics () const
 Returns true if this body is simulating, false if it is fixed (kinematic)
 
bool IsNonKinematic () const
 Returns true if the body is non kinematic
 
bool IsShapeBoundToBody (const FPhysicsShapeHandle &Shape) const
 Check if the shape is owned by this body instance
 
bool IsValidBodyInstance () const
 See if this body is valid.
 
bool LineTrace (struct FHitResult &OutHit, const FVector &Start, const FVector &End, bool bTraceComplex, bool bReturnPhysicalMaterial=false) const
 Trace a ray against just this bodyinstance 更多...
 
void LoadProfileData (bool bVerifyProfile)
 Update profile data if required 更多...
 
FCalculateCustomProjection & OnCalculateCustomProjection ()
 Returns reference to the OnCalculateCustomProjection delegate. 更多...
 
FRecalculatedMassProperties & OnRecalculatedMassProperties ()
 Returns reference to the OnRecalculatedMassProperties delegate. 更多...
 
bool OverlapMulti (TArray< struct FOverlapResult > &InOutOverlaps, const class UWorld *World, const FTransform *pWorldToComponent, const FVector &Pos, const FQuat &Rot, ECollisionChannel TestChannel, const struct FComponentQueryParams &Params, const struct FCollisionResponseParams &ResponseParams, const FCollisionObjectQueryParams &ObjectQueryParams=FCollisionObjectQueryParams::DefaultObjectQueryParam) const
 Determines the set of components that this body instance would overlap with at the supplied location/rotation 更多...
 
bool OverlapTest (const FVector &Position, const FQuat &Rotation, const struct FCollisionShape &CollisionShape, FMTDResult *OutMTD=nullptr) const
 Test if the bodyinstance overlaps with the specified shape at the specified position/rotation 更多...
 
bool OverlapTest_AssumesLocked (const FVector &Position, const FQuat &Rotation, const struct FCollisionShape &CollisionShape, FMTDResult *OutMTD=nullptr) const
 Test if the bodyinstance overlaps with the specified shape at the specified position/rotation Note: This function is not thread safe. 更多...
 
bool OverlapTestForBodies (const FVector &Position, const FQuat &Rotation, const TArray< FBodyInstance * > &Bodies) const
 Test if the bodyinstance overlaps with the specified body instances 更多...
 
void PostShapeChange ()
 After adding/removing shapes call this function to update mass distribution etc...
 
void PutInstanceToSleep ()
 Force this body to sleep
 
bool ReplaceResponseToChannels (ECollisionResponse OldResponse, ECollisionResponse NewResponse)
 Replace the channels on this body matching the old response with the new response
 
void SetAngularVelocityInRadians (const FVector &NewAngVel, bool bAddToCurrent, bool bAutoWake=true)
 Set the angular velocity of this body
 
void SetBodyTransform (const FTransform &NewTransform, ETeleportType Teleport, bool bAutoWake=true)
 Move the physics body to a new pose. 更多...
 
void SetCollisionEnabled (ECollisionEnabled::Type NewType, bool bUpdatePhysicsFilterData=true)
 Controls what kind of collision is enabled for this body and allows optional disable physics rebuild
 
void SetCollisionProfileName (FName InCollisionProfileName)
 Set Collision Profile Name This function should be called outside of constructors to set profile name. 更多...
 
void SetCollisionProfileNameDeferred (FName InCollisionProfileName)
 Set Collision Profile Name (deferred) This function is called by constructors when they set ProfileName This will change current CollisionProfileName, but collision data will not be set up until the physics state is created or the collision profile is accessed. 更多...
 
void SetContactModification (bool bNewContactModification)
 Enables/disables contact modification
 
void SetContactReportForceThreshold (float Threshold)
 Set a new contact report force threhold. 更多...
 
void SetDOFLock (EDOFMode::Type NewDOFMode)
 [Physx Only] Locks physical movement along axis.
 
void SetEnableGravity (bool bGravityEnabled)
 Enables/disables whether this body is affected by gravity.
 
void SetInstanceNotifyRBCollision (bool bNewNotifyCollision)
 Set whether we should get a notification about physics collisions
 
void SetInstanceSimulatePhysics (bool bSimulate, bool bMaintainPhysicsBlending=false)
 Set this body to be fixed (kinematic) or not.
 
void SetLinearVelocity (const FVector &NewVel, bool bAddToCurrent, bool bAutoWake=true)
 Set the linear velocity of this body
 
void SetMaskFilter (FMaskFilter InMaskFilter)
 Updates the mask filter.
 
void SetMassOverride (float MassInKG, bool bNewOverrideMass=true)
 Sets the mass override
 
void SetMassScale (float InMassScale=1.f)
 Modify the mass scale of this body
 
void SetMassSpaceLocal (const FTransform &NewMassSpaceLocalTM)
 TODO: this only works at runtime when the physics state has been created. 更多...
 
void SetMaxAngularVelocityInRadians (float NewMaxAngVel, bool bAddToCurrent, bool bUpdateOverrideMaxAngularVelocity=true)
 Set the maximum angular velocity of this body
 
void SetMaxDepenetrationVelocity (float MaxVelocity)
 Set the maximum depenetration velocity the physics simulation will introduce
 
void SetObjectType (ECollisionChannel Channel)
 Set the movement channel of this body to the one supplied
 
void SetPhysMaterialOverride (class UPhysicalMaterial *NewPhysMaterial)
 Set physical material override for this body
 
bool SetResponseToAllChannels (ECollisionResponse NewResponse)
 Set the response of this body to all channels
 
bool SetResponseToChannel (ECollisionChannel Channel, ECollisionResponse NewResponse)
 Set the collision response of this body to a particular channel
 
bool SetResponseToChannels (const FCollisionResponseContainer &NewResponses)
 Set the response of this body to the supplied settings
 
void SetShapeCollisionEnabled (const int32 ShapeIndex, ECollisionEnabled::Type NewType, bool bUpdatePhysicsFilterData=true)
 Controls what kind of collision is enabled for a particular shape
 
bool SetShapeResponseToChannels (const int32 ShapeIndex, const FCollisionResponseContainer &NewResponses)
 Set the response of a specific shape on this body to the supplied settings
 
void SetUseCCD (bool bInUseCCD)
 Enable/disable Continuous Collidion Detection feature
 
void SetWalkableSlopeOverride (const FWalkableSlopeOverride &NewOverride, bool bNewOverideSetting=true)
 Sets a custom slope override struct for this instance. 更多...
 
bool ShouldInterpolateWhenSubStepping () const
 Whether we should interpolate when substepping. 更多...
 
bool Sweep (struct FHitResult &OutHit, const FVector &Start, const FVector &End, const FQuat &ShapeWorldRotation, const FCollisionShape &Shape, bool bTraceComplex) const
 Trace a shape against just this bodyinstance 更多...
 
void TermBody (bool bNeverDeferRelease=false)
 Terminates the body, releasing resources 更多...
 
void UnWeld (FBodyInstance *Body)
 Takes a welded body and unwelds it. 更多...
 
bool UpdateBodyScale (const FVector &InScale3D, bool bForceUpdate=false)
 Update Body Scale 更多...
 
void UpdateDampingProperties ()
 Update instance's linear and angular damping
 
void UpdateInstanceSimulatePhysics ()
 Makes sure the current kinematic state matches the simulate flag
 
void UpdateMassProperties ()
 Update instance's mass properties (mass, inertia and center-of-mass offset) based on MassScale, InstanceMassScale and COMNudge.
 
void UpdatePhysicalMaterials ()
 Update the instance's material properties (friction, restitution)
 
void UpdatePhysicsFilterData ()
 Update the instances collision filtering data
 
void UpdateTriMeshVertices (const TArray< FVector > &NewPositions)
 Dynamically update the vertices of per-poly collision for this body.
 
void UseExternalCollisionProfile (UBodySetup *InExternalCollisionProfileBodySetup)
 Use the collision profile found in the given BodySetup's default BodyInstance
 
void WakeInstance ()
 Wake this body
 
bool Weld (FBodyInstance *Body, const FTransform &RelativeTM)
 Takes two body instances and welds them together to create a single simulated rigid body. 更多...
 

静态 Public 成员函数

static void ApplyMaterialToShape_AssumesLocked (const FPhysicsShapeHandle &InShape, UPhysicalMaterial *SimplePhysMat, const TArrayView< UPhysicalMaterial * > &ComplexPhysMats, const TArrayView< FPhysicalMaterialMaskParams > *ComplexPhysMatMasks=nullptr)
 Apply a material directly to the passed in shape. 更多...
 
static void BuildBodyCollisionFlags (FBodyCollisionFlags &OutFlags, ECollisionEnabled::Type UseCollisionEnabled, bool bUseComplexAsSimple)
 Build the flags to control which types of collision (sim and query) shapes owned by this BodyInstance should have.
 
static void GetComplexPhysicalMaterials (const FBodyInstance *BodyInstance, TWeakObjectPtr< UPrimitiveComponent > Owner, TArray< UPhysicalMaterial * > &OutPhysMaterials, TArray< FPhysicalMaterialMaskParams > *OutPhysMaterialMasks=nullptr)
 Find the correct PhysicalMaterial and PhysicalMaterialMasks for complex geometry on a given body and owner. 更多...
 
static UPhysicalMaterial * GetSimplePhysicalMaterial (const FBodyInstance *BodyInstance, TWeakObjectPtr< UPrimitiveComponent > Owner, TWeakObjectPtr< UBodySetup > BodySetupPtr)
 Find the correct PhysicalMaterial for simple geometry on a given body and owner. 更多...
 
static void InitStaticBodies (const TArray< FBodyInstance * > &Bodies, const TArray< FTransform > &Transforms, UBodySetup *BodySetup, class UPrimitiveComponent *PrimitiveComp, FPhysScene *InRBScene)
 Standalone path to batch initialize large amounts of static bodies, which will be deferred till the next scene update for fast scene addition. 更多...
 
static bool ValidateTransform (const FTransform &Transform, const FString &DebugName, const UBodySetup *Setup)
 Validate a body transform, outputting debug info 更多...
 

Public 属性

float AngularDamping
 'Drag' force added to reduce angular movement
 
uint8 bContactModification: 1
 Enable contact modification. 更多...
 
uint8 bHACK_DisableCollisionResponse: 1
 @HACK: These are ONLY used when the 'p.EnableDynamicPerBodyFilterHacks' CVar is set (disabled by default). 更多...
 
uint8 bIgnoreAnalyticCollisions: 1
 If true ignore analytic collisions and treat objects as a general implicit surface
 
uint8 bLockRotation: 1
 [Physx Only] When a Locked Axis Mode is selected, will lock rotation to the specified axis
 
uint8 bLockTranslation: 1
 [Physx Only] When a Locked Axis Mode is selected, will lock translation on the specified axis
 
uint8 bLockXRotation: 1
 [Physx Only] Lock rotation about the X-axis
 
uint8 bLockXTranslation: 1
 [Physx Only] Lock translation along the X-axis
 
uint8 bLockYRotation: 1
 [Physx Only] Lock rotation about the Y-axis
 
uint8 bLockYTranslation: 1
 [Physx Only] Lock translation along the Y-axis
 
uint8 bLockZRotation: 1
 [Physx Only] Lock rotation about the Z-axis
 
uint8 bLockZTranslation: 1
 [Physx Only] Lock translation along the Z-axis
 
uint8 bNotifyRigidBodyCollision: 1
 Should 'Hit' events fire when this object collides during physics simulation.
 
uint8 bOverrideMaxAngularVelocity: 1
 Override the default max angular velocity
 
uint8 bUseCCD: 1
 If true Continuous Collision Detection (CCD) will be used for this component
 
FVector COMNudge
 User specified offset for the center of mass of this object, from the calculated location
 
FVector CustomDOFPlaneNormal
 Locks physical movement along a custom plane for a given normal.
 
float CustomSleepThresholdMultiplier
 If the SleepFamily is set to custom, multiply the natural sleep threshold by this amount. 更多...
 
FConstraintInstance * DOFConstraint
 [Physx Only] Constraint used to allow for easy DOF setup per bodyinstance
 
TEnumAsByte< EDOFMode::Type > DOFMode
 [Physx Only] Locks physical movement along specified axis.
 
FVector InertiaTensorScale
 Per-instance scaling of inertia (bigger number means it'll be harder to rotate)
 
int32 InstanceBodyIndex
 Index of this BodyInstance within the SkeletalMeshComponent/PhysicsAsset. 更多...
 
int16 InstanceBoneIndex
 When we are a body within a SkeletalMeshComponent, we cache the index of the bone we represent, to speed up sync'ing physics to anim.
 
float LinearDamping
 'Drag' force added to reduce linear movement
 
float MassScale
 Per-instance scaling of mass
 
float MaxAngularVelocity
 The maximum angular velocity for this instance [degrees/s]
 
TWeakObjectPtr< class UPrimitiveComponent > OwnerComponent
 PrimitiveComponent containing this body. 更多...
 
float PhysicsBlendWeight
 Influence of rigid body physics (blending) on the mesh's pose (0.0 == use only animation, 1.0 == use only physics) 更多...
 
uint8 PositionSolverIterationCount
 [PhysX Only] This physics body's solver iteration count for position. 更多...
 
FVector Scale3D
 Current scale of physics - used to know when and how physics must be rescaled to match current transform of OwnerComponent.
 
ESleepFamily SleepFamily
 The set of values used in considering when put this body to sleep.
 
float StabilizationThresholdMultiplier
 Stabilization factor for this body if Physics stabilization is enabled. 更多...
 
uint8 VelocitySolverIterationCount
 [PhysX Only] This physics body's solver iteration count for velocity. 更多...
 
FBodyInstance * WeldParent
 The parent body that we are welded to
 

Protected 成员函数

void UpdateInterpolateWhenSubStepping ()
 Update the substepping interpolation flag
 

Protected 属性

uint8 bInterpolateWhenSubStepping: 1
 Internal flag to allow us to quickly check whether we should interpolate when substepping e.g. 更多...
 
uint8 bOverrideMaxDepenetrationVelocity: 1
 [PhysX Only] Whether this body instance has its own custom MaxDepenetrationVelocity
 
uint8 bOverrideWalkableSlopeOnInstance: 1
 Whether this instance of the object has its own custom walkable slope override setting.
 
uint8 bPendingCollisionProfileSetup: 1
 Whether we are pending a collision profile setup
 
TWeakObjectPtr< UBodySetup > ExternalCollisionProfileBodySetup
 The body setup holding the default body instance and its collision profile.
 
float MassInKgOverride
 Mass of the body in KG. 更多...
 
float MaxDepenetrationVelocity
 [PhysX Only] The maximum velocity used to depenetrate this object
 
class UPhysicalMaterial * PhysMaterialOverride
 Allows you to override the PhysicalMaterial to use for simple collision on this body.
 
struct FWalkableSlopeOverride WalkableSlopeOverride
 Custom walkable slope override setting for this instance. 更多...
 

友元

class UCollisionProfile
 
class UPhysicsAsset
 

详细描述

Container for a physics representation of an object

成员函数说明

◆ AddCustomPhysics()

void FBodyInstance::AddCustomPhysics ( FCalculateCustomPhysics &  CalculateCustomPhysics)

Add custom forces and torques on the body.

The callback will be called more than once, if substepping enabled, for every substep.

◆ AddRadialForceToBody()

void FBodyInstance::AddRadialForceToBody ( const FVector &  Origin,
float  Radius,
float  Strength,
uint8  Falloff,
bool  bAccelChange = false,
bool  bAllowSubstepping = true 
)

Add a force to this bodyinstance, originating from the supplied world-space location.

参数
OriginOrigin of force in world space.
RadiusRadius within which to apply the force.
StrengthStrength of force to apply.
FalloffAllows you to control the strength of the force as a function of distance from Origin.
bAccelChangeIf true, Strength is taken as a change in acceleration instead of a physical force (i.e. mass will have no effect).
bAllowSubsteppingWhether we should sub-step this radial force. You should only turn this off if you're calling it from a sub-step callback, otherwise there will be energy loss

◆ AddRadialImpulseToBody()

void FBodyInstance::AddRadialImpulseToBody ( const FVector &  Origin,
float  Radius,
float  Strength,
uint8  Falloff,
bool  bVelChange = false 
)

Add an impulse to this bodyinstance, radiating out from the specified position.

参数
OriginPoint of origin for the radial impulse blast, in world space
RadiusSize of radial impulse. Beyond this distance from Origin, there will be no affect.
StrengthMaximum strength of impulse applied to body.
FalloffAllows you to control the strength of the impulse as a function of distance from Origin.
bVelChangeIf true, the Strength is taken as a change in velocity instead of an impulse (ie. mass will have no effect).

◆ ApplyMaterialToInstanceShapes_AssumesLocked()

void FBodyInstance::ApplyMaterialToInstanceShapes_AssumesLocked ( UPhysicalMaterial *  SimplePhysMat,
TArray< UPhysicalMaterial * > &  ComplexPhysMats,
const TArrayView< FPhysicalMaterialMaskParams > &  ComplexPhysMatMasks 
)

Note: This function is not thread safe.

Make sure you obtain the appropriate physics scene lock before calling it

◆ ApplyMaterialToShape_AssumesLocked()

static void FBodyInstance::ApplyMaterialToShape_AssumesLocked ( const FPhysicsShapeHandle &  InShape,
UPhysicalMaterial *  SimplePhysMat,
const TArrayView< UPhysicalMaterial * > &  ComplexPhysMats,
const TArrayView< FPhysicalMaterialMaskParams > *  ComplexPhysMatMasks = nullptr 
)
static

Apply a material directly to the passed in shape.

Note this function is very advanced and requires knowledge of shape sharing as well as threading. Note: assumes the appropriate locks have been obtained

参数
PShapeThe shape we are applying the material to
SimplePhysMatThe material to use if a simple shape is provided (or complex materials are empty)
ComplexPhysMatsThe array of materials to apply if a complex shape is provided

◆ DoesUseCollisionProfile()

bool FBodyInstance::DoesUseCollisionProfile ( ) const

return true if it uses Collision Profile System.

False otherwise

◆ GetAllShapes_AssumesLocked()

int32 FBodyInstance::GetAllShapes_AssumesLocked ( TArray< FPhysicsShapeHandle > &  OutShapes) const

Utility to get all the shapes from a FBodyInstance NOTE: This function is not thread safe.

You must hold the physics scene lock while calling it and reading/writing from the shapes

◆ GetBodyInertiaTensor()

FVector FBodyInstance::GetBodyInertiaTensor ( ) const

Return the body's inertia tensor.

This is returned in local mass space

◆ GetBodyInstanceResourceSizeEx()

void FBodyInstance::GetBodyInstanceResourceSizeEx ( FResourceSizeEx &  CumulativeResourceSize) const

Returns memory used by resources allocated for this body instance ( ex.

physics resources )

◆ GetComplexPhysicalMaterials()

static void FBodyInstance::GetComplexPhysicalMaterials ( const FBodyInstance *  BodyInstance,
TWeakObjectPtr< UPrimitiveComponent >  Owner,
TArray< UPhysicalMaterial * > &  OutPhysMaterials,
TArray< FPhysicalMaterialMaskParams > *  OutPhysMaterialMasks = nullptr 
)
static

Find the correct PhysicalMaterial and PhysicalMaterialMasks for complex geometry on a given body and owner.

This is really for internal use during serialization

◆ GetDistanceToBody()

float FBodyInstance::GetDistanceToBody ( const FVector &  Point,
FVector &  OutPointOnBody 
) const

Get the square of the distance to the body surface if available It is only valid if BodyShape is convex If point is inside or shape is not convex, it will return 0.f

参数
PointPoint in world space
OutPointOnBodyPoint on the surface of body closest to Point

◆ GetMassOverride()

float FBodyInstance::GetMassOverride ( ) const
inline

Returns the mass override.

See MassInKgOverride for documentation

◆ GetOriginalBodyInstance()

const FBodyInstance * FBodyInstance::GetOriginalBodyInstance ( const FPhysicsShapeHandle &  InShape) const

Returns the original owning body instance.

This is needed for welding

◆ GetSimplePhysicalMaterial()

static UPhysicalMaterial * FBodyInstance::GetSimplePhysicalMaterial ( const FBodyInstance *  BodyInstance,
TWeakObjectPtr< UPrimitiveComponent >  Owner,
TWeakObjectPtr< UBodySetup >  BodySetupPtr 
)
static

Find the correct PhysicalMaterial for simple geometry on a given body and owner.

This is really for internal use during serialization

◆ GetSquaredDistanceToBody()

bool FBodyInstance::GetSquaredDistanceToBody ( const FVector &  Point,
float &  OutDistanceSquared,
FVector &  OutPointOnBody 
) const

Get distance to the body surface if available It is only valid if BodyShape is convex If point is inside distance it will be 0 Returns false if geometry is not supported

参数
PointPoint in world space
OutDistanceSquaredHow far from the instance the point is. 0 if inside the shape
OutPointOnBodyPoint on the surface of body closest to Point
返回
true if a distance to the body was found and OutDistanceSquared has been populated

◆ GetUnrealWorldVelocityAtPoint()

FVector FBodyInstance::GetUnrealWorldVelocityAtPoint ( const FVector &  Point) const

Get current velocity of a point on this physics body, in world space.

Point is specified in world space.

◆ GetUnrealWorldVelocityAtPoint_AssumesLocked()

FVector FBodyInstance::GetUnrealWorldVelocityAtPoint_AssumesLocked ( const FVector &  Point) const

Get current velocity of a point on this physics body, in world space.

Point is specified in world space.

◆ GetWalkableSlopeOverride()

const struct FWalkableSlopeOverride & FBodyInstance::GetWalkableSlopeOverride ( ) const

Returns the slope override struct for this instance.

If we don't have our own custom setting, it will return the setting from the body setup.

◆ InitBody()

void FBodyInstance::InitBody ( UBodySetup *  Setup,
const FTransform &  Transform,
UPrimitiveComponent *  PrimComp,
FPhysScene *  InRBScene,
const FInitBodySpawnParams &  SpawnParams 
)

Initialise a single rigid body (this FBodyInstance) for the given body setup

参数
SetupThe setup to use to create the body
TransformTransform of the body
PrimCompThe owning component
InRBSceneThe physics scene to place the body into
SpawnParamsThe parameters for determining certain spawn behavior
InAggregateAn aggregate to place the body into

◆ InitDynamicProperties_AssumesLocked()

void FBodyInstance::InitDynamicProperties_AssumesLocked ( )

Initialise dynamic properties for this instance when using physics - this must be done after scene addition.

Note: This function is not thread safe. Make sure to obtain the appropriate physics scene locks before calling this function

◆ InitStaticBodies()

static void FBodyInstance::InitStaticBodies ( const TArray< FBodyInstance * > &  Bodies,
const TArray< FTransform > &  Transforms,
UBodySetup *  BodySetup,
class UPrimitiveComponent *  PrimitiveComp,
FPhysScene *  InRBScene 
)
static

Standalone path to batch initialize large amounts of static bodies, which will be deferred till the next scene update for fast scene addition.

参数
Bodies
Transforms
BodySetup
PrimitiveComp
InRBScene

◆ LineTrace()

bool FBodyInstance::LineTrace ( struct FHitResult &  OutHit,
const FVector &  Start,
const FVector &  End,
bool  bTraceComplex,
bool  bReturnPhysicalMaterial = false 
) const

Trace a ray against just this bodyinstance

参数
OutHitInformation about hit against this component, if true is returned
StartStart location of the ray
EndEnd location of the ray
bTraceComplexShould we trace against complex or simple collision of this body
bReturnPhysicalMaterialFill in the PhysMaterial field of OutHit
返回
true if a hit is found

◆ LoadProfileData()

void FBodyInstance::LoadProfileData ( bool  bVerifyProfile)

Update profile data if required

参数
bVerifyProfile - if true, it makes sure it has correct set up with current profile, if false, it overwrites from profile data (for backward compatibility)

◆ OnCalculateCustomProjection()

FCalculateCustomProjection & FBodyInstance::OnCalculateCustomProjection ( )

Returns reference to the OnCalculateCustomProjection delegate.

Will allocate delegate struct if not already created.

◆ OnRecalculatedMassProperties()

FRecalculatedMassProperties & FBodyInstance::OnRecalculatedMassProperties ( )

Returns reference to the OnRecalculatedMassProperties delegate.

Will allocate delegate struct if not already created.

◆ OverlapMulti()

bool FBodyInstance::OverlapMulti ( TArray< struct FOverlapResult > &  InOutOverlaps,
const class UWorld *  World,
const FTransform *  pWorldToComponent,
const FVector &  Pos,
const FQuat &  Rot,
ECollisionChannel  TestChannel,
const struct FComponentQueryParams &  Params,
const struct FCollisionResponseParams &  ResponseParams,
const FCollisionObjectQueryParams &  ObjectQueryParams = FCollisionObjectQueryParams::DefaultObjectQueryParam 
) const

Determines the set of components that this body instance would overlap with at the supplied location/rotation

注解
The overload taking rotation as an FQuat is slightly faster than the version using FRotator (which will be converted to an FQuat)..
参数
InOutOverlapsArray of overlaps found between this component in specified pose and the world (new overlaps will be appended, the array is not cleared!)
WorldWorld to use for overlap test
pWorldToComponentUsed to convert the body instance world space position into local space before teleporting it to (Pos, Rot) [optional, use when the body instance isn't centered on the component instance]
PosLocation to place the component's geometry at to test against the world
RotRotation to place components' geometry at to test against the world
TestChannelThe 'channel' that this ray is in, used to determine which components to hit
Params
ResponseParams
ObjectQueryParamsList of object types it's looking for. When this enters, we do object query with component shape
返回
TRUE if OutOverlaps contains any blocking results

◆ OverlapTest()

bool FBodyInstance::OverlapTest ( const FVector &  Position,
const FQuat &  Rotation,
const struct FCollisionShape &  CollisionShape,
FMTDResult *  OutMTD = nullptr 
) const

Test if the bodyinstance overlaps with the specified shape at the specified position/rotation

参数
PositionPosition to place the shape at before testing
RotationRotation to apply to the shape before testing
CollisionShapeShape to test against
OutMTDThe minimum translation direction needed to push the shape out of this BodyInstance. (Optional)
返回
true if the geometry associated with this body instance overlaps the query shape at the specified location/rotation

◆ OverlapTest_AssumesLocked()

bool FBodyInstance::OverlapTest_AssumesLocked ( const FVector &  Position,
const FQuat &  Rotation,
const struct FCollisionShape &  CollisionShape,
FMTDResult *  OutMTD = nullptr 
) const

Test if the bodyinstance overlaps with the specified shape at the specified position/rotation Note: This function is not thread safe.

Make sure you obtain the physics scene read lock before calling it

参数
PositionPosition to place the shape at before testing
RotationRotation to apply to the shape before testing
CollisionShapeShape to test against
OutMTDThe minimum translation direction needed to push the shape out of this BodyInstance. (Optional)
返回
true if the geometry associated with this body instance overlaps the query shape at the specified location/rotation

◆ OverlapTestForBodies()

FORCEINLINE_DEBUGGABLE bool FBodyInstance::OverlapTestForBodies ( const FVector &  Position,
const FQuat &  Rotation,
const TArray< FBodyInstance * > &  Bodies 
) const

Test if the bodyinstance overlaps with the specified body instances

参数
PositionPosition to place our shapes at before testing (shapes of this BodyInstance)
RotationRotation to apply to our shapes before testing (shapes of this BodyInstance)
BodiesThe bodies we are testing for overlap with. These bodies will be in world space already
返回
true if any of the bodies passed in overlap with this

◆ SetBodyTransform()

void FBodyInstance::SetBodyTransform ( const FTransform &  NewTransform,
ETeleportType  Teleport,
bool  bAutoWake = true 
)

Move the physics body to a new pose.

参数
bTeleportIf true, no velocity is inferred on the kinematic body from this movement, but it moves right away.

◆ SetCollisionProfileName()

void FBodyInstance::SetCollisionProfileName ( FName  InCollisionProfileName)

Set Collision Profile Name This function should be called outside of constructors to set profile name.

This will change current CollisionProfileName to be this, and overwrite Collision Setting

参数
InCollisionProfileName: New Profile Name

◆ SetCollisionProfileNameDeferred()

void FBodyInstance::SetCollisionProfileNameDeferred ( FName  InCollisionProfileName)

Set Collision Profile Name (deferred) This function is called by constructors when they set ProfileName This will change current CollisionProfileName, but collision data will not be set up until the physics state is created or the collision profile is accessed.

参数
InCollisionProfileName: New Profile Name

◆ SetContactReportForceThreshold()

void FBodyInstance::SetContactReportForceThreshold ( float  Threshold)

Set a new contact report force threhold.

Threshold < 0 disables this feature.

◆ SetMassSpaceLocal()

void FBodyInstance::SetMassSpaceLocal ( const FTransform &  NewMassSpaceLocalTM)

TODO: this only works at runtime when the physics state has been created.

Any changes that result in recomputing mass properties will not properly remember this

◆ SetWalkableSlopeOverride()

void FBodyInstance::SetWalkableSlopeOverride ( const FWalkableSlopeOverride &  NewOverride,
bool  bNewOverideSetting = true 
)

Sets a custom slope override struct for this instance.

Implicitly sets bOverrideWalkableSlopeOnInstance to true.

◆ ShouldInterpolateWhenSubStepping()

bool FBodyInstance::ShouldInterpolateWhenSubStepping ( ) const
inline

Whether we should interpolate when substepping.

参见
bInterpolateWhenSubStepping

◆ Sweep()

bool FBodyInstance::Sweep ( struct FHitResult &  OutHit,
const FVector &  Start,
const FVector &  End,
const FQuat &  ShapeWorldRotation,
const FCollisionShape &  Shape,
bool  bTraceComplex 
) const

Trace a shape against just this bodyinstance

参数
OutHitInformation about hit against this component, if true is returned
StartStart location of the box
EndEnd location of the box
ShapeWorldRotationThe rotation applied to the collision shape in world space.
CollisionShapeCollision Shape
bTraceComplexShould we trace against complex or simple collision of this body
返回
true if a hit is found

◆ TermBody()

void FBodyInstance::TermBody ( bool  bNeverDeferRelease = false)

Terminates the body, releasing resources

参数
bNeverDeferReleaseIn some cases orphaned actors can have their internal release deferred. If this isn't desired this flag will override that behavior

◆ UnWeld()

void FBodyInstance::UnWeld ( FBodyInstance *  Body)

Takes a welded body and unwelds it.

This function does not create the new body, it only removes the old one

◆ UpdateBodyScale()

bool FBodyInstance::UpdateBodyScale ( const FVector &  InScale3D,
bool  bForceUpdate = false 
)

Update Body Scale

参数
InScale3DNew Scale3D. If that's different from previous Scale3D, it will update Body scale.
bForceUpdateWill refresh shape dimensions from BodySetup, even if scale has not changed.
返回
true if succeed

◆ ValidateTransform()

static bool FBodyInstance::ValidateTransform ( const FTransform &  Transform,
const FString &  DebugName,
const UBodySetup *  Setup 
)
static

Validate a body transform, outputting debug info

参数
TransformTransform to debug
DebugNameName of the instance for logging
SetupBody setup for this instance

◆ Weld()

bool FBodyInstance::Weld ( FBodyInstance *  Body,
const FTransform &  RelativeTM 
)

Takes two body instances and welds them together to create a single simulated rigid body.

Returns true if success.

类成员变量说明

◆ bContactModification

uint8 FBodyInstance::bContactModification

Enable contact modification.

Assumes custom contact modification has been provided (see FPhysXContactModifyCallback)

◆ bHACK_DisableCollisionResponse

uint8 FBodyInstance::bHACK_DisableCollisionResponse

@HACK: These are ONLY used when the 'p.EnableDynamicPerBodyFilterHacks' CVar is set (disabled by default).

Some games need to dynamically modify collision per skeletal body. These provide game code a way to do that, until we're able to refactor how skeletal bodies work.

◆ bInterpolateWhenSubStepping

uint8 FBodyInstance::bInterpolateWhenSubStepping
protected

Internal flag to allow us to quickly check whether we should interpolate when substepping e.g.

kinematic bodies that are QueryOnly do not need to interpolate as we will not be querying them at a sub-position. This is complicated by welding, where multiple the CollisionEnabled flag of the root must be considered.

◆ CustomSleepThresholdMultiplier

float FBodyInstance::CustomSleepThresholdMultiplier

If the SleepFamily is set to custom, multiply the natural sleep threshold by this amount.

A higher number will cause the body to sleep sooner.

◆ InstanceBodyIndex

int32 FBodyInstance::InstanceBodyIndex

Index of this BodyInstance within the SkeletalMeshComponent/PhysicsAsset.

Is INDEX_NONE if a single body component

◆ MassInKgOverride

float FBodyInstance::MassInKgOverride
protected

Mass of the body in KG.

By default we compute this based on physical material and mass scale.

参见
bOverrideMass to set this directly

◆ OwnerComponent

TWeakObjectPtr<class UPrimitiveComponent> FBodyInstance::OwnerComponent

PrimitiveComponent containing this body.


◆ PhysicsBlendWeight

float FBodyInstance::PhysicsBlendWeight

Influence of rigid body physics (blending) on the mesh's pose (0.0 == use only animation, 1.0 == use only physics)

Provide appropriate interface for doing this instead of allowing BlueprintReadWrite

◆ PositionSolverIterationCount

uint8 FBodyInstance::PositionSolverIterationCount

[PhysX Only] This physics body's solver iteration count for position.

Increasing this will be more CPU intensive, but better stabilized.

◆ StabilizationThresholdMultiplier

float FBodyInstance::StabilizationThresholdMultiplier

Stabilization factor for this body if Physics stabilization is enabled.

A higher number will cause more aggressive stabilization at the risk of loss of momentum at low speeds. A value of 0 will disable stabilization for this body.

◆ VelocitySolverIterationCount

uint8 FBodyInstance::VelocitySolverIterationCount

[PhysX Only] This physics body's solver iteration count for velocity.

Increasing this will be more CPU intensive, but better stabilized.

◆ WalkableSlopeOverride

struct FWalkableSlopeOverride FBodyInstance::WalkableSlopeOverride
protected

Custom walkable slope override setting for this instance.

参见
GetWalkableSlopeOverride(), SetWalkableSlopeOverride()

该结构体的文档由以下文件生成: