Changeset 406 for trunk/src/formats


Ignore:
Timestamp:
06/20/15 00:05:17 (10 years ago)
Author:
epyon
Message:
  • code compiles cleanly on maximum warning level
Location:
trunk/src/formats
Files:
6 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}
  • trunk/src/formats/md2_loader.cc

    r395 r406  
    192192        //      return vec3( v[0], v[1], v[2] );
    193193        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] );
    199194}
    200195
     
    220215md2_loader::~md2_loader()
    221216{
    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;
    226222        }
    227223}
     
    229225bool md2_loader::load( stream& source )
    230226{
    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 ) )
    233230        {
    234231                return false;
     
    240237nv::size_t md2_loader::get_max_frames() const
    241238{
    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 );
    243240}
    244241
    245242void nv::md2_loader::reindex()
    246243{
    247         md2_t* md2 = (md2_t*)m_md2;
     244        md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 );
    248245        uint32 num_indexes = static_cast< uint32 >( md2->header.num_tris * 3 );
    249246
     
    321318void nv::md2_loader::release_mesh_frame( mesh_data* data, sint32 frame )
    322319{
    323         md2_t* md2 = (md2_t*)m_md2;
     320        md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 );
    324321        size_t num_frames = static_cast< size_t >( md2->header.num_frames );
    325322        size_t num_verts  =     m_new_vindexes.size();
     
    328325
    329326        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 );
    331328
    332329        uint32 index = 0;
     
    351348
    352349        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 ) );
    356353        for (size_t i = 0; i < num_verts; ++i )
    357354        {
     
    363360        if ( m_new_indexes.size() > 0 )
    364361        {
    365                 uint16* icp = (uint16*)ic->data;
     362                uint16* icp = reinterpret_cast< uint16* >( ic->data );
    366363                raw_copy_n( m_new_indexes.data(), m_new_indexes.size(), icp );
    367364        }
  • trunk/src/formats/md3_loader.cc

    r399 r406  
    267267nv::md3_loader::~md3_loader()
    268268{
    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;
    273274        }
    274275}
     
    276277bool nv::md3_loader::load( stream& source )
    277278{
    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 ) )
    280282        {
    281283                return false;
     
    286288nv::key_raw_channel* nv::md3_loader::load_tags( const string_view& tag )
    287289{
    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 ) );
    290292        // TODO: is this brain damaged in efficiency (loop nest order) or what?
    291293        for ( sint32 f = 0; f < md3->header.num_frames; ++f )
     
    294296                {
    295297                        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) );
    297299                        if (rname == tag)
    298300                        {
     
    301303                                vec3 axisy  ( md3_vec3( rtag.axis[2] ) );
    302304                                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 ) ) );
    304306                        }
    305307                }
     
    323325{
    324326        mesh_data* data = new mesh_data;
    325         release_mesh_frame( data, -1, (sint32)index );
     327        release_mesh_frame( data, -1, static_cast< sint32 >( index ) );
    326328        return data;
    327329}
     
    329331void nv::md3_loader::release_mesh_frame( mesh_data* data, sint32 frame, sint32 surface )
    330332{
    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;
    339341
    340342        if ( surface >= 0 )
    341343        {
    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;
    344346        }
    345347        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 );
    358360
    359361        uint32 index  = 0;
     
    387389        while ( frame_count > 0 )
    388390        {
    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 );
    391393
    392394                while ( surf_count > 0 )
    393395                {
    394396                        md3_surface_t& sface  = md3->surfaces[current_surf];
    395                         uint32         vcount = (uint32)sface.header.num_verts;
    396                         uint32        offset = vcount * current_frame;
    397                         uint32        limit  = 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 )
    399401                        {
    400402                                md3_vertex_t& v = sface.vertices[j];
     
    410412        }
    411413
    412         data->set_name( (char*)md3->header.name );
     414        data->set_name( reinterpret_cast< char* >( md3->header.name ) );
    413415        data->add_channel( mc_pn );
    414416        data->add_channel( mc_t );
     
    418420mesh_nodes_data* nv::md3_loader::release_mesh_nodes_data( nv::size_t )
    419421{
    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 );
    422424        if ( node_count == 0 ) return nullptr;
    423425        mesh_node_data* nodes = new mesh_node_data[ node_count ];
     
    425427        {
    426428                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) );
    428430
    429431                nodes[i].transform = mat4();
     
    441443mesh_data_pack* nv::md3_loader::release_mesh_data_pack()
    442444{
    443         md3_t* md3 = (md3_t*)m_md3;
    444         uint32 count = 1;
     445        md3_t* md3 = reinterpret_cast<md3_t*>( m_md3 );
     446        int count = 1;
    445447        mesh_data* data = nullptr;
    446448        if ( m_merge_all )
     
    448450                data = new mesh_data[1];
    449451                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 ) );
    451453        }
    452454        else
    453455        {
    454                 count = (uint32)md3->header.num_surfaces;
     456                count = md3->header.num_surfaces;
    455457                data = new mesh_data[ count ];
    456                 for ( uint32 i = 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() );
    463465}
    464466
    465467nv::size_t md3_loader::get_max_frames() const
    466468{
    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  
    162162                                                mesh_raw_channel* ch_t   = mesh_raw_channel::create<md5_vtx_t>( num_verts );
    163163                                                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 );
    165165                                                mesh->add_channel( ch_pnt );
    166166                                                mesh->add_channel( ch_t );
     
    191191
    192192                                        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 );
    194194                                        uint32 idx = 0;
    195195                                        mesh->add_channel( ch_i );
     
    199199                                        for ( uint32 i = 0; i < num_tris; ++i )
    200200                                        {
    201                                                 size_t ti0;
    202                                                 size_t ti1;
    203                                                 size_t ti2;
     201                                                unsigned ti0;
     202                                                unsigned ti1;
     203                                                unsigned ti2;
    204204
    205205                                                std::getline( sstream, line );
    206206                                                sscanf( line.c_str(), "%*s %*u %u %u %u )", &(ti0), &(ti1), &(ti2));
    207207
    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;
    211211                                        }             
    212212                                }
     
    244244                        assert( nodes == nullptr );
    245245                        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 );
    247247                        joint_infos.resize( num_joints );
    248248
     
    318318                        {
    319319                                sstream >> buf;
    320                                 frame.push_back((float)atof(buf));
     320                                frame.push_back( static_cast< float >( atof(buf) ) );
    321321                        }
    322322
     
    336336{
    337337        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 );
    340340
    341341        for ( uint32 i = 0; i < vtx_count; ++i )
     
    368368                }
    369369
    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;
    376376                        }
    377377                        else
     
    396396        }
    397397
    398         const uint32*    idata = (uint32*)mdata->get_index_channel()->data;
     398        const uint32*    idata = reinterpret_cast< uint32* >( mdata->get_index_channel()->data );
    399399        const md5_vtx_t* tdata = mdata->get_channel_data<md5_vtx_t>();
    400400
     
    448448                vdata.tangent  = vec3(0);
    449449 
    450                 for ( size_t j = 0; j < 4; ++j )
     450                for ( int j = 0; j < 4; ++j )
    451451                {
    452452                        const mesh_node_data&  joint = nodes[vdata.boneindex[j]];
     
    484484                {
    485485                        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 );
    487487                        transform ptr;
    488488                        if ( pjoint.data->get_channel(0)->count > index ) ptr = ptv[ index ];
     
    495495                }
    496496
    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 );
    498498        }
    499499}
  • trunk/src/formats/nmd_loader.cc

    r399 r406  
    174174        eheader.type     = nmd_type::MESH;
    175175        eheader.name     = 0;
    176         eheader.children = (uint16)data.size();
     176        eheader.children = static_cast< uint16 >( data.size() );
    177177        eheader.size     = size;
    178178        stream_out.write( &eheader, sizeof( eheader ), 1 );
     
    213213        header.name     = 0;
    214214        header.type     = nmd_type::ANIMATION;
    215         header.children = (uint16)nodes->get_count();
     215        header.children = static_cast< uint16 >( nodes->get_count() );
    216216        header.size     = total;
    217217        stream_out.write( &header, sizeof( header ), 1 );
     
    237237                eheader.type     = nmd_type::NODE;
    238238                eheader.name     = strings->insert( node->name );
    239                 eheader.children = (uint16)chan_count;
     239                eheader.children = static_cast< uint16 >( chan_count );
    240240                eheader.size     = sizeof( nmd_node_header ) + chan_size;
    241241                stream_out.write( &eheader, sizeof( eheader ), 1 );
  • trunk/src/formats/obj_loader.cc

    r395 r406  
    207207        virtual void reset() { m_data.clear(); }
    208208        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() ); }
    210210};
    211211
Note: See TracChangeset for help on using the changeset viewer.