forked from organicmaps/organicmaps
Added end of route rendering
This commit is contained in:
parent
4e6ff00f5f
commit
e4c55c17dd
16 changed files with 191 additions and 58 deletions
|
@ -36,10 +36,11 @@ BackendRenderer::BackendRenderer(Params const & params)
|
|||
});
|
||||
|
||||
m_routeBuilder = make_unique_dp<RouteBuilder>([this](dp::GLState const & state, drape_ptr<dp::RenderBucket> && bucket,
|
||||
RouteData const & routeData)
|
||||
RouteData const & routeData, dp::GLState const & endOfRouteState,
|
||||
drape_ptr<dp::RenderBucket> && endOfRouteBucket)
|
||||
{
|
||||
m_commutator->PostMessage(ThreadsCommutator::RenderThread,
|
||||
make_unique_dp<FlushRouteMessage>(state, move(bucket), routeData),
|
||||
make_unique_dp<FlushRouteMessage>(state, move(bucket), routeData, endOfRouteState, move(endOfRouteBucket)),
|
||||
MessagePriority::Normal);
|
||||
});
|
||||
|
||||
|
|
|
@ -281,6 +281,14 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
|
|||
dp::GLState const & state = msg->GetState();
|
||||
drape_ptr<dp::RenderBucket> bucket = msg->AcceptBuffer();
|
||||
m_routeRenderer->AddRouteRenderBucket(state, move(bucket), msg->GetRouteData(), make_ref(m_gpuProgramManager));
|
||||
|
||||
dp::GLState const & eorState = msg->GetEndOfRouteState();
|
||||
drape_ptr<dp::RenderBucket> eorBucket = msg->AcceptEndOfRouteBuffer();
|
||||
if (eorBucket != nullptr)
|
||||
{
|
||||
m_routeRenderer->AddEndOfRouteRenderBucket(eorState, move(eorBucket), make_ref(m_gpuProgramManager));
|
||||
}
|
||||
|
||||
m_myPositionController->ActivateRouting();
|
||||
break;
|
||||
}
|
||||
|
@ -500,7 +508,8 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView)
|
|||
m_selectionShape->Render(modelView, make_ref(m_gpuProgramManager), m_generalUniforms);
|
||||
}
|
||||
|
||||
m_myPositionController->Render(modelView, make_ref(m_gpuProgramManager), m_generalUniforms);
|
||||
m_myPositionController->Render(MyPositionController::RenderAccuracy,
|
||||
modelView, make_ref(m_gpuProgramManager), m_generalUniforms);
|
||||
|
||||
for (; currentRenderGroup < m_renderGroups.size(); ++currentRenderGroup)
|
||||
{
|
||||
|
@ -522,6 +531,8 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView)
|
|||
|
||||
GLFunctions::glClearDepth();
|
||||
m_routeRenderer->Render(modelView, make_ref(m_gpuProgramManager), m_generalUniforms);
|
||||
m_myPositionController->Render(MyPositionController::RenderMyPosition,
|
||||
modelView, make_ref(m_gpuProgramManager), m_generalUniforms);
|
||||
|
||||
GLFunctions::glClearDepth();
|
||||
|
||||
|
|
|
@ -534,10 +534,13 @@ class FlushRouteMessage : public Message
|
|||
{
|
||||
public:
|
||||
FlushRouteMessage(dp::GLState const & state, drape_ptr<dp::RenderBucket> && buffer,
|
||||
RouteData const & routeData)
|
||||
RouteData const & routeData, dp::GLState const & endOfRouteState,
|
||||
drape_ptr<dp::RenderBucket> && endOfRouteBuffer)
|
||||
: m_state(state)
|
||||
, m_buffer(move(buffer))
|
||||
, m_routeData(routeData)
|
||||
, m_endOfRouteState(endOfRouteState)
|
||||
, m_endOfRouteBuffer(move(endOfRouteBuffer))
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Message::FlushRoute; }
|
||||
|
@ -546,10 +549,15 @@ public:
|
|||
drape_ptr<dp::RenderBucket> && AcceptBuffer() { return move(m_buffer); }
|
||||
RouteData const & GetRouteData() const { return m_routeData; }
|
||||
|
||||
dp::GLState const & GetEndOfRouteState() const { return m_endOfRouteState; }
|
||||
drape_ptr<dp::RenderBucket> && AcceptEndOfRouteBuffer() { return move(m_endOfRouteBuffer); }
|
||||
|
||||
private:
|
||||
dp::GLState m_state;
|
||||
drape_ptr<dp::RenderBucket> m_buffer;
|
||||
RouteData m_routeData;
|
||||
dp::GLState m_endOfRouteState;
|
||||
drape_ptr<dp::RenderBucket> m_endOfRouteBuffer;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -53,8 +53,9 @@ MyPosition::MyPosition(ref_ptr<dp::TextureManager> mng)
|
|||
, m_azimuth(0.0f)
|
||||
, m_accuracy(0.0f)
|
||||
, m_showAzimuth(false)
|
||||
, m_isRoutingMode(false)
|
||||
{
|
||||
m_parts.resize(3);
|
||||
m_parts.resize(4);
|
||||
CacheAccuracySector(mng);
|
||||
CachePointPosition(mng);
|
||||
}
|
||||
|
@ -79,29 +80,35 @@ void MyPosition::SetAccuracy(float accuracy)
|
|||
m_accuracy = accuracy;
|
||||
}
|
||||
|
||||
void MyPosition::Render(ScreenBase const & screen,
|
||||
void MyPosition::SetRoutingMode(bool routingMode)
|
||||
{
|
||||
m_isRoutingMode = routingMode;
|
||||
}
|
||||
|
||||
void MyPosition::RenderAccuracy(ScreenBase const & screen,
|
||||
ref_ptr<dp::GpuProgramManager> mng,
|
||||
dp::UniformValuesStorage const & commonUniforms)
|
||||
{
|
||||
dp::UniformValuesStorage uniforms = commonUniforms;
|
||||
m2::PointD accuracyPoint(m_position.x + m_accuracy, m_position.y);
|
||||
float pixelAccuracy = (screen.GtoP(accuracyPoint) - screen.GtoP(m_position)).Length();
|
||||
|
||||
{
|
||||
m2::PointD accuracyPoint(m_position.x + m_accuracy, m_position.y);
|
||||
float pixelAccuracy = (screen.GtoP(accuracyPoint) - screen.GtoP(m_position)).Length();
|
||||
dp::UniformValuesStorage accuracyUniforms = uniforms;
|
||||
accuracyUniforms.SetFloatValue("u_position", m_position.x, m_position.y, dp::depth::POSITION_ACCURACY);
|
||||
accuracyUniforms.SetFloatValue("u_accuracy", pixelAccuracy);
|
||||
accuracyUniforms.SetFloatValue("u_opacity", 1.0);
|
||||
RenderPart(mng, accuracyUniforms, MY_POSITION_ACCURACY);
|
||||
}
|
||||
uniforms.SetFloatValue("u_position", m_position.x, m_position.y, dp::depth::POSITION_ACCURACY);
|
||||
uniforms.SetFloatValue("u_accuracy", pixelAccuracy);
|
||||
uniforms.SetFloatValue("u_opacity", 1.0);
|
||||
RenderPart(mng, uniforms, MY_POSITION_ACCURACY);
|
||||
}
|
||||
|
||||
{
|
||||
dp::UniformValuesStorage arrowUniforms = uniforms;
|
||||
arrowUniforms.SetFloatValue("u_position", m_position.x, m_position.y, dp::depth::MY_POSITION_MARK);
|
||||
arrowUniforms.SetFloatValue("u_azimut", -(m_azimuth + screen.GetAngle()));
|
||||
arrowUniforms.SetFloatValue("u_opacity", 1.0);
|
||||
RenderPart(mng, arrowUniforms, (m_showAzimuth == true) ? MY_POSITION_ARROW : MY_POSITION_POINT);
|
||||
}
|
||||
void MyPosition::RenderMyPosition(ScreenBase const & screen,
|
||||
ref_ptr<dp::GpuProgramManager> mng,
|
||||
dp::UniformValuesStorage const & commonUniforms)
|
||||
{
|
||||
dp::UniformValuesStorage uniforms = commonUniforms;
|
||||
uniforms.SetFloatValue("u_position", m_position.x, m_position.y, dp::depth::MY_POSITION_MARK);
|
||||
uniforms.SetFloatValue("u_azimut", -(m_azimuth + screen.GetAngle()));
|
||||
uniforms.SetFloatValue("u_opacity", 1.0);
|
||||
RenderPart(mng, uniforms, (m_showAzimuth == true) ?
|
||||
(m_isRoutingMode ? MY_POSITION_ROUTING_ARROW : MY_POSITION_ARROW) : MY_POSITION_POINT);
|
||||
}
|
||||
|
||||
void MyPosition::CacheAccuracySector(ref_ptr<dp::TextureManager> mng)
|
||||
|
@ -153,9 +160,10 @@ void MyPosition::CacheAccuracySector(ref_ptr<dp::TextureManager> mng)
|
|||
|
||||
void MyPosition::CachePointPosition(ref_ptr<dp::TextureManager> mng)
|
||||
{
|
||||
dp::TextureManager::SymbolRegion pointSymbol, arrowSymbol;
|
||||
dp::TextureManager::SymbolRegion pointSymbol, arrowSymbol, routingArrowSymbol;
|
||||
mng->GetSymbolRegion("current-position", pointSymbol);
|
||||
mng->GetSymbolRegion("current-position-compas", arrowSymbol);
|
||||
mng->GetSymbolRegion("current-routing-compas", routingArrowSymbol);
|
||||
|
||||
m2::RectF const & pointTexRect = pointSymbol.GetTexRect();
|
||||
m2::PointF pointHalfSize = m2::PointF(pointSymbol.GetPixelSize()) * 0.5f;
|
||||
|
@ -179,12 +187,24 @@ void MyPosition::CachePointPosition(ref_ptr<dp::TextureManager> mng)
|
|||
{ glsl::vec2( arrowHalfSize.x, -arrowHalfSize.y), glsl::ToVec2(arrowTexRect.RightBottom())}
|
||||
};
|
||||
|
||||
m2::RectF const & routingArrowTexRect = routingArrowSymbol.GetTexRect();
|
||||
m2::PointF routingArrowHalfSize = m2::PointF(routingArrowSymbol.GetPixelSize()) * 0.5f;
|
||||
|
||||
Vertex routingArrowData[4]=
|
||||
{
|
||||
{ glsl::vec2(-routingArrowHalfSize.x, routingArrowHalfSize.y), glsl::ToVec2(routingArrowTexRect.LeftTop()) },
|
||||
{ glsl::vec2(-routingArrowHalfSize.x, -routingArrowHalfSize.y), glsl::ToVec2(routingArrowTexRect.LeftBottom()) },
|
||||
{ glsl::vec2( routingArrowHalfSize.x, routingArrowHalfSize.y), glsl::ToVec2(routingArrowTexRect.RightTop()) },
|
||||
{ glsl::vec2( routingArrowHalfSize.x, -routingArrowHalfSize.y), glsl::ToVec2(routingArrowTexRect.RightBottom())}
|
||||
};
|
||||
|
||||
ASSERT(pointSymbol.GetTexture() == arrowSymbol.GetTexture(), ());
|
||||
ASSERT(pointSymbol.GetTexture() == routingArrowSymbol.GetTexture(), ());
|
||||
dp::GLState state(gpu::MY_POSITION_PROGRAM, dp::GLState::OverlayLayer);
|
||||
state.SetColorTexture(pointSymbol.GetTexture());
|
||||
|
||||
{
|
||||
dp::Batcher batcher(2 * dp::Batcher::IndexPerQuad, 2 * dp::Batcher::VertexPerQuad);
|
||||
dp::Batcher batcher(3 * dp::Batcher::IndexPerQuad, 3 * dp::Batcher::VertexPerQuad);
|
||||
dp::SessionGuard guard(batcher, [this](dp::GLState const & state, drape_ptr<dp::RenderBucket> && b)
|
||||
{
|
||||
drape_ptr<dp::RenderBucket> bucket = move(b);
|
||||
|
@ -199,12 +219,21 @@ void MyPosition::CachePointPosition(ref_ptr<dp::TextureManager> mng)
|
|||
dp::AttributeProvider arrowProvider(1 /*stream count*/, dp::Batcher::VertexPerQuad);
|
||||
arrowProvider.InitStream(0 /*stream index*/, GetBindingInfo(), make_ref(arrowData));
|
||||
|
||||
dp::AttributeProvider routingArrowProvider(1 /*stream count*/, dp::Batcher::VertexPerQuad);
|
||||
routingArrowProvider.InitStream(0 /*stream index*/, GetBindingInfo(), make_ref(routingArrowData));
|
||||
|
||||
m_parts[MY_POSITION_POINT].second = m_nodes.size();
|
||||
m_parts[MY_POSITION_ARROW].second = m_nodes.size();
|
||||
m_parts[MY_POSITION_ROUTING_ARROW].second = m_nodes.size();
|
||||
|
||||
m_parts[MY_POSITION_POINT].first = batcher.InsertTriangleStrip(state, make_ref(&pointProvider), nullptr);
|
||||
ASSERT(m_parts[MY_POSITION_POINT].first.IsValid(), ());
|
||||
|
||||
m_parts[MY_POSITION_ARROW].first = batcher.InsertTriangleStrip(state, make_ref(&arrowProvider), nullptr);
|
||||
ASSERT(m_parts[MY_POSITION_ARROW].first.IsValid(), ());
|
||||
|
||||
m_parts[MY_POSITION_ROUTING_ARROW].first = batcher.InsertTriangleStrip(state, make_ref(&routingArrowProvider), nullptr);
|
||||
ASSERT(m_parts[MY_POSITION_ROUTING_ARROW].first.IsValid(), ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,15 @@ public:
|
|||
void SetAzimuth(float azimut);
|
||||
void SetIsValidAzimuth(bool isValid);
|
||||
void SetAccuracy(float accuracy);
|
||||
void SetRoutingMode(bool routingMode);
|
||||
|
||||
void Render(ScreenBase const & screen,
|
||||
ref_ptr<dp::GpuProgramManager> mng,
|
||||
dp::UniformValuesStorage const & commonUniforms);
|
||||
void RenderAccuracy(ScreenBase const & screen,
|
||||
ref_ptr<dp::GpuProgramManager> mng,
|
||||
dp::UniformValuesStorage const & commonUniforms);
|
||||
|
||||
void RenderMyPosition(ScreenBase const & screen,
|
||||
ref_ptr<dp::GpuProgramManager> mng,
|
||||
dp::UniformValuesStorage const & commonUniforms);
|
||||
|
||||
private:
|
||||
void CacheAccuracySector(ref_ptr<dp::TextureManager> mng);
|
||||
|
@ -39,7 +44,8 @@ private:
|
|||
// don't change order and values
|
||||
MY_POSITION_ACCURACY = 0,
|
||||
MY_POSITION_ARROW = 1,
|
||||
MY_POSITION_POINT = 2
|
||||
MY_POSITION_POINT = 2,
|
||||
MY_POSITION_ROUTING_ARROW = 3
|
||||
};
|
||||
|
||||
void RenderPart(ref_ptr<dp::GpuProgramManager> mng,
|
||||
|
@ -51,6 +57,7 @@ private:
|
|||
float m_azimuth;
|
||||
float m_accuracy;
|
||||
bool m_showAzimuth;
|
||||
bool m_isRoutingMode;
|
||||
|
||||
using TPart = pair<dp::IndicesRange, size_t>;
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ void MyPositionController::SetModeListener(location::TMyPositionModeChanged cons
|
|||
CallModeListener(m_modeInfo);
|
||||
}
|
||||
|
||||
void MyPositionController::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng,
|
||||
void MyPositionController::Render(uint32_t renderMode, ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng,
|
||||
dp::UniformValuesStorage const & commonUniforms)
|
||||
{
|
||||
location::EMyPositionMode currentMode = GetMode();
|
||||
|
@ -265,7 +265,13 @@ void MyPositionController::Render(ScreenBase const & screen, ref_ptr<dp::GpuProg
|
|||
m_shape->SetAzimuth(m_drawDirection);
|
||||
m_shape->SetIsValidAzimuth(IsRotationActive());
|
||||
m_shape->SetAccuracy(m_errorRadius);
|
||||
m_shape->Render(screen, mng, commonUniforms);
|
||||
m_shape->SetRoutingMode(IsInRouting());
|
||||
|
||||
if ((renderMode & RenderAccuracy) != 0)
|
||||
m_shape->RenderAccuracy(screen, mng, commonUniforms);
|
||||
|
||||
if ((renderMode & RenderMyPosition) != 0)
|
||||
m_shape->RenderMyPosition(screen, mng, commonUniforms);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,12 @@ public:
|
|||
virtual void ChangeModelView(m2::PointD const & userPos, double azimuth, m2::PointD const & pxZero) = 0;
|
||||
};
|
||||
|
||||
// Render bits
|
||||
// {
|
||||
static uint32_t const RenderAccuracy = 0x1;
|
||||
static uint32_t const RenderMyPosition = 0x2;
|
||||
// }
|
||||
|
||||
MyPositionController(location::EMyPositionMode initMode);
|
||||
|
||||
void SetPixelRect(m2::RectD const & pixelRect);
|
||||
|
@ -70,7 +76,7 @@ public:
|
|||
|
||||
void SetModeListener(location::TMyPositionModeChanged const & fn);
|
||||
|
||||
void Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng,
|
||||
void Render(uint32_t renderMode, ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng,
|
||||
dp::UniformValuesStorage const & commonUniforms);
|
||||
|
||||
private:
|
||||
|
|
|
@ -20,7 +20,7 @@ void RouteBuilder::Build(m2::PolylineD const & routePolyline, vector<double> co
|
|||
|
||||
RouteShape shape(routePolyline, params);
|
||||
m2::RectF textureRect = shape.GetArrowTextureRect(textures);
|
||||
shape.PrepareGeometry();
|
||||
shape.PrepareGeometry(textures);
|
||||
|
||||
RouteData routeData;
|
||||
routeData.m_color = color;
|
||||
|
@ -29,10 +29,14 @@ void RouteBuilder::Build(m2::PolylineD const & routePolyline, vector<double> co
|
|||
routeData.m_length = shape.GetLength();
|
||||
routeData.m_turns = turns;
|
||||
|
||||
auto flushRoute = [this, &routeData](dp::GLState const & state, drape_ptr<dp::RenderBucket> && bucket)
|
||||
dp::GLState eorState = shape.GetEndOfRouteState();
|
||||
drape_ptr<dp::RenderBucket> eorBucket = shape.MoveEndOfRouteRenderBucket();
|
||||
|
||||
auto flushRoute = [this, &routeData, &eorState, &eorBucket](dp::GLState const & state,
|
||||
drape_ptr<dp::RenderBucket> && bucket)
|
||||
{
|
||||
if (m_flushRouteFn != nullptr)
|
||||
m_flushRouteFn(state, move(bucket), routeData);
|
||||
m_flushRouteFn(state, move(bucket), routeData, eorState, move(eorBucket));
|
||||
};
|
||||
|
||||
m_batcher->StartSession(flushRoute);
|
||||
|
|
|
@ -28,7 +28,8 @@ struct RouteData
|
|||
class RouteBuilder
|
||||
{
|
||||
public:
|
||||
using TFlushRouteFn = function<void(dp::GLState const &, drape_ptr<dp::RenderBucket> &&, RouteData const &)>;
|
||||
using TFlushRouteFn = function<void(dp::GLState const &, drape_ptr<dp::RenderBucket> &&, RouteData const &,
|
||||
dp::GLState const &, drape_ptr<dp::RenderBucket> &&)>;
|
||||
|
||||
RouteBuilder(TFlushRouteFn const & flushRouteFn);
|
||||
|
||||
|
|
|
@ -131,6 +131,7 @@ RouteGraphics::RouteGraphics(dp::GLState const & state,
|
|||
|
||||
RouteRenderer::RouteRenderer()
|
||||
: m_distanceFromBegin(0.0)
|
||||
, m_endOfRouteState(0, dp::GLState::OverlayLayer)
|
||||
{}
|
||||
|
||||
void RouteRenderer::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng,
|
||||
|
@ -168,6 +169,18 @@ void RouteRenderer::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramMana
|
|||
if (truncedZoom >= arrowAppearingZoomLevel)
|
||||
RenderArrow(graphics, halfWidth, screen, mng, commonUniforms);
|
||||
}
|
||||
|
||||
// render end of route
|
||||
if (m_endOfRouteBuffer != nullptr)
|
||||
{
|
||||
dp::UniformValuesStorage uniforms = commonUniforms;
|
||||
uniforms.SetFloatValue("u_opacity", 1.0);
|
||||
ref_ptr<dp::GpuProgram> eorProgram = mng->GetProgram(m_endOfRouteState.GetProgramIndex());
|
||||
eorProgram->Bind();
|
||||
dp::ApplyState(m_endOfRouteState, eorProgram);
|
||||
dp::ApplyUniforms(uniforms, eorProgram);
|
||||
m_endOfRouteBuffer->Render();
|
||||
}
|
||||
}
|
||||
|
||||
void RouteRenderer::RenderArrow(RouteGraphics const & graphics, float halfWidth, ScreenBase const & screen,
|
||||
|
@ -240,9 +253,18 @@ void RouteRenderer::AddRouteRenderBucket(dp::GLState const & state, drape_ptr<dp
|
|||
route.m_buffer->Build(mng->GetProgram(route.m_state.GetProgramIndex()));
|
||||
}
|
||||
|
||||
void RouteRenderer::AddEndOfRouteRenderBucket(dp::GLState const & state, drape_ptr<dp::RenderBucket> && bucket,
|
||||
ref_ptr<dp::GpuProgramManager> mng)
|
||||
{
|
||||
m_endOfRouteState = state;
|
||||
m_endOfRouteBuffer = bucket->MoveBuffer();
|
||||
m_endOfRouteBuffer->Build(mng->GetProgram(m_endOfRouteState.GetProgramIndex()));
|
||||
}
|
||||
|
||||
void RouteRenderer::Clear()
|
||||
{
|
||||
m_routeGraphics.clear();
|
||||
m_endOfRouteBuffer.reset();
|
||||
}
|
||||
|
||||
void RouteRenderer::UpdateDistanceFromBegin(double distanceFromBegin)
|
||||
|
@ -314,6 +336,10 @@ void RouteRenderer::CalculateArrowBorders(double arrowLength, double scale, doub
|
|||
arrowBorders.m_groupIndex = (int)i;
|
||||
arrowBorders.m_startDistance = max(0.0, m_routeData.m_turns[i] - halfLen * 0.8);
|
||||
arrowBorders.m_endDistance = min(m_routeData.m_length, m_routeData.m_turns[i] + halfLen * 1.2);
|
||||
|
||||
if (arrowBorders.m_startDistance < m_distanceFromBegin)
|
||||
continue;
|
||||
|
||||
borders.push_back(arrowBorders);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ public:
|
|||
void AddRouteRenderBucket(dp::GLState const & state, drape_ptr<dp::RenderBucket> && bucket,
|
||||
RouteData const & routeData, ref_ptr<dp::GpuProgramManager> mng);
|
||||
|
||||
void AddEndOfRouteRenderBucket(dp::GLState const & state, drape_ptr<dp::RenderBucket> && bucket,
|
||||
ref_ptr<dp::GpuProgramManager> mng);
|
||||
|
||||
void Clear();
|
||||
|
||||
void UpdateDistanceFromBegin(double distanceFromBegin);
|
||||
|
@ -62,6 +65,9 @@ private:
|
|||
vector<RouteGraphics> m_routeGraphics;
|
||||
double m_distanceFromBegin;
|
||||
RouteData m_routeData;
|
||||
|
||||
dp::GLState m_endOfRouteState;
|
||||
drape_ptr<dp::VertexArrayBuffer> m_endOfRouteBuffer;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "drape/batcher.hpp"
|
||||
#include "drape/glsl_func.hpp"
|
||||
#include "drape/glsl_types.hpp"
|
||||
#include "drape/glstate.hpp"
|
||||
#include "drape/shader_def.hpp"
|
||||
#include "drape/texture_manager.hpp"
|
||||
|
||||
|
@ -31,6 +30,7 @@ RouteShape::RouteShape(m2::PolylineD const & polyline, CommonViewParams const &
|
|||
: m_params(params)
|
||||
, m_polyline(polyline)
|
||||
, m_length(0)
|
||||
, m_endOfRouteState(0, dp::GLState::OverlayLayer)
|
||||
{}
|
||||
|
||||
m2::RectF RouteShape::GetArrowTextureRect(ref_ptr<dp::TextureManager> textures) const
|
||||
|
@ -40,7 +40,7 @@ m2::RectF RouteShape::GetArrowTextureRect(ref_ptr<dp::TextureManager> textures)
|
|||
return region.GetTexRect();
|
||||
}
|
||||
|
||||
void RouteShape::PrepareGeometry()
|
||||
void RouteShape::PrepareGeometry(ref_ptr<dp::TextureManager> textures)
|
||||
{
|
||||
vector<m2::PointD> const & path = m_polyline.GetPoints();
|
||||
ASSERT(path.size() > 1, ());
|
||||
|
@ -169,6 +169,45 @@ void RouteShape::PrepareGeometry()
|
|||
bounds.m_offset = len;
|
||||
m_joinsBounds.push_back(bounds);
|
||||
}
|
||||
|
||||
CacheEndOfRouteSign(textures);
|
||||
}
|
||||
|
||||
void RouteShape::CacheEndOfRouteSign(ref_ptr<dp::TextureManager> mng)
|
||||
{
|
||||
dp::TextureManager::SymbolRegion symbol;
|
||||
mng->GetSymbolRegion("route_to", symbol);
|
||||
|
||||
m2::RectF const & texRect = symbol.GetTexRect();
|
||||
m2::PointF halfSize = m2::PointF(symbol.GetPixelSize()) * 0.5f;
|
||||
|
||||
glsl::vec2 const pos = glsl::ToVec2(m_polyline.Back());
|
||||
glsl::vec3 const pivot = glsl::vec3(pos.x, pos.y, m_params.m_depth);
|
||||
gpu::SolidTexturingVertex data[4]=
|
||||
{
|
||||
{ pivot, glsl::vec2(-halfSize.x, halfSize.y), glsl::ToVec2(texRect.LeftTop()) },
|
||||
{ pivot, glsl::vec2(-halfSize.x, -halfSize.y), glsl::ToVec2(texRect.LeftBottom()) },
|
||||
{ pivot, glsl::vec2( halfSize.x, halfSize.y), glsl::ToVec2(texRect.RightTop()) },
|
||||
{ pivot, glsl::vec2( halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom()) }
|
||||
};
|
||||
|
||||
dp::GLState state(gpu::TEXTURING_PROGRAM, dp::GLState::OverlayLayer);
|
||||
state.SetColorTexture(symbol.GetTexture());
|
||||
|
||||
{
|
||||
dp::Batcher batcher(dp::Batcher::IndexPerQuad, dp::Batcher::VertexPerQuad);
|
||||
dp::SessionGuard guard(batcher, [this](dp::GLState const & state, drape_ptr<dp::RenderBucket> && b)
|
||||
{
|
||||
m_endOfRouteRenderBucket = move(b);
|
||||
m_endOfRouteState = state;
|
||||
});
|
||||
|
||||
dp::AttributeProvider provider(1 /*stream count*/, dp::Batcher::VertexPerQuad);
|
||||
provider.InitStream(0 /*stream index*/, gpu::SolidTexturingVertex::GetBindingInfo(), make_ref(data));
|
||||
|
||||
dp::IndicesRange indices = batcher.InsertTriangleStrip(state, make_ref(&provider), nullptr);
|
||||
ASSERT(indices.IsValid(), ());
|
||||
}
|
||||
}
|
||||
|
||||
void RouteShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures)
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "drape_frontend/map_shape.hpp"
|
||||
#include "drape_frontend/shape_view_params.hpp"
|
||||
|
||||
#include "drape/glstate.hpp"
|
||||
#include "drape/render_bucket.hpp"
|
||||
#include "drape/utils/vertex_decl.hpp"
|
||||
|
||||
#include "geometry/polyline2d.hpp"
|
||||
|
@ -28,14 +30,18 @@ public:
|
|||
m2::RectF GetArrowTextureRect(ref_ptr<dp::TextureManager> textures) const;
|
||||
vector<RouteJoinBounds> const & GetJoinsBounds() const { return m_joinsBounds; }
|
||||
double GetLength() const { return m_length; }
|
||||
dp::GLState const & GetEndOfRouteState() const { return m_endOfRouteState; }
|
||||
drape_ptr<dp::RenderBucket> && MoveEndOfRouteRenderBucket() { return move(m_endOfRouteRenderBucket); }
|
||||
|
||||
void PrepareGeometry();
|
||||
void PrepareGeometry(ref_ptr<dp::TextureManager> textures);
|
||||
void Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures);
|
||||
|
||||
private:
|
||||
using RV = gpu::RouteVertex;
|
||||
using TGeometryBuffer = buffer_vector<gpu::RouteVertex, 128>;
|
||||
|
||||
void CacheEndOfRouteSign(ref_ptr<dp::TextureManager> mng);
|
||||
|
||||
TGeometryBuffer m_geometry;
|
||||
TGeometryBuffer m_joinsGeometry;
|
||||
vector<RouteJoinBounds> m_joinsBounds;
|
||||
|
@ -43,6 +49,9 @@ private:
|
|||
|
||||
CommonViewParams m_params;
|
||||
m2::PolylineD m_polyline;
|
||||
|
||||
dp::GLState m_endOfRouteState;
|
||||
drape_ptr<dp::RenderBucket> m_endOfRouteRenderBucket;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
|
|
@ -513,23 +513,6 @@ void TestingEngine::DrawImpl()
|
|||
LineShape(spl1, lvp).Draw(make_ref(m_batcher), make_ref(m_textures));
|
||||
}
|
||||
|
||||
{
|
||||
vector<m2::PointD> path1;
|
||||
path1.push_back(m2::PointD(80.277071f, 37.9271164f));
|
||||
path1.push_back(m2::PointD(80.277071f, 35.9271164f));
|
||||
path1.push_back(m2::PointD(86.277071f, 35.9271164f));
|
||||
path1.push_back(m2::PointD(86.277071f, 30.9271164f));
|
||||
path1.push_back(m2::PointD(88.277071f, 32.9271164f));
|
||||
path1.push_back(m2::PointD(89.277071f, 39.9271164f));
|
||||
m2::PolylineD pln(path1);
|
||||
|
||||
CommonViewParams rvp;
|
||||
rvp.m_depth = 95.0f;
|
||||
RouteShape shape(pln, rvp);
|
||||
shape.PrepareGeometry();
|
||||
shape.Draw(make_ref(m_batcher), make_ref(m_textures));
|
||||
}
|
||||
|
||||
{
|
||||
vector<m2::PointF> trg{ m2::PointD(110.0f, 30.0f), m2::PointD(112.0f, 30.0f), m2::PointD(112.0f, 28.0f),
|
||||
m2::PointD(110.0f, 30.0f), m2::PointD(112.0f, 28.0f), m2::PointD(110.0f, 28.0f) };
|
||||
|
|
|
@ -20,7 +20,6 @@ HEADERS += \
|
|||
ge0_parser.hpp \
|
||||
geourl_process.hpp \
|
||||
mwm_url.hpp \
|
||||
route_track.hpp \
|
||||
routing_session.hpp \
|
||||
storage_bridge.hpp \
|
||||
track.hpp \
|
||||
|
@ -39,7 +38,6 @@ SOURCES += \
|
|||
ge0_parser.cpp \
|
||||
geourl_process.cpp \
|
||||
mwm_url.cpp \
|
||||
route_track.cpp \
|
||||
routing_session.cpp \
|
||||
storage_bridge.cpp \
|
||||
track.cpp \
|
||||
|
|
|
@ -33,7 +33,6 @@ SOURCES += \
|
|||
geourl_test.cpp \
|
||||
kmz_unarchive_test.cpp \
|
||||
mwm_url_tests.cpp \
|
||||
tracks_tests.cpp \
|
||||
|
||||
!linux* {
|
||||
SOURCES += working_time_tests.cpp \
|
||||
|
|
Loading…
Add table
Reference in a new issue