forked from organicmaps/organicmaps
Restricted transit line width, fixed rendering order
This commit is contained in:
parent
5830f821e2
commit
6ec3fc658d
7 changed files with 84 additions and 46 deletions
|
@ -1302,7 +1302,7 @@ void FrontendRenderer::RenderNavigationOverlayLayer(ScreenBase const & modelView
|
|||
|
||||
bool FrontendRenderer::HasTransitData()
|
||||
{
|
||||
return !m_layers[RenderState::TransitMarkLayer].m_renderGroups.empty();
|
||||
return m_routeRenderer->HasTransitData();
|
||||
}
|
||||
|
||||
void FrontendRenderer::RenderTrafficLayer(ScreenBase const & modelView)
|
||||
|
|
|
@ -229,6 +229,14 @@ RouteRenderer::Subroutes::iterator FindSubroute(RouteRenderer::Subroutes & subro
|
|||
return info.m_subrouteId == subrouteId;
|
||||
});
|
||||
}
|
||||
|
||||
float GetCurrentHalfWidth(df::RouteRenderer::SubrouteInfo const & subrouteInfo)
|
||||
{
|
||||
if (subrouteInfo.m_subroute->m_maxPixelWidth < 0.0f)
|
||||
return subrouteInfo.m_baseHalfWidth;
|
||||
|
||||
return std::min(subrouteInfo.m_baseHalfWidth, subrouteInfo.m_subroute->m_maxPixelWidth * 0.5f);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
RouteRenderer::RouteRenderer(PreviewPointsRequestCallback && previewPointsRequest)
|
||||
|
@ -249,7 +257,7 @@ void RouteRenderer::UpdateRoute(ScreenBase const & screen, CacheRouteArrowsCallb
|
|||
double zoom = 0.0;
|
||||
float halfWidth = 0.0;
|
||||
InterpolateByZoom(subrouteInfo.m_subroute, screen, halfWidth, zoom);
|
||||
subrouteInfo.m_currentHalfWidth = halfWidth;
|
||||
subrouteInfo.m_baseHalfWidth = halfWidth;
|
||||
|
||||
if (zoom < kArrowAppearingZoomLevel)
|
||||
{
|
||||
|
@ -386,8 +394,9 @@ void RouteRenderer::RenderSubroute(SubrouteInfo const & subrouteInfo, size_t sub
|
|||
return;
|
||||
|
||||
auto const & subrouteData = subrouteInfo.m_subrouteData[subrouteDataIndex];
|
||||
float const currentHalfWidth = GetCurrentHalfWidth(subrouteInfo);
|
||||
|
||||
auto const screenHalfWidth = static_cast<float>(subrouteInfo.m_currentHalfWidth * screen.GetScale());
|
||||
auto const screenHalfWidth = static_cast<float>(currentHalfWidth * screen.GetScale());
|
||||
auto dist = static_cast<float>(kInvalidDistance);
|
||||
if (m_followingEnabled)
|
||||
{
|
||||
|
@ -408,7 +417,7 @@ void RouteRenderer::RenderSubroute(SubrouteInfo const & subrouteInfo, size_t sub
|
|||
glsl::vec4 const color = glsl::ToVec4(df::GetColorConstant(style.m_color));
|
||||
uniforms.SetFloatValue("u_color", color.r, color.g, color.b, color.a);
|
||||
|
||||
uniforms.SetFloatValue("u_routeParams", subrouteInfo.m_currentHalfWidth, screenHalfWidth, dist,
|
||||
uniforms.SetFloatValue("u_routeParams", currentHalfWidth, screenHalfWidth, dist,
|
||||
trafficShown ? 1.0f : 0.0f);
|
||||
|
||||
glsl::vec4 const maskColor = glsl::ToVec4(GetMaskColor(subrouteData->m_subroute->m_routeType,
|
||||
|
@ -454,13 +463,14 @@ void RouteRenderer::RenderSubrouteArrows(SubrouteInfo const & subrouteInfo,
|
|||
}
|
||||
|
||||
dp::GLState const & state = subrouteInfo.m_arrowsData->m_renderProperty.m_state;
|
||||
float const currentHalfWidth = GetCurrentHalfWidth(subrouteInfo);
|
||||
|
||||
// Set up shaders and apply common uniforms.
|
||||
dp::UniformValuesStorage uniforms = commonUniforms;
|
||||
math::Matrix<float, 4, 4> mv = screen.GetModelView(subrouteInfo.m_arrowsData->m_pivot,
|
||||
kShapeCoordScalar);
|
||||
uniforms.SetMatrix4x4Value("modelView", mv.m_data);
|
||||
auto const arrowHalfWidth = static_cast<float>(subrouteInfo.m_currentHalfWidth * kArrowHeightFactor);
|
||||
auto const arrowHalfWidth = static_cast<float>(currentHalfWidth * kArrowHeightFactor);
|
||||
uniforms.SetFloatValue("u_arrowHalfWidth", arrowHalfWidth);
|
||||
uniforms.SetFloatValue("u_opacity", 1.0f);
|
||||
|
||||
|
@ -493,13 +503,14 @@ void RouteRenderer::RenderSubrouteMarkers(SubrouteInfo const & subrouteInfo, Scr
|
|||
dist = static_cast<float>(m_distanceFromBegin - subrouteInfo.m_subroute->m_baseDistance);
|
||||
|
||||
dp::GLState const & state = subrouteInfo.m_markersData->m_renderProperty.m_state;
|
||||
float const currentHalfWidth = GetCurrentHalfWidth(subrouteInfo);
|
||||
|
||||
// Set up shaders and apply common uniforms.
|
||||
dp::UniformValuesStorage uniforms = commonUniforms;
|
||||
math::Matrix<float, 4, 4> mv = screen.GetModelView(subrouteInfo.m_markersData->m_pivot,
|
||||
kShapeCoordScalar);
|
||||
uniforms.SetMatrix4x4Value("modelView", mv.m_data);
|
||||
uniforms.SetFloatValue("u_routeParams", subrouteInfo.m_currentHalfWidth, dist);
|
||||
uniforms.SetFloatValue("u_routeParams", currentHalfWidth, dist);
|
||||
uniforms.SetFloatValue("u_opacity", 1.0f);
|
||||
|
||||
glsl::vec4 const maskColor = glsl::ToVec4(GetMaskColor(subrouteInfo.m_subroute->m_routeType,
|
||||
|
@ -544,20 +555,17 @@ void RouteRenderer::RenderRoute(ScreenBase const & screen, bool trafficShown,
|
|||
ref_ptr<dp::GpuProgramManager> mng,
|
||||
dp::UniformValuesStorage const & commonUniforms)
|
||||
{
|
||||
if (!m_subroutes.empty())
|
||||
for (auto const & subroute : m_subroutes)
|
||||
{
|
||||
for (auto const & subroute : m_subroutes)
|
||||
{
|
||||
// Render subroutes.
|
||||
for (size_t i = 0; i < subroute.m_subrouteData.size(); ++i)
|
||||
RenderSubroute(subroute, i, screen, trafficShown, mng, commonUniforms);
|
||||
// Render subroutes.
|
||||
for (size_t i = 0; i < subroute.m_subrouteData.size(); ++i)
|
||||
RenderSubroute(subroute, i, screen, trafficShown, mng, commonUniforms);
|
||||
|
||||
// Render markers.
|
||||
RenderSubrouteMarkers(subroute, screen, mng, commonUniforms);
|
||||
// Render markers.
|
||||
RenderSubrouteMarkers(subroute, screen, mng, commonUniforms);
|
||||
|
||||
// Render arrows.
|
||||
RenderSubrouteArrows(subroute, screen, mng, commonUniforms);
|
||||
}
|
||||
// Render arrows.
|
||||
RenderSubrouteArrows(subroute, screen, mng, commonUniforms);
|
||||
}
|
||||
|
||||
// Render preview.
|
||||
|
@ -730,4 +738,14 @@ void RouteRenderer::SetSubrouteVisibility(dp::DrapeID id, bool isVisible)
|
|||
else
|
||||
m_hiddenSubroutes.insert(id);
|
||||
}
|
||||
|
||||
bool RouteRenderer::HasTransitData() const
|
||||
{
|
||||
for (auto const & subroute : m_subroutes)
|
||||
{
|
||||
if (subroute.m_subroute->m_routeType == RouteType::Transit)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace df
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
drape_ptr<SubrouteArrowsData> m_arrowsData;
|
||||
std::vector<ArrowBorders> m_arrowBorders;
|
||||
float m_currentHalfWidth = 0.0f;
|
||||
float m_baseHalfWidth = 0.0f;
|
||||
|
||||
drape_ptr<SubrouteMarkersData> m_markersData;
|
||||
};
|
||||
|
@ -87,6 +87,8 @@ public:
|
|||
|
||||
void SetSubrouteVisibility(dp::DrapeID id, bool isVisible);
|
||||
|
||||
bool HasTransitData() const;
|
||||
|
||||
private:
|
||||
void RenderSubroute(SubrouteInfo const & subrouteInfo, size_t subrouteDataIndex,
|
||||
ScreenBase const & screen, bool trafficShown, ref_ptr<dp::GpuProgramManager> mng,
|
||||
|
|
|
@ -145,6 +145,7 @@ struct Subroute
|
|||
std::vector<traffic::SpeedGroup> m_traffic;
|
||||
double m_baseDistance = 0.0;
|
||||
double m_baseDepthIndex = 0.0;
|
||||
float m_maxPixelWidth = -1.0f;
|
||||
|
||||
SubrouteStyleType m_styleType = SubrouteStyleType::Single;
|
||||
std::vector<SubrouteStyle> m_style;
|
||||
|
|
|
@ -497,13 +497,15 @@ void RoutingManager::InsertRoute(Route const & route)
|
|||
{
|
||||
case RouterType::Vehicle:
|
||||
case RouterType::Taxi:
|
||||
subroute->m_routeType = m_currentRouterType == RouterType::Vehicle ?
|
||||
df::RouteType::Car : df::RouteType::Taxi;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteColor, df::kRouteOutlineColor));
|
||||
FillTrafficForRendering(segments, subroute->m_traffic);
|
||||
FillTurnsDistancesForRendering(segments, subroute->m_baseDistance,
|
||||
subroute->m_turns);
|
||||
break;
|
||||
{
|
||||
subroute->m_routeType = m_currentRouterType == RouterType::Vehicle ?
|
||||
df::RouteType::Car : df::RouteType::Taxi;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteColor, df::kRouteOutlineColor));
|
||||
FillTrafficForRendering(segments, subroute->m_traffic);
|
||||
FillTurnsDistancesForRendering(segments, subroute->m_baseDistance,
|
||||
subroute->m_turns);
|
||||
break;
|
||||
}
|
||||
case RouterType::Transit:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Transit;
|
||||
|
@ -517,15 +519,19 @@ void RoutingManager::InsertRoute(Route const & route)
|
|||
break;
|
||||
}
|
||||
case RouterType::Pedestrian:
|
||||
subroute->m_routeType = df::RouteType::Pedestrian;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRoutePedestrian, df::RoutePattern(4.0, 2.0)));
|
||||
break;
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Pedestrian;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRoutePedestrian, df::RoutePattern(4.0, 2.0)));
|
||||
break;
|
||||
}
|
||||
case RouterType::Bicycle:
|
||||
subroute->m_routeType = df::RouteType::Bicycle;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteBicycle, df::RoutePattern(8.0, 2.0)));
|
||||
FillTurnsDistancesForRendering(segments, subroute->m_baseDistance,
|
||||
subroute->m_turns);
|
||||
break;
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Bicycle;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteBicycle, df::RoutePattern(8.0, 2.0)));
|
||||
FillTurnsDistancesForRendering(segments, subroute->m_baseDistance,
|
||||
subroute->m_turns);
|
||||
break;
|
||||
}
|
||||
default: ASSERT(false, ("Unknown router type"));
|
||||
}
|
||||
|
||||
|
@ -972,19 +978,19 @@ void RoutingManager::SetDrapeEngine(ref_ptr<df::DrapeEngine> engine, bool is3dAl
|
|||
}
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::RequestSymbolsSize, symbols,
|
||||
[this](std::vector<m2::PointF> const & sizes)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, sizes]()
|
||||
{
|
||||
auto it = kTransitSymbols.begin();
|
||||
for (size_t i = 0; i < sizes.size(); i += 3)
|
||||
{
|
||||
m_transitSymbolSizes[it->second + "-s"] = sizes[i];
|
||||
m_transitSymbolSizes[it->second + "-m"] = sizes[i + 1];
|
||||
m_transitSymbolSizes[it->second + "-l"] = sizes[i + 2];
|
||||
++it;
|
||||
}
|
||||
});
|
||||
});
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, sizes]()
|
||||
{
|
||||
auto it = kTransitSymbols.begin();
|
||||
for (size_t i = 0; i < sizes.size(); i += 3)
|
||||
{
|
||||
m_transitSymbolSizes[it->second + "-s"] = sizes[i];
|
||||
m_transitSymbolSizes[it->second + "-m"] = sizes[i + 1];
|
||||
m_transitSymbolSizes[it->second + "-l"] = sizes[i + 2];
|
||||
++it;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// In case of the engine reinitialization recover route.
|
||||
if (IsRoutingActive())
|
||||
|
|
|
@ -166,6 +166,15 @@ TransitRouteDisplay::TransitRouteDisplay(TransitReadManager & transitReadManager
|
|||
, m_bmManager(bmManager)
|
||||
, m_symbolSizes(transitSymbolSizes)
|
||||
{
|
||||
float maxSymbolSize = -1.0f;
|
||||
for (auto const & symbolSize : m_symbolSizes)
|
||||
{
|
||||
if (maxSymbolSize < symbolSize.second.x)
|
||||
maxSymbolSize = symbolSize.second.x;
|
||||
if (maxSymbolSize < symbolSize.second.y)
|
||||
maxSymbolSize = symbolSize.second.y;
|
||||
}
|
||||
m_maxSubrouteWidth = maxSymbolSize * kGateBgScale / kStopMarkerScale;
|
||||
}
|
||||
|
||||
TransitRouteInfo const & TransitRouteDisplay::GetRouteInfo()
|
||||
|
@ -194,6 +203,7 @@ void TransitRouteDisplay::ProcessSubroute(vector<RouteSegment> const & segments,
|
|||
|
||||
std::vector<TransitMarkInfo> transitMarks;
|
||||
|
||||
subroute.m_maxPixelWidth = m_maxSubrouteWidth;
|
||||
subroute.m_styleType = df::SubrouteStyleType::Multiple;
|
||||
subroute.m_style.clear();
|
||||
subroute.m_style.reserve(segments.size());
|
||||
|
|
|
@ -126,4 +126,5 @@ private:
|
|||
TransitRouteInfo m_routeInfo;
|
||||
|
||||
int m_subrouteIndex = 0;
|
||||
float m_maxSubrouteWidth = -1.0f;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue