Changeset 323 for trunk/src/formats
- Timestamp:
- 08/26/14 04:03:10 (11 years ago)
- Location:
- trunk/src/formats
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/assimp_loader.cc
r302 r323 14 14 using namespace nv; 15 15 16 const intMAX_BONES = 64;16 const unsigned MAX_BONES = 64; 17 17 18 18 struct assimp_plain_vtx … … 90 90 m_mesh_count = 0; 91 91 NV_LOG( nv::LOG_NOTICE, "AssImp loading file..." ); 92 int size = (int)source.size();92 size_t size = source.size(); 93 93 char* data = new char[ size ]; 94 94 source.read( data, size, 1 ); … … 159 159 if ( v.boneweight[i] <= 0.0f ) 160 160 { 161 v.boneindex[i] =m;161 v.boneindex[i] = (int)m; 162 162 v.boneweight[i] = bone->mWeights[w].mWeight; 163 163 found = true; … … 289 289 for ( unsigned int m = 0; m < m_mesh_count; ++m ) 290 290 { 291 sint16 translate[MAX_BONES];291 uint16 translate[MAX_BONES]; 292 292 std::vector< mesh_node_data > bones; 293 293 const aiMesh* mesh = scene->mMeshes[ m ]; … … 304 304 { 305 305 NV_ASSERT( final_bones.size() < MAX_BONES, "Too many bones to merge!" ); 306 sint16 index = (sint16)final_bones.size();306 uint16 index = (uint16)final_bones.size(); 307 307 final_bones.push_back( bone ); 308 308 names[ bone.name ] = index; … … 311 311 else 312 312 { 313 translate[b] = (sint16)iname->second;313 translate[b] = iname->second; 314 314 } 315 315 } … … 326 326 if ( vertex.boneweight[i] > 0.0f ) 327 327 { 328 vertex.boneindex[i] = translate[vertex.boneindex[i]];328 vertex.boneindex[i] = (int)translate[vertex.boneindex[i]]; 329 329 } 330 330 } -
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 } -
trunk/src/formats/md5_loader.cc
r319 r323 135 135 mesh_data* mesh = new mesh_data("md5_mesh"); 136 136 137 intnum_verts = 0;138 intnum_tris = 0;139 intnum_weights = 0;137 uint32 num_verts = 0; 138 uint32 num_tris = 0; 139 uint32 num_weights = 0; 140 140 141 141 discard( sstream, "{" ); … … 170 170 next_line( sstream ); 171 171 std::string line; 172 for ( inti = 0; i < num_verts; ++i )172 for ( uint32 i = 0; i < num_verts; ++i ) 173 173 { 174 174 size_t weight_count; … … 194 194 next_line( sstream ); 195 195 std::string line; 196 for ( inti = 0; i < num_tris; ++i )196 for ( uint32 i = 0; i < num_tris; ++i ) 197 197 { 198 198 size_t ti0; … … 214 214 next_line( sstream ); 215 215 std::string line; 216 for ( inti = 0; i < num_weights; ++i )216 for ( uint32 i = 0; i < num_weights; ++i ) 217 217 { 218 218 md5_weight weight; … … 368 368 if ( j < weight_count ) 369 369 { 370 vdata.boneindex[j] = weights[start_weight + j].joint_id;370 vdata.boneindex[j] = (int)weights[start_weight + j].joint_id; 371 371 vdata.boneweight[j] = weights[start_weight + j].bias; 372 372 } -
trunk/src/formats/nmd_loader.cc
r319 r323 242 242 243 243 nmd_node_header nheader; 244 nheader.parent_id = (uint16)node->parent_id;244 nheader.parent_id = node->parent_id; 245 245 nheader.transform = node->transform; 246 246 stream_out.write( &nheader, sizeof( nheader ), 1 );
Note: See TracChangeset
for help on using the changeset viewer.