- Timestamp:
- 09/21/15 19:13:26 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/random.cc
r454 r471 21 21 void random::mt_init( uint32 seed ) 22 22 { 23 m_state[0] = static_cast<uint32 _t>( seed & mt_full_mask );23 m_state[0] = static_cast<uint32>( seed & mt_full_mask ); 24 24 for ( int i = 1; i < mersenne_n; i++ ) 25 25 { … … 111 111 { 112 112 f32 angle = frand( math::pi<f32>() * 2.f ); 113 return vec2( math::cos( angle ), math::sin( angle ) );113 return vec2( cos( angle ), sin( angle ) ); 114 114 } 115 115 … … 117 117 { 118 118 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 ); 120 120 f32 phi = frand( 2 * math::pi<f32>() ); 121 121 return vec3( 122 sin_theta * math::sin(phi),123 sin_theta * math::cos(phi),122 sin_theta * sin(phi), 123 sin_theta * cos(phi), 124 124 cos_theta 125 125 ); … … 132 132 if ( r1 > r2 ) swap( r1, r2 ); 133 133 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 ) ); 135 135 } 136 136 137 137 nv::vec2 nv::random::precise_disk_point() 138 138 { 139 f32 r = math::sqrt( frand() );139 f32 r = sqrt( frand() ); 140 140 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 ) ); 142 142 } 143 143 … … 146 146 f32 rad = frand(); 147 147 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; 149 149 f32 theta = frange( 0.0f, 2 * math::pi<f32>() ); 150 f32 sin_phi = math::sin( phi );150 f32 sin_phi = sin( phi ); 151 151 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) 155 155 ); 156 156 } … … 158 158 nv::vec3 nv::random::precise_sphere_point() 159 159 { 160 f32 radius = math::pow( frand(), 1.f/3.f );160 f32 radius = pow( frand(), 1.f/3.f ); 161 161 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 ); 163 163 f32 phi = frange( 0.0f, 2 * math::pi<f32>() ); 164 164 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), 167 167 radius * cos_theta 168 168 ); … … 203 203 f32 idist2 = iradius * iradius; 204 204 f32 odist2 = oradius * oradius; 205 f32 rdist = math::sqrt( frange( idist2, odist2 ) );205 f32 rdist = sqrt( frange( idist2, odist2 ) ); 206 206 return rdist * precise_unit_vec2(); 207 207 } … … 216 216 f32 idist3 = iradius * iradius * iradius; 217 217 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 ); 219 219 return rdist * precise_unit_vec3(); 220 220 } … … 237 237 f32 idist2 = ((iradii2.x * iradii2.y) / low ) * odist2; 238 238 239 f32 rdist = math::sqrt( frange( idist2, odist2 ) );239 f32 rdist = sqrt( frange( idist2, odist2 ) ); 240 240 return odir * rdist; 241 241 } … … 260 260 f32 idist2 = ((iradii2.x * iradii2.y * iradii2.z) / low ) * odist2; 261 261 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 ); 266 266 return odir * rdist; 267 267 } -
trunk/src/engine/particle_engine.cc
r454 r471 231 231 datap->plane_normal = normalize_safe( datap->plane_normal, vec3(0.0f,1.0f,0.0f) ); 232 232 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 ) ); 234 234 return true; 235 235 } … … 751 751 { 752 752 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 ); 755 755 float phi = r.frange( 0.0f, 2* math::pi<float>() ); 756 756 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 ) + 759 759 edata.dir * cos_theta ); 760 760 } -
trunk/src/formats/assimp_loader.cc
r470 r471 350 350 351 351 uint16 frame_rate = static_cast<uint16>( anim->mTicksPerSecond ); 352 int check_this;353 352 uint16 duration = static_cast<uint16>( anim->mDuration ); 354 353 bool flat = false; -
trunk/src/formats/md3_loader.cc
r451 r471 246 246 { 247 247 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 ); 250 250 for ( int lng = 0; lng < 256; ++lng, ++n ) 251 251 { 252 252 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 ); 255 255 s_normal_cache[n].x = cos_lat * sin_lng; 256 256 // s_normal_cache[n].y = sin_lat * sin_lng; -
trunk/src/gfx/mesh_creator.cc
r470 r471 17 17 if ( m_data->m_flat ) return; 18 18 merge_keys(); 19 uint 32max_frames = 0;19 uint16 max_frames = 0; 20 20 21 21 nv::vector< sint16 > ids; … … 65 65 size_t count = ( keys ? keys->get_channel_size(0) : 0 ); 66 66 size_t pcount = ( pkeys ? pkeys->get_channel_size(0) : 0 ); 67 max_frames = nv::max<uint 32>( count, max_frames );67 max_frames = nv::max<uint16>( uint16( count ), max_frames ); 68 68 if ( pkeys && pkeys->size() > 0 && keys && keys->size() > 0 ) 69 69 { -
trunk/src/gfx/skeletal_mesh.cc
r470 r471 48 48 { 49 49 float fframe = ( a_ms_time * 0.001f ) * m_fps; 50 uint32 frame = math::floor( fframe);50 uint32 frame = uint32( math::floor( fframe ) ); 51 51 float reminder = fframe - static_cast<float>( frame ); 52 52 uint32 duration = get_frame_count(); -
trunk/src/gfx/texture_atlas.cc
r398 r471 22 22 region r ( ivec2(0,0), size ); 23 23 24 int best_height = INT_MAX;24 int best_height = nv::limits::si_max; 25 25 int best_index = -1; 26 int best_width = INT_MAX;26 int best_width = nv::limits::si_max; 27 27 28 28 for( size_t i=0; i < m_nodes.size(); ++i ) -
trunk/src/gfx/texture_font.cc
r438 r471 172 172 FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_HINTING); 173 173 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 ); 175 175 } 176 176 generate_kerning(); -
trunk/src/gl/gl_device.cc
r466 r471 76 76 } 77 77 // TODO: BGR vs RGB, single channel 78 assert( image->format->BytesPerPixel > 2);78 NV_ASSERT( image->format->BytesPerPixel > 2, "bytes per pixel > 2!" ); 79 79 image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE ); 80 80 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 215 215 image_data* data = m_window->get_device()->create_image_data( filename ); 216 216 // TODO: Repitching 217 assert( data->get_depth() == 4);217 NV_ASSERT( data->get_depth() == 4, "depth != 4" ); 218 218 region r = m_atlas.get_region( data->get_size() ); 219 219 m_atlas.set_region( r, data->get_data() ); … … 327 327 position p2 = p + g->size + gp; 328 328 qvec.emplace_back( p + gp, p2, color, g->tl, g->br ); 329 p += g->advance;329 p += ivec2( g->advance ); 330 330 } 331 331 } -
trunk/src/lua/lua_math.cc
r452 r471 214 214 { 215 215 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 ) 217 217 { 218 218 lua_pushnumber( L, v[i] ); 219 219 } 220 return v. length();220 return v.size(); 221 221 } 222 222 … … 226 226 T* v = to_pvec<T>( L, 1 ); 227 227 size_t len = 0; 228 int vlen = v->length();228 size_t vlen = v->size(); 229 229 const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) ); 230 int idx = 255;230 size_t idx = 255; 231 231 232 232 if ( len == 1 ) … … 264 264 T* v = to_pvec<T>( L, 1 ); 265 265 size_t len = 0; 266 int vlen = v->length();266 size_t vlen = v->size(); 267 267 const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) ); 268 int idx = 255;268 size_t idx = 255; 269 269 if( len == 1 ) 270 270 { … … 293 293 T v = to_vec<T>( L, 1 ); 294 294 bool fl = nv::is_floating_point<typename T::value_type>::value; 295 switch ( v. length() )295 switch ( v.size() ) 296 296 { 297 297 case 1: lua_pushfstring( L, ( fl ? "(%f)" : "(%d)" ), v[0] ); break;
Note: See TracChangeset
for help on using the changeset viewer.