Ignore:
Timestamp:
01/24/17 17:55:00 (8 years ago)
Author:
epyon
Message:
  • temporary_proxy implemented
  • table_guard now uses temporary_proxy as main read functionality
File:
1 edited

Legend:

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

    r529 r539  
    1818
    1919        model* gm = new model;
    20         gm->flags  = table.get< flags<32> >( "flags" );
    21         gm->attach = table.get_string_hash_64( "attach" );
    22         gm->root.set_position( table.get<vec3>( "root_position", vec3() ) );
    23         gm->root.set_orientation( vec4_to_quat( table.get<vec4>( "root_orientation", vec4(0.0f,0.0f,0.0f,1.0f) ) ) );
     20        gm->flags  = table["flags"].as< flags<32> >();
     21        gm->attach = table["attach"].get_shash64();
     22        gm->root.set_position( table["root_position"].as<vec3>() );
     23        gm->root.set_orientation( vec4_to_quat( table["root_orientation"].as<vec4>( vec4(0.0f,0.0f,0.0f,1.0f) ) ) );
    2424       
    2525        resource< mesh_data > def_data;
    26         if ( table.is_string( "path" ) )
    27                 def_data = m_rm->get< mesh_data >( table.get_string128( "path" ) );
     26        if ( table["path"].is_string() )
     27                def_data = m_rm->get< mesh_data >( table["path"].get_string128() );
    2828
    29         if ( table.is_string( "ragdoll" ) )
    30                 gm->ragdoll_id = table.get_string32( "ragdoll" );
     29        if ( table["ragdoll"].is_string() )
     30                gm->ragdoll_id = table["ragdoll"].get_string32();
    3131       
    3232        if ( table.has_field( "animator" ) )
    3333        {
    34                 gm->animator = m_rm->get< animator_data >( table.get_string( "animator" ) );
     34                gm->animator = m_rm->get< animator_data >( table["animator"].get_string() );
    3535                pose_data_set* poses = gm->animator.lock()->poses;
    3636                if ( !def_data || !def_data.lock()->node_data )
     
    4242        if ( table.has_field( "phx_mesh" ) )
    4343        {
    44                 nv::string128 cpath( table.get_string128( "phx_mesh" ) );
     44                nv::string128 cpath( table["phx_mesh"].get_string128() );
    4545                gm->phx_mesh = m_mesh_datas->get_path( cpath, def_data );
    4646        }
    4747
    48         if ( table.is_table( "model" ) )
     48        if ( table["model"].is_table() )
    4949        {
    5050                lua::table_guard model_table( table, "model" );
     
    6666        sint16 attach_id = -1;
    6767
    68         if ( table.is_string( "material" ) )
     68        if ( table["material"].is_string() )
    6969        {
    70                 nv::string128 mat_id( table.get_string128( "material" ) );
     70                nv::string128 mat_id( table["material"].get_string128() );
    7171                cmaterial = m_rm->get< material >( mat_id );
    7272                if ( !cmaterial )
     
    7474        }
    7575
    76         if ( table.is_string( "tag" ) )
    77                 node->tag = table.get_string32( "tag" );
     76        if ( table["tag"].is_string() )
     77                node->tag = table["tag"].get_string32();
    7878
    7979        if ( table.has_field( "path" ) )
    8080        {
    81                 nv::string128 cpath( table.get_string128( "path" ) );
     81                nv::string128 cpath( table["path"].get_string128() );
    8282                nv::data_node_info info;
    8383                cmesh = m_mesh_datas->get_path( cpath, def_data, &info );
     
    8686
    8787        if ( table.has_field( "phx_hextents" ) )
    88                 node->phx_hextents = table.get<vec3>( "phx_hextents", vec3() );
     88                node->phx_hextents = table["phx_hextents"].as<vec3>();
    8989        if ( table.has_field( "phx_offset" ) )
    90                 node->phx_offset = table.get<vec3>( "phx_offset", vec3() );
     90                node->phx_offset = table["phx_offset"].as<vec3>();
    9191        if ( table.has_field( "phx_mass" ) )
    92                 node->phx_mass = table.get<float>( "phx_mass", 0.0f);
     92                node->phx_mass = table["phx_mass"].as<float>( 0.0f );
    9393        if ( table.has_field( "phx_mass" ) )
    94                 node->phx_shape = nv::phx_shape( table.get<int>( "phx_shape", 0 ) );
     94                node->phx_shape = nv::phx_shape( table["phx_shape"].as<int>( 0 ) );
    9595
    9696        if ( table.has_field( "local_position" ) )
    97                 node->local.set_position( table.get<vec3>( "local_position", vec3() ) );
     97                node->local.set_position( table["local_position"].as<vec3>() );
    9898        if ( table.has_field( "local_orientation" ) )
    99                 node->local.set_orientation( vec4_to_quat( table.get<vec4>( "local_orientation", vec4( 0.0f, 0.0f, 0.0f, 1.0f ) ) ) );
     99                node->local.set_orientation( vec4_to_quat( table["local_orientation"].as<vec4>( vec4( 0.0f, 0.0f, 0.0f, 1.0f ) ) ) );
    100100
    101101        if ( table.has_field( "position" ) )
    102102        {
    103                 node->position.min = table.get<vec3>( "position", vec3() );
     103                node->position.min = table["position"].as<vec3>();
    104104                node->position.max = node->position.min;
    105105        }
    106106        if ( table.has_field( "rotation" ) )
    107107        {
    108                 node->rotation.min = table.get<vec3>( "rotation", vec3() );
     108                node->rotation.min = table["rotation"].as<vec3>();
    109109                node->rotation.max = node->rotation.min;
    110110        }
    111         if ( table.has_field( "position_min" ) )  node->position.min  = table.get<vec3>( "position_min", vec3() );
    112         if ( table.has_field( "position_max" ) )  node->position.max  = table.get<vec3>( "position_max", vec3() );
    113         if ( table.has_field( "position_dist" ) ) node->position.dist = random_dist( table.get_unsigned( "position_dist", 0 ) );
    114         if ( table.has_field( "rotation_min" ) )  node->rotation.min  = table.get<vec3>( "rotation_min", vec3() );
    115         if ( table.has_field( "rotation_max" ) )  node->rotation.max  = table.get<vec3>( "rotation_max", vec3() );
    116         if ( table.has_field( "rotation_dist" ) ) node->rotation.dist = random_dist( table.get_unsigned( "rotation_dist", 0 ) );
     111        if ( table.has_field( "position_min" ) )  node->position.min  = table["position_min"].as<vec3>();
     112        if ( table.has_field( "position_max" ) )  node->position.max  = table["position_max"].as<vec3>();
     113        if ( table.has_field( "position_dist" ) ) node->position.dist = random_dist( table["position_dist"].get_uint32() );
     114        if ( table.has_field( "rotation_min" ) )  node->rotation.min  = table["rotation_min"].as<vec3>();
     115        if ( table.has_field( "rotation_max" ) )  node->rotation.max  = table["rotation_max"].as<vec3>();
     116        if ( table.has_field( "rotation_dist" ) ) node->rotation.dist = random_dist( table["rotation_dist"].get_uint32() );
    117117
    118118        if ( table.has_field( "attach" ) )
    119119        {
    120                 if ( table.is_number( "attach" ) )
     120                if ( table["attach"].is_number() )
    121121                {
    122                         attach_id = sint16( table.get_integer( "attach", -1 ) );
     122                        attach_id = sint16( table["attach"].get_sint32( -1 ) );
    123123                        //                              parent_id = 0;
    124124                }
    125125                else if ( auto m = def_data.lock() )
    126126                {
    127                         auto it = m->node_names.find( table.get_string_hash_64( "attach" ) );
     127                        auto it = m->node_names.find( table["attach"].get_shash64() );
    128128                        if ( it != m->node_names.end() )
    129129                                attach_id = sint16( it->second + 1 );
     
    132132        }
    133133       
    134         node->nflags    = table.get< flags<16,uint16> >( "flags" );
    135         node->choice    = model_node_choice( table.get_unsigned( "choice", false ) );
    136         node->chance    = table.get_float( "chance", 1.0f );
    137         node->weight    = static_cast< uint16 >( table.get_unsigned( "weight", 1 ) );
     134        node->nflags    = table["flags"].as< flags<16,uint16> >();
     135        node->choice    = model_node_choice( table["choice"].get_uint32( 0 ) );
     136        node->chance    = table["chance"].get_f32( 1.0f );
     137        node->weight    = static_cast< uint16 >( table["weight"].get_uint32( 1 ) );
    138138        node->mesh      = cmesh;
    139139        node->attach_id = attach_id;
Note: See TracChangeset for help on using the changeset viewer.