------------------------------------------------------------- Description: If you have a list of blocks (a startindex and a count), you can optimize this list by combining two or more subsequent elements into one by just increasing the count! Thats what this function does. Arguments: areaBlockVector - the to-be-optimized vector -------------------------------------------------------------
| 16 | // areaBlockVector - the to-be-optimized vector |
| 17 | // ------------------------------------------------------------- |
| 18 | void TriRenderBatchAreaBlock::Optimize( std::vector<TriRenderBatchAreaBlock>& areaBlockVector ) |
| 19 | { |
| 20 | // turn area block list into a std::set, so we get sorting and remove duplicates |
| 21 | std::set<unsigned int> overlayHullAreas; |
| 22 | for( auto it = areaBlockVector.begin(); it != areaBlockVector.end(); ++it ) |
| 23 | { |
| 24 | for( unsigned n = 0; n < it->m_count; ++n ) |
| 25 | { |
| 26 | overlayHullAreas.insert( it->m_startIndex + n ); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // convert the set back into an area block list, but this time it will be condensed |
| 31 | areaBlockVector.clear(); |
| 32 | TriRenderBatchAreaBlock ab( 0, 0 ); |
| 33 | for( auto it = overlayHullAreas.begin(); it != overlayHullAreas.end(); ++it ) |
| 34 | { |
| 35 | // this is for the loop iteration |
| 36 | if( ab.m_count == 0 ) |
| 37 | { |
| 38 | ab.m_startIndex = *it; |
| 39 | ab.m_count = 1; |
| 40 | } |
| 41 | // still going? |
| 42 | else if( ab.m_startIndex + ab.m_count == *it ) |
| 43 | { |
| 44 | ++ab.m_count; |
| 45 | } |
| 46 | // is a finisher, so put it on list |
| 47 | else |
| 48 | { |
| 49 | areaBlockVector.push_back( ab ); |
| 50 | ab.m_startIndex = *it; |
| 51 | ab.m_count = 1; |
| 52 | } |
| 53 | } |
| 54 | // don't forget the last element! |
| 55 | if( ab.m_count > 0 ) |
| 56 | { |
| 57 | areaBlockVector.push_back( ab ); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | TriRenderBatchAreaBlocksWithSharedMaterial::TriRenderBatchAreaBlocksWithSharedMaterial() |
| 62 | { |
no test coverage detected