Refactor: coordinatePointMatrix skip recomputation (#14507)

coordinatePointMatrix is always used with getZoom():
Projection::worldSize(scale) / std::pow(2, z) is computed as
scale * util::tileSize / std::pow(2, z)
scale is equal to std::pow(2, z).
____________________________________=>
Projection::worldSize(scale) / std::pow(2, z) => util::tileSize.
This commit is contained in:
Aleksandar Stojiljkovic
2019-05-13 22:13:37 +03:00
committed by GitHub
parent d2dd3cc2c8
commit 926e8e8a5b
2 changed files with 6 additions and 6 deletions

View File

@@ -278,7 +278,7 @@ ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng)
return {};
}
mat4 mat = coordinatePointMatrix(getZoom());
mat4 mat = coordinatePointMatrix();
vec4 p;
Point<double> pt = Projection::project(latLng, scale) / util::tileSize;
vec4 c = {{ pt.x, pt.y, 0, 1 }};
@@ -292,7 +292,7 @@ LatLng TransformState::screenCoordinateToLatLng(const ScreenCoordinate& point, L
}
float targetZ = 0;
mat4 mat = coordinatePointMatrix(getZoom());
mat4 mat = coordinatePointMatrix();
mat4 inverted;
bool err = matrix::invert(inverted, mat);
@@ -325,10 +325,10 @@ LatLng TransformState::screenCoordinateToLatLng(const ScreenCoordinate& point, L
return Projection::unproject(util::interpolate(p0, p1, t), scale / util::tileSize, wrapMode);
}
mat4 TransformState::coordinatePointMatrix(double z) const {
mat4 TransformState::coordinatePointMatrix() const {
mat4 proj;
getProjMatrix(proj);
float s = Projection::worldSize(scale) / std::pow(2, z);
float s = util::tileSize;
matrix::scale(proj, proj, s, s, 1);
matrix::multiply(proj, getPixelMatrix(), proj);
return proj;
@@ -426,7 +426,7 @@ float TransformState::maxPitchScaleFactor() const {
return {};
}
auto latLng = screenCoordinateToLatLng({ 0, static_cast<float>(getSize().height) });
mat4 mat = coordinatePointMatrix(getZoom());
mat4 mat = coordinatePointMatrix();
Point<double> pt = Projection::project(latLng, scale) / util::tileSize;
vec4 p = {{ pt.x, pt.y, 0, 1 }};
vec4 topPoint;

View File

@@ -104,7 +104,7 @@ private:
// logical dimensions
Size size;
mat4 coordinatePointMatrix(double z) const;
mat4 coordinatePointMatrix() const;
mat4 getPixelMatrix() const;
/** Recenter the map so that the given coordinate is located at the given