WorldLoader now has a startLoader function with a minimum duration.

The minimum duration tells how long to load chunks immediately before starting the async loader.
This commit is contained in:
David Vierra 2015-10-06 17:12:32 -10:00
parent 7bdcd2c044
commit 0b1f47c2b9
5 changed files with 12 additions and 5 deletions

View File

@ -220,7 +220,7 @@ class BrushTool(EditorTool):
self.cursorNode.addChild(self.cursorBoxNode)
self.brushLoader = WorldLoader(self.cursorWorldScene)
self.brushLoader.timer.start()
self.brushLoader.startLoader()
# xxx button palette?

View File

@ -412,7 +412,7 @@ class GenerateTool(EditorTool):
if dim.chunkCount() <= self.instantDisplayChunks:
exhaust(self.loader.work())
else:
self.loader.timer.start()
self.loader.startLoader()
else:
self.clearSchematic()

View File

@ -161,7 +161,7 @@ class PendingImportNode(Node, QtCore.QObject):
self.loader = WorldLoader(self.worldScene,
list(pendingImport.selection.chunkPositions()))
self.loader.timer.start()
self.loader.startLoader()
def handleBoundsChanged(self, bounds):
self.pos = bounds.origin
@ -202,7 +202,7 @@ class PendingImportNode(Node, QtCore.QObject):
cPos = list(self.pendingImport.transformedDim.chunkPositions())
self.loader = WorldLoader(self.transformedWorldScene,
cPos)
self.loader.timer.start()
self.loader.startLoader()
else:
self.rotateNode.visible = True

View File

@ -6,6 +6,7 @@ import contextlib
import logging
import weakref
from PySide import QtCore
import time
from mcedit2.util import profiler
log = logging.getLogger(__name__)
@ -56,6 +57,12 @@ class WorldLoader(object):
self.chunkPositions = chunkPositions
self.chunkIter = self.work()
def startLoader(self, duration=0.12):
self.timer.start()
start = time.time()
while time.time() < start + duration:
self.loadChunk()
def loadChunk(self):
try:
self.chunkIter.next()

View File

@ -85,8 +85,8 @@ def displaySchematic(schematic):
_swv_view = SchematicWorldView(dim, textureAtlas)
loader = WorldLoader(_swv_view.worldScene)
loader.timer.start()
loader.timer.timeout.connect(_swv_view.update)
loader.startLoader()
centerWidgetInScreen(_swv_view, resize=0.75)