You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#codereview Jurre.DeBaare, John.Barrett, Chris.Babcock [CL 2592901 by Dmitry Rekman in Main branch]
119 lines
3.6 KiB
C++
119 lines
3.6 KiB
C++
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
#pragma once
|
|
|
|
#include "DynamicMeshBuilder.h"
|
|
#include "Stats.h"
|
|
|
|
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:
|
|
TArray<int32> Indices;
|
|
|
|
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:
|
|
// QQ interfaces/comments
|
|
FGeometryCacheSceneProxy(class UGeometryCacheComponent* Component);
|
|
|
|
virtual ~FGeometryCacheSceneProxy();
|
|
|
|
virtual void GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const override;
|
|
|
|
virtual FPrimitiveViewRelevance GetViewRelevance(const FSceneView* View);
|
|
|
|
virtual bool CanBeOccluded() const override;
|
|
|
|
virtual uint32 GetMemoryFootprint(void) const;
|
|
|
|
uint32 GetAllocatedSize(void) const;
|
|
|
|
/** 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 */
|
|
void UpdateSectionIndexBuffer(const int32 SectionIndex, const TArray<int32>& Indices);
|
|
|
|
/** Clears the Sections array*/
|
|
void ClearSections();
|
|
|
|
private:
|
|
FMaterialRelevance MaterialRelevance;
|
|
|
|
/** Array of Track Proxies */
|
|
TArray<FGeomCacheTrackProxy*> Sections;
|
|
};
|