2023-03-31 02:58:27 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "GeometryCollection/GeometryCollectionExternalRenderInterface.h"
|
|
|
|
|
|
|
|
|
|
#include "GeometryCollectionISMPoolRenderer.generated.h"
|
|
|
|
|
|
|
|
|
|
class AGeometryCollectionISMPoolActor;
|
2023-04-04 19:18:34 -04:00
|
|
|
class UGeometryCollectionISMPoolComponent;
|
2023-03-31 02:58:27 -04:00
|
|
|
|
2023-04-03 10:06:24 -04:00
|
|
|
/** Implementation of a geometry collection custom renderer that pushes AutoInstanceMeshes to an ISMPool. */
|
2023-03-31 02:58:27 -04:00
|
|
|
UCLASS()
|
2023-04-03 10:06:24 -04:00
|
|
|
class UGeometryCollectionISMPoolRenderer : public UObject, public IGeometryCollectionExternalRenderInterface
|
2023-03-31 02:58:27 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
//~ Begin IGeometryCollectionExternalRenderInterface Interface.
|
2023-04-03 10:06:24 -04:00
|
|
|
virtual void OnRegisterGeometryCollection(UGeometryCollectionComponent const& InComponent) override;
|
|
|
|
|
virtual void OnUnregisterGeometryCollection() override;
|
2023-04-25 13:27:53 -04:00
|
|
|
virtual void UpdateState(UGeometryCollection const& InGeometryCollection, FTransform const& InComponentTransform, bool bInIsBroken, bool bInIsVisible) override;
|
2023-04-06 17:29:18 -04:00
|
|
|
virtual void UpdateRootTransform(UGeometryCollection const& InGeometryCollection, FTransform const& InRootTransform) override;
|
2023-05-11 19:37:23 -04:00
|
|
|
virtual void UpdateTransforms(UGeometryCollection const& InGeometryCollection, TArrayView<const FTransform> InTransforms) override;
|
2023-03-31 02:58:27 -04:00
|
|
|
//~ End IGeometryCollectionExternalRenderInterface Interface.
|
|
|
|
|
|
|
|
|
|
/** Description for a group of meshes that are added/updated together. */
|
|
|
|
|
struct FISMPoolGroup
|
|
|
|
|
{
|
|
|
|
|
int32 GroupIndex = INDEX_NONE;
|
|
|
|
|
TArray<int32> MeshIds;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected:
|
2023-04-04 19:18:34 -04:00
|
|
|
/** Instanced Static Mesh Pool actor that is used to render our meshes. */
|
|
|
|
|
UPROPERTY(Transient)
|
|
|
|
|
TObjectPtr<AGeometryCollectionISMPoolActor> ISMPoolActor;
|
|
|
|
|
|
2023-04-06 17:29:18 -04:00
|
|
|
/** Cached component transform. */
|
|
|
|
|
FTransform ComponentTransform = FTransform::Identity;
|
|
|
|
|
|
2023-03-31 02:58:27 -04:00
|
|
|
/** ISM pool groups per rendering element type. */
|
|
|
|
|
FISMPoolGroup MergedMeshGroup;
|
|
|
|
|
FISMPoolGroup InstancesGroup;
|
|
|
|
|
|
|
|
|
|
private:
|
2023-04-04 19:18:34 -04:00
|
|
|
UGeometryCollectionISMPoolComponent* GetOrCreateISMPoolComponent();
|
2023-03-31 02:58:27 -04:00
|
|
|
void InitMergedMeshFromGeometryCollection(UGeometryCollection const& InGeometryCollection);
|
|
|
|
|
void InitInstancesFromGeometryCollection(UGeometryCollection const& InGeometryCollection);
|
|
|
|
|
void UpdateMergedMeshTransforms(FTransform const& InBaseTransform);
|
2023-05-11 19:37:23 -04:00
|
|
|
void UpdateInstanceTransforms(UGeometryCollection const& InGeometryCollection, FTransform const& InBaseTransform, TArrayView<const FTransform> InTransforms);
|
2023-03-31 02:58:27 -04:00
|
|
|
void ReleaseGroup(FISMPoolGroup& InOutGroup);
|
|
|
|
|
};
|