Class MeshDataPool
- Namespace
- Vintagestory.API.Client
- Assembly
- VintagestoryAPI.dll
A model data pool: one large buffer on the GPU that chunk meshes are packed into It holds up to 400k vertices and 300k indices but never more than 900 chunks Open in GitHub
public class MeshDataPool
- Inheritance
-
MeshDataPool
- Inherited Members
- Extension Methods
Fields
AllocatedTris
How many triangles are allocated
public int AllocatedTris
Field Value
CurrentFragmentation
Current buffer fragmentation (share of holes)
public float CurrentFragmentation
Field Value
IndicesPoolSize
Size of the pool index buffer
public int IndicesPoolSize
Field Value
MaxPartsPerPool
Maximum number of parts (meshes) in this pool
public int MaxPartsPerPool
Field Value
RenderedTriangles
How many triangles were drawn
public int RenderedTriangles
Field Value
UsedVertices
How many vertices are actually used
public int UsedVertices
Field Value
VerticesPoolSize
Size of the pool vertex buffer
public int VerticesPoolSize
Field Value
indicesGroupsCount
How many index groups there are (how many draw calls to make)
public int indicesGroupsCount
Field Value
indicesPosition
Position in the index buffer
public int indicesPosition
Field Value
indicesSizes
Size of each index group
public required int[] indicesSizes
Field Value
- int[]
indicesStartsByte
Start byte of each index group
public required int[] indicesStartsByte
Field Value
- int[]
verticesPosition
Position in the vertex buffer
public int verticesPosition
Field Value
Methods
AllocateNewPool(ICoreClientAPI, int, int, int, CustomMeshDataPartFloat?, CustomMeshDataPartShort?, CustomMeshDataPartByte?, CustomMeshDataPartInt?)
Creates a new pool for mesh data
public static MeshDataPool AllocateNewPool(ICoreClientAPI capi, int verticesPoolSize, int indicesPoolSize, int maxPartsPerPool, CustomMeshDataPartFloat? customFloats = null, CustomMeshDataPartShort? customShorts = null, CustomMeshDataPartByte? customBytes = null, CustomMeshDataPartInt? customInts = null)
Parameters
capiICoreClientAPIThe core client API
verticesPoolSizeintThe vertices pool size.
indicesPoolSizeintThe indices pool size.
maxPartsPerPoolintThe maximum parts per pool.
customFloatsCustomMeshDataPartFloatThe custom floats of the pool.
customShortsCustomMeshDataPartShortThe custom shorts of the pool.
customBytesCustomMeshDataPartByteThe custom bytes of the pool.
customIntsCustomMeshDataPartIntThe custom ints of the pool.
Returns
- MeshDataPool
The resulting mesh data pool.
CalcFragmentation()
Computes fragmentation: the share of the used vertex buffer taken up by holes between meshes The more holes there are, the more worthwhile it is to insert new meshes into the gaps
public void CalcFragmentation()
Dispose(ICoreClientAPI)
Releases the pool buffers on the GPU
public void Dispose(ICoreClientAPI capi)
Parameters
capiICoreClientAPI
Draw(ICoreClientAPI, FrustumCulling, EnumFrustumCullMode)
Draws the pool: first picks the visible parts, then sends them in one call
public void Draw(ICoreClientAPI capi, FrustumCulling frustumCuller, EnumFrustumCullMode frustumCullMode)
Parameters
capiICoreClientAPIThe core client API
frustumCullerFrustumCullingThe area where models can be viewed from the camera.
frustumCullModeEnumFrustumCullModeThe mode of the culling.
FrustumCull(FrustumCulling?, EnumFrustumCullMode)
Finds the visible parts and fills the arrays for MultiDrawElements The rules themselves are implemented in PoolCullData and set by FrustumCulling
public void FrustumCull(FrustumCulling? frustumCuller, EnumFrustumCullMode frustumCullMode)
Parameters
frustumCullerFrustumCullingfrustumCullModeEnumFrustumCullMode
GetFragmentation()
Current pool fragmentation
public float GetFragmentation()
Returns
IsEmpty()
Is the pool empty
public bool IsEmpty()
Returns
RemoveLocation(ModelDataPoolLocation)
Removes a mesh from the pool Throws when it cannot be removed (wrong pool or no such mesh in this pool)
public void RemoveLocation(ModelDataPoolLocation location)
Parameters
locationModelDataPoolLocation
RenderMesh(IRenderAPI)
Sends only the parts found by the previous FrustumCull to the GPU
public void RenderMesh(IRenderAPI render)
Parameters
renderIRenderAPI
SetFullyVisible()
Draws every part that is not hidden without frustum culling Used for mini dimension pools Everything goes through Cull so Hide, the group layout and the triangle stats share one place
public void SetFullyVisible()
TryAdd(ICoreClientAPI, MeshData, Vec3i, int, Sphere)
Tries to add a new mesh to the pool. Returns null when there is no room or when the mesh is from another dimension.
public ModelDataPoolLocation? TryAdd(ICoreClientAPI capi, MeshData modeldata, Vec3i modelOrigin, int dimension, Sphere frustumCullSphere)
Parameters
capiICoreClientAPIThe core client API
modeldataMeshDataThe model to add
modelOriginVec3iThe origin point of the model.
dimensionintThe dimension this model appears in.
frustumCullSphereSphereThe culling sphere.
Returns
- ModelDataPoolLocation
The location of the model (and the data) in the pool.