Changeset 427 for trunk/src/formats/assimp_loader.cc
- Timestamp:
- 07/20/15 13:25:20 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/assimp_loader.cc
r425 r427 190 190 } 191 191 192 bool nv::assimp_loader::load_bones( size_t index, array_ref< mesh_node_data> bones )192 bool nv::assimp_loader::load_bones( size_t index, array_ref< data_channel_set* > bones ) 193 193 { 194 194 if ( m_scene == nullptr ) return false; … … 200 200 aiBone* bone = mesh->mBones[m]; 201 201 mat4 offset = assimp_mat4_cast( bone->mOffsetMatrix ); 202 bones[m] .data= data_channel_set_creator::create_set( 0 );203 data_channel_set_creator access( bones[m] .data);202 bones[m] = data_channel_set_creator::create_set( 0 ); 203 data_channel_set_creator access( bones[m] ); 204 204 const char* name = bone->mName.data; 205 205 access.set_name( make_name( name ) ); … … 287 287 { 288 288 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 289 vector< mesh_node_data > final_bones;289 mesh_nodes_data* result = new mesh_nodes_data( make_name( "bones" ) ); 290 290 unordered_map< uint64, uint16 > names; 291 291 for ( unsigned int m = 0; m < m_mesh_count; ++m ) 292 292 { 293 293 uint16 translate[MAX_BONES]; 294 vector< mesh_node_data> bones;294 vector< data_channel_set* > bones; 295 295 const aiMesh* mesh = scene->mMeshes[ m ]; 296 296 if ( mesh->mNumBones != 0 ) … … 301 301 { 302 302 303 mesh_node_data&bone = bones[b];304 auto iname = names.find( bone .data->get_name() );303 data_channel_set* bone = bones[b]; 304 auto iname = names.find( bone->get_name() ); 305 305 if ( iname == names.end() ) 306 306 { 307 NV_ASSERT( final_bones.size() < MAX_BONES, "Too many bones to merge!" );308 uint16 index = uint16( final_bones.size() );309 final_bones.push_back( bone );310 names[ bone .data->get_name() ] = index;307 NV_ASSERT( result->get_count() < MAX_BONES, "Too many bones to merge!" ); 308 uint16 index = uint16( result->get_count() ); 309 result->push_back( bone ); 310 names[ bone->get_name() ] = index; 311 311 translate[b] = index; 312 312 } … … 334 334 } 335 335 } 336 mesh_node_data* bones = new mesh_node_data[ final_bones.size() ]; 337 raw_copy( final_bones.begin(), final_bones.end(), bones ); 338 return new mesh_nodes_data( make_name( "bones" ), final_bones.size(), bones ); 336 337 return result; 339 338 } 340 339 … … 349 348 350 349 uint32 count = count_nodes( scene->mRootNode ); 351 mesh_node_data* data = new mesh_node_data[count];352 350 353 351 uint16 frame_rate = static_cast<uint16>( anim->mTicksPerSecond ); … … 355 353 bool flat = false; 356 354 357 load_node( index, data, root, 0, -1 ); 358 359 return new mesh_nodes_data( make_name( static_cast<const char*>( anim->mName.data ) ), count, data, frame_rate, duration, flat ); 355 data_channel_set** temp = new data_channel_set*[ count ]; 356 array_ref< data_channel_set* > temp_ref( temp, count ); 357 load_node( index, temp_ref, root, 0, -1 ); 358 359 mesh_nodes_data* result = new mesh_nodes_data( make_name( static_cast<const char*>( anim->mName.data ) ), frame_rate, duration, flat ); 360 for ( auto set : temp_ref ) 361 { 362 result->push_back( set ); 363 } 364 delete temp; 365 return result; 360 366 } 361 367 … … 371 377 } 372 378 373 nv::sint16 nv::assimp_loader::load_node( uint32 anim_id, mesh_node_data*nodes, const void* vnode, sint16 this_id, sint16 parent_id )379 nv::sint16 nv::assimp_loader::load_node( uint32 anim_id, array_ref< data_channel_set* > nodes, const void* vnode, sint16 this_id, sint16 parent_id ) 374 380 { 375 381 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); … … 386 392 } 387 393 388 mesh_node_data& a_data = nodes[ this_id ]; 389 390 if (anode) 391 create_keys( &a_data, anode ); 392 else 393 a_data.data = data_channel_set_creator::create_set( 0 ); 394 395 data_channel_set_creator access( a_data.data ); 394 nodes[ this_id ] = anode ? create_keys( anode ) : data_channel_set_creator::create_set( 0 ); 395 396 data_channel_set_creator access( nodes[this_id] ); 396 397 access.set_name( make_name( name ) ); 397 398 access.set_parent_id( parent_id ); … … 412 413 } 413 414 414 void nv::assimp_loader::create_keys( mesh_node_data* data,const void* vnode )415 data_channel_set* nv::assimp_loader::create_keys( const void* vnode ) 415 416 { 416 417 const aiNodeAnim* node = reinterpret_cast< const aiNodeAnim* >( vnode ); 417 418 if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 ) 418 419 { 419 return ;420 } 421 422 data ->data= data_channel_set_creator::create_set( 2 );423 data_channel_set_creator key_set( data->data);420 return data_channel_set_creator::create_set( 0 ); 421 } 422 423 data_channel_set* set = data_channel_set_creator::create_set( 2 ); 424 data_channel_set_creator key_set( set ); 424 425 425 426 assimp_key_p* pchannel = key_set.add_channel< assimp_key_p >( node->mNumPositionKeys ).data(); … … 456 457 // } 457 458 // } 458 459 return set; 459 460 } 460 461
Note: See TracChangeset
for help on using the changeset viewer.