- Timestamp:
- 07/31/15 20:25:22 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/random.cc
r451 r454 231 231 vec2 opoint = ellipse_edge( oradii ); 232 232 vec2 opoint2 = opoint * opoint; 233 vec2 odir = glm::normalize( opoint );233 vec2 odir = math::normalize( opoint ); 234 234 f32 odist2 = opoint2.x + opoint2.y; 235 235 … … 251 251 vec3 opoint = ellipsoid_edge( oradii ); 252 252 vec3 opoint2 = opoint * opoint; 253 vec3 odir = glm::normalize( opoint );253 vec3 odir = math::normalize( opoint ); 254 254 f32 odist2 = opoint2.x + opoint2.y + opoint2.z; 255 255 -
trunk/src/engine/particle_engine.cc
r453 r454 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 = - 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 ) ); 234 234 return true; 235 235 } … … 242 242 particle& pt = p[i]; 243 243 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 ) 245 245 { 246 float val = glm::dot( datap->plane_normal, pt.position ) + datap->distance;246 float val = math::dot( datap->plane_normal, pt.position ) + datap->distance; 247 247 if ( val > 0.0f ) 248 248 { 249 vec3 part_dir = direction * ( -val / glm::dot( datap->plane_normal, direction ) );249 vec3 part_dir = direction * ( -val / math::dot( datap->plane_normal, direction ) ); 250 250 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; 252 252 } 253 253 } … … 273 273 for ( uint32 i = 0; i < count; ++i ) 274 274 { 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 ); 276 276 } 277 277 } … … 296 296 for ( uint32 i = 0; i < count; ++i ) 297 297 { 298 p[i].size = glm::max( p[i].size + adjustment, vec2() );298 p[i].size = math::max( p[i].size + adjustment, vec2() ); 299 299 } 300 300 } … … 347 347 } 348 348 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) ) ); 351 351 352 352 vec2 def_size = table.get<vec2>("size", vec2(0.1,0.1) ); … … 409 409 410 410 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) ) ); 412 412 413 413 edata.odir = vec3( 0, 0, 1 ); 414 414 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 ); 416 417 417 418 data.emmiter_count++; … … 563 564 m_model_matrix = s.get_model(); 564 565 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()); 566 567 567 568 update_emmiters( info, m_last_update ); … … 636 637 637 638 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 ); 639 640 640 641 switch ( orientation ) 641 642 { 642 643 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 ); 645 646 break; 646 647 case particle_orientation::ORIENTED : 647 648 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 ) ); 650 651 break; 651 652 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 ) ); 654 655 break; 655 656 case particle_orientation::PERPENDICULAR : 656 657 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 ) ); 659 660 break; 660 661 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 ) ); 663 664 break; 664 665 } -
trunk/src/formats/assimp_loader.cc
r451 r454 134 134 { 135 135 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] ) ); 139 139 vec2 s = assimp_st_cast( mesh->mTextureCoords[0][i] ); 140 140 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 ) ); 143 143 det = ( det < 0.0f ? -1.0f : 1.0f ); 144 144 nv::vec4 vt( t_i[0], t_i[1], t_i[2], det ); … … 441 441 // { 442 442 // 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) ) ); 444 444 // if ( node->mNumScalingKeys > 1 || scale_value > 0.001 ) 445 445 // { -
trunk/src/formats/obj_loader.cc
r442 r454 283 283 if ( ! (tv.x == 0.0f && tv.y == 0.0f && tv.z == 0.0f) ) 284 284 { 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; 287 287 } 288 288 } -
trunk/src/gfx/keyframed_mesh.cc
r451 r454 217 217 for ( size_t i = 0; i < m_vertex_count; ++i ) 218 218 { 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 ); 222 222 } 223 223 } … … 231 231 for ( size_t i = 0; i < m_vertex_count; ++i ) 232 232 { 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 ); 235 235 } 236 236 } -
trunk/src/gfx/mesh_creator.cc
r430 r454 95 95 void nv::mesh_nodes_creator::transform( float scale, const mat3& r33 ) 96 96 { 97 mat3 ri33 = glm::inverse( r33 );97 mat3 ri33 = math::inverse( r33 ); 98 98 mat4 pre_transform ( scale * r33 ); 99 99 mat4 post_transform( 1.f/scale * ri33 ); … … 150 150 { 151 151 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 ); 153 153 } 154 154 if ( t_offset != -1 ) … … 156 156 { 157 157 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] ); 159 159 } 160 160 } … … 299 299 vec3 xyz2 = v2 - v1; 300 300 301 //vec3 normal = glm::cross( xyz1, xyz2 );301 //vec3 normal = math::cross( xyz1, xyz2 ); 302 302 // 303 303 //vtcs[ ti0 ].normal += normal; … … 323 323 if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) ) 324 324 { 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; 327 327 } 328 328 } -
trunk/src/lua/lua_area.cc
r449 r454 255 255 nv::rectangle* a = to_parea( L, 1 ); 256 256 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 ); 258 258 return 0; 259 259 } … … 263 263 nv::rectangle* a = to_parea( L, 1 ); 264 264 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 ) ); 266 266 return 0; 267 267 } -
trunk/src/lua/lua_values.cc
r449 r454 25 25 void* nv::lua::detail::raw_check_userdata( lua_State *L, int index, const char* metatable ) 26 26 { 27 return luaL_ checkudata( L, index, metatable );27 return luaL_testudata( L, index, metatable ); 28 28 } 29 29 -
trunk/src/rogue/fov_recursive_shadowcasting.cc
r406 r454 24 24 { 25 25 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; 28 28 } 29 29 m_radius2 = m_radius * m_radius; -
trunk/src/sdl/sdl_audio.cc
r453 r454 75 75 if ( relative != vec3() ) 76 76 { 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 ); 79 79 } 80 80 if ( angle < 0.0f ) angle += 360.0f;
Note: See TracChangeset
for help on using the changeset viewer.