Changeset 416 for trunk/src/gfx
- Timestamp:
- 07/10/15 14:16:42 (10 years ago)
- Location:
- trunk/src/gfx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/keyframed_mesh.cc
r415 r416 23 23 , m_active( false ) 24 24 { 25 m_index_count = m_mesh_data->get_ index_channel()->size();25 m_index_count = m_mesh_data->get_channel( slot::INDEX )->size(); 26 26 m_vertex_count = m_mesh_data->get_channel<vertex_t>()->size(); 27 27 m_vchannel = m_mesh_data->get_channel<vertex_pnt>(); … … 190 190 m_context->add_vertex_buffers( m_va, vb, m_mesh_data->get_channel<vertex_t>() ); 191 191 192 const raw_data_channel* index_channel = m_mesh_data->get_ index_channel();192 const raw_data_channel* index_channel = m_mesh_data->get_channel( slot::INDEX ); 193 193 buffer ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, index_channel->raw_size(), index_channel->raw_data() ); 194 195 m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->descriptor()[0].etype, true ); 194 m_context->set_index_buffer( m_va, ib, index_channel->descriptor()[0].etype, true ); 196 195 197 196 m_data = new uint8[ m_vertex_count * m_vsize ]; -
trunk/src/gfx/mesh_creator.cc
r415 r416 6 6 7 7 #include "nv/gfx/mesh_creator.hh" 8 9 #include "nv/interface/data_channel_access.hh" 8 10 9 11 struct nv_key_transform { nv::transform tform; }; … … 22 24 size_t pcount = ( pkeys ? pkeys->get_channel(0)->size() : 0 ); 23 25 max_frames = nv::max<uint32>( count, max_frames ); 24 if ( pkeys && pkeys-> get_channel_count() > 0 && keys && keys->get_channel_count() > 0 )26 if ( pkeys && pkeys->size() > 0 && keys && keys->size() > 0 ) 25 27 { 26 28 data_channel_creator< nv_key_transform > channel_creator( const_cast< raw_data_channel* >( keys->get_channel( 0 ) ) ); … … 54 56 { 55 57 key_data* old_keys = m_data->m_nodes[i].data; 56 if ( old_keys && old_keys-> get_channel_count() > 0 )57 { 58 size_t chan_count = old_keys-> get_channel_count();58 if ( old_keys && old_keys->size() > 0 ) 59 { 60 size_t chan_count = old_keys->size(); 59 61 if ( chan_count == 1 60 62 && old_keys->get_channel(0)->descriptor().size() == 1 … … 85 87 86 88 delete old_keys; 87 new_keys->add_ channel( kt_channel.release() );89 new_keys->add_key_channel( kt_channel.release() ); 88 90 m_data->m_nodes[i].data = new_keys; 89 91 } … … 104 106 { 105 107 key_data* kdata = node.data; 106 for ( size_t c = 0; c < kdata-> get_channel_count(); ++c )108 for ( size_t c = 0; c < kdata->size(); ++c ) 107 109 { 108 110 raw_data_channel_creator channel( const_cast< raw_data_channel* >( kdata->get_channel( c ) ) ); … … 123 125 mat3 normal_transform = r33; 124 126 125 for ( uint32 c = 0; c < m_data-> get_channel_count(); ++c )126 { 127 raw_data_channel_creator channel( m_data ->m_channels[ c ]);127 for ( uint32 c = 0; c < m_data->size(); ++c ) 128 { 129 raw_data_channel_creator channel( m_data, c ); 128 130 const data_descriptor& desc = channel.descriptor(); 129 131 uint8* raw_data = channel.raw_data(); … … 173 175 size_t n_offset = 0; 174 176 if ( ch_n == -1 ) return; 175 raw_data_channel_creator channel( m_data ->m_channels[ unsigned( ch_n ) ]);177 raw_data_channel_creator channel( m_data, unsigned( ch_n ) ); 176 178 for ( const auto& cslot : channel.descriptor() ) 177 179 if ( cslot.vslot == slot::NORMAL ) … … 201 203 const raw_data_channel* i_channel = nullptr; 202 204 203 for ( uint32 c = 0; c < m_data-> get_channel_count(); ++c )205 for ( uint32 c = 0; c < m_data->size(); ++c ) 204 206 { 205 207 const raw_data_channel* channel = m_data->get_channel(c); … … 219 221 { 220 222 n_offset = int( cslot.offset ); 221 n_channel = m_data->m_channels[ c ];223 n_channel = data_channel_set_creator( m_data )[ c ]; 222 224 n_channel_index = c; 223 225 } … … 331 333 delete tangents2; 332 334 333 m_data->m_channels[ n_channel_index ] = merge_channels( n_channel, g_channel.channel() );335 ( data_channel_set_creator( m_data ))[ n_channel_index ] = merge_channels( n_channel, g_channel.channel() ); 334 336 delete n_channel; 335 337 } 336 338 337 nv::raw_data_channel* nv::mesh_data_creator::merge_channels( raw_data_channel* a,raw_data_channel* b )339 nv::raw_data_channel* nv::mesh_data_creator::merge_channels( const raw_data_channel* a, const raw_data_channel* b ) 338 340 { 339 341 NV_ASSERT( a->size() == b->size(), "merge_channel - bad channels!" ); … … 351 353 } 352 354 353 nv::raw_data_channel* nv::mesh_data_creator::append_channels( raw_data_channel* a,raw_data_channel* b, uint32 frame_count )355 nv::raw_data_channel* nv::mesh_data_creator::append_channels( const raw_data_channel* a, const raw_data_channel* b, uint32 frame_count ) 354 356 { 355 357 if ( a->descriptor() != b->descriptor() ) return nullptr; … … 389 391 bool nv::mesh_data_creator::is_same_format( mesh_data* other ) 390 392 { 391 if ( m_data-> get_channel_count() != other->get_channel_count() ) return false;392 for ( uint32 c = 0; c < m_data-> get_channel_count(); ++c )393 if ( m_data->size() != other->size() ) return false; 394 for ( uint32 c = 0; c < m_data->size(); ++c ) 393 395 { 394 396 if ( m_data->get_channel(c)->descriptor() != other->get_channel(c)->descriptor() ) … … 406 408 int och_ti = other->get_channel_index( slot::TEXCOORD ); 407 409 if ( ch_pi == -1 || ch_ti == -1 ) return; 408 size_t size = m_data-> m_channels[ unsigned(ch_ti) ]->size();409 size_t osize = other-> m_channels[ unsigned(och_ti) ]->size();410 size_t count = m_data-> m_channels[ unsigned(ch_pi) ]->size();411 size_t ocount = other-> m_channels[ unsigned(och_pi) ]->size();410 size_t size = m_data->get_channel_size( unsigned(ch_ti) ); 411 size_t osize = other->get_channel_size( unsigned(och_ti) ); 412 size_t count = m_data->get_channel_size( unsigned(ch_pi) ); 413 size_t ocount = other->get_channel_size( unsigned(och_pi) ); 412 414 if ( count % size != 0 || ocount % osize != 0 ) return; 413 415 if ( count / size != ocount / osize ) return; 414 416 415 for ( uint32 c = 0; c < m_data->get_channel_count(); ++c ) 416 { 417 raw_data_channel* old = m_data->m_channels[c]; 417 data_channel_set_creator data( m_data ); 418 419 for ( uint32 c = 0; c < m_data->size(); ++c ) 420 { 421 const raw_data_channel* old = m_data->get_channel( c ); 418 422 bool old_is_index = old->size() > 0 && old->descriptor()[0].vslot == slot::INDEX; 419 423 size_t frame_count = ( old_is_index ? 1 : old->size() / size ); 420 m_data->m_channels[c] = append_channels( old, other->m_channels[c], frame_count );421 NV_ASSERT( m_data->m_channels[c], "Merge problem!" );424 data[c] = append_channels( old, other->get_channel(c), frame_count ); 425 NV_ASSERT( data[c], "Merge problem!" ); 422 426 if ( old_is_index ) 423 427 { … … 427 431 { 428 432 NV_ASSERT( size + osize < uint16(-1), "Index out of range!" ); 429 raw_data_channel_creator ic( m_data->m_channels[c] );433 raw_data_channel_creator ic( data[c] ); 430 434 uint16* indexes = reinterpret_cast<uint16*>( ic.raw_data() ); 431 435 for ( uint16 i = uint16( old->size() ); i < ic.size(); ++i ) … … 436 440 case UINT : 437 441 { 438 raw_data_channel_creator ic( m_data->m_channels[c] );442 raw_data_channel_creator ic( data[c] ); 439 443 uint32* indexes = reinterpret_cast<uint32*>( ic.raw_data() ); 440 444 for ( uint32 i = old->size(); i < ic.size(); ++i ) … … 444 448 default : NV_ASSERT( false, "Unsupported index type!" ); break; 445 449 } 446 m_data->m_index_channel = m_data->m_channels[c];447 450 } 448 451 delete old; 449 452 } 450 453 } 454 455 void nv::mesh_creator::delete_mesh( uint32 index ) 456 { 457 if ( index < m_pack->get_count() ) 458 { 459 data_channel_set_creator( &m_pack->m_meshes[index] ).destroy(); 460 data_channel_set_creator( &m_pack->m_meshes[m_pack->m_count - 1] ).move_to( m_pack->m_meshes[index] ); 461 m_pack->m_count--; 462 } 463 } -
trunk/src/gfx/skeletal_mesh.cc
r415 r416 27 27 28 28 m_vtx_data = a_mesh_data->get_channel_data<md5_vtx_pntiw>(); 29 m_indices = a_mesh_data->get_c ount();29 m_indices = a_mesh_data->get_channel_size( slot::INDEX ); 30 30 m_va = a_context->create_vertex_array(); 31 31 32 array_view< raw_data_channel* > channels = a_mesh_data->get_raw_channels();33 for ( uint32 ch = 0; ch < channels.size(); ++ch)34 { 35 const raw_data_channel* channel = channels[ch];32 //array_view< raw_data_channel* > channels = a_mesh_data->get_raw_channels(); 33 for ( auto channel : *a_mesh_data ) 34 { 35 //const raw_data_channel* channel = channels[ch]; 36 36 if ( channel->size() > 0 && channel != pntiw_chan ) 37 37 { … … 218 218 { 219 219 m_va = a_context->create_vertex_array( a_mesh, nv::STATIC_DRAW ); 220 m_index_count = a_mesh->get_c ount();220 m_index_count = a_mesh->get_channel_size( slot::INDEX ); 221 221 if ( m_bone_data ) 222 222 {
Note: See TracChangeset
for help on using the changeset viewer.