void UserMarkGenerator::GenerateUserMarksGeometry(ref_ptr<dp::GraphicsContext> context, TileKey const & tileKey, ref_ptr<dp::TextureManager> textures) { auto const clippedTileKey = TileKey(tileKey.m_x, tileKey.m_y, ClipTileZoomByMaxDataZoom(tileKey.m_zoomLevel)); auto marksGroups = GetUserMarksGroups(clippedTileKey); auto linesGroups = GetUserLinesGroups(clippedTileKey); if (marksGroups == nullptr && linesGroups == nullptr) return; uint32_t constexpr kMaxSize = 65000; dp::Batcher batcher(kMaxSize, kMaxSize); batcher.SetBatcherHash(tileKey.GetHashValue(BatcherBucket::UserMark)); TUserMarksRenderData renderData; { dp::SessionGuard guard(context, batcher, [&tileKey, &renderData](dp::RenderState const & state, drape_ptr<dp::RenderBucket> && b) { renderData.emplace_back(state, std::move(b), tileKey); }); if (marksGroups != nullptr) CacheUserMarks(context, tileKey, *marksGroups.get(), textures, batcher); if (linesGroups != nullptr) CacheUserLines(context, tileKey, *linesGroups.get(), textures, batcher); } m_flushFn(std::move(renderData)); }
void ReadManager::PushTaskBackForTileKey(TileKey const & tileKey, ref_ptr<dp::TextureManager> texMng) { shared_ptr<TileInfo> tileInfo(new TileInfo(make_unique_dp<EngineContext>(TileKey(tileKey, m_generationCounter), m_commutator, texMng))); tileInfo->Set3dBuildings(m_need3dBuildings && m_allow3dBuildings); m_tileInfos.insert(tileInfo); ReadMWMTask * task = myPool.Get(); task->Init(tileInfo); m_pool->PushBack(task); }
ref_ptr<MarksIDGroups> UserMarkGenerator::GetUserLinesGroups(TileKey const & tileKey) { auto itTile = m_index.end(); int const lineZoom = GetNearestLineIndexZoom(tileKey.m_zoomLevel); CalcTilesCoverage(tileKey.GetGlobalRect(), lineZoom, [this, &itTile, lineZoom](int tileX, int tileY) { itTile = m_index.find(TileKey(tileX, tileY, lineZoom)); }); if (itTile != m_index.end()) return make_ref(itTile->second); return nullptr; }
void BLMap::ConvertTypeToTiles() { for (uint i=0 ; i<m_oTypeMap.GetWidth()-1 ; ++i) { for (uint j=0 ; j<m_oTypeMap.GetHeight()-1 ; ++j) { CaseType tl = m_oTypeMap.GetCase(i, j); CaseType tr = m_oTypeMap.GetCase(i+1, j); CaseType bl = m_oTypeMap.GetCase(i, j+1); CaseType br = m_oTypeMap.GetCase(i+1, j+1); m_oTilesMap.GetCase(i, j).SetTilesId(m_oTiles.Find(tl, tr, bl, br)); m_oTilesMap.GetCase(i, j).SetTilesType(CaseToTile(TileKey(tl, tr, bl, br))); } } }
const TileKey Tile::getKey() const { return TileKey(_level, _row, _column); }
TileKey GetBookmarkTileKey(size_t categoryIndex) { return TileKey(categoryIndex, YBookmarksLayer, ZUserMarksLayer); }
TileKey GetDebugTileKey() { return TileKey(0, YDebugLayer, ZUserMarksLayer); }
TileKey GetApiTileKey() { return TileKey(0, YApiMarksLayer, ZUserMarksLayer); }
TileKey GetSearchTileKey() { return TileKey(0, YSearchMarksLayer, ZUserMarksLayer); }
void GeodeticManifold::initialize( MeshManager* mesh ) { mesh->_minGeomLevel = 1; mesh->_minActiveLevel = 3; // Construct the "vertex diamonds". _vd[0] = new Diamond(mesh, TileKey(), 0, "vd0"); // north pole 1 _vd[0]->setCoord( -90, 90, 0 ); _vd[1] = new Diamond(mesh, TileKey(), 0, "vd1"); // north pole 2 _vd[1]->setCoord( 90, 90, 0 ); _vd[2] = new Diamond(mesh, TileKey(), 0, "vd2"); // south pole 1 _vd[2]->setCoord( -90, -90, 0 ); _vd[3] = new Diamond(mesh, TileKey(), 0, "vd3"); // south pole 2 _vd[3]->setCoord( 90, -90, 0 ); _vd[4] = new Diamond(mesh, TileKey(), 0, "vd4"); _vd[4]->setCoord( -180, 0, 0 ); _vd[5] = new Diamond(mesh, TileKey(), 0, "vd5"); _vd[5]->setCoord( 0, 0, 0 ); // The 4 "face diamonds": _fd[0] = new Diamond(mesh, TileKey(), 0, "fd0"); _fd[0]->setCoord( -90, 0, 0 ); _fd[0]->_a[GDPARENT] = _vd[0].get(); _fd[0]->_a[QUADTREE] = _vd[2].get(); _fd[0]->_a[PARENT_L] = _vd[4].get(); _fd[0]->_a[PARENT_R] = _vd[5].get(); _fd[1] = new Diamond(mesh, TileKey(), 0, "fd1"); _fd[1]->setCoord( 90, 0, 0 ); _fd[1]->_a[GDPARENT] = _vd[3].get(); _fd[1]->_a[QUADTREE] = _vd[1].get(); _fd[1]->_a[PARENT_L] = _vd[4].get(); _fd[1]->_a[PARENT_R] = _vd[5].get(); _fd[2] = new Diamond(mesh, TileKey(), 0, "fd2"); // virtual north pole diamond _fd[2]->setCoord( 0, 90, 0 ); _fd[2]->_a[GDPARENT] = _vd[0].get(); _fd[2]->_a[QUADTREE] = _vd[1].get(); _fd[2]->_a[PARENT_L] = _vd[5].get(); _fd[2]->_a[PARENT_R] = _vd[4].get(); _fd[3] = new Diamond(mesh, TileKey(), 0, "fd3"); // virtual south pole diamond _fd[3]->setCoord( 0, -90, 0 ); _fd[3]->_a[GDPARENT] = _vd[3].get(); _fd[3]->_a[QUADTREE] = _vd[2].get(); _fd[3]->_a[PARENT_L] = _vd[5].get(); _fd[3]->_a[PARENT_R] = _vd[4].get(); // the 8 "edge diamonds" (first with geometry) _ed[0] = new Diamond(mesh, TileKey(1,0,0,_profile.get()), 1, "ed0"); _ed[0]->setCoord( -135, 45, 0 ); _ed[0]->_a[GDPARENT] = _vd[0].get(); _ed[0]->_a[QUADTREE] = _vd[4].get(); _ed[0]->_a[PARENT_L] = _fd[2].get(); _ed[0]->_a[PARENT_R] = _fd[0].get(); _ed[0]->_orientation = 0; _ed[1] = new Diamond(mesh, TileKey(1,1,0,_profile.get()), 1, "ed1"); _ed[1]->setCoord( -45, 45, 0 ); _ed[1]->_a[GDPARENT] = _vd[0].get(); _ed[1]->_a[QUADTREE] = _vd[5].get(); _ed[1]->_a[PARENT_L] = _fd[0].get(); _ed[1]->_a[PARENT_R] = _fd[2].get(); _ed[1]->_orientation = 2; _ed[2] = new Diamond(mesh, TileKey(1,0,1,_profile.get()), 1, "ed2"); _ed[2]->setCoord( -135, -45, 0 ); _ed[2]->_a[GDPARENT] = _vd[2].get(); _ed[2]->_a[QUADTREE] = _vd[4].get(); _ed[2]->_a[PARENT_L] = _fd[0].get(); _ed[2]->_a[PARENT_R] = _fd[3].get(); _ed[2]->_orientation = 6; _ed[3] = new Diamond(mesh, TileKey(1,1,1,_profile.get()), 1, "ed3"); _ed[3]->setCoord( -45, -45, 0 ); _ed[3]->_a[GDPARENT] = _vd[2].get(); _ed[3]->_a[QUADTREE] = _vd[5].get(); _ed[3]->_a[PARENT_L] = _fd[3].get(); _ed[3]->_a[PARENT_R] = _fd[0].get(); _ed[3]->_orientation = 4; _ed[4] = new Diamond(mesh, TileKey(1,2,0,_profile.get()), 1, "ed4"); _ed[4]->setCoord( 45, 45, 0 ); _ed[4]->_a[GDPARENT] = _vd[1].get(); _ed[4]->_a[QUADTREE] = _vd[5].get(); _ed[4]->_a[PARENT_L] = _fd[2].get(); _ed[4]->_a[PARENT_R] = _fd[1].get(); _ed[4]->_orientation = 0; _ed[5] = new Diamond(mesh, TileKey(1,3,0,_profile.get()), 1, "ed5"); _ed[5]->setCoord( 135, 45, 0 ); _ed[5]->_a[GDPARENT] = _vd[1].get(); _ed[5]->_a[QUADTREE] = _vd[4].get(); _ed[5]->_a[PARENT_L] = _fd[1].get(); _ed[5]->_a[PARENT_R] = _fd[2].get(); _ed[5]->_orientation = 2; _ed[6] = new Diamond(mesh, TileKey(1,2,1,_profile.get()), 1, "ed6"); _ed[6]->setCoord( 45, -45, 0 ); _ed[6]->_a[GDPARENT] = _vd[3].get(); _ed[6]->_a[QUADTREE] = _vd[5].get(); _ed[6]->_a[PARENT_L] = _fd[1].get(); _ed[6]->_a[PARENT_R] = _fd[3].get(); _ed[6]->_orientation = 6; _ed[7] = new Diamond(mesh, TileKey(1,3,1,_profile.get()), 1, "ed7"); _ed[7]->setCoord( 135, -45, 0 ); _ed[7]->_a[GDPARENT] = _vd[3].get(); _ed[7]->_a[QUADTREE] = _vd[4].get(); _ed[7]->_a[PARENT_L] = _fd[3].get(); _ed[7]->_a[PARENT_R] = _fd[1].get(); _ed[7]->_orientation = 7; // set child pointers: _fd[0]->setChild( 0, _ed[3].get() ); _fd[0]->setChild( 1, _ed[1].get() ); _fd[0]->setChild( 2, _ed[0].get() ); _fd[0]->setChild( 3, _ed[2].get() ); _fd[1]->setChild( 0, _ed[4].get() ); _fd[1]->setChild( 1, _ed[6].get() ); _fd[1]->setChild( 2, _ed[7].get() ); _fd[1]->setChild( 3, _ed[5].get() ); _fd[2]->setChild( 0, _ed[5].get() ); _fd[2]->setChild( 1, _ed[0].get() ); _fd[2]->setChild( 2, _ed[1].get() ); _fd[2]->setChild( 3, _ed[4].get() ); _fd[3]->setChild( 0, _ed[2].get() ); _fd[3]->setChild( 1, _ed[7].get() ); _fd[3]->setChild( 2, _ed[6].get() ); _fd[3]->setChild( 3, _ed[3].get() ); // seed the bouding spheres of the manifold diamonds: for( unsigned short f=0; f<4; ++f ) _fd[f]->activate(); for( unsigned short e=0; e<8; ++e ) _ed[e]->activate(); // generate Level 3 (the first renderable quadtree decendants). seed( 3 ); // hopefully, that's it! }
Diamond* Diamond::getOrCreateChild( ChildIndex c ) { if ( _c[c].valid() ) return _c[c].get(); // must force a split before creating children. dont' need to call dirty() because // that gets called later by setChild() _isSplit = true; //OE_NOTICE << "Creating child of " << _name << " at " << c << std::endl; //dump(); Diamond* d = this; osg::ref_ptr<Diamond> d0 = getOrCreateNeighbor( c ); unsigned short whichParent = c <= 1 ? PARENT_R : PARENT_L; osg::ref_ptr<Diamond> qa = d->_a[whichParent].get(); // the common parent Diamond* child = new Diamond( _mesh, TileKey(), d->_level+1 ); //Diamond* child = new Diamond( _mesh, 0L, d->_level+1, " ("+_name+" + "+d0->_name+") " ); //OE_NOTICE << "...neighbor: " << d0->_name << std::endl; //OE_NOTICE << "...common parent: " << commonParent->_name << std::endl; // assign child's quadtree ansector to d and d0's common parent. child->_a[QUADTREE] = qa.get(); // assign child's grandparent ansector pointer: child->_a[GDPARENT] = c == 0 || c == 3 ? d->_a[QUADTREE].get() : d->_a[GDPARENT].get(); // determine the child index of child in d0: unsigned short p = c==0 || c==2 ? QUADTREE : GDPARENT; ChildIndex c_d0 = d0->getIndexOfChildEdgeStartingAt( child->_a[p]->_vi ); if ( c_d0 < 0 ) { OE_WARN << "Diamond: getOrCreateChild: illegal state, cannot find neighbor's child edge...crash immiment\n"; } // assign the child's parent pointers child->_a[PARENT_R] = (c == 0 || c == 2) ? d : d0.get(); child->_a[PARENT_L] = (c == 0 || c == 2) ? d0.get() : d; // how that we know the QUADTREE & GDPARENT ancestors, create the diamond vertex. osg::Vec3d newCoord = _mesh->_manifold->midpoint( child->_a[QUADTREE]->node()._manifoldCoord, child->_a[GDPARENT]->node()._manifoldCoord ); child->setCoord( newCoord ); // assign the new child in both d and d0: d->setChild( c, child ); d0->setChild( c_d0, child ); if ( child->_hasGeometry ) { // if this is a intermediate diamond, make a new key for the parent's quadtree descendant. // if this is a geometry diamond, the new intermediate child gets no key. int quadrant = -1; if ( qa->_orientation == 0 ) { quadrant = qa->q(0) == child ? 2 : qa->q(1) == child ? 3 : qa->q(2) == child ? 1 : 0; } else if ( qa->_orientation == 2 ) { quadrant = qa->q(0) == child ? 3 : qa->q(1) == child ? 1 : qa->q(2) == child ? 0 : 2; } else if ( qa->_orientation == 4 ) { quadrant = qa->q(0) == child ? 1 : qa->q(1) == child ? 0 : qa->q(2) == child ? 2 : 3; } else // if ( qa->_orientation == 6 ) { quadrant = qa->q(0) == child ? 0 : qa->q(1) == child ? 2 : qa->q(2) == child ? 3 : 1; } child->_key = qa->_key.createChildKey( quadrant ); child->_orientation = quadrant == 1 ? 0 : quadrant == 0 ? 2 : quadrant == 2 ? 4 : 6; } child->activate(); return child; }