Changeset 471 for trunk/src


Ignore:
Timestamp:
09/21/15 19:13:26 (10 years ago)
Author:
epyon
Message:
  • full math library
  • GLM dependency removed
Location:
trunk/src
Files:
11 edited

Legend:

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

    r454 r471  
    2121void random::mt_init( uint32 seed )
    2222{
    23         m_state[0] = static_cast<uint32_t>( seed & mt_full_mask );
     23        m_state[0] = static_cast<uint32>( seed & mt_full_mask );
    2424        for ( int i = 1; i < mersenne_n; i++ )
    2525        {
     
    111111{
    112112        f32 angle = frand( math::pi<f32>() * 2.f );
    113         return vec2( math::cos( angle ), math::sin( angle ) );
     113        return vec2( cos( angle ), sin( angle ) );
    114114}
    115115
     
    117117{
    118118        f32 cos_theta = frange( -1.0f, 1.0f );
    119         f32 sin_theta = math::sqrt( 1.0f - cos_theta * cos_theta );
     119        f32 sin_theta = sqrt( 1.0f - cos_theta * cos_theta );
    120120        f32 phi       = frand( 2 * math::pi<f32>() );
    121121        return vec3(
    122                 sin_theta * math::sin(phi),
    123                 sin_theta * math::cos(phi),
     122                sin_theta * sin(phi),
     123                sin_theta * cos(phi),
    124124                cos_theta
    125125                );
     
    132132        if ( r1 > r2 ) swap( r1, r2 );
    133133        f32 rf = 2* math::pi<f32>()*(r1/r2);
    134         return vec2( r2*math::cos( rf ), r2*math::sin( rf ) );
     134        return vec2( r2*cos( rf ), r2*sin( rf ) );
    135135}
    136136
    137137nv::vec2 nv::random::precise_disk_point()
    138138{
    139         f32 r = math::sqrt( frand() );
     139        f32 r = sqrt( frand() );
    140140        f32 rangle = frand( math::pi<f32>() );
    141         return vec2( r*math::cos( rangle ), r*math::sin( rangle ) );
     141        return vec2( r*cos( rangle ), r*sin( rangle ) );
    142142}
    143143
     
    146146        f32 rad     = frand();
    147147        f32 pi      = math::pi<f32>();
    148         f32 phi     = math::asin( frange( -1.0f, 1.0f ) ) + pi*.5f;
     148        f32 phi     = asin( frange( -1.0f, 1.0f ) ) + pi*.5f;
    149149        f32 theta   = frange( 0.0f, 2 * math::pi<f32>() );
    150         f32 sin_phi = math::sin( phi );
     150        f32 sin_phi = sin( phi );
    151151        return vec3(
    152                 rad * math::cos(theta) * sin_phi,
    153                 rad * math::sin(theta) * sin_phi,
    154                 rad * math::cos(phi)
     152                rad * cos(theta) * sin_phi,
     153                rad * sin(theta) * sin_phi,
     154                rad * cos(phi)
    155155        );
    156156}
     
    158158nv::vec3 nv::random::precise_sphere_point()
    159159{
    160         f32 radius = math::pow( frand(), 1.f/3.f );
     160        f32 radius = pow( frand(), 1.f/3.f );
    161161        f32 cos_theta = frange( -1.0f, 1.0f );
    162         f32 sin_theta = math::sqrt( 1.0f - cos_theta * cos_theta );
     162        f32 sin_theta = sqrt( 1.0f - cos_theta * cos_theta );
    163163        f32 phi       = frange( 0.0f, 2 * math::pi<f32>() );
    164164        return vec3(
    165                 radius * sin_theta * math::sin(phi),
    166                 radius * sin_theta * math::cos(phi),
     165                radius * sin_theta * sin(phi),
     166                radius * sin_theta * cos(phi),
    167167                radius * cos_theta
    168168                );
     
    203203        f32 idist2 = iradius * iradius;
    204204        f32 odist2 = oradius * oradius;
    205         f32 rdist  = math::sqrt( frange( idist2, odist2 ) );
     205        f32 rdist  = sqrt( frange( idist2, odist2 ) );
    206206        return rdist * precise_unit_vec2();
    207207}
     
    216216        f32 idist3 = iradius * iradius * iradius;
    217217        f32 odist3 = oradius * oradius * oradius;
    218         f32 rdist  = math::pow( frange( idist3, odist3 ), 1.f/3.f );
     218        f32 rdist  = pow( frange( idist3, odist3 ), 1.f/3.f );
    219219        return rdist * precise_unit_vec3();
    220220}
     
    237237        f32 idist2 = ((iradii2.x * iradii2.y) / low ) * odist2;
    238238
    239         f32 rdist     = math::sqrt( frange( idist2, odist2 ) );
     239        f32 rdist     = sqrt( frange( idist2, odist2 ) );
    240240        return odir * rdist;   
    241241}
     
    260260        f32 idist2 = ((iradii2.x * iradii2.y * iradii2.z) / low ) * odist2;
    261261
    262         f32 odist3 = odist2 * math::sqrt( odist2 );
    263         f32 idist3 = idist2 * math::sqrt( idist2 );
    264 
    265         f32 rdist     = math::pow( frange( idist3, odist3 ), 1.f/3.f );
     262        f32 odist3 = odist2 * sqrt( odist2 );
     263        f32 idist3 = idist2 * sqrt( idist2 );
     264
     265        f32 rdist     = pow( frange( idist3, odist3 ), 1.f/3.f );
    266266        return odir * rdist;   
    267267}
  • trunk/src/engine/particle_engine.cc

    r454 r471  
    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     = -math::dot( datap->plane_normal, datap->plane_point ) / math::sqrt( math::dot( datap->plane_normal, datap->plane_normal ) );
     233        datap->distance     = -math::dot( datap->plane_normal, datap->plane_point ) / sqrt( math::dot( datap->plane_normal, datap->plane_normal ) );
    234234        return true;
    235235}
     
    751751                                        {
    752752                                                float emission_angle = math::radians( edata.angle );
    753                                                 float cos_theta = r.frange( math::cos( emission_angle ), 1.0f );
    754                                                 float sin_theta = math::sqrt(1.0f - cos_theta * cos_theta );
     753                                                float cos_theta = r.frange( cos( emission_angle ), 1.0f );
     754                                                float sin_theta = sqrt(1.0f - cos_theta * cos_theta );
    755755                                                float phi       = r.frange( 0.0f, 2* math::pi<float>() );
    756756                                                pinfo.velocity  = orient *
    757                                                         ( edata.odir * ( math::cos(phi) * sin_theta ) +
    758                                                         edata.cdir * ( math::sin(phi)*sin_theta ) +
     757                                                        ( edata.odir * ( cos(phi) * sin_theta ) +
     758                                                        edata.cdir * ( sin(phi)*sin_theta ) +
    759759                                                        edata.dir  * cos_theta );
    760760                                        }
  • trunk/src/formats/assimp_loader.cc

    r470 r471  
    350350
    351351        uint16 frame_rate     = static_cast<uint16>( anim->mTicksPerSecond );
    352         int check_this;
    353352        uint16 duration       = static_cast<uint16>( anim->mDuration );
    354353        bool   flat           = false;
  • trunk/src/formats/md3_loader.cc

    r451 r471  
    246246                {
    247247                        float flat    = lat * convert;
    248                         float sin_lat = math::sin( flat );
    249                         float cos_lat = math::cos( flat );
     248                        float sin_lat = nv::sin( flat );
     249                        float cos_lat = nv::cos( flat );
    250250                        for ( int lng = 0; lng < 256; ++lng, ++n )
    251251                        {
    252252                                float flng    = lng * convert;
    253                                 float sin_lng = math::sin( flng );
    254                                 float cos_lng = math::cos( flng );
     253                                float sin_lng = nv::sin( flng );
     254                                float cos_lng = nv::cos( flng );
    255255                                s_normal_cache[n].x = cos_lat * sin_lng;
    256256//                              s_normal_cache[n].y = sin_lat * sin_lng;
  • trunk/src/gfx/mesh_creator.cc

    r470 r471  
    1717        if ( m_data->m_flat ) return;
    1818        merge_keys();
    19         uint32 max_frames = 0;
     19        uint16 max_frames = 0;
    2020
    2121        nv::vector< sint16 > ids;
     
    6565                size_t count     = ( keys ? keys->get_channel_size(0) : 0 );
    6666                size_t pcount    = ( pkeys ? pkeys->get_channel_size(0) : 0 );
    67                 max_frames = nv::max<uint32>( count, max_frames );
     67                max_frames = nv::max<uint16>( uint16( count ), max_frames );
    6868                if ( pkeys && pkeys->size() > 0 && keys && keys->size() > 0 )
    6969                {
  • trunk/src/gfx/skeletal_mesh.cc

    r470 r471  
    4848{
    4949        float  fframe   = ( a_ms_time * 0.001f ) * m_fps;
    50         uint32 frame    = math::floor( fframe );
     50        uint32 frame    = uint32( math::floor( fframe ) );
    5151        float  reminder = fframe - static_cast<float>( frame );
    5252        uint32 duration = get_frame_count();
  • trunk/src/gfx/texture_atlas.cc

    r398 r471  
    2222        region r ( ivec2(0,0), size );
    2323
    24         int best_height = INT_MAX;
     24        int best_height = nv::limits::si_max;
    2525        int best_index  = -1;
    26         int best_width  = INT_MAX;
     26        int best_width  = nv::limits::si_max;
    2727
    2828        for( size_t i=0; i < m_nodes.size(); ++i )
  • trunk/src/gfx/texture_font.cc

    r438 r471  
    172172                FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_HINTING);
    173173                slot = face->glyph;
    174                 g->advance = ivec2( slot->advance.x/64.0f, slot->advance.y/64.0f );
     174                g->advance = vec2( slot->advance.x/64.0f, slot->advance.y/64.0f );
    175175        }
    176176        generate_kerning();
  • trunk/src/gl/gl_device.cc

    r466 r471  
    7676        }
    7777        // TODO: BGR vs RGB, single channel
    78         assert( image->format->BytesPerPixel > 2 );
     78        NV_ASSERT( image->format->BytesPerPixel > 2, "bytes per pixel > 2!" );
    7979        image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE );
    8080        image_data* idata = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) );
  • trunk/src/gui/gui_gfx_renderer.cc

    r469 r471  
    215215        image_data* data = m_window->get_device()->create_image_data( filename );
    216216        // TODO: Repitching
    217         assert( data->get_depth() == 4 );
     217        NV_ASSERT( data->get_depth() == 4, "depth != 4" );
    218218        region r = m_atlas.get_region( data->get_size() );
    219219        m_atlas.set_region( r, data->get_data() );
     
    327327                                                position p2 = p + g->size + gp;
    328328                                                qvec.emplace_back( p + gp, p2, color, g->tl, g->br );
    329                                                 p += g->advance;
     329                                                p += ivec2( g->advance );
    330330                                        }
    331331                                }
  • trunk/src/lua/lua_math.cc

    r452 r471  
    214214{
    215215        T v = to_vec<T>( L, 1 );
    216         for ( int i = 0; i < v.length(); ++i )
     216        for ( size_t i = 0; i < v.size(); ++i )
    217217        {
    218218                lua_pushnumber( L, v[i] );
    219219        }
    220         return v.length();
     220        return v.size();
    221221}
    222222
     
    226226        T* v = to_pvec<T>( L, 1 );
    227227        size_t len  = 0;
    228         int vlen = v->length();
     228        size_t vlen = v->size();
    229229        const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
    230         int idx = 255;
     230        size_t idx = 255;
    231231
    232232        if ( len == 1 )
     
    264264        T* v = to_pvec<T>( L, 1 );
    265265        size_t len  = 0;
    266         int vlen = v->length();
     266        size_t vlen = v->size();
    267267        const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
    268         int idx = 255;
     268        size_t idx = 255;
    269269        if( len == 1 )
    270270        {
     
    293293        T v = to_vec<T>( L, 1 );
    294294        bool fl = nv::is_floating_point<typename T::value_type>::value;
    295         switch ( v.length() )
     295        switch ( v.size() )
    296296        {
    297297        case 1: lua_pushfstring( L, ( fl ? "(%f)"          : "(%d)" ),          v[0] ); break;
Note: See TracChangeset for help on using the changeset viewer.