Brush command combines multiple selections instead of using the first
This commit is contained in:
parent
d94b807648
commit
91f9dfa560
@ -70,11 +70,11 @@ class BrushCommand(SimplePerformCommand):
|
|||||||
def _perform(self):
|
def _perform(self):
|
||||||
yield 0, len(self.points), "Applying {0} brush...".format(self.brushMode.name)
|
yield 0, len(self.points), "Applying {0} brush...".format(self.brushMode.name)
|
||||||
try:
|
try:
|
||||||
#xxx combine selections
|
|
||||||
selections = [self.brushShape.createShapedSelection(self.brushMode.brushBoxForPoint(point, self.options),
|
selections = [self.brushShape.createShapedSelection(self.brushMode.brushBoxForPoint(point, self.options),
|
||||||
self.editorSession.currentDimension)
|
self.editorSession.currentDimension)
|
||||||
for point in self.points]
|
for point in self.points]
|
||||||
self.brushMode.applyToSelections(self, selections)
|
selection = reduce(lambda a, b: a | b, selections)
|
||||||
|
self.brushMode.applyToSelection(self, selection)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
for i, point in enumerate(self.points):
|
for i, point in enumerate(self.points):
|
||||||
f = self.brushMode.applyToPoint(self, point)
|
f = self.brushMode.applyToPoint(self, point)
|
||||||
|
@ -35,10 +35,11 @@ class BrushMode(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def applyToSelections(self, command, selections):
|
def applyToSelection(self, command, selection):
|
||||||
"""
|
"""
|
||||||
Called by BrushCommand to apply this brush mode to the given selection. Selection is generated
|
Called by BrushCommand to apply this brush mode to the given selection. Selection
|
||||||
by calling
|
is generated by calling BrushShape.createShapedSelection and optionally
|
||||||
|
combining multiple selections.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@ -92,13 +93,12 @@ class Fill(BrushMode):
|
|||||||
def getOptions(self):
|
def getOptions(self):
|
||||||
return {'blockInfo': self.blockTypeButton.block}
|
return {'blockInfo': self.blockTypeButton.block}
|
||||||
|
|
||||||
def applyToSelections(self, command, selections):
|
def applyToSelection(self, command, selection):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:type command: BrushCommand
|
:type command: BrushCommand
|
||||||
"""
|
"""
|
||||||
# xxx combine selections?
|
fill = command.editorSession.currentDimension.fillBlocksIter(selection, command.options['blockInfo'])
|
||||||
fill = command.editorSession.currentDimension.fillBlocksIter(selections[0], command.options['blockInfo'])
|
|
||||||
showProgress("Applying brush...", fill)
|
showProgress("Applying brush...", fill)
|
||||||
|
|
||||||
def brushBoxForPoint(self, point, options):
|
def brushBoxForPoint(self, point, options):
|
||||||
@ -139,14 +139,12 @@ class Biome(BrushMode):
|
|||||||
self.optionsWidget.setLayout(Column(Row(label, self.biomeTypeBox, margin=0), None, margin=0))
|
self.optionsWidget.setLayout(Column(Row(label, self.biomeTypeBox, margin=0), None, margin=0))
|
||||||
return self.optionsWidget
|
return self.optionsWidget
|
||||||
|
|
||||||
def applyToSelections(self, command, selections):
|
def applyToSelection(self, command, selection):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:type command: BrushCommand
|
:type command: BrushCommand
|
||||||
"""
|
"""
|
||||||
#task = command.editorSession.currentDimension.fillBlocksIter(selections[0], command.blockInfo)
|
# TODO: progress bar, biome fill
|
||||||
#showProgress("Applying brush...", task)
|
|
||||||
selection = selections[0]
|
|
||||||
biomeID = command.options['biomeID']
|
biomeID = command.options['biomeID']
|
||||||
for x, _, z in selection.positions:
|
for x, _, z in selection.positions:
|
||||||
command.editorSession.currentDimension.setBiomeID(x, z, biomeID)
|
command.editorSession.currentDimension.setBiomeID(x, z, biomeID)
|
||||||
|
Reference in New Issue
Block a user