Changeset 406 for trunk/src/formats/assimp_loader.cc
- Timestamp:
- 06/20/15 00:05:17 (10 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.