Fix selection renderer rendering anything when selection is zero sized.
IntersectionBox had the wrong logic for one of its components returning None from box_mask All CombinationBoxes have been adjusted.
This commit is contained in:
parent
7ae713ebb2
commit
5de661cab9
@ -131,7 +131,7 @@ class SelectionBox(object):
|
|||||||
""" Iterate through all of the chunk positions within this selection box """
|
""" Iterate through all of the chunk positions within this selection box """
|
||||||
return itertools.product(xrange(self.mincx, self.maxcx), xrange(self.mincz, self.maxcz))
|
return itertools.product(xrange(self.mincx, self.maxcx), xrange(self.mincz, self.maxcz))
|
||||||
|
|
||||||
def sectionPositions(self, cx=0, cz=0):
|
def sectionPositions(self, cx, cz):
|
||||||
""" Iterate through all of the section positions within this chunk"""
|
""" Iterate through all of the section positions within this chunk"""
|
||||||
return range(self.mincy, self.maxcy)
|
return range(self.mincy, self.maxcy)
|
||||||
|
|
||||||
@ -157,6 +157,7 @@ class InvertedBox(SelectionBox):
|
|||||||
def box_mask(self, box):
|
def box_mask(self, box):
|
||||||
return ~self.base.box_mask(box)
|
return ~self.base.box_mask(box)
|
||||||
|
|
||||||
|
|
||||||
class CombinationBox(SelectionBox):
|
class CombinationBox(SelectionBox):
|
||||||
oper = NotImplemented
|
oper = NotImplemented
|
||||||
boundsminoper = NotImplemented
|
boundsminoper = NotImplemented
|
||||||
@ -173,50 +174,76 @@ class CombinationBox(SelectionBox):
|
|||||||
self.maxcz = self.boundsmaxoper(left.maxcz, right.maxcz)
|
self.maxcz = self.boundsmaxoper(left.maxcz, right.maxcz)
|
||||||
|
|
||||||
def __contains__(self, item):
|
def __contains__(self, item):
|
||||||
return self.left.contains(item) or self.right.contains(item)
|
return self.oper(item in self.left, item in self.right)
|
||||||
|
|
||||||
def contains_coords(self, x, y, z):
|
|
||||||
left = self.left.contains_coords(x, y, z)
|
|
||||||
right = self.left.contains_coords(x, y, z)
|
|
||||||
if left is None:
|
|
||||||
return right
|
|
||||||
if right is None:
|
|
||||||
return left
|
|
||||||
return self.oper(left, right)
|
|
||||||
|
|
||||||
def box_mask(self, box):
|
|
||||||
left = self.left.box_mask(box)
|
|
||||||
right = self.right.box_mask(box)
|
|
||||||
if left is None:
|
|
||||||
return right
|
|
||||||
if right is None:
|
|
||||||
return left
|
|
||||||
return self.oper(left, right)
|
|
||||||
|
|
||||||
def sectionPositions(self, cx, cz):
|
def sectionPositions(self, cx, cz):
|
||||||
left = self.left.sectionPositions(cx, cz)
|
left = self.left.sectionPositions(cx, cz)
|
||||||
right = self.right.sectionPositions(cx, cz)
|
right = self.right.sectionPositions(cx, cz)
|
||||||
sections = set()
|
left = set(left)
|
||||||
sections.update(left)
|
right = set(right)
|
||||||
sections.update(right)
|
return self.oper(left, right)
|
||||||
return sorted(sections)
|
|
||||||
|
|
||||||
|
|
||||||
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):
|
||||||
|
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)
|
||||||
|
|
||||||
|
def box_mask(self, box):
|
||||||
|
left = self.left.box_mask(box)
|
||||||
|
right = self.right.box_mask(box)
|
||||||
|
if left is None and right is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return left | right
|
||||||
|
|
||||||
class IntersectionBox(CombinationBox):
|
class IntersectionBox(CombinationBox):
|
||||||
oper = operator.and_
|
oper = operator.and_
|
||||||
boundsminoper = max
|
boundsminoper = max
|
||||||
boundsmaxoper = min
|
boundsmaxoper = min
|
||||||
|
|
||||||
|
def contains_coords(self, x, y, z):
|
||||||
|
left = self.left.contains_coords(x, y, z)
|
||||||
|
if not left:
|
||||||
|
return False
|
||||||
|
|
||||||
|
right = self.right.contains_coords(x, y, z)
|
||||||
|
return self.oper(left, right)
|
||||||
|
|
||||||
|
def box_mask(self, box):
|
||||||
|
left = self.left.box_mask(box)
|
||||||
|
if left is None:
|
||||||
|
return None
|
||||||
|
right = self.right.box_mask(box)
|
||||||
|
if right is None:
|
||||||
|
return None
|
||||||
|
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
|
||||||
boundsmaxoper = lambda a, b: a
|
boundsmaxoper = lambda a, b: a
|
||||||
|
|
||||||
|
def contains_coords(self, x, y, z):
|
||||||
|
left = self.left.contains_coords(x, y, z)
|
||||||
|
if not left:
|
||||||
|
return False
|
||||||
|
right = self.right.contains_coords(x, y, z)
|
||||||
|
return self.oper(left, right)
|
||||||
|
|
||||||
|
def box_mask(self, box):
|
||||||
|
left = self.left.box_mask(box)
|
||||||
|
right = self.right.box_mask(box)
|
||||||
|
if left is None:
|
||||||
|
return None
|
||||||
|
return self.oper(left, right)
|
||||||
|
|
||||||
|
|
||||||
def SectionBox(cx, cy, cz, section=None):
|
def SectionBox(cx, cy, cz, section=None):
|
||||||
if section is None:
|
if section is None:
|
||||||
|
Reference in New Issue
Block a user