- Timestamp:
- 07/10/15 14:16:42 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/assimp_loader.cc
r415 r416 6 6 7 7 #include "nv/formats/assimp_loader.hh" 8 9 #include "nv/interface/data_channel_access.hh" 8 10 #include "nv/stl/unordered_map.hh" 9 11 #include "nv/lib/assimp.hh" … … 103 105 } 104 106 105 mesh_data* nv::assimp_loader::release_mesh_data( size_t index /*= 0 */ )107 data_channel_set* nv::assimp_loader::release_mesh_data( size_t index /*= 0 */ ) 106 108 { 107 109 if ( index >= m_mesh_count ) return nullptr; 108 mesh_data* result = new mesh_data;110 data_channel_set* result = data_channel_set_creator::create( 2 ); 109 111 load_mesh_data( result, index ); 110 112 return result; 111 113 } 112 void nv::assimp_loader::load_mesh_data( mesh_data* data, size_t index )114 void nv::assimp_loader::load_mesh_data( data_channel_set* data, size_t index ) 113 115 { 114 116 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 115 117 const aiMesh* mesh = scene->mMeshes[ index ]; 116 data->set_name( mesh->mName.data );117 118 118 119 bool skinned = mesh->mNumBones > 0; … … 180 181 } 181 182 } 182 data->add_channel( channel.release() ); 183 data->add_channel( ichannel.release() ); 183 184 data_channel_set_creator maccess( data ); 185 maccess.set_name( mesh->mName.data ); 186 maccess.add_channel( channel.release() ); 187 maccess.add_channel( ichannel.release() ); 184 188 } 185 189 … … 283 287 } 284 288 285 mesh_nodes_data* nv::assimp_loader::release_merged_bones( mesh_data* meshes )289 mesh_nodes_data* nv::assimp_loader::release_merged_bones( data_channel_set* meshes ) 286 290 { 287 291 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); … … 317 321 if ( m > 0 && bones.size() > 0 ) 318 322 { 319 data_channel_creator< assimp_skinned_vtx > channel( meshes[m].get_raw_channels()[0]);323 data_channel_creator< assimp_skinned_vtx > channel( const_cast< raw_data_channel* >( meshes[m].get_channel(0) ) ); 320 324 for ( unsigned v = 0; v < channel.size(); ++v ) 321 325 { … … 456 460 // } 457 461 // } 458 data->data->add_ channel( pchannel_creator.release() );459 data->data->add_ channel( rchannel_creator.release() );460 // data->data->add_ channel( schannel_creator.release() );462 data->data->add_key_channel( pchannel_creator.release() ); 463 data->data->add_key_channel( rchannel_creator.release() ); 464 // data->data->add_key_channel( schannel_creator.release() ); 461 465 } 462 466 … … 466 470 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 467 471 bool has_bones = false; 468 mesh_data* meshes = new mesh_data[ m_mesh_count ];472 data_channel_set* meshes = data_channel_set_creator::create_array( m_mesh_count, 2 ); 469 473 for ( size_t m = 0; m < m_mesh_count; ++m ) 470 474 { 471 475 const aiMesh* mesh = scene->mMeshes[ m ]; 472 meshes[m].set_name( mesh->mName.data );476 data_channel_set_creator( &meshes[m] ).set_name( mesh->mName.data ); 473 477 if ( mesh->mNumBones > 0 ) has_bones = true; 474 478 load_mesh_data(&meshes[m],m); -
trunk/src/formats/md2_loader.cc
r413 r416 8 8 9 9 #include "nv/core/logging.hh" 10 #include "nv/interface/data_channel_access.hh" 11 10 12 #include <cstring> 11 13 … … 309 311 310 312 311 mesh_data* nv::md2_loader::release_mesh_data( size_t )312 { 313 mesh_data* data = new mesh_data( "md2_mesh");313 data_channel_set* nv::md2_loader::release_mesh_data( size_t ) 314 { 315 data_channel_set* data = data_channel_set_creator::create( 3 ); 314 316 release_mesh_frame( data, -1 ); 315 317 return data; 316 318 } 317 319 318 void nv::md2_loader::release_mesh_frame( mesh_data* data, sint32 frame )320 void nv::md2_loader::release_mesh_frame( data_channel_set* data, sint32 frame ) 319 321 { 320 322 md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 ); … … 364 366 } 365 367 366 data->add_channel( mc_pn.release() ); 367 data->add_channel( mc_t.release() ); 368 data->add_channel( ic.release() ); 368 data_channel_set_creator maccess( data ); 369 370 maccess.add_channel( mc_pn.release() ); 371 maccess.add_channel( mc_t.release() ); 372 maccess.add_channel( ic.release() ); 369 373 } 370 374 371 375 mesh_data_pack* nv::md2_loader::release_mesh_data_pack() 372 376 { 373 mesh_data* data = new mesh_data[1];377 data_channel_set* data = data_channel_set_creator::create_array( 1, 3 ); 374 378 release_mesh_frame( &data[0], -1 ); 375 379 return new mesh_data_pack( 1, data ); -
trunk/src/formats/md3_loader.cc
r413 r416 8 8 9 9 #include "nv/core/logging.hh" 10 #include "nv/interface/data_channel_access.hh" 10 11 11 12 using namespace nv; … … 322 323 }; 323 324 324 mesh_data* nv::md3_loader::release_mesh_data( nv::size_t index )325 { 326 mesh_data* data = new mesh_data;325 data_channel_set* nv::md3_loader::release_mesh_data( nv::size_t index ) 326 { 327 data_channel_set* data = data_channel_set_creator::create(3); 327 328 release_mesh_frame( data, -1, static_cast< sint32 >( index ) ); 328 329 return data; 329 330 } 330 331 331 void nv::md3_loader::release_mesh_frame( mesh_data* data, sint32 frame, sint32 surface )332 void nv::md3_loader::release_mesh_frame( data_channel_set* data, sint32 frame, sint32 surface ) 332 333 { 333 334 md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 ); … … 412 413 } 413 414 414 data->set_name( reinterpret_cast< char* >( md3->header.name ) ); 415 data->add_channel( mc_pn.release() ); 416 data->add_channel( mc_t.release() ); 417 data->add_channel( ic.release() ); 415 data_channel_set_creator maccess( data ); 416 maccess.set_name( reinterpret_cast<char*>( md3->header.name ) ); 417 maccess.add_channel( mc_pn.release() ); 418 maccess.add_channel( mc_t.release() ); 419 maccess.add_channel( ic.release() ); 418 420 } 419 421 … … 436 438 437 439 raw_data_channel* keys = load_tags( name ); 438 nodes[i].data->add_ channel( keys );440 nodes[i].data->add_key_channel( keys ); 439 441 } 440 442 return new mesh_nodes_data( "tags", node_count, nodes ); … … 445 447 md3_t* md3 = reinterpret_cast<md3_t*>( m_md3 ); 446 448 int count = 1; 447 mesh_data* data = nullptr;449 data_channel_set* data = nullptr; 448 450 if ( m_merge_all ) 449 451 { 450 data = new mesh_data[1];452 data = data_channel_set_creator::create_array(1,3); 451 453 release_mesh_frame( &data[0], -1, -1 ); 452 data [0].set_name( reinterpret_cast< char* >( md3->header.name ) );454 data_channel_set_creator( &data[0] ).set_name( reinterpret_cast< char* >( md3->header.name ) ); 453 455 } 454 456 else 455 457 { 456 458 count = md3->header.num_surfaces; 457 data = new mesh_data[ count ];459 data = data_channel_set_creator::create_array( count, 3 ); 458 460 for ( int i = 0; i < count; ++i ) 459 461 { 460 462 release_mesh_frame( &data[i], -1, i ); 461 data [i].set_name( reinterpret_cast< char* >( md3->surfaces[i].header.name ) );463 data_channel_set_creator( &data[i] ).set_name( reinterpret_cast< char* >( md3->surfaces[i].header.name ) ); 462 464 } 463 465 } -
trunk/src/formats/md5_loader.cc
r415 r416 10 10 #include "nv/stl/vector.hh" 11 11 #include "nv/io/std_stream.hh" 12 #include "nv/interface/data_channel_access.hh" 12 13 13 14 #include <stdio.h> // sscanf … … 136 137 { 137 138 assert( m_type == MESH ); 138 mesh_data* mesh = new mesh_data("md5_mesh");139 data_channel_set_creator mesh; 139 140 140 141 uint32 num_verts = 0; … … 163 164 data_channel_creator<md5_vtx_pntiw> ch_pntiw( num_verts ); 164 165 tdata = ch_t.data(); 165 mesh ->add_channel( ch_pnt.release() );166 mesh ->add_channel( ch_t.release() );166 mesh.add_channel( ch_pnt.release() ); 167 mesh.add_channel( ch_t.release() ); 167 168 // TODO: hack to prevent rendering 168 169 //ch_pntiw->m_count = 0; 169 mesh ->add_channel( ch_pntiw.release() );170 mesh.add_channel( ch_pntiw.release() ); 170 171 } 171 172 weight_info.resize( num_verts ); … … 210 211 } 211 212 212 mesh ->add_channel( ch_i.release() );213 mesh.add_channel( ch_i.release() ); 213 214 } 214 215 else if ( command == "numweights" ) … … 235 236 } 236 237 237 prepare_mesh( nodes, weight_info.size(), mesh, weights.data(), weight_info.data() ); 238 239 m_meshes[ num_meshes ] = mesh; 238 data_channel_set* mdata = mesh.release(); 239 prepare_mesh( nodes, weight_info.size(), mdata, weights.data(), weight_info.data() ); 240 241 m_meshes[ num_meshes ] = mdata; 240 242 num_meshes++; 241 243 } // mesh … … 258 260 nodes[i].data = new key_data; 259 261 data_channel_creator< md5_key_t > fc( num_frames ); 260 nodes[i].data->add_ channel( fc.release() );262 nodes[i].data->add_key_channel( fc.release() ); 261 263 next_line( sstream ); 262 264 } … … 335 337 } 336 338 337 bool md5_loader::prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info )339 bool md5_loader::prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, data_channel_set* mdata, md5_weight* weights, md5_weight_info* weight_info ) 338 340 { 339 341 assert( m_type == MESH ); … … 400 402 } 401 403 402 const uint32* idata = reinterpret_cast< uint32* >( const_cast< uint8* >( mdata->get_ index_channel()->raw_data() ) );404 const uint32* idata = reinterpret_cast< uint32* >( const_cast< uint8* >( mdata->get_channel( slot::INDEX )->raw_data() ) ); 403 405 const md5_vtx_t* tdata = mdata->get_channel_data<md5_vtx_t>(); 404 406 405 407 // Prepare normals 406 uint32 tri_count = mdata->get_c ount() / 3;408 uint32 tri_count = mdata->get_channel_size( slot::INDEX ) / 3; 407 409 for ( unsigned int i = 0; i < tri_count; ++i ) 408 410 { … … 503 505 } 504 506 505 mesh_data* nv::md5_loader::release_mesh_data( size_t index )506 { 507 mesh_data* result = m_meshes[ index ];507 data_channel_set* nv::md5_loader::release_mesh_data( size_t index ) 508 { 509 data_channel_set* result = m_meshes[ index ]; 508 510 m_meshes[ index ] = nullptr; 509 511 return result; … … 520 522 { 521 523 uint32 size = m_meshes.size(); 522 mesh_data* meshes = new mesh_data[ size ];524 data_channel_set* meshes = data_channel_set_creator::create_array( size, 4 ); 523 525 for ( uint32 i = 0; i < size; ++i ) 524 526 { 525 m_meshes[i]->move_to( meshes[i] );527 data_channel_set_creator( m_meshes[i] ).move_to( meshes[i] ); 526 528 delete m_meshes[i]; 527 529 m_meshes[i] = nullptr; -
trunk/src/formats/nmd_loader.cc
r415 r416 8 8 #include "nv/io/std_stream.hh" 9 9 #include "nv/stl/string.hh" 10 #include "nv/interface/data_channel_access.hh" 10 11 11 12 using namespace nv; … … 34 35 bool nv::nmd_loader::load_mesh( stream& source, const nmd_element_header& e ) 35 36 { 36 mesh_data* mesh = new mesh_data();37 data_channel_set_creator mesh; 37 38 for ( uint32 s = 0; s < e.children; ++s ) 38 39 { … … 45 46 raw_data_channel_creator channel_creator( stream_header.format, stream_header.count ); 46 47 source.read( channel_creator.raw_data(), channel_creator.element_size(), channel_creator.size() ); 47 mesh ->add_channel( channel_creator.release() );48 mesh.add_channel( channel_creator.release() ); 48 49 } 49 50 m_mesh_names.push_back( e.name ); 50 m_meshes.push_back( mesh );51 return true; 52 } 53 54 mesh_data* nv::nmd_loader::release_mesh_data( size_t index )55 { 56 mesh_data* result = m_meshes[ index ];57 if ( m_strings ) result->set_name( m_strings->get( m_mesh_names[ index ] ) );51 m_meshes.push_back( mesh.release() ); 52 return true; 53 } 54 55 data_channel_set* nv::nmd_loader::release_mesh_data( size_t index ) 56 { 57 data_channel_set* result = m_meshes[ index ]; 58 if ( m_strings ) data_channel_set_creator( result ).set_name( m_strings->get( m_mesh_names[ index ] ) ); 58 59 m_meshes[ index ] = nullptr; 59 60 return result; … … 63 64 { 64 65 uint32 size = m_meshes.size(); 65 mesh_data* meshes = new mesh_data[ size ];66 data_channel_set* meshes = data_channel_set_creator::create_array( size, 0 ); 66 67 for ( uint32 i = 0; i < size; ++i ) 67 68 { 68 m_meshes[i]->move_to( meshes[i] );69 data_channel_set_creator( m_meshes[i] ).move_to( meshes[i] ); 69 70 delete m_meshes[i]; 70 71 } … … 130 131 raw_data_channel_creator channel_creator( cheader.format, cheader.count ); 131 132 source.read( channel_creator.raw_data(), channel_creator.element_size(), channel_creator.size() ); 132 kdata->add_ channel( channel_creator.release() );133 kdata->add_key_channel( channel_creator.release() ); 133 134 } 134 135 } … … 160 161 // nmd format dump 161 162 // HACK : TEMPORARY - will go to it's own file, probably nmd_io 162 static void nmd_dump_mesh( const mesh_data* mesh, stream& stream_out ) 163 { 164 array_view< raw_data_channel* > data = mesh->get_raw_channels(); 165 163 static void nmd_dump_mesh( const data_channel_set* mesh, stream& stream_out ) 164 { 166 165 uint32 size = sizeof( nmd_element_header ); 167 for ( auto chan : data)166 for ( auto chan : *mesh ) 168 167 { 169 168 size += sizeof( nmd_element_header ) + sizeof( nmd_stream_header ); … … 174 173 eheader.type = nmd_type::MESH; 175 174 eheader.name = 0; 176 eheader.children = static_cast< uint16 >( data.size() );175 eheader.children = static_cast< uint16 >( mesh->size() ); 177 176 eheader.size = size; 178 177 stream_out.write( &eheader, sizeof( eheader ), 1 ); 179 178 180 for ( auto chan : data)179 for ( auto chan : *mesh ) 181 180 { 182 181 nmd_element_header cheader; … … 203 202 total += sizeof( nmd_element_header ) + sizeof( nmd_node_header ); 204 203 if ( node->data ) 205 for ( uint32 c = 0; c < node->data-> get_channel_count(); ++c )204 for ( uint32 c = 0; c < node->data->size(); ++c ) 206 205 { 207 206 total += sizeof( nmd_element_header ) + sizeof( nmd_stream_header ); … … 227 226 const mesh_node_data* node = nodes->get_node(i); 228 227 uint32 chan_size = 0; 229 uint32 chan_count = ( node->data ? node->data-> get_channel_count() : 0 );228 uint32 chan_count = ( node->data ? node->data->size() : 0 ); 230 229 for ( uint32 c = 0; c < chan_count; ++c ) 231 230 { … … 280 279 for ( uint32 i = 0; i < model->get_count(); ++i ) 281 280 { 282 const mesh_data* mesh = model->get_mesh(i);281 const data_channel_set* mesh = model->get_mesh(i); 283 282 nmd_dump_mesh( mesh, stream_out ); 284 283 } -
trunk/src/formats/obj_loader.cc
r413 r416 7 7 #include "nv/formats/obj_loader.hh" 8 8 #include "nv/io/std_stream.hh" 9 #include "nv/interface/data_channel_access.hh" 10 9 11 #include <sstream> 10 12 … … 330 332 } 331 333 332 mesh_data* mesh = new mesh_data(reader->name);333 mesh->add_channel( channel.release() );334 m_meshes.push_back( mesh);334 data_channel_set_creator result;// ( reader->name ); 335 result.add_channel( channel.release() ); 336 m_meshes.push_back( result.release() ); 335 337 336 338 reader->reset(); … … 341 343 } 342 344 343 mesh_data* nv::obj_loader::release_mesh_data( size_t index )344 { 345 mesh_data* result = m_meshes[ index ];345 data_channel_set* nv::obj_loader::release_mesh_data( size_t index ) 346 { 347 data_channel_set* result = m_meshes[ index ]; 346 348 m_meshes[ index ] = nullptr; 347 349 return result; … … 356 358 { 357 359 uint32 size = m_meshes.size(); 358 mesh_data* meshes = new mesh_data[ size ];360 data_channel_set* meshes = data_channel_set_creator::create_array( size, 1 ); 359 361 for ( uint32 i = 0; i < size; ++i ) 360 362 { 361 m_meshes[i]->move_to( meshes[i] );363 data_channel_set_creator( m_meshes[i] ).move_to( meshes[i] ); 362 364 delete m_meshes[i]; 363 365 } -
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.