Refactor DownloadIndexBuffer to return unsigned data
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace FlaxEngine.Utilities
|
||||
/// <summary>
|
||||
/// The index buffer.
|
||||
/// </summary>
|
||||
public int[] IndexBuffer;
|
||||
public uint[] IndexBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// The vertex buffer.
|
||||
|
||||
Reference in New Issue
Block a user