Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vectortile
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WANDER
vectortile
Commits
8526c5f3
Commit
8526c5f3
authored
1 year ago
by
Knuiman, Bart
Browse files
Options
Downloads
Patches
Plain Diff
Improvement for when download failed. It no longe remains 'not finished'.
parent
b72ce56a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Runtime/VectorTile.cs
+22
-13
22 additions, 13 deletions
Runtime/VectorTile.cs
with
22 additions
and
13 deletions
Runtime/VectorTile.cs
+
22
−
13
View file @
8526c5f3
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment