-------------------------------------------------------------------------------------- Description: Finishes the manager update. Should be called after all Add calls. --------------------------------------------------------------------------------------
| 291 | // Finishes the manager update. Should be called after all Add calls. |
| 292 | // -------------------------------------------------------------------------------------- |
| 293 | void Tr2ImpostorManager::EndUpdate() |
| 294 | { |
| 295 | std::vector<ITr2ImpostorSource*> remove; |
| 296 | for( auto it = m_objects.begin(); it != m_objects.end(); ++it ) |
| 297 | { |
| 298 | if( !it->second.used ) |
| 299 | { |
| 300 | m_atlas.Drop( it->second.texcoord ); |
| 301 | remove.push_back( it->first ); |
| 302 | } |
| 303 | else |
| 304 | { |
| 305 | Vector4 sphere, oldSphere; |
| 306 | it->first->GetImpostorBoundingSphere( sphere ); |
| 307 | it->first->GetLastImpostorBoundingSphere( oldSphere ); |
| 308 | |
| 309 | ImposterVertex vertex; |
| 310 | vertex.position = sphere; |
| 311 | vertex.oldPosition = oldSphere; |
| 312 | vertex.texCoord = it->second.texcoord; |
| 313 | Tr2QuadRenderer::Instance()->AddQuads( m_effectKey, &vertex, 1 ); |
| 314 | } |
| 315 | } |
| 316 | for( auto it = remove.begin(); it != remove.end(); ++it ) |
| 317 | { |
| 318 | m_objects.erase( *it ); |
| 319 | } |
| 320 | |
| 321 | if( m_renderQueue.size() < m_maxUpdates ) |
| 322 | { |
| 323 | std::vector<std::pair<ITr2ImpostorSource*, Impostor*>> all; |
| 324 | all.reserve( m_objects.size() ); |
| 325 | for( auto it = m_objects.begin(); it != m_objects.end(); ++it ) |
| 326 | { |
| 327 | if( !it->second.render && it->second.renderPriority > 0.f ) |
| 328 | { |
| 329 | all.push_back( std::make_pair( it->first, &it->second ) ); |
| 330 | } |
| 331 | } |
| 332 | std::sort( all.begin(), all.end(), &CompareImpostors ); |
| 333 | size_t count = std::min( m_maxUpdates - m_renderQueue.size(), all.size() ); |
| 334 | for( size_t i = 0; i < count; ++i ) |
| 335 | { |
| 336 | m_renderQueue.push_back( all[i].first ); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | Tr2Variable altas( "ImposterAtlasMap", m_rt ); |
| 341 | Vector4 itemSize( float( m_itemWidth ) / float( m_width ), float( m_itemHeight ) / float( m_height ), 0.f, 0.f ); |
| 342 | Tr2Variable itemSizeVar( "ImposterItemSize", itemSize ); |
| 343 | } |
| 344 | |
| 345 | // -------------------------------------------------------------------------------------- |
| 346 | // Description: |
nothing calls this directly
no test coverage detected