Ignore:
Timestamp:
07/31/14 08:08:31 (11 years ago)
Author:
epyon
Message:
  • lua::table_guard is_* utility functions
  • minor tweaks
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gfx/keyframed_mesh.cc

    r294 r296  
    9898
    9999
    100 void nv::keyframed_mesh::update( program* a_program ) const
     100void nv::keyframed_mesh::update( program* a_program )
    101101{
    102102        a_program->set_opt_uniform( "nv_interpolate", m_interpolation );
     
    123123}
    124124
    125 nv::keyframed_mesh_gpu::keyframed_mesh_gpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map, program* a_program )
     125nv::keyframed_mesh_gpu::keyframed_mesh_gpu( device* a_device, const mesh_data* a_data, const mesh_nodes_data* a_tag_map )
    126126        : keyframed_mesh( a_device, a_data, a_tag_map )
    127127        , m_loc_next_position( -1 )
     
    131131        , m_gpu_next_frame( 0xFFFFFFFF )
    132132{
    133         m_loc_next_position = a_program->get_attribute( "nv_next_position" )->get_location();
    134         m_loc_next_normal   = a_program->get_attribute( "nv_next_normal" )->get_location();
    135         m_loc_next_tangent  = a_program->try_get_attribute_location( "nv_next_tangent" );
    136133        m_va = a_device->create_vertex_array( a_data, STATIC_DRAW );
    137         vertex_buffer* vb = m_va->find_buffer( slot::POSITION );
    138         m_va->add_vertex_buffer( m_loc_next_position, vb, FLOAT, 3, 0, m_vsize, false );
    139         m_va->add_vertex_buffer( m_loc_next_normal,   vb, FLOAT, 3, sizeof( vec3 ), m_vsize, false );
    140         if ( m_has_tangent )
    141                 m_va->add_vertex_buffer( m_loc_next_tangent, vb, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false );
    142134}
    143135
     
    145137void nv::keyframed_mesh_gpu::update( uint32 ms )
    146138{
     139        if ( m_loc_next_position == -1 ) return;
    147140        animated_mesh::update( ms );
    148141
     
    157150                m_gpu_last_frame = m_last_frame;
    158151        }
    159         if ( m_gpu_next_frame != m_next_frame )
     152        if ( m_loc_next_position != -1 && m_gpu_next_frame != m_next_frame )
    160153        {
    161154                m_va->update_vertex_buffer( m_loc_next_position, m_next_frame * m_vertex_count * m_vsize );
     
    164157                m_gpu_next_frame = m_next_frame;
    165158        }
     159}
     160
     161void nv::keyframed_mesh_gpu::update( program* a_program )
     162{
     163        if ( m_loc_next_position == -1 )
     164        {
     165                m_loc_next_position = a_program->get_attribute( "nv_next_position" )->get_location();
     166                m_loc_next_normal   = a_program->get_attribute( "nv_next_normal" )->get_location();
     167                if ( m_has_tangent )
     168                        m_loc_next_tangent  = a_program->get_attribute( "nv_next_tangent" )->get_location();
     169
     170                vertex_buffer* vb = m_va->find_buffer( slot::POSITION );
     171                m_va->add_vertex_buffer( m_loc_next_position, vb, FLOAT, 3, 0, m_vsize, false );
     172                m_va->add_vertex_buffer( m_loc_next_normal,   vb, FLOAT, 3, sizeof( vec3 ), m_vsize, false );
     173                if ( m_has_tangent )
     174                        m_va->add_vertex_buffer( m_loc_next_tangent, vb, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false );
     175        }
     176        keyframed_mesh::update( a_program );
    166177}
    167178
Note: See TracChangeset for help on using the changeset viewer.