Fix loading models with no meshes

This commit is contained in:
Wojtek Figat
2025-06-03 12:28:17 +02:00
parent 077f7a3cd1
commit 2fd9b4a62a
3 changed files with 5 additions and 4 deletions

View File

@@ -254,7 +254,8 @@ namespace FlaxEditor.Windows.Assets
if (lodIndex >= countLODs - loadedLODs)
{
var mesh = lod.GetMesh(0);
vertexLayout = mesh.VertexLayout;
if (mesh != null)
vertexLayout = mesh.VertexLayout;
if (vertexLayout != null && vertexLayout.Elements.Length != 0)
break;
vertexLayout = null;

View File

@@ -324,7 +324,7 @@ bool Model::Init(const Span<int32>& meshesCountPerLod)
lod.Link(this, lodIndex);
lod.ScreenSize = 1.0f;
const int32 meshesCount = meshesCountPerLod[lodIndex];
if (meshesCount <= 0 || meshesCount > MODEL_MAX_MESHES)
if (meshesCount < 0 || meshesCount > MODEL_MAX_MESHES)
return true;
lod.Meshes.Resize(meshesCount);
@@ -362,7 +362,7 @@ bool Model::LoadHeader(ReadStream& stream, byte& headerVersion)
// Meshes
uint16 meshesCount;
stream.ReadUint16(&meshesCount);
if (meshesCount == 0 || meshesCount > MODEL_MAX_MESHES)
if (meshesCount > MODEL_MAX_MESHES)
return true;
ASSERT(lodIndex == 0 || LODs[0].Meshes.Count() >= meshesCount);
lod.Meshes.Resize(meshesCount, false);

View File

@@ -476,7 +476,7 @@ bool SkinnedModel::Init(const Span<int32>& meshesCountPerLod)
lod._lodIndex = lodIndex;
lod.ScreenSize = 1.0f;
const int32 meshesCount = meshesCountPerLod[lodIndex];
if (meshesCount <= 0 || meshesCount > MODEL_MAX_MESHES)
if (meshesCount < 0 || meshesCount > MODEL_MAX_MESHES)
return true;
lod.Meshes.Resize(meshesCount);