Changeset 406 for trunk/src/formats
- Timestamp:
- 06/20/15 00:05:17 (10 years ago)
- Location:
- trunk/src/formats
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/assimp_loader.cc
r399 r406 84 84 { 85 85 load_assimp_library(); 86 if ( m_scene != nullptr ) aiReleaseImport( (const aiScene*)m_scene);86 if ( m_scene != nullptr ) aiReleaseImport( reinterpret_cast<const aiScene*>( m_scene ) ); 87 87 m_scene = nullptr; 88 88 m_mesh_count = 0; … … 113 113 void nv::assimp_loader::load_mesh_data( mesh_data* data, size_t index ) 114 114 { 115 const aiScene* scene = (const aiScene*)m_scene;115 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 116 116 const aiMesh* mesh = scene->mMeshes[ index ]; 117 117 data->set_name( mesh->mName.data ); … … 139 139 nv::vec4 vt ( t_i[0], t_i[1], t_i[2], det ); 140 140 if ( skinned ) 141 ((assimp_skinned_vtx*)channel->data)[i] = assimp_skinned_vtx( v, s, n, vt );141 reinterpret_cast< assimp_skinned_vtx* >(channel->data)[i] = assimp_skinned_vtx( v, s, n, vt ); 142 142 else 143 ((assimp_plain_vtx*)channel->data)[i] = assimp_plain_vtx( v, s, n, vt );143 reinterpret_cast< assimp_plain_vtx* >(channel->data)[i] = assimp_plain_vtx( v, s, n, vt ); 144 144 } 145 145 146 146 if ( skinned ) 147 147 { 148 assimp_skinned_vtx* vtx = (assimp_skinned_vtx*)channel->data;148 assimp_skinned_vtx* vtx = reinterpret_cast< assimp_skinned_vtx* >( channel->data ); 149 149 for (unsigned int m=0; m<mesh->mNumBones; m++) 150 150 { … … 154 154 assimp_skinned_vtx& v = vtx[ bone->mWeights[w].mVertexId ]; 155 155 bool found = false; 156 for ( nv::uint32 i = 0 ; i < 4; ++i)156 for ( int i = 0 ; i < 4; ++i ) 157 157 { 158 158 if ( v.boneweight[i] <= 0.0f ) 159 159 { 160 v.boneindex[i] = (int)m;160 v.boneindex[i] = int( m ); 161 161 v.boneweight[i] = bone->mWeights[w].mWeight; 162 162 found = true; … … 171 171 mesh_raw_channel* ichannel = mesh_raw_channel::create_index( USHORT, mesh->mNumFaces * 3 ); 172 172 data->add_channel( ichannel ); 173 uint16* indices = (uint16*)ichannel->data;173 uint16* indices = reinterpret_cast<uint16*>( ichannel->data ); 174 174 for (unsigned int i=0; i<mesh->mNumFaces; i++) 175 175 { … … 177 177 for (unsigned int j=0; j<face->mNumIndices; j++) 178 178 { 179 indices[ i*3 + j ] = (uint16)face->mIndices[j];179 indices[ i*3 + j ] = uint16( face->mIndices[j] ); 180 180 } 181 181 } … … 184 184 nv::assimp_loader::~assimp_loader() 185 185 { 186 if ( m_scene != nullptr ) aiReleaseImport( (const aiScene*)m_scene);186 if ( m_scene != nullptr ) aiReleaseImport( reinterpret_cast<const aiScene*>( m_scene ) ); 187 187 } 188 188 … … 190 190 { 191 191 if ( m_scene == nullptr ) return false; 192 const aiScene* scene = (const aiScene*)m_scene;192 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 193 193 const aiMesh* mesh = scene->mMeshes[ index ]; 194 194 … … 208 208 void nv::assimp_loader::scene_report() const 209 209 { 210 const aiScene* scene = (const aiScene*)m_scene;210 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 211 211 if ( scene == nullptr ) return; 212 212 … … 237 237 aiMesh* mesh = scene->mMeshes[mc]; 238 238 239 NV_LOG_NOTICE( "Mesh #", mc, " - ", string_view( (char*)mesh->mName.data) );239 NV_LOG_NOTICE( "Mesh #", mc, " - ", string_view( static_cast<char*>( mesh->mName.data ) ) ); 240 240 NV_LOG_NOTICE( " bones - ", mesh->mNumBones ); 241 241 NV_LOG_NOTICE( " uvs - ", mesh->mNumUVComponents[0] ); … … 283 283 mesh_nodes_data* nv::assimp_loader::release_merged_bones( mesh_data* meshes ) 284 284 { 285 const aiScene* scene = (const aiScene*)m_scene;285 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 286 286 vector< mesh_node_data > final_bones; 287 287 unordered_map< std::string, uint16 > names; … … 303 303 { 304 304 NV_ASSERT( final_bones.size() < MAX_BONES, "Too many bones to merge!" ); 305 uint16 index = (uint16)final_bones.size();305 uint16 index = uint16( final_bones.size() ); 306 306 final_bones.push_back( bone ); 307 307 names[ bone.name ] = index; … … 316 316 { 317 317 mesh_raw_channel* channel = meshes[m].get_raw_channels()[0]; 318 assimp_skinned_vtx* va = (assimp_skinned_vtx*)channel->data;318 assimp_skinned_vtx* va = reinterpret_cast< assimp_skinned_vtx* >( channel->data ); 319 319 for ( unsigned v = 0; v < channel->count; ++v ) 320 320 { 321 321 assimp_skinned_vtx& vertex = va[v]; 322 322 323 for ( uint32i = 0 ; i < 4; ++i)323 for ( int i = 0 ; i < 4; ++i) 324 324 { 325 325 if ( vertex.boneweight[i] > 0.0f ) 326 326 { 327 vertex.boneindex[i] = (int)translate[vertex.boneindex[i]];327 vertex.boneindex[i] = int( translate[vertex.boneindex[i]] ); 328 328 } 329 329 } … … 340 340 { 341 341 if ( m_scene == nullptr ) return nullptr; 342 const aiScene* scene = (const aiScene*)m_scene;342 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 343 343 if ( scene->mRootNode == nullptr || scene->mAnimations == nullptr || scene->mAnimations[index] == nullptr) return nullptr; 344 344 … … 349 349 mesh_node_data* data = new mesh_node_data[count]; 350 350 351 uint16 frame_rate = (uint16)anim->mTicksPerSecond;352 float duration = (float)anim->mDuration;351 uint16 frame_rate = static_cast<uint16>( anim->mTicksPerSecond ); 352 float duration = static_cast<float>( anim->mDuration ); 353 353 bool flat = false; 354 354 … … 360 360 nv::uint32 nv::assimp_loader::count_nodes( const void* node ) const 361 361 { 362 const aiNode* ainode = (const aiNode*)node;362 const aiNode* ainode = reinterpret_cast< const aiNode* >( node ); 363 363 nv::uint32 count = 1; 364 364 for ( unsigned i = 0; i < ainode->mNumChildren; ++i ) … … 371 371 nv::sint16 nv::assimp_loader::load_node( uint32 anim_id, mesh_node_data* nodes, const void* vnode, sint16 this_id, sint16 parent_id ) 372 372 { 373 const aiScene* scene = (const aiScene*)m_scene;374 const aiNode* node = (const aiNode*)vnode;373 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 374 const aiNode* node = reinterpret_cast<const aiNode*>( vnode ); 375 375 std::string name( node->mName.data ); 376 376 const aiAnimation* anim = scene->mAnimations[anim_id]; … … 411 411 void nv::assimp_loader::create_keys( mesh_node_data* data, const void* vnode ) 412 412 { 413 const aiNodeAnim* node = (const aiNodeAnim*)vnode;413 const aiNodeAnim* node = reinterpret_cast< const aiNodeAnim* >( vnode ); 414 414 if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 ) 415 415 { … … 424 424 data->data->add_channel( raw_rchannel ); 425 425 //data->data->add_channel( raw_schannel ); 426 assimp_key_p* pchannel = ((assimp_key_p*)(raw_pchannel->data));427 assimp_key_r* rchannel = ((assimp_key_r*)(raw_rchannel->data));426 assimp_key_p* pchannel = reinterpret_cast< assimp_key_p* >( raw_pchannel->data ); 427 assimp_key_r* rchannel = reinterpret_cast< assimp_key_r* >( raw_rchannel->data ); 428 428 //assimp_key_s* schannel = ((assimp_key_s*)(raw_schannel->data)); 429 429 430 430 for ( unsigned np = 0; np < node->mNumPositionKeys; ++np ) 431 431 { 432 pchannel[np].time = (float)node->mPositionKeys[np].mTime;432 pchannel[np].time = static_cast<float>( node->mPositionKeys[np].mTime ); 433 433 pchannel[np].position = assimp_vec3_cast(node->mPositionKeys[np].mValue); 434 434 } 435 435 for ( unsigned np = 0; np < node->mNumRotationKeys; ++np ) 436 436 { 437 rchannel[np].time = (float)node->mRotationKeys[np].mTime;437 rchannel[np].time = static_cast<float>( node->mRotationKeys[np].mTime ); 438 438 rchannel[np].rotation = assimp_quat_cast(node->mRotationKeys[np].mValue ); 439 439 } … … 463 463 { 464 464 if ( m_scene == nullptr || m_mesh_count == 0 ) return nullptr; 465 const aiScene* scene = (const aiScene*)m_scene;465 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 466 466 bool has_bones = false; 467 467 mesh_data* meshes = new mesh_data[ m_mesh_count ]; … … 481 481 { 482 482 if ( m_scene == nullptr ) return 0; 483 const aiScene* scene = (const aiScene*)m_scene;483 const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene ); 484 484 return scene->mNumAnimations; 485 485 } -
trunk/src/formats/md2_loader.cc
r395 r406 192 192 // return vec3( v[0], v[1], v[2] ); 193 193 return vec3( v[0], v[2], v[1] ); 194 }195 196 static inline vec3 md2_normal( uint8 normal )197 {198 return md2_vec3( md2_normal_table[normal] );199 194 } 200 195 … … 220 215 md2_loader::~md2_loader() 221 216 { 222 if (m_md2 != nullptr) 223 { 224 free_md2( (md2_t*)(m_md2) ); 225 delete (md2_t*)m_md2; 217 md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 ); 218 if ( md2 != nullptr) 219 { 220 free_md2( md2 ); 221 delete md2; 226 222 } 227 223 } … … 229 225 bool md2_loader::load( stream& source ) 230 226 { 231 m_md2 = (void*)(new md2_t); 232 if ( !read_md2( (md2_t*)m_md2, source ) ) 227 md2_t* md2 = new md2_t; 228 m_md2 = md2; 229 if ( !read_md2( md2, source ) ) 233 230 { 234 231 return false; … … 240 237 nv::size_t md2_loader::get_max_frames() const 241 238 { 242 return static_cast< size_t >( ((md2_t*)m_md2)->header.num_frames );239 return static_cast<size_t>( reinterpret_cast<md2_t*>( m_md2 )->header.num_frames ); 243 240 } 244 241 245 242 void nv::md2_loader::reindex() 246 243 { 247 md2_t* md2 = (md2_t*)m_md2;244 md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 ); 248 245 uint32 num_indexes = static_cast< uint32 >( md2->header.num_tris * 3 ); 249 246 … … 321 318 void nv::md2_loader::release_mesh_frame( mesh_data* data, sint32 frame ) 322 319 { 323 md2_t* md2 = (md2_t*)m_md2;320 md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 ); 324 321 size_t num_frames = static_cast< size_t >( md2->header.num_frames ); 325 322 size_t num_verts = m_new_vindexes.size(); … … 328 325 329 326 mesh_raw_channel* mc_pn = mesh_raw_channel::create< vtx_md2_pn >( num_verts * frame_count ); 330 vtx_md2_pn* vtx_pn = (vtx_md2_pn*)mc_pn->data;327 vtx_md2_pn* vtx_pn = reinterpret_cast< vtx_md2_pn* >( mc_pn->data ); 331 328 332 329 uint32 index = 0; … … 351 348 352 349 mesh_raw_channel* mc_t = mesh_raw_channel::create< vtx_md2_t >( num_verts ); 353 vtx_md2_t* vtx_t = (vtx_md2_t*)mc_t->data;354 355 vec2 scale( 1.0f / (float) md2->header.skinwidth, 1.0f / (float) md2->header.skinheight);350 vtx_md2_t* vtx_t = reinterpret_cast< vtx_md2_t* >( mc_t->data ); 351 352 vec2 scale( 1.0f / static_cast<float>( md2->header.skinwidth ), 1.0f / static_cast<float>( md2->header.skinheight ) ); 356 353 for (size_t i = 0; i < num_verts; ++i ) 357 354 { … … 363 360 if ( m_new_indexes.size() > 0 ) 364 361 { 365 uint16* icp = (uint16*)ic->data;362 uint16* icp = reinterpret_cast< uint16* >( ic->data ); 366 363 raw_copy_n( m_new_indexes.data(), m_new_indexes.size(), icp ); 367 364 } -
trunk/src/formats/md3_loader.cc
r399 r406 267 267 nv::md3_loader::~md3_loader() 268 268 { 269 if (m_md3 != nullptr) 270 { 271 free_md3( (md3_t*)(m_md3) ); 272 delete (md3_t*)m_md3; 269 md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 ); 270 if ( md3 != nullptr ) 271 { 272 free_md3( md3 ); 273 delete md3; 273 274 } 274 275 } … … 276 277 bool nv::md3_loader::load( stream& source ) 277 278 { 278 m_md3 = (void*)(new md3_t); 279 if ( !read_md3( (md3_t*)m_md3, source ) ) 279 md3_t* md3 = new md3_t; 280 m_md3 = md3; 281 if ( !read_md3( md3, source ) ) 280 282 { 281 283 return false; … … 286 288 nv::key_raw_channel* nv::md3_loader::load_tags( const string_view& tag ) 287 289 { 288 md3_t* md3 = (md3_t*)m_md3;289 key_raw_channel* result = key_raw_channel::create<md3_key>( (uint32)md3->header.num_frames);290 md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 ); 291 key_raw_channel* result = key_raw_channel::create<md3_key>( uint32( md3->header.num_frames ) ); 290 292 // TODO: is this brain damaged in efficiency (loop nest order) or what? 291 293 for ( sint32 f = 0; f < md3->header.num_frames; ++f ) … … 294 296 { 295 297 const md3_tag_t& rtag = md3->tags[i + md3->header.num_tags * f]; 296 string_view rname( (char*)(rtag.name));298 string_view rname( reinterpret_cast< const char* >(rtag.name) ); 297 299 if (rname == tag) 298 300 { … … 301 303 vec3 axisy ( md3_vec3( rtag.axis[2] ) ); 302 304 vec3 origin ( md3_vec3( rtag.origin ) ); 303 ((md3_key*)(result->data))[f].tform = transform( origin, quat( mat3( axisx, axisy, axisz ) ) );305 reinterpret_cast< md3_key*>(result->data)[f].tform = transform( origin, quat( mat3( axisx, axisy, axisz ) ) ); 304 306 } 305 307 } … … 323 325 { 324 326 mesh_data* data = new mesh_data; 325 release_mesh_frame( data, -1, (sint32)index);327 release_mesh_frame( data, -1, static_cast< sint32 >( index ) ); 326 328 return data; 327 329 } … … 329 331 void nv::md3_loader::release_mesh_frame( mesh_data* data, sint32 frame, sint32 surface ) 330 332 { 331 md3_t* md3 = (md3_t*)m_md3;332 uint32 num_surfaces = (uint32)md3->header.num_surfaces;333 uint32 num_verts = 0;334 uint32 current_frame = ( frame == -1 ? 0 : (uint32)frame );335 uint32 frame_count = ( frame == -1 ? (uint32)md3->header.num_frames : 1 );336 uint32 current_surf = ( surface == -1 ? 0 : (uint32)surface );337 uint32 surf_count = ( surface == -1 ? (uint32)md3->header.num_surfaces : 1 );338 uint32 index_count = 0;333 md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 ); 334 sint32 num_surfaces = md3->header.num_surfaces; 335 sint32 num_verts = 0; 336 sint32 current_frame = ( frame == -1 ? 0 : frame ); 337 sint32 frame_count = ( frame == -1 ? md3->header.num_frames : 1 ); 338 sint32 current_surf = ( surface == -1 ? 0 : surface ); 339 sint32 surf_count = ( surface == -1 ? md3->header.num_surfaces : 1 ); 340 sint32 index_count = 0; 339 341 340 342 if ( surface >= 0 ) 341 343 { 342 index_count = (uint32)md3->surfaces[(uint32)surface].header.num_triangles * 3;343 num_verts = (uint32)md3->surfaces[(uint32)surface].header.num_verts;344 index_count = md3->surfaces[surface].header.num_triangles * 3; 345 num_verts = md3->surfaces[surface].header.num_verts; 344 346 } 345 347 else 346 for ( uint32 i = 0; i < num_surfaces; ++i )347 { 348 index_count += (uint32)md3->surfaces[i].header.num_triangles * 3;349 num_verts += (uint32)md3->surfaces[i].header.num_verts;350 } 351 352 mesh_raw_channel* mc_pn = mesh_raw_channel::create< vtx_md3_pn >( num_verts * frame_count);353 mesh_raw_channel* mc_t = mesh_raw_channel::create< vtx_md3_t >( num_verts);354 mesh_raw_channel* ic = mesh_raw_channel::create_index< uint16 >( index_count);355 vtx_md3_pn* vtx_pn = (vtx_md3_pn*)mc_pn->data;356 vtx_md3_t* vtx_t = (vtx_md3_t*) mc_t->data;357 uint16* icp = (uint16*)ic->data;348 for ( sint32 i = 0; i < num_surfaces; ++i ) 349 { 350 index_count += md3->surfaces[i].header.num_triangles * 3; 351 num_verts += md3->surfaces[i].header.num_verts; 352 } 353 354 mesh_raw_channel* mc_pn = mesh_raw_channel::create< vtx_md3_pn >( uint32( num_verts * frame_count ) ); 355 mesh_raw_channel* mc_t = mesh_raw_channel::create< vtx_md3_t >( uint32( num_verts ) ); 356 mesh_raw_channel* ic = mesh_raw_channel::create_index< uint16 >( uint32( index_count ) ); 357 vtx_md3_pn* vtx_pn = reinterpret_cast< vtx_md3_pn* >( mc_pn->data ); 358 vtx_md3_t* vtx_t = reinterpret_cast< vtx_md3_t* >( mc_t->data ); 359 uint16* icp = reinterpret_cast< uint16* >( ic->data ); 358 360 359 361 uint32 index = 0; … … 387 389 while ( frame_count > 0 ) 388 390 { 389 current_surf = ( surface == -1 ? 0 : (uint32)surface );390 surf_count = ( surface == -1 ? (uint32)md3->header.num_surfaces : 1 );391 current_surf = ( surface == -1 ? 0 : surface ); 392 surf_count = ( surface == -1 ? md3->header.num_surfaces : 1 ); 391 393 392 394 while ( surf_count > 0 ) 393 395 { 394 396 md3_surface_t& sface = md3->surfaces[current_surf]; 395 uint32 vcount = (uint32)sface.header.num_verts;396 uint32offset = vcount * current_frame;397 uint32limit = vcount + offset;398 for ( uint32 j = offset; j < limit; ++j )397 sint32 vcount = sface.header.num_verts; 398 sint32 offset = vcount * current_frame; 399 sint32 limit = vcount + offset; 400 for ( sint32 j = offset; j < limit; ++j ) 399 401 { 400 402 md3_vertex_t& v = sface.vertices[j]; … … 410 412 } 411 413 412 data->set_name( (char*)md3->header.name);414 data->set_name( reinterpret_cast< char* >( md3->header.name ) ); 413 415 data->add_channel( mc_pn ); 414 416 data->add_channel( mc_t ); … … 418 420 mesh_nodes_data* nv::md3_loader::release_mesh_nodes_data( nv::size_t ) 419 421 { 420 md3_t* md3 = (md3_t*)m_md3;421 uint32 node_count = (uint32)md3->header.num_tags;422 md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 ); 423 uint32 node_count = uint32( md3->header.num_tags ); 422 424 if ( node_count == 0 ) return nullptr; 423 425 mesh_node_data* nodes = new mesh_node_data[ node_count ]; … … 425 427 { 426 428 const md3_tag_t& rtag = md3->tags[i]; 427 string_view name( (char*)(rtag.name) );429 string_view name( reinterpret_cast< const char* >(rtag.name) ); 428 430 429 431 nodes[i].transform = mat4(); … … 441 443 mesh_data_pack* nv::md3_loader::release_mesh_data_pack() 442 444 { 443 md3_t* md3 = (md3_t*)m_md3;444 uint32count = 1;445 md3_t* md3 = reinterpret_cast<md3_t*>( m_md3 ); 446 int count = 1; 445 447 mesh_data* data = nullptr; 446 448 if ( m_merge_all ) … … 448 450 data = new mesh_data[1]; 449 451 release_mesh_frame( &data[0], -1, -1 ); 450 data[0].set_name( (char*)md3->header.name);452 data[0].set_name( reinterpret_cast< char* >( md3->header.name ) ); 451 453 } 452 454 else 453 455 { 454 count = (uint32)md3->header.num_surfaces;456 count = md3->header.num_surfaces; 455 457 data = new mesh_data[ count ]; 456 for ( uint32i = 0; i < count; ++i )457 { 458 release_mesh_frame( &data[i], -1, (sint32)i );459 data[i].set_name( (char*)md3->surfaces[i].header.name);460 } 461 } 462 return new mesh_data_pack( count, data, release_mesh_nodes_data() );458 for ( int i = 0; i < count; ++i ) 459 { 460 release_mesh_frame( &data[i], -1, i ); 461 data[i].set_name( reinterpret_cast< char* >( md3->surfaces[i].header.name ) ); 462 } 463 } 464 return new mesh_data_pack( uint32( count ), data, release_mesh_nodes_data() ); 463 465 } 464 466 465 467 nv::size_t md3_loader::get_max_frames() const 466 468 { 467 return static_cast< size_t >( ((md3_t*)m_md3)->header.num_frames );468 } 469 return static_cast<size_t>( reinterpret_cast<md3_t*>( m_md3 )->header.num_frames ); 470 } -
trunk/src/formats/md5_loader.cc
r401 r406 162 162 mesh_raw_channel* ch_t = mesh_raw_channel::create<md5_vtx_t>( num_verts ); 163 163 mesh_raw_channel* ch_pntiw = mesh_raw_channel::create<md5_vtx_pntiw>( num_verts ); 164 tdata = (md5_vtx_t*)ch_t->data;164 tdata = reinterpret_cast< md5_vtx_t* >( ch_t->data ); 165 165 mesh->add_channel( ch_pnt ); 166 166 mesh->add_channel( ch_t ); … … 191 191 192 192 mesh_raw_channel* ch_i = mesh_raw_channel::create_index<uint32>( num_tris * 3 ); 193 uint32* vtx_i = (uint32*)ch_i->data;193 uint32* vtx_i = reinterpret_cast< uint32* >( ch_i->data ); 194 194 uint32 idx = 0; 195 195 mesh->add_channel( ch_i ); … … 199 199 for ( uint32 i = 0; i < num_tris; ++i ) 200 200 { 201 size_tti0;202 size_tti1;203 size_tti2;201 unsigned ti0; 202 unsigned ti1; 203 unsigned ti2; 204 204 205 205 std::getline( sstream, line ); 206 206 sscanf( line.c_str(), "%*s %*u %u %u %u )", &(ti0), &(ti1), &(ti2)); 207 207 208 vtx_i[idx++] = (uint32)ti0;209 vtx_i[idx++] = (uint32)ti1;210 vtx_i[idx++] = (uint32)ti2;208 vtx_i[idx++] = ti0; 209 vtx_i[idx++] = ti1; 210 vtx_i[idx++] = ti2; 211 211 } 212 212 } … … 244 244 assert( nodes == nullptr ); 245 245 nodes = new mesh_node_data[ num_joints ]; 246 m_nodes = new mesh_nodes_data( "md5_animation", num_joints, nodes, (nv::uint16)frame_rate, (float)num_frames, true );246 m_nodes = new mesh_nodes_data( "md5_animation", num_joints, nodes, static_cast< nv::uint16 >( frame_rate ), static_cast< float >( num_frames ), true ); 247 247 joint_infos.resize( num_joints ); 248 248 … … 318 318 { 319 319 sstream >> buf; 320 frame.push_back( (float)atof(buf));320 frame.push_back( static_cast< float >( atof(buf) ) ); 321 321 } 322 322 … … 336 336 { 337 337 assert( m_type == MESH ); 338 md5_vtx_pnt* vtcs = (md5_vtx_pnt*)mdata->get_channel< md5_vtx_pnt >()->data;339 md5_vtx_pntiw* vtx_data = (md5_vtx_pntiw*)mdata->get_channel< md5_vtx_pntiw >()->data;338 md5_vtx_pnt* vtcs = reinterpret_cast< md5_vtx_pnt* >( mdata->get_channel< md5_vtx_pnt >()->data ); 339 md5_vtx_pntiw* vtx_data = reinterpret_cast< md5_vtx_pntiw* >( mdata->get_channel< md5_vtx_pntiw >()->data ); 340 340 341 341 for ( uint32 i = 0; i < vtx_count; ++i ) … … 368 368 } 369 369 370 for ( size_t j = 0; j < 4; ++j )371 { 372 if ( j < weight_count)373 { 374 vdata.boneindex[j] = (int)weights[start_weight + j].joint_id;375 vdata.boneweight[j] = weights[ start_weight+ j].bias;370 for ( int j = 0; j < 4; ++j ) 371 { 372 if ( j < int(weight_count) ) 373 { 374 vdata.boneindex[j] = int( weights[int(start_weight) + j].joint_id ); 375 vdata.boneweight[j] = weights[int(start_weight) + j].bias; 376 376 } 377 377 else … … 396 396 } 397 397 398 const uint32* idata = (uint32*)mdata->get_index_channel()->data;398 const uint32* idata = reinterpret_cast< uint32* >( mdata->get_index_channel()->data ); 399 399 const md5_vtx_t* tdata = mdata->get_channel_data<md5_vtx_t>(); 400 400 … … 448 448 vdata.tangent = vec3(0); 449 449 450 for ( size_t j = 0; j < 4; ++j )450 for ( int j = 0; j < 4; ++j ) 451 451 { 452 452 const mesh_node_data& joint = nodes[vdata.boneindex[j]]; … … 484 484 { 485 485 const mesh_node_data& pjoint = nodes[parent_id]; 486 const transform* ptv = (const transform*)pjoint.data->get_channel(0)->data;486 const transform* ptv = reinterpret_cast< const transform* >( pjoint.data->get_channel(0)->data ); 487 487 transform ptr; 488 488 if ( pjoint.data->get_channel(0)->count > index ) ptr = ptv[ index ]; … … 495 495 } 496 496 497 ((transform*)joint.data->get_channel(0)->data)[index] = transform( pos, orient );497 reinterpret_cast< transform* >( joint.data->get_channel(0)->data )[index] = transform( pos, orient ); 498 498 } 499 499 } -
trunk/src/formats/nmd_loader.cc
r399 r406 174 174 eheader.type = nmd_type::MESH; 175 175 eheader.name = 0; 176 eheader.children = (uint16)data.size();176 eheader.children = static_cast< uint16 >( data.size() ); 177 177 eheader.size = size; 178 178 stream_out.write( &eheader, sizeof( eheader ), 1 ); … … 213 213 header.name = 0; 214 214 header.type = nmd_type::ANIMATION; 215 header.children = (uint16)nodes->get_count();215 header.children = static_cast< uint16 >( nodes->get_count() ); 216 216 header.size = total; 217 217 stream_out.write( &header, sizeof( header ), 1 ); … … 237 237 eheader.type = nmd_type::NODE; 238 238 eheader.name = strings->insert( node->name ); 239 eheader.children = (uint16)chan_count;239 eheader.children = static_cast< uint16 >( chan_count ); 240 240 eheader.size = sizeof( nmd_node_header ) + chan_size; 241 241 stream_out.write( &eheader, sizeof( eheader ), 1 ); -
trunk/src/formats/obj_loader.cc
r395 r406 207 207 virtual void reset() { m_data.clear(); } 208 208 virtual nv::size_t raw_size() const { return m_data.size() * sizeof( VTX ); } 209 virtual const uint8* raw_pointer() const { return (const uint8*)m_data.data(); }209 virtual const uint8* raw_pointer() const { return reinterpret_cast< const uint8* >( m_data.data() ); } 210 210 }; 211 211
Note: See TracChangeset
for help on using the changeset viewer.