Files
UnrealEngineUWP/Engine/Source/Developer/MeshBuilder/Private/MeshBuilderModule.cpp
kenzo terelst 00c5e43c69 Add support for Nanite coarse mesh streaming (vertex data + BLAS):
- Cook side extra low lod coarse mesh will be created at 1/8th of the original coarse mesh if mesh streaming or editor data is available for the platform
- Nanite static meshes with streamable LODs are registered to a Nanite::CoarseMeshStreamingManager which will handle the stream in/out requests for these assets in fixed memory budget (memory budget is part of the total mesh streaming budget)
- Nanite proxy needs to handle different raytracing proxy LOD indices now for dynamic and cached indices
- What to stream is driven by what's used in the TLAS build - each deferred render pass all used streamable meshes are collected and forwarded to the CoarseMeshStreamingManager
- CoarseMeshStreamingManager is updated after all views are rendered and will make stream in/out requests depending on the TLAS usage
- When LODs of UStaticMeshes renderdata is loaded or unloaded then a rebuild of the cached render data is requested to make sure the correct LOD & RT BLAS is used (to do this the UStaticMeshComponent are registered to the UStaticMesh so a request for rebuild can be made for all the proxies on the scene)

#preflight 612659e872e9eb00010a27d9


#ROBOMERGE-SOURCE: CL 17314263
#ROBOMERGE-BOT: (v861-17282326)

[CL 17315687 by kenzo terelst in ue5-main branch]
2021-08-26 07:30:04 -04:00

73 lines
1.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "IMeshBuilderModule.h"
#include "Modules/ModuleManager.h"
#include "StaticMeshBuilder.h"
#include "Engine/StaticMesh.h"
#include "SkeletalMeshBuilder.h"
#include "Engine/SkeletalMesh.h"
class FMeshBuilderModule : public IMeshBuilderModule
{
public:
FMeshBuilderModule()
{
}
virtual void StartupModule() override
{
// Register any modular features here
}
virtual void ShutdownModule() override
{
// Unregister any modular features here
}
virtual bool BuildMesh(FStaticMeshRenderData& OutRenderData, UObject* Mesh, const FStaticMeshLODGroup& LODGroup, bool bGenerateCoarseMeshStreamingLODs) override;
virtual bool BuildMeshVertexPositions(
UObject* StaticMesh,
TArray<uint32>& Indices,
TArray<FVector3f>& Vertices) override;
virtual bool BuildSkeletalMesh(const FSkeletalMeshBuildParameters& SkeletalMeshBuildParameters) override;
private:
};
IMPLEMENT_MODULE(FMeshBuilderModule, MeshBuilder );
bool FMeshBuilderModule::BuildMesh(FStaticMeshRenderData& OutRenderData, class UObject* Mesh, const FStaticMeshLODGroup& LODGroup, bool bGenerateCoarseMeshStreamingLODs)
{
UStaticMesh* StaticMesh = Cast<UStaticMesh>(Mesh);
if (StaticMesh != nullptr)
{
//Call the static mesh builder
return FStaticMeshBuilder().Build(OutRenderData, StaticMesh, LODGroup, bGenerateCoarseMeshStreamingLODs);
}
return false;
}
bool FMeshBuilderModule::BuildMeshVertexPositions(
UObject* Mesh,
TArray<uint32>& Indices,
TArray<FVector3f>& Vertices)
{
UStaticMesh* StaticMesh = Cast< UStaticMesh >(Mesh);
if (StaticMesh)
{
//Call the static mesh builder
return FStaticMeshBuilder().BuildMeshVertexPositions(StaticMesh, Indices, Vertices);
}
return false;
}
bool FMeshBuilderModule::BuildSkeletalMesh(const FSkeletalMeshBuildParameters& SkeletalMeshBuildParameters)
{
//Call the skeletal mesh builder
return FSkeletalMeshBuilder().Build(SkeletalMeshBuildParameters);
}