Files
UnrealEngineUWP/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionISMPoolRenderer.h
vincent robert 94d8c3b195 Convert GC ComponentSpaceTransform in single precision
#rb cedric.caillaud, jeremy.moore

[CL 28801896 by vincent robert in ue5-main branch]
2023-10-16 12:20:18 -04:00

59 lines
2.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GeometryCollection/GeometryCollectionExternalRenderInterface.h"
#include "GeometryCollectionISMPoolRenderer.generated.h"
class AGeometryCollectionISMPoolActor;
class UGeometryCollectionISMPoolComponent;
class UGeometryCollectionComponent;
class ULevel;
/** 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, uint32 InStateFlags) override;
virtual void UpdateRootTransform(UGeometryCollection const& InGeometryCollection, FTransform const& InRootTransform) override;
virtual void UpdateTransforms(UGeometryCollection const& InGeometryCollection, TArrayView<const FTransform3f> InTransforms) 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;
/** level of the owning component of this renderer */
ULevel* OwningLevel = nullptr;
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 FTransform3f> InTransforms);
void ReleaseGroup(FISMPoolGroup& InOutGroup);
};