Ignore:
Timestamp:
09/17/15 17:19:14 (10 years ago)
Author:
epyon
Message:
  • animation time definition fixes
File:
1 edited

Legend:

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

    r458 r470  
    99#include "nv/interface/data_channel_access.hh"
    1010
     11#include "nv/core/logging.hh"
     12
    1113struct nv_key_transform { nv::transform tform; };
    1214
     
    1618        merge_keys();
    1719        uint32 max_frames = 0;
    18         for ( auto keys : m_data->m_data )
    19         {
     20
     21        nv::vector< sint16 > ids;
     22        {
     23                // TODO: simplify this shit!
     24                // The complexity here is that we cannot pre-transform in any order
     25                // as the bones depend on previous bones, but ARE NOT IN ORDER
     26                //
     27                // Either rewrite this a lot nicer, or sort the bones on creation
     28                // by tree-order.
     29
     30                ids.reserve( m_data->m_data.size() );
     31                {
     32                        nv::vector< sint16 > ids_next;
     33                        ids_next.reserve( m_data->m_data.size() );
     34                        ids_next.push_back( -1 );
     35                        while ( !ids_next.empty() )
     36                        {
     37                                sint16 pid = ids_next.back();
     38                                ids_next.pop_back();
     39                                for ( sint16 i = 0; i < sint16(m_data->m_data.size()); ++i )
     40                                        if ( m_data->m_data[i]->get_parent_id() == pid )
     41                                        {
     42                                                sint16* it = nv::find( ids.begin(), ids.end(), i );
     43                                                if ( it == ids.end() )
     44                                                {
     45                                                        ids.push_back( i );
     46                                                        ids_next.push_back( i );
     47                                                }
     48                                        }
     49                        }
     50                }
     51
     52                if ( ids.size() != m_data->m_data.size() )
     53                {
     54                        NV_LOG_WARNING( "Bad skeleton!" );
     55                }
     56        }
     57
     58        NV_LOG_DEBUG( "ID/PID" );
     59        for ( auto id : ids )
     60        {
     61                data_channel_set* keys = m_data->m_data[id];
    2062                sint16 parent_id = keys->get_parent_id();
    21                 data_channel_set* pkeys  = ( parent_id != -1 ? m_data->m_data[parent_id] : nullptr );
     63                NV_LOG_DEBUG( "Id : ", id, " PID", parent_id );
     64                data_channel_set* pkeys = ( parent_id != -1 ? m_data->m_data[parent_id] : nullptr );
    2265                size_t count     = ( keys ? keys->get_channel_size(0) : 0 );
    2366                size_t pcount    = ( pkeys ? pkeys->get_channel_size(0) : 0 );
     
    2669                {
    2770                        data_channel_access< nv_key_transform > channel_creator( keys, 0 );
     71
    2872                        nv_key_transform* channel = channel_creator.data();
    2973                        const nv_key_transform* pchannel = pkeys->get_channel(0)->data_cast< nv_key_transform >();
     
    3882        if ( m_data->m_frame_rate == 1 )
    3983        {
    40                 m_data->m_frame_rate = 32;
    41                 m_data->m_duration   = static_cast<float>( max_frames );
     84                m_data->m_frame_rate  = 32;
     85                m_data->m_frame_count = max_frames;
    4286        }
    4387
Note: See TracChangeset for help on using the changeset viewer.