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
1427e320
Commit
1427e320
authored
2 years ago
by
Knuiman, Bart
Browse files
Options
Downloads
Patches
Plain Diff
Caching works now!
parent
665cca26
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
+74
-67
74 additions, 67 deletions
Runtime/VectorTile.cs
with
74 additions
and
67 deletions
Runtime/VectorTile.cs
+
74
−
67
View file @
1427e320
...
@@ -197,92 +197,101 @@ namespace Wander
...
@@ -197,92 +197,101 @@ namespace Wander
public
void
OptimizeForPointIsInsideTriangle
()
public
void
OptimizeForPointIsInsideTriangle
()
{
{
Stopwatch
sw
=
new
Stopwatch
();
try
sw
.
Restart
();
for
(
int
i
=
0
;
i
<
polygonLayers
.
Count
;
i
++)
{
{
for
(
int
j
=
0
;
j
<
polygonLayers
[
i
].
Count
;
j
++)
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Restart
();
for
(
int
i
=
0
;
i
<
polygonLayers
.
Count
;
i
++)
{
{
polygonLayers
[
i
][
j
].
OptimizeForIsPointInTriangle
();
for
(
int
j
=
0
;
j
<
polygonLayers
[
i
].
Count
;
j
++)
{
polygonLayers
[
i
][
j
].
OptimizeForIsPointInTriangle
();
}
}
}
}
// Generate quadtree
// Generate quadtree
List
<
QuadTreeNode
>
stack
=
new
List
<
QuadTreeNode
>();
List
<
QuadTreeNode
>
stack
=
new
List
<
QuadTreeNode
>();
root
=
new
QuadTreeNode
();
root
=
new
QuadTreeNode
();
root
.
triangles
=
new
List
<(
int
,
int
,
int
)>();
root
.
triangles
=
new
List
<(
int
,
int
,
int
)>();
root
.
min
=
new
Vector2
(
0
,
0
);
root
.
min
=
new
Vector2
(
0
,
0
);
root
.
max
=
new
Vector2
(
4096
,
4096
);
// TODO 4096 should be max of all layer extents.
root
.
max
=
new
Vector2
(
4096
,
4096
);
// TODO 4096 should be max of all layer extents.
for
(
int
l
=
0
;
l
<
polygonLayers
.
Count
;
l
++)
for
(
int
l
=
0
;
l
<
polygonLayers
.
Count
;
l
++)
{
var
layer
=
layers
[
l
];
for
(
int
f
=
0
;
f
<
layer
.
VectorTileFeatures
.
Count
;
f
++)
{
{
var
feature
=
layer
.
VectorTileFeatures
[
f
];
var
layer
=
layers
[
l
];
for
(
int
f
=
0
;
f
<
layer
.
VectorTileFeatures
.
Count
;
f
++)
{
var
feature
=
layer
.
VectorTileFeatures
[
f
];
if
(
feature
.
GeometryType
!=
Tile
.
GeomType
.
Polygon
)
if
(
feature
.
GeometryType
!=
Tile
.
GeomType
.
Polygon
)
continue
;
continue
;
var
polygons
=
polygonLayers
[
l
][
f
];
var
polygons
=
polygonLayers
[
l
][
f
];
if
(
polygons
.
vertices
.
Count
==
0
)
if
(
polygons
.
vertices
.
Count
==
0
)
continue
;
continue
;
if
(
feature
.
SelectedLayerIdx
==
254
)
if
(
feature
.
SelectedLayerIdx
==
254
)
continue
;
continue
;
if
(
feature
.
RelativeHeight
>
0
)
if
(
feature
.
RelativeHeight
!=
0
)
continue
;
continue
;
var
poly
=
polygonLayers
[
l
][
f
];
var
poly
=
polygonLayers
[
l
][
f
];
for
(
int
t
=
0
;
t
<
poly
.
vertices
.
Count
/
3
;
t
++)
for
(
int
t
=
0
;
t
<
poly
.
vertices
.
Count
/
3
;
t
++)
{
{
root
.
triangles
.
Add
(
(
l
,
f
,
t
)
);
root
.
triangles
.
Add
(
(
l
,
f
,
t
)
);
}
}
}
}
}
}
stack
.
Add
(
root
);
stack
.
Add
(
root
);
while
(
stack
.
Count
>
0
)
while
(
stack
.
Count
>
0
)
{
{
var
node
=
stack
[
0
];
var
node
=
stack
[
0
];
stack
.
RemoveAt
(
0
);
stack
.
RemoveAt
(
0
);
if
(
node
.
triangles
.
Count
<
4
)
if
(
node
.
triangles
.
Count
<
4
)
continue
;
continue
;
if
(
node
.
depth
>
7
)
if
(
node
.
depth
>
7
)
continue
;
continue
;
node
.
children
=
new
QuadTreeNode
[
4
];
node
.
children
=
new
QuadTreeNode
[
4
];
var
hs
=
(
node
.
max
-
node
.
min
)
/
2
;
var
hs
=
(
node
.
max
-
node
.
min
)
/
2
;
Vector2
[]
mins
=
new
[]
{
Vector2
[]
mins
=
new
[]
{
node
.
min
,
node
.
min
,
new
Vector2
(
node
.
min
.
x
+
hs
.
x
,
node
.
min
.
y
),
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
,
node
.
min
.
y
+
hs
.
y
),
new
Vector2
(
node
.
min
.
x
+
hs
.
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
++)
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
var
n2
=
new
QuadTreeNode
();
n2
.
depth
=
node
.
depth
+
1
;
n2
.
min
=
mins
[
i
];
n2
.
max
=
n2
.
min
+
hs
;
n2
.
triangles
=
new
List
<(
int
,
int
,
int
)>();
for
(
int
t
=
0
;
t
<
node
.
triangles
.
Count
;
t
++
)
{
{
int
l
=
node
.
triangles
[
t
].
Item1
;
var
n2
=
new
QuadTreeNode
()
;
int
f
=
node
.
triangles
[
t
].
Item2
;
n2
.
depth
=
node
.
depth
+
1
;
int
t2
=
node
.
triangles
[
t
].
Item3
;
n2
.
min
=
mins
[
i
]
;
var
min2
=
polygonLayers
[
l
][
f
].
mins
[
t2
]
;
n2
.
max
=
n2
.
min
+
hs
;
var
max2
=
polygonLayers
[
l
][
f
].
maxs
[
t2
]
;
n2
.
triangles
=
new
List
<(
int
,
int
,
int
)>()
;
if
(
(
min2
.
x
>
n2
.
max
.
x
)
||
(
min2
.
y
>
n2
.
max
.
y
)
||
(
max2
.
x
<
n2
.
min
.
x
)
||
(
max2
.
y
<
n2
.
min
.
y
)
)
for
(
int
t
=
0
;
t
<
node
.
triangles
.
Count
;
t
++
)
{
{
continue
;
int
l
=
node
.
triangles
[
t
].
Item1
;
int
f
=
node
.
triangles
[
t
].
Item2
;
int
t2
=
node
.
triangles
[
t
].
Item3
;
var
min2
=
polygonLayers
[
l
][
f
].
mins
[
t2
];
var
max2
=
polygonLayers
[
l
][
f
].
maxs
[
t2
];
if
((
min2
.
x
>
n2
.
max
.
x
)
||
(
min2
.
y
>
n2
.
max
.
y
)
||
(
max2
.
x
<
n2
.
min
.
x
)
||
(
max2
.
y
<
n2
.
min
.
y
))
{
continue
;
}
n2
.
triangles
.
Add
(
node
.
triangles
[
t
]
);
UnityEngine
.
Debug
.
Assert
(
layers
[
l
].
VectorTileFeatures
[
f
].
SelectedLayerIdx
!=
254
&&
layers
[
l
].
VectorTileFeatures
[
f
].
RelativeHeight
==
0
);
}
}
n2
.
triangles
.
Add
(
(
l
,
f
,
t2
)
);
node
.
children
[
i
]
=
n2
;
stack
.
Add
(
n2
);
}
}
node
.
children
[
i
]
=
n2
;
node
.
triangles
=
null
;
stack
.
Add
(
n2
);
}
}
UnityEngine
.
Debug
.
Log
(
"Optimize for raytracing took "
+
sw
.
ElapsedMilliseconds
);
node
.
triangles
=
null
;
}
catch
(
Exception
e
)
{
UnityEngine
.
Debug
.
LogException
(
e
);
}
}
UnityEngine
.
Debug
.
Log
(
"Optimize for raytracing took "
+
sw
.
ElapsedMilliseconds
);
}
}
// Identify feature by specifying a (unique) index based on some criteria. This can very per
// Identify feature by specifying a (unique) index based on some criteria. This can very per
...
@@ -381,9 +390,7 @@ namespace Wander
...
@@ -381,9 +390,7 @@ namespace Wander
hit
=
GeomUtil
.
PointIsInsideTriangle2
(
p
,
vertices
[
t2
*
3
],
vertices
[
t2
*
3
+
1
],
vertices
[
t2
*
3
+
2
],
denoms
[
t2
]
);
hit
=
GeomUtil
.
PointIsInsideTriangle2
(
p
,
vertices
[
t2
*
3
],
vertices
[
t2
*
3
+
1
],
vertices
[
t2
*
3
+
2
],
denoms
[
t2
]
);
if
(
hit
)
if
(
hit
)
{
{
// TODO caching the TriIdx doees not work, I have no clue why, it should only function
cachedTriIdx
=
ti
;
// as a hint, as where to start. But using this hint results in massive number of triangles going wrong...
// cachedTriIdx = ti;
var
layerIdx
=
(
byte
)
layers
[
l
].
VectorTileFeatures
[
f
].
SelectedLayerIdx
;
var
layerIdx
=
(
byte
)
layers
[
l
].
VectorTileFeatures
[
f
].
SelectedLayerIdx
;
texture
[(
resolution
-
y
-
1
)*
resolution
+
x
]
=
layerIdx
;
texture
[(
resolution
-
y
-
1
)*
resolution
+
x
]
=
layerIdx
;
break
;
break
;
...
...
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