using System;
using System.Collections.Generic;
+//using System.Drawing;
+//using System.Drawing.Imaging;
+//using System.IO;
using System.Linq;
using Hjg.Pngcs;
// Prefetch map chunks, in pattern
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 west_pos = new Vec2i(chunkPos.X, chunkPos.Y - 1);
+ var north_pos = new Vec2i(chunkPos.X - 1 , chunkPos.Y);
uint missingRainmap = 0, missingHeightmap = 0;
if (badHeightData > 0)
Logger.VerboseDebug("H.M Zeros# {0} , Missing Rainmaps {1} Heightmaps {2}",badHeightData ,missingRainmap, missingHeightmap);
+
+ //RenderDebugBitmap(overlapHeightmap, chunkPos);
#endif
int west_Z = localZ + 1;
int northWest_X = localX;
int northWest_Z = localZ;
-
+ bool edge = localX == 0 || localZ == 0;
- northH = Math.Sign(localY - (overlapHeightmap[north_X, north_Z] == 0 ? avgOverlap_Y : overlapHeightmap[north_X, north_Z]));
- northWestH = Math.Sign(localY - (overlapHeightmap[northWest_X, northWest_Z] == 0 ? avgOverlap_Y : overlapHeightmap[northWest_X, northWest_Z]));
- westH = Math.Sign(localY - (overlapHeightmap[west_X, west_Z] == 0 ? avgOverlap_Y : overlapHeightmap[west_X, west_Z]));
+ northH = Math.Sign(localY - (overlapHeightmap[north_X, north_Z] == 0 ? localY : overlapHeightmap[north_X, north_Z]));
+ northWestH = Math.Sign(localY - (overlapHeightmap[northWest_X, northWest_Z] == 0 ? localY : overlapHeightmap[northWest_X, northWest_Z]));
+ westH = Math.Sign(localY - (overlapHeightmap[west_X, west_Z] == 0 ? localY : overlapHeightmap[west_X, west_Z]));
float slopeness = (northH + northWestH + westH);
+ float tolerance = edge ? 2.0f : 0f;
+
- if (slopeness > 0) slopeBoost = 1.2f;
- if (slopeness < 0) slopeBoost = 0.8f;
+ if (slopeness > tolerance) slopeBoost = 1.2f;
+ if (slopeness < tolerance) slopeBoost = 0.8f;
if (Math.Abs(slopeness) <= float.Epsilon) slopeBoost = 1.0f;//Same height
//slopeBoost -= 0.15f; //Slope boost value
this.PngWriter.End( );
}
+
+ /*
+ private void RenderDebugBitmap( ushort[ , ] heightmap, Vec2i chunkOrigin )
+ {
+ Bitmap mapBitmap = null;
+ Graphics gContext = null;
+ mapBitmap = new Bitmap(33, 33, PixelFormat.Format24bppRgb);
+ gContext = Graphics.FromImage(mapBitmap);
+
+ for (int x = 0; x <= chunkSize; x++) {
+ for (int y = 0; y <= chunkSize; y++) {
+ ushort heightCol = heightmap[x, y];
+ Color color= Color.FromArgb((byte)heightCol,( byte )heightCol,( byte )heightCol);
+ mapBitmap.SetPixel(x, y, color);
+ }
+ }
+
+ gContext.Flush(System.Drawing.Drawing2D.FlushIntention.Sync);
+
+ var fileName = Path.Combine( ClientAPI.GetOrCreateDataPath("Heightmaps"),$"offhm_{chunkOrigin.X}-{chunkOrigin.Y}.png");
+ mapBitmap.Save(fileName, ImageFormat.Png);
+
+ }
+ */
}
}
\ No newline at end of file