Skip to content

Commit 35b17dd

Browse files
1 parent d24768b commit 35b17dd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Assets/Scripts/Generation/Chunk.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ public sealed class Chunk
1717
public int VoxelSize => _voxelSize ??= (int)Math.Pow(2, Math.Max(0, LevelOfDetail - 1));
1818
private int? _voxelSize = null;
1919

20-
public int MaxVoxelCapacity => SquaredPaddedChunkSizeXZ * ChunkSizeY + SquaredPaddedChunkSizeXZ;
20+
public int MaxVoxelCapacity => PaddedChunkSizeXZSquared * ChunkSizeY + PaddedChunkSizeXZSquared;
2121

22-
public int PaddedChunkSizeXZ => ChunkSizeXZ + 1;
23-
public int SquaredPaddedChunkSizeXZ => _squaredChunkSizeXZ ??= (int)Math.Pow(PaddedChunkSizeXZ, 2);
24-
private int? _squaredChunkSizeXZ = null;
22+
public int PaddedChunkSizeXZSquared => _paddedChunkSizeXZsquared ??= (int)Math.Pow(PaddedChunkSizeXZ, 2);
23+
private int? _paddedChunkSizeXZsquared = null;
24+
25+
public int PaddedChunkSizeXZ => _paddedChunkSizeXZ ??= ChunkSizeXZ + 1;
26+
public int? _paddedChunkSizeXZ = null;
2527

2628
public int ChunkSizeXZ => _chunkSizeXZ ??= Generator.ChunkSizeXZ * ChunkSizeXZMultiplier;
2729
private int? _chunkSizeXZ = null;
@@ -74,7 +76,7 @@ public bool SetNoiseData(int x, int z, NoiseData noiseData) =>
7476
NoiseData.TryAdd(x * ChunkSizeXZ + z, noiseData);
7577

7678
public int ToIndex(Vector3Byte localPosition) =>
77-
localPosition.X + (localPosition.Z * PaddedChunkSizeXZ) + (localPosition.Y * SquaredPaddedChunkSizeXZ);
79+
localPosition.X + (localPosition.Z * PaddedChunkSizeXZ) + (localPosition.Y * PaddedChunkSizeXZSquared);
7880

7981
public int ToIndex(int x, int z) =>
8082
x * ChunkSizeXZ + z;

0 commit comments

Comments
 (0)