Changeset 398 for trunk/src


Ignore:
Timestamp:
06/13/15 11:20:22 (10 years ago)
Author:
epyon
Message:
  • cleanup of glm usage
Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/formats/md5_loader.cc

    r395 r398  
    3131}
    3232
    33 static void unit_quat_w( glm::quat& quat )
     33static void unit_quat_w( nv::quat& quat )
    3434{
    3535        float t = 1.0f - ( quat.x * quat.x ) - ( quat.y * quat.y ) - ( quat.z * quat.z );
     
    343343                md5_vtx_pnt& vtc = vtcs[i];
    344344
    345                 vtc.position = glm::vec3(0);
    346                 vtc.normal   = glm::vec3(0);
    347                 vtc.tangent  = glm::vec3(0);
     345                vtc.position = vec3(0);
     346                vtc.normal   = vec3(0);
     347                vtc.tangent  = vec3(0);
    348348
    349349                stable_sort( weights + start_weight, weights + start_weight + weight_count, [] ( const md5_weight& a, const md5_weight& b ) -> bool { return a.bias > b.bias; } );
     
    386386                                const mesh_node_data&  joint = nodes[weight.joint_id];
    387387                                const transform tr = transform( joint.transform ).inverse();
    388                                 glm::vec3 rot_pos = tr.get_orientation() * weight.pos;
     388                                vec3 rot_pos = tr.get_orientation() * weight.pos;
    389389
    390390                                vtc.position += ( tr.get_position() + rot_pos ) * weight.bias;
     
    404404                uint32 ti2 = idata[ i * 3 + 2 ];
    405405 
    406                 glm::vec3 v1 = vtcs[ ti0 ].position;
    407                 glm::vec3 v2 = vtcs[ ti1 ].position;
    408                 glm::vec3 v3 = vtcs[ ti2 ].position;
    409                 glm::vec3 xyz1 = v3 - v1;
    410                 glm::vec3 xyz2 = v2 - v1;
    411 
    412                 glm::vec3 normal = glm::cross( xyz1, xyz2 );
     406                vec3 v1 = vtcs[ ti0 ].position;
     407                vec3 v2 = vtcs[ ti1 ].position;
     408                vec3 v3 = vtcs[ ti2 ].position;
     409                vec3 xyz1 = v3 - v1;
     410                vec3 xyz2 = v2 - v1;
     411
     412                vec3 normal = glm::cross( xyz1, xyz2 );
    413413
    414414                vtcs[ ti0 ].normal += normal;
     
    436436                md5_vtx_pntiw& vdata = vtx_data[i];
    437437
    438                 glm::vec3 normal  = glm::normalize( vtcs[i].normal );
    439                 glm::vec3 tangent = glm::normalize( vtcs[i].tangent );
     438                vec3 normal  = glm::normalize( vtcs[i].normal );
     439                vec3 tangent = glm::normalize( vtcs[i].tangent );
    440440                vtcs[i].normal   = normal;
    441441                vtcs[i].tangent  = tangent;
    442442
    443443                vdata.position = vtcs[i].position;
    444                 vdata.normal   = glm::vec3(0);
    445                 vdata.tangent  = glm::vec3(0);
     444                vdata.normal   = vec3(0);
     445                vdata.tangent  = vec3(0);
    446446 
    447447                for ( size_t j = 0; j < 4; ++j )
     
    484484                        transform ptr;
    485485                        if ( pjoint.data->get_channel(0)->count > index ) ptr = ptv[ index ];
    486                         glm::vec3 rot_pos = ptr.get_orientation() * pos;
     486                        vec3 rot_pos = ptr.get_orientation() * pos;
    487487
    488488                        pos    = ptr.get_position() + rot_pos;
  • trunk/src/gfx/image.cc

    r395 r398  
    1010using namespace nv;
    1111
    12 image::image( glm::ivec2 size, nv::size_t depth )
     12image::image( ivec2 size, nv::size_t depth )
    1313        : m_size( size ), m_depth( depth ), m_data( nullptr )
    1414{
     
    2323
    2424
    25 image::image( glm::ivec2 size, nv::size_t depth, const uint8 * data, bool reversed )
     25image::image( ivec2 size, nv::size_t depth, const uint8 * data, bool reversed )
    2626        : m_size( size ), m_depth( depth ), m_data( nullptr )
    2727{
  • trunk/src/gfx/mesh_creator.cc

    r395 r398  
    2121                size_t count     = ( keys ? keys->get_channel(0)->count : 0 );
    2222                size_t pcount    = ( pkeys ? pkeys->get_channel(0)->count : 0 );
    23                 max_frames = glm::max<uint32>( count, max_frames );
     23                max_frames = nv::max<uint32>( count, max_frames );
    2424                if ( pkeys && pkeys->get_channel_count() > 0 && keys && keys->get_channel_count() > 0 )
    2525                {
     
    2828                        for ( unsigned n = 0; n < count; ++n )
    2929                        {
    30                                 channel[n].tform = pchannel[ glm::min( n, pcount-1 ) ].tform * channel[n].tform;
     30                                channel[n].tform = pchannel[ nv::min( n, pcount-1 ) ].tform * channel[n].tform;
    3131                        }
    3232                }
     
    6363                        for ( size_t c = 0; c < chan_count; ++c )
    6464                        {
    65                                 max_keys = glm::max( max_keys, old_keys->get_channel(c)->count );
     65                                max_keys = nv::max( max_keys, old_keys->get_channel(c)->count );
    6666                        }
    6767
     
    7979                                for ( uint16 c = 0; c < chan_count; ++c )
    8080                                {
    81                                         size_t idx = glm::min( old_keys->get_channel(c)->count - 1, n );
     81                                        size_t idx = nv::min( old_keys->get_channel(c)->count - 1, n );
    8282                                        pkey += old_keys->get_channel(c)->get_raw( idx, pkey );
    8383                                }
     
    119119void nv::mesh_data_creator::transform( float scale, const mat3& r33 )
    120120{
    121         vec3 vertex_offset     = glm::vec3();
     121        vec3 vertex_offset     = vec3();
    122122        mat3 vertex_transform  = scale * r33;
    123123        mat3 normal_transform  = r33;
     
    297297                        vec3 xyz2 = v2 - v1;
    298298
    299                         //glm::vec3 normal = glm::cross( xyz1, xyz2 );
     299                        //vec3 normal = glm::cross( xyz1, xyz2 );
    300300                        //
    301301                        //vtcs[ ti0 ].normal += normal;
  • trunk/src/gfx/texture_atlas.cc

    r395 r398  
    1111using namespace nv;
    1212
    13 texture_atlas::texture_atlas( glm::ivec2 size, nv::size_t depth, nv::size_t border /*= 1*/ )
     13texture_atlas::texture_atlas( ivec2 size, nv::size_t depth, nv::size_t border /*= 1*/ )
    1414        : image( size, depth ), m_used( 0 ), m_border( border )
    1515{
    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 ) ) );
    1717        fill( 0 );
    1818}
    1919
    20 region texture_atlas::get_region( glm::ivec2 size )
     20region texture_atlas::get_region( ivec2 size )
    2121{
    22         region r ( glm::ivec2(0,0), size );
     22        region r ( ivec2(0,0), size );
    2323
    2424        int best_height = INT_MAX;
     
    3131                if ( y >= 0 )
    3232                {
    33                         glm::ivec3 node = m_nodes[ i ];
     33                        ivec3 node = m_nodes[ i ];
    3434                        if ( ( (y + size.y) < best_height ) ||
    3535                                ( ((y + size.y) == best_height) && (node.z < best_width)) )
     
    4646        if ( best_index == -1 )
    4747        {
    48                 return region( glm::ivec2( -1, -1 ), glm::ivec2( 0, 0 ) );
     48                return region( ivec2( -1, -1 ), ivec2( 0, 0 ) );
    4949        }
    5050
    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 ) );
    5252
    5353        for( size_t i = static_cast<size_t>( best_index )+1; i < m_nodes.size(); ++i )
    5454        {
    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 ];
    5757
    5858                if ( node.x < prev.x + prev.z )
     
    8282}
    8383
    84 int texture_atlas::fit( nv::size_t index, glm::ivec2 size )
     84int texture_atlas::fit( nv::size_t index, ivec2 size )
    8585{
    86         glm::ivec3 node = m_nodes[ index ];
     86        ivec3 node = m_nodes[ index ];
    8787
    8888        if ( node.x + size.x > m_size.x - static_cast<int>( m_border ) )
     
    128128        m_nodes.clear();
    129129        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 ) );
    131131        fill( 0 );
    132132}
  • trunk/src/gfx/texture_font.cc

    r395 r398  
    9494bool texture_font::load_glyphs( string_ref codes )
    9595{
    96         FT_Face face     = (FT_Face)(m_rface);
    97         size_t depth     = m_atlas->get_depth();
    98         glm::ivec2 asize = m_atlas->get_size();
     96        FT_Face face = (FT_Face)(m_rface);
     97        size_t depth = m_atlas->get_depth();
     98        ivec2 asize = m_atlas->get_size();
    9999        FT_Int32 flags = 0;
    100100        flags |= FT_LOAD_RENDER;
     
    137137                int reg_width       = ft_bitmap_width / (depth > 3 ? 3 : (int)depth);
    138138
    139                 glm::ivec2 gsize( reg_width + 1, ft_bitmap_rows + 1 );
     139                ivec2 gsize( reg_width + 1, ft_bitmap_rows + 1 );
    140140                region r = m_atlas->get_region( gsize );
    141141                if ( r.pos.x < 0 )
     
    164164                g->charcode = c;
    165165                g->size     = gsize;
    166                 g->offset   = glm::ivec2( ft_glyph_left, ft_glyph_top );
    167                 g->tl       = glm::vec2( r.pos.x/(float)asize.x, r.pos.y/(float)asize.y );
    168                 g->br       = glm::vec2( ( r.pos.x + gsize.x )/(float)asize.x, (r.pos.y + gsize.y )/(float)asize.y );
     166                g->offset   = ivec2( ft_glyph_left, ft_glyph_top );
     167                g->tl       = vec2( r.pos.x/(float)asize.x, r.pos.y/(float)asize.y );
     168                g->br       = vec2( ( r.pos.x + gsize.x )/(float)asize.x, (r.pos.y + gsize.y )/(float)asize.y );
    169169
    170170                // Discard hinting to get advance
    171171                FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_HINTING);
    172172                slot = face->glyph;
    173                 g->advance = glm::ivec2( slot->advance.x/64.0, slot->advance.y/64.0 );
     173                g->advance = ivec2( slot->advance.x/64.0, slot->advance.y/64.0 );
    174174        }
    175175        generate_kerning();
  • trunk/src/gl/gl_context.cc

    r395 r398  
    731731        }
    732732        unsigned int buffers[8];
    733         count = glm::min<uint32>( count, 8 );
     733        count = nv::min<uint32>( count, 8 );
    734734        for ( uint32 i = 0; i < count; ++i )
    735735        {
  • trunk/src/gl/gl_device.cc

    r395 r398  
    5353        assert( image->format->BytesPerPixel > 2 );
    5454        image_format format(image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE );
    55         image_data* data = new image_data( format, glm::ivec2( image->w, image->h ), (nv::uint8*)image->pixels );
     55        image_data* data = new image_data( format, ivec2( image->w, image->h ), (nv::uint8*)image->pixels );
    5656        return data;
    5757}
     
    7171        assert( image->format->BytesPerPixel > 2 );
    7272        image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE );
    73         image_data* idata = new image_data( format, glm::ivec2( image->w, image->h ), ( nv::uint8* )image->pixels );
     73        image_data* idata = new image_data( format, ivec2( image->w, image->h ), ( nv::uint8* )image->pixels );
    7474        return idata;
    7575}
  • trunk/src/rogue/fov_recursive_shadowcasting.cc

    r395 r398  
    2424        {
    2525                position max_radius = m_size-m_position;
    26                 max_radius.x=glm::max(max_radius.x,m_position.x);
    27                 max_radius.y=glm::max(max_radius.y,m_position.y);
    28                 m_radius = (int)glm::length((glm::vec2)max_radius)+1;
     26                max_radius = glm::max(max_radius,m_position);
     27                m_radius = (int)glm::length((vec2)max_radius)+1;
    2928        }
    3029        m_radius2 = m_radius * m_radius;
Note: See TracChangeset for help on using the changeset viewer.