Changeset 398
- Timestamp:
- 06/13/15 11:20:22 (10 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/core/arcball.hh
r395 r398 16 16 #include <nv/common.hh> 17 17 #include <nv/stl/math.hh> 18 #include <nv/stl/utility/common.hh> 18 19 19 20 namespace nv … … 46 47 void drag( ivec2 nposition ) 47 48 { 48 glm::vec3 va = get_arcball_vector( m_last );49 glm::vec3 vb = get_arcball_vector( nposition );49 vec3 va = get_arcball_vector( m_last ); 50 vec3 vb = get_arcball_vector( nposition ); 50 51 51 52 m_angle = glm::acos( glm::min( 1.0f, glm::dot( va, vb ) ) ); … … 56 57 f32 get_angle() const { return m_angle; } 57 58 private: 58 glm::vec3 get_arcball_vector( const nv::ivec2& s )59 vec3 get_arcball_vector( const ivec2& s ) 59 60 { 60 glm::vec3 p( 1.0*s.x / m_window.x * 2 - 1.0, 1.0*s.y / m_window.y * 2 - 1.0, 0 );61 vec3 p( 1.0*s.x / m_window.x * 2 - 1.0, 1.0*s.y / m_window.y * 2 - 1.0, 0 ); 61 62 p.y = -p.y; 62 63 float sq = p.x * p.x + p.y * p.y; … … 64 65 p.z = sqrt( 1.0f - sq ); 65 66 else 66 p = glm::normalize( p );67 p = math::normalize( p ); 67 68 return p; 68 69 } -
trunk/nv/core/transform.hh
r397 r398 26 26 void set_orientation( const quat& a_orientation ) { m_orientation = a_orientation; } 27 27 void set_orientation( float radians, const vec3& axis ) 28 { // use glm::radians if degrees!28 { // use math::radians if degrees! 29 29 m_orientation = glm::angleAxis( radians, axis ); 30 30 } … … 43 43 } 44 44 // void rotate( const vec3& axis, f32 angle ) 45 // { // use glm::radians if degrees!45 // { // use math::radians if degrees! 46 46 // quat temp( angle, axis ); 47 47 // m_orientation = temp * m_orientation; … … 54 54 mat4 extract() const 55 55 { 56 mat4 result = glm::mat4_cast( m_orientation );56 mat4 result = mat4_cast( m_orientation ); 57 57 result[3] = vec4( m_position, 1.0f ); 58 58 return result; … … 62 62 quat new_orient( glm::inverse( m_orientation ) ); 63 63 // TODO: simplify 64 return transform( - glm::mat3_cast(new_orient) * m_position, new_orient );64 return transform( -mat3_cast(new_orient) * m_position, new_orient ); 65 65 } 66 66 … … 100 100 return transform( 101 101 glm::mix ( a.get_position(), b.get_position(), value ), 102 glm::slerp( a.get_orientation(), b.get_orientation(), value ) 102 glm::slerp( a.get_orientation(), b.get_orientation(), value ) 103 103 ); 104 104 } -
trunk/nv/formats/md5_loader.hh
r395 r398 63 63 struct md5_weight 64 64 { 65 size_t 66 float 67 glm::vec3pos;65 size_t joint_id; 66 float bias; 67 vec3 pos; 68 68 }; 69 69 -
trunk/nv/interface/interpolation_raw.hh
r395 r398 64 64 { 65 65 case animation_slot::TIME: return mat4(); 66 case animation_slot::POSITION: return glm::translate( mat4(), glm::make_vec3( data ) );67 case animation_slot::ROTATION: return glm::mat4_cast( make_quat_fixed( data ) );68 case animation_slot::SCALE: return glm::scale( mat4(), glm::make_vec3( data ) );69 case animation_slot::TFORM: return transform( glm::make_vec3( data ), make_quat_fixed( data + 3 ) ).extract();66 case animation_slot::POSITION: return glm::translate( mat4(), make_vec3( data ) ); 67 case animation_slot::ROTATION: return mat4_cast( make_quat_fixed( data ) ); 68 case animation_slot::SCALE: return glm::scale( mat4(),make_vec3( data ) ); 69 case animation_slot::TFORM: return transform( make_vec3( data ), make_quat_fixed( data + 3 ) ).extract(); 70 70 default: 71 71 return mat4(); … … 84 84 case animation_slot::TIME: break; 85 85 case animation_slot::POSITION: 86 position = glm::translate( position, glm::make_vec3( data + offset ) ); break;86 position = glm::translate( position,make_vec3( data + offset ) ); break; 87 87 case animation_slot::ROTATION: 88 rotation = glm::mat4_cast( make_quat_fixed( data + offset ) ); break;88 rotation = mat4_cast( make_quat_fixed( data + offset ) ); break; 89 89 case animation_slot::SCALE: 90 scale = glm::scale( mat4(), glm::make_vec3( data + offset ) ); break;91 case animation_slot::TFORM: return transform( glm::make_vec3( data + offset ), make_quat_fixed( data + offset + 3 ) ).extract();90 scale = glm::scale( mat4(),make_vec3( data + offset ) ); break; 91 case animation_slot::TFORM: return transform( make_vec3( data + offset ), make_quat_fixed( data + offset + 3 ) ).extract(); 92 92 default: 93 93 break; … … 105 105 { 106 106 case animation_slot::TIME: return transform(); 107 case animation_slot::POSITION: return transform( glm::make_vec3( data ) );107 case animation_slot::POSITION: return transform( make_vec3( data ) ); 108 108 case animation_slot::ROTATION: return transform( make_quat_fixed( data ) ); 109 109 case animation_slot::SCALE: return transform(); 110 case animation_slot::TFORM: return transform( glm::make_vec3( data ), make_quat_fixed( data + 3 ) );110 case animation_slot::TFORM: return transform( make_vec3( data ), make_quat_fixed( data + 3 ) ); 111 111 default: 112 112 return transform(); … … 124 124 case animation_slot::TIME: break; 125 125 case animation_slot::POSITION: 126 position = glm::make_vec3( data + offset ); break;126 position = make_vec3( data + offset ); break; 127 127 case animation_slot::ROTATION: 128 128 rotation = make_quat_fixed( data + offset ); break; 129 129 case animation_slot::SCALE: break; 130 case animation_slot::TFORM: return transform( glm::make_vec3( data + offset ), make_quat_fixed( data + 3 ) );130 case animation_slot::TFORM: return transform( make_vec3( data + offset ), make_quat_fixed( data + 3 ) ); 131 131 default: 132 132 break; … … 145 145 { 146 146 quat& r = *((quat*)(data)); 147 r = glm::quat_cast( r33 * glm::mat3_cast( r ) * ri33 );147 r = quat_cast( r33 * mat3_cast( r ) * ri33 ); 148 148 } 149 149 inline void transform_key_scale( void* data, float scale ) … … 157 157 t = transform( 158 158 r33 * t.get_position() * scale, 159 glm::quat_cast( r33 * glm::mat3_cast( t.get_orientation() ) * ri33 )159 quat_cast( r33 * mat3_cast( t.get_orientation() ) * ri33 ) 160 160 ); 161 161 } -
trunk/nv/lib/assimp.hh
r395 r398 68 68 { 69 69 const float* p = (float*)&m; 70 return glm::transpose( glm::make_mat4( p ) );70 return glm::transpose( make_mat4( p ) ); 71 71 } 72 72 -
trunk/nv/stl/math.hh
r397 r398 43 43 template < typename T > using tquat = ::glm::tmat4x4<T>; 44 44 #endif 45 46 using ::glm::mat3_cast; 47 using ::glm::mat4_cast; 48 using ::glm::quat_cast; 49 using ::glm::make_vec2; 50 using ::glm::make_vec3; 51 using ::glm::make_vec4; 52 using ::glm::make_mat2; 53 using ::glm::make_mat3; 54 using ::glm::make_mat4; 45 55 46 56 typedef tvec2<sint8> i8vec2; -
trunk/src/formats/md5_loader.cc
r395 r398 31 31 } 32 32 33 static void unit_quat_w( glm::quat& quat )33 static void unit_quat_w( nv::quat& quat ) 34 34 { 35 35 float t = 1.0f - ( quat.x * quat.x ) - ( quat.y * quat.y ) - ( quat.z * quat.z ); … … 343 343 md5_vtx_pnt& vtc = vtcs[i]; 344 344 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); 348 348 349 349 stable_sort( weights + start_weight, weights + start_weight + weight_count, [] ( const md5_weight& a, const md5_weight& b ) -> bool { return a.bias > b.bias; } ); … … 386 386 const mesh_node_data& joint = nodes[weight.joint_id]; 387 387 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; 389 389 390 390 vtc.position += ( tr.get_position() + rot_pos ) * weight.bias; … … 404 404 uint32 ti2 = idata[ i * 3 + 2 ]; 405 405 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 ); 413 413 414 414 vtcs[ ti0 ].normal += normal; … … 436 436 md5_vtx_pntiw& vdata = vtx_data[i]; 437 437 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 ); 440 440 vtcs[i].normal = normal; 441 441 vtcs[i].tangent = tangent; 442 442 443 443 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); 446 446 447 447 for ( size_t j = 0; j < 4; ++j ) … … 484 484 transform ptr; 485 485 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; 487 487 488 488 pos = ptr.get_position() + rot_pos; -
trunk/src/gfx/image.cc
r395 r398 10 10 using namespace nv; 11 11 12 image::image( glm::ivec2 size, nv::size_t depth )12 image::image( ivec2 size, nv::size_t depth ) 13 13 : m_size( size ), m_depth( depth ), m_data( nullptr ) 14 14 { … … 23 23 24 24 25 image::image( glm::ivec2 size, nv::size_t depth, const uint8 * data, bool reversed )25 image::image( ivec2 size, nv::size_t depth, const uint8 * data, bool reversed ) 26 26 : m_size( size ), m_depth( depth ), m_data( nullptr ) 27 27 { -
trunk/src/gfx/mesh_creator.cc
r395 r398 21 21 size_t count = ( keys ? keys->get_channel(0)->count : 0 ); 22 22 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 ); 24 24 if ( pkeys && pkeys->get_channel_count() > 0 && keys && keys->get_channel_count() > 0 ) 25 25 { … … 28 28 for ( unsigned n = 0; n < count; ++n ) 29 29 { 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; 31 31 } 32 32 } … … 63 63 for ( size_t c = 0; c < chan_count; ++c ) 64 64 { 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 ); 66 66 } 67 67 … … 79 79 for ( uint16 c = 0; c < chan_count; ++c ) 80 80 { 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 ); 82 82 pkey += old_keys->get_channel(c)->get_raw( idx, pkey ); 83 83 } … … 119 119 void nv::mesh_data_creator::transform( float scale, const mat3& r33 ) 120 120 { 121 vec3 vertex_offset = glm::vec3();121 vec3 vertex_offset = vec3(); 122 122 mat3 vertex_transform = scale * r33; 123 123 mat3 normal_transform = r33; … … 297 297 vec3 xyz2 = v2 - v1; 298 298 299 // glm::vec3 normal = glm::cross( xyz1, xyz2 );299 //vec3 normal = glm::cross( xyz1, xyz2 ); 300 300 // 301 301 //vtcs[ ti0 ].normal += normal; -
trunk/src/gfx/texture_atlas.cc
r395 r398 11 11 using namespace nv; 12 12 13 texture_atlas::texture_atlas( glm::ivec2 size, nv::size_t depth, nv::size_t border /*= 1*/ )13 texture_atlas::texture_atlas( ivec2 size, nv::size_t depth, nv::size_t border /*= 1*/ ) 14 14 : image( size, depth ), m_used( 0 ), m_border( border ) 15 15 { 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 ) ) ); 17 17 fill( 0 ); 18 18 } 19 19 20 region texture_atlas::get_region( glm::ivec2 size )20 region texture_atlas::get_region( ivec2 size ) 21 21 { 22 region r ( glm::ivec2(0,0), size );22 region r ( ivec2(0,0), size ); 23 23 24 24 int best_height = INT_MAX; … … 31 31 if ( y >= 0 ) 32 32 { 33 glm::ivec3 node = m_nodes[ i ];33 ivec3 node = m_nodes[ i ]; 34 34 if ( ( (y + size.y) < best_height ) || 35 35 ( ((y + size.y) == best_height) && (node.z < best_width)) ) … … 46 46 if ( best_index == -1 ) 47 47 { 48 return region( glm::ivec2( -1, -1 ), glm::ivec2( 0, 0 ) );48 return region( ivec2( -1, -1 ), ivec2( 0, 0 ) ); 49 49 } 50 50 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 ) ); 52 52 53 53 for( size_t i = static_cast<size_t>( best_index )+1; i < m_nodes.size(); ++i ) 54 54 { 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 ]; 57 57 58 58 if ( node.x < prev.x + prev.z ) … … 82 82 } 83 83 84 int texture_atlas::fit( nv::size_t index, glm::ivec2 size )84 int texture_atlas::fit( nv::size_t index, ivec2 size ) 85 85 { 86 glm::ivec3 node = m_nodes[ index ];86 ivec3 node = m_nodes[ index ]; 87 87 88 88 if ( node.x + size.x > m_size.x - static_cast<int>( m_border ) ) … … 128 128 m_nodes.clear(); 129 129 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 ) ); 131 131 fill( 0 ); 132 132 } -
trunk/src/gfx/texture_font.cc
r395 r398 94 94 bool texture_font::load_glyphs( string_ref codes ) 95 95 { 96 FT_Face face 97 size_t 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(); 99 99 FT_Int32 flags = 0; 100 100 flags |= FT_LOAD_RENDER; … … 137 137 int reg_width = ft_bitmap_width / (depth > 3 ? 3 : (int)depth); 138 138 139 glm::ivec2 gsize( reg_width + 1, ft_bitmap_rows + 1 );139 ivec2 gsize( reg_width + 1, ft_bitmap_rows + 1 ); 140 140 region r = m_atlas->get_region( gsize ); 141 141 if ( r.pos.x < 0 ) … … 164 164 g->charcode = c; 165 165 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 ); 169 169 170 170 // Discard hinting to get advance 171 171 FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_HINTING); 172 172 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 ); 174 174 } 175 175 generate_kerning(); -
trunk/src/gl/gl_context.cc
r395 r398 731 731 } 732 732 unsigned int buffers[8]; 733 count = glm::min<uint32>( count, 8 );733 count = nv::min<uint32>( count, 8 ); 734 734 for ( uint32 i = 0; i < count; ++i ) 735 735 { -
trunk/src/gl/gl_device.cc
r395 r398 53 53 assert( image->format->BytesPerPixel > 2 ); 54 54 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 ); 56 56 return data; 57 57 } … … 71 71 assert( image->format->BytesPerPixel > 2 ); 72 72 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 ); 74 74 return idata; 75 75 } -
trunk/src/rogue/fov_recursive_shadowcasting.cc
r395 r398 24 24 { 25 25 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; 29 28 } 30 29 m_radius2 = m_radius * m_radius;
Note: See TracChangeset
for help on using the changeset viewer.