aboutsummaryrefslogtreecommitdiff
path: root/src/cavegen.h
Commit message (Expand)AuthorAge
* Cavegen: Move V5-style caves to CavesNoiseIntersectionkwolekr2016-05-27
* Cavegen: Minor misc. fixeskwolekr2016-05-27
* Cavegen: Re-add small caves to CavesRandomWalkkwolekr2016-05-27
* Cavegen: Remove CavesRandomWalk dependency on Mapgenkwolekr2016-05-27
* Cavegen: Merge instances of repetitive surface level-finding codekwolekr2016-05-27
* Cavegen: Remove CavesV6 dependency on Mapgenkwolekr2016-05-27
* Cavegen: Rename CaveV6 to CavesV6kwolekr2016-05-27
* Cavegen: Merge CaveV5 and CaveV7 into CavesRandomWalkkwolekr2016-05-27
* Cavegen: Make mgfractal use mgv5 cavegenparamat2015-11-09
* Fractal mapgen: Add seabed and large pseudorandom cavesparamat2015-10-07
* Cavegen V6: Make all caves consistent with 0.4.12 stableparamat2015-08-03
* Cavegen: Mgv6: No small caves entirely above groundparamat2015-07-19
* Cavegen: Cleanup code. Define constant for MGV7_LAVA_DEPTHparamat2015-07-01
* Cavegen, mgv5: Cleanup codeparamat2015-03-04
* Mgv5: Remove blobgen. Remove crumble and wetness noisesparamat2015-02-21
* Shorten ManualMapVoxelManipulator to MMVManipkwolekr2015-01-05
* Mapgen V7: Huge rewrite, also tweaks to cavegen et al.kwolekr2013-07-06
* Cavegen: Prevent caves from occuring above ground level, and superfluous mixi...kwolekr2013-07-01
* Enhance caves for mgv7, add ravineskwolekr2013-04-27
* Class-ify caves & move to cavegen.cpp, fix cave regression, add caves to Mapg...kwolekr2013-04-21
class="hl opt">= e.x o.zstride = e.x * e.y return o end function VoxelArea:getExtent() local MaxEdge, MinEdge = self.MaxEdge, self.MinEdge return { x = MaxEdge.x - MinEdge.x + 1, y = MaxEdge.y - MinEdge.y + 1, z = MaxEdge.z - MinEdge.z + 1, } end function VoxelArea:getVolume() local e = self:getExtent() return e.x * e.y * e.z end function VoxelArea:index(x, y, z) 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 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) + MinEdge.z i = i % self.zstride p.y = math.floor(i / self.ystride) + MinEdge.y i = i % self.ystride p.x = math.floor(i) + MinEdge.x return p end function VoxelArea:contains(x, y, 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) 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) return (i >= 1) and (i <= self:getVolume()) end function VoxelArea:iter(minx, miny, minz, maxx, maxy, maxz) local i = self:index(minx, miny, minz) - 1 local xrange = maxx - minx + 1 local nextaction = i + 1 + xrange local y = 0 local yrange = maxy - miny + 1 local yreqstride = self.ystride - xrange local z = 0 local zrange = maxz - minz + 1 local multistride = self.zstride - ((yrange - 1) * self.ystride + xrange) return function() -- continue i until it needs to jump i = i + 1 if i ~= nextaction then return i end -- continue y until maxy is exceeded y = y + 1 if y ~= yrange then -- set i to index(minx, miny + y, minz + z) - 1 i = i + yreqstride nextaction = i + xrange return i end -- continue z until maxz is exceeded z = z + 1 if z == zrange then -- cuboid finished, return nil return end -- set i to index(minx, miny, minz + z) - 1 i = i + multistride y = 0 nextaction = i + xrange return i end end function VoxelArea:iterp(minp, maxp) return self:iter(minp.x, minp.y, minp.z, maxp.x, maxp.y, maxp.z) end