2019-12-26 14:45:42 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2019-06-08 17:15:34 -04:00
# include "ChaosBlueprint.h"
2019-08-02 09:01:58 -04:00
# include "PhysicsSolver.h"
2019-06-08 17:15:34 -04:00
# include "Async/Async.h"
2019-08-02 09:01:58 -04:00
# include "PhysicsProxy/GeometryCollectionPhysicsProxy.h"
2020-04-08 10:59:25 -04:00
# include "GeometryCollection/GeometryCollectionActor.h"
# include "GeometryCollection/GeometryCollectionComponent.h"
2019-08-02 09:01:58 -04:00
# define DISPATCH_BLUEPRINTS_IMMEDIATE 1
2019-06-08 17:15:34 -04:00
UChaosDestructionListener : : UChaosDestructionListener ( FObjectInitializer const & ObjectInitializer )
2021-08-31 20:23:44 -04:00
: Super ( ObjectInitializer ) , LastCollisionDataTimeStamp ( - 1.f ) , LastBreakingDataTimeStamp ( - 1.f ) , LastTrailingDataTimeStamp ( - 1.f ) , LastRemovalDataTimeStamp ( - 1.f )
2019-06-08 17:15:34 -04:00
{
bUseAttachParentBound = true ;
bAutoActivate = true ;
bNeverNeedsRenderUpdate = true ;
2019-08-02 09:01:58 -04:00
# ifdef DISPATCH_BLUEPRINTS_IMMEDIATE
PrimaryComponentTick . bCanEverTick = false ;
# else
2019-06-08 17:15:34 -04:00
PrimaryComponentTick . bCanEverTick = true ;
2019-08-02 09:01:58 -04:00
# endif
2019-06-08 17:15:34 -04:00
SetCollisionFilter ( MakeShareable ( new FChaosCollisionEventFilter ( & CollisionEventRequestSettings ) ) ) ;
SetBreakingFilter ( MakeShareable ( new FChaosBreakingEventFilter ( & BreakingEventRequestSettings ) ) ) ;
SetTrailingFilter ( MakeShareable ( new FChaosTrailingEventFilter ( & TrailingEventRequestSettings ) ) ) ;
2021-08-31 20:23:44 -04:00
SetRemovalFilter ( MakeShareable ( new FChaosRemovalEventFilter ( & RemovalEventRequestSettings ) ) ) ;
2019-06-08 17:15:34 -04:00
}
2019-08-02 09:01:58 -04:00
void UChaosDestructionListener : : ClearEvents ( )
2019-06-08 17:15:34 -04:00
{
2019-08-02 09:01:58 -04:00
#if 0 // solver actors no longer functional, using GetWorld()->GetPhysicsScene() instead
for ( AChaosSolverActor * ChaosSolverActorObject : ChaosSolverActors )
2019-06-08 17:15:34 -04:00
{
2019-08-02 09:01:58 -04:00
UnregisterChaosEvents ( ChaosSolverActorObject - > GetPhysicsScene ( ) ) ;
}
# else
UnregisterChaosEvents ( GetWorld ( ) - > GetPhysicsScene ( ) ) ;
# endif
}
void UChaosDestructionListener : : UpdateEvents ( )
{
if ( ! ChaosSolverActors . Num ( ) & & ! GeometryCollectionActors . Num ( ) )
{
if ( FPhysScene * PhysScene = GetWorld ( ) - > GetPhysicsScene ( ) )
2019-06-08 17:15:34 -04:00
{
2019-08-02 09:01:58 -04:00
RegisterChaosEvents ( PhysScene ) ;
2019-06-08 17:15:34 -04:00
}
}
else
{
2019-08-02 09:01:58 -04:00
#if 0 // solver actors no longer functional, using GetWorld()->GetPhysicsScene() instead
2019-06-08 17:15:34 -04:00
for ( AChaosSolverActor * ChaosSolverActorObject : ChaosSolverActors )
{
if ( ChaosSolverActorObject )
{
2019-08-02 09:01:58 -04:00
RegisterChaosEvents ( ChaosSolverActorObject - > GetPhysicsScene ( ) ) ;
}
}
# else
if ( FPhysScene * PhysScene = GetWorld ( ) - > GetPhysicsScene ( ) )
{
RegisterChaosEvents ( PhysScene ) ;
}
# endif
for ( AGeometryCollectionActor * GeometryCollectionActor : GeometryCollectionActors )
{
if ( GeometryCollectionActor )
{
if ( const UGeometryCollectionComponent * GeometryCollectionComponent = GeometryCollectionActor - > GetGeometryCollectionComponent ( ) )
2019-06-08 17:15:34 -04:00
{
2019-08-02 09:01:58 -04:00
if ( const FGeometryCollectionPhysicsProxy * GeometryCollectionPhysicsObject = GeometryCollectionComponent - > GetPhysicsProxy ( ) )
{
2019-11-22 05:24:36 -05:00
RegisterChaosEvents ( GeometryCollectionComponent - > GetWorld ( ) - > GetPhysicsScene ( ) ) ;
2019-08-02 09:01:58 -04:00
}
2019-06-08 17:15:34 -04:00
}
}
}
}
}
2019-08-02 09:01:58 -04:00
#if 0 // #todo: No longer required?
void UChaosDestructionListener : : UpdateGeometryCollectionPhysicsProxies ( )
2019-06-08 17:15:34 -04:00
{
2019-08-02 09:01:58 -04:00
GeometryCollectionPhysicsProxies . Reset ( ) ;
2019-06-08 17:15:34 -04:00
if ( GeometryCollectionActors . Num ( ) > 0 )
{
for ( AGeometryCollectionActor * GeometryCollectionActorObject : GeometryCollectionActors )
{
if ( GeometryCollectionActorObject )
{
// Get GeometryCollectionComponent
if ( const UGeometryCollectionComponent * GeometryCollectionComponent = GeometryCollectionActorObject - > GetGeometryCollectionComponent ( ) )
{
2019-08-02 09:01:58 -04:00
// Get GeometryCollectionPhysicsProxies
if ( const FGeometryCollectionPhysicsProxy * GeometryCollectionPhysicsProxy = GeometryCollectionComponent - > GetPhysicsProxy ( ) )
2019-06-08 17:15:34 -04:00
{
2019-08-02 09:01:58 -04:00
if ( Chaos : : FPhysicsSolver * Solver = GeometryCollectionPhysicsProxy - > GetSolver ( ) )
2019-06-08 17:15:34 -04:00
{
if ( ! Solvers . Contains ( Solver ) )
{
2019-08-02 09:01:58 -04:00
GeometryCollectionPhysicsProxies . Add ( GeometryCollectionPhysicsProxy ) ;
2019-06-08 17:15:34 -04:00
}
}
}
}
}
}
}
}
# endif
# if WITH_EDITOR
void UChaosDestructionListener : : PostEditChangeProperty ( struct FPropertyChangedEvent & PropertyChangedEvent )
{
Super : : PostEditChangeProperty ( PropertyChangedEvent ) ;
}
# endif
bool UChaosDestructionListener : : IsEventListening ( ) const
{
return bIsCollisionEventListeningEnabled | |
bIsBreakingEventListeningEnabled | |
2021-08-31 20:23:44 -04:00
bIsTrailingEventListeningEnabled | |
bIsRemovalEventListeningEnabled ;
2019-06-08 17:15:34 -04:00
}
void UChaosDestructionListener : : UpdateTransformSettings ( )
{
// Only need to update the transform if anybody is listening at all and if any of the settings are sorting by nearest, otherwise, no need to get updates
if ( IsEventListening ( ) )
{
bWantsOnUpdateTransform = CollisionEventRequestSettings . SortMethod = = EChaosCollisionSortMethod : : SortByNearestFirst | |
BreakingEventRequestSettings . SortMethod = = EChaosBreakingSortMethod : : SortByNearestFirst | |
2021-08-31 20:23:44 -04:00
TrailingEventRequestSettings . SortMethod = = EChaosTrailingSortMethod : : SortByNearestFirst | |
RemovalEventRequestSettings . SortMethod = = EChaosRemovalSortMethod : : SortByNearestFirst ;
2019-06-08 17:15:34 -04:00
}
else
{
bWantsOnUpdateTransform = false ;
}
bChanged = true ;
}
2019-08-02 09:01:58 -04:00
void UChaosDestructionListener : : BeginPlay ( )
{
Super : : BeginPlay ( ) ;
UpdateEvents ( ) ;
}
void UChaosDestructionListener : : EndPlay ( const EEndPlayReason : : Type EndPlayReason )
{
ClearEvents ( ) ;
Super : : EndPlay ( EndPlayReason ) ;
}
2019-06-08 17:15:34 -04:00
void UChaosDestructionListener : : TickComponent ( float DeltaTime , enum ELevelTick TickType , FActorComponentTickFunction * ThisTickFunction )
{
2019-08-02 09:01:58 -04:00
#if 0
2019-06-08 17:15:34 -04:00
bool bIsListening = IsEventListening ( ) ;
// if owning actor is disabled, don't listen
AActor * Owner = GetOwner ( ) ;
if ( Owner & & ! Owner - > IsActorTickEnabled ( ) )
{
bIsListening = false ;
}
// If we have a task and it isn't finished, let it do it's thing
int32 TaskStateValue = TaskState . GetValue ( ) ;
if ( TaskStateValue = = ( int32 ) ETaskState : : Processing )
{
return ;
}
// Note this could be "NoTask" if this is the first tick or if the event listener has been stopped
else if ( TaskStateValue = = ( int32 ) ETaskState : : Finished )
{
// Notify the callbacks with the filtered destruction data results if they're being listened to
// If the data was changed during the task, then bChanged will be true and we will avoid broadcasting this frame since it won't be valid.
if ( bIsListening & & ! bChanged )
{
if ( ChaosCollisionFilter . IsValid ( ) )
{
if ( bIsCollisionEventListeningEnabled & & ChaosCollisionFilter - > GetNumEvents ( ) > 0 & & OnCollisionEvents . IsBound ( ) )
{
OnCollisionEvents . Broadcast ( ChaosCollisionFilter - > GetFilteredResults ( ) ) ;
}
}
if ( ChaosBreakingFilter . IsValid ( ) )
{
if ( bIsBreakingEventListeningEnabled & & ChaosBreakingFilter - > GetNumEvents ( ) > 0 & & OnBreakingEvents . IsBound ( ) )
{
OnBreakingEvents . Broadcast ( ChaosBreakingFilter - > GetFilteredResults ( ) ) ;
}
}
if ( ChaosTrailingFilter . IsValid ( ) )
{
if ( bIsTrailingEventListeningEnabled & & ChaosTrailingFilter - > GetNumEvents ( ) > 0 & & OnTrailingEvents . IsBound ( ) )
{
OnTrailingEvents . Broadcast ( ChaosTrailingFilter - > GetFilteredResults ( ) ) ;
}
}
}
else
{
TaskState . Set ( ( int32 ) ETaskState : : NoTask ) ;
}
// Reset the changed bool so we can broadcast next tick if the settings haven't changed
bChanged = false ;
}
// Early exit if we're not listening anymore
if ( ! bIsListening )
{
return ;
}
// If we don't have solvers, call update to make sure we have built our solver array
if ( ! Solvers . Num ( ) )
{
UpdateSolvers ( ) ;
}
2019-08-02 09:01:58 -04:00
if ( ! GeometryCollectionPhysicsProxies . Num ( ) )
2019-06-08 17:15:34 -04:00
{
2019-08-02 09:01:58 -04:00
UpdateGeometryCollectionPhysicsProxies ( ) ;
2019-06-08 17:15:34 -04:00
}
// Reset our cached data arrays for various destruction types
RawCollisionDataArray . Reset ( ) ;
RawBreakingDataArray . Reset ( ) ;
RawTrailingDataArray . Reset ( ) ;
// Retrieve the raw data arrays from the solvers
GetDataFromSolvers ( ) ;
2019-08-02 09:01:58 -04:00
// Retrieve the raw data arrays from the GeometryCollectionPhysicsProxy
GetDataFromGeometryCollectionPhysicsProxies ( ) ;
2019-06-08 17:15:34 -04:00
TaskState . Set ( ( int32 ) ETaskState : : Processing ) ;
// Retreive a copy of the transform before kicking off the task
ChaosComponentTransform = GetComponentTransform ( ) ;
AsyncTask ( ENamedThreads : : AnyBackgroundThreadNormalTask ,
[ this ] ( )
{
if ( bIsCollisionEventListeningEnabled )
{
if ( ChaosCollisionFilter . IsValid ( ) )
{
ChaosCollisionFilter - > FilterEvents ( ChaosComponentTransform , RawCollisionDataArray ) ;
}
}
if ( ChaosBreakingFilter . IsValid ( ) )
{
if ( bIsBreakingEventListeningEnabled )
{
ChaosBreakingFilter - > FilterEvents ( ChaosComponentTransform , RawBreakingDataArray ) ;
}
}
if ( ChaosTrailingFilter . IsValid ( ) )
{
if ( bIsTrailingEventListeningEnabled )
{
ChaosTrailingFilter - > FilterEvents ( ChaosComponentTransform , RawTrailingDataArray ) ;
}
}
TaskState . Set ( ( int32 ) ETaskState : : Finished ) ;
} ) ;
2019-08-02 09:01:58 -04:00
# endif // if 0
2019-06-08 17:15:34 -04:00
}
void UChaosDestructionListener : : AddChaosSolverActor ( AChaosSolverActor * ChaosSolverActor )
{
2019-08-02 09:01:58 -04:00
#if 0 // solver actors no longer functional, using GetWorld()->GetPhysicsScene() instead
if ( ChaosSolverActor & & ! ChaosSolverActors . Contains ( ChaosSolverActor ) )
2019-06-08 17:15:34 -04:00
{
ChaosSolverActors . Add ( ChaosSolverActor ) ;
2019-08-02 09:01:58 -04:00
RegisterChaosEvents ( ChaosSolverActor - > GetPhysicsScene ( ) ) ;
2019-06-08 17:15:34 -04:00
}
2019-08-02 09:01:58 -04:00
# endif
2019-06-08 17:15:34 -04:00
}
void UChaosDestructionListener : : RemoveChaosSolverActor ( AChaosSolverActor * ChaosSolverActor )
{
2019-08-02 09:01:58 -04:00
#if 0 // solver actors no longer functional, using GetWorld()->GetPhysicsScene() instead
2019-06-08 17:15:34 -04:00
if ( ChaosSolverActor )
{
2019-08-02 09:01:58 -04:00
ClearEvents ( ) ;
2019-06-08 17:15:34 -04:00
ChaosSolverActors . Remove ( ChaosSolverActor ) ;
2019-08-02 09:01:58 -04:00
UpdateEvents ( ) ;
2019-06-08 17:15:34 -04:00
}
2019-08-02 09:01:58 -04:00
# endif
2019-06-08 17:15:34 -04:00
}
void UChaosDestructionListener : : AddGeometryCollectionActor ( AGeometryCollectionActor * GeometryCollectionActor )
{
2019-08-02 09:01:58 -04:00
if ( GeometryCollectionActor & & ! GeometryCollectionActors . Contains ( GeometryCollectionActor ) )
2019-06-08 17:15:34 -04:00
{
GeometryCollectionActors . Add ( GeometryCollectionActor ) ;
2019-08-02 09:01:58 -04:00
if ( const UGeometryCollectionComponent * GeometryCollectionComponent = GeometryCollectionActor - > GetGeometryCollectionComponent ( ) )
{
if ( const FGeometryCollectionPhysicsProxy * GeometryCollectionPhysicsObject = GeometryCollectionComponent - > GetPhysicsProxy ( ) )
{
2019-11-22 05:24:36 -05:00
RegisterChaosEvents ( GeometryCollectionComponent - > GetWorld ( ) - > GetPhysicsScene ( ) ) ;
2019-08-02 09:01:58 -04:00
}
}
2019-06-08 17:15:34 -04:00
}
}
void UChaosDestructionListener : : RemoveGeometryCollectionActor ( AGeometryCollectionActor * GeometryCollectionActor )
{
if ( GeometryCollectionActor )
{
2019-08-02 09:01:58 -04:00
ClearEvents ( ) ;
2019-06-08 17:15:34 -04:00
GeometryCollectionActors . Remove ( GeometryCollectionActor ) ;
2019-08-02 09:01:58 -04:00
UpdateEvents ( ) ;
2019-06-08 17:15:34 -04:00
}
}
void UChaosDestructionListener : : SetCollisionEventRequestSettings ( const FChaosCollisionEventRequestSettings & InSettings )
{
CollisionEventRequestSettings = InSettings ;
UpdateTransformSettings ( ) ;
}
void UChaosDestructionListener : : SetBreakingEventRequestSettings ( const FChaosBreakingEventRequestSettings & InSettings )
{
BreakingEventRequestSettings = InSettings ;
UpdateTransformSettings ( ) ;
}
void UChaosDestructionListener : : SetTrailingEventRequestSettings ( const FChaosTrailingEventRequestSettings & InSettings )
{
TrailingEventRequestSettings = InSettings ;
UpdateTransformSettings ( ) ;
}
2021-08-31 20:23:44 -04:00
void UChaosDestructionListener : : SetRemovalEventRequestSettings ( const FChaosRemovalEventRequestSettings & InSettings )
{
RemovalEventRequestSettings = InSettings ;
UpdateTransformSettings ( ) ;
}
2019-06-08 17:15:34 -04:00
void UChaosDestructionListener : : SetCollisionEventEnabled ( bool bIsEnabled )
{
bIsCollisionEventListeningEnabled = bIsEnabled ;
UpdateTransformSettings ( ) ;
}
void UChaosDestructionListener : : SetBreakingEventEnabled ( bool bIsEnabled )
{
bIsBreakingEventListeningEnabled = bIsEnabled ;
UpdateTransformSettings ( ) ;
}
void UChaosDestructionListener : : SetTrailingEventEnabled ( bool bIsEnabled )
{
bIsTrailingEventListeningEnabled = bIsEnabled ;
UpdateTransformSettings ( ) ;
}
2021-08-31 20:23:44 -04:00
void UChaosDestructionListener : : SetRemovalEventEnabled ( bool bIsEnabled )
{
bIsRemovalEventListeningEnabled = bIsEnabled ;
UpdateTransformSettings ( ) ;
}
2019-06-08 17:15:34 -04:00
void UChaosDestructionListener : : SortCollisionEvents ( TArray < FChaosCollisionEventData > & CollisionEvents , EChaosCollisionSortMethod SortMethod )
{
if ( ChaosCollisionFilter . IsValid ( ) )
{
ChaosCollisionFilter - > SortEvents ( CollisionEvents , SortMethod , GetComponentTransform ( ) ) ;
}
}
void UChaosDestructionListener : : SortBreakingEvents ( TArray < FChaosBreakingEventData > & BreakingEvents , EChaosBreakingSortMethod SortMethod )
{
if ( ChaosBreakingFilter . IsValid ( ) )
{
ChaosBreakingFilter - > SortEvents ( BreakingEvents , SortMethod , GetComponentTransform ( ) ) ;
}
}
void UChaosDestructionListener : : SortTrailingEvents ( TArray < FChaosTrailingEventData > & TrailingEvents , EChaosTrailingSortMethod SortMethod )
{
if ( ChaosTrailingFilter . IsValid ( ) )
{
ChaosTrailingFilter - > SortEvents ( TrailingEvents , SortMethod , GetComponentTransform ( ) ) ;
}
}
2019-08-02 09:01:58 -04:00
2021-08-31 20:23:44 -04:00
void UChaosDestructionListener : : SortRemovalEvents ( TArray < FChaosRemovalEventData > & RemovalEvents , EChaosRemovalSortMethod SortMethod )
{
if ( ChaosRemovalFilter . IsValid ( ) )
{
ChaosRemovalFilter - > SortEvents ( RemovalEvents , SortMethod , GetComponentTransform ( ) ) ;
}
}
2019-08-02 09:01:58 -04:00
void UChaosDestructionListener : : RegisterChaosEvents ( FPhysScene * Scene )
{
# if WITH_CHAOS
2020-08-11 01:36:57 -04:00
Chaos : : FPhysicsSolver * Solver = Scene - > GetSolver ( ) ;
2019-10-02 17:27:26 -04:00
Chaos : : FEventManager * EventManager = Solver - > GetEventManager ( ) ;
EventManager - > RegisterHandler < Chaos : : FCollisionEventData > ( Chaos : : EEventType : : Collision , this , & UChaosDestructionListener : : HandleCollisionEvents ) ;
EventManager - > RegisterHandler < Chaos : : FBreakingEventData > ( Chaos : : EEventType : : Breaking , this , & UChaosDestructionListener : : HandleBreakingEvents ) ;
EventManager - > RegisterHandler < Chaos : : FTrailingEventData > ( Chaos : : EEventType : : Trailing , this , & UChaosDestructionListener : : HandleTrailingEvents ) ;
2021-08-31 20:23:44 -04:00
EventManager - > RegisterHandler < Chaos : : FRemovalEventData > ( Chaos : : EEventType : : Removal , this , & UChaosDestructionListener : : HandleRemovalEvents ) ;
2019-08-02 09:01:58 -04:00
# endif
}
void UChaosDestructionListener : : UnregisterChaosEvents ( FPhysScene * Scene )
{
# if WITH_CHAOS
2020-08-11 01:36:57 -04:00
Chaos : : FPhysicsSolver * Solver = Scene - > GetSolver ( ) ;
2019-10-02 17:27:26 -04:00
Chaos : : FEventManager * EventManager = Solver - > GetEventManager ( ) ;
EventManager - > UnregisterHandler ( Chaos : : EEventType : : Collision , this ) ;
EventManager - > UnregisterHandler ( Chaos : : EEventType : : Breaking , this ) ;
EventManager - > UnregisterHandler ( Chaos : : EEventType : : Trailing , this ) ;
2021-08-31 20:23:44 -04:00
EventManager - > UnregisterHandler ( Chaos : : EEventType : : Removal , this ) ;
2019-08-02 09:01:58 -04:00
# endif
}
void UChaosDestructionListener : : RegisterChaosEvents ( TSharedPtr < FPhysScene_Chaos > Scene )
{
# if WITH_CHAOS
2019-10-02 17:27:26 -04:00
Chaos : : FPhysicsSolver * Solver = Scene - > GetSolver ( ) ;
Chaos : : FEventManager * EventManager = Solver - > GetEventManager ( ) ;
EventManager - > RegisterHandler < Chaos : : FCollisionEventData > ( Chaos : : EEventType : : Collision , this , & UChaosDestructionListener : : HandleCollisionEvents ) ;
EventManager - > RegisterHandler < Chaos : : FBreakingEventData > ( Chaos : : EEventType : : Breaking , this , & UChaosDestructionListener : : HandleBreakingEvents ) ;
EventManager - > RegisterHandler < Chaos : : FTrailingEventData > ( Chaos : : EEventType : : Trailing , this , & UChaosDestructionListener : : HandleTrailingEvents ) ;
2021-08-31 20:23:44 -04:00
EventManager - > RegisterHandler < Chaos : : FRemovalEventData > ( Chaos : : EEventType : : Removal , this , & UChaosDestructionListener : : HandleRemovalEvents ) ;
2019-08-02 09:01:58 -04:00
# endif
}
void UChaosDestructionListener : : UnregisterChaosEvents ( TSharedPtr < FPhysScene_Chaos > Scene )
{
# if WITH_CHAOS
2019-10-02 17:27:26 -04:00
Chaos : : FPhysicsSolver * Solver = Scene - > GetSolver ( ) ;
Chaos : : FEventManager * EventManager = Solver - > GetEventManager ( ) ;
EventManager - > UnregisterHandler ( Chaos : : EEventType : : Collision , this ) ;
EventManager - > UnregisterHandler ( Chaos : : EEventType : : Breaking , this ) ;
EventManager - > UnregisterHandler ( Chaos : : EEventType : : Trailing , this ) ;
2021-08-31 20:23:44 -04:00
EventManager - > UnregisterHandler ( Chaos : : EEventType : : Removal , this ) ;
2019-08-02 09:01:58 -04:00
# endif
}
void UChaosDestructionListener : : HandleCollisionEvents ( const Chaos : : FCollisionEventData & Event )
{
if ( bIsCollisionEventListeningEnabled )
{
int NumCollisions = Event . CollisionData . AllCollisionsArray . Num ( ) ;
RawCollisionDataArray . Append ( Event . CollisionData . AllCollisionsArray . GetData ( ) , NumCollisions ) ;
# if DISPATCH_BLUEPRINTS_IMMEDIATE
if ( ChaosCollisionFilter . IsValid ( ) )
{
ChaosCollisionFilter - > FilterEvents ( ChaosComponentTransform , RawCollisionDataArray ) ;
if ( ChaosCollisionFilter - > GetNumEvents ( ) > 0 & & OnCollisionEvents . IsBound ( ) )
{
OnCollisionEvents . Broadcast ( ChaosCollisionFilter - > GetFilteredResults ( ) ) ;
}
}
RawCollisionDataArray . Reset ( ) ;
# endif
}
}
void UChaosDestructionListener : : HandleBreakingEvents ( const Chaos : : FBreakingEventData & Event )
{
if ( bIsBreakingEventListeningEnabled )
{
int NumBreakings = Event . BreakingData . AllBreakingsArray . Num ( ) ;
RawBreakingDataArray . Append ( Event . BreakingData . AllBreakingsArray . GetData ( ) , NumBreakings ) ;
# if DISPATCH_BLUEPRINTS_IMMEDIATE
if ( ChaosBreakingFilter . IsValid ( ) )
{
ChaosBreakingFilter - > FilterEvents ( ChaosComponentTransform , RawBreakingDataArray ) ;
if ( ChaosBreakingFilter - > GetNumEvents ( ) > 0 & & OnBreakingEvents . IsBound ( ) )
{
OnBreakingEvents . Broadcast ( ChaosBreakingFilter - > GetFilteredResults ( ) ) ;
}
}
RawBreakingDataArray . Reset ( ) ;
# endif
}
}
void UChaosDestructionListener : : HandleTrailingEvents ( const Chaos : : FTrailingEventData & Event )
{
if ( bIsTrailingEventListeningEnabled )
{
int NumTrailings = Event . TrailingData . AllTrailingsArray . Num ( ) ;
RawTrailingDataArray . Append ( Event . TrailingData . AllTrailingsArray . GetData ( ) , NumTrailings ) ;
# if DISPATCH_BLUEPRINTS_IMMEDIATE
if ( ChaosTrailingFilter . IsValid ( ) )
{
ChaosTrailingFilter - > FilterEvents ( ChaosComponentTransform , RawTrailingDataArray ) ;
if ( ChaosTrailingFilter - > GetNumEvents ( ) > 0 & & OnTrailingEvents . IsBound ( ) )
{
OnTrailingEvents . Broadcast ( ChaosTrailingFilter - > GetFilteredResults ( ) ) ;
}
}
RawTrailingDataArray . Reset ( ) ;
# endif
}
}
2021-08-31 20:23:44 -04:00
void UChaosDestructionListener : : HandleRemovalEvents ( const Chaos : : FRemovalEventData & Event )
{
if ( bIsRemovalEventListeningEnabled )
{
int NumRemovals = Event . RemovalData . AllRemovalArray . Num ( ) ;
RawRemovalDataArray . Append ( Event . RemovalData . AllRemovalArray . GetData ( ) , NumRemovals ) ;
# if DISPATCH_BLUEPRINTS_IMMEDIATE
if ( ChaosRemovalFilter . IsValid ( ) )
{
ChaosRemovalFilter - > FilterEvents ( ChaosComponentTransform , RawRemovalDataArray ) ;
if ( ChaosRemovalFilter - > GetNumEvents ( ) > 0 & & OnRemovalEvents . IsBound ( ) )
{
OnRemovalEvents . Broadcast ( ChaosRemovalFilter - > GetFilteredResults ( ) ) ;
}
}
RawRemovalDataArray . Reset ( ) ;
# endif
}
}