Skip to content
Snippets Groups Projects
Commit 8526c5f3 authored by Knuiman, Bart's avatar Knuiman, Bart
Browse files

Improvement for when download failed. It no longe remains 'not finished'.

parent b72ce56a
No related branches found
No related tags found
No related merge requests found
......@@ -115,6 +115,10 @@ namespace Wander
parseTileTask = null;
}
}
else // Done but not succesful.
{
finished = true;
}
return finished;
}
......@@ -239,11 +243,11 @@ namespace Wander
node.children = new QuadTreeNode[4];
var hs = (node.max - node.min) / 2;
Vector2 [] mins = new [] {
node.min,
new Vector2(node.min.x+hs.x, node.min.y),
new Vector2(node.min.x, node.min.y+hs.y),
new Vector2(node.min.x+hs.x, node.min.y+hs.y)
};
node.min,
new Vector2(node.min.x+hs.x, node.min.y),
new Vector2(node.min.x, node.min.y+hs.y),
new Vector2(node.min.x+hs.x, node.min.y+hs.y)
};
for (int i = 0;i < 4;i++)
{
var n2 = new QuadTreeNode();
......@@ -271,7 +275,7 @@ namespace Wander
}
node.triangles = null;
}
UnityEngine.Debug.Log( "Optimize for raytracing took " + sw.ElapsedMilliseconds );
// UnityEngine.Debug.Log( "Optimize for raytracing took " + sw.ElapsedMilliseconds );
}
catch (Exception e)
{
......@@ -308,11 +312,8 @@ namespace Wander
// If no polygon was hit, 15 is encoded (reserved).
// If polygon was hit, but no feature was matched, also 15 is encoded.
// Returns a list of failed to match pixels. This can be due to geometry not exactly matching or a layer not being found.
// Also outputs a remap of layer indices. For instance for a specific tile, only layerIdx 1, 6 and 3 are used.
// Then it applies a remapping of 1->0, 6->1, 3->2. So that in the shader only 3 textures are needed starting from 0, 1.. etc.
public byte[] RenderToTextureSingle(
int resolution,
out Dictionary<byte, byte> remappedLayerIndices,
out List<Vector3Int> failedPixels,
ref bool cancelToken )
{
......@@ -325,7 +326,6 @@ namespace Wander
byte [] texture = new byte[resolution*resolution/2];
failedPixels = new List<Vector3Int>();
remappedLayerIndices = new Dictionary<byte, byte>();
float oneOverRes = 1.0f / resolution;
int cachedTriIdx = 0;
float fx = 4096 * oneOverRes; // TODO 4096 may be different in other implementations.
......@@ -406,8 +406,18 @@ namespace Wander
}
}
// UnityEngine.Debug.Log( "Render to texture took " + sw.ElapsedMilliseconds );
return texture;
}
// Remaps layer indices. For instance for a specific tile, only layerIdx 1, 6 and 3 are used.
// Then it applies a remapping of 1->0, 6->1, 3->2. So that in the shader only 3 textures are needed starting from 0, 1.. etc.
public static Dictionary<byte, byte> FindLayersInTexture(byte[] texture, int resolution, ref bool cancelToken)
{
// Determine number of different layers. For instance, if only layer 3, 8, 14 and 15 are used, we select
// a material that only uses 4 textures and put 3 -> Albedo_0 -> 8 to Albedo_1, etc. in the shader.
Dictionary<byte, byte> remappedLayerIndices = new Dictionary<byte, byte>();
byte cachedPixel = 15;
int remappedIndexCounter = -1;
byte remappedPixel = 15;
......@@ -454,12 +464,11 @@ namespace Wander
}
UnityEngine.Debug.Assert( remappedIndexCounter <= 15, "Exceeded layer count." ); // Invalid pixel is not added to map, so max must be 15, not 16.
UnityEngine.Debug.Log( "Render to texture took " + sw.ElapsedMilliseconds );
return texture;
return remappedLayerIndices;
}
}
public static class VectorTileLoader
{
public static VectorTile LoadFromUrl( string url, bool autoStart = true )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment