summaryrefslogtreecommitdiff
path: root/src/mbgl/map/transform_state.cpp
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2017-05-15 14:17:06 -0700
committerAnsis Brammanis <brammanis@gmail.com>2017-07-11 09:10:22 -0700
commit59df3a90f41461562a80688337ec53687e341124 (patch)
treeaae3e94ddc74134600494fce944a5b3ab764a41a /src/mbgl/map/transform_state.cpp
parente364f24570f863044b9c464c2eb8c0fd75c5a80b (diff)
downloadqtlocation-mapboxgl-59df3a90f41461562a80688337ec53687e341124.tar.gz
[core] Improved label pitch-scaling: approximate collision box shapes based on tile distance from camera.
Diffstat (limited to 'src/mbgl/map/transform_state.cpp')
-rw-r--r--src/mbgl/map/transform_state.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp
index f052e30a6b..4606e3eece 100644
--- a/src/mbgl/map/transform_state.cpp
+++ b/src/mbgl/map/transform_state.cpp
@@ -385,4 +385,16 @@ void TransformState::setScalePoint(const double newScale, const ScreenCoordinate
Cc = Projection::worldSize(scale) / util::M2PI;
}
+float TransformState::getCameraToTileDistance(const UnwrappedTileID& tileID) const {
+ mat4 projectionMatrix;
+ getProjMatrix(projectionMatrix);
+ mat4 tileProjectionMatrix;
+ matrixFor(tileProjectionMatrix, tileID);
+ matrix::multiply(tileProjectionMatrix, projectionMatrix, tileProjectionMatrix);
+ vec4 tileCenter = {{util::tileSize / 2, util::tileSize / 2, 0, 1}};
+ vec4 projectedCenter;
+ matrix::transformMat4(projectedCenter, tileCenter, tileProjectionMatrix);
+ return projectedCenter[3];
+}
+
} // namespace mbgl