Added outline min zoom level

This commit is contained in:
r.kuznetsov 2016-11-25 15:16:04 +03:00
parent b47d206d38
commit 7fb6ef01af
5 changed files with 36 additions and 24 deletions

View file

@ -426,12 +426,13 @@ void ApplyPointFeature::Finish()
ApplyAreaFeature::ApplyAreaFeature(m2::PointD const & tileCenter,
TInsertShapeFn const & insertShape, FeatureID const & id,
m2::RectD const & clipRect, bool isBuilding, float minPosZ,
float posZ, int minVisibleScale, uint8_t rank,
float posZ, int minVisibleScale, uint8_t rank, bool generateOutline,
CaptionDescription const & captions)
: TBase(tileCenter, insertShape, id, minVisibleScale, rank, captions, posZ)
, m_minPosZ(minPosZ)
, m_isBuilding(isBuilding)
, m_clipRect(clipRect)
, m_generateOutline(generateOutline)
{}
void ApplyAreaFeature::operator()(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3)
@ -598,10 +599,13 @@ void ApplyAreaFeature::ProcessRule(Stylist::TRuleWrapper const & rule)
params.m_posZ = m_posZ;
BuildingOutline outline;
bool const calculateNormals = m_posZ > 0.0;
if (m_isBuilding)
{
outline.m_generateOutline = m_generateOutline;
bool const calculateNormals = m_posZ > 0.0;
CalculateBuildingOutline(calculateNormals, outline);
params.m_is3D = !outline.m_indices.empty() && calculateNormals;
params.m_is3D = !outline.m_indices.empty() && calculateNormals;
}
m_insertShape(make_unique_dp<AreaShape>(move(m_triangles), move(outline), params));
}

View file

@ -102,7 +102,7 @@ public:
ApplyAreaFeature(m2::PointD const & tileCenter,
TInsertShapeFn const & insertShape, FeatureID const & id,
m2::RectD const & clipRect, bool isBuilding, float minPosZ,
float posZ, int minVisibleScale, uint8_t rank,
float posZ, int minVisibleScale, uint8_t rank, bool generateOutline,
CaptionDescription const & captions);
using TBase::operator ();
@ -128,6 +128,7 @@ private:
float const m_minPosZ;
bool const m_isBuilding;
m2::RectD m_clipRect;
bool m_generateOutline;
};
class ApplyLineFeature : public BaseApplyFeature

View file

@ -70,7 +70,7 @@ void AreaShape::DrawArea(ref_ptr<dp::Batcher> batcher, m2::PointD const & colorU
batcher->InsertTriangleList(state, make_ref(&provider));
// Generate outline.
if (!m_buildingOutline.m_indices.empty())
if (m_buildingOutline.m_generateOutline && !m_buildingOutline.m_indices.empty())
{
glsl::vec2 const ouv = glsl::ToVec2(outlineUv);
@ -96,7 +96,7 @@ void AreaShape::DrawArea(ref_ptr<dp::Batcher> batcher, m2::PointD const & colorU
void AreaShape::DrawArea3D(ref_ptr<dp::Batcher> batcher, m2::PointD const & colorUv, m2::PointD const & outlineUv,
ref_ptr<dp::Texture> texture) const
{
ASSERT(!m_buildingOutline.m_indices.empty(), ());
ASSERT(m_buildingOutline.m_generateOutline && !m_buildingOutline.m_indices.empty(), ());
ASSERT(!m_buildingOutline.m_normals.empty(), ());
glsl::vec2 const uv = glsl::ToVec2(colorUv);
@ -140,25 +140,28 @@ void AreaShape::DrawArea3D(ref_ptr<dp::Batcher> batcher, m2::PointD const & colo
batcher->InsertTriangleList(state, make_ref(&provider));
// Generate outline.
glsl::vec2 const ouv = glsl::ToVec2(outlineUv);
dp::GLState outlineState(gpu::AREA_3D_OUTLINE_PROGRAM, dp::GLState::GeometryLayer);
outlineState.SetColorTexture(texture);
outlineState.SetBlending(dp::Blending(false /* isEnabled */));
outlineState.SetDrawAsLine(true);
vector<gpu::AreaVertex> vertices;
vertices.reserve(m_buildingOutline.m_vertices.size());
for (size_t i = 0; i < m_buildingOutline.m_vertices.size(); i++)
if (m_buildingOutline.m_generateOutline)
{
glsl::vec2 const pos = glsl::ToVec2(ConvertToLocal(m_buildingOutline.m_vertices[i],
m_params.m_tileCenter, kShapeCoordScalar));
vertices.emplace_back(gpu::AreaVertex(glsl::vec3(pos, -m_params.m_posZ), ouv));
}
glsl::vec2 const ouv = glsl::ToVec2(outlineUv);
dp::AttributeProvider outlineProvider(1, vertices.size());
outlineProvider.InitStream(0, gpu::AreaVertex::GetBindingInfo(), make_ref(vertices.data()));
batcher->InsertLineRaw(outlineState, make_ref(&outlineProvider), m_buildingOutline.m_indices);
dp::GLState outlineState(gpu::AREA_3D_OUTLINE_PROGRAM, dp::GLState::GeometryLayer);
outlineState.SetColorTexture(texture);
outlineState.SetBlending(dp::Blending(false /* isEnabled */));
outlineState.SetDrawAsLine(true);
vector<gpu::AreaVertex> vertices;
vertices.reserve(m_buildingOutline.m_vertices.size());
for (size_t i = 0; i < m_buildingOutline.m_vertices.size(); i++)
{
glsl::vec2 const pos = glsl::ToVec2(ConvertToLocal(m_buildingOutline.m_vertices[i],
m_params.m_tileCenter, kShapeCoordScalar));
vertices.emplace_back(gpu::AreaVertex(glsl::vec3(pos, -m_params.m_posZ), ouv));
}
dp::AttributeProvider outlineProvider(1, vertices.size());
outlineProvider.InitStream(0, gpu::AreaVertex::GetBindingInfo(), make_ref(vertices.data()));
batcher->InsertLineRaw(outlineState, make_ref(&outlineProvider), m_buildingOutline.m_indices);
}
}
} // namespace df

View file

@ -16,6 +16,7 @@ struct BuildingOutline
buffer_vector<m2::PointD, kBuildingOutlineSize> m_vertices;
vector<int> m_indices;
vector<m2::PointD> m_normals;
bool m_generateOutline = false;
};
class AreaShape : public MapShape

View file

@ -27,6 +27,8 @@
namespace
{
int constexpr kOutlineMinZoomLevel = 16;
df::BaseApplyFeature::HotelData ExtractHotelData(FeatureType const & f)
{
df::BaseApplyFeature::HotelData result;
@ -250,9 +252,10 @@ void RuleDrawer::operator()(FeatureType const & f)
if (applyPointStyle || is3dBuilding)
minVisibleScale = feature::GetMinDrawableScale(f);
bool const generateOutline = (zoomLevel >= kOutlineMinZoomLevel);
ApplyAreaFeature apply(m_globalRect.Center(), insertShape, f.GetID(), m_globalRect,
isBuilding, areaMinHeight, areaHeight, minVisibleScale,
f.GetRank(), s.GetCaptionDescription());
f.GetRank(), generateOutline, s.GetCaptionDescription());
f.ForEachTriangle(apply, zoomLevel);
apply.SetHotelData(ExtractHotelData(f));
if (applyPointStyle)