Changeset 398 for trunk/src/gfx/texture_atlas.cc
- Timestamp:
- 06/13/15 11:20:22 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/texture_atlas.cc
r395 r398 11 11 using namespace nv; 12 12 13 texture_atlas::texture_atlas( glm::ivec2 size, nv::size_t depth, nv::size_t border /*= 1*/ )13 texture_atlas::texture_atlas( ivec2 size, nv::size_t depth, nv::size_t border /*= 1*/ ) 14 14 : image( size, depth ), m_used( 0 ), m_border( border ) 15 15 { 16 m_nodes.push_back( glm::ivec3( m_border, m_border, m_size.x - 2 * static_cast<int>( m_border ) ) );16 m_nodes.push_back( ivec3( m_border, m_border, m_size.x - 2 * static_cast<int>( m_border ) ) ); 17 17 fill( 0 ); 18 18 } 19 19 20 region texture_atlas::get_region( glm::ivec2 size )20 region texture_atlas::get_region( ivec2 size ) 21 21 { 22 region r ( glm::ivec2(0,0), size );22 region r ( ivec2(0,0), size ); 23 23 24 24 int best_height = INT_MAX; … … 31 31 if ( y >= 0 ) 32 32 { 33 glm::ivec3 node = m_nodes[ i ];33 ivec3 node = m_nodes[ i ]; 34 34 if ( ( (y + size.y) < best_height ) || 35 35 ( ((y + size.y) == best_height) && (node.z < best_width)) ) … … 46 46 if ( best_index == -1 ) 47 47 { 48 return region( glm::ivec2( -1, -1 ), glm::ivec2( 0, 0 ) );48 return region( ivec2( -1, -1 ), ivec2( 0, 0 ) ); 49 49 } 50 50 51 m_nodes.insert( m_nodes.begin() + best_index, glm::ivec3( r.pos.x, r.pos.y + size.y, size.x ) );51 m_nodes.insert( m_nodes.begin() + best_index, ivec3( r.pos.x, r.pos.y + size.y, size.x ) ); 52 52 53 53 for( size_t i = static_cast<size_t>( best_index )+1; i < m_nodes.size(); ++i ) 54 54 { 55 glm::ivec3 node = m_nodes[ i ];56 glm::ivec3 prev = m_nodes[ i-1 ];55 ivec3 node = m_nodes[ i ]; 56 ivec3 prev = m_nodes[ i-1 ]; 57 57 58 58 if ( node.x < prev.x + prev.z ) … … 82 82 } 83 83 84 int texture_atlas::fit( nv::size_t index, glm::ivec2 size )84 int texture_atlas::fit( nv::size_t index, ivec2 size ) 85 85 { 86 glm::ivec3 node = m_nodes[ index ];86 ivec3 node = m_nodes[ index ]; 87 87 88 88 if ( node.x + size.x > m_size.x - static_cast<int>( m_border ) ) … … 128 128 m_nodes.clear(); 129 129 m_used = 0; 130 m_nodes.push_back( glm::ivec3( 1, 1, m_size.x - 2 ) );130 m_nodes.push_back( ivec3( 1, 1, m_size.x - 2 ) ); 131 131 fill( 0 ); 132 132 }
Note: See TracChangeset
for help on using the changeset viewer.