UBodySetup

BodySetup contains all collision information that is associated with a single asset.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/PhysicsEngine/BodySetup.h

Include

#include "PhysicsEngine/BodySetup.h"

Syntax

class UBodySetup : public UObject

Remarks

BodySetup contains all collision information that is associated with a single asset. A single BodySetup instance is shared among many BodyInstances so that geometry data is not duplicated. Assets typically implement a GetBodySetup function that is used during physics state creation.

Variables

Name Description

Public variable

FKAggregateGeom

 

AggGeom

Simplified collision representation of this

Public variable

uint8: 1

 

bConsiderForBounds

Should this BodySetup be considered for the bounding box of the PhysicsAsset (and hence SkeletalMeshComponent).

Public variable

uint8: 1

 

bCreatedPhysicsMeshes

Flag used to know if we have created the physics convex and tri meshes from the cooked data yet

Public variable

uint8: 1

 

bDoubleSidedGeometry

If true, the physics triangle mesh will use double sided faces when doing scene queries.

Public variable

uint8: 1

 

bFailedToCreatePhysicsMeshes

Flag used to know if we have failed to create physics meshes.

Public variable

uint8: 1

 

bGenerateMirroredCollision

Should we generate data necessary to support collision on mirrored versions of this mesh.

Public variable

uint8: 1

 

bGenerateNonMirroredCollision

Should we generate data necessary to support collision on normal (non-mirrored) versions of this body.

Public variable

uint8: 1

 

bHasCookedCollisionData

Indicates whether this setup has any cooked collision data.

Public variable

uint8: 1

 

bMeshCollideAll

If true, the physics of this mesh (only affects static meshes) will always contain ALL elements from the mesh - not just the ones enabled for collision.

Public variable

uint8: 1

 

bNeverNeedsCookedCollisionData

Indicates that we will never use convex or trimesh shapes.

Public variable

FGuid

 

BodySetupGuid

GUID used to uniquely identify this setup so it can be found in the DDC

Public variable

FName

 

BoneName

Used in the PhysicsAsset case. Associates this Body with Bone in a skeletal mesh.

Public variable

uint8: 1

 

bSharedCookedData

Whether the cooked data is shared by multiple body setups.

Public variable

uint8: 1

 

bSupportUVsAndFaceRemap

If true, the physics triangle mesh will store UVs and the face remap table.

Public variable

FVector

 

BuildScale3D

Build scale for this body setup (static mesh settings define this value)

Public variable

TEnumAsByte< en...

 

CollisionReponse

Collision Type for this body. This eventually changes response to collision to others

Public variable

TEnumAsByte< en...

 

CollisionTraceFlag

Collision Trace behavior - by default, it will keep simple(convex)/complex(per-poly) separate

Public variable

FFormatContaine...

 

CookedFormatData

Cooked physics data for each format

Public variable

FFormatContaine...

 

CookedFormatDataOverride

Cooked physics data override.

Public variable

FPhysXCookHelpe...

 

CurrentCookHelper

References the current async cook helper. Used to be able to abort a cook task

Public variable

FBodyInstance

 

DefaultInstance

Default properties of the body instance, copied into objects on instantiation, was URB_BodyInstance

Public variable

TArray< int32 >

 

FaceRemap

Additional face remap table, if available.

Public variable

TEnumAsByte< EP...

 

PhysicsType

If simulated it will use physics, if kinematic it will not be affected by physics, but can interact with physically simulated bodies.

Public variable

UPhysicalMateri...

 

PhysMaterial

Physical material to use for simple collision on this body.

Public variable

TArray< physx::...

 

TriMeshes

Physics triangle mesh, created from cooked data in CreatePhysicsMeshes

Public variable

FBodySetupUVInf...

 

UVInfo

Additional UV info, if available. Used for determining UV for a line trace impact.

Public variable

FWalkableSlopeO...

 

WalkableSlopeOverride

Custom walkable slope setting for this body.

Constructors

Name Description

Public function

UBodySetup

(
    const FObjectInitializer& ObjectIn...
)

Public function

UBodySetup

(
    FVTableHelper& Helper
)

Needs implementation in BodySetup.cpp to compile UniquePtr for forward declared class

Destructors

Name Description

Public function Virtual

~UBodySetup()

Functions

Name Description

Public function

void

 

AbortPhysicsMeshAsyncCreation()

Aborts an async cook that hasn't begun.

Public function

void

 

AddCollisionFrom

(
    const FKAggregateGeom& FromAggGeom
)

Add collision shapes from another body setup to this one

Public function

void

 

AddCollisionFrom

(
    UBodySetup* FromSetup
)

Add collision shapes from another body setup to this one

Public function

void

 

AddShapesToRigidActor_AssumesLocked

(
    FBodyInstance* OwningInstance,
    FVector& Scale3D,
    UPhysicalMaterial* SimpleMater...,
    TArray< UPhysicalMaterial* >&...,
    TArray< FPhysicalMaterialMaskParams...,
    const FBodyCollisionData& BodyColl...,
    const FTransform& RelativeTM,
    TArray< FPhysicsShapeHandle >*...
)

Add the shapes defined by this body setup to the supplied PxRigidBody.

Public function Virtual Const

float

 

CalculateMass

(
    const UPrimitiveComponent* Com...
)

Calculates the mass.

Public function Const

bool

 

CalcUVAtLocation

(
    const FVector& BodySpaceLocation,
    int32 FaceIndex,
    int32 UVChannel,
    FVector2D& UV
)

Given a location in body space, and face index, find the UV of the desired UV channel.

Public function

void

 

ClearPhysicsMeshes()

Release Physics meshes (ConvexMeshes, TriMesh & TriMeshNegX)

Public function

void

 

CopyBodyPropertiesFrom

(
    const UBodySetup* FromSetup
)

Public function Virtual

void

 

CopyBodySetupProperty

(
    const UBodySetup* Other
)

Copy all UPROPERTY settings except the collision geometry.

Public function

bool

 

CreateFromModel

(
    UModel* InModel,
    bool bRemoveExisting
)

Converts a UModel to a set of convex hulls for simplified collision.

Public function Virtual

void

 

CreatePhysicsMeshes()

Create Physics meshes (ConvexMeshes, TriMesh & TriMeshNegX) from cooked data Release Physics meshes (ConvexMeshes, TriMesh & TriMeshNegX).

Public function

void

 

CreatePhysicsMeshesAsync

(
    FOnAsyncPhysicsCookFinished OnAsync...
)

Create Physics meshes (ConvexMeshes, TriMesh & TriMeshNegX) from cooked data async (useful for runtime cooking as it can go wide off the game thread) Release Physics meshes (ConvexMeshes, TriMesh & TriMeshNegX).

Public function Const

float

 

GetClosestPointAndNormal

(
    const FVector& WorldPosition,
    const FTransform& BodyToWorldTM,
    FVector& ClosestWorldPosition,
    FVector& FeatureNormal
)

Finds the closest point in the body setup.

Public function Const

TEnumAsByte<...

 

GetCollisionTraceFlag()

Public function Const

void

 

GetCookInfo

(
    FCookBodySetupInfo& OutCookInfo,
    EPhysXMeshCookFlags InCookFlags
)

Generates the information needed for cooking geometry.

Public function Const

void

 

GetGeometryDDCKey

(
    FString& OutString
)

Generate a string to uniquely describe the state of the geometry in this setup to populate the DDC

Public function Const

UPhysicalMat...

 

GetPhysMaterial()

Returns the physics material used for this body.

Public function Const

float

 

GetShortestDistanceToPoint

(
    const FVector& WorldPosition,
    const FTransform& BodyToWorldTM
)

Finds the shortest distance between the body setup and a world position.

Public function Virtual Const

float

 

GetVolume

(
    const FVector& Scale
)

Returns the volume of this element

Public function Virtual

void

 

InvalidatePhysicsData()

Invalidate physics data

Public function

void

 

RemoveSimpleCollision()

Clear all simple collision

Public function

void

 

RescaleSimpleCollision

(
    FVector BuildScale
)

Rescales simple collision geometry. Note you must recreate physics meshes after this

Public function

void

 

UpdateTriMeshVertices

(
    const TArray< FVector >& NewPositi...
)

Updates the tri mesh collision with new positions, and refits the BVH to match.

Overridden from UObject

Name Description

Public function Virtual

void

 

BeginCacheForCookedPlatformData

(
    const ITargetPlatform* TargetP...
)

Starts caching of platform specific data for the target platform Called when cooking before serialization so that object can prepare platform specific data Not called during normal loading of objects

Public function Virtual

void

 

BeginDestroy()

Called before destroying the object.

Public function Virtual

void

 

ClearCachedCookedPlatformData

(
    const ITargetPlatform* TargetP...
)

Clears cached cooked platform data for specific platform

Public function Virtual

void

 

FinishDestroy()

Called to finish destroying the object.

Public function Virtual

void

 

GetResourceSizeEx

(
    FResourceSizeEx& CumulativeResourc...
)

Get the size of the object/resource for use in memory tools or to display to artists/LDs in the Editor This is the extended version which separates up the used memory into different memory regions (the actual definition of which may be platform specific).

Public function Virtual

void

 

PostEditChangeProperty

(
    FPropertyChangedEvent& PropertyCha...
)

Called when a property on this object has been modified externally

Public function Virtual

void

 

PostEditUndo()

Called after applying a transaction to the object.

Public function Virtual

void

 

PostInitProperties()

Called after the C++ constructor and after the properties have been initialized, including those loaded from config.

Public function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object.

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Deprecated Variables

Name Description

Public variable

uint8: 1

 

bAlwaysFullAnimWeight_DEPRECATED

If true (and bEnableFullAnimWeightBodies in SkelMeshComp is true), the physics of this bone will always be blended into the skeletal mesh, regardless of what PhysicsWeight of the SkelMeshComp is.

Public variable

float

 

BuildScale_DEPRECATED

See Also

GetBodySetup

FBodyInstance

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss