Files
UnrealEngineUWP/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionISMPoolRenderer.h
jeremy moore e861e8645f Add support for ISMPool reverse culling flag. This allows us to potentially create two ISM components for left and right handedness if needed.
Add free list for ISMPool ISM component slots so that we can recycle them when the number of instances for a component becomes zero.
#preflight 642f0942427eda562650ef0b

[CL 24957562 by jeremy moore in ue5-main branch]
2023-04-06 17:29:18 -04:00

54 lines
2.2 KiB
C++

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