Rewrite UnionBox.contains_coords for subselection list
This commit is contained in:
parent
f3ff47a445
commit
5683804ab8
@ -170,8 +170,8 @@ class SelectionBox(object):
|
||||
def chunkCount(self):
|
||||
return (self.maxcx - self.mincx) * (self.maxcz - self.mincz)
|
||||
|
||||
class InvertedBox(SelectionBox):
|
||||
|
||||
class InvertedBox(SelectionBox):
|
||||
def __init__(self, base):
|
||||
super(InvertedBox, self).__init__()
|
||||
self.base = base
|
||||
@ -216,17 +216,15 @@ class CombinationBox(SelectionBox):
|
||||
|
||||
return reduce(self.oper, positionLists)
|
||||
|
||||
|
||||
class UnionBox(CombinationBox):
|
||||
oper = operator.or_
|
||||
boundsminoper = min
|
||||
boundsmaxoper = max
|
||||
|
||||
def contains_coords(self, x, y, z):
|
||||
left = self.left.contains_coords(x, y, z)
|
||||
if left:
|
||||
return True
|
||||
right = self.right.contains_coords(x, y, z)
|
||||
return self.oper(left, right)
|
||||
contains = [s.contains_coords(x, y, z) for s in self.selections]
|
||||
return reduce(self.oper, contains, False)
|
||||
|
||||
def box_mask(self, box):
|
||||
masks = [s.box_mask(box) for s in self.selections]
|
||||
@ -241,6 +239,7 @@ class UnionBox(CombinationBox):
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class IntersectionBox(CombinationBox):
|
||||
oper = operator.and_
|
||||
boundsminoper = max
|
||||
@ -263,6 +262,7 @@ class IntersectionBox(CombinationBox):
|
||||
return None
|
||||
return self.oper(left, right)
|
||||
|
||||
|
||||
class DifferenceBox(CombinationBox):
|
||||
oper = lambda a, b: a & (~b)
|
||||
boundsminoper = lambda a, b: a
|
||||
|
Reference in New Issue
Block a user