2016-12-08 08:52:44 -05:00
|
|
|
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
2015-06-18 06:59:14 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "Stats/Stats.h"
|
|
|
|
|
#include "Containers/ResourceArray.h"
|
|
|
|
|
#include "RenderResource.h"
|
|
|
|
|
#include "PrimitiveViewRelevance.h"
|
|
|
|
|
#include "PrimitiveSceneProxy.h"
|
|
|
|
|
#include "Materials/MaterialInterface.h"
|
|
|
|
|
#include "LocalVertexFactory.h"
|
2015-06-18 06:59:14 -04:00
|
|
|
#include "DynamicMeshBuilder.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
|
|
|
|
|
class FMeshElementCollector;
|
|
|
|
|
struct FGeometryCacheMeshData;
|
2015-06-18 06:59:14 -04:00
|
|
|
|
|
|
|
|
DECLARE_STATS_GROUP(TEXT("GeometryCache"), STATGROUP_GeometryCache, STATCAT_Advanced);
|
|
|
|
|
DECLARE_CYCLE_STAT(TEXT("MeshTime"), STAT_GeometryCacheSceneProxy_GetMeshElements, STATGROUP_GeometryCache );
|
|
|
|
|
DECLARE_DWORD_COUNTER_STAT(TEXT("Triangle Count"), STAT_GeometryCacheSceneProxy_TriangleCount, STATGROUP_GeometryCache);
|
|
|
|
|
DECLARE_DWORD_COUNTER_STAT(TEXT("Section Count"), STAT_GeometryCacheSceneProxy_MeshBatchCount, STATGROUP_GeometryCache);
|
|
|
|
|
|
|
|
|
|
/** Resource array to pass */
|
|
|
|
|
class GEOMETRYCACHE_API FGeomCacheVertexResourceArray : public FResourceArrayInterface
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FGeomCacheVertexResourceArray(void* InData, uint32 InSize);
|
|
|
|
|
|
|
|
|
|
virtual const void* GetResourceData() const override;
|
|
|
|
|
virtual uint32 GetResourceDataSize() const override;
|
|
|
|
|
virtual void Discard() override;
|
|
|
|
|
virtual bool IsStatic() const override;
|
|
|
|
|
virtual bool GetAllowCPUAccess() const override;
|
|
|
|
|
virtual void SetAllowCPUAccess(bool bInNeedsCPUAccess) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void* Data;
|
|
|
|
|
uint32 Size;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Vertex Buffer */
|
|
|
|
|
class GEOMETRYCACHE_API FGeomCacheVertexBuffer : public FVertexBuffer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TArray<FDynamicMeshVertex> Vertices;
|
|
|
|
|
|
|
|
|
|
virtual void InitRHI() override;
|
|
|
|
|
|
|
|
|
|
void UpdateRHI();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Index Buffer */
|
|
|
|
|
class GEOMETRYCACHE_API FGeomCacheIndexBuffer : public FIndexBuffer
|
|
|
|
|
{
|
|
|
|
|
public:
|
2015-09-07 09:32:51 -04:00
|
|
|
TArray<uint32> Indices;
|
2015-06-18 06:59:14 -04:00
|
|
|
|
|
|
|
|
virtual void InitRHI() override;
|
|
|
|
|
|
|
|
|
|
void UpdateRHI();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Vertex Factory */
|
|
|
|
|
class GEOMETRYCACHE_API FGeomCacheVertexFactory : public FLocalVertexFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
FGeomCacheVertexFactory();
|
|
|
|
|
|
|
|
|
|
/** Init function that should only be called on render thread. */
|
|
|
|
|
void Init_RenderThread(const FGeomCacheVertexBuffer* VertexBuffer);
|
|
|
|
|
|
|
|
|
|
/** Init function that can be called on any thread, and will do the right thing (enqueue command if called on main thread) */
|
|
|
|
|
void Init(const FGeomCacheVertexBuffer* VertexBuffer);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class GEOMETRYCACHE_API FGeomCacheTrackProxy
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/** MeshData storing information used for rendering this Track */
|
|
|
|
|
FGeometryCacheMeshData* MeshData;
|
|
|
|
|
|
|
|
|
|
/** Material applied to this Track */
|
|
|
|
|
TArray<UMaterialInterface*> Materials;
|
|
|
|
|
/** Vertex buffer for this Track */
|
|
|
|
|
FGeomCacheVertexBuffer VertexBuffer;
|
|
|
|
|
/** Index buffer for this Track */
|
|
|
|
|
FGeomCacheIndexBuffer IndexBuffer;
|
|
|
|
|
/** Vertex factory for this Track */
|
|
|
|
|
FGeomCacheVertexFactory VertexFactory;
|
|
|
|
|
/** World Matrix for this Track */
|
|
|
|
|
FMatrix WorldMatrix;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Procedural mesh scene proxy */
|
|
|
|
|
class GEOMETRYCACHE_API FGeometryCacheSceneProxy : public FPrimitiveSceneProxy
|
|
|
|
|
{
|
|
|
|
|
public:
|
2015-09-07 09:32:51 -04:00
|
|
|
|
2015-06-18 18:46:15 -04:00
|
|
|
FGeometryCacheSceneProxy(class UGeometryCacheComponent* Component);
|
2015-06-18 06:59:14 -04:00
|
|
|
|
|
|
|
|
virtual ~FGeometryCacheSceneProxy();
|
|
|
|
|
|
2015-09-07 09:32:51 -04:00
|
|
|
// Begin FPrimitiveSceneProxy interface.
|
2015-06-18 06:59:14 -04:00
|
|
|
virtual void GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const override;
|
2015-09-01 18:01:22 -04:00
|
|
|
virtual FPrimitiveViewRelevance GetViewRelevance(const FSceneView* View) const override;
|
2015-06-18 06:59:14 -04:00
|
|
|
|
|
|
|
|
virtual bool CanBeOccluded() const override;
|
|
|
|
|
virtual uint32 GetMemoryFootprint(void) const;
|
|
|
|
|
uint32 GetAllocatedSize(void) const;
|
2015-09-07 09:32:51 -04:00
|
|
|
// End FPrimitiveSceneProxy interface.
|
2015-06-18 06:59:14 -04:00
|
|
|
|
|
|
|
|
/** Update world matrix for specific section */
|
|
|
|
|
void UpdateSectionWorldMatrix(const int32 SectionIndex, const FMatrix& WorldMatrix);
|
|
|
|
|
/** Update vertex buffer for specific section */
|
|
|
|
|
void UpdateSectionVertexBuffer(const int32 SectionIndex, FGeometryCacheMeshData* MeshData );
|
|
|
|
|
/** Update index buffer for specific section */
|
2015-09-07 09:32:51 -04:00
|
|
|
void UpdateSectionIndexBuffer(const int32 SectionIndex, const TArray<uint32>& Indices);
|
2015-06-18 06:59:14 -04:00
|
|
|
|
|
|
|
|
/** Clears the Sections array*/
|
|
|
|
|
void ClearSections();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
FMaterialRelevance MaterialRelevance;
|
|
|
|
|
|
|
|
|
|
/** Array of Track Proxies */
|
|
|
|
|
TArray<FGeomCacheTrackProxy*> Sections;
|
|
|
|
|
};
|