Navigation
API > API/Runtime > API/Runtime/Engine > API/Runtime/Engine/PhysicsEngine
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UActorComponent
- USceneComponent
- UPrimitiveComponent
- UClusterUnionComponent
References
| Module | Engine |
| Header | /Engine/Source/Runtime/Engine/Classes/PhysicsEngine/ClusterUnionComponent.h |
| Include | #include "PhysicsEngine/ClusterUnionComponent.h" |
Syntax
UCLASS (MinimalAPI)
class UClusterUnionComponent : public UPrimitiveComponent
Remarks
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.
Variables
| Type | Name | Description | |
|---|---|---|---|
| bool | bEnableDamageFromCollision | Whether or not collisions against this geometry collection will apply strain which could cause the geometry collection to fracture. | |
| FOnClusterUnionPostSyncBodies | OnClusterUnionPostSyncBodiesEvent | ||
| FOnClusterUnionAddedComponent | OnComponentAddedEvent | ||
| FOnClusterUnionAddedComponentNative | OnComponentAddedNativeEvent | Native (fast, low overhead) versions | |
| FOnClusterUnionBoundsChanged | OnComponentBoundsChangedEvent | ||
| FOnClusterUnionRemovedComponent | OnComponentRemovedEvent | ||
| FOnClusterUnionRemovedComponentNative | OnComponentRemovedNativeEvent | ||
| TMap< TObjectKey< UPrimitiveComponent >, FClusteredComponentData > | PerComponentData | We need to keep track of the mapping of primitive components to physics objects. |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UClusterUnionComponent
(
const FObjectInitializer& ObjectInitializer |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AddComponentToCluster
(
UPrimitiveComponent* InComponent, |
||
| void | AddReferencedObjects
(
UObject* InThis, |
||
| void | BroadcastComponentAddedEvents
(
UPrimitiveComponent* ChangedComponent, |
||
| void | BroadcastComponentRemovedEvents
(
UPrimitiveComponent* ChangedComponent, |
||
| void | ChangeIfComponentBonesAreMainParticle
(
UPrimitiveComponent* Component, |
||
| Chaos::FPhysicsObjectHandle | FindChildPhysicsObjectByShapeIndex
(
int32 Index |
This function will return information from the latest physics sync. | |
| void | Force a rebuild of the GT geometry. | ||
| void | ForceSetChildToParent
(
UPrimitiveComponent* InComponent, |
This should only be called on the client when replication happens. | |
| TArray< AActor * > | GetActors () |
||
| TArray< int32 > | GetAddedBoneIdsForComponent
(
UPrimitiveComponent* Component |
||
| Chaos::FClusterUnionPhysicsProxy * | |||
| Chaos::FClusterUnionPhysicsProxy * | |||
| TArray< UPrimitiveComponent * > | |||
| const FClusterUnionReplicatedData & | |||
| const FSpatialAcceleration * | |||
| bool | IsAnchored () |
||
| bool | IsAuthority () |
Whether or not this code is running on the server. | |
| bool | IsComponentAdded
(
UPrimitiveComponent* Component |
||
| bool | LineTraceComponent
(
TArray< FHitResult >& OutHit, |
Multi-trace/sweep functions that only make sense in the context of a cluster union. | |
| int32 | |||
| void | OnChildToParentUpdated
(
UPrimitiveComponent* ChangedComponent, |
||
| void | Handles changes to ReplicatedRigidState. | ||
| void | RemoveComponentBonesFromCluster
(
UPrimitiveComponent* InComponent, |
||
| void | RemoveComponentFromCluster
(
UPrimitiveComponent* InComponent |
||
| void | SetEnableDamageFromCollision
(
bool bValue |
||
| void | SetIsAnchored
(
bool bIsAnchored |
||
| void | SetRigidState
(
Chaos::EObjectStateType ObjectState |
||
| bool | SweepComponent
(
TArray< FHitResult >& OutHit, |
||
| void | SyncClusterUnionFromProxy
(
const FTransform& NewTransform, |
SyncClusterUnionFromProxy will examine the make up of the cluster union (particles, child to parent, etc.) and do whatever is needed on the GT in terms of bookkeeping. | |
| void | VisitAllCurrentActors
(
const TFunction< bool(AActor*)>& Lambda |
||
| void | VisitAllCurrentChildComponents
(
const TFunction< bool(UPrimitiveComponent*)>& Lambda |
Lambda returns whether or not iteration should continue;. |
Overridden from UPrimitiveComponent
| Type | Name | Description | |
|---|---|---|---|
| bool | Determines whether or not the simulate physics setting can be edited interactively on this component | ||
| bool | ComponentOverlapComponentWithResultImpl
(
const UPrimitiveComponent*const PrimComp, |
||
| FBodyInstance * | GetBodyInstance
(
FName BoneName, |
Returns BodyInstance of the component. | |
| bool | Returns if any body in this component is currently awake and simulating. | ||
| bool | LineTraceComponent
(
FHitResult& OutHit, |
Trace a ray against just this component. | |
| bool | LineTraceComponent
(
FHitResult& OutHit, |
Trace a ray against just this component. | |
| bool | OverlapComponentWithResult
(
const FVector& Pos, |
Test the collision of the supplied shape at the supplied location, and determine if it overlaps this component. | |
| bool | OverlapComponentWithResult
(
const FVector& Pos, |
Test the collision of the supplied shape at the supplied location, and determine if it overlaps this component. | |
| void | SetMassOverrideInKg
(
FName BoneName, |
Set the cluster union total mass. | |
| void | SetSimulatePhysics
(
bool bSimulate |
When this component is a simple/single body, this will enable or disable simulation on that body. | |
| bool | ShouldDispatchWakeEvents
(
FName BoneName |
Whether or not the primitive component should dispatch sleep/wake events. | |
| bool | SweepComponent
(
FHitResult& OutHit, |
Trace a shape against just this component. | |
| bool | SweepComponent
(
FHitResult& OutHit, |
Trace a shape against just this component. | |
| void | Ensure simulation is running for all bodies in this component. |
Overridden from USceneComponent
| Type | Name | Description | |
|---|---|---|---|
| FBoxSphereBounds | CalcBounds
(
const FTransform& LocalToWorld |
Calculate the bounds of the component. Default behavior is a bounding box/sphere of zero size. | |
| FVector | Get velocity of the component: either ComponentVelocity, or the velocity of the physics body if simulating physics. | ||
| void | OnReceiveReplicatedState
(
const FVector X, |
Called when client receive replication data, before replication is performed. | |
| void | OnUpdateTransform
(
EUpdateTransformFlags UpdateTransformFlags, |
Native callback when this component is moved |
Overridden from UActorComponent
| Type | Name | Description | |
|---|---|---|---|
| bool | Used to check that DestroyPhysicsState() is working correctly | ||
| void | Used to create any physics engine information for this component | ||
| void | Used to shut down and physics engine structure for this component | ||
| bool | Return true if CreatePhysicsState() should be called. |
Overridden from UObject
| Type | Name | Description | |
|---|---|---|---|
| void | GetLifetimeReplicatedProps
(
TArray< FLifetimeProperty >& OutLifetimeProps |
Returns properties that are replicated for the lifetime of the actor channel |
Overridden from INavRelevantInterface
| Type | Name | Description | |
|---|---|---|---|
| bool | DoCustomNavigableGeometryExport
(
FNavigableGeometryExport& GeomExport |
Collects custom navigable geometry of component. |
Overridden from IPhysicsComponent
| Type | Name | Description | |
|---|---|---|---|
| TArray< Chaos::FPhysicsObject * > | |||
| Chaos::FPhysicsObjectId | GetIdFromGTParticle
(
Chaos::FGeometryParticle* Particle |
||
| Chaos::FPhysicsObject * | GetPhysicsObjectById
(
Chaos::FPhysicsObjectId Id |
||
| Chaos::FPhysicsObject * | GetPhysicsObjectByName
(
const FName& Name |
Classes
| Type | Name | Description | |
|---|---|---|---|
| FMappedBoneData | |||
| FMappedComponentKey | Structure that stores an object key and its raw ptr, so it can be accessed without going trough the global uobjects array (so it could be garbage, therefore it has to be used withing the same frame) |
Typedefs
| Name | Description |
|---|---|
| FLocalBonesToTransformMap | There are several instances where we have 1 single elements. The inline allocator should help in these cases without a huge impact when we go over. |
| FSpatialAcceleration |