Bit more rendering
Some checks failed
Build Dusk / build-linux (push) Failing after 53s
Build Dusk / build-psp (push) Failing after 47s

This commit is contained in:
2025-11-19 09:52:31 -06:00
parent 2179a27bf5
commit 1668c4b0d2
6 changed files with 119 additions and 33 deletions

View File

@@ -15,14 +15,15 @@ class Chunk:
self.current = {}
self.original = {}
self.onChunkData = Event()
self.dirty = False
self.tiles = {}
self.vertexBuffer = VertexBuffer()
tileIndex = 0
for tx in range(CHUNK_WIDTH):
for tz in range(CHUNK_DEPTH):
for ty in range(CHUNK_HEIGHT):
for tz in range(CHUNK_DEPTH):
for tx in range(CHUNK_WIDTH):
self.tiles[tileIndex] = Tile(self, tx, ty, tz, tileIndex)
tileIndex += 1
@@ -42,8 +43,17 @@ class Chunk:
return
try:
with open(fname, 'r') as f:
self.current = json.load(f)
self.original = json.loads(json.dumps(self.current)) # Deep copy
data = json.load(f)
if not 'shapes' in data:
data['shapes'] = []
# For each tile.
for tile in self.tiles.values():
tile.load(data)
self.tileUpdateVertices()
self.dirty = False
self.onChunkData.invoke(self.current)
except Exception as e:
raise RuntimeError(f"Failed to load chunk file: {e}")
@@ -55,7 +65,7 @@ class Chunk:
try:
with open(fname, 'w') as f:
json.dump(self.current, f, indent=2)
self.original = json.loads(json.dumps(self.current)) # Deep copy
self.dirty = False
except Exception as e:
raise RuntimeError(f"Failed to save chunk file: {e}")
@@ -65,7 +75,8 @@ class Chunk:
self.onChunkData.invoke(self.current)
def isDirty(self):
return json.dumps(self.current, sort_keys=True) != json.dumps(self.original, sort_keys=True)
return False
# return json.dumps(self.current, sort_keys=True) != json.dumps(self.original, sort_keys=True)
def getFilename(self):
if not self.map or not hasattr(self.map, 'getMapDirectory'):