Changeset 454 for trunk/src


Ignore:
Timestamp:
07/31/15 20:25:22 (10 years ago)
Author:
epyon
Message:
  • math library work
  • glm only referenced in math/common.hh
  • still a lot work to do, but its WURF
Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/random.cc

    r451 r454  
    231231        vec2 opoint     = ellipse_edge( oradii );
    232232        vec2 opoint2    = opoint * opoint;
    233         vec2 odir       = glm::normalize( opoint );
     233        vec2 odir       = math::normalize( opoint );
    234234        f32 odist2    = opoint2.x + opoint2.y;
    235235
     
    251251        vec3 opoint     = ellipsoid_edge( oradii );
    252252        vec3 opoint2    = opoint * opoint;
    253         vec3 odir       = glm::normalize( opoint );
     253        vec3 odir       = math::normalize( opoint );
    254254        f32 odist2    = opoint2.x + opoint2.y + opoint2.z;
    255255
  • trunk/src/engine/particle_engine.cc

    r453 r454  
    231231        datap->plane_normal = normalize_safe( datap->plane_normal, vec3(0.0f,1.0f,0.0f) );
    232232        datap->bounce       = table->get<float>("bounce", 0.0f );
    233         datap->distance     = -glm::dot( datap->plane_normal, datap->plane_point ) / math::sqrt(glm::dot( datap->plane_normal, datap->plane_normal ) );
     233        datap->distance     = -math::dot( datap->plane_normal, datap->plane_point ) / math::sqrt( math::dot( datap->plane_normal, datap->plane_normal ) );
    234234        return true;
    235235}
     
    242242                particle& pt = p[i];
    243243                vec3 direction  = pt.velocity * factor;
    244                 if ( glm::dot( datap->plane_normal, pt.position + direction ) + datap->distance <= 0.0f )
     244                if ( math::dot( datap->plane_normal, pt.position + direction ) + datap->distance <= 0.0f )
    245245                {
    246                         float val = glm::dot( datap->plane_normal, pt.position ) + datap->distance;
     246                        float val = math::dot( datap->plane_normal, pt.position ) + datap->distance;
    247247                        if ( val > 0.0f )
    248248                        {
    249                                 vec3 part_dir = direction * ( -val / glm::dot( datap->plane_normal, direction ) );
     249                                vec3 part_dir = direction * ( -val / math::dot( datap->plane_normal, direction ) );
    250250                                pt.position = pt.position + part_dir + ( part_dir - direction ) * datap->bounce;
    251                                 pt.velocity = glm::reflect( pt.velocity, datap->plane_normal ) * datap->bounce;
     251                                pt.velocity = math::reflect( pt.velocity, datap->plane_normal ) * datap->bounce;
    252252                        }
    253253                }
     
    273273        for ( uint32 i = 0; i < count; ++i )
    274274        {
    275                 p[i].color = glm::clamp( p[i].color + adjustment, 0.0f, 1.0f );
     275                p[i].color = math::clamp( p[i].color + adjustment, 0.0f, 1.0f );
    276276        }
    277277}
     
    296296        for ( uint32 i = 0; i < count; ++i )
    297297        {
    298                 p[i].size = glm::max( p[i].size + adjustment, vec2() );
     298                p[i].size = math::max( p[i].size + adjustment, vec2() );
    299299        }
    300300}
     
    347347        }
    348348
    349         data.common_up  = glm::normalize( table.get<vec3>("common_up",  vec3(1,0,0) ) );
    350         data.common_dir = glm::normalize( table.get<vec3>("common_dir", vec3(0,1,0) ) );
     349        data.common_up  = math::normalize( table.get<vec3>("common_up",  vec3(1,0,0) ) );
     350        data.common_dir = math::normalize( table.get<vec3>("common_dir", vec3(0,1,0) ) );
    351351
    352352        vec2 def_size        = table.get<vec2>("size", vec2(0.1,0.1) );
     
    409409
    410410                                edata.rate         = element.get<float>("rate", 1.0f );
    411                                 edata.dir          = glm::normalize( element.get<vec3>("direction", vec3(0,1,0) ) );
     411                                edata.dir          = math::normalize( element.get<vec3>("direction", vec3(0,1,0) ) );
    412412                               
    413413                                edata.odir = vec3( 0, 0, 1 );
    414414                                if ( edata.dir != vec3( 0, 1, 0 ) && edata.dir != vec3( 0, -1, 0 ) )
    415                                         edata.odir = glm::normalize( glm::cross( edata.dir, vec3( 0, 1, 0 ) ) );                edata.cdir = glm::cross( edata.dir, edata.odir );
     415                                        edata.odir = math::normalize( math::cross( edata.dir, vec3( 0, 1, 0 ) ) );
     416                                edata.cdir = math::cross( edata.dir, edata.odir );
    416417
    417418                                data.emmiter_count++;
     
    563564                m_model_matrix = s.get_model();
    564565                m_camera_pos   = s.get_camera().get_position();
    565                 m_inv_view_dir = glm::normalize(-s.get_camera().get_direction());
     566                m_inv_view_dir = math::normalize(-s.get_camera().get_direction());
    566567
    567568                update_emmiters( info, m_last_update );
     
    636637
    637638                vec3 view_dir( m_inv_view_dir );
    638                 if ( accurate_facing ) view_dir = glm::normalize( m_camera_pos - pdata.position );
     639                if ( accurate_facing ) view_dir = math::normalize( m_camera_pos - pdata.position );
    639640
    640641                switch ( orientation )
    641642                {
    642643                case particle_orientation::POINT :
    643                         right   = glm::normalize( glm::cross( view_dir, vec3( 0, 1, 0 ) ) );
    644                         rot_mat = mat3( right, glm::cross( right, -view_dir ), -view_dir );
     644                        right   = math::normalize( math::cross( view_dir, vec3( 0, 1, 0 ) ) );
     645                        rot_mat = mat3( right, math::cross( right, -view_dir ), -view_dir );
    645646                        break;
    646647                case particle_orientation::ORIENTED :
    647648                        pdir    = normalize_safe( pdata.velocity, pdir );
    648                         right   = glm::normalize( glm::cross( pdir, view_dir ) );
    649                         rot_mat = mat3( right, pdir, glm::cross( pdir, right ) );
     649                        right   = math::normalize( math::cross( pdir, view_dir ) );
     650                        rot_mat = mat3( right, pdir, math::cross( pdir, right ) );
    650651                        break;
    651652                case particle_orientation::ORIENTED_COMMON :
    652                         right   = glm::normalize( glm::cross( common_dir, view_dir ) );
    653                         rot_mat = mat3( right, common_dir, glm::cross( common_dir, right ) );
     653                        right   = math::normalize( math::cross( common_dir, view_dir ) );
     654                        rot_mat = mat3( right, common_dir, math::cross( common_dir, right ) );
    654655                        break;
    655656                case particle_orientation::PERPENDICULAR :
    656657                        pdir    = normalize_safe( pdata.velocity, pdir );
    657                         right   = glm::normalize( glm::cross( common_up, pdir ) );
    658                         rot_mat = mat3( right, common_up, glm::cross( common_up, right ) );
     658                        right   = math::normalize( math::cross( common_up, pdir ) );
     659                        rot_mat = mat3( right, common_up, math::cross( common_up, right ) );
    659660                        break;
    660661                case particle_orientation::PERPENDICULAR_COMMON :
    661                         right   = glm::normalize( glm::cross( common_up, common_dir ) );
    662                         rot_mat = mat3( right, common_up, glm::cross( common_up, right ) );
     662                        right   = math::normalize( math::cross( common_up, common_dir ) );
     663                        rot_mat = mat3( right, common_up, math::cross( common_up, right ) );
    663664                        break;
    664665                }
  • trunk/src/formats/assimp_loader.cc

    r451 r454  
    134134                {
    135135                        vec3 v = assimp_vec3_cast( mesh->mVertices[i] );
    136                         vec3 n = glm::normalize( assimp_vec3_cast( mesh->mNormals[i] ) );
    137                         vec3 t = glm::normalize( assimp_vec3_cast( mesh->mTangents[i] ) );
    138                         vec3 b = glm::normalize( assimp_vec3_cast( mesh->mBitangents[i] ) );
     136                        vec3 n = math::normalize( assimp_vec3_cast( mesh->mNormals[i] ) );
     137                        vec3 t = math::normalize( assimp_vec3_cast( mesh->mTangents[i] ) );
     138                        vec3 b = math::normalize( assimp_vec3_cast( mesh->mBitangents[i] ) );
    139139                        vec2 s = assimp_st_cast( mesh->mTextureCoords[0][i] );
    140140
    141                         vec3 t_i = glm::normalize( t - n * glm::dot( n, t ) );
    142                         float det = ( glm::dot( glm::cross( n, t ), b ) );
     141                        vec3 t_i = math::normalize( t - n * math::dot( n, t ) );
     142                        float det = ( math::dot( math::cross( n, t ), b ) );
    143143                        det = ( det < 0.0f ? -1.0f : 1.0f );
    144144                        nv::vec4 vt( t_i[0], t_i[1], t_i[2], det );
     
    441441//      {
    442442//              vec3 scale_vec0 = assimp_vec3_cast( node->mScalingKeys[0].mValue );
    443 //              float scale_value   = glm::length( math::abs( scale_vec0 - vec3(1,1,1) ) );
     443//              float scale_value   = math::length( math::abs( scale_vec0 - vec3(1,1,1) ) );
    444444//              if ( node->mNumScalingKeys > 1 || scale_value > 0.001 )
    445445//              {
  • trunk/src/formats/obj_loader.cc

    r442 r454  
    283283                        if ( ! (tv.x == 0.0f && tv.y == 0.0f && tv.z == 0.0f) )
    284284                        {
    285                                 m_data[a].tangent    = vec4( glm::normalize(tv - nv * glm::dot( nv, tv )), 0.0f );
    286                                 m_data[a].tangent[3] = (glm::dot(glm::cross(nv, tv), tan2[a]) < 0.0f) ? -1.0f : 1.0f;
     285                                m_data[a].tangent    = vec4( math::normalize(tv - nv * math::dot( nv, tv )), 0.0f );
     286                                m_data[a].tangent[3] = ( math::dot( math::cross(nv, tv), tan2[a]) < 0.0f) ? -1.0f : 1.0f;
    287287                        }
    288288                }
  • trunk/src/gfx/keyframed_mesh.cc

    r451 r454  
    217217                for ( size_t i = 0; i < m_vertex_count; ++i )
    218218                {
    219                         vtx[i].position = glm::mix( prev[i].position, next[i].position, m_interpolation );
    220                         vtx[i].normal   = glm::mix( prev[i].normal,   next[i].normal,   m_interpolation );
    221                         vtx[i].tangent  = glm::mix( prev[i].tangent,  next[i].tangent,   m_interpolation );
     219                        vtx[i].position = math::mix( prev[i].position, next[i].position, m_interpolation );
     220                        vtx[i].normal   = math::mix( prev[i].normal,   next[i].normal,   m_interpolation );
     221                        vtx[i].tangent  = math::mix( prev[i].tangent,  next[i].tangent,   m_interpolation );
    222222                }
    223223        }
     
    231231                for ( size_t i = 0; i < m_vertex_count; ++i )
    232232                {
    233                         vtx[i].position = glm::mix( prev[i].position, next[i].position, m_interpolation );
    234                         vtx[i].normal   = glm::mix( prev[i].normal,   next[i].normal,   m_interpolation );
     233                        vtx[i].position = math::mix( prev[i].position, next[i].position, m_interpolation );
     234                        vtx[i].normal   = math::mix( prev[i].normal,   next[i].normal,   m_interpolation );
    235235                }
    236236        }
  • trunk/src/gfx/mesh_creator.cc

    r430 r454  
    9595void nv::mesh_nodes_creator::transform( float scale, const mat3& r33 )
    9696{
    97         mat3 ri33 = glm::inverse( r33 );
     97        mat3 ri33 = math::inverse( r33 );
    9898        mat4 pre_transform ( scale * r33 );
    9999        mat4 post_transform( 1.f/scale * ri33 );
     
    150150                        {
    151151                                vec3& n = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + n_offset );
    152                                 n = glm::normalize( normal_transform * n );
     152                                n = math::normalize( normal_transform * n );
    153153                        }
    154154                if ( t_offset != -1 )
     
    156156                        {
    157157                                vec4& t = *reinterpret_cast<vec4*>(raw_data + vtx_size*i + t_offset );
    158                                 t = vec4( glm::normalize( normal_transform * vec3(t) ), t[3] );
     158                                t = vec4( math::normalize( normal_transform * vec3(t) ), t[3] );
    159159                        }
    160160        }
     
    299299                        vec3 xyz2 = v2 - v1;
    300300
    301                         //vec3 normal = glm::cross( xyz1, xyz2 );
     301                        //vec3 normal = math::cross( xyz1, xyz2 );
    302302                        //
    303303                        //vtcs[ ti0 ].normal += normal;
     
    323323                if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) )
    324324                {
    325                         tangents[i]    = vec4( glm::normalize(t - n * glm::dot( n, t )), 0.0f );
    326                         tangents[i][3] = (glm::dot(glm::cross(n, t), tangents2[i]) < 0.0f) ? -1.0f : 1.0f;
     325                        tangents[i]    = vec4( math::normalize(t - n * math::dot( n, t )), 0.0f );
     326                        tangents[i][3] = ( math::dot( math::cross(n, t), tangents2[i]) < 0.0f) ? -1.0f : 1.0f;
    327327                }
    328328        }
  • trunk/src/lua/lua_area.cc

    r449 r454  
    255255        nv::rectangle* a = to_parea( L, 1 );
    256256        nv::ivec2*     c = to_pcoord( L, 2 );
    257         *c = glm::clamp( *c, a->ul, a->lr );
     257        *c = nv::math::clamp( *c, a->ul, a->lr );
    258258        return 0;
    259259}
     
    263263        nv::rectangle* a = to_parea( L, 1 );
    264264        nv::ivec2*     c = to_pcoord( L, 2 );
    265         push_coord( L, glm::clamp( *c, a->ul, a->lr ) );
     265        push_coord( L, nv::math::clamp( *c, a->ul, a->lr ) );
    266266        return 0;
    267267}
  • trunk/src/lua/lua_values.cc

    r449 r454  
    2525void* nv::lua::detail::raw_check_userdata( lua_State *L, int index, const char* metatable )
    2626{
    27         return luaL_checkudata( L, index, metatable );
     27        return luaL_testudata( L, index, metatable );
    2828}
    2929
  • trunk/src/rogue/fov_recursive_shadowcasting.cc

    r406 r454  
    2424        {
    2525                position max_radius = m_size-m_position;
    26                 max_radius = glm::max(max_radius,m_position);
    27                 m_radius = static_cast<int>( glm::length( vec2( max_radius ) ) )+1;
     26                max_radius = math::max(max_radius,m_position);
     27                m_radius = static_cast<int>( math::length( vec2( max_radius ) ) )+1;
    2828        }
    2929        m_radius2 = m_radius * m_radius;
  • trunk/src/sdl/sdl_audio.cc

    r453 r454  
    7575                        if ( relative != vec3() )
    7676                        {
    77                                 angle = math::degrees( -glm::orientedAngle( m_forward, glm::normalize( relative ), m_up ) );
    78                                 distance = glm::clamp( 20.0f * glm::length( relative ), 0.0f, 255.0f );
     77                                angle = math::degrees( -math::oriented_angle( m_forward, math::normalize( relative ), m_up ) );
     78                                distance = math::clamp( 20.0f * math::length( relative ), 0.0f, 255.0f );
    7979                        }
    8080                        if ( angle < 0.0f ) angle += 360.0f;
Note: See TracChangeset for help on using the changeset viewer.