allow creating more glTF instances than pre-allocated

This commit is contained in:
Nick Fisher
2025-06-20 18:46:36 +08:00
parent 37c35906d6
commit e1cb517417
2 changed files with 16 additions and 14 deletions

View File

@@ -63,12 +63,12 @@ namespace thermion
{
auto instanceNumber = _instances.size();
if (instanceNumber > _asset->getAssetInstanceCount() - 1)
if (instanceNumber >= _asset->getAssetInstanceCount() - 1)
{
Log("glTF asset was created with %d instances reserved, and %d instances have been used. Increase the number of instances pre-allocated when the asset is loaded.",
_asset->getAssetInstanceCount(), _instances.size()
TRACE("Warning: %d/%d pre-allocated instances already consumed. You may wish to pre-allocate a larger number.",
_asset->getAssetInstanceCount(), _instances.size()
);
return std::nullptr_t();
_assetLoader->createInstance(_asset);
}
TRACE("Creating instance %d", instanceNumber);
auto instance = _asset->getAssetInstances()[instanceNumber];