Changeset 323 for trunk/src/formats/md3_loader.cc
- Timestamp:
- 08/26/14 04:03:10 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/md3_loader.cc
r319 r323 234 234 235 235 md3_loader::md3_loader( bool merge_all ) 236 : m_m d3( nullptr ), m_merge_all( merge_all)236 : m_merge_all( merge_all ), m_md3( nullptr ) 237 237 { 238 238 if ( !s_normal_ready ) … … 286 286 { 287 287 md3_t* md3 = (md3_t*)m_md3; 288 key_raw_channel* result = key_raw_channel::create<md3_key>( md3->header.num_frames );288 key_raw_channel* result = key_raw_channel::create<md3_key>( (uint32)md3->header.num_frames ); 289 289 // TODO: is this brain damaged in efficiency (loop nest order) or what? 290 290 for ( sint32 f = 0; f < md3->header.num_frames; ++f ) … … 322 322 { 323 323 mesh_data* data = new mesh_data; 324 release_mesh_frame( data, -1, index );324 release_mesh_frame( data, -1, (sint32)index ); 325 325 return data; 326 326 } … … 329 329 { 330 330 md3_t* md3 = (md3_t*)m_md3; 331 sint32 num_surfaces =md3->header.num_surfaces;332 sint32 num_verts = 0;333 sint32 current_frame = ( frame == -1 ? 0 :frame );334 sint32 frame_count = ( frame == -1 ?md3->header.num_frames : 1 );335 sint32 current_surf = ( surface == -1 ? 0 :surface );336 sint32 surf_count = ( surface == -1 ?md3->header.num_surfaces : 1 );337 sint32 index_count = 0;331 uint32 num_surfaces = (uint32)md3->header.num_surfaces; 332 uint32 num_verts = 0; 333 uint32 current_frame = ( frame == -1 ? 0 : (uint32)frame ); 334 uint32 frame_count = ( frame == -1 ? (uint32)md3->header.num_frames : 1 ); 335 uint32 current_surf = ( surface == -1 ? 0 : (uint32)surface ); 336 uint32 surf_count = ( surface == -1 ? (uint32)md3->header.num_surfaces : 1 ); 337 uint32 index_count = 0; 338 338 339 339 if ( surface >= 0 ) 340 340 { 341 index_count = md3->surfaces[surface].header.num_triangles * 3;342 num_verts = md3->surfaces[surface].header.num_verts;341 index_count = (uint32)md3->surfaces[(uint32)surface].header.num_triangles * 3; 342 num_verts = (uint32)md3->surfaces[(uint32)surface].header.num_verts; 343 343 } 344 344 else 345 for ( sint32 i = 0; i < num_surfaces; ++i )346 { 347 index_count += md3->surfaces[i].header.num_triangles * 3;348 num_verts += md3->surfaces[i].header.num_verts;345 for ( uint32 i = 0; i < num_surfaces; ++i ) 346 { 347 index_count += (uint32)md3->surfaces[i].header.num_triangles * 3; 348 num_verts += (uint32)md3->surfaces[i].header.num_verts; 349 349 } 350 350 … … 362 362 while ( surf_count > 0 ) 363 363 { 364 const md3_surface_t& s urface= md3->surfaces[ current_surf ];365 const uint32 vcount = static_cast< uint32 >( surface.header.num_verts );366 const uint32 tcount = static_cast< uint32 >( surface.header.num_triangles );364 const md3_surface_t& sface = md3->surfaces[ current_surf ]; 365 const uint32 vcount = static_cast< uint32 >( sface.header.num_verts ); 366 const uint32 tcount = static_cast< uint32 >( sface.header.num_triangles ); 367 367 368 368 for (uint32 j = 0; j < vcount; ++j ) 369 369 { 370 vtx_t[index++].texcoord = md3_texcoord( s urface.st[j] );370 vtx_t[index++].texcoord = md3_texcoord( sface.st[j] ); 371 371 } 372 372 373 373 for (size_t j = 0; j < tcount; ++j ) 374 374 { 375 const md3_triangle_t& t = s urface.triangles[j];375 const md3_triangle_t& t = sface.triangles[j]; 376 376 icp[iindex++] = static_cast< uint16 >( index_base + t.indexes[0] ); 377 377 icp[iindex++] = static_cast< uint16 >( index_base + t.indexes[1] ); 378 378 icp[iindex++] = static_cast< uint16 >( index_base + t.indexes[2] ); 379 379 } 380 index_base += s urface.header.num_verts;380 index_base += sface.header.num_verts; 381 381 ++current_surf; 382 382 --surf_count; … … 386 386 while ( frame_count > 0 ) 387 387 { 388 current_surf = ( surface == -1 ? 0 : surface );389 surf_count = ( surface == -1 ? md3->header.num_surfaces : 1 );388 current_surf = ( surface == -1 ? 0 : (uint32)surface ); 389 surf_count = ( surface == -1 ? (uint32)md3->header.num_surfaces : 1 ); 390 390 391 391 while ( surf_count > 0 ) 392 392 { 393 md3_surface_t& s urface= md3->surfaces[current_surf];394 sint32 vcount = surface.header.num_verts;395 sint32 offset= vcount * current_frame;396 sint32 limit= vcount + offset;397 for ( sint32 j = offset; j < limit; ++j )393 md3_surface_t& sface = md3->surfaces[current_surf]; 394 uint32 vcount = (uint32)sface.header.num_verts; 395 uint32 offset = vcount * current_frame; 396 uint32 limit = vcount + offset; 397 for (uint32 j = offset; j < limit; ++j ) 398 398 { 399 md3_vertex_t& v = s urface.vertices[j];399 md3_vertex_t& v = sface.vertices[j]; 400 400 vtx_pn[index].position = vec3( v.x * MD3_XYZ_SCALE, v.z * MD3_XYZ_SCALE, v.y * MD3_XYZ_SCALE ); 401 401 vtx_pn[index].normal = s_normal_cache[ v.normal ]; … … 418 418 { 419 419 md3_t* md3 = (md3_t*)m_md3; 420 uint32 node_count = md3->header.num_tags;420 uint32 node_count = (uint32)md3->header.num_tags; 421 421 if ( node_count == 0 ) return nullptr;; 422 422 mesh_node_data* nodes = new mesh_node_data[ node_count ]; … … 451 451 else 452 452 { 453 count = md3->header.num_surfaces;453 count = (uint32)md3->header.num_surfaces; 454 454 data = new mesh_data[ count ]; 455 455 for ( uint32 i = 0; i < count; ++i ) 456 456 { 457 release_mesh_frame( &data[i], -1, i );457 release_mesh_frame( &data[i], -1, (sint32)i ); 458 458 data[i].set_name( (char*)md3->surfaces[i].header.name ); 459 459 }
Note: See TracChangeset
for help on using the changeset viewer.