diff options
author | Aleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com> | 2019-05-13 22:13:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-13 22:13:37 +0300 |
commit | 926e8e8a5b453b02b0df754df35837c4f106f024 (patch) | |
tree | 02984e9c992a88b65c4745fa473c6d8f786e70af /src | |
parent | d2dd3cc2c875f52d2bb797a5f842f6f6fb3c769a (diff) | |
download | qtlocation-mapboxgl-926e8e8a5b453b02b0df754df35837c4f106f024.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.hpp | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index 45bee7ac7f..596ed05195 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -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; diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index 811fa253af..f51660912c 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -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 |