Changeset 431 for trunk/src


Ignore:
Timestamp:
07/21/15 13:31:23 (10 years ago)
Author:
epyon
Message:
  • hash storage type
  • string hash storage type
  • several minor fixes
  • more cleanups needed
Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/engine/resource_system.cc

    r399 r431  
    1515}
    1616
    17 nv::resource_id nv::resource_manager_base::load_resource( const std::string& id )
     17nv::resource_id nv::resource_manager_base::load_resource( const string_view& id )
    1818{
    1919        lua::table_guard table( m_lua, lua::path( get_storage_name(), id ) );
     
    3232                lua::table_guard sub_table( table, i+1 );
    3333                resource_id rid = load_resource( sub_table );
    34                 if ( rid != 0 ) m_names[ sub_table.get_std_string("id") ] = rid;
     34                if ( rid != 0 ) m_names[ sub_table.get_string_hash_64("id") ] = rid;
    3535        }
    3636}
    3737
    38 nv::resource_type_id nv::resource_system::register_resource_type( const std::string& /*name*/, resource_manager_base* /*manager*/ )
     38nv::resource_type_id nv::resource_system::register_resource_type( const string_view& /*name*/, resource_manager_base* /*manager*/ )
    3939{
    4040        return 0;
    4141}
    4242
    43 nv::resource_type_id nv::resource_system::get_resource_type_id( const std::string& /*name*/ ) const
     43nv::resource_type_id nv::resource_system::get_resource_type_id( const string_view& /*name*/ ) const
    4444{
    4545        return 0;
  • trunk/src/formats/assimp_loader.cc

    r428 r431  
    288288        const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
    289289        mesh_nodes_data* result = new mesh_nodes_data( make_name( "bones" ) );
    290         unordered_map< uint64, uint16 > names;
     290        hashed_table< shash64, uint16 > names;
    291291        for ( unsigned int m = 0; m < m_mesh_count; ++m )
    292292        {
  • trunk/src/formats/md3_loader.cc

    r427 r431  
    420420        uint32 node_count = uint32( md3->header.num_tags );
    421421        if ( node_count == 0 ) return nullptr;
    422         mesh_nodes_data* result = new mesh_nodes_data( m_strings ? m_strings->insert( "tags" ) : 0 );
     422        mesh_nodes_data* result = new mesh_nodes_data( m_strings ? m_strings->insert( "tags" ) : shash64() );
    423423        for ( uint32 i = 0; i < node_count; ++i )
    424424        {
  • trunk/src/formats/nmd_loader.cc

    r428 r431  
    233233        sheader.children   = 0;
    234234        sheader.size       = strings.dump_size();
    235         sheader.name       = 0;
     235        sheader.name       = shash64();
    236236        sheader.parent_id  = -1;
    237237    sheader.attributes = 0;
  • trunk/src/gfx/skeletal_mesh.cc

    r430 r431  
    177177        {
    178178                const data_channel_set* bone = (*bones)[ bi ];
    179                 bone_names[ bone->get_name() ] = bi;
     179                bone_names[ bone->get_name().value() ] = bi;
    180180                m_offsets[bi] = bone->get_transform();
    181181        }
     
    186186                sint16 bone_id = -1;
    187187
    188                 auto bi = bone_names.find( node->get_name() );
     188                auto bi = bone_names.find( node->get_name().value() );
    189189                if ( bi != bone_names.end() )
    190190                {
  • trunk/src/lua/lua_map_area.cc

    r406 r431  
    137137{
    138138        nv::map_area* ma = to_map_area( L, 1 );
    139         lua_pushstring( L, ma->id_to_string( ma->get_cell( to_coord( L, 2 ) ) ).c_str() );
     139        nv::string_view result( ma->id_to_string( ma->get_cell( to_coord( L, 2 ) ) ) );
     140        lua_pushlstring( L, result.data(), result.size() );
    140141        return 1;
    141142}
  • trunk/src/lua/lua_state.cc

    r426 r431  
    184184}
    185185
    186 uint64 nv::lua::table_guard::get_string_hash_64( string_view element, uint64 defval /*= 0 */ )
     186shash64 nv::lua::table_guard::get_string_hash_64( string_view element, uint64 defval /*= 0 */ )
    187187{
    188188        lua_getfield( m_state, -1, element.data() );
     
    196196        }
    197197        lua_pop( m_state, 1 );
    198         return result;
     198        return shash64( result );
     199}
     200
     201shash64 nv::lua::table_guard::get_string( string_view element, string_table& table, uint64 defval /*= 0 */ )
     202{
     203        lua_getfield( m_state, -1, element.data() );
     204        size_t l = 0;
     205        const char* str = nullptr;
     206        uint64 result = defval;
     207        if ( lua_type( m_state, -1 ) == LUA_TSTRING )
     208        {
     209                str = lua_tolstring( m_state, -1, &l );
     210                result = table.insert( string_view( str, l ) ).value();
     211        }
     212        lua_pop( m_state, 1 );
     213        return shash64( result );
    199214}
    200215
Note: See TracChangeset for help on using the changeset viewer.