Fix loading models with no meshes
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user