diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2016-12-07 17:00:25 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2016-12-07 17:10:13 +0300 |
commit | 4707e83608ce69b72c2d6dc4eeace2f6a9953a32 (patch) | |
tree | 870c084cc8a815e3da12051707f541ff04da7005 /drape_frontend | |
parent | 2944c4b0135b8212dc06528fae08033ff09f4e4e (diff) |
Optimized caps rendering in lines
Diffstat (limited to 'drape_frontend')
-rw-r--r-- | drape_frontend/line_shape.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/drape_frontend/line_shape.cpp b/drape_frontend/line_shape.cpp index 4f92d2e266..b55592df75 100644 --- a/drape_frontend/line_shape.cpp +++ b/drape_frontend/line_shape.cpp @@ -245,21 +245,19 @@ public: private: void CreateRoundCap(glsl::vec2 const & pos) { - m_capGeometry.reserve(8); - + // Here we use an equilateral triangle to render circle (incircle of a triangle). + static float const kSqrt3 = sqrt(3.0f); float const radius = GetHalfWidth(); + m_capGeometry.reserve(3); m_capGeometry.push_back(CapVertex(CapVertex::TPosition(pos, m_params.m_depth), - CapVertex::TNormal(-radius, radius, radius), - CapVertex::TTexCoord(m_colorCoord))); - m_capGeometry.push_back(CapVertex(CapVertex::TPosition(pos, m_params.m_depth), - CapVertex::TNormal(-radius, -radius, radius), + CapVertex::TNormal(-radius * kSqrt3, -radius, radius), CapVertex::TTexCoord(m_colorCoord))); m_capGeometry.push_back(CapVertex(CapVertex::TPosition(pos, m_params.m_depth), - CapVertex::TNormal(radius, radius, radius), + CapVertex::TNormal(radius * kSqrt3, -radius, radius), CapVertex::TTexCoord(m_colorCoord))); m_capGeometry.push_back(CapVertex(CapVertex::TPosition(pos, m_params.m_depth), - CapVertex::TNormal(radius, -radius, radius), + CapVertex::TNormal(0, 2.0f * radius, radius), CapVertex::TTexCoord(m_colorCoord))); } @@ -563,7 +561,7 @@ void LineShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> t { dp::AttributeProvider capProvider(1, capSize); capProvider.InitStream(0, m_lineShapeInfo->GetCapBindingInfo(), m_lineShapeInfo->GetCapData()); - batcher->InsertListOfStrip(m_lineShapeInfo->GetCapState(), make_ref(&capProvider), dp::Batcher::VertexPerQuad); + batcher->InsertTriangleList(m_lineShapeInfo->GetCapState(), make_ref(&capProvider)); } } else |