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 "CoreMinimal.h"
# include "Misc/Crc.h"
2020-07-15 03:00:04 -04:00
# include "Rendering/NaniteResources.h"
2020-07-15 02:29:09 -04:00
# include "InstanceUniformShaderParameters.h"
2018-12-12 11:25:29 -05:00
# include "GeometryCollection/ManagedArray.h"
2022-11-09 20:53:21 -05:00
# include "GeometryCollection/GeometryCollectionDamagePropagationData.h"
2019-06-08 17:15:34 -04:00
# include "GeometryCollection/GeometryCollectionSimulationTypes.h"
2021-01-25 00:53:27 -04:00
# include "Chaos/ChaosSolverActor.h"
2021-02-18 13:20:03 -04:00
2018-12-12 11:25:29 -05:00
# include "GeometryCollectionObject.generated.h"
class UMaterialInterface ;
class UGeometryCollectionCache ;
class FGeometryCollection ;
2022-06-16 16:26:52 -04:00
struct FManagedArrayCollection ;
2018-12-12 11:25:29 -05:00
struct FGeometryCollectionSection ;
2019-06-08 17:15:34 -04:00
struct FSharedSimulationParameters ;
2022-05-26 19:00:40 -04:00
class UDataflow ;
2019-06-08 17:15:34 -04:00
2020-10-22 19:19:16 -04:00
USTRUCT ( BlueprintType )
struct GEOMETRYCOLLECTIONENGINE_API FGeometryCollectionSource
{
GENERATED_BODY ( )
2022-05-22 10:30:02 -04:00
UPROPERTY ( BlueprintReadWrite , EditAnywhere , Category = " GeometrySource " , meta = ( AllowedClasses = " /Script/Engine.StaticMesh, /Script/Engine.SkeletalMesh, /Script/GeometryCollectionEngine.GeometryCollection " ) )
2020-10-22 19:19:16 -04:00
FSoftObjectPath SourceGeometryObject ;
UPROPERTY ( BlueprintReadWrite , EditAnywhere , Category = " GeometrySource " )
FTransform LocalTransform ;
UPROPERTY ( BlueprintReadWrite , EditAnywhere , Category = " GeometrySource " )
2021-01-27 17:40:25 -04:00
TArray < TObjectPtr < UMaterialInterface > > SourceMaterial ;
2022-08-18 15:37:22 -04:00
/** Whether source materials should be duplicated to create slots for internal materials. Does not apply if the source is a GeometryCollection. */
UPROPERTY ( BlueprintReadWrite , EditAnywhere , Category = " GeometrySource " )
bool bAddInternalMaterials = true ;
2022-10-12 13:30:05 -04:00
/** Whether individual source mesh components should be split into separate pieces of geometry based on mesh connectivity. If checked, triangles that are not topologically connected will be assigned separate bones. */
2022-08-18 15:37:22 -04:00
UPROPERTY ( BlueprintReadWrite , EditAnywhere , Category = " GeometrySource " )
bool bSplitComponents = false ;
2022-10-21 19:51:57 -04:00
// TODO: add primtive custom data
} ;
USTRUCT ( BlueprintType )
struct GEOMETRYCOLLECTIONENGINE_API FGeometryCollectionAutoInstanceMesh
{
GENERATED_BODY ( )
UPROPERTY ( BlueprintReadWrite , EditAnywhere , Category = " AutoInstance " , meta = ( AllowedClasses = " /Script/Engine.StaticMesh " ) )
FSoftObjectPath StaticMesh ;
UPROPERTY ( BlueprintReadWrite , EditAnywhere , Category = " AutoInstance " )
TArray < TObjectPtr < UMaterialInterface > > Materials ;
2020-10-22 19:19:16 -04:00
} ;
2021-02-18 13:20:03 -04:00
USTRUCT ( BlueprintType )
struct GEOMETRYCOLLECTIONENGINE_API FGeometryCollectionEmbeddedExemplar
{
GENERATED_BODY ( )
2021-02-18 20:40:54 -04:00
FGeometryCollectionEmbeddedExemplar ( )
: StaticMeshExemplar ( FString ( TEXT ( " None " ) ) )
, StartCullDistance ( 0.0f )
, EndCullDistance ( 0.0f )
, InstanceCount ( 0 )
{ } ;
2021-02-18 13:20:03 -04:00
FGeometryCollectionEmbeddedExemplar ( FSoftObjectPath NewExemplar )
: StaticMeshExemplar ( NewExemplar )
, StartCullDistance ( 0.0f )
, EndCullDistance ( 0.0f )
, InstanceCount ( 0 )
{ }
2022-05-22 10:30:02 -04:00
UPROPERTY ( EditAnywhere , Category = " EmbeddedExemplar " , meta = ( AllowedClasses = " /Script/Engine.StaticMesh " ) )
2021-02-18 13:20:03 -04:00
FSoftObjectPath StaticMeshExemplar ;
UPROPERTY ( EditAnywhere , Category = " EmbeddedExemplar " )
float StartCullDistance ;
UPROPERTY ( EditAnywhere , Category = " EmbeddedExemplar " )
float EndCullDistance ;
UPROPERTY ( VisibleAnywhere , Category = " EmbeddedExemplar " )
int32 InstanceCount ;
} ;
2019-06-08 17:15:34 -04:00
USTRUCT ( )
2021-05-22 12:07:31 -04:00
struct GEOMETRYCOLLECTIONENGINE_API FGeometryCollectionLevelSetData
2019-06-08 17:15:34 -04:00
{
GENERATED_BODY ( )
2021-05-24 16:21:06 -04:00
FGeometryCollectionLevelSetData ( ) ;
2019-06-08 17:15:34 -04:00
2021-05-22 12:07:31 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 5 )
*/
UPROPERTY ( EditAnywhere , Category = " LevelSet " )
2021-05-24 16:21:06 -04:00
int32 MinLevelSetResolution ;
2021-05-22 12:07:31 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 10 )
*/
UPROPERTY ( EditAnywhere , Category = " LevelSet " )
2021-05-24 16:21:06 -04:00
int32 MaxLevelSetResolution ;
2021-05-22 12:07:31 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 5 )
*/
UPROPERTY ( EditAnywhere , Category = " LevelSet " )
2021-05-24 16:21:06 -04:00
int32 MinClusterLevelSetResolution ;
2021-05-22 12:07:31 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 10 )
*/
UPROPERTY ( EditAnywhere , Category = " LevelSet " )
2021-05-24 16:21:06 -04:00
int32 MaxClusterLevelSetResolution ;
2021-05-22 12:07:31 -04:00
} ;
USTRUCT ( )
struct GEOMETRYCOLLECTIONENGINE_API FGeometryCollectionCollisionParticleData
{
GENERATED_BODY ( )
2021-05-24 16:21:06 -04:00
FGeometryCollectionCollisionParticleData ( ) ;
2021-05-22 12:07:31 -04:00
/**
* Number of particles on the triangulated surface to use for collisions .
*/
UPROPERTY ( EditAnywhere , Category = " Particle " )
float CollisionParticlesFraction ;
/**
* Max number of particles .
*/
UPROPERTY ( EditAnywhere , Category = " Particle " )
int32 MaximumCollisionParticles ;
} ;
USTRUCT ( )
struct GEOMETRYCOLLECTIONENGINE_API FGeometryCollectionCollisionTypeData
{
GENERATED_BODY ( )
2021-05-24 16:21:06 -04:00
FGeometryCollectionCollisionTypeData ( ) ;
2019-06-08 17:15:34 -04:00
/*
* CollisionType defines how to initialize the rigid collision structures .
*/
2020-11-19 22:01:51 -04:00
UPROPERTY ( EditAnywhere , Category = " Collisions " )
2019-06-08 17:15:34 -04:00
ECollisionTypeEnum CollisionType ;
/*
* CollisionType defines how to initialize the rigid collision structures .
*/
2020-11-19 22:01:51 -04:00
UPROPERTY ( EditAnywhere , Category = " Collisions " )
2019-06-08 17:15:34 -04:00
EImplicitTypeEnum ImplicitType ;
/*
2021-05-22 12:07:31 -04:00
* LevelSet Resolution data for rasterization .
2019-06-08 17:15:34 -04:00
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( EditAnywhere , Category = " Collisions " , meta = ( EditCondition = " ImplicitType == EImplicitTypeEnum::Chaos_Implicit_LevelSet " , EditConditionHides ) )
FGeometryCollectionLevelSetData LevelSet ;
2019-06-08 17:15:34 -04:00
/*
2021-05-22 12:07:31 -04:00
* Collision Particle data for surface samples during Particle - LevelSet collisions .
2019-06-08 17:15:34 -04:00
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( EditAnywhere , Category = " Collisions " , meta = ( EditCondition = " CollisionType == ECollisionTypeEnum::Chaos_Surface_Volumetric " , EditConditionHides ) )
FGeometryCollectionCollisionParticleData CollisionParticles ;
2019-06-08 17:15:34 -04:00
/*
2021-05-22 12:07:31 -04:00
* Uniform scale on the collision body . ( def : 0 )
2019-06-08 17:15:34 -04:00
*/
2020-11-19 22:01:51 -04:00
UPROPERTY ( EditAnywhere , Category = " Collisions " )
2021-05-22 12:07:31 -04:00
float CollisionObjectReductionPercentage ;
2021-07-03 18:22:11 -04:00
/**
* A collision margin is a fraction of size used by some boxes and convex shapes to improve collision detection results .
* The core geometry of shapes that support a margin are reduced in size by the margin , and the margin
* is added back on during collision detection . The net result is a shape of the same size but with rounded corners .
*/
UPROPERTY ( EditAnywhere , Category = " Collisions " , meta = ( EditCondition = " ImplicitType == EImplicitTypeEnum::Chaos_Implicit_Convex || ImplicitType == EImplicitTypeEnum::Chaos_Implicit_Box " , EditConditionHides ) )
float CollisionMarginFraction ;
2021-05-22 12:07:31 -04:00
} ;
USTRUCT ( )
struct GEOMETRYCOLLECTIONENGINE_API FGeometryCollectionSizeSpecificData
{
GENERATED_BODY ( )
FGeometryCollectionSizeSpecificData ( ) ;
/** The max size these settings apply to*/
UPROPERTY ( EditAnywhere , Category = " Collisions " )
float MaxSize ;
2019-06-08 17:15:34 -04:00
/*
2021-05-22 12:07:31 -04:00
* Collision Shapes allow kfor multiple collision types per rigid body .
2019-06-08 17:15:34 -04:00
*/
2020-11-19 22:01:51 -04:00
UPROPERTY ( EditAnywhere , Category = " Collisions " )
2021-05-22 12:07:31 -04:00
TArray < FGeometryCollectionCollisionTypeData > CollisionShapes ;
# if WITH_EDITORONLY_DATA
/*
* CollisionType defines how to initialize the rigid collision structures .
*/
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use Collision.CollisionType instead. " ) )
ECollisionTypeEnum CollisionType_DEPRECATED ;
2019-06-08 17:15:34 -04:00
/*
2021-05-22 12:07:31 -04:00
* CollisionType defines how to initialize the rigid collision structures .
*/
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use Collision.ImplicitType instead. " ) )
EImplicitTypeEnum ImplicitType_DEPRECATED ;
/*
* Resolution on the smallest axes for the level set . ( def : 5 )
*/
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use Collision.LevelSet.MinLevelSetResolution instead. " ) )
int32 MinLevelSetResolution_DEPRECATED ;
/*
* Resolution on the smallest axes for the level set . ( def : 10 )
*/
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use Collision.LevelSet.MaxLevelSetResolution instead. " ) )
2021-05-24 16:21:06 -04:00
int32 MaxLevelSetResolution_DEPRECATED ;
2021-05-22 12:07:31 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 5 )
*/
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use Collision.LevelSet.MinClusterLevelSetResolution instead. " ) )
int32 MinClusterLevelSetResolution_DEPRECATED ;
/*
* Resolution on the smallest axes for the level set . ( def : 10 )
*/
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use Collision.LevelSet.MaxClusterLevelSetResolution instead. " ) )
int32 MaxClusterLevelSetResolution_DEPRECATED ;
/*
* Resolution on the smallest axes for the level set . ( def : 10 )
*/
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use Collision.CollisionObjectReductionPercentage instead. " ) )
int32 CollisionObjectReductionPercentage_DEPRECATED ;
2019-06-08 17:15:34 -04:00
/**
* Number of particles on the triangulated surface to use for collisions .
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use Collision.CollisionParticlesFraction instead. " ) )
float CollisionParticlesFraction_DEPRECATED ;
/**
* Max number of particles .
*/
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use Collision.MaximumCollisionParticles instead. " ) )
int32 MaximumCollisionParticles_DEPRECATED ;
# endif
2019-08-15 21:16:13 -04:00
/**
* Max number of particles .
*/
2020-11-19 22:01:51 -04:00
UPROPERTY ( EditAnywhere , Category = " Collisions " )
2021-01-29 00:35:21 -04:00
int32 DamageThreshold ;
2021-05-22 12:07:31 -04:00
bool Serialize ( FArchive & Ar ) ;
# if WITH_EDITORONLY_DATA
void PostSerialize ( const FArchive & Ar ) ;
# endif
} ;
template < >
struct TStructOpsTypeTraits < FGeometryCollectionSizeSpecificData > : public TStructOpsTypeTraitsBase2 < FGeometryCollectionSizeSpecificData >
{
enum
{
WithSerializer = true ,
# if WITH_EDITORONLY_DATA
WithPostSerialize = true
# endif
} ;
2019-06-08 17:15:34 -04:00
} ;
2018-12-12 11:25:29 -05:00
2020-09-01 12:46:08 -04:00
class FGeometryCollectionNaniteData
{
public :
GEOMETRYCOLLECTIONENGINE_API FGeometryCollectionNaniteData ( ) ;
GEOMETRYCOLLECTIONENGINE_API ~ FGeometryCollectionNaniteData ( ) ;
FORCEINLINE bool IsInitialized ( )
{
return bIsInitialized ;
}
/** Serialization. */
void Serialize ( FArchive & Ar , UGeometryCollection * Owner ) ;
/** Initialize the render resources. */
void InitResources ( UGeometryCollection * Owner ) ;
/** Releases the render resources. */
GEOMETRYCOLLECTIONENGINE_API void ReleaseResources ( ) ;
2020-12-01 11:18:19 -04:00
Nanite : : FResources NaniteResource ;
2020-09-01 12:46:08 -04:00
private :
bool bIsInitialized = false ;
} ;
2022-08-23 17:17:36 -04:00
2018-12-12 11:25:29 -05:00
/**
* UGeometryCollectionObject ( UObject )
*
* UObject wrapper for the FGeometryCollection
*
*/
2020-10-22 19:19:16 -04:00
UCLASS ( BlueprintType , customconstructor )
2018-12-12 11:25:29 -05:00
class GEOMETRYCOLLECTIONENGINE_API UGeometryCollection : public UObject
{
GENERATED_UCLASS_BODY ( )
public :
UGeometryCollection ( const FObjectInitializer & ObjectInitializer = FObjectInitializer : : Get ( ) ) ;
/** UObject Interface */
# if WITH_EDITOR
virtual void PostEditChangeProperty ( struct FPropertyChangedEvent & PropertyChangedEvent ) override ;
virtual bool Modify ( bool bAlwaysMarkDirty = true ) override ;
2019-08-27 17:20:03 -04:00
# endif
2022-11-08 04:24:06 -05:00
virtual void PostInitProperties ( ) override ;
2020-07-15 01:49:28 -04:00
virtual void PostLoad ( ) override ;
virtual void BeginDestroy ( ) override ;
2018-12-12 11:25:29 -05:00
/** End UObject Interface */
void Serialize ( FArchive & Ar ) ;
2022-04-28 20:20:32 -04:00
# if WITH_EDITORONLY_DATA
void PostSerialize ( const FArchive & Ar ) ;
# endif
2018-12-12 11:25:29 -05:00
2019-06-08 17:15:34 -04:00
# if WITH_EDITOR
2022-07-08 10:54:36 -04:00
void EnsureDataIsCooked ( bool bInitResources = true , bool bIsTransacting = false ) ;
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
/** Accessors for internal geometry collection */
void SetGeometryCollection ( TSharedPtr < FGeometryCollection , ESPMode : : ThreadSafe > GeometryCollectionIn ) { GeometryCollection = GeometryCollectionIn ; }
TSharedPtr < FGeometryCollection , ESPMode : : ThreadSafe > GetGeometryCollection ( ) { return GeometryCollection ; }
const TSharedPtr < FGeometryCollection , ESPMode : : ThreadSafe > GetGeometryCollection ( ) const { return GeometryCollection ; }
2020-10-22 19:19:16 -04:00
/** Return collection to initial (ie. empty) state. */
void Reset ( ) ;
2022-10-26 19:04:47 -04:00
/** Reset the collection from another set of attributes and materials. */
void ResetFrom ( const FManagedArrayCollection & InCollection , const TArray < UMaterial * > & InMaterials ) ;
2020-10-22 19:19:16 -04:00
2019-06-08 17:15:34 -04:00
int32 AppendGeometry ( const UGeometryCollection & Element , bool ReindexAllMaterials = false , const FTransform & TransformRoot = FTransform : : Identity ) ;
2020-07-15 01:49:28 -04:00
int32 NumElements ( const FName & Group ) const ;
void RemoveElements ( const FName & Group , const TArray < int32 > & SortedDeletionList ) ;
2021-06-07 23:55:28 -04:00
FORCEINLINE bool HasNaniteData ( ) const
{
return NaniteData ! = nullptr ;
}
FORCEINLINE uint32 GetNaniteResourceID ( ) const
{
Nanite : : FResources & Resource = NaniteData - > NaniteResource ;
return Resource . RuntimeResourceID ;
}
FORCEINLINE uint32 GetNaniteHierarchyOffset ( ) const
{
Nanite : : FResources & Resource = NaniteData - > NaniteResource ;
return Resource . HierarchyOffset ;
}
FORCEINLINE uint32 GetNaniteHierarchyOffset ( int32 GeometryIndex , bool bFlattened = false ) const
2020-07-15 01:49:28 -04:00
{
2020-12-01 11:18:19 -04:00
Nanite : : FResources & Resource = NaniteData - > NaniteResource ;
check ( GeometryIndex > = 0 & & GeometryIndex < Resource . HierarchyRootOffsets . Num ( ) ) ;
2021-06-07 23:55:28 -04:00
uint32 HierarchyOffset = Resource . HierarchyRootOffsets [ GeometryIndex ] ;
if ( bFlattened )
{
HierarchyOffset + = Resource . HierarchyOffset ;
}
return HierarchyOffset ;
2020-07-15 01:49:28 -04:00
}
2018-12-12 11:25:29 -05:00
/** ReindexMaterialSections */
void ReindexMaterialSections ( ) ;
2021-06-07 23:55:28 -04:00
/** appends the standard materials to this UObject */
2019-06-08 17:15:34 -04:00
void InitializeMaterials ( ) ;
2018-12-12 11:25:29 -05:00
2021-02-09 20:08:13 -04:00
2018-12-12 11:25:29 -05:00
/** Returns true if there is anything to render */
2019-06-08 17:15:34 -04:00
bool HasVisibleGeometry ( ) const ;
2018-12-12 11:25:29 -05:00
/** Invalidates this collection signaling a structural change and renders any previously recorded caches unable to play with this collection */
void InvalidateCollection ( ) ;
2020-11-19 22:01:51 -04:00
/** Check to see if Simulation Data requires regeneration */
bool IsSimulationDataDirty ( ) const ;
2021-02-18 13:20:03 -04:00
/** Attach a Static Mesh exemplar for embedded geometry, if that mesh has not already been attached. Return the exemplar index. */
int32 AttachEmbeddedGeometryExemplar ( const UStaticMesh * Exemplar ) ;
/** Remove embedded geometry exemplars with indices matching the sorted removal list. */
void RemoveExemplars ( const TArray < int32 > & SortedRemovalIndices ) ;
2022-10-21 19:51:57 -04:00
/** find or add a auto instance mesh and return its index */
const FGeometryCollectionAutoInstanceMesh & GetAutoInstanceMesh ( int32 AutoInstanceMeshIndex ) const ;
/** find or add a auto instance mesh from another one and return its index */
int32 FindOrAddAutoInstanceMesh ( const FGeometryCollectionAutoInstanceMesh & AutoInstanecMesh ) ;
/** find or add a auto instance mesh from a mesh and alist of material and return its index */
int32 FindOrAddAutoInstanceMesh ( const UStaticMesh & StaticMesh , const TArray < UMaterialInterface * > & Materials ) ;
2021-04-20 09:50:07 -04:00
/** Produce a deep copy of GeometryCollection member, stripped of data unecessary for gameplay. */
TSharedPtr < FGeometryCollection , ESPMode : : ThreadSafe > GenerateMinimalGeometryCollection ( ) const ;
2022-11-08 04:24:06 -05:00
/** copy a collection and remove geometry from it */
static TSharedPtr < FGeometryCollection , ESPMode : : ThreadSafe > CopyCollectionAndRemoveGeometry ( const TSharedPtr < const FGeometryCollection , ESPMode : : ThreadSafe > & CollectionToCopy ) ;
2020-11-19 22:01:51 -04:00
# if WITH_EDITOR
/** If this flag is set, we only regenerate simulation data when requested via CreateSimulationData() */
bool bManualDataCreate ;
2019-06-08 17:15:34 -04:00
/** Create the simulation data that can be shared among all instances (mass, volume, etc...)*/
void CreateSimulationData ( ) ;
2020-07-15 01:49:28 -04:00
/** Create the Nanite rendering data. */
2020-09-01 12:46:08 -04:00
static TUniquePtr < FGeometryCollectionNaniteData > CreateNaniteData ( FGeometryCollection * Collection ) ;
2019-06-08 17:15:34 -04:00
# endif
2020-07-15 01:49:28 -04:00
void InitResources ( ) ;
void ReleaseResources ( ) ;
2019-06-08 17:15:34 -04:00
/** Fills params struct with parameters used for precomputing content. */
void GetSharedSimulationParams ( FSharedSimulationParameters & OutParams ) const ;
2018-12-12 11:25:29 -05:00
/** Accessors for the two guids used to identify this collection */
FGuid GetIdGuid ( ) const ;
FGuid GetStateGuid ( ) const ;
2020-09-01 12:46:08 -04:00
/** Pointer to the data used to render this geometry collection with Nanite. */
TUniquePtr < class FGeometryCollectionNaniteData > NaniteData ;
2021-02-03 14:57:28 -04:00
2021-01-25 00:53:27 -04:00
UPROPERTY ( EditAnywhere , Category = " Clustering " )
bool EnableClustering ;
/** Maximum level for cluster breaks. */
UPROPERTY ( EditAnywhere , Category = " Clustering " )
int32 ClusterGroupIndex ;
/** Maximum level for cluster breaks. */
UPROPERTY ( EditAnywhere , Category = " Clustering " )
int32 MaxClusterLevel ;
/** Damage threshold for clusters at different levels. */
2022-09-16 21:25:31 -04:00
UPROPERTY ( EditAnywhere , Category = " Damage " , meta = ( EditCondition = " !bUseSizeSpecificDamageThreshold " ) )
2022-02-09 19:28:14 -05:00
TArray < float > DamageThreshold ;
2021-01-25 00:53:27 -04:00
2022-09-16 21:25:31 -04:00
/** whether to use size specific damage threshold instead of level based ones ( see Size Specific Data array ). */
UPROPERTY ( EditAnywhere , Category = " Damage " )
bool bUseSizeSpecificDamageThreshold ;
2022-04-28 20:20:32 -04:00
/** compatibility check, when true, only cluster compute damage from parameters and propagate to direct children
* when false , each child will compute it ' s damage threshold allowing for more precise and intuitive destruction behavior
*/
2022-09-15 15:14:33 -04:00
UPROPERTY ( EditAnywhere , Category = " Compatibility " )
2022-04-28 20:20:32 -04:00
bool PerClusterOnlyDamageThreshold ;
2022-08-23 17:17:36 -04:00
/** Data about how damage propagation shoudl behave. */
UPROPERTY ( EditAnywhere , Category = " Damage " )
FGeometryCollectionDamagePropagationData DamagePropagationData ;
2021-01-25 00:53:27 -04:00
/** */
UPROPERTY ( EditAnywhere , Category = " Clustering " )
EClusterConnectionTypeEnum ClusterConnectionType ;
2022-05-20 15:20:13 -04:00
UPROPERTY ( EditAnywhere , Category = " Clustering " )
float ConnectionGraphBoundsFilteringMargin ;
2021-05-10 23:54:01 -04:00
# if WITH_EDITORONLY_DATA
2020-10-22 19:19:16 -04:00
UPROPERTY ( BlueprintReadWrite , EditAnywhere , Category = " GeometrySource " )
TArray < FGeometryCollectionSource > GeometrySource ;
2021-05-10 23:54:01 -04:00
# endif
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = " Materials " )
2021-01-27 17:40:25 -04:00
TArray < TObjectPtr < UMaterialInterface > > Materials ;
2018-12-12 11:25:29 -05:00
2021-02-18 13:20:03 -04:00
/** References for embedded geometry generation */
UPROPERTY ( EditAnywhere , Category = " EmbeddedGeometry " )
TArray < FGeometryCollectionEmbeddedExemplar > EmbeddedGeometryExemplar ;
2021-06-01 14:20:47 -04:00
/** Whether to use full precision UVs when rendering this geometry. (Does not apply to Nanite rendering) */
UPROPERTY ( EditAnywhere , Category = " Rendering " )
bool bUseFullPrecisionUVs = false ;
2022-10-21 19:51:57 -04:00
/** list of unique static mesh / materials pairs for auto instancing*/
UPROPERTY ( EditAnywhere , Category = " Rendering " )
TArray < FGeometryCollectionAutoInstanceMesh > AutoInstanceMeshes ;
/** static mesh to use as a proxy for rendering until the geometry collection is broken */
UPROPERTY ( BlueprintReadWrite , EditAnywhere , Category = " Rendering " , meta = ( AllowedClasses = " /Script/Engine.StaticMesh " ) )
FSoftObjectPath RootProxy ;
2020-07-15 01:49:28 -04:00
/**
2021-06-01 14:20:47 -04:00
* Strip unnecessary data from the Geometry Collection to keep the memory footprint as small as possible .
*/
2021-04-20 09:50:07 -04:00
UPROPERTY ( EditAnywhere , Category = " Nanite " )
bool bStripOnCook ;
2021-06-01 14:20:47 -04:00
/**
* Enable support for Nanite .
*/
2020-07-15 01:49:28 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " Nanite " )
bool EnableNanite ;
2021-05-22 12:07:31 -04:00
# if WITH_EDITORONLY_DATA
2019-06-08 17:15:34 -04:00
/*
* CollisionType defines how to initialize the rigid collision structures .
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " This property is deprecated. Use the default SizeSpecificData instead. " ) )
ECollisionTypeEnum CollisionType_DEPRECATED ;
2018-12-12 11:25:29 -05:00
2019-06-08 17:15:34 -04:00
/*
* CollisionType defines how to initialize the rigid collision structures .
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " This property is deprecated. Use the default SizeSpecificData instead. " ) )
EImplicitTypeEnum ImplicitType_DEPRECATED ;
2019-06-08 17:15:34 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 5 )
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " This property is deprecated. Use the default SizeSpecificData instead. " ) )
int32 MinLevelSetResolution_DEPRECATED ;
2019-06-08 17:15:34 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 10 )
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " This property is deprecated. Use the default SizeSpecificData instead. " ) )
int32 MaxLevelSetResolution_DEPRECATED ;
2019-06-08 17:15:34 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 5 )
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " This property is deprecated. Use the default SizeSpecificData instead. " ) )
int32 MinClusterLevelSetResolution_DEPRECATED ;
2019-06-08 17:15:34 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 10 )
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " This property is deprecated. Use the default SizeSpecificData instead. " ) )
int32 MaxClusterLevelSetResolution_DEPRECATED ;
2019-06-08 17:15:34 -04:00
/*
* Resolution on the smallest axes for the level set . ( def : 10 )
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " This property is deprecated. Use the default SizeSpecificData instead. " ) )
float CollisionObjectReductionPercentage_DEPRECATED ;
# endif
2019-06-08 17:15:34 -04:00
/**
* Mass As Density , units are in kg / m ^ 3
*/
2020-11-19 22:01:51 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " Collisions " )
2019-06-08 17:15:34 -04:00
bool bMassAsDensity ;
/**
* Total Mass of Collection . If density , units are in kg / m ^ 3
*/
2020-11-19 22:01:51 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " Collisions " )
2019-06-08 17:15:34 -04:00
float Mass ;
/**
* Smallest allowable mass ( def : 0.1 )
*/
2020-11-19 22:01:51 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " Collisions " )
2019-06-08 17:15:34 -04:00
float MinimumMassClamp ;
2022-05-26 12:02:54 -04:00
/**
* whether to import collision from the source asset
*/
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = " Collisions " )
bool bImportCollisionFromSource ;
2021-05-22 12:07:31 -04:00
# if WITH_EDITORONLY_DATA
2019-06-08 17:15:34 -04:00
/**
* Number of particles on the triangulated surface to use for collisions .
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " This property is deprecated. Use the default SizeSpecificData instead. " ) )
float CollisionParticlesFraction_DEPRECATED ;
2019-06-08 17:15:34 -04:00
2019-08-15 21:16:13 -04:00
/**
* Max number of particles .
*/
2021-05-22 12:07:31 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " This property is deprecated. Use the default SizeSpecificData instead. " ) )
int32 MaximumCollisionParticles_DEPRECATED ;
# endif
2019-08-15 21:16:13 -04:00
2021-08-31 20:23:44 -04:00
/** Remove particle from simulation and dissolve rendered geometry once sleep threshold has been exceeded. */
2022-06-14 11:45:26 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = Removal , meta = ( DisplayName = " Remove on Sleep " ) )
2021-08-31 20:23:44 -04:00
bool bRemoveOnMaxSleep ;
/** How long may the particle sleep before initiating removal (in seconds). */
2022-06-14 11:45:26 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = Removal , meta = ( DisplayName = " Sleep Min Max " , EditCondition = " bRemoveOnMaxSleep " ) )
2021-09-15 17:17:24 -04:00
FVector2D MaximumSleepTime ;
2021-08-31 20:23:44 -04:00
/** How long does the removal process take (in seconds). */
2022-06-14 11:45:26 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = Removal , meta = ( DisplayName = " Removal Duration " , EditCondition = " bRemoveOnMaxSleep " ) )
2021-09-15 17:17:24 -04:00
FVector2D RemovalDuration ;
2021-08-31 20:23:44 -04:00
2022-06-17 11:29:46 -04:00
/** when on non-sleeping, slow moving pieces will be considered as sleeping, this helps removal of jittery but not really moving objects. */
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = Removal , meta = ( DisplayName = " Slow-Moving as sleeping " , EditCondition = " bRemoveOnMaxSleep " ) )
2022-06-14 11:45:26 -04:00
bool bSlowMovingAsSleeping ;
/** When slow moving detection is on, this defines the linear velocity thresholds in cm/s to consider the object as sleeping . */
2022-06-17 11:29:46 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = Removal , meta = ( DisplayName = " Slow-Moving Velocity Threshold " , EditCondition = " bRemoveOnMaxSleep && bSlowMovingAsSleeping " ) )
2022-06-14 11:45:26 -04:00
float SlowMovingVelocityThreshold ;
2021-05-22 12:07:31 -04:00
/*
* Size Specfic Data reflects the default geometry to bind to rigid bodies smaller
* than the max size volume . This can also be empty to reflect no collision geometry
* for the collection .
*/
2020-11-19 22:01:51 -04:00
UPROPERTY ( EditAnywhere , Category = " Collisions " )
2019-06-08 17:15:34 -04:00
TArray < FGeometryCollectionSizeSpecificData > SizeSpecificData ;
2020-07-15 01:49:28 -04:00
2021-05-22 12:07:31 -04:00
int GetDefaultSizeSpecificDataIndex ( ) const ;
FGeometryCollectionSizeSpecificData & GetDefaultSizeSpecificData ( ) ;
const FGeometryCollectionSizeSpecificData & GetDefaultSizeSpecificData ( ) const ;
2021-05-25 17:13:53 -04:00
static FGeometryCollectionSizeSpecificData GeometryCollectionSizeSpecificDataDefaults ( ) ;
2021-05-22 12:07:31 -04:00
2019-06-08 17:15:34 -04:00
/**
* Enable remove pieces on fracture
*/
2022-09-15 15:14:33 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use remove on break feature instead ( Fracture editor tools ). " ) )
bool EnableRemovePiecesOnFracture_DEPRECATED ;
2019-06-08 17:15:34 -04:00
/**
* Materials relating to remove on fracture
*/
2022-09-15 15:14:33 -04:00
UPROPERTY ( meta = ( DeprecatedProperty , DeprecationMessage = " Use remove on break feature instead ( Fracture editor tools ). " ) )
TArray < TObjectPtr < UMaterialInterface > > RemoveOnFractureMaterials_DEPRECATED ;
2019-06-08 17:15:34 -04:00
2020-07-15 01:49:28 -04:00
FORCEINLINE const int32 GetBoneSelectedMaterialIndex ( ) const { return BoneSelectedMaterialIndex ; }
2019-06-08 17:15:34 -04:00
2020-07-22 13:12:31 -04:00
/** Returns the asset path for the automatically populated selected material. */
2021-02-09 20:08:13 -04:00
static const TCHAR * GetSelectedMaterialPath ( ) ;
2020-07-22 13:12:31 -04:00
2019-06-08 17:15:34 -04:00
# if WITH_EDITORONLY_DATA
2022-11-08 04:24:06 -05:00
/** Importing data and options used for this geometry collection */
UPROPERTY ( EditAnywhere , Instanced , Category = ImportSettings )
TObjectPtr < class UAssetImportData > AssetImportData ;
2019-06-08 17:15:34 -04:00
/** Information for thumbnail rendering */
UPROPERTY ( VisibleAnywhere , Instanced , AdvancedDisplay , Category = GeometryCollection )
2021-01-27 17:40:25 -04:00
TObjectPtr < class UThumbnailInfo > ThumbnailInfo ;
2019-06-08 17:15:34 -04:00
# endif // WITH_EDITORONLY_DATA
2022-01-31 12:57:29 -05:00
/*
* Update the convex geometry on the collection .
*/
void UpdateConvexGeometry ( ) ;
2022-10-24 16:24:39 -04:00
/*
* Update properties that depend on the geometry and clustering : Proximity , Convex Hulls , Volume and Size data .
*/
void UpdateGeometryDependentProperties ( ) ;
2022-01-31 12:57:29 -05:00
2022-05-26 19:00:40 -04:00
//
// Dataflow
//
2022-11-08 04:24:06 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " Dataflow " )
2022-11-09 02:18:51 -05:00
TObjectPtr < UDataflow > DataflowAsset ;
2022-05-26 19:00:40 -04:00
2022-10-19 01:58:50 -04:00
UPROPERTY ( EditAnywhere , Category = " Dataflow " )
2022-11-09 02:18:51 -05:00
FString DataflowTerminal = " GeometryCollectionTerminal " ;
2022-10-19 01:58:50 -04:00
2019-06-08 17:15:34 -04:00
private :
# if WITH_EDITOR
2020-09-01 12:46:08 -04:00
void CreateSimulationDataImp ( bool bCopyFromDDC ) ;
2019-06-08 17:15:34 -04:00
# endif
2018-12-12 11:25:29 -05:00
2021-05-25 17:13:53 -04:00
/*
2021-05-26 17:46:30 -04:00
* Used to transfer deprecated properties to the size specific structures during serialization
2022-01-31 12:57:29 -05:00
* and to add back the default size specific data when deleted .
2021-05-25 17:13:53 -04:00
*/
2021-05-26 17:46:30 -04:00
void ValidateSizeSpecificDataDefaults ( ) ;
2021-05-25 17:13:53 -04:00
2018-12-12 11:25:29 -05:00
private :
/** Guid created on construction of this collection. It should be used to uniquely identify this collection */
UPROPERTY ( )
FGuid PersistentGuid ;
/**
* Guid that can be invalidated on demand - essentially a ' version ' that should be changed when a structural change is made to
* the geometry collection . This signals to any caches that attempt to link to a geometry collection whether the collection
* is still valid ( hasn ' t structurally changed post - recording )
*/
UPROPERTY ( )
FGuid StateGuid ;
2019-06-08 17:15:34 -04:00
# if WITH_EDITOR
//Used to determine whether we need to cook content
FGuid LastBuiltGuid ;
2020-11-19 22:01:51 -04:00
//Used to determine whether we need to regenerate simulation data
FGuid SimulationDataGuid ;
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
// #todo(dmp): rename to be consistent BoneSelectedMaterialID?
2018-12-12 11:25:29 -05:00
UPROPERTY ( )
int32 BoneSelectedMaterialIndex ;
2019-06-08 17:15:34 -04:00
TSharedPtr < FGeometryCollection , ESPMode : : ThreadSafe > GeometryCollection ;
2018-12-12 11:25:29 -05:00
} ;