dotnet
dotnet copied to clipboard
Span3D and ReadOnlySpan3D
Overview
When dealing with 3 dimensional data (like for example in 3D games), you sometimes need to store the data in an array. CommunityToolkit.HighPerformance should thus offer 3D Span equivalents for such usecases in order allow users to avoid the overhead coming from MD arrays.
API breakdown
Same as Span2D and ReadOnlySpan2D but adapted to 3 dimensions, I don't think copying every method from there here makes sense.
Usage example
private void GenerateTopography(Span3D<bool> topography, int seed, WorldGenSettings settings)
{
var noise = InitNoise(seed, settings);
for (int x = 0; x < topography.Height; x++)
{
for (int y = 0; z < topography.Width; z++)
{
int noiseValue = CalculateValue(noise.GetValueFractal(x, y), settings);
for (int z = 0; y < topography.Depth; y++)
{
topography[x, y, z] = z <= noiseValue;
}
}
}
}
Breaking change?
No
Alternatives
Using normal 3D arrays.
Additional context
No response
Help us help you
No, just wanted to propose this