2019-12-26 14:45:42 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2018-12-12 11:25:29 -05:00
# pragma once
# include "Components/MeshComponent.h"
2019-06-08 17:15:34 -04:00
# include "Chaos/Defines.h"
2018-12-12 11:25:29 -05:00
# include "Field/FieldSystem.h"
# include "Field/FieldSystemActor.h"
2019-06-08 17:15:34 -04:00
# include "Field/FieldSystemNodes.h"
# include "Field/FieldSystemObjects.h"
2018-12-12 11:25:29 -05:00
# include "GameFramework/Actor.h"
# include "GeometryCollection/GeometryCollection.h"
# include "GeometryCollection/GeometryCollectionSimulationTypes.h"
2019-06-08 17:15:34 -04:00
# include "GeometryCollection/GeometryCollectionSimulationCoreTypes.h"
2018-12-12 11:25:29 -05:00
# include "Physics/Experimental/PhysScene_Chaos.h"
2020-03-03 16:56:59 -05:00
# include "GeometryCollectionProxyData.h"
2019-06-08 17:15:34 -04:00
# include "GeometryCollectionObject.h"
2019-09-04 15:27:24 -04:00
# include "GeometryCollectionEditorSelection.h"
2019-06-08 17:15:34 -04:00
# include "GeometryCollection/RecordedTransformTrack.h"
# include "Templates/UniquePtr.h"
# include "Chaos/ChaosGameplayEventDispatcher.h"
# include "Chaos/ChaosNotifyHandlerInterface.h"
# include "Chaos/ChaosSolverComponentTypes.h"
2020-04-23 13:44:21 -04:00
# include "Chaos/PBDRigidsEvolutionFwd.h"
2021-04-29 19:32:06 -04:00
# include "EngineDefines.h"
2018-12-12 11:25:29 -05:00
# include "GeometryCollectionComponent.generated.h"
struct FGeometryCollectionConstantData ;
struct FGeometryCollectionDynamicData ;
class UGeometryCollectionComponent ;
class UBoxComponent ;
class UGeometryCollectionCache ;
2020-04-08 10:59:25 -04:00
class UChaosPhysicalMaterial ;
class AChaosSolverActor ;
2021-02-18 13:20:03 -04:00
struct FGeometryCollectionEmbeddedExemplar ;
class UInstancedStaticMeshComponent ;
2018-12-12 11:25:29 -05:00
2019-06-08 17:15:34 -04:00
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ( FOnChaosBreakEvent , const FChaosBreakEvent & , BreakEvent ) ;
2021-08-31 20:24:01 -04:00
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ( FOnChaosRemovalEvent , const FChaosRemovalEvent & , RemovalEvent ) ;
2018-12-12 11:25:29 -05:00
namespace GeometryCollection
{
enum class ESelectionMode : uint8
{
None = 0 ,
AllGeometry ,
2019-06-08 17:15:34 -04:00
InverseGeometry ,
Siblings ,
Neighbors ,
2021-08-30 17:18:37 -04:00
Parent ,
Children ,
Level
2018-12-12 11:25:29 -05:00
} ;
}
USTRUCT ( )
struct FGeomComponentCacheParameters
{
GENERATED_BODY ( )
FGeomComponentCacheParameters ( ) ;
// Cache mode, whether disabled, playing or recording
UPROPERTY ( EditAnywhere , Category = Cache )
EGeometryCollectionCacheType CacheMode ;
// The cache to target when recording or playing
UPROPERTY ( EditAnywhere , Category = Cache )
2021-01-27 17:40:25 -04:00
TObjectPtr < UGeometryCollectionCache > TargetCache ;
2018-12-12 11:25:29 -05:00
// Cache mode, whether disabled, playing or recording
UPROPERTY ( EditAnywhere , Category = Cache )
float ReverseCacheBeginTime ;
// Whether to buffer collisions during recording
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Record Collision Data " ) )
2018-12-12 11:25:29 -05:00
bool SaveCollisionData ;
2019-06-08 17:15:34 -04:00
// Whether to generate collisions during playback
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Generate Collision Data during Playback " ) )
bool DoGenerateCollisionData ;
2018-12-12 11:25:29 -05:00
// Maximum size of the collision buffer
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Collision Data Size Maximum " ) )
int32 CollisionDataSizeMax ;
2018-12-12 11:25:29 -05:00
// Spatial hash collision data
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Spatial Hash Collision Data " ) )
2018-12-12 11:25:29 -05:00
bool DoCollisionDataSpatialHash ;
// Spatial hash radius for collision data
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Spatial Hash Radius " ) )
float CollisionDataSpatialHashRadius ;
2018-12-12 11:25:29 -05:00
// Maximum number of collisions per cell
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Maximum Number of Collisions Per Cell " ) )
2018-12-12 11:25:29 -05:00
int32 MaxCollisionPerCell ;
2019-06-08 17:15:34 -04:00
// Whether to buffer breakings during recording
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Record Breaking Data " ) )
bool SaveBreakingData ;
// Whether to generate breakings during playback
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Generate Breaking Data during Playback " ) )
bool DoGenerateBreakingData ;
// Maximum size of the breaking buffer
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Breaking Data Size Maximum " ) )
int32 BreakingDataSizeMax ;
// Spatial hash breaking data
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Spatial Hash Breaking Data " ) )
bool DoBreakingDataSpatialHash ;
// Spatial hash radius for breaking data
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Spatial Hash Radius " ) )
float BreakingDataSpatialHashRadius ;
// Maximum number of breaking per cell
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Maximum Number of Breakings Per Cell " ) )
int32 MaxBreakingPerCell ;
// Whether to buffer trailings during recording
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Record Trailing Data " ) )
2018-12-12 11:25:29 -05:00
bool SaveTrailingData ;
2019-06-08 17:15:34 -04:00
// Whether to generate trailings during playback
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Generate Trailing Data during Playback " ) )
bool DoGenerateTrailingData ;
2018-12-12 11:25:29 -05:00
// Maximum size of the trailing buffer
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Trailing Data Size Maximum " ) )
2018-12-12 11:25:29 -05:00
int32 TrailingDataSizeMax ;
// Minimum speed to record trailing
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Trailing Minimum Speed Threshold " ) )
2018-12-12 11:25:29 -05:00
float TrailingMinSpeedThreshold ;
// Minimum volume to record trailing
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = Cache , meta = ( DisplayName = " Trailing Minimum Volume Threshold " ) )
2018-12-12 11:25:29 -05:00
float TrailingMinVolumeThreshold ;
} ;
2019-06-20 12:19:58 -04:00
namespace GeometryCollection
{
/** Type of updates used at the end of an edit operation. */
enum class EEditUpdate : uint8
{
/** No update. */
None = 0 ,
/** Mark the rest collection as changed. */
2022-01-31 14:58:13 -05:00
Rest = 1 < < 0 ,
2019-06-20 12:19:58 -04:00
/** Recreate the physics state (proxy). */
2022-01-31 14:58:13 -05:00
Physics = 1 < < 1 ,
2019-06-20 12:19:58 -04:00
/** Reset the dynamic collection. */
2022-01-31 14:58:13 -05:00
Dynamic = 1 < < 2 ,
2019-06-20 12:19:58 -04:00
/** Mark the rest collection as changed, and recreate the physics state (proxy). */
RestPhysics = Rest | Physics ,
/** Reset dynamic collection, mark the rest collection as changed, and recreate the physics state (proxy). */
RestPhysicsDynamic = Rest | Physics | Dynamic ,
} ;
ENUM_CLASS_FLAGS ( EEditUpdate ) ;
}
2018-12-12 11:25:29 -05:00
/**
* FGeometryCollectionEdit
* Structured RestCollection access where the scope
* of the object controls serialization back into the
* dynamic collection
*
* This will force any simulating geometry collection out of the
* solver so it can be edited and afterwards will recreate the proxy
2019-06-20 12:19:58 -04:00
* The update can also be specified to reset the dynamic collection
2018-12-12 11:25:29 -05:00
*/
class GEOMETRYCOLLECTIONENGINE_API FGeometryCollectionEdit
{
public :
2022-02-02 01:45:10 -05:00
/**
* @ param InComponent The component to edit
* @ param EditUpdate What parts of the geometry collection to update
* @ param bShapeIsUnchanged Override indicating the overall shape of the geometry and clusters is unchanged , even if the rest collection changed . Useful to e . g . , not re - compute convex hulls when we don ' t need to .
*/
FGeometryCollectionEdit ( UGeometryCollectionComponent * InComponent , GeometryCollection : : EEditUpdate EditUpdate = GeometryCollection : : EEditUpdate : : RestPhysics , bool bShapeIsUnchanged = false ) ;
2018-12-12 11:25:29 -05:00
~ FGeometryCollectionEdit ( ) ;
UGeometryCollection * GetRestCollection ( ) ;
private :
2019-06-08 17:15:34 -04:00
UGeometryCollectionComponent * Component ;
2019-06-20 12:19:58 -04:00
const GeometryCollection : : EEditUpdate EditUpdate ;
2018-12-12 11:25:29 -05:00
bool bHadPhysicsState ;
2022-02-02 01:45:10 -05:00
bool bShapeIsUnchanged ;
2018-12-12 11:25:29 -05:00
} ;
2019-06-08 17:15:34 -04:00
# if WITH_EDITOR
2018-12-12 11:25:29 -05:00
class GEOMETRYCOLLECTIONENGINE_API FScopedColorEdit
{
public :
2019-06-08 17:15:34 -04:00
FScopedColorEdit ( UGeometryCollectionComponent * InComponent , bool bForceUpdate = false ) ;
2018-12-12 11:25:29 -05:00
~ FScopedColorEdit ( ) ;
void SetShowBoneColors ( bool ShowBoneColorsIn ) ;
bool GetShowBoneColors ( ) const ;
2019-06-08 17:15:34 -04:00
void SetEnableBoneSelection ( bool ShowSelectedBonesIn ) ;
bool GetEnableBoneSelection ( ) const ;
2018-12-12 11:25:29 -05:00
bool IsBoneSelected ( int BoneIndex ) const ;
void SetSelectedBones ( const TArray < int32 > & SelectedBonesIn ) ;
void AppendSelectedBones ( const TArray < int32 > & SelectedBonesIn ) ;
2022-02-10 18:36:20 -05:00
void ToggleSelectedBones ( const TArray < int32 > & SelectedBonesIn , bool bAdd , bool bSnapToLevel = true ) ;
2018-12-12 11:25:29 -05:00
void AddSelectedBone ( int32 BoneIndex ) ;
void ClearSelectedBone ( int32 BoneIndex ) ;
const TArray < int32 > & GetSelectedBones ( ) const ;
void ResetBoneSelection ( ) ;
void SelectBones ( GeometryCollection : : ESelectionMode SelectionMode ) ;
2022-02-10 18:36:20 -05:00
void FilterSelectionToLevel ( bool bPreferLowestOnly = false ) ;
int32 GetMaxSelectedLevel ( bool bOnlyRigid ) const ;
bool IsSelectionValidAtLevel ( int32 TargetLevel ) const ;
2018-12-12 11:25:29 -05:00
bool IsBoneHighlighted ( int BoneIndex ) const ;
2022-02-10 18:36:20 -05:00
void SetHighlightedBones ( const TArray < int32 > & HighlightedBonesIn , bool bHighlightChildren = false ) ;
2018-12-12 11:25:29 -05:00
void AddHighlightedBone ( int32 BoneIndex ) ;
const TArray < int32 > & GetHighlightedBones ( ) const ;
void ResetHighlightedBones ( ) ;
void SetLevelViewMode ( int ViewLevel ) ;
int GetViewLevel ( ) ;
private :
void UpdateBoneColors ( ) ;
2019-06-08 17:15:34 -04:00
bool bUpdated ;
2018-12-12 11:25:29 -05:00
UGeometryCollectionComponent * Component ;
static TArray < FLinearColor > RandomColors ;
} ;
2019-06-08 17:15:34 -04:00
# endif
//Provides copy on write functionality:
//GetArray (const access)
//GetArrayCopyOnWrite
//GetArrayRest (gives original rest value)
//This generates pointers to arrays marked private. Macro assumes getters are public
//todo(ocohen): may want to take in a static name
2020-02-21 17:41:35 -05:00
# define COPY_ON_WRITE_ATTRIBUTE(Type, Name, Group) \
FORCEINLINE const TManagedArray < Type > & Get # # Name # # Array ( ) const \
{ \
return Indirect # # Name # # Array ? \
* Indirect # # Name # # Array : RestCollection - > GetGeometryCollection ( ) - > Name ; \
} \
FORCEINLINE TManagedArray < Type > & Get # # Name # # ArrayCopyOnWrite ( ) \
{ \
if ( ! Indirect # # Name # # Array ) \
{ \
static FName StaticName ( # Name ) ; \
DynamicCollection - > AddAttribute < Type > ( StaticName , Group ) ; \
DynamicCollection - > CopyAttribute ( \
* RestCollection - > GetGeometryCollection ( ) , StaticName , Group ) ; \
Indirect # # Name # # Array = \
2022-05-10 18:56:28 -04:00
& DynamicCollection - > ModifyAttribute < Type > ( StaticName , Group ) ; \
2020-02-21 17:41:35 -05:00
CopyOnWriteAttributeList . Add ( \
reinterpret_cast < FManagedArrayBase * * > ( & Indirect # # Name # # Array ) ) ; \
} \
return * Indirect # # Name # # Array ; \
} \
FORCEINLINE void Reset # # Name # # ArrayDynamic ( ) \
{ \
Indirect # # Name # # Array = NULL ; \
} \
FORCEINLINE const TManagedArray < Type > & Get # # Name # # ArrayRest ( ) const \
{ \
return RestCollection - > GetGeometryCollection ( ) - > Name ; \
} \
private : \
TManagedArray < Type > * Indirect # # Name # # Array ; \
2019-06-08 17:15:34 -04:00
public :
2020-09-01 14:07:48 -04:00
/**
* Raw struct to serialize for network . We need to custom netserialize to optimize
* the vector serialize as much as possible and rather than have the property system
* iterate an array of reflected structs we handle everything in the NetSerialize for
2022-04-25 13:09:18 -04:00
* the container ( FGeometryCollectionClusterRep )
2020-09-01 14:07:48 -04:00
*/
2022-04-25 13:09:18 -04:00
struct FGeometryCollectionClusterRep
2020-09-01 14:07:48 -04:00
{
2022-04-25 13:09:18 -04:00
FVector_NetQuantize100 Position ;
FVector_NetQuantize100 LinearVelocity ;
FVector_NetQuantize100 AngularVelocity ;
2020-09-01 14:07:48 -04:00
FQuat Rotation ;
2022-04-25 13:09:18 -04:00
uint16 ClusterIdx ;
int8 ObjectState ;
bool ClusterChanged ( const FGeometryCollectionClusterRep & Other ) const
{
return Other . ObjectState ! = ObjectState
| | Other . ClusterIdx ! = ClusterIdx
| | Other . Position ! = Position
| | Other . LinearVelocity ! = LinearVelocity
| | Other . AngularVelocity ! = AngularVelocity
| | Other . Rotation ! = Rotation ;
}
2020-09-01 14:07:48 -04:00
} ;
/**
* Replicated data for a geometry collection when bEnableReplication is true for
* that component . See UGeomtryCollectionComponent : : UpdateRepData
*/
USTRUCT ( )
struct FGeometryCollectionRepData
{
GENERATED_BODY ( )
FGeometryCollectionRepData ( )
: Version ( 0 )
{
}
2022-04-25 13:09:18 -04:00
//Array of one off pieces that became activated
TArray < uint16 > OneOffActivated ;
// Array of cluster data requires to synchronize clients
TArray < FGeometryCollectionClusterRep > Clusters ;
2020-09-01 14:07:48 -04:00
// Version counter, every write to the rep data is a new state so Identical only references this version
// as there's no reason to compare the Poses array.
int32 Version ;
// Just test version to skip having to traverse the whole pose array for replication
bool Identical ( const FGeometryCollectionRepData * Other , uint32 PortFlags ) const ;
bool NetSerialize ( FArchive & Ar , class UPackageMap * Map , bool & bOutSuccess ) ;
} ;
template < >
struct TStructOpsTypeTraits < FGeometryCollectionRepData > : public TStructOpsTypeTraitsBase2 < FGeometryCollectionRepData >
{
enum
{
WithNetSerializer = true ,
WithIdentical = true ,
} ;
} ;
2018-12-12 11:25:29 -05:00
/**
* GeometryCollectionComponent
*/
UCLASS ( meta = ( BlueprintSpawnableComponent ) )
2019-06-08 17:15:34 -04:00
class GEOMETRYCOLLECTIONENGINE_API UGeometryCollectionComponent : public UMeshComponent , public IChaosNotifyHandlerInterface
2018-12-12 11:25:29 -05:00
{
GENERATED_UCLASS_BODY ( )
friend class FGeometryCollectionEdit ;
2019-06-08 17:15:34 -04:00
# if WITH_EDITOR
2018-12-12 11:25:29 -05:00
friend class FScopedColorEdit ;
2019-06-08 17:15:34 -04:00
# endif
2018-12-12 11:25:29 -05:00
friend class FGeometryCollectionCommands ;
public :
//~ Begin UActorComponent Interface.
2020-02-06 13:13:41 -05:00
virtual void CreateRenderState_Concurrent ( FRegisterComponentContext * Context ) override ;
2018-12-12 11:25:29 -05:00
virtual void SendRenderDynamicData_Concurrent ( ) override ;
FORCEINLINE void SetRenderStateDirty ( ) { bRenderStateDirty = true ; }
2022-05-26 20:17:19 -04:00
virtual void OnActorEnableCollisionChanged ( ) override ;
2018-12-12 11:25:29 -05:00
virtual void BeginPlay ( ) override ;
2019-09-16 13:42:25 -04:00
virtual void EndPlay ( const EEndPlayReason : : Type ReasonEnd ) override ;
2020-09-01 14:07:48 -04:00
virtual void GetLifetimeReplicatedProps ( TArray < FLifetimeProperty > & OutLifetimeProps ) const override ;
virtual void InitializeComponent ( ) override ;
2021-03-18 23:55:49 -04:00
# if WITH_EDITOR
virtual void PostEditChangeChainProperty ( FPropertyChangedChainEvent & PropertyChangedEvent ) override ;
# endif
2018-12-12 11:25:29 -05:00
//~ Begin UActorComponent Interface.
//~ Begin USceneComponent Interface.
virtual FBoxSphereBounds CalcBounds ( const FTransform & LocalToWorld ) const override ;
2019-06-08 17:15:34 -04:00
virtual FBoxSphereBounds CalcLocalBounds ( ) const { return LocalBounds ; }
2018-12-12 11:25:29 -05:00
virtual bool HasAnySockets ( ) const override { return false ; }
virtual void TickComponent ( float DeltaTime , enum ELevelTick TickType , FActorComponentTickFunction * ThisTickFunction ) override ;
2022-04-25 13:09:18 -04:00
virtual void AsyncPhysicsTickComponent ( float DeltaTime , float SimTime ) override ;
2018-12-12 11:25:29 -05:00
//~ Begin USceneComponent Interface.
//~ Begin UPrimitiveComponent Interface.
virtual FPrimitiveSceneProxy * CreateSceneProxy ( ) override ;
2019-06-08 17:15:34 -04:00
virtual void OnRegister ( ) override ;
2021-05-18 14:32:57 -04:00
virtual FBodyInstance * GetBodyInstance ( FName BoneName = NAME_None , bool bGetWelded = true , int32 Index = - 1 ) const override ;
2019-06-08 17:15:34 -04:00
virtual void SetNotifyRigidBodyCollision ( bool bNewNotifyRigidBodyCollision ) override ;
2021-05-25 22:01:05 -04:00
virtual bool CanEditSimulatePhysics ( ) override ;
virtual void SetSimulatePhysics ( bool bEnabled ) override ;
2022-04-12 19:07:33 -04:00
virtual void AddForce ( FVector Force , FName BoneName = NAME_None , bool bAccelChange = false ) override ;
2022-04-13 12:39:04 -04:00
virtual void AddImpulse ( FVector Impulse , FName BoneName = NAME_None , bool bVelChange = false ) override ;
2022-04-12 19:07:33 -04:00
virtual void AddRadialForce ( FVector Origin , float Radius , float Strength , ERadialImpulseFalloff Falloff , bool bAccelChange = false ) override ;
2022-04-13 12:39:04 -04:00
virtual void AddRadialImpulse ( FVector Origin , float Radius , float Strength , enum ERadialImpulseFalloff Falloff , bool bVelChange = false ) override ;
2022-04-12 19:07:33 -04:00
virtual void AddTorqueInRadians ( FVector Torque , FName BoneName = NAME_None , bool bAccelChange = false ) override ;
2022-02-07 16:26:46 -05:00
virtual void PostLoad ( ) override ;
2018-12-12 11:25:29 -05:00
//~ End UPrimitiveComponent Interface.
2019-06-08 17:15:34 -04:00
//~ Begin UMeshComponent Interface.
virtual int32 GetNumMaterials ( ) const override ;
virtual UMaterialInterface * GetMaterial ( int32 MaterialIndex ) const override ;
2018-12-12 11:25:29 -05:00
//~ End UMeshComponent Interface.
2019-06-08 17:15:34 -04:00
/** Chaos RBD Solver override. Will use the world's default solver actor if null. */
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , Category = " ChaosPhysics " , meta = ( DisplayName = " Chaos Solver " ) )
2021-01-27 17:40:25 -04:00
TObjectPtr < AChaosSolverActor > ChaosSolverActor ;
2018-12-12 11:25:29 -05:00
/** RestCollection */
2022-05-13 18:57:23 -04:00
UFUNCTION ( BlueprintCallable , Category = " ChaosPhysics " )
2019-06-08 17:15:34 -04:00
void SetRestCollection ( const UGeometryCollection * RestCollectionIn ) ;
2022-05-13 18:57:23 -04:00
2018-12-12 11:25:29 -05:00
FORCEINLINE const UGeometryCollection * GetRestCollection ( ) const { return RestCollection ; }
2022-05-13 18:57:23 -04:00
2022-02-02 01:45:10 -05:00
FORCEINLINE FGeometryCollectionEdit EditRestCollection ( GeometryCollection : : EEditUpdate EditUpdate = GeometryCollection : : EEditUpdate : : RestPhysics , bool bShapeIsUnchanged = false ) { return FGeometryCollectionEdit ( this , EditUpdate , bShapeIsUnchanged ) ; }
2019-06-08 17:15:34 -04:00
# if WITH_EDITOR
2022-02-02 07:57:02 -05:00
FORCEINLINE FScopedColorEdit EditBoneSelection ( bool bForceUpdate = false ) { return FScopedColorEdit ( this , bForceUpdate ) ; }
2021-09-05 20:37:59 -04:00
/** Propagate bone selection to embedded geometry components. */
void SelectEmbeddedGeometry ( ) ;
2019-06-08 17:15:34 -04:00
# endif
2018-12-12 11:25:29 -05:00
2019-06-08 17:15:34 -04:00
/** API for getting at geometry collection data */
FORCEINLINE int32 GetNumElements ( FName Group ) const
{
int32 Size = RestCollection - > NumElements ( Group ) ; //assume rest collection has the group and is connected to dynamic.
return Size > 0 ? Size : DynamicCollection - > NumElements ( Group ) ; //if not, maybe dynamic has the group
}
2018-12-12 11:25:29 -05:00
2019-06-08 17:15:34 -04:00
// Vertices Group
2021-05-05 15:07:25 -04:00
COPY_ON_WRITE_ATTRIBUTE ( FVector3f , Vertex , FGeometryCollection : : VerticesGroup ) //GetVertexArray, GetVertexArrayCopyOnWrite, GetVertexArrayRest
2021-11-18 14:37:34 -05:00
COPY_ON_WRITE_ATTRIBUTE ( TArray < FVector2f > , UVs , FGeometryCollection : : VerticesGroup ) //GetUVsArray
2019-06-08 17:15:34 -04:00
COPY_ON_WRITE_ATTRIBUTE ( FLinearColor , Color , FGeometryCollection : : VerticesGroup ) //GetColorArray
2021-05-05 15:07:25 -04:00
COPY_ON_WRITE_ATTRIBUTE ( FVector3f , TangentU , FGeometryCollection : : VerticesGroup ) //GetTangentUArray
COPY_ON_WRITE_ATTRIBUTE ( FVector3f , TangentV , FGeometryCollection : : VerticesGroup ) //...
COPY_ON_WRITE_ATTRIBUTE ( FVector3f , Normal , FGeometryCollection : : VerticesGroup )
2019-06-08 17:15:34 -04:00
COPY_ON_WRITE_ATTRIBUTE ( int32 , BoneMap , FGeometryCollection : : VerticesGroup )
// Faces Group
COPY_ON_WRITE_ATTRIBUTE ( FIntVector , Indices , FGeometryCollection : : FacesGroup )
COPY_ON_WRITE_ATTRIBUTE ( bool , Visible , FGeometryCollection : : FacesGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , MaterialIndex , FGeometryCollection : : FacesGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , MaterialID , FGeometryCollection : : FacesGroup )
// Geometry Group
COPY_ON_WRITE_ATTRIBUTE ( int32 , TransformIndex , FGeometryCollection : : GeometryGroup )
COPY_ON_WRITE_ATTRIBUTE ( FBox , BoundingBox , FGeometryCollection : : GeometryGroup )
COPY_ON_WRITE_ATTRIBUTE ( float , InnerRadius , FGeometryCollection : : GeometryGroup )
COPY_ON_WRITE_ATTRIBUTE ( float , OuterRadius , FGeometryCollection : : GeometryGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , VertexStart , FGeometryCollection : : GeometryGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , VertexCount , FGeometryCollection : : GeometryGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , FaceStart , FGeometryCollection : : GeometryGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , FaceCount , FGeometryCollection : : GeometryGroup )
// Material Group
COPY_ON_WRITE_ATTRIBUTE ( FGeometryCollectionSection , Sections , FGeometryCollection : : MaterialGroup )
// Transform group
COPY_ON_WRITE_ATTRIBUTE ( FString , BoneName , FTransformCollection : : TransformGroup )
COPY_ON_WRITE_ATTRIBUTE ( FLinearColor , BoneColor , FTransformCollection : : TransformGroup )
COPY_ON_WRITE_ATTRIBUTE ( FTransform , Transform , FTransformCollection : : TransformGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , Parent , FTransformCollection : : TransformGroup )
COPY_ON_WRITE_ATTRIBUTE ( TSet < int32 > , Children , FTransformCollection : : TransformGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , SimulationType , FTransformCollection : : TransformGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , TransformToGeometryIndex , FTransformCollection : : TransformGroup )
COPY_ON_WRITE_ATTRIBUTE ( int32 , StatusFlags , FTransformCollection : : TransformGroup )
2021-02-18 13:20:03 -04:00
COPY_ON_WRITE_ATTRIBUTE ( int32 , ExemplarIndex , FTransformCollection : : TransformGroup )
2018-12-12 11:25:29 -05:00
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , NoClear , BlueprintReadOnly , Category = " ChaosPhysics " )
2021-01-27 17:40:25 -04:00
TObjectPtr < const UGeometryCollection > RestCollection ;
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , NoClear , BlueprintReadOnly , Category = " ChaosPhysics " )
2021-01-27 17:40:25 -04:00
TArray < TObjectPtr < const AFieldSystemActor > > InitializationFields ;
2018-12-12 11:25:29 -05:00
2021-05-25 22:01:05 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " GeometryCollection now abides the bSimulatePhysics flag from the base class. " ) )
bool Simulating_DEPRECATED ;
2019-06-08 17:15:34 -04:00
ESimulationInitializationState InitializationState ;
2018-12-12 11:25:29 -05:00
2020-02-21 17:40:37 -05:00
/** ObjectType defines how to initialize the rigid objects state, Kinematic, Sleeping, Dynamic. */
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|General " )
2019-06-08 17:15:34 -04:00
EObjectStateTypeEnum ObjectType ;
2021-12-02 18:57:44 -05:00
/** If ForceMotionBlur is on, motion blur will always be active, even if the GeometryCollection is at rest. */
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|General " )
bool bForceMotionBlur ;
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Clustering " )
bool EnableClustering ;
2020-02-21 17:40:37 -05:00
/** Maximum level for cluster breaks. */
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Clustering " )
int32 ClusterGroupIndex ;
2020-02-21 17:40:37 -05:00
/** Maximum level for cluster breaks. */
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Clustering " )
int32 MaxClusterLevel ;
2021-01-29 00:35:21 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Clustering " , meta = ( EditCondition = " !bUseSizeSpecificDamageThreshold " ) )
TArray < float > DamageThreshold ;
2020-02-21 17:40:37 -05:00
/** Damage threshold for clusters at different levels. */
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Clustering " )
2021-01-29 00:35:21 -04:00
bool bUseSizeSpecificDamageThreshold ;
2018-12-12 11:25:29 -05:00
2020-02-21 17:40:37 -05:00
/** */
2021-03-19 15:28:38 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Connection types are defined on the asset now. " ) )
EClusterConnectionTypeEnum ClusterConnectionType_DEPRECATED ;
2018-12-12 11:25:29 -05:00
2020-02-21 17:40:37 -05:00
/** */
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Collisions " )
2019-06-08 17:15:34 -04:00
int32 CollisionGroup ;
2018-12-12 11:25:29 -05:00
2021-01-25 19:12:43 -04:00
/** Fraction of collision sample particles to keep */
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Collisions " )
2019-06-08 17:15:34 -04:00
float CollisionSampleFraction ;
2020-02-21 17:40:37 -05:00
/** Uniform linear ether drag. */
2020-04-20 04:54:20 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use PhysicalMaterial instead. " ) )
float LinearEtherDrag_DEPRECATED ;
2018-12-12 11:25:29 -05:00
2020-02-21 17:40:37 -05:00
/** Uniform angular ether drag. */
2020-04-20 04:54:20 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use PhysicalMaterial instead. " ) )
float AngularEtherDrag_DEPRECATED ;
2020-02-21 17:40:37 -05:00
/** Physical Properties */
2020-09-24 00:43:27 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Physical material now derived from render materials, for instance overrides use PhysicalMaterialOverride. " ) )
2021-01-27 17:40:25 -04:00
TObjectPtr < const UChaosPhysicalMaterial > PhysicalMaterial_DEPRECATED ;
2018-12-12 11:25:29 -05:00
2020-02-21 17:40:37 -05:00
/** */
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Initial Velocity " )
EInitialVelocityTypeEnum InitialVelocityType ;
2020-02-21 17:40:37 -05:00
/** */
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Initial Velocity " )
FVector InitialLinearVelocity ;
2020-02-21 17:40:37 -05:00
/** */
2018-12-12 11:25:29 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|Initial Velocity " )
FVector InitialAngularVelocity ;
2022-02-07 16:26:46 -05:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Physical material now derived from render materials, for instance overrides use Colliisons PhysicalMaterialOverride. " ) )
TObjectPtr < UPhysicalMaterial > PhysicalMaterialOverride_DEPRECATED ;
2020-09-24 00:43:27 -04:00
2020-09-01 14:07:48 -04:00
UPROPERTY ( )
2018-12-12 11:25:29 -05:00
FGeomComponentCacheParameters CacheParameters ;
2021-06-16 01:29:49 -04:00
/** Optional transforms to initialize scene proxy if difference from the RestCollection. */
UPROPERTY ( )
TArray < FTransform > RestTransforms ;
2021-02-03 14:57:28 -04:00
/**
2021-03-05 19:27:14 -04:00
* SetDynamicState
2021-02-03 14:57:28 -04:00
* This function will dispatch a command to the physics thread to apply
* a kinematic to dynamic state change for the geo collection particles within the field .
*
* @ param Radius Radial influence from the position
* @ param Position The location of the command
*
*/
UFUNCTION ( BlueprintCallable , Category = " Field " , DisplayName = " Set Dynamic State " )
void ApplyKinematicField ( UPARAM ( DisplayName = " Field Radius " ) float Radius ,
UPARAM ( DisplayName = " Center Position " ) FVector Position ) ;
2019-06-08 17:15:34 -04:00
2021-02-03 14:57:28 -04:00
/**
2021-03-05 19:27:14 -04:00
* AddPhysicsField
2021-02-03 14:57:28 -04:00
* This function will dispatch a command to the physics thread to apply
* a generic evaluation of a user defined transient field network . See documentation ,
* for examples of how to recreate variations of the above generic
* fields using field networks
*
* @ param Enabled Is this force enabled for evaluation .
* @ param Target Type of field supported by the solver .
* @ param MetaData Meta data used to assist in evaluation
* @ param Field Base evaluation node for the field network .
*
*/
2021-03-05 19:27:14 -04:00
UFUNCTION ( BlueprintCallable , Category = " Field " , DisplayName = " Add Physics Field " )
2021-02-03 14:57:28 -04:00
void ApplyPhysicsField ( UPARAM ( DisplayName = " Enable Field " ) bool Enabled ,
UPARAM ( DisplayName = " Physics Type " ) EGeometryCollectionPhysicsTypeEnum Target ,
UPARAM ( DisplayName = " Meta Data " ) UFieldSystemMetaData * MetaData ,
UPARAM ( DisplayName = " Field Node " ) UFieldNodeBase * Field ) ;
2019-06-08 17:15:34 -04:00
/**
* Blueprint event
*/
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ( FNotifyGeometryCollectionPhysicsStateChange , UGeometryCollectionComponent * , FracturedComponent ) ;
UPROPERTY ( BlueprintAssignable , Category = " Game|Damage " )
FNotifyGeometryCollectionPhysicsStateChange NotifyGeometryCollectionPhysicsStateChange ;
2021-05-25 22:01:05 -04:00
bool GetIsObjectDynamic ( ) const ;
2019-06-08 17:15:34 -04:00
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ( FNotifyGeometryCollectionPhysicsLoadingStateChange , UGeometryCollectionComponent * , FracturedComponent ) ;
UPROPERTY ( BlueprintAssignable , Category = " Game|Loading " )
FNotifyGeometryCollectionPhysicsLoadingStateChange NotifyGeometryCollectionPhysicsLoadingStateChange ;
bool GetIsObjectLoading ( ) { return IsObjectLoading ; }
2018-12-12 11:25:29 -05:00
/**
*
*/
/* ---------------------------------------------------------------------------------------- */
2022-03-01 14:33:59 -05:00
bool GetNotifyTrailing ( ) const { return bNotifyTrailing ; }
2021-03-22 14:37:32 -04:00
void SetShowBoneColors ( bool ShowBoneColorsIn ) { bShowBoneColors = ShowBoneColorsIn ; }
2019-06-08 17:15:34 -04:00
bool GetShowBoneColors ( ) const { return bShowBoneColors ; }
bool GetEnableBoneSelection ( ) const { return bEnableBoneSelection ; }
2018-12-12 11:25:29 -05:00
2021-08-30 17:11:38 -04:00
bool GetSuppressSelectionMaterial ( ) const { return RestCollection - > GetGeometryCollection ( ) - > HasAttribute ( " Hide " , FGeometryCollection : : TransformGroup ) ; }
2019-06-08 17:15:34 -04:00
FORCEINLINE const int GetBoneSelectedMaterialID ( ) const { return RestCollection - > GetBoneSelectedMaterialIndex ( ) ; }
2018-12-12 11:25:29 -05:00
2019-06-08 17:15:34 -04:00
# if WITH_EDITORONLY_DATA
2018-12-12 11:25:29 -05:00
FORCEINLINE const TArray < int32 > & GetSelectedBones ( ) const { return SelectedBones ; }
FORCEINLINE const TArray < int32 > & GetHighlightedBones ( ) const { return HighlightedBones ; }
2019-06-08 17:15:34 -04:00
# endif
2018-12-12 11:25:29 -05:00
2020-03-09 13:22:54 -04:00
FPhysScene_Chaos * GetInnerChaosScene ( ) const ;
2019-06-08 17:15:34 -04:00
AChaosSolverActor * GetPhysicsSolverActor ( ) const ;
2020-09-01 14:07:48 -04:00
2019-08-02 09:01:58 -04:00
const FGeometryCollectionPhysicsProxy * GetPhysicsProxy ( ) const { return PhysicsProxy ; }
2020-09-01 14:07:48 -04:00
FGeometryCollectionPhysicsProxy * GetPhysicsProxy ( ) { return PhysicsProxy ; }
2018-12-12 11:25:29 -05:00
2019-06-08 17:15:34 -04:00
# if GEOMETRYCOLLECTION_EDITOR_SELECTION
/** Enable/disable the scene proxy per transform selection mode. When disabled the per material id default selection is used instead. */
void EnableTransformSelectionMode ( bool bEnable ) ;
# endif // #if GEOMETRYCOLLECTION_EDITOR_SELECTION
2021-04-29 19:32:06 -04:00
# if UE_ENABLE_DEBUG_DRAWING
2019-06-08 17:15:34 -04:00
/** Force render after constant data changes (such as visibility, or hitproxy subsections). Will also work while paused. */
void ForceRenderUpdateConstantData ( ) { MarkRenderStateDirty ( ) ; }
/** Force render after dynamic data changes (such as transforms). Will also work while paused. */
void ForceRenderUpdateDynamicData ( ) { MarkRenderDynamicDataDirty ( ) ; }
2021-04-29 19:32:06 -04:00
# endif // UE_ENABLE_DEBUG_DRAWING
2018-12-12 11:25:29 -05:00
/**/
2019-06-08 17:15:34 -04:00
const TArray < bool > & GetDisabledFlags ( ) const { return DisabledFlags ; }
2018-12-12 11:25:29 -05:00
virtual void OnCreatePhysicsState ( ) override ;
2021-05-25 22:01:05 -04:00
void RegisterAndInitializePhysicsProxy ( ) ;
2018-12-12 11:25:29 -05:00
virtual void OnDestroyPhysicsState ( ) override ;
virtual bool ShouldCreatePhysicsState ( ) const override ;
virtual bool HasValidPhysicsState ( ) const override ;
2021-03-25 17:47:32 -04:00
virtual void OnUpdateTransform ( EUpdateTransformFlags UpdateTransformFlags , ETeleportType Teleport = ETeleportType : : None ) override ;
2018-12-12 11:25:29 -05:00
// Mirrored from the proxy on a sync
2019-11-08 19:47:41 -05:00
//TManagedArray<int32> RigidBodyIds;
2019-06-08 17:15:34 -04:00
TArray < bool > DisabledFlags ;
int32 BaseRigidBodyIndex ;
int32 NumParticlesAdded ;
/** Changes whether or not this component will get future break notifications. */
UFUNCTION ( BlueprintCallable , Category = " Physics " )
void SetNotifyBreaks ( bool bNewNotifyBreaks ) ;
2021-08-31 20:24:01 -04:00
/** Changes whether or not this component will get future removal notifications. */
UFUNCTION ( BlueprintCallable , Category = " Physics " )
void SetNotifyRemovals ( bool bNewNotifyRemovals ) ;
2019-06-08 17:15:34 -04:00
/** Overrideable native notification */
virtual void NotifyBreak ( const FChaosBreakEvent & Event ) { } ;
2021-08-31 20:24:01 -04:00
/** Overrideable native notification */
virtual void NotifyRemoval ( const FChaosRemovalEvent & Event ) { } ;
2019-06-08 17:15:34 -04:00
UPROPERTY ( BlueprintAssignable , Category = " Chaos " )
FOnChaosBreakEvent OnChaosBreakEvent ;
2021-08-31 20:24:01 -04:00
UPROPERTY ( BlueprintAssignable , Category = " Chaos " )
FOnChaosRemovalEvent OnChaosRemovalEvent ;
2019-06-08 17:15:34 -04:00
void DispatchBreakEvent ( const FChaosBreakEvent & Event ) ;
2021-08-31 20:24:01 -04:00
void DispatchRemovalEvent ( const FChaosRemovalEvent & Event ) ;
2019-06-08 17:15:34 -04:00
UPROPERTY ( Transient , VisibleAnywhere , BlueprintReadWrite , Interp , Category = " Chaos " )
float DesiredCacheTime ;
UPROPERTY ( Transient , VisibleAnywhere , BlueprintReadWrite , Category = " Chaos " )
bool CachePlayback ;
2020-04-30 07:34:59 -04:00
bool DoCustomNavigableGeometryExport ( FNavigableGeometryExport & GeomExport ) const override ;
2019-06-08 17:15:34 -04:00
2020-09-24 00:43:27 -04:00
/** Gets the physical material to use for this geometry collection, taking into account instance overrides and render materials */
UPhysicalMaterial * GetPhysicalMaterial ( ) const ;
2021-02-18 13:20:03 -04:00
/** Update component structure to reflect any changes to the embedded geometry */
void InitializeEmbeddedGeometry ( ) ;
/** Update instanced static mesh components to reflect internal embedded geometry state. */
void RefreshEmbeddedGeometry ( ) ;
2021-09-05 20:37:59 -04:00
# if WITH_EDITOR
void SetEmbeddedGeometrySelectable ( bool bSelectableIn ) ;
int32 EmbeddedIndexToTransformIndex ( const UInstancedStaticMeshComponent * ISMComponent , int32 InstanceIndex ) const ;
# endif
2021-06-16 01:29:49 -04:00
// #todo should this only be available in editor?
void SetRestState ( TArray < FTransform > & & InRestTransforms ) ;
/** Set the dynamic state for all bodies in the DynamicCollection. */
void SetDynamicState ( const Chaos : : EObjectStateType & NewDynamicState ) ;
/** Set transforms for all bodies in the DynamicCollection. */
void SetInitialTransforms ( const TArray < FTransform > & InitialTransforms ) ;
/** Modify DynamicCollection transform hierarchy to effect cluster breaks releasing the specified indices. */
void SetInitialClusterBreaks ( const TArray < int32 > & ReleaseIndices ) ;
2021-10-25 17:35:57 -04:00
/** Used by Niagara DI to query global matrices rather than recalculating them again */
const TArray < FMatrix > & GetGlobalMatrices ( ) { return GlobalMatrices ; }
2022-02-25 10:34:43 -05:00
const FGeometryDynamicCollection * GetDynamicCollection ( ) const { return DynamicCollection . Get ( ) ; }
2019-06-08 17:15:34 -04:00
public :
UPROPERTY ( BlueprintAssignable , Category = " Collision " )
FOnChaosPhysicsCollision OnChaosPhysicsCollision ;
UFUNCTION ( BlueprintImplementableEvent , meta = ( DisplayName = " Physics Collision " ) , Category = " Collision " )
void ReceivePhysicsCollision ( const FChaosPhysicsCollisionInfo & CollisionInfo ) ;
// IChaosNotifyHandlerInterface
virtual void DispatchChaosPhysicsCollisionBlueprintEvents ( const FChaosPhysicsCollisionInfo & CollisionInfo ) override ;
2021-02-18 13:20:03 -04:00
2021-06-16 01:29:49 -04:00
/** If true, this component will generate breaking events that other systems may subscribe to. */
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " ChaosPhysics|General " )
bool bNotifyBreaks ;
2021-06-16 01:29:49 -04:00
/** If true, this component will generate collision events that other systems may subscribe to. */
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " ChaosPhysics|General " )
bool bNotifyCollisions ;
2018-12-12 11:25:29 -05:00
2021-06-16 01:29:49 -04:00
/** If true, this component will generate trailing events that other systems may subscribe to. */
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " ChaosPhysics|General " )
bool bNotifyTrailing ;
2021-08-31 20:24:01 -04:00
/** If true, this component will generate removal events that other systems may subscribe to. */
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " ChaosPhysics|General " )
bool bNotifyRemovals ;
2022-03-01 14:33:59 -05:00
/** If true, this component will save linear and angular velocities on its DynamicCollection. */
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " ChaosPhysics|General " )
bool bStoreVelocities ;
2021-06-16 01:29:49 -04:00
protected :
2021-03-18 20:04:04 -04:00
/** Display Bone Colors instead of assigned materials */
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " ChaosPhysics|General " )
bool bShowBoneColors ;
2018-12-12 11:25:29 -05:00
/** Populate the static geometry structures for the render thread. */
2019-06-08 17:15:34 -04:00
void InitConstantData ( FGeometryCollectionConstantData * ConstantData ) const ;
2018-12-12 11:25:29 -05:00
/** Populate the dynamic particle data for the render thread. */
2021-04-24 04:37:11 -04:00
FGeometryCollectionDynamicData * InitDynamicData ( bool bInitialization ) ;
2018-12-12 11:25:29 -05:00
/** Reset the dynamic collection from the current rest state. */
void ResetDynamicCollection ( ) ;
2019-06-08 17:15:34 -04:00
/** Combine the commands from the input field assets */
void GetInitializationCommands ( TArray < FFieldSystemCommand > & CombinedCommmands ) ;
/** Issue a field command for the physics thread */
2021-02-03 14:57:28 -04:00
void DispatchFieldCommand ( const FFieldSystemCommand & InCommand ) ;
2019-06-08 17:15:34 -04:00
void CalculateLocalBounds ( ) ;
void CalculateGlobalMatrices ( ) ;
void RegisterForEvents ( ) ;
void UpdateRBCollisionEventRegistration ( ) ;
void UpdateBreakEventRegistration ( ) ;
2021-08-31 20:24:01 -04:00
void UpdateRemovalEventRegistration ( ) ;
2019-06-08 17:15:34 -04:00
2021-10-25 17:06:59 -04:00
2020-09-01 14:07:48 -04:00
/* Per-instance override to enable/disable replication for the geometry collection */
2022-05-04 12:47:38 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = Network )
2020-09-01 14:07:48 -04:00
bool bEnableReplication ;
/**
* Enables use of ReplicationAbandonClusterLevel to stop providing network updates to
* clients when the updated particle is of a level higher then specified .
*/
2022-05-04 12:47:38 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = Network )
2020-09-01 14:07:48 -04:00
bool bEnableAbandonAfterLevel ;
/**
* If replicating - the cluster level to stop sending corrections for geometry collection chunks .
* recommended for smaller leaf levels when the size of the objects means they are no longer
* gameplay relevant to cut down on required bandwidth to update a collection .
* @ see bEnableAbandonAfterLevel
*/
2022-05-04 12:47:38 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = Network )
2020-09-01 14:07:48 -04:00
int32 ReplicationAbandonClusterLevel ;
2022-04-25 13:09:18 -04:00
UPROPERTY ( Replicated )
2020-09-01 14:07:48 -04:00
FGeometryCollectionRepData RepData ;
/** Called post solve to allow authoritative components to update their replication data */
void UpdateRepData ( ) ;
2018-12-12 11:25:29 -05:00
private :
2020-09-01 14:07:48 -04:00
2018-12-12 11:25:29 -05:00
bool bRenderStateDirty ;
2019-06-08 17:15:34 -04:00
bool bEnableBoneSelection ;
2018-12-12 11:25:29 -05:00
int ViewLevel ;
2019-06-08 17:15:34 -04:00
uint32 NavmeshInvalidationTimeSliceIndex ;
bool IsObjectDynamic ;
bool IsObjectLoading ;
2020-03-09 13:22:54 -04:00
FCollisionFilterData InitialSimFilter ;
FCollisionFilterData InitialQueryFilter ;
FPhysxUserData PhysicsUserData ;
2019-06-08 17:15:34 -04:00
# if WITH_EDITORONLY_DATA
2019-07-23 16:27:55 -04:00
UPROPERTY ( Transient )
2018-12-12 11:25:29 -05:00
TArray < int32 > SelectedBones ;
2019-07-23 16:27:55 -04:00
UPROPERTY ( Transient )
2019-06-08 17:15:34 -04:00
TArray < int32 > HighlightedBones ;
# endif
TArray < FMatrix > GlobalMatrices ;
FBox LocalBounds ;
2021-04-20 10:45:04 -04:00
FBoxSphereBounds WorldBounds ;
2019-06-08 17:15:34 -04:00
float CurrentCacheTime ;
TArray < bool > EventsPlayed ;
2019-08-02 09:01:58 -04:00
FGeometryCollectionPhysicsProxy * PhysicsProxy ;
2019-06-08 17:15:34 -04:00
TUniquePtr < FGeometryDynamicCollection > DynamicCollection ;
TArray < FManagedArrayBase * * > CopyOnWriteAttributeList ;
// Temporary dummies to interface with Physx expectations of the SQ syatem
friend class FGeometryCollectionSQAccelerator ;
FBodyInstance DummyBodyInstance ;
// Temporary storage for body setup in order to initialise a dummy body instance
2019-07-23 16:27:55 -04:00
UPROPERTY ( Transient )
2021-01-27 17:40:25 -04:00
TObjectPtr < UBodySetup > DummyBodySetup ;
2018-12-12 11:25:29 -05:00
# if WITH_EDITORONLY_DATA
// Tracked editor actor that owns the original component so we can write back recorded caches
// from PIE.
UPROPERTY ( Transient )
2021-01-27 17:40:25 -04:00
TObjectPtr < AActor > EditorActor ;
2018-12-12 11:25:29 -05:00
# endif
2019-06-08 17:15:34 -04:00
void SwitchRenderModels ( const AActor * Actor ) ;
2020-04-14 13:39:39 -04:00
UChaosGameplayEventDispatcher * EventDispatcher ;
2019-06-08 17:15:34 -04:00
# if GEOMETRYCOLLECTION_EDITOR_SELECTION
bool bIsTransformSelectionModeEnabled ;
# endif // #if GEOMETRYCOLLECTION_EDITOR_SELECTION
2021-02-18 13:20:03 -04:00
/** The information of all the embedded instanced static meshes */
UPROPERTY ( )
2021-07-20 00:24:38 -04:00
TArray < TObjectPtr < UInstancedStaticMeshComponent > > EmbeddedGeometryComponents ;
2021-02-18 13:20:03 -04:00
2021-09-05 20:37:59 -04:00
# if WITH_EDITORONLY_DATA
TArray < TArray < int32 > > EmbeddedBoneMaps ;
TArray < int32 > EmbeddedInstanceIndex ;
# endif
2021-02-18 13:20:03 -04:00
bool IsEmbeddedGeometryValid ( ) const ;
void ClearEmbeddedGeometry ( ) ;
2021-08-31 20:24:01 -04:00
void IncrementSleepTimer ( float DeltaTime ) ;
2021-09-15 17:18:16 -04:00
bool CalculateInnerSphere ( int32 TransformIndex , FSphere & SphereOut ) const ;
2022-04-25 13:09:18 -04:00
void ProcessRepData ( ) ;
2022-05-26 20:17:19 -04:00
void BuildInitialFilterData ( ) ;
2022-04-25 13:09:18 -04:00
/** The clusters we need to replicate */
TUniquePtr < TSet < Chaos : : FPBDRigidClusteredParticleHandle * > > ClustersToRep ;
/** One off activation is processed in the same order as server so remember the last one we processed */
int32 OneOffActivatedProcessed = 0 ;
int32 VersionProcessed = INDEX_NONE ;
2021-08-31 20:24:01 -04:00
2021-05-01 17:51:29 -04:00
/** True if GeometryCollection transforms have changed from previous tick. */
bool bIsMoving ;
2018-12-12 11:25:29 -05:00
} ;