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:
parent
7bdcd2c044
commit
0b1f47c2b9
@ -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?
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user