Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaria Volvenkova <d.volvenkova@corp.mail.ru>2019-03-07 03:59:46 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2019-03-07 11:32:22 +0300
commit8fdaabf36155e4631a25feb330798229dda8bc77 (patch)
tree609915a4c660669387ebe342fa075ff96efa0ab3 /geometry
parent5e1a5836674412819fa8ca0345515adeea4b7683 (diff)
Take in account z offset of an overlay when computing the scrolling distance of the map.
Diffstat (limited to 'geometry')
-rw-r--r--geometry/screenbase.cpp19
-rw-r--r--geometry/screenbase.hpp1
2 files changed, 18 insertions, 2 deletions
diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp
index 1721b3148f..e922aa3bd1 100644
--- a/geometry/screenbase.cpp
+++ b/geometry/screenbase.cpp
@@ -441,6 +441,11 @@ m2::PointD ScreenBase::PtoP3d(m2::PointD const & pt, double ptZ) const
m2::PointD ScreenBase::P3dtoP(m2::PointD const & pt) const
{
+ return P3dtoP(pt, 0.0 /* ptZ */);
+}
+
+m2::PointD ScreenBase::P3dtoP(m2::PointD const & pt, double ptZ) const
+{
if (!m_isPerspective)
return pt;
@@ -448,14 +453,24 @@ m2::PointD ScreenBase::P3dtoP(m2::PointD const & pt) const
double const normalizedY = -2.0 * pt.y / PixelRectIn3d().SizeY() + 1.0;
double normalizedZ = 0.0;
+
if (m_3dAngleX != 0.0)
{
double const halfFOV = m_3dFOV / 2.0;
double const cameraZ = 1.0 / tan(halfFOV);
double const tanX = tan(m_3dAngleX);
- double const cameraDistanceZ =
- cameraZ * (1.0 + (normalizedY + 1.0) * tanX / (cameraZ - normalizedY * tanX));
+ double cameraDistanceZ = cameraZ * (1.0 + (normalizedY + 1.0) * tanX / (cameraZ - normalizedY * tanX));
+
+ if (ptZ != 0.0)
+ {
+ double const t = sqrt(cameraZ * cameraZ + normalizedY * normalizedY);
+ double const cosBeta = cameraZ / t;
+ double const sinBeta = normalizedY / t;
+ double const dz = ptZ * GetZScale() * cosBeta / (cos(m_3dAngleX) * cosBeta - sin(m_3dAngleX) * sinBeta);
+
+ cameraDistanceZ -= dz;
+ }
double const a = (m_3dFarZ + m_3dNearZ) / (m_3dFarZ - m_3dNearZ);
double const b = -2.0 * m_3dFarZ * m_3dNearZ / (m_3dFarZ - m_3dNearZ);
diff --git a/geometry/screenbase.hpp b/geometry/screenbase.hpp
index 2278883134..ffdaa96612 100644
--- a/geometry/screenbase.hpp
+++ b/geometry/screenbase.hpp
@@ -92,6 +92,7 @@ public:
double GetDepth3d() const { return m_3dFarZ - m_3dNearZ; }
m2::PointD P3dtoP(m2::PointD const & pt) const;
+ m2::PointD P3dtoP(m2::PointD const & pt, double ptZ) const;
Matrix3dT const & Pto3dMatrix() const { return m_Pto3d; }
bool isPerspective() const { return m_isPerspective; }