| 91 | } |
| 92 | |
| 93 | void SelectionShape::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::ProgramManager> mng, |
| 94 | ScreenBase const & screen, int zoomLevel, FrameValues const & frameValues) |
| 95 | { |
| 96 | if (!IsVisible()) |
| 97 | return; |
| 98 | |
| 99 | if (m_selectionGeometry.empty()) |
| 100 | { |
| 101 | gpu::ShapesProgramParams params; |
| 102 | frameValues.SetTo(params); |
| 103 | TileKey const key = GetTileKeyByPoint(m_position, ClipTileZoomByMaxDataZoom(zoomLevel)); |
| 104 | params.m_modelView = glsl::make_mat4(key.GetTileBasedModelView(screen).m_data); |
| 105 | |
| 106 | m2::PointD const pos = MapShape::ConvertToLocal(m_position, key.GetGlobalRect().Center(), kShapeCoordScalar); |
| 107 | params.m_position = glsl::vec3(pos.x, pos.y, -m_positionZ); |
| 108 | |
| 109 | float accuracy = m_selectedObject == OBJECT_TRACK ? 1.0 : m_mapping.GetValue(m_animation.GetT()); |
| 110 | if (screen.isPerspective()) |
| 111 | { |
| 112 | m2::PointD const pt1 = screen.GtoP(m_position); |
| 113 | m2::PointD const pt2(pt1.x + 1, pt1.y); |
| 114 | auto const scale = static_cast<float>(screen.PtoP3d(pt2).x - screen.PtoP3d(pt1).x); |
| 115 | accuracy /= scale; |
| 116 | } |
| 117 | params.m_accuracy = accuracy; |
| 118 | if (m_selectedObject == OBJECT_TRACK) |
| 119 | m_trackRenderNode->Render(context, mng, params); |
| 120 | else |
| 121 | m_renderNode->Render(context, mng, params); |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | // Render selection geometry. |
| 126 | double zoom = 0.0; |
| 127 | int index = 0; |
| 128 | float lerpCoef = 0.0f; |
| 129 | ExtractZoomFactors(screen, zoom, index, lerpCoef); |
| 130 | float const currentHalfWidth = |
| 131 | InterpolateByZoomLevels(index, lerpCoef, kHalfLineWidthInPixel) * VisualParams::Instance().GetVisualScale(); |
| 132 | auto const screenHalfWidth = static_cast<float>(currentHalfWidth * screen.GetScale()); |
| 133 | |
| 134 | gpu::ShapesProgramParams geomParams; |
| 135 | frameValues.SetTo(geomParams); |
| 136 | geomParams.m_lineParams = glsl::vec2(currentHalfWidth, screenHalfWidth); |
| 137 | for (auto const & geometry : m_selectionGeometry) |
| 138 | { |
| 139 | math::Matrix<float, 4, 4> mv = screen.GetModelView(geometry->GetPivot(), kShapeCoordScalar); |
| 140 | geomParams.m_modelView = glsl::make_mat4(mv.m_data); |
| 141 | geometry->Render(context, mng, geomParams); |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | SelectionShape::ESelectedObject SelectionShape::GetSelectedObject() const |
| 147 | { |
nothing calls this directly
no test coverage detected