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):
|
||||
yield 0, len(self.points), "Applying {0} brush...".format(self.brushMode.name)
|
||||
try:
|
||||
#xxx combine selections
|
||||
selections = [self.brushShape.createShapedSelection(self.brushMode.brushBoxForPoint(point, self.options),
|
||||
self.editorSession.currentDimension)
|
||||
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:
|
||||
for i, point in enumerate(self.points):
|
||||
f = self.brushMode.applyToPoint(self, point)
|
||||
|
@ -35,10 +35,11 @@ class BrushMode(QtCore.QObject):
|
||||
"""
|
||||
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
|
||||
by calling
|
||||
Called by BrushCommand to apply this brush mode to the given selection. Selection
|
||||
is generated by calling BrushShape.createShapedSelection and optionally
|
||||
combining multiple selections.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@ -92,13 +93,12 @@ class Fill(BrushMode):
|
||||
def getOptions(self):
|
||||
return {'blockInfo': self.blockTypeButton.block}
|
||||
|
||||
def applyToSelections(self, command, selections):
|
||||
def applyToSelection(self, command, selection):
|
||||
"""
|
||||
|
||||
:type command: BrushCommand
|
||||
"""
|
||||
# xxx combine selections?
|
||||
fill = command.editorSession.currentDimension.fillBlocksIter(selections[0], command.options['blockInfo'])
|
||||
fill = command.editorSession.currentDimension.fillBlocksIter(selection, command.options['blockInfo'])
|
||||
showProgress("Applying brush...", fill)
|
||||
|
||||
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))
|
||||
return self.optionsWidget
|
||||
|
||||
def applyToSelections(self, command, selections):
|
||||
def applyToSelection(self, command, selection):
|
||||
"""
|
||||
|
||||
:type command: BrushCommand
|
||||
"""
|
||||
#task = command.editorSession.currentDimension.fillBlocksIter(selections[0], command.blockInfo)
|
||||
#showProgress("Applying brush...", task)
|
||||
selection = selections[0]
|
||||
# TODO: progress bar, biome fill
|
||||
biomeID = command.options['biomeID']
|
||||
for x, _, z in selection.positions:
|
||||
command.editorSession.currentDimension.setBiomeID(x, z, biomeID)
|
||||
|
Reference in New Issue
Block a user