clamp source box of extractSchematic
return a schematic of the desired shape filled with air in the parts where there was nothing to extract
This commit is contained in:
parent
584b8a30b4
commit
aa6f39f15f
30
mclevel.py
30
mclevel.py
@ -886,7 +886,10 @@ class MCLevel(object):
|
|||||||
def extractSchematic(self, box):
|
def extractSchematic(self, box):
|
||||||
x,y,z = box.origin
|
x,y,z = box.origin
|
||||||
w,h,l = box.size
|
w,h,l = box.size
|
||||||
|
destX = destY = destZ = 0;
|
||||||
|
|
||||||
if y<0:
|
if y<0:
|
||||||
|
destY -= y
|
||||||
h += y
|
h += y
|
||||||
y = 0;
|
y = 0;
|
||||||
if y+h>self.Height:
|
if y+h>self.Height:
|
||||||
@ -895,13 +898,34 @@ class MCLevel(object):
|
|||||||
|
|
||||||
if h<=0: return
|
if h<=0: return
|
||||||
|
|
||||||
box.origin = x,y,z
|
if self.Width:
|
||||||
box.size = w,h,l
|
if x < 0:
|
||||||
|
destX -= x;
|
||||||
|
x = 0;
|
||||||
|
w += x
|
||||||
|
if x + w > self.Width:
|
||||||
|
w = self.Width - x
|
||||||
|
|
||||||
|
if w <= 0: return
|
||||||
|
|
||||||
|
if z < 0:
|
||||||
|
destZ -= z;
|
||||||
|
z = 0;
|
||||||
|
l += z
|
||||||
|
if z + l > self.Length:
|
||||||
|
l = self.Length - z
|
||||||
|
|
||||||
|
if l <= 0: return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
box = BoundingBox ( (x,y,z), (w,h,l) )
|
||||||
|
|
||||||
|
|
||||||
tempSchematic = MCSchematic(shape=box.size)
|
tempSchematic = MCSchematic(shape=box.size)
|
||||||
tempSchematic.materials = self.materials
|
tempSchematic.materials = self.materials
|
||||||
tempSchematic.copyBlocksFrom(self, box, (0,0,0))
|
tempSchematic.copyBlocksFrom(self, box, (destX, destY, destZ))
|
||||||
return tempSchematic
|
return tempSchematic
|
||||||
|
|
||||||
fromFile = MCLevel.fromFile
|
fromFile = MCLevel.fromFile
|
||||||
|
Reference in New Issue
Block a user