Ignore:
Timestamp:
10/23/15 19:35:39 (10 years ago)
Author:
epyon
Message:
  • resource handling rewrite
  • skeletal_mesh/mesh_data updates
File:
1 edited

Legend:

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

    r475 r477  
    1313#include "nv/core/logging.hh"
    1414
    15 void nv::skeletal_animation_entry::update_skeleton( mat4* data, uint32 a_ms_time ) const
     15void nv::skeletal_animation_entry::update_skeleton( skeleton_instance& data, uint32 a_ms_time ) const
    1616{
    1717        float  fframe   = ( a_ms_time * 0.001f ) * m_fps;
     
    3838        }
    3939
    40         m_data.animate( data, fframe );
     40        if ( data.size() == 0 )
     41                data.initialize( m_temp_anim->size() );
     42        data.animate( m_temp_anim, m_data, fframe );
    4143}
    4244
    4345void nv::skeletal_animation_entry::prepare( const mesh_nodes_data* bones )
    4446{
    45         m_data.prepare( bones );
     47        m_data.prepare( m_temp_anim, bones ? bones : m_temp_anim );
    4648}
    4749
    4850nv::skeletal_mesh::skeletal_mesh( context* a_context, const data_channel_set* a_mesh, const mesh_nodes_data* a_bone_data )
    49         : m_context( a_context ), m_bone_data( a_bone_data ), m_index_count( 0 ), m_transform( nullptr ), m_parent_id(-1)
     51        : m_skeleton( a_bone_data ? a_bone_data->size() : 0 ), m_context( a_context ), m_bone_data( a_bone_data ), m_index_count( 0 ), m_parent_id(-1)
    5052{
    5153        if ( a_mesh )
     
    5557                m_parent_id = a_mesh->get_parent_id();
    5658        }
    57         if ( m_bone_data )
    58         {
    59                 m_transform = new mat4[ m_bone_data->size() ];
    60         }
    6159}
    6260
    63 void nv::skeletal_mesh::update_animation( animation_entry* a_anim, uint32 a_anim_time )
     61void nv::skeletal_mesh::update_animation( animation_entry& a_anim, uint32 a_anim_time )
    6462{
    65         if ( m_bone_data && a_anim )
    66         {
    67                 skeletal_animation_entry * anim = static_cast<skeletal_animation_entry*>( a_anim );
    68                 anim->prepare( m_bone_data );
    69                 anim->update_skeleton( m_transform, a_anim_time );
    70         }
     63        skeletal_animation_entry& anim = static_cast<skeletal_animation_entry&>( a_anim );
     64        anim.prepare( m_bone_data );
     65        anim.update_skeleton( m_skeleton, a_anim_time );
    7166}
    7267
    73 void nv::skeletal_mesh::update( program a_program )
     68void nv::skeletal_mesh::update_program( program a_program )
    7469{
    75         if ( m_bone_data )
    76                 m_context->get_device()->set_opt_uniform_array( a_program, "nv_m_bones", m_transform, m_bone_data->size() );
     70        m_context->get_device()->set_opt_uniform_array( a_program, "nv_m_bones", m_skeleton.transforms(), m_skeleton.size() );
    7771}
    7872
    7973nv::transform nv::skeletal_mesh::get_node_transform( uint32 node_id ) const
    8074{
    81         return transform( m_transform[ node_id ] );
     75        return transform( get_node_matrix( node_id ) );
    8276}
    8377
    8478nv::mat4 nv::skeletal_mesh::get_node_matrix( uint32 node_id ) const
    8579{
    86         return m_transform[ node_id ];
     80        return m_skeleton.transforms()[ node_id ];
    8781}
Note: See TracChangeset for help on using the changeset viewer.