MCPcopy Create free account
hub / github.com/DFHack/dfhack / adjust_layer_depth

Method adjust_layer_depth

plugins/3dveins.cpp:818–909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816}
817
818bool VeinGenerator::adjust_layer_depth(df::coord2d column)
819{
820 for (auto it = biomes.begin(); it != biomes.end(); ++it)
821 {
822 GeoBiome *biome = it->second;
823 auto &col_info = biome->columns(column);
824
825 for (int x = 0; x < 16; x++)
826 {
827 for (int y = 0; y < 16; y++)
828 {
829 auto &max_level = col_info.max_level[x][y];
830 auto &min_level = col_info.min_level[x][y];
831 auto top_solid = col_info.top_solid_z[x][y];
832
833 int min_defined = col_info.top_layer[x][y];
834 int max_defined = col_info.bottom_layer[x][y];
835 if (max_defined < 0)
836 continue;
837
838 int last_top = min_defined;
839
840 // Verify assumptions
841 for (int i = min_defined; i < max_defined; i++)
842 {
843 if (max_level[i] >= top_solid)
844 last_top = i;
845
846 if (max_level[i+1] < 0 && min_level[i] > top_solid)
847 max_level[i+1] = min_level[i+1] = min_level[i];
848
849 if (max_level[i+1] > top_solid)
850 continue;
851
852 if (max_level[i+1] != min_level[i]-1)
853 {
854 WARN(process, out).print(
855 "Gap or overlap with next layer {} at ({} {} {}-{}).\n",
856 i+1, x+column.x*16, y+column.y*16, max_level[i+1], min_level[i]
857 );
858 return false;
859 }
860 }
861
862 for (int i = min_defined; i < max_defined; i++)
863 {
864 auto layer = biome->layers[i];
865 int size = max_level[i]-min_level[i]+1;
866
867 if (size == layer->thickness)
868 continue;
869
870 // Adjust the top layers so that the bottom of the layer maps to the correct place
871 if (max_level[i] >= top_solid)
872 {
873 max_level[i] += layer->thickness - size;
874
875 if (size > layer->thickness)

Callers

nothing calls this directly

Calls 4

setZBiasMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected