Changeset 534 for trunk/src/formats


Ignore:
Timestamp:
01/12/17 14:41:17 (8 years ago)
Author:
epyon
Message:

CONTINUED:

  • getting rid of size_t
  • datatypes now restricted to uint32 size
  • 64-bit compatibility
  • copyright updates where modified
Location:
trunk/src/formats
Files:
3 edited

Legend:

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

    r491 r534  
    1 // Copyright (C) 2014-2015 ChaosForge Ltd
     1// Copyright (C) 2014-2017 ChaosForge Ltd
    22// http://chaosforge.org/
    33//
     
    107107        m_mesh_count = 0;
    108108        NV_LOG_NOTICE( "AssImp loading file..." );
    109         size_t size = source.size();
     109        uint32 size = static_cast< uint32 >( source.size() );
    110110        char* data  = new char[ size ];
    111111        source.read( data, size, 1 );
     
    143143}
    144144
    145 data_channel_set* nv::assimp_loader::release_mesh_data( size_t index, data_node_info& info )
     145data_channel_set* nv::assimp_loader::release_mesh_data( uint32 index, data_node_info& info )
    146146{
    147147        if ( index >= m_mesh_count ) return nullptr;
     
    149149        return m_meshes[index];
    150150}
    151 void nv::assimp_loader::load_mesh_data( data_channel_set* data, size_t index, data_node_info& info )
     151void nv::assimp_loader::load_mesh_data( data_channel_set* data, uint32 index, data_node_info& info )
    152152{
    153153        const aiMesh*  mesh  = m_data->scene->mMeshes[ index ];
     
    161161                desc.initialize< assimp_plain_vtx >();
    162162        data_channel_set_creator maccess( data );
    163         string64 name( mesh->mName.data, mesh->mName.length );
     163        string64 name( mesh->mName.data, static_cast< uint32 >( mesh->mName.length ) );
    164164        if ( mesh->mName.length == 0 )
    165165        {
     
    170170                                        if ( node->mMeshes[i] == index )
    171171                                        {
    172                                                 name.assign( node->mName.data, node->mName.length );
     172                                                name.assign( node->mName.data, static_cast< uint32 >( node->mName.length ) );
    173173                                                if ( i != 0 )
    174174                                                {
     
    215215                {
    216216                        aiBone* bone  = mesh->mBones[m];
    217                         for ( size_t w=0; w<bone->mNumWeights; w++)
     217                        for ( uint32 w=0; w<bone->mNumWeights; w++)
    218218                        {
    219219                                assimp_skinned_vtx& v = vtx[ bone->mWeights[w].mVertexId ];
    220220                                bool found = false;
    221                                 for ( size_t i = 0 ; i < 4; ++i )
     221                                for ( uint32 i = 0 ; i < 4; ++i )
    222222                                {
    223223                                        if ( v.boneweight[i] <= 0.0f )
     
    281281                        aiMesh* mesh = m_data->scene->mMeshes[mc];
    282282
    283                         NV_LOG_NOTICE( "Mesh #", mc, "   - ", string_view( static_cast<char*>( mesh->mName.data ), mesh->mName.length ) );
     283                        NV_LOG_NOTICE( "Mesh #", mc, "   - ", string_view( static_cast<char*>( mesh->mName.data ), static_cast< uint32 >( mesh->mName.length ) ) );
    284284                        NV_LOG_NOTICE( "  bones   - ", mesh->mNumBones );
    285285                        NV_LOG_NOTICE( "  uvs     - ", mesh->mNumUVComponents[0] );
     
    303303        for ( auto node : m_data->nodes )
    304304        {
    305                 NV_LOG_NOTICE( "Node : ", string_view( node->mName.data, node->mName.length ) );
     305                NV_LOG_NOTICE( "Node : ", string_view( node->mName.data, static_cast< uint32 >( node->mName.length ) ) );
    306306        }
    307307
    308308        for ( auto skeleton : m_data->skeletons )
    309309        {
    310                 NV_LOG_NOTICE( "Skeleton : ", string_view( skeleton->mName.data, skeleton->mName.length ) );
     310                NV_LOG_NOTICE( "Skeleton : ", string_view( skeleton->mName.data, static_cast< uint32 >( skeleton->mName.length ) ) );
    311311        }
    312312
     
    353353        }
    354354
    355         string_view name( ainode->mName.data, ainode->mName.length );
     355        string_view name( ainode->mName.data, static_cast< uint32 >( ainode->mName.length ) );
    356356        if ( name.starts_with( '_' ) ) return;
    357357
     
    409409                        {
    410410                                assimp_skinned_vtx& vertex = channel.data()[v];
    411                                 for ( size_t i = 0; i < 4; ++i )
     411                                for ( uint32 i = 0; i < 4; ++i )
    412412                                {
    413413                                        if ( vertex.boneweight[i] > 0.0f )
     
    430430                        int pid = bone_data[i].parent_id;
    431431                        if ( pid >= 0 )
    432                                 bone_data[i].transform = tr * bone_data[ size_t( pid ) ].transform;
     432                                bone_data[i].transform = tr * bone_data[uint32( pid ) ].transform;
    433433                        else
    434434                                bone_data[i].transform = tr;
     
    447447}
    448448
    449 mesh_nodes_data* nv::assimp_loader::release_mesh_nodes_data( size_t index /*= 0*/ )
     449mesh_nodes_data* nv::assimp_loader::release_mesh_nodes_data( uint32 index /*= 0*/ )
    450450{
    451451        if ( m_data->scene == nullptr ) return nullptr;
     
    484484}
    485485
    486 data_node_list* nv::assimp_loader::release_data_node_list( size_t /*= 0 */ )
     486data_node_list* nv::assimp_loader::release_data_node_list( uint32 /*= 0 */ )
    487487{
    488488        return release_merged_bones();
    489489}
    490490
    491 bool nv::assimp_loader::is_animated( size_t /*= 0 */ )
     491bool nv::assimp_loader::is_animated( uint32 /*= 0 */ )
    492492{
    493493        int this_is_incorrect;
     
    623623//      bool has_bones = false;
    624624//      data_channel_set* meshes = data_channel_set_creator::create_set_array( m_mesh_count, 2 );
    625 //      for ( size_t m = 0; m < m_mesh_count; ++m )
     625//      for ( uint32 m = 0; m < m_mesh_count; ++m )
    626626//      {
    627627//              const aiMesh* mesh = scene->mMeshes[ m ];
     
    635635// }
    636636
    637 nv::size_t nv::assimp_loader::get_nodes_data_count() const
     637uint32 nv::assimp_loader::get_nodes_data_count() const
    638638{
    639639        if ( m_data->scene == nullptr ) return 0;
  • trunk/src/formats/nmd_loader.cc

    r487 r534  
    1 // Copyright (C) 2014-2015 ChaosForge Ltd
     1// Copyright (C) 2014-2017 ChaosForge Ltd
    22// http://chaosforge.org/
    33//
     
    4545}
    4646
    47 data_channel_set* nv::nmd_loader::release_mesh_data( size_t index, data_node_info& info )
     47data_channel_set* nv::nmd_loader::release_mesh_data( uint32 index, data_node_info& info )
    4848{
    4949        data_channel_set* result = m_meshes[ index ];
     
    158158}
    159159
    160 mesh_nodes_data* nv::nmd_loader::release_mesh_nodes_data( size_t )
     160mesh_nodes_data* nv::nmd_loader::release_mesh_nodes_data( uint32 )
    161161{
    162162        return nullptr;
    163163}
    164164
    165 data_node_list* nv::nmd_loader::release_data_node_list( size_t )
     165data_node_list* nv::nmd_loader::release_data_node_list( uint32 )
    166166{
    167167        data_node_list* result = m_bone_data;
     
    170170}
    171171
    172 bool nv::nmd_loader::is_animated( size_t /*= 0 */ )
     172bool nv::nmd_loader::is_animated( uint32 /*= 0 */ )
    173173{
    174174        return m_pose_data_set != nullptr;
  • trunk/src/formats/obj_loader.cc

    r482 r534  
    1 // Copyright (C) 2012-2015 ChaosForge Ltd
     1// Copyright (C) 2012-2017 ChaosForge Ltd
    22// http://chaosforge.org/
    33//
     
    5252        string32 next_name;
    5353
    54         nv::size_t size;
     54        uint32 size;
    5555        bool   eof;
    5656
    5757        obj_reader();
    5858        bool read_stream( stream& str );
    59         virtual nv::size_t add_face( uint32* vi, uint32* ti, uint32* ni, nv::size_t count ) = 0;
    60         virtual nv::size_t raw_size() const = 0;
     59        virtual uint32 add_face( uint32* vi, uint32* ti, uint32* ni, uint32 count ) = 0;
     60        virtual uint32 raw_size() const = 0;
    6161        virtual void reset() = 0;
    6262        virtual const uint8* raw_pointer() const = 0;
     
    126126                        string_view scan( cline );
    127127                        scan.remove_prefix( 2 );
    128                         size_t pos = 0;
     128                        uint32 pos = 0;
    129129                        while ( pos != string_view::npos )
    130130                        {
     
    176176{
    177177        mesh_data_reader( bool normals ) : m_normals( normals ) {}
    178         virtual nv::size_t add_face( uint32* vi, uint32* ti, uint32* ni, nv::size_t count )
     178        virtual uint32 add_face( uint32* vi, uint32* ti, uint32* ni, uint32 count )
    179179        {
    180180                if ( count < 3 ) return 0; // TODO : report error?
     
    182182                // TODO : support if normals not present;
    183183                vec3 nullvec;
    184                 nv::size_t result = 0;
     184                uint32 result = 0;
    185185                // Simple triangulation - obj's shouldn't have more than quads anyway
    186186
    187187                if ( m_normals )
    188188                {
    189                         for ( nv::size_t i = 2; i < count; ++i )
     189                        for ( uint32 i = 2; i < count; ++i )
    190190                        {
    191191                                result++;
     
    197197                else
    198198                {
    199                         for ( nv::size_t i = 2; i < count; ++i )
     199                        for ( uint32 i = 2; i < count; ++i )
    200200                        {
    201201                                result++;
     
    210210        vector< VTX > m_data;
    211211        virtual void reset() { m_data.clear(); }
    212         virtual nv::size_t raw_size() const { return m_data.size() * sizeof( VTX ); }
     212        virtual uint32 raw_size() const { return m_data.size() * sizeof( VTX ); }
    213213        virtual const uint8* raw_pointer() const { return reinterpret_cast< const uint8* >( m_data.data() ); }
    214214};
     
    232232        void calculate_tangents()
    233233        {
    234                 nv::size_t count = m_data.size();
    235                 nv::size_t tcount = count / 3;
     234                uint32 count = m_data.size();
     235                uint32 tcount = count / 3;
    236236
    237237                vector< vec3 > tan1( count );
    238238                vector< vec3 > tan2( count );
    239239
    240                 for ( nv::size_t a = 0; a < tcount; ++a )
    241                 {
    242                         nv::size_t i1 = a * 3;
    243                         nv::size_t i2 = a * 3 + 1;
    244                         nv::size_t i3 = a * 3 + 2;
     240                for ( uint32 a = 0; a < tcount; ++a )
     241                {
     242                        uint32 i1 = a * 3;
     243                        uint32 i2 = a * 3 + 1;
     244                        uint32 i3 = a * 3 + 2;
    245245                        obj_vertex_vtnt& vtx1 = m_data[ i1 ];
    246246                        obj_vertex_vtnt& vtx2 = m_data[ i2 ];
     
    277277                }
    278278
    279                 for ( nv::size_t a = 0; a < count; ++a )
     279                for ( uint32 a = 0; a < count; ++a )
    280280                {
    281281                        const vec3& nv = m_data[a].normal;
     
    347347}
    348348
    349 data_channel_set* nv::obj_loader::release_mesh_data( size_t index, data_node_info& info )
     349data_channel_set* nv::obj_loader::release_mesh_data( uint32 index, data_node_info& info )
    350350{
    351351        data_channel_set* result = m_meshes[ index ];
Note: See TracChangeset for help on using the changeset viewer.