localmath_max,math_min,math_abs,math_floor,math_pi=math.max,math.min,math.abs,math.floor,math.pi-- avoid needing table lookups each time a common math function is invoked
-- Create a tiling space of close-packed spheres, using Hexagonal close packing
-- of spheres with radius 0.5.
-- With a layer of spheres on a flat surface, if the pack-z distance is 1 due to 0.5
-- radius then the pack-x distance will be the height of an equilateral triangle: sqrt(3) / 2,
-- and the pack-y distance between each layer will be sqrt(6) / 3,
-- The tessellating space will be a rectangular box of 2*pack-x by 1*pack-z by 3*pack-y
localxPack=math.sqrt(3)/2-- 0.866, height of an equalateral triangle
localxPack2=xPack*2-- 1.732
localyPack=math.sqrt(6)/3-- 0.816, y height of each layer
localyPack2=yPack*2
localyPack3=yPack*3
locallayer2offsetx=xPack/3-- 0.289, height to center of equalateral triangle
locallayer3offsetx=xPack2/3-- 0.577
localstructureSize=50-- magic numbers may need retuning if this changes too much
locallayer1={
{0,0,0},
{0,0,1},
{xPack,0,-0.5},
{xPack,0,0.5},
{xPack,0,1.5},
{xPack2,0,0},
{xPack2,0,1},
}
locallayer2={
{layer2offsetx-xPack,yPack,0},
{layer2offsetx-xPack,yPack,1},
{layer2offsetx,yPack,-0.5},
{layer2offsetx,yPack,0.5},
{layer2offsetx,yPack,1.5},
{layer2offsetx+xPack,yPack,0},
{layer2offsetx+xPack,yPack,1},
{layer2offsetx+xPack2,yPack,-0.5},
{layer2offsetx+xPack2,yPack,0.5},
{layer2offsetx+xPack2,yPack,1.5},
}
locallayer3={
{layer3offsetx-xPack,yPack2,-0.5},
{layer3offsetx-xPack,yPack2,0.5},
{layer3offsetx-xPack,yPack2,1.5},
{layer3offsetx,yPack2,0},
{layer3offsetx,yPack2,1},
{layer3offsetx+xPack,yPack2,-0.5},
{layer3offsetx+xPack,yPack2,0.5},
{layer3offsetx+xPack,yPack2,1.5},
{layer3offsetx+xPack2,yPack2,0},
{layer3offsetx+xPack2,yPack2,1},
}
locallayer4={
{0,yPack3,0},
{0,yPack3,1},
{xPack,yPack3,-0.5},
{xPack,yPack3,0.5},
{xPack,yPack3,1.5},
{xPack2,yPack3,0},
{xPack2,yPack3,1},
}
locallayers={
{y=layer1[1][2],points=layer1},-- layer1[1][2] is the y value of the first point in layer1, and all spheres in a layer have the same y
{y=layer2[1][2],points=layer2},
{y=layer3[1][2],points=layer3},
{y=layer4[1][2],points=layer4},
}
-- Geode mapgen functions (AKA proof of secondary/spare region concept)