void HeightMatrix::Fill(const RasterMap &map, const WindowProjection &projection, unsigned quantisation_pixels, bool interpolate) { const unsigned screen_width = projection.GetScreenWidth(); const unsigned screen_height = projection.GetScreenHeight(); SetSize((screen_width + quantisation_pixels - 1) / quantisation_pixels, (screen_height + quantisation_pixels - 1) / quantisation_pixels); minimum = 0x7fff; maximum = 0; for (unsigned y = 0; y < screen_height; y += quantisation_pixels) { const FastRowRotation rotation = projection.GetScreenAngleRotation(y - projection.GetScreenOrigin().y); short *p = data.begin() + y * width / quantisation_pixels; for (unsigned x = 0; x < screen_width; x += quantisation_pixels) { #ifndef SLOW_TERRAIN_STUFF const FastRowRotation::Pair r = rotation.Rotate(x - projection.GetScreenOrigin().x); GeoPoint gp; gp.Latitude = projection.GetGeoLocation().Latitude - projection.PixelsToAngle(r.second); gp.Longitude = projection.GetGeoLocation().Longitude + projection.PixelsToAngle(r.first) * gp.Latitude.invfastcosine(); #else GeoPoint gp = projection.ScreenToGeo(x, y); #endif short h = interpolate ? map.GetFieldInterpolated(gp) : map.GetField(gp); if (!RasterBuffer::is_special(h)) { if (h < minimum) minimum = h; if (h > maximum) maximum = h; } *p++ = h; } assert(p <= data.end()); } }