Table of Contents

Class AnimatedModelCache

Namespace
PopcorningGuineaPig.Engine.Gameplay
Assembly
PopcorningGuineaPig.Engine.dll

Singleton cache managing shared AnimatedModelData instances with reference counting. Ensures each unique GLB file is loaded into GPU memory only once.

public sealed class AnimatedModelCache : IDisposable
Inheritance
AnimatedModelCache
Implements
Inherited Members

Constructors

AnimatedModelCache()

public AnimatedModelCache()

Properties

CachedCount

Number of unique models currently cached.

public int CachedCount { get; }

Property Value

int

Methods

Dispose()

Disposes all cached AnimatedModelData entries (engine shutdown cleanup).

public void Dispose()

EstimateMemoryBytes()

Conservatively estimates the bytes consumed by cached AnimatedModelData entries. Per-cache-entry estimate sums:

  • Mesh vertex buffers across all meshes (32 bytes/vertex for position+normal+uv).
  • Index buffer (4 bytes/index, triangle list).
  • Skeletal animation pose data (animationCount * boneCount * frameCount * 64 bytes per Raylib Transform).

GPU upload overhead and embedded textures are NOT counted here — they live in the asset registry's texture estimator. Intended for diagnostics; O(N) over cached models.

public long EstimateMemoryBytes()

Returns

long

GetOrLoad(string)

Returns an existing AnimatedModelData for the given path (incrementing ref count), or creates a new one if not yet cached.

public AnimatedModelData GetOrLoad(string filePath)

Parameters

filePath string

Returns

AnimatedModelData

Release(AnimatedModelData)

Decrements the reference count for the given data. When ref count reaches 0, the data is disposed and removed from the cache.

public void Release(AnimatedModelData data)

Parameters

data AnimatedModelData