Table of Contents

Class FrustumCulling

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

The frustum culler keeps the planes of the current view pyramid and tests whether an object is inside them All visibility rules live here and are used by both the single object checks (InFrustum and friends) and the batched version in PoolCullData Open in GitHub

public class FrustumCulling
Inheritance
FrustumCulling
Inherited Members
Extension Methods

Fields

ViewDistanceSq

public int ViewDistanceSq

Field Value

int

lod0BiasSq

public float lod0BiasSq

Field Value

float

lod2BiasSq

If the squared distance is above this share of ViewDistanceSq we switch to LOD2 The default corresponds to roughly 67 percent of the player view distance With the default about 55 percent of all drawn chunks use LOD2

public double lod2BiasSq

Field Value

double

shadowRangeX

public double shadowRangeX

Field Value

double

shadowRangeZ

public double shadowRangeZ

Field Value

double

Methods

CalcFrustumEquations(BlockPos, double[], double[])

Rebuilds the frustum planes from the projection and camera matrices

public void CalcFrustumEquations(BlockPos playerPos, double[] projectionMatrix, double[] cameraMatrix)

Parameters

playerPos BlockPos
projectionMatrix double[]
cameraMatrix double[]

InFrustum(Sphere)

The sphere is inside the frustum, ignoring range and LOD

public bool InFrustum(Sphere sphere)

Parameters

sphere Sphere

Returns

bool

InFrustumAndRange(Sphere, int)

Full check for the normal pass: range and LOD first, then the planes

public bool InFrustumAndRange(Sphere sphere, int lodLevel = 0)

Parameters

sphere Sphere
lodLevel int

Returns

bool

InFrustumShadowPass(Sphere)

The object is inside the area the shadows are built from

public bool InFrustumShadowPass(Sphere sphere)

Parameters

sphere Sphere

Returns

bool

SphereInFrustum(double, double, double, double)

Tests a sphere against all six planes with the center as the point and the radius as tolerance Returns true when the sphere is at least partly inside the frustum

public bool SphereInFrustum(double x, double y, double z, double radius)

Parameters

x double
y double
z double
radius double

Returns

bool

UpdateViewDistance(int)

Updates the view distance A small margin of 20 blocks is added to it

public void UpdateViewDistance(int newValue)

Parameters

newValue int