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); }
void TileLayerComponentManager::_render(EntityRef entity, float interp, const OrthographicCamera& camera) { if ( !entity.isEnabled() ) return; TileLayerComponent* comp = get(entity); if(comp && comp->isEnabled() && comp->tileMap() && comp->tileMap()->tileSet() && comp->tileMap()->tileSet().get() && comp->tileMap()->tileSet()->get()->isValid()) { TileMapSP tileMap = comp->tileMap(); unsigned layer = comp->layerIndex(); // FIXME: Find a way to get rid of this - we should not upload stuff here. TextureAspectSP texAspect = tileMap->tileSet()->asset()->aspect<TextureAspect>(); if(!texAspect || !texAspect->get()) { texAspect = _spriteRenderer->createTexture(tileMap->tileSet()->asset()); _spriteRenderer->renderer()->uploadPendingTextures(); } TextureSP tex = texAspect->get(); // FIXME: wt should be applied as a shader parameter Matrix4 wt = lerp(interp, comp->_entity()->prevWorldTransform.matrix(), comp->_entity()->worldTransform.matrix()); if(comp->_bufferDirty) { float tileWidth = float(tex->width()) / float(tileMap->tileSetHTiles()); float tileHeight = float(tex->height()) / float(tileMap->tileSetVTiles()); _fillBuffer(*comp->_buffer, tileMap, layer, tileWidth, tileHeight, wt); comp->_bufferDirty = false; } unsigned count = comp->_buffer->indexSize(); if(count) { _states.buffer = comp->_buffer.get(); _states.texture = tex; _states.textureFlags = comp->textureFlags(); _states.blendingMode = comp->blendingMode(); Vector4i tileInfo(tileMap->tileSetHTiles(), tileMap->tileSetVTiles(), tex->width(), tex->height()); const ShaderParameter* params = _spriteRenderer->addShaderParameters( _spriteRenderer->shader(), camera.transform(), 0, tileInfo); float depth = 1.f - normalize(wt(2, 3), camera.viewBox().min()(2), camera.viewBox().max()(2)); _renderPass->addDrawCall(_states, params, depth, 0, count); } } EntityRef child = entity.firstChild(); while(child.isValid()) { render(child, interp, camera); child = child.nextSibling(); } }