Grid.isWithinBoundaries(): allow for boundary padding
This commit is contained in:
parent
c4b9b10b71
commit
f22c3bd798
@ -204,15 +204,18 @@ class Grid:
|
||||
def isCorner(self, pos: Coordinate) -> bool:
|
||||
return pos in self.getCorners()
|
||||
|
||||
def isWithinBoundaries(self, pos: Coordinate) -> bool:
|
||||
def isWithinBoundaries(self, pos: Coordinate, pad: int = 0) -> bool:
|
||||
if self.mode3D:
|
||||
return (
|
||||
self.minX <= pos.x <= self.maxX
|
||||
and self.minY <= pos.y <= self.maxY
|
||||
and self.minZ <= pos.z <= self.maxZ
|
||||
self.minX + pad <= pos.x <= self.maxX - pad
|
||||
and self.minY + pad <= pos.y <= self.maxY - pad
|
||||
and self.minZ + pad <= pos.z <= self.maxZ - pad
|
||||
)
|
||||
else:
|
||||
return self.minX <= pos.x <= self.maxX and self.minY <= pos.y <= self.maxY
|
||||
return (
|
||||
self.minX + pad <= pos.x <= self.maxX - pad
|
||||
and self.minY + pad <= pos.y <= self.maxY - pad
|
||||
)
|
||||
|
||||
def getActiveCells(
|
||||
self, x: int = None, y: int = None, z: int = None
|
||||
|
||||
Loading…
Reference in New Issue
Block a user