TMassLODCalculator

Helper struct to calculate LOD for each agent and maximize count per LOD Requires TViewerInfoFragment fragment collected by the [TMassLODCollector](API\Plugins\MassLOD\TMassLODCollector).

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

FMassLODBaseLogic

TMassLODCalculator

References

Module

MassLOD

Header

/Engine/Plugins/Runtime/MassGameplay/Source/MassLOD/Public/MassLODCalculator.h

Include

#include "MassLODCalculator.h"

Syntax

template<typename FLODLogic>
struct TMassLODCalculator : public FMassLODBaseLogic

Remarks

Helper struct to calculate LOD for each agent and maximize count per LOD Requires TViewerInfoFragment fragment collected by the TMassLODCollector. Stores information in TLODFragment fragment.

Variables

Name Description

Protected variable

TStaticArray< f...

 

BaseBucketSize

The size of each subdivision per LOD (LOD Size/MaxBucketsPerLOD)

Protected variable

TStaticArray< f...

 

BaseLODDistance

LOD distances

Protected variable

float

 

BufferHysteresisOnDistanceRatio

Ratio for Buffer Distance Hysteresis

Protected variable

TStaticArray< i...

 

LODMaxCount

MaxCount total

Protected variable

TStaticArray< i...

 

LODMaxCountPerViewer

MaxCount total per viewers

Protected variable

float

 

MaxLODDistance

Maximum LOD Distance

Protected variable

FMassLODRuntime...

 

RuntimeData

Runtime data for LOD calculation

Protected variable

TArray< FMassLO...

 

RuntimeDataPerViewer

Runtime data for each viewer specific LOD calculation, used only when bMaximizeCountPerViewer is true

Protected variable

TStaticArray< f...

 

VisibleBucketSize

Protected variable

float

 

VisibleDistanceToFrustum

How far away from frustum does this entities are considered visible

Protected variable

float

 

VisibleDistanceToFrustumWithHysteresis

Once visible how much further than distance to frustum does the entities need to be before being consider not visible

Protected variable

TStaticArray< f...

 

VisibleLODDistance

Functions

Name Description

Protected function Const

float

 

AccumulateCountInRuntimeData

(
    const EMassLOD::Type LOD,
    const float ViewerDistanceSq,
    const bool bIsVisible,
    FMassLODRuntimeData& Data
)

Public function

bool

 

AdjustDistancesFromCount()

Adjust LOD distances by clamping them to respect the maximum LOD count true if any LOD distances clamping was done

Protected function Const

bool

 

AdjustDistancesFromCountForRuntimeData

(
    const TStaticArray< int32, EMassLOD...,
    FMassLODRuntimeData& RuntimeData
)

Public function

void

 

AdjustLODFromCount

(
    FMassExecutionContext& Context,
    TConstArrayView< TViewerInfoFragmen...,
    TArrayView< TLODFragment > LODList
)

Adjust LOD from newly adjusted distances, only needed to be called when AdjustDistancesFromCount return true, called for each entity chunks Use next method when FLODLogic::bStoreInfoPerViewer is enabled Context of the chunk execution ViewersInfoList is the source information fragment for LOD calculation LODList is the fragment where calculation are stored

Public function

void

 

AdjustLODFromCount

(
    FMassExecutionContext& Context,
    TConstArrayView< TViewerInfoFragmen...,
    TArrayView< TLODFragment > LODList,
    TConstArrayView< TPerViewerInfoFrag...
)

Adjust LOD from newly adjusted distances, only needed to be called when AdjustDistancesFromCount return true, called for each entity chunks Use this version when FLODLogic::bStoreInfoPerViewer is enabled It calculates a LOD per viewer and needs information per viewer via PerViewerInfoList fragments Context of the chunk execution ViewersInfoList is the source information fragment for LOD calculation LODList is the fragment where calculation are stored PerViewerInfoList is the Per viewer source information

Public function

void

 

CalculateLOD

(
    FMassExecutionContext& Context,
    TConstArrayView< TViewerInfoFragmen...,
    TArrayView< TLODFragment > LODList
)

Calculate LOD, called for each entity chunks Use next method when FLODLogic::bStoreInfoPerViewer is enabled Context of the chunk execution ViewersInfoList is the source information fragment for LOD calculation LODList is the fragment where calculation are stored

Public function

void

 

CalculateLOD

(
    FMassExecutionContext& Context,
    TConstArrayView< TViewerInfoFragmen...,
    TArrayView< TLODFragment > LODList,
    TConstArrayView< TPerViewerInfoFrag...
)

Calculate LOD, called for each entity chunks Use this version when FLODLogic::bStoreInfoPerViewer is enabled It calculates a LOD per viewer and needs information per viewer via PerViewerInfoList fragments Context of the chunk execution ViewersInfoList is the source information fragment for LOD calculation LODList is the fragment where calculation are stored PerViewerInfoList is the Per viewer source information

Protected function Const

bool

 

CalculateVisibility

(
    const bool bWasVisible,
    const float DistanceToFrustum
)

Protected function Const

EMassLOD::Ty...

 

ComputeLODFromSettings

(
    const EMassLOD::Type PrevLOD,
    const float DistanceToViewerSq,
    const bool bIsVisible,
    bool* bIsInAVisibleRange,
    const FMassLODRuntimeData& Data
)

Public function

void

 

DebugDisplayLOD

(
    FMassExecutionContext& Context,
    TConstArrayView< TLODFragment > LOD...,
    TConstArrayView< TTransformFragment...,
    UWorld* World
)

Debug draw the current state of each agent as a color coded square Context of the chunk execution LODList is the fragment where calculation are stored LocationList is the fragment transforms of the entities World where the debug display should be drawn

Public function

void

 

ForceOffLOD

(
    FMassExecutionContext& Context,
    TArrayView< TLODFragment > LODList
)

Turn Off all LOD, called for each entity chunks Context of the chunk execution LODList is the fragment where calculation are stored

Public function

void

 

Initialize

(
    const float InBaseLODDistance,
    const float InBufferHysteresisOnDis...,
    const int32 InLODMaxCount,
    const int32 InLODMaxCountPerViewer,
    const float InVisibleDistanceToFrus...,
    const float InVisibleDistanceToFrus...,
    const float InVisibleLODDistance
)

Initializes the LOD calculator, needed to be called once at initialization time InBaseLODDistance distances used to calculate LOD InBufferHysteresisOnFOVRatio distance hysteresis used to calculate LOD InLODMaxCount the maximum count for each LOD InLODMaxCountPerViewer the maximum count for each LOD per viewer (Only when FLODLogic::bMaximizeCountPerViewer is enabled) InVisibleDistanceToFrustum is the distance from the frustum to start considering this entity is visible (Only when FLODLogic::bDoVisibilityLogic is enabled) InVisibleDistanceToFrustumHysteresis once visible, what extra distance the entity need to be before considered not visible anymore (Only when FLODLogic::bDoVisibilityLogic is enabled) InVisibleLODDistance the maximum count for each LOD per viewer (Only when FLODLogic::bDoVisibilityLogic is enabled)

Public function

void

 

PrepareExecution

(
    TConstArrayView< FViewerInfo > View...
)

Prepares execution for the current frame, needed to be called before every execution Viewers is the array of all the known viewers

Classes

Name

Description

Protected struct

FMassLODRuntimeData