From ce631dc9f9324e4a22670f2596148c5600d8d3ab Mon Sep 17 00:00:00 2001 From: "Marcus Str." Date: Fri, 3 Jan 2025 11:07:18 +0100 Subject: [PATCH] New mechanism for resource allocation --- orthographic.py | 13 +++++-------- tileprep.py | 41 ++++++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/orthographic.py b/orthographic.py index 82b0b87..609856c 100644 --- a/orthographic.py +++ b/orthographic.py @@ -468,16 +468,11 @@ class mstr_orthographic: tp._setLatLngFold(self._latlngfld) tp._setAlreadyVisitedTiles(self._tiles_visited[vstidx]) tp._placeTileSources(mlat, mlng) - self.adjust_tiles_visited(lyr[0], lyr[1], tp._all_visited) + self.adjust_tiles_visited(vstidx, tp._all_visited) # Adjust the tiles visited for one resource - def adjust_tiles_visited(self, tag, value, tiles): - lyridx = -1 - for v in range(0, len(self._tiles_visited)): - if self._tiles_visited[v][0][0] == tag and self._tiles_visited[v][0][1] == value: - lyridx = v - break + def adjust_tiles_visited(self, lyridx, tiles): for t in range(1, len(tiles)): fnd = False @@ -486,7 +481,9 @@ class mstr_orthographic: fnd = True break if fnd == False: - self._tiles_visited[lyridx].append((tiles[t][0], tiles[t][1])) + if tiles[t][0] > 0 and tiles[t][1] > 0: + self._tiles_visited[lyridx].append((tiles[t][0], tiles[t][1])) + # Generates X-Plane 11/12 scenery with # - the finished orthos diff --git a/tileprep.py b/tileprep.py index 41f032f..7e2eed4 100644 --- a/tileprep.py +++ b/tileprep.py @@ -314,26 +314,33 @@ class mstr_tileprep: # sources for every tile, thus evading previous edge detection errors def _placeTileSources(self, mlat, mlng): - # Initial scan "cross" - visited = self._scanConnections((self._tile_v, self._tile_h)) + # Check if this tile was already processed + alr_processed = self._checkVisited(self._already_visited, (self._tile_v, self._tile_h)) - # Recursive scan of initial cross - for v in range(len(visited)): - vst = self._scanConnections((visited[v][0], visited[v][1])) - for l in range(len(vst)): - if self._checkVisited(visited, (vst[l][0], vst[l][1])) == False: visited.append((vst[l][0], vst[l][1])) + # If this is not the case, we can proceed + if alr_processed == False: - self._all_visited = visited - - # We will take the resource of the original tile we have started - # our scan from. If there is nothing, we can choose. - # This is then used for all visited tiles. - tv = self._tile_v - th = self._tile_h - resstring = self._selectResources() - for v in range(0, len(visited)): - self._storeResourceInfo(visited[v][0], visited[v][1], resstring) + # Initial scan "cross" + visited = self._scanConnections((self._tile_v, self._tile_h)) + # Recursive scan of initial cross + for v in range(len(visited)): + vst = self._scanConnections((visited[v][0], visited[v][1])) + for l in range(len(vst)): + if self._checkVisited(visited, (vst[l][0], vst[l][1])) == False: visited.append((vst[l][0], vst[l][1])) + + self._all_visited = visited + + # We will take the resource of the original tile we have started + # our scan from. If there is nothing, we can choose. + # This is then used for all visited tiles. + tv = self._tile_v + th = self._tile_h + + resstring = self._selectResources() + + for v in range(0, len(visited)): + self._storeResourceInfo(visited[v][0], visited[v][1], resstring) # Check if a tile was visited