From 0b29970a9e4c1c65e7dda053822efabbd9620afe Mon Sep 17 00:00:00 2001
From: bart <bart.knuiman@wur.nl>
Date: Thu, 9 Mar 2023 19:11:41 +0100
Subject: [PATCH] Bridges now go as intended.

---
 Runtime/3rdParty/VectorTile/VectorTileFeature.cs |  1 +
 Runtime/VectorTile.cs                            | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Runtime/3rdParty/VectorTile/VectorTileFeature.cs b/Runtime/3rdParty/VectorTile/VectorTileFeature.cs
index bde5b10..732ce80 100644
--- a/Runtime/3rdParty/VectorTile/VectorTileFeature.cs
+++ b/Runtime/3rdParty/VectorTile/VectorTileFeature.cs
@@ -13,6 +13,7 @@ namespace Mapbox.Vector.Tile
 
         /* Added to this struct for easier managing layer info. */
         public int SelectedLayerIdx { get; set; }
+        public int RelativeHeight { get; set; }
     }
 
 
diff --git a/Runtime/VectorTile.cs b/Runtime/VectorTile.cs
index 61b08dc..1b9f62f 100644
--- a/Runtime/VectorTile.cs
+++ b/Runtime/VectorTile.cs
@@ -197,7 +197,8 @@ namespace Wander
 
         // Identify feature by specifying a (unique) index based on some criteria. This can very per
         // vector tile provider. 
-        public void IdentifyLayers( Func<VectorTileLayer, List<KeyValuePair<string, object>>, int> selectionCallback )
+        public void IdentifyLayers( Func<VectorTileLayer, List<KeyValuePair<string, object>>, int> selectionCallback,
+                                    Func<VectorTileLayer, List<KeyValuePair<string, object>>, int> relativeHeightCallback )
         {
             for (int l = 0;l < layers.Count;l++)
             {
@@ -212,6 +213,8 @@ namespace Wander
                     {
                         feature.SelectedLayerIdx = uniqueId;
                     }
+                    uniqueId = relativeHeightCallback( layer, feature.Attributes );
+                    feature.RelativeHeight = uniqueId;
                 }
             }
             layersIdentified = true;
@@ -269,6 +272,12 @@ namespace Wander
                             if (polygons.vertices.Count == 0)
                                 continue;
 
+                            if (feature.SelectedLayerIdx == 254)
+                                continue;
+
+                            if (feature.RelativeHeight > 0)
+                                continue;
+
                             var poly     = polygonLayers[lIdx][ftrIdx];
                             var mins     = poly.mins;
                             var maxs     = poly.maxs;
@@ -293,7 +302,8 @@ namespace Wander
 
                             if (hit) break;
 
-                            cachedTriIdx = 0;
+                            cachedTriIdx += 1;
+                            if(cachedTriIdx == triCount) cachedTriIdx = 0;
                         }
 
                         if (hit) break;
-- 
GitLab