Refactor DownloadIndexBuffer to return unsigned data

This commit is contained in:
Wojtek Figat
2021-08-13 10:06:29 +02:00
parent f44e5fb2fe
commit af22c7e96f
5 changed files with 15 additions and 15 deletions

View File

@@ -538,9 +538,9 @@ namespace FlaxEditor.Windows.Assets
for (int i = 0; i < meshData.IndexBuffer.Length; i += 3)
{
// Cache triangle indices
int i0 = meshData.IndexBuffer[i + 0];
int i1 = meshData.IndexBuffer[i + 1];
int i2 = meshData.IndexBuffer[i + 2];
uint i0 = meshData.IndexBuffer[i + 0];
uint i1 = meshData.IndexBuffer[i + 1];
uint i2 = meshData.IndexBuffer[i + 2];
// Cache triangle uvs positions and transform positions to output target
Vector2 uv0 = meshData.VertexBuffer[i0].TexCoord * uvScale;
@@ -562,9 +562,9 @@ namespace FlaxEditor.Windows.Assets
for (int i = 0; i < meshData.IndexBuffer.Length; i += 3)
{
// Cache triangle indices
int i0 = meshData.IndexBuffer[i + 0];
int i1 = meshData.IndexBuffer[i + 1];
int i2 = meshData.IndexBuffer[i + 2];
uint i0 = meshData.IndexBuffer[i + 0];
uint i1 = meshData.IndexBuffer[i + 1];
uint i2 = meshData.IndexBuffer[i + 2];
// Cache triangle uvs positions and transform positions to output target
Vector2 uv0 = meshData.VertexBuffer[i0].LightmapUVs * uvScale;

View File

@@ -645,9 +645,9 @@ namespace FlaxEditor.Windows.Assets
for (int i = 0; i < meshData.IndexBuffer.Length; i += 3)
{
// Cache triangle indices
int i0 = meshData.IndexBuffer[i + 0];
int i1 = meshData.IndexBuffer[i + 1];
int i2 = meshData.IndexBuffer[i + 2];
uint i0 = meshData.IndexBuffer[i + 0];
uint i1 = meshData.IndexBuffer[i + 1];
uint i2 = meshData.IndexBuffer[i + 2];
// Cache triangle uvs positions and transform positions to output target
Vector2 uv0 = meshData.VertexBuffer[i0].TexCoord * uvScale;
@@ -820,7 +820,7 @@ namespace FlaxEditor.Windows.Assets
private struct MeshData
{
public int[] IndexBuffer;
public uint[] IndexBuffer;
public SkinnedMesh.Vertex[] VertexBuffer;
}

View File

@@ -592,10 +592,10 @@ namespace FlaxEngine
/// <remarks>If mesh index buffer format (see <see cref="IndexBufferFormat"/>) is <see cref="PixelFormat.R16_UInt"/> then it's faster to call .</remarks>
/// <param name="forceGpu">If set to <c>true</c> the data will be downloaded from the GPU, otherwise it can be loaded from the drive (source asset file) or from memory (if cached). Downloading mesh from GPU requires this call to be made from the other thread than main thread. Virtual assets are always downloaded from GPU memory due to lack of dedicated storage container for the asset data.</param>
/// <returns>The gathered data.</returns>
public int[] DownloadIndexBuffer(bool forceGpu = false)
public uint[] DownloadIndexBuffer(bool forceGpu = false)
{
var triangles = TriangleCount;
var result = new int[triangles * 3];
var result = new uint[triangles * 3];
if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.IB32))
throw new FlaxException("Failed to download mesh data.");
return result;

View File

@@ -263,10 +263,10 @@ namespace FlaxEngine
/// <remarks>If mesh index buffer format (see <see cref="IndexBufferFormat"/>) is <see cref="PixelFormat.R16_UInt"/> then it's faster to call .</remarks>
/// <param name="forceGpu">If set to <c>true</c> the data will be downloaded from the GPU, otherwise it can be loaded from the drive (source asset file) or from memory (if cached). Downloading mesh from GPU requires this call to be made from the other thread than main thread. Virtual assets are always downloaded from GPU memory due to lack of dedicated storage container for the asset data.</param>
/// <returns>The gathered data.</returns>
public int[] DownloadIndexBuffer(bool forceGpu = false)
public uint[] DownloadIndexBuffer(bool forceGpu = false)
{
var triangles = TriangleCount;
var result = new int[triangles * 3];
var result = new uint[triangles * 3];
if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.IB32))
throw new FlaxException("Failed to download mesh data.");
return result;

View File

@@ -20,7 +20,7 @@ namespace FlaxEngine.Utilities
/// <summary>
/// The index buffer.
/// </summary>
public int[] IndexBuffer;
public uint[] IndexBuffer;
/// <summary>
/// The vertex buffer.