mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Gracefully handle integer UV channels during GLB export
* Resolves #1811
This commit is contained in:
parent
ab7d9b59cf
commit
e9db99e07e
@ -185,6 +185,6 @@ public readonly record struct MeshData(
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static T TryGetAtIndex<T>(T[]? array, uint index) where T : struct
|
||||
{
|
||||
return array is null ? default : array[index];
|
||||
return array is null or { Length: 0 } ? default : array[index];
|
||||
}
|
||||
}
|
||||
|
||||
32
Source/AssetRipper.Tests/MeshDataTests.cs
Normal file
32
Source/AssetRipper.Tests/MeshDataTests.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using AssetRipper.SourceGenerated.Extensions;
|
||||
|
||||
namespace AssetRipper.Tests;
|
||||
|
||||
internal class MeshDataTests
|
||||
{
|
||||
[Test]
|
||||
public void AccessingNullUV2DoesNotThrow()
|
||||
{
|
||||
MeshData meshData = MeshData.CreateTriangleMesh() with
|
||||
{
|
||||
UV2 = null
|
||||
};
|
||||
Assert.DoesNotThrow(() =>
|
||||
{
|
||||
meshData.TryGetUV2AtIndex(0);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AccessingEmptyUV2DoesNotThrow()
|
||||
{
|
||||
MeshData meshData = MeshData.CreateTriangleMesh() with
|
||||
{
|
||||
UV2 = []
|
||||
};
|
||||
Assert.DoesNotThrow(() =>
|
||||
{
|
||||
meshData.TryGetUV2AtIndex(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user