{
public struct ColumnCounter
{
- public bool NewOrLoaded;
- public byte[] EditTally;
+ private bool NewOrLoaded;
+ private byte[] EditTally;
+ private byte HeightCutoff; //CHUNK #
public uint WeightedSum
{
get
- {//TODO: Rank deduction for lower chunks
- return ( uint )(EditTally.Sum(ed => ed)) + (NewOrLoaded ? 100u : 0u);
+ {//TODO: Rank ZERO for deep sub-surface chunks
+ return ( uint )(EditTally.Skip(HeightCutoff - 1).Sum(ed => ed)) + (NewOrLoaded ? 100u : 0u);
}
}
{
NewOrLoaded = false;
EditTally = new byte[chunkSize];
+ HeightCutoff = 0;
}
public ColumnCounter(int chunkSize, bool editLoaded)
{
NewOrLoaded = editLoaded;
EditTally = new byte[chunkSize];
+ HeightCutoff = 0;
}
public ColumnCounter(int chunkSize, bool editLoaded, Vec3i chunkCoord)
EditTally = new byte[chunkSize];
EditTally[chunkY]++;
+ HeightCutoff = ( byte )chunkY;
}
public ColumnCounter Update(Vec3i chunkCoord, int chunkSize, bool partlyNewOrLoaded = false)
{
int chunkY = chunkCoord.Y % chunkSize;
- EditTally[chunkY]++;
- if (partlyNewOrLoaded) NewOrLoaded = true;;
+ if (EditTally[chunkY] < Byte.MaxValue) EditTally[chunkY]++;
+ if (partlyNewOrLoaded) NewOrLoaded = true;
return this;
}
+ public void SetCutoff(int height)
+ {
+
+ HeightCutoff = ( byte )height;
+
+ }
+
public override string ToString( )
{
- return $"{(NewOrLoaded?'N':'O')} W:{WeightedSum}";
+ return $"{(NewOrLoaded?"NEW":"Old")} W:{WeightedSum}";
}
}
}
}
// Prefetch map chunks, in pattern
- var corner_pos = new Vec2i(chunkPos.X - 1, chunkPos.Y + 1);
+ var corner_pos = new Vec2i(chunkPos.X - 1, chunkPos.Y - 1);
var west_pos = new Vec2i(chunkPos.X - 1, chunkPos.Y);
- var north_pos = new Vec2i(chunkPos.X, chunkPos.Y + 1);
+ var north_pos = new Vec2i(chunkPos.X, chunkPos.Y - 1);
+
+ uint missingRainmap = 0, missingHeightmap = 0;
ColumnMeta north, northWest, west;
/*
overlapHeightmap[0, 0] = northWest.HeightMap[chunkSize - 1, chunkSize - 1];
}
else {
+ missingHeightmap++;
var cornerMC = ClientAPI.World.BlockAccessor.GetMapChunk(corner_pos);
if (cornerMC != null && cornerMC.RainHeightMap != null)
{
- overlapHeightmap[0, 0] = cornerMC.RainHeight2DMap(chunkSize - 1, (chunkSize - 1) );
- }
- }
+ overlapHeightmap[0, 0] = cornerMC.RainHeight2DMap(chunkSize - 1, (chunkSize - 1));
+ } else missingRainmap++;
+ }
if (allCols.Contains(north_pos) && allCols[north_pos].HeightMap != null) {
north = allCols[north_pos];
for (int northEdgeIndex = 0; northEdgeIndex < chunkSize; northEdgeIndex++)
{
- overlapHeightmap[1, northEdgeIndex + 1 ] = north.HeightMap[ (chunkSize - 1), northEdgeIndex];
+ overlapHeightmap[0, northEdgeIndex + 1 ] = north.HeightMap[ (chunkSize - 1), northEdgeIndex];
}
}
else {
+ missingHeightmap++;
var northMC = ClientAPI.World.BlockAccessor.GetMapChunk(north_pos);
if (northMC != null && northMC.RainHeightMap != null) {
for (int northEdgeIndex = 0; northEdgeIndex < chunkSize; northEdgeIndex++)
{
- overlapHeightmap[1, northEdgeIndex + 1] = northMC.RainHeight2DMap((chunkSize - 1), northEdgeIndex);
+ overlapHeightmap[0, northEdgeIndex + 1] = northMC.RainHeight2DMap((chunkSize - 1), northEdgeIndex);
}
- }
+ } else missingRainmap++;
}
if (allCols.Contains(west_pos) && allCols[west_pos].HeightMap != null) {
}
}
else {
+ missingHeightmap++;
var westMC = ClientAPI.World.BlockAccessor.GetMapChunk(west_pos);
if (westMC != null && westMC.RainHeightMap != null) {
- for (int westEdgeIndex = 0; westEdgeIndex < chunkSize; westEdgeIndex++) {
- overlapHeightmap[westEdgeIndex + 1, 0] = westMC.RainHeight2DMap(westEdgeIndex, chunkSize - 1);
- }
+ for (int westEdgeIndex = 0; westEdgeIndex < chunkSize; westEdgeIndex++) {
+ overlapHeightmap[westEdgeIndex + 1, 0] = westMC.RainHeight2DMap(westEdgeIndex, chunkSize - 1);
}
+ } else missingRainmap++;
}
- var avgOverlap_Y = overlapHeightmap.OfType<ushort>( ).Average((ushort sel) => sel == 0 ? targetColMeta.YMax : sel);
+ ushort avgOverlap_Y = ( ushort )overlapHeightmap.OfType<ushort>( ).Average((ushort sel) => sel == 0 ? targetColMeta.YMax : sel);
//TODO: Row - then - Column averaging at Edges?
-
- // if (height == 0) height = ( ushort )avgOverlap_Y;
+
+ #if DEBUG
+ var badHeightData = overlapHeightmap.OfType<ushort>( ).Count((ushort arg) => arg == 0);
+
+ if (badHeightData > 0)
+ Logger.VerboseDebug("H.M Zeros# {0} , Missing Rainmaps {1} Heightmaps {2}",badHeightData ,missingRainmap, missingHeightmap);
+ #endif
int up_X = localX;
int low_X = localX + 1;
int left_Z = localZ;
- int right_Z = localZ + 1;
-
+ int right_Z = localZ + 1;
+
//topX = GameMath.Mod(topX, chunkSize + 1);
- //leftZ = GameMath.Mod(leftZ, chunkSize + 1);
+ //leftZ = GameMath.Mod(leftZ, chunkSize + 1);
- leftTop = Math.Sign(localY - overlapHeightmap[up_X, left_Z]);
- rightTop = Math.Sign(localY - overlapHeightmap[up_X, right_Z]);
- leftBot = Math.Sign(localY - overlapHeightmap[low_X, left_Z]);
+ leftTop = Math.Sign(localY - (overlapHeightmap[up_X, left_Z] == 0 ? avgOverlap_Y : overlapHeightmap[up_X, left_Z]));
+ rightTop = Math.Sign(localY - (overlapHeightmap[up_X, right_Z]== 0 ? avgOverlap_Y : overlapHeightmap[up_X, right_Z]));
+ leftBot = Math.Sign(localY - (overlapHeightmap[low_X, left_Z]== 0 ? avgOverlap_Y : overlapHeightmap[low_X, left_Z]));
float slopeness = (leftTop + rightTop + leftBot);
internal const string _mapPath = @"Maps";
internal const string _chunkPath = @"Chunks";
- internal const uint editThreshold = 1;
+ internal const uint editThreshold = 9;
private const string _domain = @"automap";
private const string chunkFile_filter = @"*_*.png";
private const string poiFileName = @"poi_binary";
#endif
}
ProcessChunkBlocks(mostActiveCol.Key, mapChunk, ref chunkMeta);
+ mostActiveCol.Value.SetCutoff(chunkMeta.YMax / chunkSize);
ChunkRenderer.SetupPngImage(mostActiveCol.Key, path, _chunkPath, ref chunkMeta);
ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, ref chunkTopMetadata, out updatedPixels);
var airBlocksQuery = from airyBlock in ClientAPI.World.Blocks
where airyBlock.MatterState == EnumMatterState.Solid
where airyBlock.BlockMaterial == EnumBlockMaterial.Plant || airyBlock.BlockMaterial == EnumBlockMaterial.Leaves
- where airyBlock.CollisionBoxes == null || airyBlock.CollisionBoxes.Length == 0
+ where airyBlock.CollisionBoxes == null || airyBlock.CollisionBoxes.Length == 0 ||airyBlock.RainPermeable == true
select airyBlock;
//^^ 'Solid' phase - 'Plant' Blocks without any boundg box ? Except water...
this.AiryIdCodes = airBlocksQuery.ToDictionary(aBlk => aBlk.BlockId, aBlk => aBlk.Code.Path);