Table of Contents

Class MeshDataRecycler

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

This is a recycling system for MeshData objects, so that they can be re-used: helps performance by easing memory allocation pressure, at the cost of holding typically around 300-400MB of memory for these recycled objects

public class MeshDataRecycler
Inheritance
MeshDataRecycler
Inherited Members
Extension Methods

Constructors

MeshDataRecycler(IClientWorldAccessor)

public MeshDataRecycler(IClientWorldAccessor clientMain)

Parameters

clientMain IClientWorldAccessor

Fields

MinimumSizeForRecycling

public const int MinimumSizeForRecycling = 4096

Field Value

int

TTL

public const int TTL = 15000

Field Value

int

Methods

Dispose()

Dispose of the MeshDataRecycler (normally on game exit, but can also be used to disable further use of it)

public void Dispose()

DoRecycling()

Call this periodically on the same thread which will call GetOrCreateMesh, this is required to ensure the Recycling system is up to date

public void DoRecycling()

GetOrCreateMesh(int)

Gets or creates a MeshData with basic data fields already allocated (may contain junk data) and capacity (VerticesMax) at least equal to minimumVertices; in MeshData created/recycled using this system, IndicesMax will be fixed equal to VerticesMax * 6 / 4

public MeshData GetOrCreateMesh(int minimumVertices)

Parameters

minimumVertices int

Returns

MeshData

Recycle(MeshData)

Offer this MeshData to the recycling system: it will first be queued for recycling, and later processed to be either recycled or disposed of

public void Recycle(MeshData meshData)

Parameters

meshData MeshData