From 151a5989188410426f7a8cd95d783e772a8936f2 Mon Sep 17 00:00:00 2001 From: Dmitry Kunin Date: Mon, 10 Feb 2014 11:54:16 +0300 Subject: [PATCH] [drape] buttcap is flatcap --- drape/shaders/line_vertex_shader.vsh | 2 +- drape_frontend/line_shape.cpp | 41 ++++++++++++++++------------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/drape/shaders/line_vertex_shader.vsh b/drape/shaders/line_vertex_shader.vsh index 1784861fd7..7d5b1752df 100644 --- a/drape/shaders/line_vertex_shader.vsh +++ b/drape/shaders/line_vertex_shader.vsh @@ -23,7 +23,7 @@ void main(void) if (vertexType < 0.0) { - highp float quadWidth = a_vertType.y <= 0.0 ? 2.0 * abs(shift_mult) : abs(shift_mult); + highp float quadWidth = 2.0 * abs(shift_mult); highp vec4 pd = normalize(d * modelView) * quadWidth; pos = (pn - pd + pivot); } diff --git a/drape_frontend/line_shape.cpp b/drape_frontend/line_shape.cpp index 5b9797fe5b..d798a9c762 100644 --- a/drape_frontend/line_shape.cpp +++ b/drape_frontend/line_shape.cpp @@ -52,17 +52,21 @@ namespace df const float hw = GetWidth() / 2.0f; const float realWidth = GetWidth(); - // Add start cap quad + // We understand 'butt' cap as 'flat' + const bool doAddCap = m_params.m_cap != ButtCap; vec2 direction = m_points[1] - m_points[0]; m2::PointF firstPoint = m_points[0]; + // Add start cap quad + if (doAddCap) + { + renderPoints.push_back(Point3D::From2D(firstPoint, m_depth)); // A + renderDirections.push_back(Point3D::From2D(direction, hw)); + renderVertexTypes.push_back(Point3D(T_CAP, m_params.m_cap, realWidth)); - renderPoints.push_back(Point3D::From2D(firstPoint, m_depth)); // A - renderDirections.push_back(Point3D::From2D(direction, hw)); - renderVertexTypes.push_back(Point3D(T_CAP, m_params.m_cap, realWidth)); - - renderPoints.push_back(Point3D::From2D(firstPoint, m_depth)); // B - renderDirections.push_back(Point3D::From2D(direction, -hw)); - renderVertexTypes.push_back(Point3D(T_CAP, m_params.m_cap, realWidth)); + renderPoints.push_back(Point3D::From2D(firstPoint, m_depth)); // B + renderDirections.push_back(Point3D::From2D(direction, -hw)); + renderVertexTypes.push_back(Point3D(T_CAP, m_params.m_cap, realWidth)); + } // m2::PointF start = m_points[0]; @@ -174,17 +178,20 @@ namespace df } //Add final cap - vec2 lastSegment = m_points[count-1] - m_points[count-2]; - m2::PointF lastPoint = m_points[count-1]; - direction = -lastSegment; + if (doAddCap) + { + vec2 lastSegment = m_points[count-1] - m_points[count-2]; + m2::PointF lastPoint = m_points[count-1]; + direction = -lastSegment; - renderPoints.push_back(Point3D::From2D(lastPoint, m_depth)); // A - renderDirections.push_back(Point3D::From2D(direction, -hw)); - renderVertexTypes.push_back(Point3D(T_CAP, m_params.m_cap, realWidth)); + renderPoints.push_back(Point3D::From2D(lastPoint, m_depth)); // A + renderDirections.push_back(Point3D::From2D(direction, -hw)); + renderVertexTypes.push_back(Point3D(T_CAP, m_params.m_cap, realWidth)); - renderPoints.push_back(Point3D::From2D(lastPoint, m_depth)); // B - renderDirections.push_back(Point3D::From2D(direction, hw)); - renderVertexTypes.push_back(Point3D(T_CAP, m_params.m_cap, realWidth)); + renderPoints.push_back(Point3D::From2D(lastPoint, m_depth)); // B + renderDirections.push_back(Point3D::From2D(direction, hw)); + renderVertexTypes.push_back(Point3D(T_CAP, m_params.m_cap, realWidth)); + } // GLState state(gpu::SOLID_LINE_PROGRAM, 0, TextureBinding("", false, 0, MakeStackRefPointer(NULL)));