Ignore:
Timestamp:
06/20/15 00:05:17 (10 years ago)
Author:
epyon
Message:
  • code compiles cleanly on maximum warning level
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/formats/assimp_loader.cc

    r399 r406  
    8484{
    8585        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 ) );
    8787        m_scene = nullptr;
    8888        m_mesh_count = 0;
     
    113113void nv::assimp_loader::load_mesh_data( mesh_data* data, size_t index )
    114114{
    115         const aiScene* scene = (const aiScene*)m_scene;
     115        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    116116        const aiMesh*  mesh  = scene->mMeshes[ index ];
    117117        data->set_name( mesh->mName.data );
     
    139139                nv::vec4 vt ( t_i[0], t_i[1], t_i[2], det );
    140140                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 );
    142142                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 );
    144144        }
    145145
    146146        if ( skinned )
    147147        {
    148                 assimp_skinned_vtx* vtx = (assimp_skinned_vtx*)channel->data;
     148                assimp_skinned_vtx* vtx = reinterpret_cast< assimp_skinned_vtx* >( channel->data );
    149149                for (unsigned int m=0; m<mesh->mNumBones; m++)
    150150                {
     
    154154                                assimp_skinned_vtx& v = vtx[ bone->mWeights[w].mVertexId ];
    155155                                bool found = false;
    156                                 for (nv::uint32 i = 0 ; i < 4; ++i)
     156                                for ( int i = 0 ; i < 4; ++i )
    157157                                {
    158158                                        if ( v.boneweight[i] <= 0.0f )
    159159                                        {
    160                                                 v.boneindex[i]  = (int)m;
     160                                                v.boneindex[i]  = int( m );
    161161                                                v.boneweight[i] = bone->mWeights[w].mWeight;
    162162                                                found = true;
     
    171171        mesh_raw_channel* ichannel = mesh_raw_channel::create_index( USHORT, mesh->mNumFaces * 3 );
    172172        data->add_channel( ichannel );
    173         uint16* indices = (uint16*)ichannel->data;
     173        uint16* indices = reinterpret_cast<uint16*>( ichannel->data );
    174174        for (unsigned int i=0; i<mesh->mNumFaces; i++)
    175175        {
     
    177177                for (unsigned int j=0; j<face->mNumIndices; j++)
    178178                {
    179                         indices[ i*3 + j ] = (uint16)face->mIndices[j];
     179                        indices[ i*3 + j ] = uint16( face->mIndices[j] );
    180180                }
    181181        }
     
    184184nv::assimp_loader::~assimp_loader()
    185185{
    186         if ( m_scene != nullptr ) aiReleaseImport( (const aiScene*)m_scene );
     186        if ( m_scene != nullptr ) aiReleaseImport( reinterpret_cast<const aiScene*>( m_scene ) );
    187187}
    188188
     
    190190{
    191191        if ( m_scene == nullptr ) return false;
    192         const aiScene* scene = (const aiScene*)m_scene;
     192        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    193193        const aiMesh*  mesh  = scene->mMeshes[ index ];
    194194
     
    208208void nv::assimp_loader::scene_report() const
    209209{
    210         const aiScene* scene = (const aiScene*)m_scene;
     210        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    211211        if ( scene == nullptr ) return;
    212212
     
    237237                        aiMesh* mesh = scene->mMeshes[mc];
    238238
    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 ) ) );
    240240                        NV_LOG_NOTICE( "  bones   - ", mesh->mNumBones );
    241241                        NV_LOG_NOTICE( "  uvs     - ", mesh->mNumUVComponents[0] );
     
    283283mesh_nodes_data* nv::assimp_loader::release_merged_bones( mesh_data* meshes )
    284284{
    285         const aiScene* scene = (const aiScene*)m_scene;
     285        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    286286        vector< mesh_node_data > final_bones;
    287287        unordered_map< std::string, uint16 > names;
     
    303303                                {
    304304                                        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() );
    306306                                        final_bones.push_back( bone );
    307307                                        names[ bone.name ] = index;
     
    316316                        {
    317317                                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 );
    319319                                for ( unsigned v = 0; v < channel->count; ++v )
    320320                                {
    321321                                        assimp_skinned_vtx& vertex = va[v];
    322322
    323                                         for (uint32 i = 0 ; i < 4; ++i)
     323                                        for ( int i = 0 ; i < 4; ++i)
    324324                                        {
    325325                                                if ( vertex.boneweight[i] > 0.0f )
    326326                                                {
    327                                                         vertex.boneindex[i] = (int)translate[vertex.boneindex[i]];
     327                                                        vertex.boneindex[i] = int( translate[vertex.boneindex[i]] );
    328328                                                }
    329329                                        }
     
    340340{
    341341        if ( m_scene == nullptr ) return nullptr;
    342         const aiScene* scene = (const aiScene*)m_scene;
     342        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    343343        if ( scene->mRootNode == nullptr || scene->mAnimations == nullptr || scene->mAnimations[index] == nullptr) return nullptr;
    344344
     
    349349        mesh_node_data* data    = new mesh_node_data[count];
    350350
    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 );
    353353        bool   flat           = false;
    354354
     
    360360nv::uint32 nv::assimp_loader::count_nodes( const void* node ) const
    361361{
    362         const aiNode* ainode = (const aiNode*)node;
     362        const aiNode* ainode = reinterpret_cast< const aiNode* >( node );
    363363        nv::uint32 count = 1;
    364364        for ( unsigned i = 0; i < ainode->mNumChildren; ++i )
     
    371371nv::sint16 nv::assimp_loader::load_node( uint32 anim_id, mesh_node_data* nodes, const void* vnode, sint16 this_id, sint16 parent_id )
    372372{
    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 );
    375375        std::string name( node->mName.data );
    376376        const aiAnimation* anim  = scene->mAnimations[anim_id];
     
    411411void nv::assimp_loader::create_keys( mesh_node_data* data, const void* vnode )
    412412{
    413         const aiNodeAnim* node = (const aiNodeAnim*)vnode;
     413        const aiNodeAnim* node = reinterpret_cast< const aiNodeAnim* >( vnode );
    414414        if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 )
    415415        {
     
    424424        data->data->add_channel( raw_rchannel );
    425425        //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 );
    428428        //assimp_key_s* schannel = ((assimp_key_s*)(raw_schannel->data));
    429429
    430430        for ( unsigned np = 0; np < node->mNumPositionKeys; ++np )
    431431        {
    432                 pchannel[np].time     = (float)node->mPositionKeys[np].mTime;
     432                pchannel[np].time     = static_cast<float>( node->mPositionKeys[np].mTime );
    433433                pchannel[np].position = assimp_vec3_cast(node->mPositionKeys[np].mValue);
    434434        }
    435435        for ( unsigned np = 0; np < node->mNumRotationKeys; ++np )
    436436        {
    437                 rchannel[np].time     = (float)node->mRotationKeys[np].mTime;
     437                rchannel[np].time     = static_cast<float>( node->mRotationKeys[np].mTime );
    438438                rchannel[np].rotation = assimp_quat_cast(node->mRotationKeys[np].mValue );
    439439        }
     
    463463{
    464464        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 );
    466466        bool has_bones = false;
    467467        mesh_data* meshes = new mesh_data[ m_mesh_count ];
     
    481481{
    482482        if ( m_scene == nullptr ) return 0;
    483         const aiScene* scene = (const aiScene*)m_scene;
     483        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    484484        return scene->mNumAnimations;   
    485485}
Note: See TracChangeset for help on using the changeset viewer.