|
|
@@ -25,6 +25,18 @@ impl TextureRect {
|
|
25
|
25
|
y2: self.y2 - margin_y,
|
|
26
|
26
|
}
|
|
27
|
27
|
}
|
|
|
28
|
+
|
|
|
29
|
+ pub fn subdivide(&self, sub_tile: &SubTileCoord) -> TextureRect {
|
|
|
30
|
+ let scale = 1.0 / f64::from(sub_tile.size);
|
|
|
31
|
+ let w = (self.x2 - self.x1) * scale;
|
|
|
32
|
+ let h = (self.y2 - self.y1) * scale;
|
|
|
33
|
+ TextureRect {
|
|
|
34
|
+ x1: self.x1 + f64::from(sub_tile.x) * w,
|
|
|
35
|
+ y1: self.y1 + f64::from(sub_tile.y) * h,
|
|
|
36
|
+ x2: self.x1 + f64::from(sub_tile.x + 1) * w,
|
|
|
37
|
+ y2: self.y1 + f64::from(sub_tile.y + 1) * h,
|
|
|
38
|
+ }
|
|
|
39
|
+ }
|
|
28
|
40
|
}
|
|
29
|
41
|
|
|
30
|
42
|
#[derive(Clone, Debug)]
|
|
|
@@ -137,9 +149,13 @@ impl<'a> TileCacheGl<'a> {
|
|
137
|
149
|
}
|
|
138
|
150
|
);
|
|
139
|
151
|
} else {
|
|
140
|
|
- // look for cached tiles in lower zoom layers
|
|
|
152
|
+ // exact tile not found
|
|
|
153
|
+
|
|
|
154
|
+ // default tile
|
|
141
|
155
|
let mut tex_sub_rect = self.slot_to_texture_rect(Self::default_slot());
|
|
142
|
156
|
let mut tex_rect = tex_sub_rect;
|
|
|
157
|
+
|
|
|
158
|
+ // look for cached tiles in lower zoom layers
|
|
143
|
159
|
for dist in 1..31 {
|
|
144
|
160
|
if let Some((parent_tile, sub_coord)) = vt.tile.parent(dist) {
|
|
145
|
161
|
if let Some(slot) = self.store(parent_tile, source, cache, false) {
|
|
|
@@ -147,17 +163,34 @@ impl<'a> TileCacheGl<'a> {
|
|
147
|
163
|
tex_rect = self.slot_to_texture_rect(slot);
|
|
148
|
164
|
break;
|
|
149
|
165
|
}
|
|
|
166
|
+ } else {
|
|
|
167
|
+ break;
|
|
150
|
168
|
}
|
|
151
|
169
|
}
|
|
152
|
|
- tvt.push(
|
|
153
|
|
- TexturedVisibleTile {
|
|
154
|
|
- screen_rect: vt.rect,
|
|
155
|
|
- tex_rect: tex_sub_rect,
|
|
156
|
|
- tex_minmax: tex_rect.inset(inset_x, inset_y),
|
|
|
170
|
+
|
|
|
171
|
+ // look for cached tiles in higher zoom layers
|
|
|
172
|
+ for &(child_tile, child_sub_coord) in &vt.tile.children() {
|
|
|
173
|
+ if let Some(slot) = self.store(child_tile, source, cache, false) {
|
|
|
174
|
+ let tex_rect = self.slot_to_texture_rect(slot);
|
|
|
175
|
+
|
|
|
176
|
+ tvt.push(
|
|
|
177
|
+ TexturedVisibleTile {
|
|
|
178
|
+ screen_rect: vt.rect.subdivide(&child_sub_coord),
|
|
|
179
|
+ tex_rect: tex_rect,
|
|
|
180
|
+ tex_minmax: tex_rect.inset(inset_x, inset_y),
|
|
|
181
|
+ }
|
|
|
182
|
+ );
|
|
|
183
|
+ } else {
|
|
|
184
|
+ tvt.push(
|
|
|
185
|
+ TexturedVisibleTile {
|
|
|
186
|
+ screen_rect: vt.rect.subdivide(&child_sub_coord),
|
|
|
187
|
+ tex_rect: tex_sub_rect.subdivide(&child_sub_coord),
|
|
|
188
|
+ tex_minmax: tex_rect.inset(inset_x, inset_y),
|
|
|
189
|
+ }
|
|
|
190
|
+ );
|
|
157
|
191
|
}
|
|
158
|
|
- );
|
|
|
192
|
+ }
|
|
159
|
193
|
};
|
|
160
|
|
-
|
|
161
|
194
|
}
|
|
162
|
195
|
|
|
163
|
196
|
tvt
|