Automap (client) [VS plugin mod]
Revisão | ee1ef4dd4fb1496a5dc7fcc5336ec6df1d191c34 (tree) |
---|---|
Hora | 2021-05-18 07:46:19 |
Autor | melchior <melchior@user...> |
Commiter | melchior |
W.I.P. correct direction diagonal
@@ -51,54 +51,53 @@ namespace Automap | ||
51 | 51 | } |
52 | 52 | |
53 | 53 | // 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); | |
55 | 55 | var west_pos = new Vec2i(chunkPos.X - 1, chunkPos.Y); |
56 | - var south_pos = new Vec2i(chunkPos.X, chunkPos.Y - 1); | |
57 | - | |
56 | + var north_pos = new Vec2i(chunkPos.X, chunkPos.Y + 1); | |
58 | 57 | |
59 | - ColumnMeta south, southWest, west; | |
58 | + ColumnMeta north, northWest, west; | |
60 | 59 | /* |
61 | 60 | "Overlap" Heightmap for Slope (height) values; covers 1 whole + 2 chunk edges, and corner block, |
62 | 61 | substitute ZERO with Average Height....better than nothing even if its wrong? |
63 | 62 | */ |
64 | 63 | var overlapHeightmap = new ushort[chunkSize + 1, chunkSize + 1]; |
65 | 64 | |
66 | - //Ofset copy of Heightmap... | |
65 | + //Ofset copy of Heightmap...copied to Bottom, Rightmost | |
67 | 66 | for (int copyX = 0; copyX < chunkSize; copyX++) |
68 | 67 | { |
69 | 68 | for (int copyY = 0; copyY < chunkSize; copyY++) { |
70 | - overlapHeightmap[copyX + 1, copyY] = targetColMeta.HeightMap[copyX, copyY]; | |
69 | + overlapHeightmap[copyX + 1, copyY + 1] = targetColMeta.HeightMap[copyX, copyY]; | |
71 | 70 | } |
72 | 71 | } |
73 | 72 | |
74 | 73 | |
75 | 74 | |
76 | 75 | if (allCols.Contains(corner_pos) && allCols[corner_pos].HeightMap != null) { |
77 | - southWest = allCols[corner_pos]; | |
78 | - overlapHeightmap[0, 32] = southWest.HeightMap[0, chunkSize - 1]; | |
76 | + northWest = allCols[corner_pos]; | |
77 | + overlapHeightmap[0, 0] = northWest.HeightMap[chunkSize - 1, chunkSize - 1]; | |
79 | 78 | } |
80 | 79 | else { |
81 | 80 | var cornerMC = ClientAPI.World.BlockAccessor.GetMapChunk(corner_pos); |
82 | 81 | if (cornerMC != null && cornerMC.RainHeightMap != null) |
83 | 82 | { |
84 | - overlapHeightmap[0, 32] = cornerMC.RainHeight2DMap(0, (chunkSize - 1) ); | |
83 | + overlapHeightmap[0, 0] = cornerMC.RainHeight2DMap(chunkSize - 1, (chunkSize - 1) ); | |
85 | 84 | } |
86 | 85 | } |
87 | 86 | |
88 | - if (allCols.Contains(south_pos) && allCols[south_pos].HeightMap != null) { | |
89 | - south = allCols[south_pos]; | |
87 | + if (allCols.Contains(north_pos) && allCols[north_pos].HeightMap != null) { | |
88 | + north = allCols[north_pos]; | |
90 | 89 | |
91 | - for (int southEdgeIndex = 0; southEdgeIndex < chunkSize; southEdgeIndex++) | |
90 | + for (int northEdgeIndex = 0; northEdgeIndex < chunkSize; northEdgeIndex++) | |
92 | 91 | { |
93 | - overlapHeightmap[32, southEdgeIndex + 1] = south.HeightMap[0, southEdgeIndex]; | |
92 | + overlapHeightmap[1, northEdgeIndex + 1 ] = north.HeightMap[ (chunkSize - 1), northEdgeIndex]; | |
94 | 93 | } |
95 | 94 | } |
96 | 95 | else { |
97 | - var southMC = ClientAPI.World.BlockAccessor.GetMapChunk(south_pos); | |
98 | - if (southMC != null && southMC.RainHeightMap != null) { | |
99 | - for (int southEdgeIndex = 0; southEdgeIndex < chunkSize; southEdgeIndex++) | |
96 | + var northMC = ClientAPI.World.BlockAccessor.GetMapChunk(north_pos); | |
97 | + if (northMC != null && northMC.RainHeightMap != null) { | |
98 | + for (int northEdgeIndex = 0; northEdgeIndex < chunkSize; northEdgeIndex++) | |
100 | 99 | { |
101 | - overlapHeightmap[32, southEdgeIndex] = southMC.RainHeight2DMap(0, southEdgeIndex); | |
100 | + overlapHeightmap[1, northEdgeIndex + 1] = northMC.RainHeight2DMap((chunkSize - 1), northEdgeIndex); | |
102 | 101 | } |
103 | 102 | } |
104 | 103 | } |
@@ -108,14 +107,14 @@ namespace Automap | ||
108 | 107 | |
109 | 108 | for (int westEdgeIndex = 0; westEdgeIndex < chunkSize; westEdgeIndex++) |
110 | 109 | { |
111 | - overlapHeightmap[westEdgeIndex, 0] = west.HeightMap[westEdgeIndex, chunkSize - 1]; | |
110 | + overlapHeightmap[westEdgeIndex + 1, 0] = west.HeightMap[westEdgeIndex, chunkSize - 1]; | |
112 | 111 | } |
113 | 112 | } |
114 | 113 | else { |
115 | - var westMC = ClientAPI.World.BlockAccessor.GetMapChunk(south_pos); | |
114 | + var westMC = ClientAPI.World.BlockAccessor.GetMapChunk(west_pos); | |
116 | 115 | if (westMC != null && westMC.RainHeightMap != null) { |
117 | 116 | for (int westEdgeIndex = 0; westEdgeIndex < chunkSize; westEdgeIndex++) { |
118 | - overlapHeightmap[westEdgeIndex, 0] = westMC.RainHeight2DMap(westEdgeIndex, chunkSize - 1); | |
117 | + overlapHeightmap[westEdgeIndex + 1, 0] = westMC.RainHeight2DMap(westEdgeIndex, chunkSize - 1); | |
119 | 118 | } |
120 | 119 | } |
121 | 120 | } |
@@ -152,17 +151,17 @@ namespace Automap | ||
152 | 151 | float slopeBoost = 1f; |
153 | 152 | int leftTop, rightTop, leftBot; |
154 | 153 | |
155 | - int topX = localX; | |
156 | - int botX = localX + 1; | |
157 | - int leftZ = localZ + 1; | |
158 | - int rightZ = localZ; | |
159 | - | |
160 | - topX = GameMath.Mod(topX, chunkSize + 1); | |
161 | - leftZ = GameMath.Mod(leftZ, chunkSize + 1); | |
154 | + int up_X = localX; | |
155 | + int low_X = localX + 1; | |
156 | + int left_Z = localZ; | |
157 | + int right_Z = localZ + 1; | |
162 | 158 | |
163 | - leftTop = Math.Sign(localY - overlapHeightmap[topX, leftZ]); | |
164 | - rightTop = Math.Sign(localY - overlapHeightmap[topX, rightZ]); | |
165 | - leftBot = Math.Sign(localY - overlapHeightmap[botX, leftZ]); | |
159 | + //topX = GameMath.Mod(topX, chunkSize + 1); | |
160 | + //leftZ = GameMath.Mod(leftZ, chunkSize + 1); | |
161 | + | |
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]); | |
166 | 165 | |
167 | 166 | float slopeness = (leftTop + rightTop + leftBot); |
168 | 167 |