Bladeren bron

Spherical tile visibility, part IV

Partial solution. Check AABB of tile vertices.
Johannes Hofmann 7 jaren geleden
bovenliggende
commit
03c33086ba
1 gewijzigde bestanden met toevoegingen van 8 en 7 verwijderingen
  1. 8
    7
      src/orthografic_view.rs

+ 8
- 7
src/orthografic_view.rs Bestand weergeven

@@ -159,10 +159,6 @@ impl OrthograficView {
159 159
 
160 160
         let transform = Self::transformation_matrix(map_view);
161 161
 
162
-        let point_on_screen = |p: &Point3<_>| {
163
-            p.x >= -1.0 && p.x <= 1.0 && p.y >= -1.0 && p.y <= 1.0
164
-        };
165
-
166 162
         let tile_is_visible = |tc: TileCoord| -> bool {
167 163
             let nw = tc.latlon_rad_north_west();
168 164
             let se = tc.latlon_rad_south_east();
@@ -177,7 +173,12 @@ impl OrthograficView {
177 173
                 // Tile is on the backside of the sphere
178 174
                 false
179 175
             } else {
180
-                vertices.iter().any(&point_on_screen)
176
+                // Check bounding box of vertices against screen.
177
+                //TODO Create true bounding box of tile that also accounts for curved borders.
178
+                vertices.iter().fold(false, |acc, v| acc || v.x >= -1.0) &&
179
+                vertices.iter().fold(false, |acc, v| acc || v.x <= 1.0) &&
180
+                vertices.iter().fold(false, |acc, v| acc || v.y >= -1.0) &&
181
+                vertices.iter().fold(false, |acc, v| acc || v.y <= 1.0)
181 182
             }
182 183
         };
183 184
 
@@ -231,7 +232,7 @@ impl OrthograficView {
231 232
             let alpha = center_latlon.lon + (PI * 0.5);
232 233
             let cosa = alpha.cos();
233 234
             let sina = alpha.sin();
234
-                Matrix3::from_cols(
235
+            Matrix3::from_cols(
235 236
                 vec3(cosa, 0.0, -sina),
236 237
                 vec3(0.0, 1.0, 0.0),
237 238
                 vec3(sina, 0.0, cosa),
@@ -243,7 +244,7 @@ impl OrthograficView {
243 244
             let alpha = -center_latlon.lat;
244 245
             let cosa = alpha.cos();
245 246
             let sina = alpha.sin();
246
-                Matrix3::from_cols(
247
+            Matrix3::from_cols(
247 248
                 vec3(1.0, 0.0, 0.0),
248 249
                 vec3(0.0, cosa, sina),
249 250
                 vec3(0.0, -sina, cosa),