def buildChunkMeshes(self): """ Rebuild the meshes which render the entire chunk from top to bottom :return: :rtype: """ chunkInfo = self.chunkInfo blockMeshes = self.blockMeshes for cls in self.wholeChunkMeshClasses: if chunkInfo.detailLevel not in cls.detailLevels: #log.info("%s (%s) not in detail levels (%s)", cls.__name__, self.chunkMeshGroup.detailLevel, cls.detailLevels) continue if cls.layer not in chunkInfo.visibleLayers: continue if cls.layer not in chunkInfo.invalidLayers and cls.layer in chunkInfo.renderedLayers: continue chunkMesh = cls(self) chunkMesh.detailLevel = chunkMesh.detailLevel name = cls.__name__ try: worker = chunkMesh.makeChunkVertices(self.chunk, chunkInfo.worldScene.bounds) for _ in profiler.iterate(worker, name): yield except Exception as e: log.exception("Failed rendering for mesh class %s: %s", cls, e) continue blockMeshes.append(chunkMesh) chunkMesh.chunkUpdate = None
def buildChunkMeshes(self): """ Rebuild the meshes which render the entire chunk from top to bottom :return: :rtype: """ chunkInfo = self.chunkInfo blockMeshes = self.blockMeshes for cls in self.wholeChunkMeshClasses: if chunkInfo.detailLevel not in cls.detailLevels: #log.info("%s (%s) not in detail levels (%s)", cls.__name__, self.chunkMeshGroup.detailLevel, cls.detailLevels) continue if cls.layer not in chunkInfo.visibleLayers: continue if cls.layer not in chunkInfo.invalidLayers and cls.layer in chunkInfo.renderedLayers: continue chunkMesh = cls(self) chunkMesh.detailLevel = chunkMesh.detailLevel name = cls.__name__ try: worker = chunkMesh.makeChunkVertices( self.chunk, chunkInfo.worldScene.bounds) for _ in profiler.iterate(worker, name): yield except Exception as e: log.exception("Failed rendering for mesh class %s: %s", cls, e) continue blockMeshes.append(chunkMesh) chunkMesh.chunkUpdate = None
def _loadChunk(self, cPos): if not self.dimension.containsChunk(*cPos): log.debug("Chunk %s is missing!", cPos) return if not any([client.wantsChunk(cPos) for client in self.clients]): log.debug("Chunk %s is unwanted.", cPos) return chunkStartTime = time.time() try: with profiler.context("getChunk"): chunk = self.dimension.getChunk(*cPos) except (EnvironmentError, LevelFormatError) as e: #log.exception(e) log.debug("Chunk %s had an error: %r!", cPos, e) for c in self.clients: if hasattr(c, 'chunkNotLoaded'): c.chunkNotLoaded(cPos, e) else: for c in self.clients: log.debug("Chunk %s -> %s", cPos, c) iterator = profiler.iterate(c.recieveChunk(chunk), "Client %s" % type(c).__name__) if iterator: for _ in iterator: yield self.chunkSamples.append(time.time() - chunkStartTime) self.chunkCompleted.emit()
def _loadChunk(self, cPos): if not self.dimension.containsChunk(*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) for ref in self.clients if ref() is not None]): log.debug("Chunk %s is unwanted.", cPos) return chunkStartTime = time.time() try: with profiler.context("getChunk"): chunk = self.dimension.getChunk(*cPos) except (EnvironmentError, LevelFormatError) as e: #log.exception(e) log.debug("Chunk %s had an error: %r!", cPos, e) for ref in self.clients: client = ref() if client is None: continue if hasattr(client, 'chunkNotLoaded'): client.chunkNotLoaded(cPos, e) else: for ref in self.clients: client = ref() if client is None: continue log.debug("Chunk %s -> %s", cPos, client) iterator = profiler.iterate(client.recieveChunk(chunk), "Client %s" % type(client).__name__) if iterator: for _ in iterator: yield self.chunkSamples.append(time.time() - chunkStartTime) self.chunkCompleted.emit()
def buildChunkMeshes(self): """ Rebuild the meshes which render the entire chunk from top to bottom :return: :rtype: """ chunkInfo = self.chunkInfo blockMeshes = self.blockMeshes existingBlockVertexNodes = sum( [list(node.children) for node in chunkInfo.getChunkVertexNodes()], []) for cls in self.wholeChunkMeshClasses: if chunkInfo.detailLevel not in cls.detailLevels: #log.info("%s (%s) not in detail levels (%s)", cls.__name__, self.chunkMeshGroup.detailLevel, cls.detailLevels) continue if cls.layer not in chunkInfo.visibleLayers: continue if cls.layer not in chunkInfo.invalidLayers: for vertexNode in existingBlockVertexNodes: if vertexNode.meshClass is cls: # xxxxx blockMeshes.append(existingBlockVertexNodes[cls]) continue chunkMesh = cls(self) chunkMesh.detailLevel = chunkMesh.detailLevel name = cls.__name__ worker = chunkMesh.makeChunkVertices(self.chunk, chunkInfo.worldScene.bounds) for _ in profiler.iterate(worker, name): yield blockMeshes.append(chunkMesh) chunkMesh.chunkUpdate = None