Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions sources/engine/Stride.Graphics/IndexBufferHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@ public readonly struct IndexBufferHelper
public Span<byte> DataInner => DataOuter.AsSpan(Binding.Offset, Binding.Count * (Binding.Is32Bit ? 4 : 2));

/// <inheritdoc cref="MeshExtension.AsReadable(IndexBufferBinding, IServiceRegistry, out IndexBufferHelper, out int)"/>
public IndexBufferHelper(IndexBufferBinding binding, IServiceRegistry services, out int count)
public IndexBufferHelper(IndexBufferBinding binding, IServiceRegistry services, out int count)
: this(binding, MeshExtension.FetchBufferContentOrThrow(binding.Buffer, services), out count)
{
DataOuter = MeshExtension.FetchBufferContentOrThrow(binding.Buffer, services);
}

/// <inheritdoc cref="MeshExtension.AsReadable(IndexBufferBinding, IServiceRegistry, out IndexBufferHelper, out int)"/>
public IndexBufferHelper(IndexBufferBinding binding, byte[] dataOuter, out int count)
{
if (dataOuter.Length < binding.Offset + binding.Count * (binding.Is32Bit ? 4 : 2))
throw new ArgumentException($"Binding describes an array larger than {nameof(dataOuter)} ({dataOuter.Length} < {binding.Offset} + {binding.Count} * {(binding.Is32Bit ? 4 : 2)})");

DataOuter = dataOuter;
Binding = binding;
count = Binding.Count;
}
Expand Down
2 changes: 1 addition & 1 deletion sources/engine/Stride.Graphics/VertexBufferBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public VertexBufferBinding(Buffer vertexBuffer, VertexDeclaration vertexDeclarat
public Buffer Buffer { get; private set; }

/// <summary>
/// Gets the offset (vertex index) between the beginning of the buffer and the vertex data to use.
/// Gets the offset in bytes between the beginning of the buffer and the vertex data to use.
/// </summary>
public int Offset { get; private set; }

Expand Down
2 changes: 1 addition & 1 deletion sources/engine/Stride.Graphics/VertexBufferHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public VertexBufferHelper(VertexBufferBinding binding, IServiceRegistry services
public VertexBufferHelper(VertexBufferBinding binding, byte[] dataOuter, out int count)
{
if (dataOuter.Length < binding.Offset + binding.Count * binding.Stride)
throw new ArgumentException($"{nameof(dataOuter)} does not fit the bindings provided. Make sure that the span provided contains the entirety of the vertex buffer");
throw new ArgumentException($"Binding describes an array larger than {nameof(dataOuter)} ({dataOuter.Length} < {binding.Offset} + {binding.Count} * {binding.Stride})");

DataOuter = dataOuter;
Binding = binding;
Expand Down
Loading