forked from organicmaps/organicmaps
Fixed house rendering order and added invalidation
Conflicts: drape_frontend/read_manager.cpp drape_frontend/rule_drawer.cpp drape_frontend/rule_drawer.hpp drape_frontend/tile_info.cpp
This commit is contained in:
parent
fe4707c733
commit
1602dd561a
7 changed files with 51 additions and 23 deletions
|
@ -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<RenderGroup> 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<RenderGroup> 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<RenderGroup> 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<RenderGroup> 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);
|
||||
|
|
|
@ -36,6 +36,7 @@ ReadManager::ReadManager(ref_ptr<ThreadsCommutator> commutator, MapDataProvider
|
|||
, m_model(model)
|
||||
, m_pool(make_unique_dp<threads::ThreadPool>(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<int>(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<dp::Te
|
|||
{
|
||||
shared_ptr<TileInfo> tileInfo(new TileInfo(make_unique_dp<EngineContext>(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<dp::Te
|
|||
|
||||
void ReadManager::PushTaskFront(shared_ptr<TileInfo> const & tileToReread)
|
||||
{
|
||||
tileToReread->Set3dMode(m_is3d);
|
||||
ReadMWMTask * task = myPool.Get();
|
||||
task->Init(tileToReread);
|
||||
m_pool->PushFront(task);
|
||||
|
|
|
@ -30,7 +30,8 @@ class ReadManager
|
|||
public:
|
||||
ReadManager(ref_ptr<ThreadsCommutator> commutator, MapDataProvider & model);
|
||||
|
||||
void UpdateCoverage(ScreenBase const & screen, TTilesCollection const & tiles, ref_ptr<dp::TextureManager> texMng);
|
||||
void UpdateCoverage(ScreenBase const & screen, TTilesCollection const & tiles,
|
||||
ref_ptr<dp::TextureManager> texMng);
|
||||
void Invalidate(TTilesCollection const & keyStorage);
|
||||
void Stop();
|
||||
|
||||
|
@ -55,6 +56,7 @@ private:
|
|||
|
||||
ScreenBase m_currentViewport;
|
||||
bool m_forceUpdate;
|
||||
bool m_is3d;
|
||||
|
||||
struct LessByTileInfo
|
||||
{
|
||||
|
|
|
@ -38,11 +38,12 @@ size_t kMinFlushSizes[df::PrioritiesCount] =
|
|||
RuleDrawer::RuleDrawer(TDrawerCallback const & fn,
|
||||
TCheckCancelledCallback const & checkCancelled,
|
||||
TIsCountryLoadedByNameFn const & isLoadedFn,
|
||||
ref_ptr<EngineContext> context)
|
||||
ref_ptr<EngineContext> 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);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
using TIsCountryLoadedByNameFn = function<bool (string const &)>;
|
||||
|
||||
RuleDrawer(TDrawerCallback const & drawerFn, TCheckCancelledCallback const & checkCancelled,
|
||||
TIsCountryLoadedByNameFn const & isLoadedFn, ref_ptr<EngineContext> context);
|
||||
TIsCountryLoadedByNameFn const & isLoadedFn, ref_ptr<EngineContext> 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<TMapShapes, df::PrioritiesCount> m_mapShapes;
|
||||
bool m_wasCancelled;
|
||||
};
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace df
|
|||
TileInfo::TileInfo(drape_ptr<EngineContext> && 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<void>(ref(drawer), _1), featuresToRead);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<EngineContext> m_context;
|
||||
TFeaturesInfo m_featureInfo;
|
||||
bool m_is3d;
|
||||
|
||||
atomic<bool> m_isCanceled;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue