optimized faces

This commit is contained in:
maxwes08
2025-12-15 10:14:16 +01:00
parent 0641d22c9b
commit f532eddfbb
11 changed files with 107 additions and 141 deletions

View File

@@ -10,6 +10,7 @@ namespace Voxel
private (int x, int z) _lastCenter = (0, 0);
private int _loadDistance = 4;
bool chunkLoadingInitialized = false;
private static readonly Dictionary<Orientation, (int x, int y)> _neighborOffsets = new()
{
@@ -62,7 +63,7 @@ namespace Voxel
int centerZ = (int)Math.Floor(playerPosition.Z / Chunk.Size);
// Quick check - skip if still in same chunk
if (centerX == _lastCenter.x && centerZ == _lastCenter.z)
if ((centerX == _lastCenter.x && centerZ == _lastCenter.z) && chunkLoadingInitialized)
return;
_lastCenter = (centerX, centerZ);
@@ -78,6 +79,8 @@ namespace Voxel
// Load chunks inside range
LoadChunksInRange(minX, maxX, minZ, maxZ);
chunkLoadingInitialized = true;
}
private void UnloadDistantChunks(int minX, int maxX, int minZ, int maxZ)