diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 0e79948417..357211f43f 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -731,6 +731,9 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView) dp::GLState::DepthLayer prevLayer = dp::GLState::GeometryLayer; size_t currentRenderGroup = 0; + bool has3dAreas = false; + size_t area3dRenderGroupStart = 0; + size_t area3dRenderGroupEnd = 0; for (; currentRenderGroup < m_renderGroups.size(); ++currentRenderGroup) { drape_ptr const & group = m_renderGroups[currentRenderGroup]; @@ -738,7 +741,15 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView) dp::GLState const & state = group->GetState(); if (isPerspective && state.GetProgram3dIndex() == gpu::AREA_3D_PROGRAM) + { + if (!has3dAreas) + { + area3dRenderGroupStart = currentRenderGroup; + has3dAreas = true; + } + area3dRenderGroupEnd = currentRenderGroup; continue; + } dp::GLState::DepthLayer layer = state.GetDepthLayer(); if (prevLayer != layer && layer == dp::GLState::OverlayLayer) @@ -760,7 +771,9 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView) m_selectionShape->Render(modelView, make_ref(m_gpuProgramManager), m_generalUniforms); } else if (selectedObject == SelectionShape::OBJECT_POI) + { m_selectionShape->Render(modelView, make_ref(m_gpuProgramManager), m_generalUniforms); + } } m_myPositionController->Render(MyPositionController::RenderAccuracy, @@ -768,6 +781,18 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView) GLFunctions::glEnable(gl_const::GLDepthTest); GLFunctions::glClearDepth(); + + if (isPerspective && has3dAreas) + { + for (size_t index = area3dRenderGroupStart; index <= area3dRenderGroupEnd; ++index) + { + drape_ptr const & group = m_renderGroups[index]; + if (group->GetState().GetProgram3dIndex() == gpu::AREA_3D_PROGRAM) + RenderSingleGroup(modelView, make_ref(group)); + } + GLFunctions::glClearDepth(); + } + for (; currentRenderGroup < m_renderGroups.size(); ++currentRenderGroup) { drape_ptr const & group = m_renderGroups[currentRenderGroup]; @@ -789,19 +814,6 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView) m_routeRenderer->RenderRouteSigns(modelView, make_ref(m_gpuProgramManager), m_generalUniforms); - - if (isPerspective) - { - GLFunctions::glEnable(gl_const::GLDepthTest); - for (currentRenderGroup = 0; currentRenderGroup < m_renderGroups.size(); ++currentRenderGroup) - { - drape_ptr const & group = m_renderGroups[currentRenderGroup]; - - if (isPerspective && group->GetState().GetProgram3dIndex() == gpu::AREA_3D_PROGRAM) - RenderSingleGroup(modelView, make_ref(group)); - } - } - m_myPositionController->Render(MyPositionController::RenderMyPosition, modelView, make_ref(m_gpuProgramManager), m_generalUniforms); @@ -814,7 +826,9 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView) m_guiRenderer->Render(make_ref(m_gpuProgramManager), modelView2d); } else + { m_guiRenderer->Render(make_ref(m_gpuProgramManager), modelView); + } } GLFunctions::glEnable(gl_const::GLDepthTest); diff --git a/drape_frontend/read_manager.cpp b/drape_frontend/read_manager.cpp index 68885e871b..91d038b2cf 100755 --- a/drape_frontend/read_manager.cpp +++ b/drape_frontend/read_manager.cpp @@ -36,6 +36,7 @@ ReadManager::ReadManager(ref_ptr commutator, MapDataProvider , m_model(model) , m_pool(make_unique_dp(ReadCount(), bind(&ReadManager::OnTaskFinished, this, _1))) , m_forceUpdate(true) + , m_is3d(false) , myPool(64, ReadMWMTaskFactory(m_memIndex, m_model)) , m_counter(0) , m_generationCounter(0) @@ -76,7 +77,9 @@ void ReadManager::UpdateCoverage(ScreenBase const & screen, TTilesCollection con return; m_forceUpdate = false; - if (MustDropAllTiles(screen)) + m_is3d = screen.isPerspective(); + bool const changeMode = (m_is3d != m_currentViewport.isPerspective()); + if (changeMode || MustDropAllTiles(screen)) { IncreaseCounter(static_cast(tiles.size())); m_generationCounter++; @@ -113,8 +116,8 @@ void ReadManager::UpdateCoverage(ScreenBase const & screen, TTilesCollection con { if (IsNeighbours(tile->GetTileKey(), outTile->GetTileKey())) { - rereadTiles.push_back(tile); - break; + rereadTiles.push_back(tile); + break; } } } @@ -180,6 +183,7 @@ void ReadManager::PushTaskBackForTileKey(TileKey const & tileKey, ref_ptr tileInfo(new TileInfo(make_unique_dp(TileKey(tileKey, m_generationCounter), m_commutator, texMng))); + tileInfo->Set3dMode(m_is3d); m_tileInfos.insert(tileInfo); ReadMWMTask * task = myPool.Get(); task->Init(tileInfo); @@ -188,6 +192,7 @@ void ReadManager::PushTaskBackForTileKey(TileKey const & tileKey, ref_ptr const & tileToReread) { + tileToReread->Set3dMode(m_is3d); ReadMWMTask * task = myPool.Get(); task->Init(tileToReread); m_pool->PushFront(task); diff --git a/drape_frontend/read_manager.hpp b/drape_frontend/read_manager.hpp index bb61ac02cc..baa7465719 100755 --- a/drape_frontend/read_manager.hpp +++ b/drape_frontend/read_manager.hpp @@ -30,7 +30,8 @@ class ReadManager public: ReadManager(ref_ptr commutator, MapDataProvider & model); - void UpdateCoverage(ScreenBase const & screen, TTilesCollection const & tiles, ref_ptr texMng); + void UpdateCoverage(ScreenBase const & screen, TTilesCollection const & tiles, + ref_ptr texMng); void Invalidate(TTilesCollection const & keyStorage); void Stop(); @@ -55,6 +56,7 @@ private: ScreenBase m_currentViewport; bool m_forceUpdate; + bool m_is3d; struct LessByTileInfo { diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp index fed04852c5..d537ca6172 100644 --- a/drape_frontend/rule_drawer.cpp +++ b/drape_frontend/rule_drawer.cpp @@ -38,11 +38,12 @@ size_t kMinFlushSizes[df::PrioritiesCount] = RuleDrawer::RuleDrawer(TDrawerCallback const & fn, TCheckCancelledCallback const & checkCancelled, TIsCountryLoadedByNameFn const & isLoadedFn, - ref_ptr context) + ref_ptr context, bool is3d) : m_callback(fn) , m_checkCancelled(checkCancelled) , m_isLoadedFn(isLoadedFn) , m_context(context) + , m_is3d(is3d) , m_wasCancelled(false) { ASSERT(m_callback != nullptr, ()); @@ -133,9 +134,8 @@ void RuleDrawer::operator()(FeatureType const & f) if (s.AreaStyleExists()) { - // TODO: isBuilding can be true ONLY if 3D houses mode is on - bool const isBuilding = ftypes::IsBuildingChecker::Instance()(f); - ApplyAreaFeature apply(insertShape, f.GetID(), isBuilding, + bool const is3dBuilding = m_is3d ? ftypes::IsBuildingChecker::Instance()(f) : false; + ApplyAreaFeature apply(insertShape, f.GetID(), is3dBuilding, minVisibleScale, f.GetRank(), s.GetCaptionDescription()); f.ForEachTriangleRef(apply, zoomLevel); diff --git a/drape_frontend/rule_drawer.hpp b/drape_frontend/rule_drawer.hpp index 2b89e47388..01e088d43d 100644 --- a/drape_frontend/rule_drawer.hpp +++ b/drape_frontend/rule_drawer.hpp @@ -29,7 +29,7 @@ public: using TIsCountryLoadedByNameFn = function; RuleDrawer(TDrawerCallback const & drawerFn, TCheckCancelledCallback const & checkCancelled, - TIsCountryLoadedByNameFn const & isLoadedFn, ref_ptr context); + TIsCountryLoadedByNameFn const & isLoadedFn, ref_ptr context, bool is3d); ~RuleDrawer(); void operator() (FeatureType const & f); @@ -45,6 +45,8 @@ private: m2::RectD m_globalRect; double m_currentScaleGtoP; + bool const m_is3d; + array m_mapShapes; bool m_wasCancelled; }; diff --git a/drape_frontend/tile_info.cpp b/drape_frontend/tile_info.cpp index 1ecb07a67f..5dcccc4162 100644 --- a/drape_frontend/tile_info.cpp +++ b/drape_frontend/tile_info.cpp @@ -17,6 +17,7 @@ namespace df TileInfo::TileInfo(drape_ptr && context) : m_context(move(context)) , m_isCanceled(false) + , m_is3d(false) { } @@ -73,7 +74,7 @@ void TileInfo::ReadFeatures(MapDataProvider const & model, MemoryFeatureIndex & RuleDrawer drawer(bind(&TileInfo::InitStylist, this, _1 ,_2), bind(&TileInfo::IsCancelled, this), model.m_isCountryLoadedByNameFn, - make_ref(m_context)); + make_ref(m_context), m_is3d); model.ReadFeatures(bind(ref(drawer), _1), featuresToRead); } } diff --git a/drape_frontend/tile_info.hpp b/drape_frontend/tile_info.hpp index 3c5478973c..89334d634b 100644 --- a/drape_frontend/tile_info.hpp +++ b/drape_frontend/tile_info.hpp @@ -31,6 +31,9 @@ public: void Cancel(MemoryFeatureIndex & memIndex); bool IsCancelled() const; + void Set3dMode(bool mode) { m_is3d = mode; } + bool Get3dMode() const { return m_is3d; } + m2::RectD GetGlobalRect() const; TileKey const & GetTileKey() const { return m_context->GetTileKey(); } bool operator <(TileInfo const & other) const { return GetTileKey() < other.GetTileKey(); } @@ -47,6 +50,7 @@ private: private: drape_ptr m_context; TFeaturesInfo m_featureInfo; + bool m_is3d; atomic m_isCanceled; };