• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Automap (client) [VS plugin mod]


Commit MetaInfo

Revision8958039090797fadd178f3c433390b2affb40827 (tree)
Time2021-05-19 04:27:30
Authormelchior <melchior@user...>
Commitermelchior

Log Message

W.I.P. fixed positioning errors, various tweaks

Change Summary

Incremental Difference

--- a/Automap/Data/ColumnCounter.cs
+++ b/Automap/Data/ColumnCounter.cs
@@ -7,14 +7,15 @@ namespace Automap
77 {
88 public struct ColumnCounter
99 {
10- public bool NewOrLoaded;
11- public byte[] EditTally;
10+ private bool NewOrLoaded;
11+ private byte[] EditTally;
12+ private byte HeightCutoff; //CHUNK #
1213
1314 public uint WeightedSum
1415 {
1516 get
16- {//TODO: Rank deduction for lower chunks
17- return ( uint )(EditTally.Sum(ed => ed)) + (NewOrLoaded ? 100u : 0u);
17+ {//TODO: Rank ZERO for deep sub-surface chunks
18+ return ( uint )(EditTally.Skip(HeightCutoff - 1).Sum(ed => ed)) + (NewOrLoaded ? 100u : 0u);
1819 }
1920 }
2021
@@ -22,12 +23,14 @@ namespace Automap
2223 {
2324 NewOrLoaded = false;
2425 EditTally = new byte[chunkSize];
26+ HeightCutoff = 0;
2527 }
2628
2729 public ColumnCounter(int chunkSize, bool editLoaded)
2830 {
2931 NewOrLoaded = editLoaded;
3032 EditTally = new byte[chunkSize];
33+ HeightCutoff = 0;
3134 }
3235
3336 public ColumnCounter(int chunkSize, bool editLoaded, Vec3i chunkCoord)
@@ -38,20 +41,28 @@ namespace Automap
3841 EditTally = new byte[chunkSize];
3942
4043 EditTally[chunkY]++;
44+ HeightCutoff = ( byte )chunkY;
4145 }
4246
4347 public ColumnCounter Update(Vec3i chunkCoord, int chunkSize, bool partlyNewOrLoaded = false)
4448 {
4549 int chunkY = chunkCoord.Y % chunkSize;
46- EditTally[chunkY]++;
47- if (partlyNewOrLoaded) NewOrLoaded = true;;
50+ if (EditTally[chunkY] < Byte.MaxValue) EditTally[chunkY]++;
51+ if (partlyNewOrLoaded) NewOrLoaded = true;
4852
4953 return this;
5054 }
5155
56+ public void SetCutoff(int height)
57+ {
58+
59+ HeightCutoff = ( byte )height;
60+
61+ }
62+
5263 public override string ToString( )
5364 {
54- return $"{(NewOrLoaded?'N':'O')} W:{WeightedSum}";
65+ return $"{(NewOrLoaded?"NEW":"Old")} W:{WeightedSum}";
5566 }
5667 }
5768 }
--- a/Automap/Helpers.cs
+++ b/Automap/Helpers.cs
@@ -96,7 +96,8 @@ namespace Automap
9696
9797 public static ushort RainHeight2DMap(this IMapChunk mapChunk, int x, int y, int chunkSize = 32)
9898 {
99- int index = y % chunkSize * chunkSize + x % chunkSize;
99+ //int num = posZ % this.chunksize * this.chunksize + posX % this.chunksize;
100+ int index = (y % chunkSize) * chunkSize + (x % chunkSize);
100101 return mapChunk.RainHeightMap[index];
101102 }
102103
--- a/Automap/Renderers/StandardRenderer.cs
+++ b/Automap/Renderers/StandardRenderer.cs
@@ -51,9 +51,11 @@ namespace Automap
5151 }
5252
5353 // Prefetch map chunks, in pattern
54- var corner_pos = new Vec2i(chunkPos.X - 1, chunkPos.Y + 1);
54+ var corner_pos = new Vec2i(chunkPos.X - 1, chunkPos.Y - 1);
5555 var west_pos = new Vec2i(chunkPos.X - 1, chunkPos.Y);
56- var north_pos = new Vec2i(chunkPos.X, chunkPos.Y + 1);
56+ var north_pos = new Vec2i(chunkPos.X, chunkPos.Y - 1);
57+
58+ uint missingRainmap = 0, missingHeightmap = 0;
5759
5860 ColumnMeta north, northWest, west;
5961 /*
@@ -77,29 +79,31 @@ namespace Automap
7779 overlapHeightmap[0, 0] = northWest.HeightMap[chunkSize - 1, chunkSize - 1];
7880 }
7981 else {
82+ missingHeightmap++;
8083 var cornerMC = ClientAPI.World.BlockAccessor.GetMapChunk(corner_pos);
8184 if (cornerMC != null && cornerMC.RainHeightMap != null)
8285 {
83- overlapHeightmap[0, 0] = cornerMC.RainHeight2DMap(chunkSize - 1, (chunkSize - 1) );
84- }
85- }
86+ overlapHeightmap[0, 0] = cornerMC.RainHeight2DMap(chunkSize - 1, (chunkSize - 1));
87+ } else missingRainmap++;
88+ }
8689
8790 if (allCols.Contains(north_pos) && allCols[north_pos].HeightMap != null) {
8891 north = allCols[north_pos];
8992
9093 for (int northEdgeIndex = 0; northEdgeIndex < chunkSize; northEdgeIndex++)
9194 {
92- overlapHeightmap[1, northEdgeIndex + 1 ] = north.HeightMap[ (chunkSize - 1), northEdgeIndex];
95+ overlapHeightmap[0, northEdgeIndex + 1 ] = north.HeightMap[ (chunkSize - 1), northEdgeIndex];
9396 }
9497 }
9598 else {
99+ missingHeightmap++;
96100 var northMC = ClientAPI.World.BlockAccessor.GetMapChunk(north_pos);
97101 if (northMC != null && northMC.RainHeightMap != null) {
98102 for (int northEdgeIndex = 0; northEdgeIndex < chunkSize; northEdgeIndex++)
99103 {
100- overlapHeightmap[1, northEdgeIndex + 1] = northMC.RainHeight2DMap((chunkSize - 1), northEdgeIndex);
104+ overlapHeightmap[0, northEdgeIndex + 1] = northMC.RainHeight2DMap((chunkSize - 1), northEdgeIndex);
101105 }
102- }
106+ } else missingRainmap++;
103107 }
104108
105109 if (allCols.Contains(west_pos) && allCols[west_pos].HeightMap != null) {
@@ -111,18 +115,24 @@ namespace Automap
111115 }
112116 }
113117 else {
118+ missingHeightmap++;
114119 var westMC = ClientAPI.World.BlockAccessor.GetMapChunk(west_pos);
115120 if (westMC != null && westMC.RainHeightMap != null) {
116- for (int westEdgeIndex = 0; westEdgeIndex < chunkSize; westEdgeIndex++) {
117- overlapHeightmap[westEdgeIndex + 1, 0] = westMC.RainHeight2DMap(westEdgeIndex, chunkSize - 1);
118- }
121+ for (int westEdgeIndex = 0; westEdgeIndex < chunkSize; westEdgeIndex++) {
122+ overlapHeightmap[westEdgeIndex + 1, 0] = westMC.RainHeight2DMap(westEdgeIndex, chunkSize - 1);
119123 }
124+ } else missingRainmap++;
120125 }
121126
122- var avgOverlap_Y = overlapHeightmap.OfType<ushort>( ).Average((ushort sel) => sel == 0 ? targetColMeta.YMax : sel);
127+ ushort avgOverlap_Y = ( ushort )overlapHeightmap.OfType<ushort>( ).Average((ushort sel) => sel == 0 ? targetColMeta.YMax : sel);
123128 //TODO: Row - then - Column averaging at Edges?
124-
125- // if (height == 0) height = ( ushort )avgOverlap_Y;
129+
130+ #if DEBUG
131+ var badHeightData = overlapHeightmap.OfType<ushort>( ).Count((ushort arg) => arg == 0);
132+
133+ if (badHeightData > 0)
134+ Logger.VerboseDebug("H.M Zeros# {0} , Missing Rainmaps {1} Heightmaps {2}",badHeightData ,missingRainmap, missingHeightmap);
135+ #endif
126136
127137
128138
@@ -154,14 +164,14 @@ namespace Automap
154164 int up_X = localX;
155165 int low_X = localX + 1;
156166 int left_Z = localZ;
157- int right_Z = localZ + 1;
158-
167+ int right_Z = localZ + 1;
168+
159169 //topX = GameMath.Mod(topX, chunkSize + 1);
160- //leftZ = GameMath.Mod(leftZ, chunkSize + 1);
170+ //leftZ = GameMath.Mod(leftZ, chunkSize + 1);
161171
162- leftTop = Math.Sign(localY - overlapHeightmap[up_X, left_Z]);
163- rightTop = Math.Sign(localY - overlapHeightmap[up_X, right_Z]);
164- leftBot = Math.Sign(localY - overlapHeightmap[low_X, left_Z]);
172+ leftTop = Math.Sign(localY - (overlapHeightmap[up_X, left_Z] == 0 ? avgOverlap_Y : overlapHeightmap[up_X, left_Z]));
173+ rightTop = Math.Sign(localY - (overlapHeightmap[up_X, right_Z]== 0 ? avgOverlap_Y : overlapHeightmap[up_X, right_Z]));
174+ leftBot = Math.Sign(localY - (overlapHeightmap[low_X, left_Z]== 0 ? avgOverlap_Y : overlapHeightmap[low_X, left_Z]));
165175
166176 float slopeness = (leftTop + rightTop + leftBot);
167177
--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -33,7 +33,7 @@ namespace Automap
3333
3434 internal const string _mapPath = @"Maps";
3535 internal const string _chunkPath = @"Chunks";
36- internal const uint editThreshold = 1;
36+ internal const uint editThreshold = 9;
3737 private const string _domain = @"automap";
3838 private const string chunkFile_filter = @"*_*.png";
3939 private const string poiFileName = @"poi_binary";
@@ -227,6 +227,7 @@ namespace Automap
227227 #endif
228228 }
229229 ProcessChunkBlocks(mostActiveCol.Key, mapChunk, ref chunkMeta);
230+ mostActiveCol.Value.SetCutoff(chunkMeta.YMax / chunkSize);
230231
231232 ChunkRenderer.SetupPngImage(mostActiveCol.Key, path, _chunkPath, ref chunkMeta);
232233 ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, ref chunkTopMetadata, out updatedPixels);
@@ -342,7 +343,7 @@ namespace Automap
342343 var airBlocksQuery = from airyBlock in ClientAPI.World.Blocks
343344 where airyBlock.MatterState == EnumMatterState.Solid
344345 where airyBlock.BlockMaterial == EnumBlockMaterial.Plant || airyBlock.BlockMaterial == EnumBlockMaterial.Leaves
345- where airyBlock.CollisionBoxes == null || airyBlock.CollisionBoxes.Length == 0
346+ where airyBlock.CollisionBoxes == null || airyBlock.CollisionBoxes.Length == 0 ||airyBlock.RainPermeable == true
346347 select airyBlock;
347348 //^^ 'Solid' phase - 'Plant' Blocks without any boundg box ? Except water...
348349 this.AiryIdCodes = airBlocksQuery.ToDictionary(aBlk => aBlk.BlockId, aBlk => aBlk.Code.Path);