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