Browse Source

Spherical tile visibility, part IV

Partial solution. Check AABB of tile vertices.
Johannes Hofmann 7 years ago
parent
commit
03c33086ba
1 changed files with 8 additions and 7 deletions
  1. 8
    7
      src/orthografic_view.rs

+ 8
- 7
src/orthografic_view.rs View File

159
 
159
 
160
         let transform = Self::transformation_matrix(map_view);
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
         let tile_is_visible = |tc: TileCoord| -> bool {
162
         let tile_is_visible = |tc: TileCoord| -> bool {
167
             let nw = tc.latlon_rad_north_west();
163
             let nw = tc.latlon_rad_north_west();
168
             let se = tc.latlon_rad_south_east();
164
             let se = tc.latlon_rad_south_east();
177
                 // Tile is on the backside of the sphere
173
                 // Tile is on the backside of the sphere
178
                 false
174
                 false
179
             } else {
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
             let alpha = center_latlon.lon + (PI * 0.5);
232
             let alpha = center_latlon.lon + (PI * 0.5);
232
             let cosa = alpha.cos();
233
             let cosa = alpha.cos();
233
             let sina = alpha.sin();
234
             let sina = alpha.sin();
234
-                Matrix3::from_cols(
235
+            Matrix3::from_cols(
235
                 vec3(cosa, 0.0, -sina),
236
                 vec3(cosa, 0.0, -sina),
236
                 vec3(0.0, 1.0, 0.0),
237
                 vec3(0.0, 1.0, 0.0),
237
                 vec3(sina, 0.0, cosa),
238
                 vec3(sina, 0.0, cosa),
243
             let alpha = -center_latlon.lat;
244
             let alpha = -center_latlon.lat;
244
             let cosa = alpha.cos();
245
             let cosa = alpha.cos();
245
             let sina = alpha.sin();
246
             let sina = alpha.sin();
246
-                Matrix3::from_cols(
247
+            Matrix3::from_cols(
247
                 vec3(1.0, 0.0, 0.0),
248
                 vec3(1.0, 0.0, 0.0),
248
                 vec3(0.0, cosa, sina),
249
                 vec3(0.0, cosa, sina),
249
                 vec3(0.0, -sina, cosa),
250
                 vec3(0.0, -sina, cosa),