Add chunkNotPresent to ChunkLoader, WorldView, WorldScene
This commit is contained in:
parent
891bb6db2f
commit
3c56b0f7fd
@ -79,6 +79,14 @@ class IChunkLoaderClient(object):
|
||||
:param exc: The exception that was thrown, usually IOError or LevelFormatError
|
||||
"""
|
||||
|
||||
def chunkNotPresent(self, (cx, cz)):
|
||||
"""
|
||||
Called when a chunk fails to load because it is not present in the world.
|
||||
|
||||
Notifies each client of the chunk's position.
|
||||
|
||||
:param (cx, cz): chunk position
|
||||
"""
|
||||
|
||||
class ChunkLoader(QtCore.QObject):
|
||||
chunkCompleted = QtCore.Signal()
|
||||
@ -203,7 +211,12 @@ class ChunkLoader(QtCore.QObject):
|
||||
def _loadChunk(self, cPos):
|
||||
|
||||
if not self.dimension.containsChunk(*cPos):
|
||||
log.debug("Chunk %s is missing!", cPos)
|
||||
for ref in self.clients:
|
||||
client = ref()
|
||||
if client is None:
|
||||
continue
|
||||
if hasattr(client, 'chunkNotPresent'):
|
||||
client.chunkNotPresent(cPos)
|
||||
return
|
||||
|
||||
if not any([ref().wantsChunk(cPos)
|
||||
|
@ -143,8 +143,14 @@ class SceneUpdateTask(object):
|
||||
groupNode.discardChunkNode(*cPos)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception(u"Rendering chunk %s failed: %r", cPos, e)
|
||||
log.exception(u"Rendering chunk %s failed: %r", cPos, e)
|
||||
|
||||
def chunkNotPresent(self, (cx, cz)):
|
||||
log.info("Chunk removed: %s", (cx, cz))
|
||||
# Assume chunk was deleted by the user
|
||||
for renderstate in renderstates.allRenderstates:
|
||||
groupNode = self.worldScene.getRenderstateGroup(renderstate)
|
||||
groupNode.discardChunkNode(cx, cz)
|
||||
|
||||
class WorldScene(scenegraph.Node):
|
||||
def __init__(self, dimension, textureAtlas=None, geometryCache=None, bounds=None):
|
||||
@ -270,6 +276,9 @@ class WorldScene(scenegraph.Node):
|
||||
def workOnChunk(self, chunk, visibleSections=None):
|
||||
return self.updateTask.workOnChunk(chunk, visibleSections)
|
||||
|
||||
def chunkNotPresent(self, cPos):
|
||||
self.updateTask.chunkNotPresent(cPos)
|
||||
|
||||
def getChunkRenderInfo(self, cPos):
|
||||
chunkInfo = self.chunkRenderInfo.get(cPos)
|
||||
if chunkInfo is None:
|
||||
|
@ -96,6 +96,7 @@ class SlicedWorldScene(scenegraph.Node):
|
||||
loadRadius = 320
|
||||
|
||||
_pos = 0
|
||||
|
||||
@property
|
||||
def pos(self):
|
||||
return self._pos
|
||||
@ -154,6 +155,10 @@ class SlicedWorldScene(scenegraph.Node):
|
||||
def wantsChunk(self, c):
|
||||
return any([mesh.wantsChunk(c) for mesh in self.sliceScenes.itervalues()])
|
||||
|
||||
def chunkNotPresent(self, cPos):
|
||||
for mesh in self.sliceScenes.itervalues():
|
||||
mesh.chunkNotPresent(cPos)
|
||||
|
||||
@profiler.iterator("SlicedMesh")
|
||||
def workOnChunk(self, c, sections=None):
|
||||
for i, mesh in self.sliceScenes.iteritems():
|
||||
|
@ -585,6 +585,11 @@ class WorldView(QGLWidget):
|
||||
|
||||
return True
|
||||
|
||||
def chunkNotPresent(self, cPos):
|
||||
log.info("Chunk not present: %s", cPos)
|
||||
self.worldScene.chunkNotPresent(cPos)
|
||||
self.loadableChunksNode.dirty = True # gross.
|
||||
|
||||
def recieveChunk(self, chunk):
|
||||
t = time.time()
|
||||
if self.lastAutoUpdate + self.autoUpdateInterval < t:
|
||||
|
Reference in New Issue
Block a user