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"
2021-04-29 19:32:06 -04:00
# include "GeometryCollection/GeometryCollectionParticlesData.h"
2018-12-12 11:25:29 -05:00
# include "GeometryCollectionDebugDrawComponent.generated.h"
2019-06-08 17:15:34 -04:00
2018-12-12 11:25:29 -05:00
class AGeometryCollectionRenderLevelSetActor ;
class UGeometryCollectionComponent ;
class AGeometryCollectionDebugDrawActor ;
2019-06-26 13:41:32 -04:00
class AChaosSolverActor ;
2018-12-12 11:25:29 -05:00
2019-10-02 17:27:26 -04:00
# if GEOMETRYCOLLECTION_DEBUG_DRAW
2019-10-31 17:28:08 -04:00
namespace Chaos { class FImplicitObject ; }
2019-06-08 17:15:34 -04:00
namespace Chaos { template < class T , int d > class TPBDRigidParticles ; }
2019-10-02 17:27:26 -04:00
# endif // #if GEOMETRYCOLLECTION_DEBUG_DRAW
2019-06-08 17:15:34 -04:00
2019-07-22 08:16:50 -04:00
/**
* UGeometryCollectionDebugDrawComponent
* Component adding debug drawing functionality to a GeometryCollectionActor .
* This component is automatically added to every GeometryCollectionActor .
*/
2019-06-08 17:15:34 -04:00
UCLASS ( meta = ( BlueprintSpawnableComponent ) , HideCategories = ( " Tags " , " Activation " , " Cooking " , " AssetUserData " , " Collision " ) )
class GEOMETRYCOLLECTIONENGINE_API UGeometryCollectionDebugDrawComponent : public UActorComponent
2018-12-12 11:25:29 -05:00
{
GENERATED_UCLASS_BODY ( )
public :
2019-08-07 14:56:14 -04:00
/** Singleton actor, containing the debug draw properties. Automatically populated at play time unless explicitly set. */
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = " Debug Draw " , AdvancedDisplay )
2021-01-27 17:40:25 -04:00
TObjectPtr < AGeometryCollectionDebugDrawActor > GeometryCollectionDebugDrawActor ;
2018-12-12 11:25:29 -05:00
2019-08-07 14:56:14 -04:00
/** Level Set singleton actor, containing the Render properties. Automatically populated at play time unless explicitly set. */
2019-06-08 17:15:34 -04:00
UPROPERTY ( EditAnywhere , Category = " Debug Draw " , AdvancedDisplay )
2021-01-27 17:40:25 -04:00
TObjectPtr < AGeometryCollectionRenderLevelSetActor > GeometryCollectionRenderLevelSetActor ;
2018-12-12 11:25:29 -05:00
UGeometryCollectionComponent * GeometryCollectionComponent ; // the component we are debug rendering for, set by the GeometryCollectionActor after creation
virtual void BeginPlay ( ) override ;
virtual void EndPlay ( EEndPlayReason : : Type ReasonEnd ) override ;
virtual void TickComponent ( float DeltaTime , enum ELevelTick TickType , FActorComponentTickFunction * ThisTickFunction ) override ;
2019-06-08 17:15:34 -04:00
# if GEOMETRYCOLLECTION_DEBUG_DRAW
2019-06-17 14:53:58 -04:00
/** Update selection and visibility after any change in properties. Also enable/disable this component tick update. Return true if this geometry collection is selected. */
bool OnDebugDrawPropertiesChanged ( bool bForceVisibilityUpdate ) ;
2018-12-12 11:25:29 -05:00
2019-06-08 17:15:34 -04:00
/** Update selection and visibility after a change in cluster. Only handled when the debug drawing is active (the component is ticking). */
void OnClusterChanged ( ) ;
2019-06-27 13:29:26 -04:00
/** Return whether the geometry collection rigid body id array is not completely initialized. This can happen when running the physics multithreaded. */
FORCEINLINE bool HasIncompleteRigidBodyIdSync ( ) const { return bHasIncompleteRigidBodyIdSync ; }
2019-06-08 17:15:34 -04:00
private :
/** Recursively compute global cluster transforms. Only gives geometry transforms for the leaf nodes, mid-level transforms are those of the clusters. */
void ComputeClusterTransforms ( int32 Index , TArray < bool > & IsComputed , TArray < FTransform > & InOutGlobalTransforms ) ;
/**
* Compute global transforms .
* Unlike GeometryCollectionAlgo : : GlobalMatrices ( ) , this also calculates the correct mid - level geometry transforms and includes the actor transform .
*/
void ComputeTransforms ( TArray < FTransform > & OutClusterTransforms , TArray < FTransform > & OutGeometryTransforms ) ;
/** Geometry collection debug draw. */
2018-12-12 11:25:29 -05:00
void DebugDrawTick ( ) ;
2019-06-08 17:15:34 -04:00
/** Update the transform index dependending on the current filter settings. */
void UpdateSelectedTransformIndex ( ) ;
/** Return the number of faces for the given geometry (includes its children, and includes its detached children when bDebugDrawClustering is true). */
int32 CountFaces ( int32 TransformIndex , bool bDebugDrawClustering ) const ;
/** Update visible array to hide the selected geometry and its children, and includes its detached children when bDebugDrawClustering is true)*/
void HideFaces ( int32 TransformIndex , bool bDebugDrawClustering ) ;
/** Update geometry visibility. Set bForceVisibilityUpdate to true to force the visibility array update. */
void UpdateGeometryVisibility ( bool bForceVisibilityUpdate = false ) ;
/** Update ticking status. */
void UpdateTickStatus ( ) ;
/** Chaos dependent debug draw. */
void DebugDrawChaosTick ( ) ;
/** Update level set visibility. */
void UpdateLevelSetVisibility ( ) ;
# endif // #if GEOMETRYCOLLECTION_DEBUG_DRAW
2018-12-12 11:25:29 -05:00
private :
2019-06-08 17:15:34 -04:00
static UGeometryCollectionDebugDrawComponent * RenderLevelSetOwner ;
static int32 LastRenderedId ;
2019-11-08 19:47:41 -05:00
//static FGuid LastRenderedId;
2019-06-08 17:15:34 -04:00
# if GEOMETRYCOLLECTION_DEBUG_DRAW
FGeometryCollectionParticlesData ParticlesData ;
int32 ParentCheckSum ;
int32 SelectedRigidBodyId ;
2019-11-08 19:47:41 -05:00
//FGuid SelectedRigidBodyId;
2019-06-08 17:15:34 -04:00
int32 SelectedTransformIndex ;
int32 HiddenTransformIndex ;
2019-07-16 12:13:20 -04:00
bool bWasVisible ;
2019-06-27 13:29:26 -04:00
bool bHasIncompleteRigidBodyIdSync ;
2019-06-26 13:41:32 -04:00
AChaosSolverActor * SelectedChaosSolver ;
2019-06-08 17:15:34 -04:00
# endif // #if GEOMETRYCOLLECTION_DEBUG_DRAW
2018-12-12 11:25:29 -05:00
} ;