void SelectionShape::Render(ScreenBase const & screen, int zoomLevel, ref_ptr<dp::GpuProgramManager> mng, dp::UniformValuesStorage const & commonUniforms) { ShowHideAnimation::EState state = m_animation.GetState(); if (state == ShowHideAnimation::STATE_VISIBLE || state == ShowHideAnimation::STATE_SHOW_DIRECTION) { dp::UniformValuesStorage uniforms = commonUniforms; TileKey const key = GetTileKeyByPoint(m_position, ClipTileZoomByMaxDataZoom(zoomLevel)); math::Matrix<float, 4, 4> mv = key.GetTileBasedModelView(screen); uniforms.SetMatrix4x4Value("modelView", mv.m_data); m2::PointD const pos = MapShape::ConvertToLocal(m_position, key.GetGlobalRect().Center(), kShapeCoordScalar); uniforms.SetFloatValue("u_position", pos.x, pos.y, -m_positionZ); float accuracy = m_mapping.GetValue(m_animation.GetT()); if (screen.isPerspective()) { m2::PointD const pt1 = screen.GtoP(m_position); m2::PointD const pt2(pt1.x + 1, pt1.y); float const scale = screen.PtoP3d(pt2).x - screen.PtoP3d(pt1).x; accuracy /= scale; } uniforms.SetFloatValue("u_accuracy", accuracy); uniforms.SetFloatValue("u_opacity", 1.0f); m_renderNode->Render(mng, uniforms); } }
bool SelectionShape::IsVisible(ScreenBase const & screen, m2::PointD & pxPos) const { m2::PointD const pt = screen.GtoP(m_position); ShowHideAnimation::EState state = m_animation.GetState(); if ((state == ShowHideAnimation::STATE_VISIBLE || state == ShowHideAnimation::STATE_SHOW_DIRECTION) && !screen.IsReverseProjection3d(pt)) { pxPos = screen.PtoP3d(pt, -m_positionZ); return true; } return false; }
void SelectionShape::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng, dp::UniformValuesStorage const & commonUniforms) { ShowHideAnimation::EState state = m_animation.GetState(); if (state == ShowHideAnimation::STATE_VISIBLE || state == ShowHideAnimation::STATE_SHOW_DIRECTION) { dp::UniformValuesStorage uniforms = commonUniforms; uniforms.SetFloatValue("u_position", m_position.x, m_position.y, -m_positionZ); float accuracy = m_mapping.GetValue(m_animation.GetT()); if (screen.isPerspective()) { m2::PointD const pt1 = screen.GtoP(m_position); m2::PointD const pt2(pt1.x + 1, pt1.y); float const scale = screen.PtoP3d(pt2).x - screen.PtoP3d(pt1).x; accuracy /= scale; } uniforms.SetFloatValue("u_accuracy", accuracy); uniforms.SetFloatValue("u_opacity", 1.0f); m_renderNode->Render(mng, uniforms); } }
m2::PointD OverlayHandle::GetPivot(ScreenBase const & screen, bool perspective) const { m2::RectD r = GetPixelRect(screen, false); m2::PointD size(0.5 * r.SizeX(), 0.5 * r.SizeY()); m2::PointD result = r.Center(); if (m_anchor & dp::Left) result.x -= size.x; else if (m_anchor & dp::Right) result.x += size.x; if (m_anchor & dp::Top) result.y -= size.y; else if (m_anchor & dp::Bottom) result.y += size.y; if (perspective) result = screen.PtoP3d(result, -m_pivotZ / screen.GetScale()); return result; }
inline m2::PointD GtoP3d(m2::PointD const & p) const { return m_currentModelView.PtoP3d(m_currentModelView.GtoP(p)); }