UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UClusterUnionComponent Class Reference

#include <ClusterUnionComponent.h>

+ Inheritance diagram for UClusterUnionComponent:

Classes

struct  FMappedBoneData
 
struct  FMappedComponentKey
 

Public Types

using FSpatialAcceleration = Chaos::ISpatialAcceleration< FExternalSpatialAccelerationPayload, Chaos::FReal, 3 >
 
using FLocalBonesToTransformMap = TSortedMap< int32, FMappedBoneData, TInlineAllocator< 1 > >
 

Public Member Functions

ENGINE_API UClusterUnionComponent (const FObjectInitializer &ObjectInitializer)
 
ENGINE_API void AddComponentToCluster (UPrimitiveComponent *InComponent, const TArray< int32 > &BoneIds, bool bRebuildGeometry=true)
 
ENGINE_API void RemoveComponentFromCluster (UPrimitiveComponent *InComponent)
 
ENGINE_API void RemoveComponentBonesFromCluster (UPrimitiveComponent *InComponent, const TArray< int32 > &BoneIds)
 
ENGINE_API TArray< UPrimitiveComponent * > GetPrimitiveComponents ()
 
ENGINE_API TArray< AActor * > GetActors ()
 
virtual ENGINE_API void SetIsAnchored (bool bIsAnchored)
 
ENGINE_API bool IsAnchored () const
 
ENGINE_API void SetEnableDamageFromCollision (bool bValue)
 
ENGINE_API void SyncClusterUnionFromProxy (const FTransform &NewTransform, TArray< TTuple< UPrimitiveComponent *, FTransform > > *OutNewComponents)
 
bool IsComponentAdded (UPrimitiveComponent *Component)
 
virtual ENGINE_API void WakeAllRigidBodies () override
 
virtual ENGINE_API bool IsAnyRigidBodyAwake () override
 
virtual ENGINE_API void SetMassOverrideInKg (FName BoneName, float MassInKg, bool bOverrideMass) override
 
ENGINE_API bool LineTraceComponent (TArray< FHitResult > &OutHit, const FVector Start, const FVector End, ECollisionChannel TraceChannel, const struct FCollisionQueryParams &Params, const struct FCollisionResponseParams &ResponseParams, const struct FCollisionObjectQueryParams &ObjectParams)
 
ENGINE_API bool SweepComponent (TArray< FHitResult > &OutHit, const FVector Start, const FVector End, const FQuat &ShapeWorldRotation, const FPhysicsGeometry &Geometry, ECollisionChannel TraceChannel, const struct FCollisionQueryParams &Params, const struct FCollisionResponseParams &ResponseParams, const struct FCollisionObjectQueryParams &ObjectParams)
 
ENGINE_API void VisitAllCurrentChildComponents (const TFunction< bool(UPrimitiveComponent *)> &Lambda) const
 
ENGINE_API void VisitAllCurrentActors (const TFunction< bool(AActor *)> &Lambda) const
 
ENGINE_API int32 NumChildClusterComponents () const
 
ENGINE_API void ForceRebuildGTParticleGeometry ()
 
ENGINE_API const FSpatialAccelerationGetSpatialAcceleration () const
 
ENGINE_API TArray< int32GetAddedBoneIdsForComponent (UPrimitiveComponent *Component) const
 
ENGINE_API void ChangeIfComponentBonesAreMainParticle (UPrimitiveComponent *Component, const TArray< int32 > &BoneIds, bool bIsMain)
 
ENGINE_API Chaos::FPhysicsObjectHandle FindChildPhysicsObjectByShapeIndex (int32 Index) const
 
ENGINE_API void ForceSetChildToParent (UPrimitiveComponent *InComponent, const TArray< int32 > &BoneIds, const TArray< FTransform > &ChildToParent)
 
virtual void OnChildToParentUpdated (UPrimitiveComponent *ChangedComponent, const FLocalBonesToTransformMap &PerBoneChildToParent, const FTransform &NewTransform, TArray< TTuple< UPrimitiveComponent *, FTransform > > *OutNewComponents)
 
virtual ENGINE_API void OnCreatePhysicsState () override
 
virtual ENGINE_API void OnDestroyPhysicsState () override
 
virtual ENGINE_API bool ShouldCreatePhysicsState () const override
 
virtual ENGINE_API bool HasValidPhysicsState () const override
 
virtual ENGINE_API void GetLifetimeReplicatedProps (TArray< FLifetimeProperty > &OutLifetimeProps) const override
 
virtual FBodyInstanceGetBodyInstance (FName BoneName, bool bGetWelded, int32 Index) const override
 
virtual ENGINE_API void SetSimulatePhysics (bool bSimulate) override
 
virtual bool CanEditSimulatePhysics () override
 
virtual ENGINE_API bool LineTraceComponent (FHitResult &OutHit, const FVector Start, const FVector End, ECollisionChannel TraceChannel, const struct FCollisionQueryParams &Params, const struct FCollisionResponseParams &ResponseParams, const struct FCollisionObjectQueryParams &ObjectParams) override
 
virtual ENGINE_API bool SweepComponent (FHitResult &OutHit, const FVector Start, const FVector End, const FQuat &ShapeWorldRotation, const FPhysicsGeometry &Geometry, ECollisionChannel TraceChannel, const struct FCollisionQueryParams &Params, const struct FCollisionResponseParams &ResponseParams, const struct FCollisionObjectQueryParams &ObjectParams) override
 
virtual ENGINE_API bool OverlapComponentWithResult (const FVector &Pos, const FQuat &Rot, const FPhysicsGeometry &Geometry, ECollisionChannel TraceChannel, const struct FCollisionQueryParams &Params, const struct FCollisionResponseParams &ResponseParams, const struct FCollisionObjectQueryParams &ObjectParams, TArray< FOverlapResult > &OutOverlap) const override
 
virtual ENGINE_API bool ComponentOverlapComponentWithResultImpl (const class UPrimitiveComponent *const PrimComp, const FVector &Pos, const FQuat &Rot, const FCollisionQueryParams &Params, TArray< FOverlapResult > &OutOverlap) const override
 
virtual bool ShouldDispatchWakeEvents (FName BoneName) const override
 
virtual ENGINE_API bool DoCustomNavigableGeometryExport (FNavigableGeometryExport &GeomExport) const override
 
virtual ENGINE_API void OnReceiveReplicatedState (const FVector X, const FQuat R, const FVector V, const FVector W) override
 
virtual ENGINE_API void OnUpdateTransform (EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport) override
 
virtual ENGINE_API FBoxSphereBounds CalcBounds (const FTransform &LocalToWorld) const override
 
virtual ENGINE_API FVector GetComponentVelocity () const override
 
virtual ENGINE_API Chaos::FPhysicsObjectGetPhysicsObjectById (Chaos::FPhysicsObjectId Id) const override
 
virtual ENGINE_API Chaos::FPhysicsObjectGetPhysicsObjectByName (const FName &Name) const override
 
virtual ENGINE_API TArray< Chaos::FPhysicsObject * > GetAllPhysicsObjects () const override
 
virtual ENGINE_API Chaos::FPhysicsObjectId GetIdFromGTParticle (Chaos::FGeometryParticle *Particle) const override
 

Static Public Member Functions

static ENGINE_API void AddReferencedObjects (UObject *InThis, FReferenceCollector &Collector)
 

Public Attributes

bool bEnableDamageFromCollision
 
FOnClusterUnionAddedComponent OnComponentAddedEvent
 
FOnClusterUnionRemovedComponent OnComponentRemovedEvent
 
FOnClusterUnionBoundsChanged OnComponentBoundsChangedEvent
 
FOnClusterUnionAddedComponentNative OnComponentAddedNativeEvent
 
FOnClusterUnionRemovedComponentNative OnComponentRemovedNativeEvent
 
FOnClusterUnionPostSyncBodies OnClusterUnionPostSyncBodiesEvent
 

Protected Member Functions

ENGINE_API void BroadcastComponentAddedEvents (UPrimitiveComponent *ChangedComponent, const TArray< FClusterUnionBoneData > &BoneIds, bool bIsNew, const TArray< FClusterUnionBoneData > &RemovedBoneIDs)
 
ENGINE_API void BroadcastComponentRemovedEvents (UPrimitiveComponent *ChangedComponent, const TArray< FClusterUnionBoneData > &InRemovedBonesData)
 
Chaos::FClusterUnionPhysicsProxyGetPhysicsProxy () const
 
Chaos::FClusterUnionPhysicsProxyGetPhysicsProxy ()
 
virtual ENGINE_API void SetRigidState (Chaos::EObjectStateType ObjectState)
 
ENGINE_API bool IsAuthority () const
 
const FClusterUnionReplicatedDataGetReplicatedRigidState () const
 
virtual ENGINE_API void OnRep_RigidState ()
 

Protected Attributes

TMap< TObjectKey< UPrimitiveComponent >, FClusteredComponentDataPerComponentData
 

Friends

class UClusterUnionReplicatedProxyComponent
 
class UModularVehicleBaseComponent
 

Detailed Description

This does the bulk of the work exposing a physics cluster union to the game thread. This component needs to be a primitive component primarily because of how physics proxies need to be registered with the solver with an association with a primitive component. This component can be used as part of AClusterUnionActor or on its own as its list of clustered components/actors can be specified dynamically at runtime and/or statically on asset creation.

The cluster union component needs to not only maintain a game thread representation of what's happening on the physics thread but it also needs to make sure this data gets replicated to every client. A general model of how the data flow happens is as follows:

[Server GT Command] -> [Server PT Command] -> [Server Modifies PT Data] -> [Server Sync PT Data back to GT Data].

This enables GT control over what happens to the cluster union BUT ALSO maintains a physics-first approach to the cluster union where a physics event can possibly cause the cluster union to break.

The GT data is replicated from the server to the clients either via the FClusterUnionReplicatedData on the cluster union component or per-child component data is replicated via the UClusterUnionReplicatedProxyComponent. Generally, the same flow is replicated on the client. The only exception is for replicating the X/R/V/W properties on the cluster union particle which does a GT -> PT data sync. There's no particula reason this happens...it just mirrors the single particle physics proxy here.

Member Typedef Documentation

◆ FLocalBonesToTransformMap

◆ FSpatialAcceleration

Constructor & Destructor Documentation

◆ UClusterUnionComponent()

UClusterUnionComponent::UClusterUnionComponent ( const FObjectInitializer ObjectInitializer)

Member Function Documentation

◆ AddComponentToCluster()

void UClusterUnionComponent::AddComponentToCluster ( UPrimitiveComponent *  InComponent,
const TArray< int32 > &  BoneIds,
bool  bRebuildGeometry = true 
)

◆ AddReferencedObjects()

void UClusterUnionComponent::AddReferencedObjects ( UObject InThis,
FReferenceCollector Collector 
)
static

◆ BroadcastComponentAddedEvents()

void UClusterUnionComponent::BroadcastComponentAddedEvents ( UPrimitiveComponent *  ChangedComponent,
const TArray< FClusterUnionBoneData > &  BoneIds,
bool  bIsNew,
const TArray< FClusterUnionBoneData > &  RemovedBoneIDs 
)
protected

◆ BroadcastComponentRemovedEvents()

void UClusterUnionComponent::BroadcastComponentRemovedEvents ( UPrimitiveComponent *  ChangedComponent,
const TArray< FClusterUnionBoneData > &  InRemovedBonesData 
)
protected

◆ CalcBounds()

FBoxSphereBounds UClusterUnionComponent::CalcBounds ( const FTransform LocalToWorld) const
overridevirtual

◆ CanEditSimulatePhysics()

virtual bool UClusterUnionComponent::CanEditSimulatePhysics ( )
inlineoverridevirtual

◆ ChangeIfComponentBonesAreMainParticle()

void UClusterUnionComponent::ChangeIfComponentBonesAreMainParticle ( UPrimitiveComponent *  Component,
const TArray< int32 > &  BoneIds,
bool  bIsMain 
)

◆ ComponentOverlapComponentWithResultImpl()

bool UClusterUnionComponent::ComponentOverlapComponentWithResultImpl ( const class UPrimitiveComponent *const  PrimComp,
const FVector Pos,
const FQuat Rot,
const FCollisionQueryParams Params,
TArray< FOverlapResult > &  OutOverlap 
) const
overridevirtual

◆ DoCustomNavigableGeometryExport()

bool UClusterUnionComponent::DoCustomNavigableGeometryExport ( FNavigableGeometryExport GeomExport) const
overridevirtual

◆ FindChildPhysicsObjectByShapeIndex()

Chaos::FPhysicsObjectHandle UClusterUnionComponent::FindChildPhysicsObjectByShapeIndex ( int32  Index) const

◆ ForceRebuildGTParticleGeometry()

void UClusterUnionComponent::ForceRebuildGTParticleGeometry ( )

◆ ForceSetChildToParent()

void UClusterUnionComponent::ForceSetChildToParent ( UPrimitiveComponent *  InComponent,
const TArray< int32 > &  BoneIds,
const TArray< FTransform > &  ChildToParent 
)

◆ GetActors()

TArray< AActor * > UClusterUnionComponent::GetActors ( )

◆ GetAddedBoneIdsForComponent()

TArray< int32 > UClusterUnionComponent::GetAddedBoneIdsForComponent ( UPrimitiveComponent *  Component) const

◆ GetAllPhysicsObjects()

TArray< Chaos::FPhysicsObject * > UClusterUnionComponent::GetAllPhysicsObjects ( ) const
overridevirtual

◆ GetBodyInstance()

virtual FBodyInstance * UClusterUnionComponent::GetBodyInstance ( FName  BoneName,
bool  bGetWelded,
int32  Index 
) const
inlineoverridevirtual

◆ GetComponentVelocity()

FVector UClusterUnionComponent::GetComponentVelocity ( ) const
overridevirtual

◆ GetIdFromGTParticle()

Chaos::FPhysicsObjectId UClusterUnionComponent::GetIdFromGTParticle ( Chaos::FGeometryParticle Particle) const
overridevirtual

◆ GetLifetimeReplicatedProps()

void UClusterUnionComponent::GetLifetimeReplicatedProps ( TArray< FLifetimeProperty > &  OutLifetimeProps) const
overridevirtual

◆ GetPhysicsObjectById()

Chaos::FPhysicsObject * UClusterUnionComponent::GetPhysicsObjectById ( Chaos::FPhysicsObjectId  Id) const
overridevirtual

◆ GetPhysicsObjectByName()

Chaos::FPhysicsObject * UClusterUnionComponent::GetPhysicsObjectByName ( const FName Name) const
overridevirtual

◆ GetPhysicsProxy() [1/2]

Chaos::FClusterUnionPhysicsProxy * UClusterUnionComponent::GetPhysicsProxy ( )
inlineprotected

◆ GetPhysicsProxy() [2/2]

Chaos::FClusterUnionPhysicsProxy * UClusterUnionComponent::GetPhysicsProxy ( ) const
inlineprotected

◆ GetPrimitiveComponents()

TArray< UPrimitiveComponent * > UClusterUnionComponent::GetPrimitiveComponents ( )

◆ GetReplicatedRigidState()

const FClusterUnionReplicatedData & UClusterUnionComponent::GetReplicatedRigidState ( ) const
inlineprotected

◆ GetSpatialAcceleration()

const UClusterUnionComponent::FSpatialAcceleration * UClusterUnionComponent::GetSpatialAcceleration ( ) const

◆ HasValidPhysicsState()

bool UClusterUnionComponent::HasValidPhysicsState ( ) const
overridevirtual

◆ IsAnchored()

ENGINE_API bool UClusterUnionComponent::IsAnchored ( ) const

◆ IsAnyRigidBodyAwake()

bool UClusterUnionComponent::IsAnyRigidBodyAwake ( )
overridevirtual

◆ IsAuthority()

bool UClusterUnionComponent::IsAuthority ( ) const
protected

◆ IsComponentAdded()

bool UClusterUnionComponent::IsComponentAdded ( UPrimitiveComponent *  Component)
inline

◆ LineTraceComponent() [1/2]

bool UClusterUnionComponent::LineTraceComponent ( FHitResult OutHit,
const FVector  Start,
const FVector  End,
ECollisionChannel  TraceChannel,
const struct FCollisionQueryParams Params,
const struct FCollisionResponseParams ResponseParams,
const struct FCollisionObjectQueryParams ObjectParams 
)
overridevirtual

◆ LineTraceComponent() [2/2]

bool UClusterUnionComponent::LineTraceComponent ( TArray< FHitResult > &  OutHit,
const FVector  Start,
const FVector  End,
ECollisionChannel  TraceChannel,
const struct FCollisionQueryParams Params,
const struct FCollisionResponseParams ResponseParams,
const struct FCollisionObjectQueryParams ObjectParams 
)

◆ NumChildClusterComponents()

int32 UClusterUnionComponent::NumChildClusterComponents ( ) const

◆ OnChildToParentUpdated()

virtual void UClusterUnionComponent::OnChildToParentUpdated ( UPrimitiveComponent *  ChangedComponent,
const FLocalBonesToTransformMap PerBoneChildToParent,
const FTransform NewTransform,
TArray< TTuple< UPrimitiveComponent *, FTransform > > *  OutNewComponents 
)
inlinevirtual

◆ OnCreatePhysicsState()

void UClusterUnionComponent::OnCreatePhysicsState ( )
overridevirtual

◆ OnDestroyPhysicsState()

void UClusterUnionComponent::OnDestroyPhysicsState ( )
overridevirtual

◆ OnReceiveReplicatedState()

void UClusterUnionComponent::OnReceiveReplicatedState ( const FVector  X,
const FQuat  R,
const FVector  V,
const FVector  W 
)
overridevirtual

◆ OnRep_RigidState()

void UClusterUnionComponent::OnRep_RigidState ( )
protectedvirtual

◆ OnUpdateTransform()

void UClusterUnionComponent::OnUpdateTransform ( EUpdateTransformFlags  UpdateTransformFlags,
ETeleportType  Teleport 
)
overridevirtual

◆ OverlapComponentWithResult()

bool UClusterUnionComponent::OverlapComponentWithResult ( const FVector Pos,
const FQuat Rot,
const FPhysicsGeometry Geometry,
ECollisionChannel  TraceChannel,
const struct FCollisionQueryParams Params,
const struct FCollisionResponseParams ResponseParams,
const struct FCollisionObjectQueryParams ObjectParams,
TArray< FOverlapResult > &  OutOverlap 
) const
overridevirtual

◆ RemoveComponentBonesFromCluster()

void UClusterUnionComponent::RemoveComponentBonesFromCluster ( UPrimitiveComponent *  InComponent,
const TArray< int32 > &  BoneIds 
)

◆ RemoveComponentFromCluster()

void UClusterUnionComponent::RemoveComponentFromCluster ( UPrimitiveComponent *  InComponent)

◆ SetEnableDamageFromCollision()

void UClusterUnionComponent::SetEnableDamageFromCollision ( bool  bValue)

◆ SetIsAnchored()

void UClusterUnionComponent::SetIsAnchored ( bool  bIsAnchored)
virtual

◆ SetMassOverrideInKg()

void UClusterUnionComponent::SetMassOverrideInKg ( FName  BoneName,
float  MassInKg,
bool  bOverrideMass 
)
overridevirtual

◆ SetRigidState()

void UClusterUnionComponent::SetRigidState ( Chaos::EObjectStateType  ObjectState)
protectedvirtual

◆ SetSimulatePhysics()

void UClusterUnionComponent::SetSimulatePhysics ( bool  bSimulate)
overridevirtual

◆ ShouldCreatePhysicsState()

bool UClusterUnionComponent::ShouldCreatePhysicsState ( ) const
overridevirtual

◆ ShouldDispatchWakeEvents()

virtual bool UClusterUnionComponent::ShouldDispatchWakeEvents ( FName  BoneName) const
inlineoverridevirtual

◆ SweepComponent() [1/2]

bool UClusterUnionComponent::SweepComponent ( FHitResult OutHit,
const FVector  Start,
const FVector  End,
const FQuat ShapeWorldRotation,
const FPhysicsGeometry Geometry,
ECollisionChannel  TraceChannel,
const struct FCollisionQueryParams Params,
const struct FCollisionResponseParams ResponseParams,
const struct FCollisionObjectQueryParams ObjectParams 
)
overridevirtual

◆ SweepComponent() [2/2]

bool UClusterUnionComponent::SweepComponent ( TArray< FHitResult > &  OutHit,
const FVector  Start,
const FVector  End,
const FQuat ShapeWorldRotation,
const FPhysicsGeometry Geometry,
ECollisionChannel  TraceChannel,
const struct FCollisionQueryParams Params,
const struct FCollisionResponseParams ResponseParams,
const struct FCollisionObjectQueryParams ObjectParams 
)

◆ SyncClusterUnionFromProxy()

void UClusterUnionComponent::SyncClusterUnionFromProxy ( const FTransform NewTransform,
TArray< TTuple< UPrimitiveComponent *, FTransform > > *  OutNewComponents 
)

◆ VisitAllCurrentActors()

void UClusterUnionComponent::VisitAllCurrentActors ( const TFunction< bool(AActor *)> &  Lambda) const

◆ VisitAllCurrentChildComponents()

void UClusterUnionComponent::VisitAllCurrentChildComponents ( const TFunction< bool(UPrimitiveComponent *)> &  Lambda) const

◆ WakeAllRigidBodies()

void UClusterUnionComponent::WakeAllRigidBodies ( )
overridevirtual

Friends And Related Symbol Documentation

◆ UClusterUnionReplicatedProxyComponent

◆ UModularVehicleBaseComponent

friend class UModularVehicleBaseComponent
friend

Member Data Documentation

◆ bEnableDamageFromCollision

bool UClusterUnionComponent::bEnableDamageFromCollision

Whether or not collisions against this geometry collection will apply strain which could cause the geometry collection to fracture.

◆ OnClusterUnionPostSyncBodiesEvent

FOnClusterUnionPostSyncBodies UClusterUnionComponent::OnClusterUnionPostSyncBodiesEvent

◆ OnComponentAddedEvent

FOnClusterUnionAddedComponent UClusterUnionComponent::OnComponentAddedEvent

◆ OnComponentAddedNativeEvent

FOnClusterUnionAddedComponentNative UClusterUnionComponent::OnComponentAddedNativeEvent

◆ OnComponentBoundsChangedEvent

FOnClusterUnionBoundsChanged UClusterUnionComponent::OnComponentBoundsChangedEvent

◆ OnComponentRemovedEvent

FOnClusterUnionRemovedComponent UClusterUnionComponent::OnComponentRemovedEvent

◆ OnComponentRemovedNativeEvent

FOnClusterUnionRemovedComponentNative UClusterUnionComponent::OnComponentRemovedNativeEvent

◆ PerComponentData

TMap<TObjectKey<UPrimitiveComponent>, FClusteredComponentData> UClusterUnionComponent::PerComponentData
protected

The documentation for this class was generated from the following files: