end
function VoxelArea:getExtent()
+ local MaxEdge, MinEdge = self.MaxEdge, self.MinEdge
return {
- x = self.MaxEdge.x - self.MinEdge.x + 1,
- y = self.MaxEdge.y - self.MinEdge.y + 1,
- z = self.MaxEdge.z - self.MinEdge.z + 1,
+ x = MaxEdge.x - MinEdge.x + 1,
+ y = MaxEdge.y - MinEdge.y + 1,
+ z = MaxEdge.z - MinEdge.z + 1,
}
end
end
function VoxelArea:index(x, y, z)
- local i = (z - self.MinEdge.z) * self.zstride +
- (y - self.MinEdge.y) * self.ystride +
- (x - self.MinEdge.x) + 1
+ local MinEdge = self.MinEdge
+ local i = (z - MinEdge.z) * self.zstride +
+ (y - MinEdge.y) * self.ystride +
+ (x - MinEdge.x) + 1
return math.floor(i)
end
function VoxelArea:indexp(p)
- local i = (p.z - self.MinEdge.z) * self.zstride +
- (p.y - self.MinEdge.y) * self.ystride +
- (p.x - self.MinEdge.x) + 1
+ local MinEdge = self.MinEdge
+ local i = (p.z - MinEdge.z) * self.zstride +
+ (p.y - MinEdge.y) * self.ystride +
+ (p.x - MinEdge.x) + 1
return math.floor(i)
end
function VoxelArea:position(i)
local p = {}
+ local MinEdge = self.MinEdge
i = i - 1
- p.z = math.floor(i / self.zstride) + self.MinEdge.z
+ p.z = math.floor(i / self.zstride) + MinEdge.z
i = i % self.zstride
- p.y = math.floor(i / self.ystride) + self.MinEdge.y
+ p.y = math.floor(i / self.ystride) + MinEdge.y
i = i % self.ystride
- p.x = math.floor(i) + self.MinEdge.x
+ p.x = math.floor(i) + MinEdge.x
return p
end
function VoxelArea:contains(x, y, z)
- return (x >= self.MinEdge.x) and (x <= self.MaxEdge.x) and
- (y >= self.MinEdge.y) and (y <= self.MaxEdge.y) and
- (z >= self.MinEdge.z) and (z <= self.MaxEdge.z)
+ local MaxEdge, MinEdge = self.MaxEdge, self.MinEdge
+ return (x >= MinEdge.x) and (x <= MaxEdge.x) and
+ (y >= MinEdge.y) and (y <= MaxEdge.y) and
+ (z >= MinEdge.z) and (z <= MaxEdge.z)
end
function VoxelArea:containsp(p)
- return (p.x >= self.MinEdge.x) and (p.x <= self.MaxEdge.x) and
- (p.y >= self.MinEdge.y) and (p.y <= self.MaxEdge.y) and
- (p.z >= self.MinEdge.z) and (p.z <= self.MaxEdge.z)
+ local MaxEdge, MinEdge = self.MaxEdge, self.MinEdge
+ return (p.x >= MinEdge.x) and (p.x <= MaxEdge.x) and
+ (p.y >= MinEdge.y) and (p.y <= MaxEdge.y) and
+ (p.z >= MinEdge.z) and (p.z <= MaxEdge.z)
end
function VoxelArea:containsi(i)