Slightly simplify lightmap bytes conversion
This commit is contained in:
parent
117f5b924c
commit
5b53d03ae6
|
@ -151,20 +151,18 @@ public class WorldRep : IChunk
|
||||||
|
|
||||||
public readonly byte[] AsBytesRgba(int layer)
|
public readonly byte[] AsBytesRgba(int layer)
|
||||||
{
|
{
|
||||||
if (layer >= Layers)
|
ArgumentOutOfRangeException.ThrowIfLessThan(layer, 0, nameof(layer));
|
||||||
{
|
ArgumentOutOfRangeException.ThrowIfGreaterThan(layer, Layers, nameof(layer));
|
||||||
throw new ArgumentOutOfRangeException(nameof(layer));
|
|
||||||
}
|
var bIdx = 0;
|
||||||
|
var pIdx = layer * Bpp * Width * Height;
|
||||||
|
|
||||||
var length = Width * Height * 4;
|
var length = Width * Height * 4;
|
||||||
var layerOffset = layer * Bpp * Width * Height;
|
|
||||||
var bytes = new byte[length];
|
var bytes = new byte[length];
|
||||||
for (var y = 0; y < Height; y++)
|
for (var y = 0; y < Height; y++)
|
||||||
{
|
{
|
||||||
for (var x = 0; x < Width; x++)
|
for (var x = 0; x < Width; x++)
|
||||||
{
|
{
|
||||||
var bIdx = x * 4 + y * 4 * Width;
|
|
||||||
var pIdx = x * Bpp + y * Bpp * Width + layerOffset;
|
|
||||||
switch (Bpp)
|
switch (Bpp)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -188,6 +186,9 @@ public class WorldRep : IChunk
|
||||||
bytes[bIdx + 3] = Pixels[pIdx + 3];
|
bytes[bIdx + 3] = Pixels[pIdx + 3];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bIdx += 4;
|
||||||
|
pIdx += Bpp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue